From ce7bf2e6ff801146d2ee02825b23d186e110c523 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Tue, 22 Jul 2025 18:06:35 +0800
Subject: [PATCH] 骑手送达照片记录

---
 oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java |   50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java b/oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java
index 74eedd1..455d421 100644
--- a/oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java
+++ b/oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java
@@ -6,8 +6,12 @@
 import com.oying.modules.rider.domain.RiderInfo;
 import com.oying.modules.rider.domain.RiderSourceInfo;
 import com.oying.modules.rider.domain.RiderSourceInfoHttp;
+import com.oying.modules.rider.domain.RiderWalletInfo;
+import com.oying.modules.rider.service.RiderWalletInfoService;
 import com.oying.modules.rider.utils.Constants;
 import com.oying.modules.rider.utils.RiderSourceHttpUtils;
+import com.oying.modules.system.domain.User;
+import com.oying.modules.system.service.UserService;
 import com.oying.utils.FileUtil;
 import com.oying.utils.SecurityUtils;
 import lombok.RequiredArgsConstructor;
@@ -20,6 +24,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import com.oying.utils.PageUtil;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
@@ -36,6 +41,8 @@
 public class RiderInfoServiceImpl extends ServiceImpl<RiderInfoMapper, RiderInfo> implements RiderInfoService {
 
     private final RiderInfoMapper riderInfoMapper;
+    private final RiderWalletInfoService riderWalletInfoService;
+    private final UserService userService;
 
     @Override
     public PageResult<RiderInfo> queryAll(RiderInfoQueryCriteria criteria, Page<Object> page) {
@@ -91,19 +98,24 @@
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void syncRiderSourceInfo(String sourcePlatform) {
         Long riderId = SecurityUtils.getCurrentUserId();
+        // 添加请求参数
+        List<String> phoneList = new ArrayList<>();
+        phoneList.add(SecurityUtils.getCurrentUsername());
         // 查询其他平台的数据
-        RiderSourceInfoHttp riderSourceInfoHttp = RiderSourceHttpUtils.getRiderSourceInfoHttp(SecurityUtils.getCurrentUsername(), sourcePlatform);
+        RiderSourceInfoHttp riderSourceInfoHttp = RiderSourceHttpUtils.getRiderSourceInfoHttp(phoneList, sourcePlatform);
         // 请求成功
         if (riderSourceInfoHttp.getCode().equals(Constants.HTTP_CODE_SUCCESS)) {
+            // 检查是否存在该平台的骑手信息
+            QueryWrapper<RiderInfo> riderInfoQueryWrapper = new QueryWrapper<>();
+            riderInfoQueryWrapper.eq(RiderInfo.COL_RIDER_ID, riderId);
+            RiderInfo riderInfo = riderInfoMapper.selectOne(riderInfoQueryWrapper);
             // 获取骑手信息等于空
-            if (null != riderSourceInfoHttp.getData()) {
-                RiderSourceInfo infoHttpData = riderSourceInfoHttp.getData();
-                // 检查是否存在该平台的骑手信息
-                QueryWrapper<RiderInfo> riderInfoQueryWrapper = new QueryWrapper<>();
-                riderInfoQueryWrapper.eq(RiderInfo.COL_RIDER_ID, riderId);
-                RiderInfo riderInfo = riderInfoMapper.selectOne(riderInfoQueryWrapper);
+            if (!riderSourceInfoHttp.getData().isEmpty()) {
+                // 单个骑手信息同步只取第一条数据
+                RiderSourceInfo infoHttpData = riderSourceInfoHttp.getData().get(0);
                 // 如果存在该平台的骑手信息
                 if (null == riderInfo) {
                     // 如果不存在,则创建新的骑手三方信息
@@ -112,6 +124,28 @@
                     newRiderInfo.setRiderId(riderId);
                     newRiderInfo.setSourcePlatform(sourcePlatform);
                     create(newRiderInfo);
+                    // 覆盖骑手账号昵称信息
+                    User user = new User();
+                    user.setId(riderId);
+                    user.setNickName(infoHttpData.getCardName());
+                    userService.updateById(user);
+                    // 创建骑手钱包信息 正常
+                    RiderWalletInfo riderWalletInfo = new RiderWalletInfo();
+                    riderWalletInfo.setRiderId(riderId);
+                    riderWalletInfo.setAmount(new BigDecimal(0.00));
+                    riderWalletInfo.setAvailableBalance(new BigDecimal(0.00));
+                    riderWalletInfo.setPurchasingElectricityAmount(new BigDecimal(0.00));
+                    riderWalletInfo.setWithdrawTotal(new BigDecimal(0.00));
+                    riderWalletInfo.setIncomeTotal(new BigDecimal(0.00));
+                    riderWalletInfo.setFrozenAmount(new BigDecimal(0.00));
+                    riderWalletInfo.setRunTotal(Constants.ZERO);
+                    riderWalletInfo.setCashWithdrawalTotal(Constants.ZERO);
+                    riderWalletInfo.setPurchasingElectricityTotal(Constants.ZERO);
+                    riderWalletInfo.setStatus(Constants.WALLET_STATUS_NORMAL);
+                    riderWalletInfo.setPhone(infoHttpData.getPhone());
+                    riderWalletInfo.setCardName(infoHttpData.getCardName());
+                    riderWalletInfo.setCardNum(infoHttpData.getCardNum());
+                    riderWalletInfoService.create(riderWalletInfo);
                 } else {
                     // 是否相同平台
                     if (sourcePlatform.equals(riderInfo.getSourcePlatform())) {
@@ -142,7 +176,7 @@
     }
 
     @Override
-    public RiderInfo getRiderSourceInfo(String riderId) {
+    public RiderInfo getRiderSourceInfo(Long riderId) {
         QueryWrapper<RiderInfo> riderInfoQueryWrapper = new QueryWrapper<>();
         riderInfoQueryWrapper.eq(RiderInfo.COL_RIDER_ID, riderId);
         return riderInfoMapper.selectOne(riderInfoQueryWrapper);

--
Gitblit v1.9.3