Parcourir la source

扣积分流程修复没有生成商场商家赠送积分记录

LIDEXI il y a 4 ans
Parent
commit
6161ced249

+ 8 - 0
src/main/java/org/springblade/modules/payment/paystrategy/loginuser/impl/ChannelNoEnoughRareNoEnoughStrategy.java

@@ -194,6 +194,14 @@ public class ChannelNoEnoughRareNoEnoughStrategy implements IPayStrategy {
 		billRecordService.updateById(billRecord);
 
 
+		//5商家待送积分记录
+		PayUtil.addShopPointValue(mall,shop,loginUser,billRecord,pointDetailService);
+		//6商场待送积分记录
+		if(mall != null){
+			PayUtil.addMallPointValue(mall,loginUser,billRecord,mallMember,pointDetailService);
+		}
+
+
 		return billRecord;
 	}
 }

+ 6 - 0
src/main/java/org/springblade/modules/payment/paystrategy/loginuser/impl/ChannelNoEnoughRareZeroStrategy.java

@@ -165,6 +165,12 @@ public class ChannelNoEnoughRareZeroStrategy implements IPayStrategy {
 		billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 		billRecordService.updateById(billRecord);
 
+		//4.新增商户赠送积分记录,状态为待确认
+		PayUtil.addShopPointValue(mall,shop,loginUser,billRecord,pointDetailService);
+		//5.新增商场赠送积分记录,状态为待确认
+		if(mall != null){
+			PayUtil.addMallPointValue(mall,loginUser,billRecord,mallMember,pointDetailService);
+		}
 
 		return billRecord;
 	}

+ 10 - 3
src/main/java/org/springblade/modules/payment/paystrategy/loginuser/impl/ChannelZeroRareNoEnoughStrategy.java

@@ -15,6 +15,7 @@ import org.springblade.modules.ldt.channeluserpoint.service.IChannelUserPointSer
 import org.springblade.modules.ldt.loginuser.dto.PayDto;
 import org.springblade.modules.ldt.loginuser.entity.LoginUser;
 import org.springblade.modules.ldt.loginuser.service.ILoginUserService;
+import org.springblade.modules.ldt.mall.entity.Mall;
 import org.springblade.modules.ldt.mall.service.IMallService;
 import org.springblade.modules.ldt.member.entity.Member;
 import org.springblade.modules.ldt.member.service.IMemberService;
@@ -25,6 +26,7 @@ import org.springblade.modules.ldt.shop.entity.Shop;
 import org.springblade.modules.ldt.shop.service.IShopService;
 import org.springblade.modules.ldt.shopyingshou.service.IShopYingshouService;
 import org.springblade.modules.payment.paystrategy.loginuser.IPayStrategy;
+import org.springblade.modules.payment.paystrategy.loginuser.util.PayUtil;
 import org.springblade.modules.system.service.IParamService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -140,9 +142,14 @@ public class ChannelZeroRareNoEnoughStrategy implements IPayStrategy {
 		pointDetail.setName(shop.getName());
 		pointDetailService.save(pointDetail);
 
-		//该用户的余额 = 0 待支付回调后才能扣余额
-//								loginUser.setPointValue(BigDecimal.ZERO);
-//								this.updateById(loginUser);
+		Mall mall = null;
+		//3商家送积分记录-记录状态为待确认
+		mall = mallService.getById(shop.getMallId());
+		PayUtil.addShopPointValue(mall,shop,loginUser,billRecord,pointDetailService);
+		//4商场送积分记录-记录状态为待确认
+		if(mall != null){
+			PayUtil.addMallPointValue(mall,loginUser,billRecord,mallMember,pointDetailService);
+		}
 
 		billRecordService.updateById(billRecord);
 

+ 3 - 34
src/main/java/org/springblade/modules/payment/paystrategy/loginuser/impl/ChannelZeroRareZeroStrategy.java

@@ -26,6 +26,7 @@ import org.springblade.modules.ldt.shop.entity.Shop;
 import org.springblade.modules.ldt.shop.service.IShopService;
 import org.springblade.modules.ldt.shopyingshou.service.IShopYingshouService;
 import org.springblade.modules.payment.paystrategy.loginuser.IPayStrategy;
+import org.springblade.modules.payment.paystrategy.loginuser.util.PayUtil;
 import org.springblade.modules.system.service.IParamService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -125,45 +126,13 @@ public class ChannelZeroRareZeroStrategy implements IPayStrategy {
 		if (shop.getMallId() != null) {
 			mall = mallService.getById(shop.getMallId());
 			//商场带确认赠送积分
-			PointDetail mallSendPoint = new PointDetail();
-			mallSendPoint.setMemberId(mallMember.getId());
-			mallSendPoint.setMallId(mall.getId());
-			mallSendPoint.setUserId(loginUser.getId());
-			mallSendPoint.setType(SystemConstant.PointDetailType.MALL_SEND.getValue());
-			mallSendPoint.setName(mall.getName());
-			mallSendPoint.setLogo(mall.getPic());
-			mallSendPoint.setPrice(billRecord.getPrice());//总价
-			mallSendPoint.setChannelId(mall.getId());
-			//商场送的积分数 = 总价*商场会员中心每消费一元赠送的积分数
-			mallSendPoint.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
-			//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分价值/商场会员中心的积分数
-			mallSendPoint.setPointValue(mallSendPoint.getPoint().multiply(mall.getPointValue()).divide(mall.getPoint()));
-			mallSendPoint.setBillRecordId(billRecord.getId());
-			mallSendPoint.setBillRecordStatus(billRecord.getPayStatus());
-			pointDetailService.save(mallSendPoint);
+			PayUtil.addMallPointValue(mall,loginUser,billRecord,mallMember,pointDetailService);
 
 		}
 
 
 		//商户赠送积分待确认
-		PointDetail shopPointDetail = new PointDetail();
-		shopPointDetail.setMallId(mall != null ? mall.getId() : null);
-		shopPointDetail.setShopId(shop.getId());
-		shopPointDetail.setMemberId(shopMember.getId());
-		shopPointDetail.setUserId(loginUser.getId());
-		shopPointDetail.setType(SystemConstant.PointDetailType.SHOP_SEND.getValue());
-		shopPointDetail.setName(shop.getName());
-//						shopPointDetail.setLogo(shop.getShopPic());
-		shopPointDetail.setPrice(billRecord.getPrice());
-		//商家送的积分 = 总价*商家的会议中心每消费一元赠送的积分数
-		shopPointDetail.setPoint(billRecord.getPrice().multiply(shop.getConsumeOnePoint()));
-		//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分价值/商家会员中心的积分数
-		Assert.isFalse(shop.getIsOpenMember() == 0, "该商户未开启会员中心");
-		Assert.isFalse(shop.getPoint().compareTo(BigDecimal.ZERO) == 0,"会员中心积分数不能为0");
-		shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPointValue()).divide(shop.getPoint()));
-		shopPointDetail.setBillRecordStatus(billRecord.getPayStatus());
-		shopPointDetail.setBillRecordId(billRecord.getId());
-		pointDetailService.save(shopPointDetail);
+		PayUtil.addShopPointValue(mall,shop,loginUser,billRecord,pointDetailService);
 
 
 		//用户余额为0时用户需要全额支付,待支付回调成功后才会发放积分

