| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.stylefeng.guns.modular.system.controller.util.HttpUtils; |
| | | import com.stylefeng.guns.modular.system.controller.util.TokenUtils; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.dao.AccountChangeDetailMapper; |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.model.TDriverWork; |
| | | import com.stylefeng.guns.modular.system.model.TRechargeRecord; |
| | | import com.stylefeng.guns.modular.system.model.TRegion; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | |
| | | @Autowired |
| | | private ITRechargeRecordService tRechargeRecordService; |
| | | |
| | | @Autowired |
| | | private ITSystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private AccountChangeDetailMapper accountChangeDetailMapper; |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | /** |
| | |
| | | * 跳转到修改 |
| | | */ |
| | | @RequestMapping("/tDriver_update") |
| | | public String tDriverUpdate( Integer tDriverId, Model model) { |
| | | public String tDriverUpdate( Integer tDriverId, Model model) throws ParseException { |
| | | TDriver tDriver = tDriverService.selectById(tDriverId); |
| | | TDriverResp tDriverResp = new TDriverResp(); |
| | | BeanUtils.copyProperties(tDriver,tDriverResp); |
| | | |
| | | if(Objects.nonNull(tDriverResp.getFirstCertificateTime())){ |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format1 = format.format(tDriverResp.getFirstCertificateTime()); |
| | | tDriverResp.setFirstCertificateTimeStr(format1); |
| | | } |
| | | // tDriverResp.setFirstCertificateTime(format.parse(format1)); |
| | | |
| | | // 查询邀请人 |
| | | TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId()); |
| | |
| | | TRegion city = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriver.getCityCode()) |
| | | .last("LIMIT 1")); |
| | | |
| | | tDriverResp.setArea(tDriver.getProvinceName()+"/"+tDriver.getCityName()+"/"+tDriver.getAreaName()); |
| | | if(Objects.nonNull(district) && Objects.nonNull(city)){ |
| | | tDriverResp.setAreaId(city.getParentId()+"/"+city.getId()+"/"+district.getId()); |
| | | // tDriverResp.setArea(tDriver.getProvinceName()+"/"+tDriver.getCityName()+"/"+tDriver.getAreaName()); |
| | | // if(Objects.nonNull(district) && Objects.nonNull(city)){ |
| | | // tDriverResp.setAreaId(city.getParentId()+"/"+city.getId()+"/"+district.getId()); |
| | | // } |
| | | if(StringUtils.hasLength(tDriver.getAreaName()) && !tDriver.getAreaName().equals(tDriver.getCityName())){ |
| | | tDriverResp.setArea(tDriver.getProvinceName()+"/"+tDriver.getCityName()+"/"+tDriver.getAreaName()); |
| | | }else { |
| | | tDriverResp.setArea(tDriver.getProvinceName()+"/"+tDriver.getCityName()); |
| | | } |
| | | |
| | | if(Objects.nonNull(city)){ |
| | | if(Objects.nonNull(district) && !district.getCode().equals(city.getCode())){ |
| | | tDriverResp.setAreaId(city.getParentId()+"/"+city.getId()+"/"+district.getId()); |
| | | }else { |
| | | tDriverResp.setAreaId(city.getParentId()+"/"+city.getId()); |
| | | } |
| | | } |
| | | |
| | | model.addAttribute("item",tDriverResp); |
| | |
| | | String[] split = area.split("/"); |
| | | model.addAttribute("provinceName",split[0]); |
| | | model.addAttribute("cityName",split[1]); |
| | | model.addAttribute("districtName",split[2]); |
| | | if(split.length>2){ |
| | | model.addAttribute("districtName",split[2]); |
| | | }else { |
| | | model.addAttribute("districtName",""); |
| | | } |
| | | |
| | | String[] split1 = areaId.split("/"); |
| | | model.addAttribute("provinceId",split1[0]); |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | if(split1.length>2) { |
| | | model.addAttribute("districtId", split1[2]); |
| | | }else { |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | |
| | | |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | |
| | | |
| | | // 查询区 |
| | | List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", split1[1])); |
| | | model.addAttribute("districtList",tRegions2); |
| | | |
| | | return PREFIX + "tDriverAreaUpdate.html"; |
| | |
| | | String[] split1 = areaId.split("/"); |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",tRegions); |
| | | List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | // 查询市 |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | | List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | model.addAttribute("districtList",tRegions2); |
| | | // List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | // // 查询市 |
| | | // List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | // model.addAttribute("cityList",tRegions1); |
| | | // |
| | | // // 查询区 |
| | | // List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | // List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | // model.addAttribute("districtList",tRegions2); |
| | | |
| | | if(StringUtils.hasLength(area) && StringUtils.hasLength(areaId)){ |
| | | String[] split = area.split("/"); |
| | |
| | | }else { |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", split1[1])); |
| | | model.addAttribute("districtList",tRegions2); |
| | | }else { |
| | | model.addAttribute("cityList",new ArrayList<>()); |
| | | model.addAttribute("districtList",new ArrayList<>()); |
| | | |
| | | model.addAttribute("provinceName",""); |
| | | model.addAttribute("cityName","split[1]"); |
| | | model.addAttribute("districtName",""); |
| | |
| | | tDriver.setApprovalUserId(shiroUser.getId()); |
| | | tDriver.setApprovalTime(new Date()); |
| | | tDriverService.updateById(tDriver); |
| | | |
| | | //增加积分奖励 |
| | | if(approvalStatus == 2 && null != tDriver.getInviterId()){ |
| | | TSystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 4)); |
| | | Integer num7 = JSON.parseObject(systemConfig.getContent()).getInteger("num7"); |
| | | TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId()); |
| | | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(tDriver1.getId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setChangeType(10); |
| | | accountChangeDetail.setOldData(tDriver1.getIntegral().doubleValue()); |
| | | tDriver1.setIntegral(tDriver1.getIntegral() + num7); |
| | | accountChangeDetail.setNewData(tDriver1.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("推荐奖励"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetailMapper.insert(accountChangeDetail); |
| | | tDriverService.updateById(tDriver1); |
| | | } |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |