| | |
| | | import com.stylefeng.guns.modular.account.unionpay.GetOpenBodySig; |
| | | import com.stylefeng.guns.modular.account.unionpay.QrCodeConfiguration; |
| | | import com.stylefeng.guns.modular.account.unionpay.Util; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineMapper; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineShiftMapper; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineSiteMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineShift; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineSite; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | private ITEnterpriseWithdrawalService enterpriseWithdrawalService; |
| | | @Autowired |
| | | private UserWithdrawalService userWithdrawalService; |
| | | private LineShiftMapper lineShiftMapper; |
| | | |
| | | @Autowired |
| | | private LineSiteMapper lineSiteMapper; |
| | | |
| | | |
| | | @Value("${callbackPath}") |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil saveData(Reassign reassign, Integer uid, Integer type) throws Exception { |
| | | public ResultUtil saveData(Reassign reassign, Integer uid, Integer type,Integer driverId) throws Exception { |
| | | type = null == type ? 2 : type;//现目前微信只支持小程序支付 |
| | | String content = reassign.getRemark(); |
| | | if (ToolUtil.isNotEmpty(content)) { |
| | |
| | | // if(null != query){ |
| | | // return ResultUtil.error("有未完成支付的改派申请"); |
| | | // } |
| | | int types=1; |
| | | int types = 1; |
| | | Reassign query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 1); |
| | | if (null != query) { |
| | | types=2; |
| | | types = 2; |
| | | // return ResultUtil.error("不能重复提交申请"); |
| | | reassignMapper.deleteById(query.getId()); |
| | | } |
| | | query = reassignMapper.query(uid, null, reassign.getOrderId(), reassign.getOrderType(), 2); |
| | | |
| | | if (null != query) { |
| | | types=2; |
| | | types = 2; |
| | | // return ResultUtil.error("您提交的申请正在处理中"); |
| | | } |
| | | //获取支付金额 |
| | |
| | | reassign.setOriginalDriverId(uid); |
| | | reassign.setOriginalCarId(driver.getCarId()); |
| | | reassign.setInsertTime(new Date()); |
| | | if(types==1){ |
| | | if (types == 1) { |
| | | this.insert(reassign); |
| | | } |
| | | // systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid, 1); |
| | |
| | | if (null != reassign.getPayType()) { |
| | | if (reassign.getPayType() == 1) {//微信支付 |
| | | reassign.setState(1); |
| | | if(ToolUtil.isEmpty(driver.getAppletsOpenId())){ |
| | | if (ToolUtil.isEmpty(driver.getAppletsOpenId())) { |
| | | return ResultUtil.errorOpenId("司机未绑定微信小程序openid,无法发起微信支付"); |
| | | } |
| | | String outTradeNo = buildCbyzxReassignOutTradeNo(reassign.getId(), reassign.getOrderType()); |
| | | JSONObject response = cbyzxOrderPayHelper.createOrder(uid, driver.getAppletsOpenId(), outTradeNo, aDouble); |
| | | if(!cbyzxOrderPayHelper.isCreateSuccess(response)){ |
| | | if (!cbyzxOrderPayHelper.isCreateSuccess(response)) { |
| | | return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response); |
| | | } |
| | | resultUtil = ResultUtil.success(response); |
| | |
| | | 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()); |
| | | 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()); |
| | | |
| | | |
| | | //修改改派通知状态 |
| | |
| | | //添加已收入明细 |
| | | // incomeService.saveData(1, orderPrivateCar.getCompanyId(), 4, orderPrivateCar.getId(), 1, reassign.getMoney()); |
| | | // qyt 改派直接推送 |
| | | pushOrderPrivate(orderPrivateCar, uid,types); |
| | | pushOrderPrivate(orderPrivateCar, uid, types); |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | |
| | | // incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney()); |
| | | |
| | | // qyt 改派直接推送 |
| | | pushOrderTaxi(orderTaxi, uid,types); |
| | | pushOrderTaxi(orderTaxi, uid, types); |
| | | break; |
| | | case 3: |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(reassign.getOrderId()); |
| | | orderCrossCity.setOldState(orderCrossCity.getState()); |
| | | orderCrossCity.setIsReassign(2); |
| | | orderCrossCity.setReassignNotice(2); |
| | | if(driverId==null){ |
| | | orderCrossCity.setState(11); |
| | | }else { |
| | | orderCrossCity.setDriverId(driverId); |
| | | } |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 4, orderCrossCity.getId(), 3, reassign.getMoney()); |
| | | |
| | | // 推送用户消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity.getUserId(), 1, orderCrossCity.getId(), 3); |
| | | // 推送司机消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3); |
| | | |
| | | case 4: |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(reassign.getOrderId()); |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | |
| | | |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(reassign.getOrderId()); |
| | | if(orderPrivateCar.getState() == 10){ |
| | | if (orderPrivateCar.getState() == 10) { |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | orderPrivateCar.setState(orderPrivateCar.getOldState()); |
| | |
| | | break; |
| | | case 2: |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId()); |
| | | if(orderTaxi.getState() == 10){ |
| | | if (orderTaxi.getState() == 10) { |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | orderTaxi.setState(orderTaxi.getOldState()); |
| | |
| | | orderTaxiService.updateById(orderTaxi); |
| | | break; |
| | | } |
| | | reassignMapper.delete(new EntityWrapper<Reassign>().eq("orderId",reassign.getOrderId()).eq("orderType",reassign.getOrderType())); |
| | | reassignMapper.delete(new EntityWrapper<Reassign>().eq("orderId", reassign.getOrderId()).eq("orderType", reassign.getOrderType())); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | if (null != reassign.getPayType()) { |
| | | if (reassign.getPayType() == 1) {//微信支付 |
| | | String[] split1 = ids.split(","); |
| | | if(ToolUtil.isEmpty(driver.getAppletsOpenId())){ |
| | | if (ToolUtil.isEmpty(driver.getAppletsOpenId())) { |
| | | return ResultUtil.errorOpenId("司机未绑定微信小程序openid,无法发起微信支付"); |
| | | } |
| | | String outTradeNo = buildCbyzxBatchReassignOutTradeNo(ids); |
| | | JSONObject response = cbyzxOrderPayHelper.createOrder(uid, driver.getAppletsOpenId(), outTradeNo, totalMoney); |
| | | if(!cbyzxOrderPayHelper.isCreateSuccess(response)){ |
| | | if (!cbyzxOrderPayHelper.isCreateSuccess(response)) { |
| | | return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response); |
| | | } |
| | | resultUtil = ResultUtil.success(response); |
| | |
| | | for (String id : split) { |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(id); |
| | | orderCrossCity.setOldState(orderCrossCity.getState()); |
| | | orderCrossCity.setState(11); |
| | | if(reassign.getNowDriverId()==null){ |
| | | orderCrossCity.setState(11); |
| | | }else { |
| | | orderCrossCity.setDriverId(reassign.getNowDriverId()); |
| | | } |
| | | |
| | | orderCrossCity.setReassignNotice(2); |
| | | orderCrossCity.setIsReassign(2); |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 4, orderCrossCity.getId(), 3, reassign.getMoney()); |
| | | |
| | | |
| | | if(reassign.getNowDriverId()!=null){ |
| | | // 推送用户消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity.getUserId(), 1, orderCrossCity.getId(), 3); |
| | | // 推送司机消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3); |
| | | } |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid, 1); |
| | | |
| | | |
| | | //开始推送调度单 |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderId", reassign.getOrderId().toString()); |
| | |
| | | for (Reassign reassign : reassigns) { |
| | | OrderCrossCity orderCrossCity1 = orderCrossCityService.selectById(reassign.getOrderId()); |
| | | orderCrossCity1.setOldState(orderCrossCity1.getState()); |
| | | orderCrossCity1.setState(11); |
| | | if(reassign.getNowDriverId()==null){ |
| | | orderCrossCity1.setState(11); |
| | | }else { |
| | | orderCrossCity1.setDriverId(reassign.getNowDriverId()); |
| | | } |
| | | orderCrossCity1.setReassignNotice(2); |
| | | orderCrossCity1.setIsReassign(2); |
| | | orderCrossCityService.updateById(orderCrossCity1); |
| | |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity1.getCompanyId(), 4, orderCrossCity1.getId(), 3, reassign.getMoney()); |
| | | |
| | | |
| | | if(reassign.getNowDriverId()!=null){ |
| | | // 推送用户消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity1.getUserId(), 1, orderCrossCity1.getId(), 3); |
| | | // 推送司机消息 |
| | | pushUtil.pushOrderReassign(orderCrossCity1.getDriverId(), 2, orderCrossCity1.getId(), 3); |
| | | } |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2 ? "支付宝" : "云闪付")) + "成功支付改派申请费用!", reassigns.get(0).getOriginalDriverId(), 1); |
| | | System.out.println("==============跨城修改改派通知状态完毕==================="); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryDriver(String orderId) throws Exception { |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String day = sdf.format(new Date()); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(new Date()); |
| | | c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), 0, 0, 0); |
| | | c.set(Calendar.MILLISECOND, 0); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | List<LineShift> lineShifts = lineShiftMapper.getOtherDriverLineShift(orderCrossCity.getLineShiftDriverId()); |
| | | List<Map<String, Object>> s = lineSiteMapper.queryOtherDriver(orderCrossCity.getLineId(), sdf.parse(day), orderCrossCity.getDriverId()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(sdf.parse(day)); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | if (ToolUtil.isNotEmpty(vehicle)) { |
| | | integers = JSON.parseArray(vehicle).toJavaList(Integer.class); |
| | | } |
| | | for (LineShift lineShift : lineShifts) { |
| | | boolean b = true; |
| | | String[] split = lineShift.getEndTime().split(":"); |
| | | calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | calendar.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | if (calendar.getTimeInMillis() < System.currentTimeMillis()) {//结束时间小于当前时间不显示 |
| | | continue; |
| | | } |
| | | |
| | | Map<String, Object> data = new HashMap<>(); |
| | | for (Map<String, Object> map : s) { |
| | | //先判断司机是否在限制接单范围内 |
| | | boolean bo = false; |
| | | for (Integer integer : integers) { |
| | | if (integer.compareTo(Integer.valueOf(map.get("driverId").toString())) == 0) { |
| | | bo = true; |
| | | break; |
| | | } |
| | | } |
| | | if (bo) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | int i = orderTaxiService.selectCount(new EntityWrapper<OrderTaxi>().eq("driverId", map.get("driverId")).in("state", Arrays.asList(2, 3, 4, 5, 11)).eq("DATE_FORMAT(travelTime, '%Y-%m-%d')", day)); |
| | | if (i > 0) { |
| | | continue; |
| | | } |
| | | i = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("driverId", map.get("driverId")).in("state", Arrays.asList(2, 3, 4, 5, 11)).eq("DATE_FORMAT(travelTime, '%Y-%m-%d')", day)); |
| | | if (i > 0) { |
| | | continue; |
| | | } |
| | | List<OrderCrossCity> driverId1 = orderCrossCityService.queryListOrder(Integer.valueOf(map.get("driverId").toString()), lineShift.getId(), Arrays.asList(5), day); |
| | | if (driverId1.size() > 0) { |
| | | continue; |
| | | } |
| | | if (Integer.valueOf(map.get("laveSeat").toString()) < orderCrossCity.getPeopleNumber()) { |
| | | continue; |
| | | } |
| | | if (lineShift.getId().intValue() == Integer.valueOf(map.get("id").toString()).intValue()) { |
| | | b = false; |
| | | String content = map.get("content").toString(); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | map.put("price", jsonObject.getString("num1")); |
| | | data = map; |
| | | list.add(data); |
| | | } |
| | | } |
| | | if (b) { |
| | | data.put("id", lineShift.getId()); |
| | | data.put("startTime", lineShift.getStartTime() + "-" + lineShift.getEndTime()); |
| | | list.add(data); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | |
| | | * @param orderTaxi |
| | | * @throws Exception |
| | | */ |
| | | public void pushOrderTaxi(OrderTaxi orderTaxi, Integer uid,int type) throws Exception { |
| | | public void pushOrderTaxi(OrderTaxi orderTaxi, Integer uid, int type) throws Exception { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | push = true; |
| | | break; |
| | | } |
| | | if (num == 18 && (state == 1 || state==11)) { |
| | | if (num == 18 && (state == 1 || state == 11)) { |
| | | System.err.println("结束改派退单-------------修改订单为取消状态"); |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2, 11); |
| | | pushUtil.pushOrderState(2, orderTaxi.getDriverId(), orderTaxi.getId(), 2, 10); |
| | |
| | | orderIds.remove(orderTaxi.getId()); |
| | | } |
| | | } |
| | | if(push){ |
| | | if (push) { |
| | | break; |
| | | } |
| | | } |
| | |
| | | * @param orderPrivateCar |
| | | * @throws Exception |
| | | */ |
| | | public void pushOrderPrivate(OrderPrivateCar orderPrivateCar, Integer uid,int type) throws Exception { |
| | | public void pushOrderPrivate(OrderPrivateCar orderPrivateCar, Integer uid, int type) throws Exception { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | push = true; |
| | | return; |
| | | } |
| | | if (num == 18 && (state == 1 || state==11)) { |
| | | if (num == 18 && (state == 1 || state == 11)) { |
| | | System.err.println("结束改派退单-------------修改订单为取消状态"); |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 11); |
| | | pushUtil.pushReassignEndCancel(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 10); |
| | |
| | | orderIds.remove(orderPrivateCar.getId()); |
| | | } |
| | | } |
| | | if(push){ |
| | | if (push) { |
| | | break; |
| | | } |
| | | } |