| | |
| | | */ |
| | | @Override |
| | | public ResultUtil saveData(Reassign reassign, Integer uid, Integer type) throws Exception { |
| | | type = null == type ? 2 : type;//现目前微信只支持小程序支付 |
| | | String content = reassign.getRemark(); |
| | | if(ToolUtil.isNotEmpty(content)){ |
| | | List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null); |
| | |
| | | reassign.setRemark(content); |
| | | ResultUtil resultUtil = ResultUtil.success(); |
| | | Driver driver = driverService.selectById(uid); |
| | | // TODO: 2020/11/12 司机端不控制重复提交(如果重复提交且未支付,直接将之前的数据删除) |
| | | // Reassign query = reassignMapper.query(uid, null, null, null, 1); |
| | | // if(null != query){ |
| | | // return ResultUtil.error("有未完成支付的改派申请"); |
| | | // } |
| | | Reassign query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 1); |
| | | if(null != query){ |
| | | // return ResultUtil.error("不能重复提交申请"); |
| | | reassignMapper.deleteById(query.getId()); |
| | | } |
| | | query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 2); |
| | |
| | | } |
| | | |
| | | //获取支付金额 |
| | | Double aDouble = orderService.queryReassignMoney(reassign.getOrderId(), reassign.getOrderType()); |
| | | reassign.setMoney(aDouble); |
| | | reassign.setOriginalDriverId(uid); |
| | | reassign.setOriginalCarId(driver.getCarId()); |
| | | reassign.setInsertTime(new Date()); |
| | | reassign.setState(2); |
| | | this.insert(reassign); |
| | | |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | | orderPrivateCar.setState(11); |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | | orderTaxi.setOldState(orderTaxi.getState()); |
| | | orderTaxi.setState(11); |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | | orderLogistics.setState(11); |
| | | orderLogistics.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | orderLogistics1.setOldState(orderLogistics1.getState()); |
| | | orderLogistics1.setState(11); |
| | | orderLogistics1.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics1); |
| | | break; |
| | | } |
| | | |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | | map.put("orderType", reassign.getOrderType().toString()); |
| | | List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | for(Dispatch dispatch : dispatches){ |
| | | jgPushUtil.push(2,"有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid); |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | reassign.setState(1); |
| | | ResultUtil resultUtil1 = payMoneyUtil.weixinpay("改派订单",reassign.getId()+"",reassign.getId() + "_" + reassign.getOrderType(),aDouble+"","/base/wxReassign","APP"); |
| | | //Map<String, String> map = icbcPayUtil.placeAnOrder(reassign.getId() + "_" + reassign.getOrderType(), 9, 5, uid.toString(), "改派订单", aDouble, callbackPath + "/base/wxReassign", "", type, driver.getAppletsOpenId()); |
| | | if(resultUtil1.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, reassign.getOrderId(), reassign.getOrderType(), 1, aDouble, null, 1);//添加预支付数据 |
| | | resultUtil = resultUtil1; |
| | | }else{ |
| | | resultUtil = ResultUtil.error("获取支付信息失败", ""); |
| | | } |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | reassign.setState(1); |
| | | ResultUtil resultUtil1 = payMoneyUtil.alipay("改派订单","改派订单",reassign.getId() + "_" + reassign.getOrderType(),aDouble+"","/base/aliReassign"); |
| | | //Map<String, String> map = icbcPayUtil.placeAnOrder(reassign.getId() + "_" + reassign.getOrderType(), 10, 5, uid.toString(), "改派订单", aDouble, callbackPath + "/base/aliReassign", "", 2, ""); |
| | | if(resultUtil1.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, reassign.getOrderId(), reassign.getOrderType(), 2, aDouble, null, 1);//添加预支付数据 |
| | | resultUtil = resultUtil1; |
| | | }else{ |
| | | resultUtil = ResultUtil.error("获取支付信息失败", ""); |
| | | } |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | | reassign.setState(2); |
| | | reassign.setPayTime(new Date()); |
| | | reassignMapper.updateById(reassign); |
| | | |
| | | Double balance = driver.getBalance(); |
| | | Double laveBusinessMoney = driver.getLaveBusinessMoney(); |
| | | Double laveActivityMoney = driver.getLaveActivityMoney(); |
| | | if(null == balance || balance < aDouble){ |
| | | throw new SystemException("账户余额不足"); |
| | | } |
| | | if(null != laveBusinessMoney && laveBusinessMoney.compareTo(aDouble) >= 0){ |
| | | driver.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(aDouble)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | }else if(null != laveActivityMoney && laveActivityMoney.compareTo(aDouble) >= 0){ |
| | | driver.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(new BigDecimal(aDouble)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | } |
| | | driver.setBalance(new BigDecimal(balance).subtract(new BigDecimal(aDouble)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "司机改派支付", aDouble, 2, 1, 2, reassign.getOrderType(), reassign.getOrderId()); |
| | | |
| | | |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()){ |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | | orderPrivateCar.setState(11); |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 4, orderPrivateCar.getId(), 1, reassign.getMoney()); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | | orderTaxi.setOldState(orderTaxi.getState()); |
| | | orderTaxi.setState(11); |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney()); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | | orderLogistics.setState(11); |
| | | orderLogistics.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 4, orderLogistics.getId(), orderLogistics.getType(), reassign.getMoney()); |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | orderLogistics1.setOldState(orderLogistics1.getState()); |
| | | orderLogistics1.setState(11); |
| | | orderLogistics1.setReassignNotice(2); |
| | | orderLogisticsService.updateById(orderLogistics1); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderLogistics1.getCompanyId(), 4, orderLogistics1.getId(), orderLogistics1.getType(), reassign.getMoney()); |
| | | break; |
| | | } |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | | map.put("orderType", reassign.getOrderType().toString()); |
| | | List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | for(Dispatch dispatch : dispatches){ |
| | | jgPushUtil.push(2,"有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | } |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |