From c399be7463c16b3787b3e591d3006628a11ab858 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 28 四月 2025 17:46:45 +0800 Subject: [PATCH] Merge branch '1.1' of http://120.76.84.145:10101/gitblit/r/java/XianNingChuXing --- DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java | 123 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 114 insertions(+), 9 deletions(-) diff --git a/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java index 3929711..7176f91 100644 --- a/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java +++ b/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java @@ -4,11 +4,9 @@ import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; import com.stylefeng.guns.modular.system.dao.DriverWorkMapper; import com.stylefeng.guns.modular.system.dao.TUseMoneyMapper; +import com.stylefeng.guns.modular.system.dao.UserCouponRecordMapper; import com.stylefeng.guns.modular.system.model.*; -import com.stylefeng.guns.modular.system.service.IDriverService; -import com.stylefeng.guns.modular.system.service.IOrderCancelService; -import com.stylefeng.guns.modular.system.service.IOrderService; -import com.stylefeng.guns.modular.system.service.IReassignService; +import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.ChinaMobileUtil; import com.stylefeng.guns.modular.system.util.PushUtil; import com.stylefeng.guns.modular.system.util.ResultUtil; @@ -45,6 +43,8 @@ @Autowired private IDriverService driverService; + @Autowired + private ICompanyService companyService; @Autowired private IReassignService reassignService; @@ -224,8 +224,6 @@ } - @Autowired - private TUseMoneyMapper useMoneyMapper; @Resource private DriverWorkMapper driverWorkMapper; @Autowired @@ -302,9 +300,9 @@ } // 抢单的时候 判断司机当前余额是否足够支付一笔软件使用费 Driver driver = driverService.selectById(uid); - List<TUseMoney> tUseMoney = useMoneyMapper.selectList(null); - - if (tUseMoney.get(0).getMoney() > driver.getBalance()) { +// List<TUseMoney> tUseMoney = useMoneyMapper.selectList(null); + Company company = companyService.selectById(driver.getCompanyId()); + if (company.getDriverRestriction() > driver.getBalance()) { // 将这个司机下线 driver.setState(1); driverService.updateById(driver); @@ -447,6 +445,113 @@ } } + @Autowired + private IPaymentRecordService paymentRecordService; + @Autowired + private ITransactionDetailsService transactionDetailsService; + @Autowired + private UserCouponRecordMapper userCouponRecordMapper; + /** + * 司机手动确认收款 + * @param orderId + * @param orderType + * @param request + * @return + */ + @ResponseBody + @PostMapping("/api/order/confirm") + @ApiOperation(value = "司机手动确认收款", tags = {"司机端-2.0新增"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), + @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"), + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil process(Integer orderId, Integer orderType, HttpServletRequest request){ + try { + Integer uid = driverService.getUserIdFormRedis(request); + if(null == uid){ + return ResultUtil.tokenErr(); + } + OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); + paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderId, 2, 1, orderTaxi.getOrderMoney(), "", 1);//添加预支付数据 + orderTaxi.setState(8); + orderTaxi.setPayType(3); + orderTaxi.setPayMoney(orderTaxi.getOrderMoney()); + Integer placeOrderWay = null; + switch (orderTaxi.getOrderSource()){ + case 2: + placeOrderWay = 4; + break; + case 3: + placeOrderWay = 4; + break; + case 6: + placeOrderWay = 1; + break; + case 7: + placeOrderWay = 2; + break; + case 5: + placeOrderWay = 3; + break; + } + // 司机收入 + double moneyTwo; + // 平台收入 + double money; + Driver driver = driverService.selectById(orderTaxi.getDriverId()); + Company company = companyService.selectById(driver.getCompanyId()); + + if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){ + double v = company.getPercentageDeduction() / 100; + money = v * orderTaxi.getOrderMoney(); + moneyTwo = orderTaxi.getOrderMoney()-money; + }else { + money = company.getFixedDeduction(); + moneyTwo = orderTaxi.getOrderMoney()-money; + } + Double orderMoney = orderTaxi.getOrderMoney(); + if (orderTaxi.getCouponId()!=null){ + UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(orderTaxi.getCouponId()); +// if(userCouponRecord.getCompanyId() != orderTaxi.getCompanyId()){ +// return ResultUtil.error("优惠券不能用于此订单", ""); +// } +// if(userCouponRecord.getState() == 2){ +// return ResultUtil.error("优惠券已使用", ""); +// } +// if(userCouponRecord.getState() == 3){ +// return ResultUtil.error("优惠券已过期", ""); +// } +// if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 2){ +// return ResultUtil.error("优惠券不能用于此类型订单", ""); +// } +// if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){ +// return ResultUtil.error("优惠券不能用于此订单", ""); +// } + orderMoney = orderMoney - userCouponRecord.getMoney(); + orderTaxi.setCouponMoney(userCouponRecord.getMoney()); + orderTaxi.setCouponId(orderTaxi.getCouponId()); + } + orderTaxi.setPayMoney(orderMoney); + orderTaxiService.updateById(orderTaxi); + + driver.setBalance(driver.getBalance() + moneyTwo); + // 新增扣除使用费记录 + transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId()); + // 司机订单收入 + transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId()); + + driverService.updateById(driver); + + pushUtil.pushOrderState(1, orderTaxi.getUserId(), orderTaxi.getId(), 2, orderTaxi.getState()); + + return ResultUtil.success(); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + /** -- Gitblit v1.7.1