| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserVipDetailClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.model.TInviteUser; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.account.mapper.TInviteUserMapper; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TInviteUserService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TIntegralRule; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired |
| | | private IntegralRuleClient integralRuleClient; |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Resource |
| | | private AppUserVipDetailClient vipDetailClient; |
| | | |
| | | /** |
| | | * |
| | | * @param appUserId 被邀请人 |
| | | * @param beInvitedAppUserId 邀请人 |
| | | */ |
| | | @Override |
| | | public void saveInviteUser(Long appUserId, Long beInvitedAppUserId) { |
| | | |
| | | // 查询用户信息 |
| | | TAppUser user = appUserService.getById(beInvitedAppUserId); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(beInvitedAppUserId); |
| | | getAppUserVipDetail.setVipId(user.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | String vipJson = data1.getVipJson(); |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | |
| | | // 查询邀请用户获得积分配置 |
| | | TIntegralRule integralRule = integralRuleClient.getSet().getData(); |
| | | JSONObject jsonObject = JSONObject.parseObject(integralRule.getInviteUsersToEarnPoints()); |
| | |
| | | inviteUser.setAppUserId(beInvitedAppUserId); |
| | | inviteUser.setBeInvitedAppUserId(appUserId); |
| | | inviteUser.setCreateTime(LocalDateTime.now()); |
| | | inviteUser.setAward(jsonObject.getInteger("num1")); |
| | | if(Objects.nonNull(vip) && vip.getDoubleIntegration() == 1){ |
| | | inviteUser.setAward(jsonObject.getInteger("num1")*2); |
| | | }else { |
| | | inviteUser.setAward(jsonObject.getInteger("num1")); |
| | | } |
| | | this.save(inviteUser); |
| | | } |
| | | } |