| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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 |
| | | @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)) { |
| | | // 获取骑手信息等于空 |
| | | if (null != riderSourceInfoHttp.getData()) { |
| | | RiderSourceInfo infoHttpData = riderSourceInfoHttp.getData(); |
| | | if (!riderSourceInfoHttp.getData().isEmpty()) { |
| | | // 单个骑手信息同步只取第一条数据 |
| | | RiderSourceInfo infoHttpData = riderSourceInfoHttp.getData().get(0); |
| | | // 检查是否存在该平台的骑手信息 |
| | | QueryWrapper<RiderInfo> riderInfoQueryWrapper = new QueryWrapper<>(); |
| | | riderInfoQueryWrapper.eq(RiderInfo.COL_RIDER_ID, riderId); |
| | |
| | | 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())) { |
| | |
| | | } |
| | | |
| | | @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); |