| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.base.tips.SuccessTip; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverCommissionResp; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITAgentService; |
| | | import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | 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.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.model.TRechargeRecord; |
| | | import com.stylefeng.guns.modular.system.model.TRegion; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | 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.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | private HttpUtils httpUtils; |
| | | @Autowired |
| | | private TokenUtils tokenUtils; |
| | | @Autowired |
| | | private ITRechargeRecordService tRechargeRecordService; |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | */ |
| | | @RequestMapping("/areaPageUpdate") |
| | | public String areaPageUpdate(String area,String areaId,Model model) { |
| | | |
| | | String[] split = area.split("/"); |
| | | model.addAttribute("provinceName",split[0]); |
| | | model.addAttribute("cityName",split[1]); |
| | | model.addAttribute("districtName",split[2]); |
| | | |
| | | String[] split1 = areaId.split("/"); |
| | | model.addAttribute("provinceId",split1[0]); |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | |
| | | |
| | | 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); |
| | | |
| | | return PREFIX + "tDriverAreaUpdate.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面新增 |
| | | */ |
| | | @RequestMapping("/areaPageAdd") |
| | | public String areaPageAdd(String area,String areaId,Model model) { |
| | | 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>().in("parent_id", provinceIds)); |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | |
| | | 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]); |
| | | } |
| | | return PREFIX + "tDriverAreaUpdate.html"; |
| | | } |
| | | if(split1.length>2) { |
| | | model.addAttribute("districtId", split1[2]); |
| | | }else { |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | }else { |
| | | model.addAttribute("provinceName",""); |
| | | model.addAttribute("cityName","split[1]"); |
| | | model.addAttribute("districtName",""); |
| | | |
| | | /** |
| | | * 跳转区域页面新增 |
| | | */ |
| | | @RequestMapping("/areaPageAdd") |
| | | public String areaPageAdd(Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",tRegions); |
| | | model.addAttribute("provinceId",""); |
| | | model.addAttribute("cityId","split1[1]"); |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | return PREFIX + "tDriverAreaAdd.html"; |
| | | } |
| | | |
| | |
| | | public Object list(String createTime,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.ne("isException",2); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | } |
| | |
| | | public Object exceptionList(String createTime,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.eq("isException",2); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | } |
| | |
| | | if(StringUtils.hasLength(driverId)){ |
| | | wrapper.eq("inviterId",driverId); |
| | | } |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | List<TDriverCommissionResp> commissionResp = tDriverService.getTDriverCommissionResp(list); |
| | | for (TDriverCommissionResp tDriverCommissionResp : commissionResp) { |
| | |
| | | */ |
| | | @RequestMapping(value = "/ocr") |
| | | @ResponseBody |
| | | public Object ocr(String imgUrl) { |
| | | public JSONObject ocr(MultipartFile multipartFile) { |
| | | /*String accessToken = redisTemplate.opsForValue().get(TokenUtils.ACCESS_TOKEN_CACHE_KEY); |
| | | if (!StringUtils.hasLength(accessToken)) { |
| | | accessToken = tokenUtils.getSimpleAccessToken(); |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | System.err.println(jsonObject); |
| | | return jsonObject;*/ |
| | | return tDriverService.ocr(imgUrl); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String[] filename = originalFilename.split("\\."); |
| | | log.info("tupian::"+filename[0]+"//"+filename[1]); |
| | | File file= null; |
| | | try { |
| | | file = File.createTempFile(filename[0], "."+filename[1]); |
| | | multipartFile.transferTo(file); |
| | | file.deleteOnExit(); |
| | | log.info("file:"+file.getName()); |
| | | } catch (IOException e) { |
| | | log.error("ocr识别失败:{}",e.getMessage()); |
| | | } |
| | | return tDriverService.ocr(file); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(value = "充值余额") |
| | | @RequestMapping(value = "/recharge-balance") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @ResponseBody |
| | | public Object rechargeBalance(Integer id, String money) { |
| | | TDriver tDriver = tDriverService.selectById(id); |
| | | tDriver.setBackgroundBalance(new BigDecimal(money).add(tDriver.getBackgroundBalance())); |
| | | tDriverService.updateById(tDriver); |
| | | |
| | | // 添加充值记录 |
| | | TRechargeRecord tRechargeRecord = new TRechargeRecord(); |
| | | tRechargeRecord.setType(UserTypeEnum.AGENT.getCode()); |
| | | tRechargeRecord.setUserId(id); |
| | | tRechargeRecord.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tRechargeRecord.setAmount(new BigDecimal(money)); |
| | | tRechargeRecord.setPayType(2); |
| | | tRechargeRecord.setPayTime(new Date()); |
| | | tRechargeRecord.setPayStatus(2); |
| | | tRechargeRecord.setCreateTime(new Date()); |
| | | tRechargeRecord.setAgentId(Objects.requireNonNull(ShiroKit.getUser()).getId()); |
| | | tRechargeRecordService.insert(tRechargeRecord); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |