From bd375f4fe8081c0ca612d72ed06c47ab3f89d68d Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Wed, 02 Jul 2025 16:37:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/pxb'

---
 oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java |  151 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 151 insertions(+), 0 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
new file mode 100644
index 0000000..74eedd1
--- /dev/null
+++ b/oying-system/src/main/java/com/oying/modules/rider/service/impl/RiderInfoServiceImpl.java
@@ -0,0 +1,151 @@
+package com.oying.modules.rider.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.oying.exception.BadRequestException;
+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.utils.Constants;
+import com.oying.modules.rider.utils.RiderSourceHttpUtils;
+import com.oying.utils.FileUtil;
+import com.oying.utils.SecurityUtils;
+import lombok.RequiredArgsConstructor;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.oying.modules.rider.service.RiderInfoService;
+import com.oying.modules.rider.domain.dto.RiderInfoQueryCriteria;
+import com.oying.modules.rider.mapper.RiderInfoMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import com.oying.utils.PageUtil;
+
+import java.util.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+import com.oying.utils.PageResult;
+
+/**
+ * @author pxb
+ * @description 服务实现
+ * @date 2025-07-01
+ **/
+@Service
+@RequiredArgsConstructor
+public class RiderInfoServiceImpl extends ServiceImpl<RiderInfoMapper, RiderInfo> implements RiderInfoService {
+
+    private final RiderInfoMapper riderInfoMapper;
+
+    @Override
+    public PageResult<RiderInfo> queryAll(RiderInfoQueryCriteria criteria, Page<Object> page) {
+        return PageUtil.toPage(riderInfoMapper.findAll(criteria, page));
+    }
+
+    @Override
+    public List<RiderInfo> queryAll(RiderInfoQueryCriteria criteria) {
+        return riderInfoMapper.findAll(criteria);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void create(RiderInfo resources) {
+        riderInfoMapper.insert(resources);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(RiderInfo resources) {
+        RiderInfo riderInfo = getById(resources.getInfoId());
+        riderInfo.copy(resources);
+        riderInfoMapper.updateById(riderInfo);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteAll(List<Long> ids) {
+        riderInfoMapper.deleteBatchIds(ids);
+    }
+
+    @Override
+    public void download(List<RiderInfo> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (RiderInfo riderInfo : all) {
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("骑手id", riderInfo.getRiderId());
+            map.put("数据来源id", riderInfo.getSourceId());
+            map.put("电话", riderInfo.getPhone());
+            map.put("乙方姓名", riderInfo.getCardName());
+            map.put("证件号", riderInfo.getCardNum());
+            map.put("数据来源编号", riderInfo.getSourceNum());
+            map.put("状态0不生效,1生效 其他平台的条件是否满足", riderInfo.getEnabled());
+            map.put("数据来源平台(LY,等)", riderInfo.getSourcePlatform());
+            map.put("地址", riderInfo.getAddress());
+            map.put("创建者", riderInfo.getCreateBy());
+            map.put("更新者", riderInfo.getUpdateBy());
+            map.put("创建日期", riderInfo.getCreateTime());
+            map.put("更新时间", riderInfo.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+
+    @Override
+    public void syncRiderSourceInfo(String sourcePlatform) {
+        Long riderId = SecurityUtils.getCurrentUserId();
+        // 查询其他平台的数据
+        RiderSourceInfoHttp riderSourceInfoHttp = RiderSourceHttpUtils.getRiderSourceInfoHttp(SecurityUtils.getCurrentUsername(), sourcePlatform);
+        // 请求成功
+        if (riderSourceInfoHttp.getCode().equals(Constants.HTTP_CODE_SUCCESS)) {
+            // 获取骑手信息等于空
+            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 (null == riderInfo) {
+                    // 如果不存在,则创建新的骑手三方信息
+                    RiderInfo newRiderInfo = new RiderInfo();
+                    BeanUtil.copyProperties(infoHttpData, newRiderInfo);
+                    newRiderInfo.setRiderId(riderId);
+                    newRiderInfo.setSourcePlatform(sourcePlatform);
+                    create(newRiderInfo);
+                } else {
+                    // 是否相同平台
+                    if (sourcePlatform.equals(riderInfo.getSourcePlatform())) {
+                        // 如果存在,接单状态不同 更新接单状态
+                        if (!infoHttpData.getEnabled().equals(riderInfo.getEnabled())) {
+                            riderInfo.setEnabled(infoHttpData.getEnabled());
+                            // 更新骑手信息
+                            updateById(riderInfo);
+                        }
+                    } else {
+                        // 骑手平台信息变更
+                        RiderInfo newRiderInfo = new RiderInfo();
+                        BeanUtil.copyProperties(infoHttpData, newRiderInfo);
+                        newRiderInfo.setRiderId(riderId);
+                        newRiderInfo.setSourcePlatform(sourcePlatform);
+                        updateById(newRiderInfo);
+                        // 添加变更记录...
+                    }
+                }
+            } else {
+                // 获取骑手三方数据为空,抛出异常
+                throw new BadRequestException("获取骑手三方数据为空");
+            }
+        } else {
+            // 获取骑手三方数据失败,抛出异常
+            throw new BadRequestException("获取骑手三方数据失败");
+        }
+    }
+
+    @Override
+    public RiderInfo getRiderSourceInfo(String riderId) {
+        QueryWrapper<RiderInfo> riderInfoQueryWrapper = new QueryWrapper<>();
+        riderInfoQueryWrapper.eq(RiderInfo.COL_RIDER_ID, riderId);
+        return riderInfoMapper.selectOne(riderInfoQueryWrapper);
+    }
+
+}

--
Gitblit v1.9.3