LIDEXI 4 роки тому
батько
коміт
41da6eb8b6

+ 2 - 2
src/main/java/org/springblade/common/enums/PayWay.java

@@ -14,8 +14,8 @@ public enum  PayWay {
 	POINT("积分支付"),
 	MIX("混合支付"),
 	CASH("现金支付"),
-	WECHAT("微信支付"),
-	ALIPAY("支付宝支付");
+	WECHAT("微信用户"),
+	ALIPAY("支付宝用户");
 
 	String name;
 }

+ 2 - 2
src/main/java/org/springblade/modules/ldt/billrecord/wrapper/BillRecordWrapper.java

@@ -38,10 +38,10 @@ public class BillRecordWrapper extends BaseEntityWrapper<BillRecord, BillRecordV
 		BillRecordVO billRecordVO = Objects.requireNonNull(BeanUtil.copy(billRecord, BillRecordVO.class));
 		LoginUser loginUser = loginUserService.getById(billRecord.getUserId());
 		if(billRecord.getUserId() == null){
-			if(billRecord.getPayWay().equals(PayWay.ALIPAY)){
+			if(billRecord.getPayWay().equals(PayWay.ALIPAY.getName())){
 				billRecordVO.setPayWay(PayWay.ALIPAY.getName());
 				billRecordVO.setUserName("支付宝用户");
-			}else if(billRecord.getPayWay().equals(PayWay.WECHAT)){
+			}else if(billRecord.getPayWay().equals(PayWay.WECHAT.getName())){
 				billRecordVO.setPayWay(PayWay.WECHAT.getName());
 				billRecordVO.setUserName("微信用户");
 			}

+ 10 - 6
src/main/java/org/springblade/modules/ldt/loginuser/controller/AppUserController.java

@@ -12,6 +12,7 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.modules.ldt.billrecord.entity.BillRecord;
+import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
 import org.springblade.modules.ldt.channeluserpoint.dto.ChannelUserPointDTO;
 import org.springblade.modules.ldt.channeluserpoint.entity.ChannelUserPoint;
 import org.springblade.modules.ldt.channeluserpoint.service.IChannelUserPointService;
@@ -21,6 +22,8 @@ import org.springblade.modules.ldt.loginuser.service.ILoginUserService;
 import org.springblade.modules.ldt.pointdetail.dto.PointDetailDTO;
 import org.springblade.modules.ldt.pointdetail.entity.PointDetail;
 import org.springblade.modules.ldt.pointdetail.service.IPointDetailService;
+import org.springblade.modules.ldt.pointdetail.vo.PointDetailVO;
+import org.springblade.modules.ldt.pointdetail.wrapper.PointDetailWrapper;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -43,6 +46,7 @@ public class AppUserController {
 
 	private final IChannelUserPointService channelUserPointService;
 	private final IPointDetailService pointDetailService;
+	private final IBillRecordService billRecordService;
 
 	/**
 	 * 渠道积分记录分页
@@ -50,7 +54,7 @@ public class AppUserController {
 	@GetMapping("/channeluserpoint/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入channelUserPoint")
-	public R<IPage<PointDetail>> channeluserpointList(PointDetailDTO pointDetailDTO, Query query) {
+	public R<IPage<PointDetailVO>> channeluserpointList(PointDetailDTO pointDetailDTO, Query query) {
 		PointDetail pointDetail = Objects.requireNonNull(BeanUtil.copy(pointDetailDTO,PointDetail.class));
 		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
 		String selectMonth = null;
@@ -64,8 +68,8 @@ public class AppUserController {
 			.eq(PointDetail::getBillRecordStatus,SystemConstant.BillRecordPayStatus.PAYED.getValue())
 			.isNotNull(PointDetail::getChannelId)
 			.in(PointDetail::getType,
-				Arrays.asList(SystemConstant.PointDetailType.CHANNEL.getValue(),SystemConstant.PointDetailType.MALL_SEND.getValue()),SystemConstant.PointDetailType.USER_PAY.getValue()));
-		return R.data(pages);
+				Arrays.asList(SystemConstant.PointDetailType.CHANNEL.getValue(),SystemConstant.PointDetailType.MALL_SEND.getValue(),SystemConstant.PointDetailType.USER_PAY.getValue())));
+		return R.data(PointDetailWrapper.build(billRecordService).pageVO(pages));
 	}
 
 	/**
@@ -74,7 +78,7 @@ public class AppUserController {
 	@GetMapping("/remaining/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入channelUserPoint")
-	public R<IPage<PointDetail>> list(PointDetailDTO pointDetailDTO, Query query) {
+	public R<IPage<PointDetailVO>> list(PointDetailDTO pointDetailDTO, Query query) {
 		PointDetail pointDetail = Objects.requireNonNull(BeanUtil.copy(pointDetailDTO,PointDetail.class));
 		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
 		String selectMonth = null;
@@ -86,7 +90,7 @@ public class AppUserController {
 		IPage<PointDetail> pages = pointDetailService.page(Condition.getPage(query), Condition.getQueryWrapper(pointDetail).lambda()
 			.like(selectMonth != null,PointDetail::getCreateTime,selectMonth)
 			.eq(PointDetail::getBillRecordStatus,SystemConstant.BillRecordPayStatus.PAYED.getValue())
-			.in(PointDetail::getType,Arrays.asList(SystemConstant.PointDetailType.USER_PAY.getValue()),SystemConstant.PointDetailType.SHOP_SEND.getValue()));
-		return R.data(pages);
+			.in(PointDetail::getType,Arrays.asList(SystemConstant.PointDetailType.USER_PAY.getValue(),SystemConstant.PointDetailType.SHOP_SEND.getValue())));
+		return R.data(PointDetailWrapper.build(billRecordService).pageVO(pages));
 	}
 }

+ 13 - 1
src/main/java/org/springblade/modules/ldt/loginuser/service/impl/LoginUserServiceImpl.java

@@ -149,6 +149,10 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		Member mallMember = memberMap.get("mallMember");//商场会员
 		Assert.notNull(shopMember,"程序异常");
 		billRecord.setMemberId(shopMember.getId());
+		if(shop.getIsOpenMember() != 1){
+			System.out.println("该商户未开通会员中心");
+			Assert.isTrue(false,"该商户未开通会员中心");
+		}
 
 		//先查询该小B的活动折扣
 		List<ActivityJoinRecord> activityJoinRecords = activityJoinRecordService.getBaseMapper().selectList(new QueryWrapper<>(new ActivityJoinRecord()).lambda()
@@ -271,6 +275,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 							mallSendPoint.setName(mall.getName());
 							mallSendPoint.setLogo(mall.getPic());
 							mallSendPoint.setPrice(billRecord.getPrice());//总价
+							mallSendPoint.setChannelId(mall.getId());
 							//商场送的积分数 = 总价*商场会员中心每消费一元赠送的积分数
 							mallSendPoint.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
 							//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分价值/商场会员中心的积分数
@@ -291,6 +296,9 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 							//商家送的积分 = 总价*商家的会议中心每消费一元赠送的积分数
 							shopPointDetail.setPoint(billRecord.getPrice().multiply(shop.getConsumeOnePoint()));
 							//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分价值/商家会员中心的积分数
+							if(shop.getIsOpenMember() != 1){
+								Assert.isTrue(false,"该商户未开启会员中心");
+							}
 							shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPointValue()).divide(shop.getPoint()));
 							shopPointDetail.setBillRecordStatus(billRecord.getPayStatus());
 							shopPointDetail.setBillRecordId(billRecord.getId());
@@ -380,6 +388,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 						//大B渠道可抵用积分
 						BigDecimal channelEnablePointValue = channelUserPoint.getUsablePoint().multiply(BigDecimal.ONE.subtract(gxServerRate));
 						PointDetail channelPointDetail = new PointDetail();
+						channelPointDetail.setMemberId(mallMember.getId());
 						channelPointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
 						channelPointDetail.setBillRecordId(billRecord.getId());
 						channelPointDetail.setUserId(payDto.getLoginUserId());
@@ -396,7 +405,9 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 						channelUserPoint.setUsedPoint(channelUserPoint.getUsedPoint().add(channelPointDetail.getPoint()).add(channelPointDetail.getGxRewardPointValue()));
 						channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().subtract(channelPointDetail.getPoint()).subtract(channelPointDetail.getGxRewardPointValue()));
 						channelUserPointService.updateById(channelUserPoint);
-
+						//修改该用户的渠道积分
+						loginUser.setChannelPointValue(loginUser.getChannelPointValue().subtract(channelPointDetail.getPointValue()));
+						this.updateById(loginUser);
 						//商家应收明细
 						this.saveShopYingShou(billRecord,pointChannel,channelPointDetail,shop);
 
@@ -598,6 +609,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		mallSendPoint.setName(mall.getName());
 		mallSendPoint.setLogo(mall.getPic());
 		mallSendPoint.setPrice(billRecord.getPrice());//总价
+		mallSendPoint.setChannelId(mall.getId());
 		//商场送的积分数 = 总价*商场会员中心每消费一元赠送的积分数
 		mallSendPoint.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
 		//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分价值/商场会员中心的积分数

+ 6 - 0
src/main/java/org/springblade/modules/ldt/member/entity/Member.java

@@ -53,6 +53,12 @@ public class Member extends BaseEntity {
 	*/
 		@ApiModelProperty(value = "商店id")
 		private Long shopId;
+
+	/**
+	 * 该会员在该店/商场的总消费
+	 */
+	@ApiModelProperty(value = "该会员在该店/商场的总消费")
+	private BigDecimal payTotal;
 	/**
 	* 该会员在该店所获积分总和
 	*/

+ 2 - 1
src/main/java/org/springblade/modules/ldt/member/mapper/MemberMapper.xml

@@ -15,6 +15,7 @@
         <result column="user_id" property="userId"/>
         <result column="mall_id" property="mallId"/>
         <result column="shop_id" property="shopId"/>
+        <result column="pay_total" property="payTotal"/>
         <result column="point_total" property="pointTotal"/>
         <result column="point_value" property="pointValue"/>
         <result column="type" property="type"/>
@@ -31,7 +32,7 @@
 
     <select id="selectMemberPage" resultMap="memberVOResultMap">
         select
-            lm.id,lm.user_id,lm.mall_id,lm.shop_id,lm.point_total,lm.point_value,lm.type,
+            lm.id,lm.user_id,lm.mall_id,lm.shop_id,lm.point_total,lm.point_value,lm.type,lm.pay_total,
             llu.nick_name,llu.avatar,llu.phone,llu.gender
         from
             ldt_member lm,ldt_login_user llu

+ 2 - 0
src/main/java/org/springblade/modules/ldt/pointdetail/vo/PointDetailVO.java

@@ -33,4 +33,6 @@ import io.swagger.annotations.ApiModel;
 public class PointDetailVO extends PointDetail {
 	private static final long serialVersionUID = 1L;
 
+	private String payWay;
+
 }

+ 33 - 0
src/main/java/org/springblade/modules/ldt/pointdetail/wrapper/PointDetailWrapper.java

@@ -0,0 +1,33 @@
+package org.springblade.modules.ldt.pointdetail.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.ldt.billrecord.entity.BillRecord;
+import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
+import org.springblade.modules.ldt.pointdetail.entity.PointDetail;
+import org.springblade.modules.ldt.pointdetail.vo.PointDetailVO;
+
+import java.util.Objects;
+
+/**
+ * Created By lidexi in 2021/8/13
+ **/
+public class PointDetailWrapper extends BaseEntityWrapper<PointDetail, PointDetailVO> {
+
+	private IBillRecordService billRecordService;
+	private PointDetailWrapper(IBillRecordService billRecordService){
+		this.billRecordService = billRecordService;
+	}
+	public static PointDetailWrapper build(IBillRecordService billRecordService){
+		return new PointDetailWrapper(billRecordService);
+	}
+	@Override
+	public PointDetailVO entityVO(PointDetail pointDetail) {
+		PointDetailVO pointDetailVO = Objects.requireNonNull(BeanUtil.copy(pointDetail,PointDetailVO.class));
+		BillRecord billRecord = billRecordService.getById(pointDetailVO.getBillRecordId());
+		if(billRecord != null){
+			pointDetailVO.setPayWay(billRecord.getPayWay());
+		}
+		return pointDetailVO;
+	}
+}

+ 40 - 0
src/main/java/org/springblade/modules/ldt/shop/controller/AppShopController.java

@@ -8,7 +8,9 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import oracle.jdbc.proxy.annotation.Post;
 import org.springblade.common.constant.SystemConstant;
+import org.springblade.common.enums.OrderType;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
@@ -130,6 +132,26 @@ public class AppShopController {
 		return R.data(pages);
 	}
 
+	/**
+	 * 获取某个会员在某个商户中的历史消费记录
+	 */
+	@GetMapping("/getMemberBillRecord")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "获取某个会员在某个商户中的历史消费记录", notes = "传入member")
+	public R<IPage<BillRecordVO>> getMemberBillRecord(MemberVO member, Query query) {
+		Assert.notNull(member.getShopId(),"商店id不能为空");
+		Assert.notNull(member.getId(),"会员id不能为空");
+
+		IPage<BillRecord> pages = billRecordService.page(Condition.getPage(query),new QueryWrapper<>(new BillRecord())
+			.lambda().eq(BillRecord::getPayStatus,SystemConstant.BillRecordPayStatus.PAYED.getValue())
+			.eq(BillRecord::getShopId,member.getShopId())
+			.eq(BillRecord::getType, OrderType.USER_PAY)
+			.eq(BillRecord::getMemberId,member.getId())
+			.orderByDesc(BillRecord::getUpdateTime));
+
+		return R.data(BillRecordWrapper.build(loginUserService,pointDetailService).pageVO(pages));
+	}
+
 	/**
 	 * 应收明细
 	 */
@@ -178,6 +200,24 @@ public class AppShopController {
 
 
 
+	}
+
+	/**
+	 * 商户修改会员中心
+	 */
+	@PostMapping("/updateMemberCenter")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "通过商店id获取会员列表", notes = "传入billRecord")
+	public R updateMemberCenter(@RequestBody Shop shop) {
+		Assert.notNull(shop.getId(),"商店id不能为空");
+		Assert.notNull(shop.getConsumeOnePoint(),"每消费一元赠送多少积分不能为空");
+
+		Shop oldEntity = shopService.getById(shop.getId());
+		Assert.notNull(oldEntity,"商户不存在");
+		oldEntity.setConsumeOnePoint(shop.getConsumeOnePoint());
+
+		return R.data(shopService.updateById(oldEntity));
+
 	}
 
 	/**

+ 153 - 92
src/main/java/org/springblade/modules/payment/listener/UserPayListener.java

@@ -10,6 +10,7 @@ import org.springblade.modules.ldt.channel.entity.PointChannel;
 import org.springblade.modules.ldt.channel.service.IPointChannelService;
 import org.springblade.modules.ldt.channeluserpoint.entity.ChannelUserPoint;
 import org.springblade.modules.ldt.channeluserpoint.service.IChannelUserPointService;
+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;
@@ -27,6 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
@@ -61,9 +65,11 @@ public class UserPayListener {
 	@Autowired
 	private ILoginUserService loginUserService;
 
+
+
 	@EventListener
 	@Async
-//	@Transactional
+	@Transactional
 	public void PaySuccess(UserPayEvent userPayEvent){
 		SuccessParams successParams = userPayEvent.getSuccessParams();
 
@@ -75,109 +81,164 @@ public class UserPayListener {
 		}else{
 			String shopId = billRecord.getShopId().toString();
 			synchronized (shopId.intern()){//对商户加锁
-				Shop shop = shopService.getById(billRecord.getShopId());
-
-				if(SystemConstant.BillRecordPayStatus.PAYING.getValue() == billRecord.getPayStatus() && "success".equals(successParams.getStatus())){//只处理待支付订单变成已支付成功的情况
 
-					if(billRecord.getUserId() == null){//非平台用户支付直接增加用户可提现余额,无需赠送积分
-						billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-						billRecord.setSubsidy(BigDecimal.valueOf(1));
-						billRecord.setPayWay(successParams.getPayChannel());
-						billRecordService.updateById(billRecord);
-						shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice() != null ?
-							shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()) : billRecord.getRealPayAmount());
+				try{
+					Shop shop = shopService.getById(billRecord.getShopId());
+
+					if(SystemConstant.BillRecordPayStatus.PAYING.getValue() == billRecord.getPayStatus() && "success".equals(successParams.getStatus())){//只处理待支付订单变成已支付成功的情况
+
+						if(billRecord.getUserId() == null){//非平台用户支付直接增加用户可提现余额,无需赠送积分
+							billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+							billRecord.setSubsidy(BigDecimal.valueOf(1));
+							billRecord.setPayWay(successParams.getPayChannel().equals("WECHAT")?"微信用户":"支付宝用户");
+							billRecordService.updateById(billRecord);
+							shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice() != null ?
+								shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()) : billRecord.getRealPayAmount());
+							shopService.updateById(shop);
+							return;
+						}
+
+						/**                  平台用户支付回调                 **/
+						//增加商户的可提现余额
+						LoginUser loginUser = loginUserService.getById(billRecord.getUserId());
+						shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()));
+						shop.setSales(shop.getSales() != null?shop.getSales()+1:1);
+						shop.setTradeTimes(shop.getTradeTimes() != null ? shop.getTradeTimes() +1 : 1);
 						shopService.updateById(shop);
