| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | */ |
| | | @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); |
| | |
| | | reassign.setInsertTime(new Date()); |
| | | this.insert(reassign); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid); |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + reassign.getOrderType() + reassign.getId(); |
| | | |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | reassign.setState(1); |
| | | |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/wxReassign", "APP"); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 1, aDouble, "", 1);//添加预支付数据 |
| | | String appletsOpenId = ""; |
| | | String tradeType = "APP"; |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", out_trade_no, aDouble.toString(), callbackPath + "/base/wxReassign", tradeType, appletsOpenId, ""); |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | reassign.setState(1); |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/aliReassign"); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 2, aDouble, "", 1);//添加预支付数据 |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "支付订单", out_trade_no, aDouble.toString(), callbackPath + "/base/aliReassign"); |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | | reassign.setState(2); |
| | |
| | | break; |
| | | } |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid, 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | |
| | | ids += reassign.getId() + ","; |
| | | } |
| | | ids = ids.substring(0, ids.length() - 1); |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid); |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + 3 + ids; |
| | | |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | String[] split1 = ids.split(","); |
| | | |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", ids + "_3_" + UUIDUtil.getRandomCode(5), totalMoney.toString(), "/base/wxReassign", "APP"); |
| | | for(String id : split1){ |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 1, aDouble, "", 1);//添加预支付数据 |
| | | String appletsOpenId = ""; |
| | | String tradeType = "APP"; |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", out_trade_no, totalMoney.toString(), callbackPath + "/base/wxReassign", tradeType, appletsOpenId, ""); |
| | | if(resultUtil.getCode() == 200){ |
| | | for(String id : split1){ |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 1, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(ids + "_3", 9, 5, uid.toString(), "改派订单", totalMoney, callbackPath + "/base/wxReassign", "", type, driver.getAppletsOpenId()); |
| | | // if(map.get("code").equals("200")){ |
| | | // for(String id : split1){ |
| | | // paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 1, aDouble, map.get("order_id"), 1);//添加预支付数据 |
| | | // } |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | String[] split1 = ids.split(","); |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "改派订单", "", ids + "_3_" + UUIDUtil.getRandomCode(5), totalMoney.toString(), "/base/aliReassign"); |
| | | for(String id : split1){ |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 2, aDouble, "", 1);//添加预支付数据 |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "支付订单", out_trade_no, totalMoney.toString(), callbackPath + "/base/aliReassign"); |
| | | if(resultUtil.getCode() == 200){ |
| | | for(String id : split1){ |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 2, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | |
| | | |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(ids + "_3", 10, 5, uid.toString(), "改派订单", totalMoney, callbackPath + "/base/aliReassign", "", 2, ""); |
| | | // if(map.get("code").equals("200")){ |
| | | // for(String id : split1){ |
| | | // paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 2, aDouble, map.get("order_id"), 1);//添加预支付数据 |
| | | // } |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | | for(String id : split){ |
| | |
| | | transactionDetailsService.saveData(uid, "司机改派支付", aDouble, 2, 1, 2, 3, Integer.valueOf(id)); |
| | | } |
| | | Double balance = driver.getBalance(); |
| | | Double laveBusinessMoney = driver.getLaveBusinessMoney(); |
| | | Double laveActivityMoney = driver.getLaveActivityMoney(); |
| | | if(null == balance || balance < totalMoney){ |
| | | throw new SystemException("账户余额不足"); |
| | | } |
| | | if(null != laveBusinessMoney && laveBusinessMoney.compareTo(totalMoney) >= 0){ |
| | | driver.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(totalMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | }else if(null != laveActivityMoney && laveActivityMoney.compareTo(totalMoney) >= 0){ |
| | | driver.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(new BigDecimal(totalMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | } |
| | | driver.setBalance(new BigDecimal(balance).subtract(new BigDecimal(totalMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 4, orderCrossCity.getId(), 3, reassign.getMoney()); |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid, 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void payReassign(String id, String order_id, Integer type) throws Exception { |
| | | String[] s = id.split("_"); |
| | | if(Integer.valueOf(s[1]) == 3){//跨城订单 |
| | | String[] split = s[0].split(","); |
| | | public void payReassign(String id, Integer orderType, String order_id, Integer type) throws Exception { |
| | | String[] split = id.split(","); |
| | | if(orderType == 3){//跨城订单 |
| | | List<Reassign> reassigns = this.selectBatchIds(Arrays.asList(split)); |
| | | Driver driver = driverService.selectById(reassigns.get(0).getOriginalDriverId()); |
| | | for(String key : split){ |
| | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity1.getCompanyId(), 4, orderCrossCity1.getId(), 3, reassign.getMoney()); |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功支付改派申请费用!", reassigns.get(0).getOriginalDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功支付改派申请费用!", reassigns.get(0).getOriginalDriverId()); |
| | | |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | |
| | | |
| | | |
| | | }else{//其他订单 |
| | | Reassign reassign = this.selectById(s[0]); |
| | | Reassign reassign = this.selectById(split[0]); |
| | | Driver driver = driverService.selectById(reassign.getOriginalDriverId()); |
| | | PaymentRecord query = paymentRecordService.query(1, driver.getId(), 2, reassign.getOrderId(), reassign.getOrderType(), type, 1); |
| | | if(null != query){ |
| | |
| | | incomeService.saveData(1, orderLogistics1.getCompanyId(), 4, orderLogistics1.getId(), 5, reassign.getMoney()); |
| | | break; |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功支付改派申请费用!", reassign.getOriginalDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功支付改派申请费用!", reassign.getOriginalDriverId()); |
| | | //开始推送调度单 |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("orderId", reassign.getOrderId().toString()); |