From f1e88066e0af2a0852fe1095da87c04018c9cf5a Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 11 Sep 2023 18:11:05 +0800
Subject: [PATCH] 优惠卷
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java | 153 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 116 insertions(+), 37 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
index 22df22c..48309b2 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
@@ -13,15 +13,13 @@
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
-import cc.mrbird.febs.mall.service.IApiMallMemberService;
-import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
-import cc.mrbird.febs.mall.service.ICommonService;
-import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
+import cc.mrbird.febs.mall.service.*;
import cc.mrbird.febs.mall.vo.*;
import cc.mrbird.febs.pay.model.BrandWCPayRequestData;
import cc.mrbird.febs.pay.service.IXcxPayService;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -30,6 +28,7 @@
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -69,6 +68,12 @@
private final SpringContextHolder springContextHolder;
private final MallAgentRecordMapper mallAgentRecordMapper;
private final IMallMoneyFlowService mallMoneyFlowService;
+ private final IMallMemberCollectionService mallMemberCollectionService;
+ private final IMallMemberFootprintService mallMemberFootprintService;
+ private final SalemanCouponMapper salemanCouponMapper;
+ private final CouponGoodsMapper couponGoodsMapper;
+ private final MallGoodsCouponMapper mallGoodsCouponMapper;
+ private final MallMemberCouponMapper mallMemberCouponMapper;
@Value("${spring.profiles.active}")
@@ -253,37 +258,26 @@
mallMemberVo.setHasPayment(1);
}
+ MemberCollectionListDto memberCollectionListDto = new MemberCollectionListDto();
+ memberCollectionListDto.setPageNow(1);
+ memberCollectionListDto.setPageSize(10);
+ List<CollectionListVo> collectionList = mallMemberCollectionService.findMemberCollectionList(memberCollectionListDto);
+ mallMemberVo.setCollectionCnt(CollUtil.isNotEmpty(collectionList) ? collectionList.size() : 0);
+
+ MemberFootprintListDto memberFootprintListDto = new MemberFootprintListDto();
+ memberFootprintListDto.setPageNow(1);
+ memberFootprintListDto.setPageSize(10);
+ List<FootprintListVo> footprintList = mallMemberFootprintService.findMemberFootprintList(memberFootprintListDto);
+ mallMemberVo.setFootprintCnt(CollUtil.isNotEmpty(footprintList) ? footprintList.size() : 0);
+
+ List<MallMember> mallMembers = this.baseMapper.selectByRefererId(mallMember.getInviteId());
+ mallMemberVo.setChildCnt(CollUtil.isNotEmpty(mallMembers) ? mallMembers.size() : 0);
+
MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(mallMemberVo.getId());
mallMemberVo.setBalance(wallet.getBalance());
- mallMemberVo.setScore(wallet.getScore());
- mallMemberVo.setPrizeScore(wallet.getPrizeScore());
- mallMemberVo.setTotalCost(mallOrderInfoMapper.selectTotalAmount(id));
-
- //代理状态
- MallAgentRecord mallAgentRecordIng = mallAgentRecordMapper.selectByMemberIdAndState(id, MallAgentRecord.APPLY_ING);
- MallAgentRecord mallAgentRecordAgree = mallAgentRecordMapper.selectByMemberIdAndState(id, MallAgentRecord.APPLY_AGREE);
- MallAgentRecord mallAgentRecordDisagree = mallAgentRecordMapper.selectByMemberIdAndState(id, MallAgentRecord.APPLY_DISAGREE);
- if(ObjectUtil.isNotEmpty(mallAgentRecordIng)){
- mallMemberVo.setIsAgent(1);
- }else if(ObjectUtil.isNotEmpty(mallAgentRecordAgree)){
- mallMemberVo.setIsAgent(2);
- if(StrUtil.isNotEmpty(mallAgentRecordAgree.getAgentLevel())){
- DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("AGENT_LEVEL_APPLY", mallAgentRecordAgree.getAgentLevel());
- mallMemberVo.setAgentLevelName(dataDictionaryCustom.getDescription());
- }
- if(mallAgentRecordAgree.getAgentLevel().equals("LEVEL_ONE")){
- mallMemberVo.setAgentLevel(1);
- }
- if(mallAgentRecordAgree.getAgentLevel().equals("LEVEL_TWO")){
- mallMemberVo.setAgentLevel(2);
- }
- if(mallAgentRecordAgree.getAgentLevel().equals("LEVEL_THREE")){
- mallMemberVo.setAgentLevel(3);
- }
- }else if(ObjectUtil.isNotEmpty(mallAgentRecordDisagree)){
- mallMemberVo.setIsAgent(3);
- }
-
+// mallMemberVo.setScore(wallet.getScore());
+// mallMemberVo.setPrizeScore(wallet.getPrizeScore());
+// mallMemberVo.setTotalCost(mallOrderInfoMapper.selectTotalAmount(id));
return new FebsResponse().success().data(mallMemberVo);
}
@@ -355,8 +349,8 @@
MyTeamVo myTeamVo = new MyTeamVo();
myTeamVo.setTeam(list);
- myTeamVo.setMyAchieve(this.baseMapper.selectAchieveByMemberId(mallMember.getInviteId(), 1));
- myTeamVo.setMyTeamAchieve(this.baseMapper.selectAchieveByMemberId(mallMember.getInviteId(), 2));
+ myTeamVo.setMyAchieve(this.mallOrderInfoMapper.selectAmountOrTeamAmount(mallMember.getInviteId(), 1));
+ myTeamVo.setMyTeamAchieve(this.mallOrderInfoMapper.selectAmountOrTeamAmount(mallMember.getInviteId(), 2));
myTeamVo.setMyTeamCnt(this.baseMapper.selectAllChildAgentListByInviteId(mallMember.getInviteId()).size());
return new FebsResponse().success().data(myTeamVo);
}
@@ -577,6 +571,7 @@
@Override
public FebsResponse xcxLogin(ApiXcxLoginDto apiXcxLoginDto) throws IOException {
+ log.info("登录请求参数:{}", JSONObject.toJSONString(apiXcxLoginDto));
FebsResponse febsResponse = new FebsResponse();
String code = apiXcxLoginDto.getCode();
log.info("code:" + code);
@@ -606,6 +601,40 @@
mallMember.setLevel(AgentLevelEnum.ZERO_LEVEL.name());
mallMember.setOpenId(openId);
mallMember.setSessionKey(sessionKey);
+
+ if (StrUtil.isNotBlank(apiXcxLoginDto.getInviteId())) {
+ MallMember member = this.baseMapper.selectInfoByInviteId(apiXcxLoginDto.getInviteId());
+ if (member != null) {
+ mallMember.setReferrerId(member.getInviteId());
+
+ //推荐人和推荐人链
+ boolean flag = false;
+ String parentId = mallMember.getReferrerId();
+ if (StrUtil.isBlank(parentId)) {
+ flag = true;
+ }
+ String ids = "";
+ while (!flag) {
+ if (StrUtil.isBlank(ids)) {
+ ids += parentId;
+ } else {
+ ids += ("," + parentId);
+ }
+ MallMember parentMember = this.baseMapper.selectInfoByInviteId(parentId);
+ if (parentMember == null) {
+ break;
+ }
+ parentId = parentMember.getReferrerId();
+ if (StrUtil.isBlank(parentMember.getReferrerId())) {
+ flag = true;
+ }
+ }
+
+ if (StrUtil.isNotBlank(ids)) {
+ mallMember.setReferrerIds(ids);
+ }
+ }
+ }
this.baseMapper.insert(mallMember);
mallMember = this.baseMapper.selectMemberByOpenId(openId);
@@ -799,9 +828,9 @@
@Override
public void updateMemberAgent(Long memberId,String levelCode) {
mallAgentRecordMapper.updateStateByMemberId(memberId);
-
+ MallAgentRecord mallAgentRecord = mallAgentRecordMapper.selectById(memberId);
//更新用户表中的LEVEL
- MallMember mallMember = this.baseMapper.selectById(memberId);
+ MallMember mallMember = this.baseMapper.selectById(mallAgentRecord.getMemberId());
mallMember.setLevel(levelCode);
this.baseMapper.updateById(mallMember);
}
@@ -845,6 +874,56 @@
return new FebsResponse().success().data(apiMallAgentRecordVo);
}
+ @Override
+ public FebsResponse getCoupon(GetCouponDto getCouponDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ //通过邀请人信息,获取能领取的优惠卷信息
+ MallMember mallMember = this.baseMapper.selectInfoByInviteId(getCouponDto.getInviteId());
+ SalemanCoupon salemanCoupon = salemanCouponMapper.selectByMemberId(mallMember.getId());
+ if(ObjectUtil.isNotEmpty(salemanCoupon)){
+ Long couponId = salemanCoupon.getCouponId();
+ Long goodsId = getCouponDto.getGoodsId();
+ //商品优惠卷如果绑定了,那么当前登陆者获取一张卷
+ List<CouponGoods> couponGoodsList = couponGoodsMapper.selectByGoodIdAndCouponId(goodsId,couponId);
+ MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(couponId);
+ if(CollUtil.isNotEmpty(couponGoodsList)){
+ MallMemberCoupon mallMemberCoupon = new MallMemberCoupon();
+ mallMemberCoupon.setCouponId(couponId);
+ mallMemberCoupon.setCouponName(mallGoodsCoupon.getName());
+ mallMemberCoupon.setMemberId(memberId);
+ mallMemberCoupon.setGoodsId(goodsId);
+ mallMemberCoupon.setInviteId(mallMember.getInviteId());
+ mallMemberCoupon.setState(1);
+ mallMemberCoupon.setExpireTime(DateUtil.offsetDay(DateUtil.date(),mallGoodsCoupon.getExpireDay()));
+ mallMemberCouponMapper.insert(mallMemberCoupon);
+ }
+ }
+
+ return new FebsResponse().success();
+ }
+
+ @Override
+ public FebsResponse memberCoupon(MallMemberCouponDto mallMemberCouponDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ IPage<MallMemberCouponVo> page = new Page<>(mallMemberCouponDto.getPageNum(), mallMemberCouponDto.getPageSize());
+ mallMemberCouponDto.setMemberId(memberId);
+ mallMemberCouponDto.setExpireTime(DateUtil.date());
+ IPage<MallMemberCouponVo> pages = mallMemberCouponMapper.selectListInPage(page, mallMemberCouponDto);
+ return new FebsResponse().success().data(pages);
+ }
+
+ @Override
+ public FebsResponse couponDetails(Long id) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ MallMemberCoupon mallMemberCoupon = mallMemberCouponMapper.selectById(id);
+ MallMemberCouponVo mallMemberCouponVo = new MallMemberCouponVo();
+ mallMemberCouponVo.setCouponName(mallMemberCoupon.getCouponName());
+ MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(mallMemberCoupon.getCouponId());
+ mallMemberCouponVo.setCostAmount(mallGoodsCoupon.getCostAmount());
+ mallMemberCouponVo.setRealAmount(mallGoodsCoupon.getRealAmount());
+ return new FebsResponse().success().data(mallMemberCouponVo);
+ }
+
private String getXcxLoginUrl(String code) {
String wechatLoginUrl =xcxProperties.getWecharLoginUrl();
return String.format(wechatLoginUrl, xcxProperties.getXcxAppid(), xcxProperties.getXcxSecret(), code);
--
Gitblit v1.9.1