| | |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | 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; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | * @Date 2023-02-20 09:18:08 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/tAgent") |
| | | @RequestMapping("") |
| | | public class TAgentController extends BaseController { |
| | | |
| | | private String PREFIX = "/system/tAgent/"; |
| | |
| | | @Autowired |
| | | private IRechargeRecordService rechargeRecordService; |
| | | |
| | | @Autowired |
| | | private ITSystemConfigService systemConfigService; |
| | | |
| | | @Autowired |
| | | private ICompanyFundFlowService companyFundFlowService; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | |
| | | /** |
| | | * 跳转到首页 |
| | | */ |
| | | @RequestMapping("") |
| | | @RequestMapping("/tAgent") |
| | | public String index(Model model) { |
| | | model.addAttribute("userType", Objects.requireNonNull(ShiroKit.getUser()).getRoleType()); |
| | | return PREFIX + "tAgent.html"; |
| | |
| | | /** |
| | | * 跳转到添加 |
| | | */ |
| | | @RequestMapping("/tAgent_add") |
| | | @RequestMapping("/tAgent/tAgent_add") |
| | | public String tAgentAdd() { |
| | | return PREFIX + "tAgent_add.html"; |
| | | } |
| | |
| | | /** |
| | | * 跳转到修改 |
| | | */ |
| | | @RequestMapping("/tAgent_update/{tAgentId}") |
| | | @RequestMapping("/tAgent/tAgent_update/{tAgentId}") |
| | | public String tAgentUpdate(@PathVariable Integer tAgentId, Model model) { |
| | | 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("/agentDetail") |
| | | @RequestMapping("/tAgent/agentDetail") |
| | | public String agentDetail(Integer agentId, Model model) { |
| | | tAgentService.detail(agentId,model); |
| | | return PREFIX + "tAgentDetail.html"; |
| | |
| | | /** |
| | | * 跳转区域页面 |
| | | */ |
| | | @RequestMapping("/areaDetail") |
| | | @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("province",tRegions); |
| | | List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | 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); |
| | |
| | | /** |
| | | * 获取列表 |
| | | */ |
| | | @RequestMapping(value = "/list") |
| | | @RequestMapping(value = "/tAgent/list") |
| | | @ResponseBody |
| | | public Object list(String principal,String principalPhone,String createTime,Integer status) { |
| | | EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime,status); |
| | |
| | | /** |
| | | * 获取列表 |
| | | */ |
| | | @RequestMapping(value = "/list-back") |
| | | @RequestMapping(value = "/tAgent/list-back") |
| | | @ResponseBody |
| | | public Object listBack(String condition) { |
| | | return tAgentService.selectList(null); |
| | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @RequestMapping(value = "/tAgent/add") |
| | | @ResponseBody |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public Object add(TAgent tAgent) { |
| | | |
| | | String[] split1 = tAgent.getArea().split("/"); |
| | | |
| | | int count = tAgentService.selectCount(new EntityWrapper<TAgent>().eq("provinceName", split1[0]).eq("cityName",split1[1])); |
| | | // int count = tAgentService.selectCount(new EntityWrapper<TAgent>() |
| | | // .eq("provinceName", split1[0]) |
| | | // .eq("cityName",split1[1]) |
| | | // .eq("districtName",sp)); |
| | | int count = tAgentService.selectCount(new EntityWrapper<TAgent>() |
| | | .eq("merchantName", tAgent.getMerchantName())); |
| | | if(count>0){ |
| | | return new SuccessTip(500,"该代理商已存在!"); |
| | | } |
| | |
| | | registerVO.setUserType("0"); |
| | | registerVO.setUserName(tAgent.getMerchantName()); |
| | | registerVO.setCertId(tAgent.getMerchantIDCode()); |
| | | registerVO.setNotifyUrl(callbackPath + "/base/driver/microenterpriseCallback"); |
| | | registerVO.setNotifyUrl(callbackPath + "/base/tAgent/microenterpriseCallback"); |
| | | TrhRequest<Register> request = new TrhRequest(); |
| | | InterfaceResponse execute = request.execute(registerVO, Register.SERVICE_CODE); |
| | | if("0000".equals(execute.getCode())){ |
| | |
| | | registerVO.setLegalPhone(tAgent.getLegalPhone()); |
| | | registerVO.setLegalPerson(tAgent.getLegalPerson()); |
| | | registerVO.setAddress(tAgent.getAddress()); |
| | | /** |
| | | * 省份编码(子商户类型非小微必填) 字段长度最长:4位 |
| | | */ |
| | | registerVO.setProvCode("0035"); |
| | | /** |
| | | * 地区编码(子商户类型非小微必填) 字段长度最长:4位 |
| | | */ |
| | | registerVO.setAreaCode("3501"); |
| | | registerVO.setProvCode(tAgent.getProvCodeEnterprise()); |
| | | registerVO.setAreaCode(tAgent.getAreaCodeEnterprise()); |
| | | registerVO.setFileNo(tAgent.getFileNo()); |
| | | registerVO.setNotifyUrl(callbackPath + "/base/driver/microenterpriseCallback"); |
| | | registerVO.setNotifyUrl(callbackPath + "/base/tAgent/microenterpriseCallback"); |
| | | registerVO.setParameter1(tAgent.getId().toString()); |
| | | |
| | | TrhRequest<Register> request = new TrhRequest(); |
| | |
| | | bindAccount.setBankAcctType(tAgent.getBankAcctType().toString()); |
| | | bindAccount.setPhone(tAgent.getPhone()); |
| | | bindAccount.setBankCode(tAgent.getBankCode()); |
| | | /** |
| | | * 省份编码 |
| | | */ |
| | | bindAccount.setProvCode("0035"); |
| | | /** |
| | | * 地区编码 |
| | | */ |
| | | bindAccount.setAreaCode("3501"); |
| | | bindAccount.setProvCode(tAgent.getProvCodeBank()); |
| | | bindAccount.setAreaCode(tAgent.getAreaCodeBank()); |
| | | TrhRequest<BindAccount> request1 = new TrhRequest(); |
| | | InterfaceResponse execute = request1.execute(bindAccount, BindAccount.SERVICE_CODE); |
| | | if("0000".equals(execute.getCode())){ |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 注册商户回调 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/tAgent/microenterpriseCallback") |
| | | public void microenterpriseCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){ |
| | | try { |
| | | if("0000".equals(interfaceResponse.getCode())) { |
| | | JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult()); |
| | | String status = jsonObject.getString("status"); |
| | | String parameter1 = jsonObject.getString("parameter1"); |
| | | TAgent tAgent = tAgentService.selectById(parameter1); |
| | | if ("2".equals(status)) { |
| | | tAgent.setMerchantStatus(2); |
| | | tAgentService.updateById(tAgent); |
| | | System.err.println("注册代理商子商户失败"); |
| | | } |
| | | if ("0".equals(status)) { |
| | | tAgent.setMerchantStatus(0); |
| | | tAgentService.updateById(tAgent); |
| | | System.err.println("注册代理商子商户处理中"); |
| | | } |
| | | if ("1".equals(status)) { |
| | | String userId = jsonObject.getString("userId"); |
| | | tAgent.setMerchantNumber(userId); |
| | | tAgent.setMerchantStatus(1); |
| | | tAgentService.updateById(tAgent); |
| | | |
| | | //开始绑定结算账户 |
| | | BindAccount bindAccount = new BindAccount(); |
| | | bindAccount.setUserId(tAgent.getMerchantNumber()); |
| | | bindAccount.setCertId(tAgent.getMerchantIDCode()); |
| | | bindAccount.setCardName(tAgent.getCardName()); |
| | | bindAccount.setCardNo(tAgent.getCardNo()); |
| | | bindAccount.setBankAcctType(tAgent.getBankAcctType().toString()); |
| | | bindAccount.setPhone(tAgent.getPhone()); |
| | | bindAccount.setBankCode(tAgent.getBankCode()); |
| | | bindAccount.setProvCode(tAgent.getProvCodeBank()); |
| | | bindAccount.setAreaCode(tAgent.getAreaCodeBank()); |
| | | TrhRequest<BindAccount> request1 = new TrhRequest(); |
| | | InterfaceResponse execute = request1.execute(bindAccount, BindAccount.SERVICE_CODE); |
| | | if ("0000".equals(execute.getCode())) { |
| | | JSONObject jsonObject1 = JSON.parseObject(execute.getResult()); |
| | | String status1 = jsonObject1.getString("status"); |
| | | if ("2".equals(status1)) { |
| | | tAgent.setBankStatus(2); |
| | | tAgentService.updateById(tAgent); |
| | | System.err.println("绑定结算账户失败"); |
| | | } |
| | | if ("1".equals(status1)) { |
| | | tAgent.setBankStatus(1); |
| | | tAgentService.updateById(tAgent); |
| | | System.err.println("绑定结算账户成功"); |
| | | } |
| | | if ("0".equals(status1)) { |
| | | tAgent.setBankStatus(0); |
| | | tAgentService.updateById(tAgent); |
| | | System.err.println("绑定结算账户处理中"); |
| | | } |
| | | } else { |
| | | System.err.println("绑定结算账户失败:" + execute.getMsg()); |
| | | } |
| | | response.setStatus(200); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("OK"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @RequestMapping(value = "/delete") |
| | | @RequestMapping(value = "/tAgent/delete") |
| | | @ResponseBody |
| | | public Object delete(@RequestParam Integer tAgentId) { |
| | | tAgentService.deleteById(tAgentId); |
| | |
| | | /** |
| | | * 修改用户状态 |
| | | */ |
| | | @RequestMapping(value = "/update-status") |
| | | @RequestMapping(value = "/tAgent/update-status") |
| | | @ResponseBody |
| | | public Object updateStatus(Integer id,Integer status) { |
| | | TAgent tAgent = tAgentService.selectById(id); |
| | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @RequestMapping(value = "/update") |
| | | @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; |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | @RequestMapping(value = "/detail/{tAgentId}") |
| | | @RequestMapping(value = "/tAgent/detail/{tAgentId}") |
| | | @ResponseBody |
| | | public Object detail(@PathVariable("tAgentId") Integer tAgentId) { |
| | | return tAgentService.selectById(tAgentId); |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "省市区查询",notes="省市区查询") |
| | | @RequestMapping(value = "/area") |
| | | @RequestMapping(value = "/tAgent/area") |
| | | @ResponseBody |
| | | public Object area() { |
| | | return tRegionService.getAreaList(); |
| | | } |
| | | |
| | | @ApiOperation(value = "省查询",notes="省查询") |
| | | @RequestMapping(value = "/areaProvince") |
| | | @RequestMapping(value = "/tAgent/areaProvince") |
| | | @ResponseBody |
| | | public Object areaProvince(Model model) { |
| | | return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | } |
| | | |
| | | @ApiOperation(value = "市区查询",notes="市区查询") |
| | | @RequestMapping(value = "/areaCity") |
| | | @RequestMapping(value = "/tAgent/areaCity") |
| | | @ResponseBody |
| | | public Object areaCity(Integer parentId) { |
| | | return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id",parentId)); |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "导出代理商列表",notes="导出代理商列表") |
| | | @RequestMapping(value = "/export") |
| | | @RequestMapping(value = "/tAgent/export") |
| | | @ResponseBody |
| | | public void export(String principal,String principalPhone,Integer status,String createTime, HttpServletResponse response) { |
| | | try { |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/uploadFile") |
| | | @RequestMapping(value = "/tAgent/uploadFile") |
| | | public String uploadFile(MultipartFile file){ |
| | | File srcFile = null; |
| | | String originalFilename = file.getOriginalFilename(); |
| | |
| | | * 跳转到企业信息页 |
| | | * @return |
| | | */ |
| | | @GetMapping("/showEnterprisePage") |
| | | @GetMapping("/tAgent/showEnterprisePage") |
| | | public String showEnterprisePage(Model model){ |
| | | ShiroUser user = ShiroKit.getUser(); |
| | | Integer objectId = user.getObjectId(); |
| | |
| | | model.addAttribute("roleType", roleType); |
| | | model.addAttribute("item", tAgent); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | model.addAttribute("socialCreditCodeExpires", roleType == 1 ? "" : sdf.format(tAgent.getSocialCreditCodeExpires())); |
| | | model.addAttribute("certIdExpires", roleType == 1 ? "" : sdf.format(tAgent.getCertIdExpires())); |
| | | model.addAttribute("socialCreditCodeExpires", roleType == 1 ? "" :Objects.isNull(tAgent.getSocialCreditCodeExpires())?"": sdf.format(tAgent.getSocialCreditCodeExpires())); |
| | | 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"; |
| | |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/withdrawCash") |
| | | @PostMapping("/tAgent/withdrawCash") |
| | | public ResultUtil withdrawCash(){ |
| | | ShiroUser user = ShiroKit.getUser(); |
| | | Integer objectId = user.getObjectId(); |
| | |
| | | InterfaceResponse execute = request.execute(queryBalance, QueryBalance.SERVICE_CODE); |
| | | if("0000".equals(execute.getCode())){ |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | double settledAmount = jsonObject.getDoubleValue("settledAmount"); |
| | | Integer settledAmount = jsonObject.getInteger("settledAmount"); |
| | | 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.setObjectId(tAgent.getId()); |
| | | } |
| | | settlementRecord.setAmount(settledAmount); |
| | | settlementRecord.setAmount(Double.valueOf(settledAmount) / 100); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | |
| | | |
| | | Withdraw withdraw = new Withdraw(); |
| | | withdraw.setUserId(tAgent.getMerchantNumber()); |
| | | withdraw.setAmount(settledAmount + ""); |
| | | withdraw.setAmount(String.valueOf(settledAmount)); |
| | | withdraw.setOrderName("账户余额提现"); |
| | | withdraw.setRemark("账户余额提现"); |
| | | withdraw.setNotifyUrl(callbackPath + "/tAgent/withdrawCashCallback"); |
| | | withdraw.setNotifyUrl(callbackPath + "/base/tAgent/withdrawCashCallback"); |
| | | withdraw.setParameter1(settlementRecord.getId().toString()); |
| | | TrhRequest<Withdraw> request1 = new TrhRequest(); |
| | | InterfaceResponse execute1 = request1.execute(withdraw, Withdraw.SERVICE_CODE);//结算(提现) |
| | |
| | | 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){ |
| | |
| | | * @param interfaceResponse |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/withdrawCashCallback") |
| | | public void withdrawCashCallback(@RequestBody InterfaceResponse interfaceResponse) { |
| | | if("0000".equals(interfaceResponse.getCode())){ |
| | | JSONObject jsonObject1 = JSON.parseObject(interfaceResponse.getResult()); |
| | | String merOrderId1 = jsonObject1.getString("merOrderId"); |
| | | Integer status = jsonObject1.getInteger("status");//0:待处理;1:成功;2:失败 |
| | | if(1 == status){ |
| | | String parameter1 = jsonObject1.getString("parameter1"); |
| | | SettlementRecord settlementRecord = settlementRecordService.selectById(parameter1); |
| | | settlementRecord.setOrderNumber(merOrderId1); |
| | | settlementRecord.setArrivalTime(new Date()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | @PostMapping("/base/tAgent/withdrawCashCallback") |
| | | public void withdrawCashCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response) { |
| | | try { |
| | | if("0000".equals(interfaceResponse.getCode())){ |
| | | JSONObject jsonObject1 = JSON.parseObject(interfaceResponse.getResult()); |
| | | String merOrderId1 = jsonObject1.getString("merOrderId"); |
| | | Integer status = jsonObject1.getInteger("status");//0:待处理;1:成功;2:失败 |
| | | if(1 == status){ |
| | | String parameter1 = jsonObject1.getString("parameter1"); |
| | | SettlementRecord settlementRecord = settlementRecordService.selectById(parameter1); |
| | | 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"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | if(2 == status){ |
| | | System.err.println("结算接口异常【提现】:" + jsonObject1.getString("statusMsg")); |
| | | } |
| | | }else{ |
| | | System.err.println("结算接口异常【提现】:" + interfaceResponse.getMsg()); |
| | | } |
| | | if(2 == status){ |
| | | System.err.println("结算接口异常【提现】:" + jsonObject1.getString("statusMsg")); |
| | | } |
| | | }else{ |
| | | System.err.println("结算接口异常【提现】:" + interfaceResponse.getMsg()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/accountRecharge") |
| | | @PostMapping("/tAgent/accountRecharge") |
| | | public ResultUtil accountRecharge(Double amount){ |
| | | 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); |
| | |
| | | deposit.setOrderName("补贴充值"); |
| | | deposit.setPayType("ALI_CB"); |
| | | deposit.setTerminalIp(InetAddress.getLocalHost().getHostAddress()); |
| | | deposit.setFrontUrl(callbackPath + "/tAgent/accountRechargeCallback"); |
| | | deposit.setNotifyUrl(callbackPath + "/tAgent/accountRechargeCallback"); |
| | | deposit.setFrontUrl(callbackPath + "/base/tAgent/accountRechargeCallback"); |
| | | deposit.setNotifyUrl(callbackPath + "/base/tAgent/accountRechargeCallback"); |
| | | deposit.setParameter1(rechargeRecord.getId().toString()); |
| | | TrhRequest<Deposit> request = new TrhRequest(); |
| | | InterfaceResponse execute = request.execute(deposit, Deposit.SERVICE_CODE); |
| | |
| | | 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){//失败 |
| | |
| | | * @param interfaceResponse |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/accountRechargeCallback") |
| | | public void accountRechargeCallback(@RequestBody InterfaceResponse interfaceResponse){ |
| | | if("0000".equals(interfaceResponse.getCode())){ |
| | | JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult()); |
| | | Integer status = jsonObject.getInteger("status"); |
| | | if(2 == status){ |
| | | System.err.println("支付异常"); |
| | | return; |
| | | @PostMapping("/base/tAgent/accountRechargeCallback") |
| | | public void accountRechargeCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){ |
| | | try { |
| | | if("0000".equals(interfaceResponse.getCode())){ |
| | | JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult()); |
| | | Integer status = jsonObject.getInteger("status"); |
| | | if(2 == status){ |
| | | System.err.println("支付异常"); |
| | | return; |
| | | } |
| | | if(1 == status){ |
| | | Double balance = rechargeRecordService.queryCompanyBalance();//平台余额 |
| | | String parameter1 = jsonObject.getString("parameter1"); |
| | | RechargeRecord rechargeRecord = rechargeRecordService.selectById(parameter1); |
| | | rechargeRecord.setPayStatus(2); |
| | | rechargeRecord.setPayTime(new Date()); |
| | | 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"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | }else{ |
| | | System.err.println(interfaceResponse.getMsg()); |
| | | } |
| | | if(1 == status){ |
| | | String parameter1 = jsonObject.getString("parameter1"); |
| | | RechargeRecord rechargeRecord = rechargeRecordService.selectById(parameter1); |
| | | rechargeRecord.setPayStatus(2); |
| | | rechargeRecord.setPayTime(new Date()); |
| | | rechargeRecord.setOrderNumber(jsonObject.getString("merOrderId")); |
| | | rechargeRecord.setSurplusDividedAmount(rechargeRecord.getAmount()); |
| | | rechargeRecordService.updateById(rechargeRecord); |
| | | } |
| | | }else{ |
| | | System.err.println(interfaceResponse.getMsg()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取企业流水 |
| | | * @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); |
| | | } |
| | | } |