From 0d8b60c9ed72d996280688a82ffa8eac3afbbff9 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 02 六月 2023 15:28:24 +0800
Subject: [PATCH] 新增加充值和提现功能
---
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java | 218 +++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 167 insertions(+), 51 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 4416d6b..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
@@ -13,12 +13,8 @@
import com.supersavedriving.driver.modular.system.util.mongodb.model.Location;
import com.supersavedriving.driver.modular.system.warpper.*;
import com.supersavedriving.driver.core.util.ToolUtil;
-import com.supersavedriving.driver.modular.system.util.*;
import com.supersavedriving.driver.modular.system.util.GaoDe.model.District;
import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil;
-import com.supersavedriving.driver.modular.system.warpper.*;
-import com.supersavedriving.driver.modular.system.model.*;
-import com.supersavedriving.driver.modular.system.service.*;
import com.supersavedriving.driver.modular.system.util.PushUtil;
import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper;
import com.supersavedriving.driver.modular.system.warpper.HallOrderList;
@@ -94,6 +90,12 @@
@Autowired
private IRevenueService revenueService;
+ @Autowired
+ private ICouponService couponService;
+
+ @Autowired
+ private IUserToCouponService userToCouponService;
+
private Map<String, Timer> timerMap = new HashMap<>();
@@ -134,7 +136,7 @@
*/
int count = this.selectCount(new EntityWrapper<Order>().eq("userPhone", addOrderWarpper.getPhone()).eq("status", 1).in("state", Arrays.asList(101, 102, 103, 104, 105, 106, 201)));
if(count > 0){
- return ResultUtil.error("该用户还有未完成的订单");
+ return ResultUtil.error("该用户还有未完成的订单", "");
}
Driver driver = driverService.selectById(uid);
DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
@@ -166,7 +168,7 @@
if(ToolUtil.isNotEmpty(addOrderWarpper.getEndAddress())){
Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), order.getEndLng() + "," + order.getEndLat(), 1);
if(null == distance){
- return ResultUtil.error("获取预估距离出错");
+ return ResultUtil.error("获取预估距离出错", "");
}
d = Double.valueOf(distance.get("distance")) / 1000;
order.setEstimatedMileage(d);
@@ -190,7 +192,13 @@
pushUtil.pushOrderStatus(uid, 2, order.getId(), order.getStatus());
}else{
//开始推单
- pushOrder(order);
+ Order finalOrder = order;
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ pushOrder(finalOrder);
+ }
+ }).start();
}
return ResultUtil.success(order.getState() == 102 ? order.getId() : null);
}
@@ -535,6 +543,9 @@
String value = redisUtil.getValue("DRIVER" + uid);
List<HallOrderList> hallOrderLists = this.baseMapper.queryOrderHall(pageNum, pageSize);
hallOrderLists.forEach(hallOrderList -> {
+ if(ToolUtil.isEmpty(hallOrderList.getAvatar())){
+ hallOrderList.setAvatar("https://csxdj.obs.cn-south-1.myhuaweicloud.com:443/66cc269703a84e4da87fb21e2c21ab1f.png");
+ }
hallOrderList.setCurrentDistance(0D);
if(ToolUtil.isNotEmpty(value)){
Map<String, Double> distance = GeodesyUtil.getDistance(hallOrderList.getStartLng() + "," + hallOrderList.getStartLat(), value);
@@ -571,7 +582,7 @@
orderRefusal.setOrderId(orderId);
orderRefusalService.insert(orderRefusal);
- Driver driver = driverService.selectById(order.getDriverId());
+ Driver driver = driverService.selectById(uid);
//扣除积分
SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4));
if(null != systemConfig) {
@@ -582,8 +593,10 @@
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
- accountChangeDetail.setUserId(order.getDriverId());
+ accountChangeDetail.setUserId(uid);
accountChangeDetail.setType(2);
+ accountChangeDetail.setChangeType(2);
+ accountChangeDetail.setOrderId(orderId);
accountChangeDetail.setOldData(null == driver.getIntegral() ? 0 : driver.getIntegral().doubleValue());
driver.setIntegral((null == driver.getIntegral() ? 0 : driver.getIntegral()) - num10);
accountChangeDetail.setNewData(driver.getIntegral().doubleValue());
@@ -626,7 +639,7 @@
redisUtil.unlock();
return ResultUtil.error("订单已被取消");
}
- if(state != 101){
+ if(state != 101 && state != 201){
redisUtil.unlock();
return ResultUtil.error("手速慢了哦");
}
@@ -641,6 +654,7 @@
if(null != order.getUserId()){
AppUser appUser = appUserService.selectById(order.getUserId());
appUser.setCancelCount(0);
+ appUser.setIsException(1);
appUserService.updateById(appUser);
}
@@ -714,9 +728,12 @@
if(orderInfoWarpper.getTravelTime() == null){
orderInfoWarpper.setTravelTime(0);
}
- AppUser appUser = appUserService.selectById(uid);
- orderInfoWarpper.setBalance(appUser.getAccountBalance());
+ AppUser appUser = appUserService.selectById(orderInfoWarpper.getUserId());
+ orderInfoWarpper.setBalance(null == appUser ? 0D : appUser.getAccountBalance());
orderInfoWarpper.setCurrentDistance(0D);
+ if(ToolUtil.isEmpty(orderInfoWarpper.getAvatar())){
+ orderInfoWarpper.setAvatar("https://csxdj.obs.cn-south-1.myhuaweicloud.com:443/66cc269703a84e4da87fb21e2c21ab1f.png");
+ }
String value = redisUtil.getValue("DRIVER" + uid);
orderInfoWarpper.setPickUpTime(0);
if(ToolUtil.isNotEmpty(value)){
@@ -746,6 +763,10 @@
}
if(order.getState() == 201){
return ResultUtil.error("订单正在转单中");
+ }
+ if(order.getState() == 301){
+ redisUtil.unlock();
+ return ResultUtil.error("订单已被取消");
}
order.setState(processOperationsWarpper.getState());
switch (processOperationsWarpper.getState()){
@@ -908,7 +929,11 @@
pushOrderInfoWarpper.setDriverLat(split[1]);
pushOrderInfoWarpper.setDriverLng(split[0]);
}
- pushOrderInfoWarpper.setWaitTime(order.getWaitTime());
+ int w = 0;
+ if(null != order.getStartWaitTime()){
+ w = Double.valueOf((System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000).intValue();
+ }
+ pushOrderInfoWarpper.setWaitTime(order.getWaitTime() + w);
pushOrderInfoWarpper.setState(order.getState());
pushOrderInfoWarpper.setActualMileage(Double.valueOf(order.getActualMileage() / 1000));
pushOrderInfoWarpper.setTravelTime(0);
@@ -916,10 +941,16 @@
int travelTime = Double.valueOf((System.currentTimeMillis() - order.getStartTime().getTime()) / 60000).intValue();
pushOrderInfoWarpper.setTravelTime(travelTime);
}
- pushUtil.pushOrderInfo(uid, 2, pushOrderInfoWarpper);
if(null != order.getUserId()){
pushUtil.pushOrderInfo(order.getUserId(), 1, pushOrderInfoWarpper);
}
+ if(order.getState() == 301){//司机取消不推送给司机
+ CancelOrder cancelOrder = cancelOrderService.selectOne(new EntityWrapper<CancelOrder>().eq("orderId", order.getId()).eq("status", 1));
+ if(null != cancelOrder && cancelOrder.getUserType() == 2){
+ return;
+ }
+ }
+ pushUtil.pushOrderInfo(uid, 2, pushOrderInfoWarpper);
}
},0, 10000);
timerMap.put(orderId.toString(), timer);
@@ -956,7 +987,13 @@
orderTransferService.insert(orderTransfer);
//开始派单
- pushOrder(order);
+ Order finalOrder = order;
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ pushOrder(finalOrder);
+ }
+ }).start();
return ResultUtil.success();
}
@@ -1055,6 +1092,8 @@
driver.setServerStatus(1);
driverService.updateById(driver);
}
+
+ pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getStatus());
return ResultUtil.success();
}
@@ -1104,21 +1143,56 @@
* @throws Exception
*/
@Override
- public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer state) throws Exception {
+ public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer payType, Integer state) throws Exception {
List<Integer> s = Arrays.asList(107, 108);
if(!s.contains(state)){
return ResultUtil.error("操作失败");
}
Order order = this.selectById(orderId);
order.setState(state);
- if(state == 108){
+
+ if(payType == 2 && state == 107){
order.setPayType(3);
+ Coupon coupon = userToCouponService.queryCoupon(order.getUserId(), order.getOrderMoney());
+ if(null != coupon){
+ order.setCouponId(coupon.getId());
+ order.setDiscountAmount(coupon.getCouponPreferentialAmount());
+ order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount());
+ }else{
+ order.setPayMoney(order.getOrderMoney());
+ }
+ }
+
+ if(payType == 2 && state == 108){
order.setPayTime(new Date());
- order.setPayMoney(order.getOrderMoney() - order.getDiscountAmount());
+ 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);
- if(state == 108){//计算抽成
+ if(payType == 2 && state == 108){//计算抽成
saveRevenue(order);
}
@@ -1165,15 +1239,16 @@
if(num1 > 0){
Driver driver1 = driverService.selectById(appUser.getInviterId());
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver1.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver1.getCommission());
+ accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver1.setCommission(driver1.getCommission() + num1);
- accountChangeDetail.setNewData(driver1.getCommission());
+ accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
driverService.updateById(driver1);
accountChangeDetailService.saveData(accountChangeDetail);
@@ -1192,9 +1267,9 @@
//开始处理层级抽佣
if(null != driver.getInviterType() && driver.getInviterType() == 2){
Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机
- if(null != driver1.getInviterType() && driver1.getInviterType() == 2){
+ if(null != driver1 && null != driver1.getInviterType() && driver1.getInviterType() == 2){
Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机
- if(null != driver2.getInviterType() && driver2.getInviterType() == 2){
+ if(null != driver2 && null != driver2.getInviterType() && driver2.getInviterType() == 2){
Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机
Double num5 = jsonObject1.getDouble("num5");
Double num6 = jsonObject1.getDouble("num6");
@@ -1211,15 +1286,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver1.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver1.getCommission());
+ accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver1.setCommission(driver1.getCommission() + num5);
- accountChangeDetail.setNewData(driver1.getCommission());
+ accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
driverService.updateById(driver1);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num5 ? num3 - num5 : 0);
@@ -1236,15 +1312,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver2.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver2.getCommission());
+ accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver2.setCommission(driver2.getCommission() + num6);
- accountChangeDetail.setNewData(driver2.getCommission());
+ accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
driverService.updateById(driver2);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num6 ? num3 - num6 : 0);
@@ -1261,15 +1338,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver3.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver3.getCommission());
+ accountChangeDetail.setOldData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver3.setCommission(driver3.getCommission() + num7);
- accountChangeDetail.setNewData(driver3.getCommission());
+ accountChangeDetail.setNewData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
driverService.updateById(driver3);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num7 ? num3 - num7 : 0);
@@ -1289,15 +1367,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver1.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver1.getCommission());
+ accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver1.setCommission(driver1.getCommission() + num3_);
- accountChangeDetail.setNewData(driver1.getCommission());
+ accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
driverService.updateById(driver1);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num3_ ? num3 - num3_ : 0);
@@ -1314,15 +1393,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver2.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver2.getCommission());
+ accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver2.setCommission(driver2.getCommission() + num4);
- accountChangeDetail.setNewData(driver2.getCommission());
+ accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
driverService.updateById(driver2);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num4 ? num3 - num4 : 0);
@@ -1342,15 +1422,16 @@
revenueService.insert(revenue);
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver1.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(5);
- accountChangeDetail.setOldData(driver1.getCommission());
+ accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
accountChangeDetail.setExplain("订单分佣收入");
accountChangeDetail.setCreateTime(new Date());
driver1.setCommission(driver1.getCommission() + num2_);
- accountChangeDetail.setNewData(driver1.getCommission());
+ accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
driverService.updateById(driver1);
accountChangeDetailService.saveData(accountChangeDetail);
num3 = (num3 >= num2_ ? num3 - num2_ : 0);
@@ -1374,16 +1455,17 @@
//司机余额扣减抽佣金额
if(n > 0){
AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+ accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
accountChangeDetail.setUserType(2);
accountChangeDetail.setUserId(driver.getId());
accountChangeDetail.setType(1);
accountChangeDetail.setChangeType(9);
accountChangeDetail.setOrderId(order.getId());
- accountChangeDetail.setOldData(driver.getBalance());
+ accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
accountChangeDetail.setExplain("线下收款服务费支出");
accountChangeDetail.setCreateTime(new Date());
driver.setBalance(driver.getBalance() - n);
- accountChangeDetail.setNewData(driver.getBalance());
+ accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
driverService.updateById(driver);
accountChangeDetailService.saveData(accountChangeDetail);
}
@@ -1436,9 +1518,7 @@
List<Integer> state = Arrays.asList(107, 108, 109);
int count = this.selectCount(new EntityWrapper<Order>().eq("driverId", driverId).in("state", state).eq("status", 1));
performanceSummaryWarpper.setTotalOrder(count);
- List<PerformanceRankingWarpper> list = new ArrayList<>();
int position = 0;
- Double d = 0D;
List<PerformanceRankingWarpper> performanceRankingWarppers = null;
if(type == 1){//订单量
performanceRankingWarppers = this.baseMapper.queryDriverRank(time, dayType);
@@ -1447,24 +1527,17 @@
performanceRankingWarppers = revenueService.queryDriverRank(2, time, dayType);
}
if(type == 3){//收入
- performanceRankingWarppers = revenueService.queryDriverRank(null, time, dayType);
+ performanceRankingWarppers = revenueService.queryDriverRank(1, time, dayType);
}
for (int i = 0; i < performanceRankingWarppers.size(); i++) {
PerformanceRankingWarpper performanceRankingWarpper = performanceRankingWarppers.get(i);
- Double amountOfData = performanceRankingWarpper.getAmountOfData();
- if(amountOfData.compareTo(d) != 0){
- position++;
- d = amountOfData;
- }
- if(position <= 10){
- list.add(performanceRankingWarpper);
- }
if(performanceRankingWarpper.getDriverId().compareTo(driverId) == 0){
+ position = i + 1;
break;
}
}
performanceSummaryWarpper.setPosition(position);
- performanceSummaryWarpper.setList(list);
+ performanceSummaryWarpper.setList(performanceRankingWarppers.size() > 10 ? performanceRankingWarppers.subList(0, 10) : performanceRankingWarppers.subList(0, performanceRankingWarppers.size()));
return performanceSummaryWarpper;
}
@@ -1479,9 +1552,9 @@
@Override
public List<MyAchievementWarpper> queryMyAchievement(Integer driverId, String time) throws Exception {
List<MyAchievementWarpper> list = new ArrayList<>();
- time = time.replaceAll("-", "年") + "月";
+// time = time.replaceAll("-", "年");
//订单量
- List<PerformanceRankingWarpper> performanceRankingWarppers = performanceRankingWarppers = this.baseMapper.queryDriverRank(time, 2);
+ List<PerformanceRankingWarpper> performanceRankingWarppers = this.baseMapper.queryDriverRank(time, 2);
int position = 0;
Double d = 0D;
for (int i = 0; i < performanceRankingWarppers.size(); i++) {
@@ -1547,4 +1620,47 @@
list.add(myAchievementWarpper);
return list;
}
+
+
+ /**
+ * 主动完成线下收款
+ */
+ @Override
+ public void 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