From 9a42cbae72259034a6cbe3a827d168a3a6f65154 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期五, 02 六月 2023 08:34:42 +0800 Subject: [PATCH] 新增加司机提现分账逻辑 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java | 43 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 38 insertions(+), 5 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java index 583abd5..47b1267 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java @@ -1158,6 +1158,8 @@ order.setCouponId(coupon.getId()); order.setDiscountAmount(coupon.getCouponPreferentialAmount()); order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount()); + }else{ + order.setPayMoney(order.getOrderMoney()); } } @@ -1169,9 +1171,6 @@ userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); userToCouponService.updateById(userToCoupon); Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); - order.setPayMoney(order.getPayMoney() - coupon.getCouponPreferentialAmount()); - order.setCouponId(coupon.getId()); - order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); Driver driver = driverService.selectById(order.getDriverId()); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); @@ -1193,7 +1192,7 @@ } this.updateById(order); - if(state == 108){//计算抽成 + if(payType == 2 && state == 108){//计算抽成 saveRevenue(order); } @@ -1628,6 +1627,40 @@ */ @Override public void completeCollection() { - this.baseMapper.completeCollection(); + List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1).eq("payType", 3)); + for (Order order : orders) { + order.setPayTime(new Date()); + if(null != order.getCouponId()){ + UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId()); + if(userToCoupon.getValidCount() > 0){ + userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); + userToCouponService.updateById(userToCoupon); + Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); + + Driver driver = driverService.selectById(order.getDriverId()); + AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); + accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); + accountChangeDetail.setUserType(2); + accountChangeDetail.setUserId(order.getDriverId()); + accountChangeDetail.setCreateTime(new Date()); + accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); + accountChangeDetail.setType(1); + accountChangeDetail.setChangeType(7); + accountChangeDetail.setOrderId(order.getId()); + accountChangeDetail.setExplain("优惠券收入"); + driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount()); + accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); + driverService.updateById(driver); + accountChangeDetailService.insert(accountChangeDetail); + } + } + this.updateById(order); + + try { + saveRevenue(order); + } catch (Exception e) { + e.printStackTrace(); + } + } } } -- Gitblit v1.7.1