| | |
| | | import com.oying.modules.rider.service.RiderWalletInfoService; |
| | | 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 com.oying.modules.system.domain.User; |
| | | import com.oying.modules.system.service.UserService; |
| | | import com.oying.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | 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.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.oying.utils.PageResult; |
| | | |
| | | /** |
| | | * @author pxb |
| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void syncRiderSourceInfo(String sourcePlatform) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R 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); |
| | |
| | | // 添加变更记录... |
| | | } |
| | | } |
| | | return R.success(riderInfo, "获取骑手三方数据"); |
| | | } else { |
| | | // 修改骑手信息为信息失效 |
| | | if(riderInfo != null) { |
| | | RiderInfo newRiderInfo = new RiderInfo(); |
| | | newRiderInfo.setRiderId(riderId); |
| | | newRiderInfo.setEnabled(Constants.SOURCE_ENABLED_DFF); |
| | | updateById(newRiderInfo); |
| | | } |
| | | // 获取骑手三方数据为空,抛出异常 |
| | | throw new BadRequestException("获取骑手三方数据为空"); |
| | | return R.fail(null, "获取骑手三方数据为空"); |
| | | } |
| | | } else { |
| | | // 获取骑手三方数据失败,抛出异常 |
| | |
| | | } |
| | | |
| | | @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); |