| | |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.http.server.HttpServerResponse; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.base.tips.SuccessTip; |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.common.constant.state.ManagerStatus; |
| | | import com.stylefeng.guns.core.exception.GunsException; |
| | | import com.stylefeng.guns.core.exception.ServiceExceptionEnum; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TAgentResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.enums.OrderStateEnum; |
| | | import com.stylefeng.guns.modular.system.enums.PayStatusEnum; |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.MallBook.model.*; |
| | | import com.stylefeng.guns.modular.system.util.MallBook.util.TrhRequest; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.hdf.extractor.TC; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | @Autowired |
| | | private IRechargeRecordService rechargeRecordService; |
| | | |
| | | @Autowired |
| | | private ITSystemConfigService systemConfigService; |
| | | |
| | | @Autowired |
| | | private ICompanyFundFlowService companyFundFlowService; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | |
| | | TAgent tAgent = tAgentService.selectById(tAgentId); |
| | | model.addAttribute("item",tAgent); |
| | | LogObjectHolder.me().set(tAgent); |
| | | User user = userService.selectOne(new EntityWrapper<User>().eq("role_type", 3).eq("object_id", tAgentId)); |
| | | model.addAttribute("user", user); |
| | | return PREFIX + "tAgent_edit.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping("/tAgent/areaDetail") |
| | | public String areaDetail(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>().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("/"); |
| | | // model.addAttribute("provinceName",split[0]); |
| | | // model.addAttribute("cityName",split[1]); |
| | | // if(split.length>2){ |
| | | // model.addAttribute("districtName",split[2]); |
| | | // }else { |
| | | // model.addAttribute("districtName",""); |
| | | // } |
| | | // |
| | | // model.addAttribute("provinceId",split1[0]); |
| | | // model.addAttribute("cityId",split1[1]); |
| | | // if(split1.length>2) { |
| | | // model.addAttribute("districtId", split1[2]); |
| | | // }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",""); |
| | | // model.addAttribute("districtName",""); |
| | | // |
| | | // model.addAttribute("provinceId",""); |
| | | // model.addAttribute("cityId",""); |
| | | // model.addAttribute("districtId", ""); |
| | | // } |
| | | String[] split1 = areaId.split("/"); |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",tRegions); |
| | |
| | | @RequestMapping(value = "/tAgent/update") |
| | | @ResponseBody |
| | | public Object update(TAgent tAgent) { |
| | | TAgent tAgent1 = tAgentService.selectOne(new EntityWrapper<TAgent>() |
| | | .eq("merchantName", tAgent.getMerchantName())); |
| | | if(null != tAgent1 && tAgent1.getId().compareTo(tAgent.getId()) != 0){ |
| | | return new SuccessTip(500,"该代理商已存在!"); |
| | | } |
| | | User user = userService.selectOne(new EntityWrapper<User>().eq("account", tAgent.getAccount())); |
| | | User user1 = userService.selectOne(new EntityWrapper<User>().eq("role_type", 3).eq("object_id", tAgent.getId())); |
| | | if (null != user && user.getId().compareTo(user1.getId()) != 0){ |
| | | return new SuccessTip(500,"该账号已存在!"); |
| | | } |
| | | tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); |
| | | String[] split = tAgent.getAreaId().split("/"); |
| | | // 查询省市 |
| | | // 黑龙江省/大兴安岭地区 |
| | | // 702/852 |
| | | TRegion province = tRegionService.selectById(split[0]); |
| | | tAgent.setProvinceName(province.getName()); |
| | | tAgent.setProvinceCode(province.getCode()); |
| | | TRegion city = tRegionService.selectById(split[1]); |
| | | if(Objects.isNull(city)){ |
| | | city = tRegionService.selectOne(new EntityWrapper<TRegion>() |
| | | .eq("name",split[1]) |
| | | .last("LIMIT 1")); |
| | | } |
| | | tAgent.setCityName(city.getName()); |
| | | tAgent.setCityCode(city.getCode()); |
| | | tAgentService.updateById(tAgent); |
| | | user1.setAccount(tAgent.getAccount()); |
| | | if(ToolUtil.isNotEmpty(tAgent.getPassword())){ |
| | | user1.setPassword(ShiroKit.md5(tAgent.getPassword(), user.getSalt())); |
| | | } |
| | | userService.updateById(user1); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | model.addAttribute("item", tAgent); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | model.addAttribute("socialCreditCodeExpires", roleType == 1 ? "" :Objects.isNull(tAgent.getSocialCreditCodeExpires())?"": sdf.format(tAgent.getSocialCreditCodeExpires())); |
| | | model.addAttribute("certIdExpires", roleType == 1 ? "" : sdf.format(tAgent.getCertIdExpires())); |
| | | model.addAttribute("certIdExpires", roleType == 1 ? "" : null == tAgent.getCertIdExpires() ? "" : sdf.format(tAgent.getCertIdExpires())); |
| | | Wrapper<SettlementRecord> settlementRecordWrapper = new EntityWrapper<SettlementRecord>().eq("type", roleType == 1 ? 1 : 2); |
| | | if(roleType == 2){ |
| | | settlementRecordWrapper.eq("objectId", objectId); |
| | |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | model.addAttribute("balance", jsonObject.getDoubleValue("settledAmount") / 100); |
| | | if(roleType == 1){ |
| | | model.addAttribute("marketingAmount", jsonObject.getDoubleValue("marketingAmount") / 100); |
| | | Double amount = rechargeRecordService.querSumSurplusDividedAmount(4); |
| | | model.addAttribute("marketingAmount", amount); |
| | | } |
| | | } |
| | | return PREFIX + "enterprisePage.html"; |
| | |
| | | if(0 == settledAmount){ |
| | | return ResultUtil.error("余额不足"); |
| | | } |
| | | |
| | | Double balance = 0D; |
| | | if(roleType == 1){ |
| | | balance = rechargeRecordService.queryCompanyBalance(); |
| | | }else{ |
| | | balance = rechargeRecordService.queryAgentBalance(tAgent.getId()); |
| | | } |
| | | |
| | | SettlementRecord settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setType(roleType == 1 ? 1 : 2); |
| | | if(roleType == 3){ |
| | |
| | | settlementRecord.setOrderNumber(merOrderId1); |
| | | settlementRecord.setArrivalTime(new Date()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setType(2); |
| | | companyFundFlow.setObjectType(roleType == 1 ? 1 : 2); |
| | | if(roleType == 3){ |
| | | companyFundFlow.setObjectId(tAgent.getId()); |
| | | } |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setMoney(new BigDecimal(settlementRecord.getAmount())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | return ResultUtil.success(); |
| | | } |
| | | if(2 == status){ |
| | |
| | | settlementRecord.setOrderNumber(merOrderId1); |
| | | settlementRecord.setArrivalTime(new Date()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | Integer type = settlementRecord.getType(); |
| | | Double balance = 0D; |
| | | if(type == 1){ |
| | | balance = rechargeRecordService.queryCompanyBalance(); |
| | | }else{ |
| | | balance = rechargeRecordService.queryAgentBalance(settlementRecord.getObjectId()); |
| | | } |
| | | BigDecimal bigDecimal = new BigDecimal(balance).add(new BigDecimal(settlementRecord.getAmount())); |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setType(2); |
| | | companyFundFlow.setObjectType(type); |
| | | if(type == 2){ |
| | | companyFundFlow.setObjectId(settlementRecord.getObjectId()); |
| | | } |
| | | companyFundFlow.setBalance(bigDecimal); |
| | | companyFundFlow.setMoney(new BigDecimal(settlementRecord.getAmount())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3); |
| | | |
| | | RechargeRecord rechargeRecord = new RechargeRecord(); |
| | | rechargeRecord.setCode(out_trade_no); |
| | | rechargeRecord.setType(4); |
| | |
| | | num++; |
| | | } |
| | | if("1".equals(status1)){//成功 |
| | | Double balance = rechargeRecordService.queryCompanyBalance();//平台余额 |
| | | |
| | | String merOrderId = jsonObject1.getString("merOrderId"); |
| | | rechargeRecord1.setPayTime(new Date()); |
| | | rechargeRecord1.setPayStatus(2); |
| | | rechargeRecord1.setOrderNumber(merOrderId); |
| | | rechargeRecord1.setSurplusDividedAmount(rechargeRecord1.getAmount()); |
| | | rechargeRecordService.updateById(rechargeRecord1); |
| | | |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setType(1); |
| | | companyFundFlow.setObjectType(1); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setMoney(new BigDecimal(rechargeRecord1.getAmount())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | break; |
| | | } |
| | | if("2".equals(status1) || 10 == num){//失败 |
| | |
| | | return; |
| | | } |
| | | if(1 == status){ |
| | | Double balance = rechargeRecordService.queryCompanyBalance();//平台余额 |
| | | String parameter1 = jsonObject.getString("parameter1"); |
| | | RechargeRecord rechargeRecord = rechargeRecordService.selectById(parameter1); |
| | | rechargeRecord.setPayStatus(2); |
| | |
| | | rechargeRecord.setOrderNumber(jsonObject.getString("merOrderId")); |
| | | rechargeRecord.setSurplusDividedAmount(rechargeRecord.getAmount()); |
| | | rechargeRecordService.updateById(rechargeRecord); |
| | | CompanyFundFlow companyFundFlow = new CompanyFundFlow(); |
| | | companyFundFlow.setType(1); |
| | | companyFundFlow.setObjectType(1); |
| | | companyFundFlow.setBalance(new BigDecimal(balance)); |
| | | companyFundFlow.setMoney(new BigDecimal(rechargeRecord.getAmount())); |
| | | companyFundFlow.setCreateTime(new Date()); |
| | | companyFundFlowService.insert(companyFundFlow); |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取企业流水 |
| | | * @param type |
| | | * @param time |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/tAgent/queryCompanyFundFlow") |
| | | public Object queryCompanyFundFlow(Integer type, String time){ |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<Map<String, Object>> list = companyFundFlowService.queryCompanyFundFlow(page, type, time); |
| | | page.setRecords(list); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取代理商汇总数据 |
| | | * @param id |
| | | * @param time |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/tAgent/queryAgentSummaryData") |
| | | public Map<String, Object> queryAgentSummaryData(Integer id, String time){ |
| | | return tAgentService.queryAgentSummaryData(id, time); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取代理商明细列表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/tAgent/queryAgentCompanyFundFlow") |
| | | public Object queryAgentCompanyFundFlow(Integer id){ |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<Map<String, Object>> list = companyFundFlowService.queryAgentCompanyFundFlow(page, id); |
| | | page.setRecords(list); |
| | | return super.packForBT(page); |
| | | } |
| | | } |