| | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | @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) { |
| | | // 如果不存在,则创建新的骑手三方信息 |
| | |
| | | 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); |