| | |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.enums.PointChangeType; |
| | | import com.ruoyi.account.mapper.UserPointMapper; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Service |
| | | public class UserPointServiceImpl extends ServiceImpl<UserPointMapper, UserPoint> implements UserPointService { |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private RemoteVipSettingClient remoteVipSettingClient; |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | |
| | | @Override |
| | | public UserPointVO getUserPoint(Long userId) { |
| | | AppUser appUser = appUserClient.getAppUserById(userId); |
| | | AppUser appUser = appUserService.getById(userId); |
| | | List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() |
| | | .eq(UserPoint::getAppUserId, userId)); |
| | | |
| | | Map<Integer, Integer> userBalanceMap = userPointList.stream() |
| | | .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); |
| | | |
| | | R<VipSetting> r = remoteVipSettingClient.getVipSettingById(appUser.getVipId()); |
| | | if (!R.isSuccess(r)){ |
| | | throw new RuntimeException("会员等级获取失败"); |
| | | } |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userId); |
| | | |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | UserPointVO userPointVO = new UserPointVO(); |
| | |
| | | userPointVO.setPullNewPoint(userBalanceMap.get(PointChangeType.NEW_USER_REFERRAL.getCode())); |
| | | userPointVO.setShopAchievementPoint(userBalanceMap.get(PointChangeType.STORE_PERFORMANCE.getCode())); |
| | | userPointVO.setShopSharePoint(userBalanceMap.get(PointChangeType.STORE_COMMISSION_RETURN.getCode())); |
| | | userPointVO.setGiftPoint(r.getData().getVipGiftRole()); |
| | | userPointVO.setGiftPoint(vipSetting.getVipGiftRole()); |
| | | return userPointVO; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void transferPoint(BigDecimal point, Long phone) { |
| | | AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | AppUser appUserForPhoe = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getPhone, phone)); |
| | | |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Long userid = loginUserApplet.getUserid(); |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userid); |
| | | |
| | | |
| | | } |
| | | } |