-						return;
-					}
+						//支付成功增加商场和商家的积分成本,增加用户的可用积分余额
 
-					/**                  平台用户支付回调                 **/
-					//增加商户的可提现余额
-					shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()));
-					shop.setSales(shop.getSales() != null?shop.getSales()+1:1);
-					shop.setTradeTimes(shop.getTradeTimes() != null ? shop.getTradeTimes() +1 : 1);
-					shopService.updateById(shop);
-					//支付成功增加商场和商家的积分成本,增加用户的可用积分余额
-
-					//查询是否有商场送积分的待确认记录
-					List<PointDetail> mallPointDetails = pointDetailService.getBaseMapper().selectList(new QueryWrapper<>(new PointDetail()).lambda()
-						.eq(PointDetail::getBillRecordId,billRecord.getId())
-						.eq(PointDetail::getType,SystemConstant.PointDetailType.MALL_SEND.getValue()).orderByDesc(PointDetail::getCreateTime));
-					if (mallPointDetails.size() > 0) {
-						PointDetail mallPointDetail = mallPointDetails.get(0);
-						/**
-						 * 增加商场的积分成本
-						 */
-						mallPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-						pointDetailService.updateById(mallPointDetail);
-						//获取商场的积分渠道
-						PointChannel pointChannel = pointChannelService.getBaseMapper().selectOne(new QueryWrapper<>(new PointChannel()).lambda()
-							.eq(PointChannel::getType,SystemConstant.PointChannelType.MALL.getValue())
-							.eq(PointChannel::getRelationId,billRecord.getMallId()));
-						//获取该用户在商场渠道的积分信息
-						ChannelUserPoint channelUserPoint = channelUserPointService.getBaseMapper().selectOne(new QueryWrapper<>(new ChannelUserPoint()).lambda()
-							.eq(ChannelUserPoint::getUserId, billRecord.getUserId())
-							.eq(ChannelUserPoint::getChannelId, pointChannel.getId()));
-						//增加该用户在该商场的积分信息
-						channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().add(mallPointDetail.getPoint()));
-						channelUserPoint.setTotalPoint(channelUserPoint.getTotalPoint().add(mallPointDetail.getPoint()));
-						channelUserPoint.setUsablePointValue(channelUserPoint.getUsablePoint().multiply(pointChannel.getPointValue()).divide(BigDecimal.valueOf(100)));
-						channelUserPointService.updateById(channelUserPoint);
-						//增加该商场的积分总价值
-						Mall mall = mallService.getById(billRecord.getMallId());
-
-						mall.setTotalPointValue(mall.getTotalPointValue() != null?mall.getTotalPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
-						mallService.updateById(mall);
-						//增加会员的可用积分
-						Member mallMember = memberService.getBaseMapper().selectOne(new QueryWrapper<>(new Member()).lambda()
+						//查询是否有商场送积分的待确认记录
+						List<PointDetail> mallPointDetails = pointDetailService.getBaseMapper().selectList(new QueryWrapper<>(new PointDetail()).lambda()
+							.eq(PointDetail::getBillRecordId,billRecord.getId())
+							.eq(PointDetail::getType,SystemConstant.PointDetailType.MALL_SEND.getValue()).orderByDesc(PointDetail::getCreateTime));
+						Member shopMember  = memberService.getBaseMapper().selectOne(new QueryWrapper<>(new Member()).lambda()
+							.eq(Member::getUserId,billRecord.getUserId())
+							.eq(Member::getType,SystemConstant.MALLORSHOP.SHOP.getValue())
+							.eq(Member::getShopId,billRecord.getShopId()));
+						Member mallMember =  memberService.getBaseMapper().selectOne(new QueryWrapper<>(new Member()).lambda()
 							.eq(Member::getType,SystemConstant.MALLORSHOP.MALL.getValue())
 							.eq(Member::getUserId,billRecord.getUserId())
 							.eq(Member::getMallId,billRecord.getMallId()));
-						mallMember.setPointTotal(mallMember.getPointTotal() != null?mallMember.getPointTotal().add(mallPointDetail.getPoint()) :mallPointDetail.getPoint());
-						mallMember.setPointValue(mallMember.getPointValue() != null?mallMember.getPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
-						memberService.updateById(mallMember);
-						//增加会员
-					}
+						ChannelUserPoint channelUserPoint = null;
+						if (mallPointDetails.size() > 0) {
+							PointDetail mallPointDetail = mallPointDetails.get(0);
+							/**
+							 * 增加商场的积分成本
+							 */
+							mallPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+							pointDetailService.updateById(mallPointDetail);
+							//获取商场的积分渠道
+							PointChannel pointChannel = pointChannelService.getBaseMapper().selectOne(new QueryWrapper<>(new PointChannel()).lambda()
+								.eq(PointChannel::getType,SystemConstant.PointChannelType.MALL.getValue())
+								.eq(PointChannel::getRelationId,billRecord.getMallId()));
+							//获取该用户在商场渠道的积分信息
+							 channelUserPoint = channelUserPointService.getBaseMapper().selectOne(new QueryWrapper<>(new ChannelUserPoint()).lambda()
+								.eq(ChannelUserPoint::getUserId, billRecord.getUserId())
+								.eq(ChannelUserPoint::getChannelId, pointChannel.getId()));
+							//增加该用户在该商场的积分信息
+							channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().add(mallPointDetail.getPoint()));
+							channelUserPoint.setTotalPoint(channelUserPoint.getTotalPoint().add(mallPointDetail.getPoint()));
+							channelUserPoint.setUsablePointValue(channelUserPoint.getUsablePoint().multiply(pointChannel.getPointValue()).divide(BigDecimal.valueOf(100)));
+							channelUserPointService.updateById(channelUserPoint);
+							//增加该商场的积分总价值
+							Mall mall = mallService.getById(billRecord.getMallId());
+							mall.setTotalPointValue(mall.getTotalPointValue() != null?mall.getTotalPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
+							mallService.updateById(mall);
+							//修改用户信息的渠道总积分价值
+
+							loginUser.setChannelPointValue(loginUser.getChannelPointValue() != null ? loginUser.getChannelPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
+							loginUserService.updateById(loginUser);
+							//增加会员的可用积分
+
+							mallMember.setPointTotal(mallMember.getPointTotal() != null?mallMember.getPointTotal().add(mallPointDetail.getPoint()) :mallPointDetail.getPoint());
+							mallMember.setPointValue(mallMember.getPointValue() != null?mallMember.getPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
+							mallMember.setPayTotal(mallMember.getPayTotal()!= null ? mallMember.getPayTotal().add(billRecord.getPrice()):billRecord.getPrice());
+							memberService.updateById(mallMember);
+						}
 
-					/**
-					 * 商场送积分的待确认记录
-					 */
-					List<PointDetail> shopPointDetails = pointDetailService.getBaseMapper().selectList(new QueryWrapper<>(new PointDetail()).lambda()
-						.eq(PointDetail::getBillRecordId,billRecord.getId())
-						.eq(PointDetail::getType,SystemConstant.PointDetailType.SHOP_SEND.getValue()).orderByDesc(PointDetail::getCreateTime));
-					if(shopPointDetails.size()>0){
-						PointDetail shopPointDetail = shopPointDetails.get(0);
-
-						//增加商家的积分成本
-						shop.setTotalPointValue(shop.getTotalPointValue() != null ? shop.getTotalPointValue().add(shopPointDetail.getPointValue()):shopPointDetail.getPointValue());
-						shopService.updateById(shop);
-						shopPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-						pointDetailService.updateById(shopPointDetail);
-						//增加该商店会员的可用积分
-						Member shopMember = memberService.getBaseMapper().selectOne(new QueryWrapper<>(new Member()).lambda()
-							.eq(Member::getUserId,billRecord.getUserId())
-							.eq(Member::getType,SystemConstant.MALLORSHOP.SHOP.getValue())
-							.eq(Member::getShopId,billRecord.getShopId()));
-						shopMember.setPointValue(shopMember.getPointValue() != null ? shopMember.getPointValue().add(shopPointDetail.getPointValue()): shopPointDetail.getPointValue());
-						shopMember.setPointTotal(shopMember.getPointTotal() != null ? shopMember.getPointTotal().add(shopPointDetail.getPoint()): shopPointDetail.getPoint());
-						memberService.updateById(shopMember);
+						/**
+						 * 商场送积分的待确认记录
+						 */
+						List<PointDetail> shopPointDetails = pointDetailService.getBaseMapper().selectList(new QueryWrapper<>(new PointDetail()).lambda()
+							.eq(PointDetail::getBillRecordId,billRecord.getId())
+							.eq(PointDetail::getType,SystemConstant.PointDetailType.SHOP_SEND.getValue()).orderByDesc(PointDetail::getCreateTime));
+						if(shopPointDetails.size()>0){
+							PointDetail shopPointDetail = shopPointDetails.get(0);
+
+							//增加商家的积分成本
+							shop.setTotalPointValue(shop.getTotalPointValue() != null ? shop.getTotalPointValue().add(shopPointDetail.getPointValue()):shopPointDetail.getPointValue());
+							shopService.updateById(shop);
+							shopPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+							pointDetailService.updateById(shopPointDetail);
+							//修改该用户的
+							//增加该商店会员的可用积分
+
+							shopMember.setPointValue(shopMember.getPointValue() != null ? shopMember.getPointValue().add(shopPointDetail.getPointValue()): shopPointDetail.getPointValue());
+							shopMember.setPointTotal(shopMember.getPointTotal() != null ? shopMember.getPointTotal().add(shopPointDetail.getPoint()): shopPointDetail.getPoint());
+							shopMember.setPayTotal(shopMember.getPayTotal() != null ? shopMember.getPayTotal().add(billRecord.getPrice()):billRecord.getPrice());
+							memberService.updateById(shopMember);
+							loginUser.setPointValue(loginUser.getPointValue() != null ? loginUser.getPointValue().add(shopPointDetail.getPointValue()):shopPointDetail.getPointValue());
+							loginUser.setPoint(loginUser.getPoint() != null ? loginUser.getPoint().add(shopPointDetail.getPoint()):shopPointDetail.getPoint());
+							loginUserService.updateById(loginUser);
+
+						}
+
+
+
+
+						//判断用户是否使用了大B的积分支付
+						PointDetail channelPointDetail = pointDetailService.getBaseMapper().selectOne(new QueryWrapper<>(new PointDetail()).lambda()
+							.eq(PointDetail::getBillRecordId,billRecord.getId()).eq(PointDetail::getType,SystemConstant.PointDetailType.USER_PAY)
+							.eq(PointDetail::getMemberId,mallMember.getId()).eq(PointDetail::getBillRecordStatus,SystemConstant.BillRecordPayStatus.PAYING.getValue()));
+						if(channelPointDetail != null){
+							channelPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+							pointDetailService.updateById(channelPointDetail);
+							if(channelUserPoint != null){
+								channelUserPoint.setUsablePointValue(channelUserPoint.getUsablePoint().subtract(channelPointDetail.getPoint()));
+								channelUserPointService.updateById(channelUserPoint);
+								//减少用户信息的渠道积分
+								loginUser.setChannelPointValue(loginUser.getChannelPointValue().subtract(channelPointDetail.getPointValue()));
+								loginUserService.updateById(loginUser);
+								/**   判断是否有商家待应收记录   **/
+								ShopYingshou shopYingshou = shopYingshouService.getBaseMapper().selectOne(new QueryWrapper<>(new ShopYingshou()).lambda()
+									.eq(ShopYingshou::getBillRecordStatus, SystemConstant.BillRecordPayStatus.PAYING.getValue())
+									.eq(ShopYingshou::getBillRecordId, billRecord.getId()));
+								if(shopYingshou != null){
+									//增加商户的总应收
+									shopYingshou.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+									shop.setTotalFunkPrice(shop.getTotalFunkPrice() != null? shop.getTotalFunkPrice().add(shopYingshou.getPointValue()):shopYingshou.getPointValue());
+									shopService.updateById(shop);
+								}
+							}
+						}
+
+
+
+
+
+						//判断用户是否使用了小B的积分支付
+						PointDetail shopPointDetail = pointDetailService.getBaseMapper().selectOne(new QueryWrapper<>(new PointDetail()).lambda()
+							.eq(PointDetail::getBillRecordId,billRecord.getId()).eq(PointDetail::getType,SystemConstant.PointDetailType.USER_PAY)
+							.eq(PointDetail::getMemberId,shopMember.getId()).eq(PointDetail::getBillRecordStatus,SystemConstant.BillRecordPayStatus.PAYING.getValue()));
+						if(shopPointDetail != null){
+							shopPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+							pointDetailService.updateById(shopPointDetail);
+							//减少用户信息的可用余额
+							loginUser.setPointValue(loginUser.getPointValue().subtract(shopPointDetail.getPointValue()));
+							loginUserService.updateById(loginUser);
+						}
+
+						//修改订单状态
+						billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+						billRecordService.updateById(billRecord);
 
 					}
+				}catch (Exception e){
 
-					/**   判断是否有商家待应收记录   **/
-					ShopYingshou shopYingshou = shopYingshouService.getBaseMapper().selectOne(new QueryWrapper<>(new ShopYingshou()).lambda()
-						.eq(ShopYingshou::getBillRecordStatus, SystemConstant.BillRecordPayStatus.PAYING.getValue())
-						.eq(ShopYingshou::getBillRecordId, billRecord.getId()));
-					if(shopYingshou != null){
-						//增加商户的总应收
-						shopYingshou.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-						shop.setTotalFunkPrice(shop.getTotalFunkPrice() != null? shop.getTotalFunkPrice().add(shopYingshou.getPointValue()):shopYingshou.getPointValue());
-						shopService.updateById(shop);
-					}
-					//修改订单状态
-					billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-					billRecordService.updateById(billRecord);
+					e.printStackTrace();
 
 				}
+
 			}
 
 		}

+ 1 - 1
src/main/resources/application.yml

@@ -24,7 +24,7 @@ spring:
       #validation-query: select 1 from dual
       validation-query-timeout: 2000
       initial-size: 5
-      max-active: 20
+      max-active: 200
       min-idle: 5
       max-wait: 60000
       test-on-borrow: false