+ 13 - 5
src/main/java/org/springblade/modules/payment/paystrategy/loginuser/util/PayUtil.java

@@ -1,5 +1,6 @@
 package org.springblade.modules.payment.paystrategy.loginuser.util;
 
+import com.baomidou.mybatisplus.core.toolkit.Assert;
 import org.springblade.common.constant.SystemConstant;
 import org.springblade.modules.ldt.billrecord.entity.BillRecord;
 import org.springblade.modules.ldt.channel.entity.PointChannel;
@@ -13,6 +14,7 @@ import org.springblade.modules.ldt.shop.entity.Shop;
 import org.springblade.modules.ldt.shopyingshou.entity.ShopYingshou;
 import org.springblade.modules.ldt.shopyingshou.service.IShopYingshouService;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
@@ -22,13 +24,14 @@ public class PayUtil {
 
 	/**
 	 * 当用户不需要支付时新增商家的积分成本,增加用户的渠道可用积分
+	 *
 	 * @param mall
 	 * @param loginUser
 	 * @param billRecord
 	 */
 
 	public static PointDetail addMallPointValue(Mall mall, LoginUser loginUser, BillRecord billRecord,
-												Member mallMember, IPointDetailService pointDetailService){
+												Member mallMember, IPointDetailService pointDetailService) {
 		PointDetail mallSendPoint = new PointDetail();
 		mallSendPoint.setMallId(mall.getId());
 		mallSendPoint.setMemberId(mallMember.getId());
@@ -50,16 +53,20 @@ public class PayUtil {
 	}
 
 	/**
-	 *  当用户不需要支付时新增商店的积分成本,增加用户的可用积分(余额)
+	 * 当用户不需要支付时新增商店的积分成本,增加用户的可用积分(余额)
+	 *
 	 * @param mall
 	 * @param shop
 	 * @param loginUser
 	 * @param billRecord
 	 */
 	public static PointDetail addShopPointValue(Mall mall, Shop shop, LoginUser loginUser, BillRecord billRecord,
-								   IPointDetailService pointDetailService){
+												IPointDetailService pointDetailService) {
+		//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分价值/商家会员中心的积分数
+		Assert.isFalse(shop.getIsOpenMember() == 0, "该商户未开启会员中心");
+		Assert.isFalse(shop.getPoint().compareTo(BigDecimal.ZERO) == 0,"会员中心积分数不能为0");
 		PointDetail shopPointDetail = new PointDetail();
-		shopPointDetail.setMallId(mall.getId());
+		shopPointDetail.setMallId(mall != null ? mall.getId() : null);
 		shopPointDetail.setShopId(shop.getId());
 		shopPointDetail.setUserId(loginUser.getId());
 		shopPointDetail.setType(SystemConstant.PointDetailType.SHOP_SEND.getValue());
@@ -79,13 +86,14 @@ public class PayUtil {
 
 	/**
 	 * 当用户不需要支付时直接新增商家应收明细
+	 *
 	 * @param billRecord
 	 * @param pointChannel
 	 * @param pointDetail
 	 * @param shop
 	 */
 	public static void saveShopYingShou(BillRecord billRecord, PointChannel pointChannel, PointDetail pointDetail, Shop shop,
-								  IShopYingshouService shopYingshouService){
+										IShopYingshouService shopYingshouService) {
 		ShopYingshou shopYingshou = new ShopYingshou();
 		shopYingshou.setBillRecordId(billRecord.getId());
 		shopYingshou.setBillRecordStatus(billRecord.getPayStatus());