| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.AgentApplication; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.mapper.AgentApplicationMapper; |
| | | import com.ruoyi.account.service.AgentApplicationService; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class AgentApplicationServiceImpl extends ServiceImpl<AgentApplicationMapper, AgentApplication> implements AgentApplicationService { |
| | | @Resource |
| | | private AgentApplicationMapper agentApplicationMapper; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | |
| | | @Override |
| | | public void apply(AgentApplication agentApplication) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); |
| | | |
| | | agentApplication.setAppUserId(loginUserApplet.getUserid()); |
| | | agentApplication.setStatus(1); |
| | | agentApplication.setApplicationTime(LocalDateTime.now()); |
| | | agentApplication.setShopPoint(appUser.getShopPoint()); |
| | | agentApplication.setSharePoint(appUser.getSharePoint()); |
| | | |
| | | // 直推用户已达钻石会员数量 |
| | | List<AppUser> directVipUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getVipId, 3)); |
| | | agentApplication.setDirectVipNum(directVipUserList.size()); |
| | | |
| | | // 直推用户已成为代理数量 |
| | | List<AppUser> directAgentUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getUserType, 4)); |
| | | agentApplication.setDirectAgentNum(directAgentUserList.size()); |
| | | |
| | | // 已绑定门店数量 |
| | | R<List<Shop>> R = shopClient.getShopByUserIds(Collections.singletonList(loginUserApplet.getUserid())); |
| | | List<Shop> shopList = R.getData(); |
| | | agentApplication.setBindShopNum(shopList.size()); |
| | | agentApplicationMapper.insert(agentApplication); |
| | | } |
| | | } |