From 4c3577ffcc1e4c1fab90cdcc79e50216c6733d5b Mon Sep 17 00:00:00 2001 From: "12691282@qq.com" <12691282@qq.com> Date: Fri, 8 Nov 2024 14:52:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=AE=9E=E6=97=B6=E6=9F=A5?= =?UTF-8?q?=E8=B4=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../buy507/mall/mapper/UmsMemberMapper.xml | 2 +- .../impl/MemberSplitProfitService.java | 23 ++- .../impl/OmsPortalOrderServiceImpl.java | 3 - .../service/impl/UmsMemberServiceImpl.java | 147 +++++++++--------- .../portal/OmsPortalOrderServiceTest.java | 8 + 5 files changed, 89 insertions(+), 94 deletions(-) diff --git a/mall-dao/src/main/resources/com/buy507/mall/mapper/UmsMemberMapper.xml b/mall-dao/src/main/resources/com/buy507/mall/mapper/UmsMemberMapper.xml index b9c7347..2d7cade 100644 --- a/mall-dao/src/main/resources/com/buy507/mall/mapper/UmsMemberMapper.xml +++ b/mall-dao/src/main/resources/com/buy507/mall/mapper/UmsMemberMapper.xml @@ -503,7 +503,7 @@ real_name = #{realName,jdbcType=VARCHAR}, - order_status = #{realName,jdbcType=INTEGER}, + order_status = #{orderStatus,jdbcType=INTEGER}, where id = #{id,jdbcType=BIGINT} diff --git a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/MemberSplitProfitService.java b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/MemberSplitProfitService.java index ab13430..dea819d 100644 --- a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/MemberSplitProfitService.java +++ b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/MemberSplitProfitService.java @@ -50,6 +50,9 @@ public class MemberSplitProfitService{ @Value("${becomeVipAmount}") private String becomeVipAmount; + @Value("${sameLevelProfit}") + private String sameLevelProfit; + @Async @Transactional public void updateOderAndMemberInfo(OmsOrder order) { @@ -277,16 +280,13 @@ public class MemberSplitProfitService{ threeLevelSplitProfit(higherMember, next, order, tenPercent); fourLevelSplitProfit(higherMember, next, order, tenPercent); } - } - - //平级关系 }else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){ - BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0.10")).setScale(2, RoundingMode.HALF_UP); + BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0."+sameLevelProfit)).setScale(2, RoundingMode.HALF_UP); UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction(); - accountTransaction.setCommissionRatio(10); + accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit)); accountTransaction.setMemberId(higherMember.getId()); accountTransaction.setOrderId(order.getId()); accountTransaction.setRemarks("二级店长平级分润"); @@ -327,10 +327,8 @@ public class MemberSplitProfitService{ } String ratioStr = profitRatio < 10 ? "0.0" + profitRatio : "0."+profitRatio; - //查看上级的分润比例 BigDecimal tenPercent = order.getPayAmount().multiply(new BigDecimal(ratioStr)).setScale(2, RoundingMode.HALF_UP); - UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction(); accountTransaction.setCommissionRatio(profitRatio); accountTransaction.setMemberId(higherMember.getId()); @@ -353,10 +351,9 @@ public class MemberSplitProfitService{ } //平级关系 }else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){ - BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0.10")).setScale(2, RoundingMode.HALF_UP); - + BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0."+sameLevelProfit)).setScale(2, RoundingMode.HALF_UP); UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction(); - accountTransaction.setCommissionRatio(10); + accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit)); accountTransaction.setMemberId(higherMember.getId()); accountTransaction.setOrderId(order.getId()); accountTransaction.setRemarks("三级代理平级分润"); @@ -392,9 +389,7 @@ public class MemberSplitProfitService{ if(higherLevel.getCommissionRatio() != null && lowerLevel.getCommissionRatio() != null){ profitRatio = higherLevel.getCommissionRatio() - lowerLevel.getCommissionRatio(); } - String ratioStr = profitRatio < 10 ? "0.0" + profitRatio : "0."+profitRatio; - //查看上级的分润比例 BigDecimal tenPercent = order.getPayAmount().multiply(new BigDecimal(ratioStr)).setScale(2, RoundingMode.HALF_UP); @@ -416,10 +411,10 @@ public class MemberSplitProfitService{ } //平级关系 }else if(lowerMember.getMemberLevel().equals(lowerMember.getMemberLevel())){ - BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0.10")).setScale(2, RoundingMode.HALF_UP); + BigDecimal tenPercent = revenueAmount.multiply(new BigDecimal("0."+sameLevelProfit)).setScale(2, RoundingMode.HALF_UP); UmsMemberAccountTransaction accountTransaction = new UmsMemberAccountTransaction(); - accountTransaction.setCommissionRatio(10); + accountTransaction.setCommissionRatio(Integer.valueOf(sameLevelProfit)); accountTransaction.setMemberId(higherMember.getId()); accountTransaction.setOrderId(order.getId()); accountTransaction.setRemarks("四级市代平级分润"); diff --git a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/OmsPortalOrderServiceImpl.java b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/OmsPortalOrderServiceImpl.java index ad96619..eb7c704 100644 --- a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/OmsPortalOrderServiceImpl.java +++ b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/OmsPortalOrderServiceImpl.java @@ -1703,9 +1703,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { @Value("${alipay.signType}") private String signType; - @Value("${becomeVipAmount}") - private String becomeVipAmount; - @Override public void alipayCallback(Map params) { LOGGER.info("============开始处理支付宝的支付异步通知 接收到参数 {}", JSONUtil.toJsonStr(params)); diff --git a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/UmsMemberServiceImpl.java b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/UmsMemberServiceImpl.java index 10235ac..7ab479d 100644 --- a/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/UmsMemberServiceImpl.java +++ b/mall-portal/src/main/java/com/buy507/mall/portal/service/impl/UmsMemberServiceImpl.java @@ -1,13 +1,29 @@ package com.buy507.mall.portal.service.impl; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - +import cn.hutool.core.date.DateTime; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import com.buy507.mall.common.api.CommonResult; +import com.buy507.mall.common.util.Constants; +import com.buy507.mall.mapper.*; +import com.buy507.mall.model.*; +import com.buy507.mall.portal.component.RedisLock; +import com.buy507.mall.portal.component.TeamMemberNumberHanderQueue; +import com.buy507.mall.portal.dao.PortalMemberDao; +import com.buy507.mall.portal.domain.*; +import com.buy507.mall.portal.service.InitDistributionService; +import com.buy507.mall.portal.service.PortalCommonService; +import com.buy507.mall.portal.service.RedisService; +import com.buy507.mall.portal.service.UmsMemberService; +import com.buy507.mall.portal.util.JwtTokenUtil; +import com.buy507.mall.portal.util.WeChatDecryptDataUtil; +import com.github.pagehelper.PageHelper; +import com.google.gson.Gson; +import com.google.gson.JsonObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -28,60 +44,9 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; -import com.aliyuncs.CommonRequest; -import com.aliyuncs.CommonResponse; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.http.MethodType; -import com.aliyuncs.profile.DefaultProfile; -import com.buy507.mall.common.api.CommonResult; -import com.buy507.mall.common.util.Constants; -import com.buy507.mall.mapper.DmsMemberBankAccountMapper; -import com.buy507.mall.mapper.DmsMemberTradeRecordMapper; -import com.buy507.mall.mapper.DmsMemberTransferRecordMapper; -import com.buy507.mall.mapper.DmsMemberWithdrawApplyMapper; -import com.buy507.mall.mapper.DmsTeamLevelMapper; -import com.buy507.mall.mapper.DmsTeamTotalConsumeMapper; -import com.buy507.mall.mapper.OmsOrderMapper; -import com.buy507.mall.mapper.UmsMemberLevelMapper; -import com.buy507.mall.mapper.UmsMemberMapper; -import com.buy507.mall.model.DmsMemberBankAccount; -import com.buy507.mall.model.DmsMemberTradeRecord; -import com.buy507.mall.model.DmsMemberTransferRecord; -import com.buy507.mall.model.DmsMemberWithdrawApply; -import com.buy507.mall.model.DmsTeamLevel; -import com.buy507.mall.model.DmsTeamTotalConsume; -import com.buy507.mall.model.ItemType; -import com.buy507.mall.model.MemberLevel; -import com.buy507.mall.model.OmsOrder; -import com.buy507.mall.model.OmsOrderExample; -import com.buy507.mall.model.StoreStatus; -import com.buy507.mall.model.UmsMember; -import com.buy507.mall.model.UmsMemberExample; -import com.buy507.mall.model.UmsMemberLevel; -import com.buy507.mall.model.UmsMemberLevelExample; -import com.buy507.mall.portal.component.RedisLock; -import com.buy507.mall.portal.component.TeamMemberNumberHanderQueue; -import com.buy507.mall.portal.dao.PortalMemberDao; -import com.buy507.mall.portal.domain.AccountDetailResult; -import com.buy507.mall.portal.domain.FirstMemberInfoParam; -import com.buy507.mall.portal.domain.MemberDetails; -import com.buy507.mall.portal.domain.MemberInfoResult; -import com.buy507.mall.portal.domain.MemberTransferParam; -import com.buy507.mall.portal.domain.MemberTransferResult; -import com.buy507.mall.portal.domain.MemberWithdrawApplyResult; -import com.buy507.mall.portal.domain.TeamMemberResult; -import com.buy507.mall.portal.domain.WeChatLogin; -import com.buy507.mall.portal.domain.WithdrawApplyParam; -import com.buy507.mall.portal.service.InitDistributionService; -import com.buy507.mall.portal.service.PortalCommonService; -import com.buy507.mall.portal.service.RedisService; -import com.buy507.mall.portal.service.UmsMemberService; -import com.buy507.mall.portal.util.JwtTokenUtil; -import com.buy507.mall.portal.util.WeChatDecryptDataUtil; -import com.github.pagehelper.PageHelper; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; /** * 会员管理Service实现类 @@ -147,6 +112,11 @@ public class UmsMemberServiceImpl implements UmsMemberService { @Autowired private DmsMemberTransferRecordMapper memberTransferRecordMapper; + /** + * 会员分成流水 + */ + @Resource + private UmsMemberAccountTransactionMapper umsMemberAccountTransactionMapper; @Autowired private RedisLock redisLock; @@ -479,17 +449,46 @@ public class UmsMemberServiceImpl implements UmsMemberService { String realAuthCode = redisService.get(REDIS_KEY_PREFIX_AUTH_CODE + telephone); return authCode.equals(realAuthCode); } - + @Override public MemberInfoResult getMemberInfo() { - UmsMember loginMember = getCurrentMember(); + UmsMember loginMember = new UmsMember(); //getCurrentMember(); + loginMember.setId(1L); UmsMember member = memberMapper.selectByPrimaryKey(loginMember.getId()); DmsTeamTotalConsume teamTotalConsume = teamTotalConsumeMapper.selectOneByMemberId(loginMember.getId()); OmsOrderExample example = new OmsOrderExample(); example.createCriteria().andMemberIdEqualTo(loginMember.getId()); List orders = orderMapper.selectByExample(example); - + + //查询流水冻结信息 + UmsMemberAccountTransactionExample accountTransactionExample = new UmsMemberAccountTransactionExample(); + accountTransactionExample.createCriteria() + .andMemberIdEqualTo(member.getId()) + .andTransactionStateEqualTo(UmsMemberAccountTransaction.TRANSACTION_STATE_NO); + + List umatList = umsMemberAccountTransactionMapper.selectByExample(accountTransactionExample); + DateTime nowTime = DateTime.now(); + BigDecimal freezeTransactionAccount = BigDecimal.ZERO; + if(!umatList.isEmpty()){ + BigDecimal balanceTransaction = BigDecimal.ZERO; + for (UmsMemberAccountTransaction accountTransaction : umatList) { + //冻结金额超过24后到账用户账号 + if(nowTime.isAfter(accountTransaction.getTransferPaymentTime())){ + balanceTransaction = balanceTransaction.add(accountTransaction.getRevenueAmount()); + accountTransaction.setTransactionState(UmsMemberAccountTransaction.TRANSACTION_STATE_YES); + umsMemberAccountTransactionMapper.updateByPrimaryKeySelective(accountTransaction); + }else { + freezeTransactionAccount = freezeTransactionAccount.add(accountTransaction.getRevenueAmount()); + } + } + if(!balanceTransaction.equals(BigDecimal.ZERO)){ + member.setBalance(member.getBalance().add(balanceTransaction)); + memberMapper.updateByPrimaryKeySelective(member); + } + + } + member.setFreeze(member.getFreeze().add(freezeTransactionAccount)); MemberInfoResult result = new MemberInfoResult(); result.setBalance(member.getBalance()); //余额 result.setFreeze(member.getFreeze()); //冻结余额 @@ -503,22 +502,18 @@ public class UmsMemberServiceImpl implements UmsMemberService { result.setDetailAddress(member.getDetailAddress()); if(MemberLevel.Member.equals(member.getMemberLevel())) { - result.setMemberLevelName("普通会员"); + result.setMemberLevelName("普通用户"); } else if(MemberLevel.Consumer.equals(member.getMemberLevel())) { - result.setMemberLevelName("消费商"); + result.setMemberLevelName("vip会员"); } else if(MemberLevel.Partner.equals(member.getMemberLevel())) { - result.setMemberLevelName("经销商"); + result.setMemberLevelName("店长"); } else if(MemberLevel.Diamond.equals(member.getMemberLevel())) { - result.setMemberLevelName("合作商"); + result.setMemberLevelName("代理"); } else if(MemberLevel.OneDiamond.equals(member.getMemberLevel())) { - result.setMemberLevelName("初级合作商"); - } else if(MemberLevel.TwoDiamond.equals(member.getMemberLevel())) { - result.setMemberLevelName("中级合作商"); - } else if(MemberLevel.ThreeDiamond.equals(member.getMemberLevel())) { - result.setMemberLevelName("高级合作商"); + result.setMemberLevelName("市代"); } else { - result.setMemberLevelName("特级合作商"); - } + result.setMemberLevelName("市代"); + } BigDecimal memberTotal = new BigDecimal(0); diff --git a/mall-portal/src/test/java/com/buy507/mall/portal/OmsPortalOrderServiceTest.java b/mall-portal/src/test/java/com/buy507/mall/portal/OmsPortalOrderServiceTest.java index c70cde0..c1735b7 100644 --- a/mall-portal/src/test/java/com/buy507/mall/portal/OmsPortalOrderServiceTest.java +++ b/mall-portal/src/test/java/com/buy507/mall/portal/OmsPortalOrderServiceTest.java @@ -1,6 +1,7 @@ package com.buy507.mall.portal; import com.buy507.mall.portal.service.OmsPortalOrderService; +import com.buy507.mall.portal.service.UmsMemberService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +33,13 @@ public class OmsPortalOrderServiceTest { + @Autowired + private UmsMemberService memberService; + + @Test + public void getMemberInfoTest() { + memberService.getMemberInfo(); + } }