| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService; |
| | |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyTravelItineraryRequest; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import com.stylefeng.guns.modular.taxi.service.impl.OrderTaxiServiceImpl; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private String callbackPath; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 提交改派申请 |
| | | * @param uid 申请司机id |
| | |
| | | public ResultUtil saveData(Reassign reassign, Integer uid, Integer type) throws Exception { |
| | | type = null == type ? 2 : type;//现目前微信只支持小程序支付 |
| | | String content = reassign.getRemark(); |
| | | if(ToolUtil.isNotEmpty(content)){ |
| | | if (ToolUtil.isNotEmpty(content)) { |
| | | List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null); |
| | | for(SensitiveWords s : sensitiveWords){ |
| | | for (SensitiveWords s : sensitiveWords) { |
| | | content = content.replaceAll(s.getContent(), "***"); |
| | | } |
| | | } |
| | |
| | | // return ResultUtil.error("有未完成支付的改派申请"); |
| | | // } |
| | | Reassign query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 1); |
| | | if(null != query){ |
| | | if (null != query) { |
| | | // return ResultUtil.error("不能重复提交申请"); |
| | | reassignMapper.deleteById(query.getId()); |
| | | } |
| | | query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 2); |
| | | if(null != query){ |
| | | return ResultUtil.error("您提交的申请正在处理中"); |
| | | int types=1; |
| | | if (null != query) { |
| | | types=2; |
| | | // return ResultUtil.error("您提交的申请正在处理中"); |
| | | } |
| | | |
| | | //获取支付金额 |
| | | Double aDouble = orderService.queryReassignMoney(reassign.getOrderId(), reassign.getOrderType()); |
| | | reassign.setMoney(aDouble); |
| | | reassign.setOriginalDriverId(uid); |
| | | reassign.setOriginalCarId(driver.getCarId()); |
| | | reassign.setInsertTime(new Date()); |
| | | this.insert(reassign); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | if(types==1){ |
| | | this.insert(reassign); |
| | | } |
| | | // systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | if (null != reassign.getPayType()) { |
| | | 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);//添加预支付数据 |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), "0", "/base/wxReassign", "APP", ""); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 1, 0.0, "", 1);//添加预支付数据 |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | 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("改派订单", "改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), "0", "/base/aliReassign"); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 2, 0.0, "", 1);//添加预支付数据 |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | | if (reassign.getPayType() == 3) {//余额 |
| | | reassign.setState(2); |
| | | reassign.setPayTime(new Date()); |
| | | reassignMapper.updateById(reassign); |
| | |
| | | |
| | | |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()){ |
| | | switch (reassign.getOrderType()) { |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | |
| | | orderPrivateCar.setReassignNotice(2); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | |
| | | |
| | | //添加已收入明细 |
| | | // incomeService.saveData(1, orderPrivateCar.getCompanyId(), 4, orderPrivateCar.getId(), 1, reassign.getMoney()); |
| | | // qyt 改派直接推送 |
| | | pushOrderPrivate(orderPrivateCar,uid); |
| | | pushOrderPrivate(orderPrivateCar, uid,types); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | |
| | | orderTaxi.setReassignNotice(2); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | |
| | | //添加已收入明细 |
| | | // incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney()); |
| | | |
| | | // qyt 改派直接推送 |
| | | pushOrderTaxi(orderTaxi,uid); |
| | | pushOrderTaxi(orderTaxi, uid,types); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | |
| | | // jgPushUtil.push(2,"有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | if(reassign.getPayType() == 4){ |
| | | // TODO 司机云闪付 改派调起云闪付 |
| | | Double payMoney = reassign.getMoney(); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 4, aDouble, "", 1);//添加预支付数据 |
| | | resultUtil = placeAnOrder(new BigDecimal(payMoney), 4,1,reassign.getId()); |
| | | } |
| | | // if (reassign.getPayType() == 4) { |
| | | // // TODO 司机云闪付 改派调起云闪付 |
| | | // Double payMoney = reassign.getMoney(); |
| | | // paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 4, aDouble, "", 1);//添加预支付数据 |
| | | // resultUtil = placeAnOrder(new BigDecimal(payMoney), 4, 1, reassign.getId()); |
| | | // } |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil saveDataCancel(Reassign reassign, Integer uid, Integer type) throws Exception { |
| | | Driver driver = driverService.selectById(uid); |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()) { |
| | | |
| | | private ResultUtil placeAnOrder(BigDecimal amount, Integer type,Integer orderType,Integer reassignId) throws Exception { |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | orderPrivateCar.setState(orderPrivateCar.getOldState()); |
| | | orderPrivateCar.setReassignNotice(0); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); |
| | | request.setOrderId(orderPrivateCar.getTravelId()); |
| | | request.setStatus(orderPrivateCar.getState()); |
| | | request.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderPrivateCar.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); |
| | | request.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request.setSupplierShopId(company.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | | orderTaxi.setState(orderTaxi.getOldState()); |
| | | orderTaxi.setReassignNotice(0); |
| | | orderTaxiService.updateById(orderTaxi); |
| | | Company company1 = companyService.selectById(driver.getCompanyId()); |
| | | //中台修改订单状态 |
| | | ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); |
| | | request1.setOrderId(orderTaxi.getTravelId()); |
| | | request1.setStatus(orderTaxi.getState()); |
| | | request1.setDriverId(driver.getEmpId().toString()); |
| | | if (2 == orderTaxi.getPromotion()) { |
| | | Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); |
| | | request1.setPromoterId(driver1.getEmpId().toString()); |
| | | } |
| | | request1.setSupplierShopId(company1.getEnterCode()); |
| | | OrderUtil.modifyTravelItinerary(request1); |
| | | break; |
| | | } |
| | | reassignMapper.delete(new EntityWrapper<Reassign>().eq("orderId",reassign.getOrderId()).eq("orderType",reassign.getOrderType())); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | private ResultUtil placeAnOrder(BigDecimal amount, Integer type, Integer orderType, Integer reassignId) throws Exception { |
| | | Reassign reassign = reassignMapper.selectById(reassignId); |
| | | String merOrderId = Util.getMerOrderId(qrCodeConfiguration.getMsgSrcId()); |
| | | reassign.setBillNo(merOrderId+"0"); |
| | | reassign.setBillNo(merOrderId + "0"); |
| | | reassignMapper.updateById(reassign); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); // 报文请求时间 |
| | |
| | | json.put("instMid", qrCodeConfiguration.getInstMid()); // 业务类型 |
| | | json.put("totalAmount", amount.multiply(new BigDecimal("100")).intValue()); // 支付总金额 |
| | | json.put("orderDesc", "APP下单"); // 订单描述 |
| | | json.put("srcReserve", reassignId+"_"+orderType+"_"+UUIDUtil.getRandomCode(5) + "-" +orderType+"-"+type); // 预留字段 |
| | | json.put("srcReserve", reassignId + "_" + orderType + "_" + UUIDUtil.getRandomCode(5) + "-" + orderType + "-" + type); // 预留字段 |
| | | json.put("subAppId", "wxasdasdasdasdads"); |
| | | json.put("notifyUrl", "https://zhentonggongsi.com:443/driver/api/placeOrder/notifyUrl"); |
| | | json.put("tradeType", "APP"); // 交易类型,微信必传 |
| | |
| | | |
| | | System.err.println("请求报文json:\n" + json); |
| | | String url; |
| | | if(1 == type){ |
| | | if (1 == type) { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/wx/app-pre-order";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/wx/app-pre-order"; |
| | | }else if (2 == type){ |
| | | } else if (2 == type) { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/trade/precreate";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/trade/precreate"; |
| | | }else { |
| | | } else { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/uac/app-order";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/uac/app-order"; |
| | | } |
| | | //OPEN-BODY-SIG 方式 |
| | | String result = GetOpenBodySig.sendOpenBodySig(qrCodeConfiguration.getAppId(),qrCodeConfiguration.getAppKey(),url, json.toString()); |
| | | String result = GetOpenBodySig.sendOpenBodySig(qrCodeConfiguration.getAppId(), qrCodeConfiguration.getAppKey(), url, json.toString()); |
| | | System.err.println("响应报文json:\n" + result); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | Object appPayRequest = jsonObject.get("appPayRequest"); |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private ResultUtil placeAnOrder1(BigDecimal amount, Integer type,Integer orderType,Integer reassignId) throws Exception { |
| | | private ResultUtil placeAnOrder1(BigDecimal amount, Integer type, Integer orderType, Integer reassignId) throws Exception { |
| | | Reassign reassign = reassignMapper.selectById(reassignId); |
| | | String merOrderId = Util.getMerOrderId(qrCodeConfiguration.getMsgSrcId()); |
| | | reassign.setBillNo(merOrderId+"0"); |
| | | reassign.setBillNo(merOrderId + "0"); |
| | | reassignMapper.updateById(reassign); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); // 报文请求时间 |
| | |
| | | json.put("instMid", qrCodeConfiguration.getInstMid()); // 业务类型 |
| | | json.put("totalAmount", amount.multiply(new BigDecimal("100")).intValue()); // 支付总金额 |
| | | json.put("orderDesc", "APP下单"); // 订单描述 |
| | | json.put("srcReserve", reassignId+"_"+orderType+"_"+UUIDUtil.getRandomCode(5) + "-" +1+"-"+type); // 预留字段 |
| | | json.put("srcReserve", reassignId + "_" + orderType + "_" + UUIDUtil.getRandomCode(5) + "-" + 1 + "-" + type); // 预留字段 |
| | | json.put("subAppId", "wxasdasdasdasdads"); |
| | | json.put("notifyUrl", "https://zhentonggongsi.com:443/driver/api/placeOrder/notifyUrl"); |
| | | json.put("tradeType", "APP"); // 交易类型,微信必传 |
| | |
| | | |
| | | System.err.println("请求报文json:\n" + json); |
| | | String url; |
| | | if(1 == type){ |
| | | if (1 == type) { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/wx/app-pre-order";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/wx/app-pre-order"; |
| | | }else if (2 == type){ |
| | | } else if (2 == type) { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/trade/precreate";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/trade/precreate"; |
| | | }else { |
| | | } else { |
| | | // url = "https://test-api-open.chinaums.com/v1/netpay/uac/app-order";// 测试 |
| | | url = "https://api-mop.chinaums.com/v1/netpay/uac/app-order"; |
| | | } |
| | | //OPEN-BODY-SIG 方式 |
| | | String result = GetOpenBodySig.sendOpenBodySig(qrCodeConfiguration.getAppId(),qrCodeConfiguration.getAppKey(),url, json.toString()); |
| | | String result = GetOpenBodySig.sendOpenBodySig(qrCodeConfiguration.getAppId(), qrCodeConfiguration.getAppKey(), url, json.toString()); |
| | | System.err.println("响应报文json:\n" + result); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | Object appPayRequest = jsonObject.get("appPayRequest"); |
| | |
| | | public ResultUtil saveData_(Reassign reassign, String orderIds, Integer uid, Integer type) throws Exception { |
| | | type = null == type ? 2 : type;//现目前微信只支持小程序支付 |
| | | String content = reassign.getRemark(); |
| | | if(ToolUtil.isNotEmpty(content)){ |
| | | if (ToolUtil.isNotEmpty(content)) { |
| | | List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null); |
| | | for(SensitiveWords s : sensitiveWords){ |
| | | for (SensitiveWords s : sensitiveWords) { |
| | | content = content.replaceAll(s.getContent(), "***"); |
| | | } |
| | | } |
| | |
| | | Double aDouble = orderService.queryReassignMoney(Integer.valueOf(split[0]), 3); |
| | | Double totalMoney = aDouble * split.length; |
| | | String ids = ""; |
| | | for(String id : split){ |
| | | for (String id : split) { |
| | | Reassign query = reassignMapper.query(uid, null, Integer.valueOf(id), 3, 1); |
| | | if(null != query){ |
| | | if (null != query) { |
| | | // return ResultUtil.error("不能重复提交申请"); |
| | | reassignMapper.deleteById(query.getId()); |
| | | } |
| | | query = reassignMapper.query(uid, null, Integer.valueOf(id), 3, 2); |
| | | if(null != query){ |
| | | if (null != query) { |
| | | return ResultUtil.error("您提交的申请正在处理中"); |
| | | } |
| | | |
| | |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | if (null != reassign.getPayType()) { |
| | | 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){ |
| | | for (String id : split1) { |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 1, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | if (reassign.getPayType() == 2) {//支付宝 |
| | | String[] split1 = ids.split(","); |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "改派订单", "", ids + "_3_" + UUIDUtil.getRandomCode(5), totalMoney.toString(), "/base/aliReassign"); |
| | | for(String id : split1){ |
| | | for (String id : split1) { |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 2, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | | for(String id : split){ |
| | | if (reassign.getPayType() == 3) {//余额 |
| | | for (String id : split) { |
| | | Reassign query = reassignMapper.query(uid, null, Integer.valueOf(id), 3, 1); |
| | | query.setState(2); |
| | | query.setPayTime(new Date()); |
| | |
| | | Double balance = driver.getBalance(); |
| | | Double laveBusinessMoney = driver.getLaveBusinessMoney(); |
| | | Double laveActivityMoney = driver.getLaveActivityMoney(); |
| | | if(null == balance || balance < totalMoney){ |
| | | if (null == balance || balance < totalMoney) { |
| | | throw new SystemException("账户余额不足"); |
| | | } |
| | | if(null != laveBusinessMoney && laveBusinessMoney.compareTo(totalMoney) >= 0){ |
| | | 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){ |
| | | } 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()); |
| | |
| | | |
| | | |
| | | //修改改派通知状态 |
| | | for(String id : split){ |
| | | for (String id : split) { |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(id); |
| | | orderCrossCity.setOldState(orderCrossCity.getState()); |
| | | orderCrossCity.setState(11); |
| | |
| | | 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()); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | } |
| | | if(reassign.getPayType() == 4){ |
| | | if (reassign.getPayType() == 4) { |
| | | |
| | | String[] split1 = ids.split(","); |
| | | resultUtil = placeAnOrder1(new BigDecimal(aDouble), 4,3,Integer.valueOf(split1[0])); |
| | | for(String id : split1){ |
| | | resultUtil = placeAnOrder1(new BigDecimal(aDouble), 4, 3, Integer.valueOf(split1[0])); |
| | | for (String id : split1) { |
| | | // TODO 司机云闪付 跨城改派调起云闪付 |
| | | paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 4, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | pageNum = (pageNum - 1) * size; |
| | | return reassignMapper.queryList(uid, pageNum, size); |
| | | } |
| | | |
| | | |
| | | |
| | | public static List<Integer> orderIds = new ArrayList<>(); |
| | |
| | | public void payReassign(String id, String order_id, Integer type) throws Exception { |
| | | System.out.println("改派支付完成后的操作"); |
| | | String[] s = id.split("_"); |
| | | if(Integer.valueOf(s[1]) == 3){//跨城订单 |
| | | if (Integer.valueOf(s[1]) == 3) {//跨城订单 |
| | | System.out.println("跨城订单"); |
| | | String[] split = s[0].split(","); |
| | | List<Reassign> reassigns = this.selectBatchIds(Arrays.asList(split)); |
| | | Driver driver = driverService.selectById(reassigns.get(0).getOriginalDriverId()); |
| | | for(String key : split){ |
| | | for (String key : split) { |
| | | PaymentRecord query = paymentRecordService.query(1, driver.getId(), 2, Integer.valueOf(key), 3, type, 1); |
| | | if(null != query){ |
| | | if (null != query) { |
| | | System.out.println("跨城订单开始"); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(reassigns.get(0).getOriginalDriverId(), "司机改派支付", reassigns.get(0).getMoney(), 2, 1, 2, 3, Integer.valueOf(key)); |
| | | System.out.println("==============添加交易明细完毕==================="); |
| | | for(Reassign reassign : reassigns){ |
| | | for (Reassign reassign : reassigns) { |
| | | reassign.setState(2); |
| | | reassign.setPayOrder(order_id); |
| | | reassign.setPayTime(new Date()); |
| | |
| | | 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()); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | } |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | System.out.println("==============paymentRecord完毕==================="+query); |
| | | System.out.println("==============paymentRecord完毕===================" + query); |
| | | //修改改派通知状态 |
| | | for(Reassign reassign : reassigns){ |
| | | for (Reassign reassign : reassigns) { |
| | | OrderCrossCity orderCrossCity1 = orderCrossCityService.selectById(reassign.getOrderId()); |
| | | orderCrossCity1.setOldState(orderCrossCity1.getState()); |
| | | orderCrossCity1.setState(11); |
| | | orderCrossCity1.setReassignNotice(2); |
| | | orderCrossCityService.updateById(orderCrossCity1); |
| | | System.out.println("==============跨城修改改派通知状态完毕==================="+orderCrossCity1); |
| | | System.out.println("==============跨城修改改派通知状态完毕===================" + orderCrossCity1); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity1.getCompanyId(), 4, orderCrossCity1.getId(), 3, reassign.getMoney()); |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2?"支付宝":"云闪付")) + "成功支付改派申请费用!", reassigns.get(0).getOriginalDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2 ? "支付宝" : "云闪付")) + "成功支付改派申请费用!", reassigns.get(0).getOriginalDriverId(), 1); |
| | | System.out.println("==============跨城修改改派通知状态完毕==================="); |
| | | |
| | | |
| | | // qyt 新增改派 重新推送 |
| | | |
| | | |
| | | |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } else { |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | } |
| | | |
| | | |
| | | }else{//其他订单 |
| | | } else {//其他订单 |
| | | System.out.println("其他订单"); |
| | | Reassign reassign = this.selectById(s[0]); |
| | | Driver driver = driverService.selectById(reassign.getOriginalDriverId()); |
| | | PaymentRecord query = paymentRecordService.query(1, driver.getId(), 2, reassign.getOrderId(), reassign.getOrderType(), type, 1); |
| | | System.out.println("==============paymentRecord查询==================="+query); |
| | | if(null != query){ |
| | | System.out.println("==============paymentRecord查询===================" + query); |
| | | if (null != query) { |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(reassign.getOriginalDriverId(), "司机改派支付", reassign.getMoney(), 2, 1, 2, reassign.getOrderType(), reassign.getOrderId()); |
| | | reassign.setState(2); |
| | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | System.out.println("==============paymentRecord完毕==================="+query); |
| | | System.out.println("==============paymentRecord完毕===================" + query); |
| | | |
| | | //修改改派通知状态 |
| | | switch (reassign.getOrderType()){ |
| | | switch (reassign.getOrderType()) { |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | orderPrivateCar.setOldState(orderPrivateCar.getState()); |
| | |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 4, orderPrivateCar.getId(), 1, reassign.getMoney()); |
| | | System.out.println("==============快车完毕==================="+orderPrivateCar); |
| | | System.out.println("==============快车完毕===================" + orderPrivateCar); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney()); |
| | | System.out.println("==============出租车完毕==================="+orderTaxi); |
| | | System.out.println("==============出租车完毕===================" + orderTaxi); |
| | | break; |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 4, orderLogistics.getId(), 4, reassign.getMoney()); |
| | | System.out.println("==============物流订单完毕1==================="+orderLogistics); |
| | | System.out.println("==============物流订单完毕1===================" + orderLogistics); |
| | | break; |
| | | case 5: |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(reassign.getOrderId()); |
| | |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderLogistics1.getCompanyId(), 4, orderLogistics1.getId(), 5, reassign.getMoney()); |
| | | System.out.println("==============物流订单完毕2==================="+orderLogistics1); |
| | | System.out.println("==============物流订单完毕2===================" + orderLogistics1); |
| | | break; |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" :(type == 2?"支付宝":"云闪付") ) + "成功支付改派申请费用!", reassign.getOriginalDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2 ? "支付宝" : "云闪付")) + "成功支付改派申请费用!", reassign.getOriginalDriverId(), 1); |
| | | //开始推送调度单 |
| | | 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()); |
| | | for (Dispatch dispatch : dispatches) { |
| | | jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | } |
| | | System.out.println("==============其他订单完毕==================="); |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } else { |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | @Autowired |
| | | private IPushOrderService pushOrderService; |
| | | |
| | | @Autowired |
| | | private IOpenCityService openCityService; |
| | | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | |
| | | * @param orderTaxi |
| | | * @throws Exception |
| | | */ |
| | | public void pushOrderTaxi(OrderTaxi orderTaxi, Integer uid) throws Exception{ |
| | | public void pushOrderTaxi(OrderTaxi orderTaxi, Integer uid,int type) throws Exception { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | if (ToolUtil.isNotEmpty(vehicle)) { |
| | | integers = JSON.parseArray(vehicle).toJavaList(Integer.class); |
| | | } |
| | | Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));//获取起点所属分公司 |
| | | List<PushOrder> querys = pushOrderService.querys(null, 2, query.getId());//获取需要推送的次数 |
| | | for (int i = 1; i <=6; i++) { |
| | | PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0); |
| | | OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 2, openCity.getId());//获取需要推送的次数 |
| | | int size=1; |
| | | if(type==2){ |
| | | size = 6; |
| | | } |
| | | |
| | | for (int i = 1; i <= size; i++) { |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | list = list.stream().filter(e->e.getId()!=uid).collect(Collectors.toList()); |
| | | list = list.stream().filter(e -> e.getId() != uid).collect(Collectors.toList()); |
| | | OrderTaxi orderTaxi1 = orderTaxiService.selectById(orderTaxi.getId()); |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | |
| | | } |
| | | } |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |
| | | OrderTaxi orderTaxi1 = orderTaxiService.selectById(orderTaxi.getId()); |
| | | Integer state = orderTaxi1.getState(); |
| | | if (state != 1) { |
| | | if (state != 1 || state!= 11) { |
| | | break; |
| | | } |
| | | if (i == 6 && state == 1) { |
| | | if (i == 6 && (state == 1 || state==11)) { |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); |
| | | orderTaxi1.setState(10); |
| | | orderTaxiService.updateById(orderTaxi1); |
| | |
| | | * @param orderPrivateCar |
| | | * @throws Exception |
| | | */ |
| | | public void pushOrderPrivate(OrderPrivateCar orderPrivateCar,Integer uid) throws Exception{ |
| | | public void pushOrderPrivate(OrderPrivateCar orderPrivateCar, Integer uid,int type) throws Exception { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Integer id = orderPrivateCar.getId(); |
| | | Integer orderType = orderPrivateCar.getRideType()==1?1:orderPrivateCar.getRideType()==2?9:8; |
| | | Integer orderType = orderPrivateCar.getRideType() == 1 ? 1 : orderPrivateCar.getRideType() == 2 ? 9 : 8; |
| | | orderIds.add(orderPrivateCar.getId());//添加记录,防止调用接口重复提醒无人接单 |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | if (ToolUtil.isNotEmpty(vehicle)) { |
| | | integers = JSON.parseArray(vehicle).toJavaList(Integer.class); |
| | | } |
| | | Company query = companyCityService.query(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司 |
| | | List<PushOrder> querys = pushOrderService.querys(null, 1, query.getId());//获取需要推送的次数 |
| | | for(int i = 1; i <= 6; i++){ |
| | | OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//获取需要推送的次数 |
| | | int size=1; |
| | | if(type==2){ |
| | | size=6; |
| | | } |
| | | for (int i = 1; i <= size; i++) { |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(id); |
| | | if (null == orderPrivateCar || orderPrivateCar.getState() > 1) { |
| | | if (null == orderPrivateCar || (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11)) { |
| | | break; |
| | | } |
| | | PushOrder pushOrder = pushOrderService.querys(i, 1, query.getId()).get(0); |
| | | System.out.println("pushOrder:"+pushOrder); |
| | | int finalI = i; |
| | | PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | int i2 = pushOrder.getPushTime() / 10; |
| | | if(i2==0){ |
| | | i2=1; |
| | | if (i2 == 0) { |
| | | i2 = 1; |
| | | } |
| | | for (int i1 = 0; i1 < i2 ; i1++) { |
| | | if (orderPrivateCar.getState() > 1) { |
| | | for (int i1 = 0; i1 < i2; i1++) { |
| | | if (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11) { |
| | | break; |
| | | } |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(orderType, orderPrivateCar.getServerCarModelId(), orderPrivateCar.getStartLon(), orderPrivateCar.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | list = list.stream().filter(e->e.getId()!=uid).collect(Collectors.toList()); |
| | | list = list.stream().filter(e -> e.getId() != uid).collect(Collectors.toList()); |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | |
| | | } |
| | | Thread.sleep(10000);//设置等待时间 |
| | | Integer state = orderPrivateCar.getState(); |
| | | if (state > 1) { |
| | | if (state > 1 && state != 11) { |
| | | orderIds.remove(orderPrivateCar.getId()); |
| | | return; |
| | | } |
| | | if (i == 6 && state == 1) { |
| | | if (i == 6 && (state == 1 || state==11)) { |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1); |
| | | orderPrivateCar.setState(10); |
| | | orderPrivateCarService.updateById(orderPrivateCar); |