Просмотр исходного кода

支付回调,非平台用户支付

LIDEXI 4 лет назад
Родитель
Сommit
434e5d6f1b
16 измененных файлов с 606 добавлено и 59 удалено
  1. 18 0
      src/main/java/org/springblade/common/enums/PayWay.java
  2. 4 0
      src/main/java/org/springblade/modules/ldt/channeluserpoint/dto/ChannelUserPointDTO.java
  3. 92 0
      src/main/java/org/springblade/modules/ldt/loginuser/controller/AppUserController.java
  4. 34 0
      src/main/java/org/springblade/modules/ldt/loginuser/controller/LoginUserController.java
  5. 1 1
      src/main/java/org/springblade/modules/ldt/loginuser/entity/LoginUser.java
  6. 322 55
      src/main/java/org/springblade/modules/ldt/loginuser/service/impl/LoginUserServiceImpl.java
  7. 1 0
      src/main/java/org/springblade/modules/ldt/mall/controller/AppMallController.java
  8. 1 0
      src/main/java/org/springblade/modules/ldt/mall/controller/MallController.java
  9. 7 1
      src/main/java/org/springblade/modules/ldt/mall/entity/Mall.java
  10. 1 0
      src/main/java/org/springblade/modules/ldt/mall/mapper/MallMapper.xml
  11. 4 0
      src/main/java/org/springblade/modules/ldt/pointdetail/dto/PointDetailDTO.java
  12. 10 0
      src/main/java/org/springblade/modules/ldt/pointdetail/entity/PointDetail.java
  13. 3 0
      src/main/java/org/springblade/modules/ldt/shop/controller/AppShopController.java
  14. 4 1
      src/main/java/org/springblade/modules/ldt/shop/entity/Shop.java
  15. 1 1
      src/main/java/org/springblade/modules/ldt/shopyingshou/entity/ShopYingshou.java
  16. 103 0
      src/main/java/org/springblade/modules/payment/listener/UserPayListener.java

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

@@ -0,0 +1,18 @@
+package org.springblade.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Created By lidexi in 2021/8/10
+ **/
+
+@AllArgsConstructor
+@Getter
+public enum  PayWay {
+
+	POINT("积分支付"),
+	MIX("混合支付"),
+	CASH("现金支付");
+	String name;
+}

+ 4 - 0
src/main/java/org/springblade/modules/ldt/channeluserpoint/dto/ChannelUserPointDTO.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.ldt.channeluserpoint.dto;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.springblade.modules.ldt.channeluserpoint.entity.ChannelUserPoint;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -31,4 +32,7 @@ import lombok.EqualsAndHashCode;
 public class ChannelUserPointDTO extends ChannelUserPoint {
 	private static final long serialVersionUID = 1L;
 
+	@ApiModelProperty("时间: yyyy-MM")
+	private String monthTime;
+
 }

+ 92 - 0
src/main/java/org/springblade/modules/ldt/loginuser/controller/AppUserController.java

@@ -0,0 +1,92 @@
+package org.springblade.modules.ldt.loginuser.controller;
+
+import com.alibaba.fastjson.support.geo.Point;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.common.constant.SystemConstant;
+import org.springblade.core.mp.support.Condition;
+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.channeluserpoint.dto.ChannelUserPointDTO;
+import org.springblade.modules.ldt.channeluserpoint.entity.ChannelUserPoint;
+import org.springblade.modules.ldt.channeluserpoint.service.IChannelUserPointService;
+import org.springblade.modules.ldt.channeluserpoint.vo.ChannelUserPointVO;
+import org.springblade.modules.ldt.loginuser.entity.LoginUser;
+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.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Created By lidexi in 2021/8/11
+ **/
+@RestController
+@AllArgsConstructor
+@RequestMapping("cyzh-ldt/loginuser")
+@Api(value = "", tags = "接口")
+public class AppUserController {
+
+	private final IChannelUserPointService channelUserPointService;
+	private final IPointDetailService pointDetailService;
+
+	/**
+	 * 渠道积分记录分页
+	 */
+	@GetMapping("/channeluserpoint/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入channelUserPoint")
+	public R<IPage<PointDetail>> channeluserpointList(PointDetailDTO pointDetailDTO, Query query) {
+		PointDetail pointDetail = Objects.requireNonNull(BeanUtil.copy(pointDetailDTO,PointDetail.class));
+		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+		String selectMonth = null;
+		try {
+			selectMonth = simpleDateFormat.format(simpleDateFormat.parse(pointDetailDTO.getMonthTime()));
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		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())
+			.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);
+	}
+
+	/**
+	 * 余额分页
+	 */
+	@GetMapping("/remaining/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入channelUserPoint")
+	public R<IPage<PointDetail>> list(PointDetailDTO pointDetailDTO, Query query) {
+		PointDetail pointDetail = Objects.requireNonNull(BeanUtil.copy(pointDetailDTO,PointDetail.class));
+		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+		String selectMonth = null;
+		try {
+			selectMonth = simpleDateFormat.format(simpleDateFormat.parse(pointDetailDTO.getMonthTime()));
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		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);
+	}
+}

+ 34 - 0
src/main/java/org/springblade/modules/ldt/loginuser/controller/LoginUserController.java

@@ -29,6 +29,9 @@ import javax.smartcardio.CardChannel;
 import javax.validation.Valid;
 
 import org.springblade.common.cache.CacheNames;
+import org.springblade.common.constant.SystemConstant;
+import org.springblade.common.enums.OrderType;
+import org.springblade.common.enums.PayWay;
 import org.springblade.common.utils.OtpUtils;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.mp.support.Condition;
@@ -38,6 +41,7 @@ import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.ldt.activityjoinrecord.service.IActivityJoinRecordService;
 import org.springblade.modules.ldt.billrecord.entity.BillRecord;
+import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
 import org.springblade.modules.ldt.loginuser.dto.LoginUserDTO;
 import org.springblade.modules.ldt.loginuser.dto.PayDto;
 import org.springblade.modules.ldt.member.service.IMemberService;
@@ -71,6 +75,7 @@ public class LoginUserController extends BladeController {
 	private final ILoginUserService loginUserService;
 
 	private final IShopService shopService;
+	private final IBillRecordService billRecordService;
 
 	private final static String USER_INFO = "userId:";
 	private final RedisTemplate<String,String> redisTemplate;
@@ -191,6 +196,35 @@ public class LoginUserController extends BladeController {
 		return R.data(billRecord);
 	}
 
+	/**
+	 * 非平台用户扫码支付生成预订单-直接用微信原生的扫一扫支付,没有userId
+	 */
+	@PostMapping("/payBeforeForNormal")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "非平台用户扫码支付生成预订单", notes = "传入loginUser")
+	public R<BillRecord> payBeforeForNormal(@RequestBody PayDto payDto) {
+
+		Assert.notNull(payDto.getMoney(),"商品价格不能为空");
+		Assert.notNull(payDto.getShopId(),"商店信息不能为空");
+		Shop shop = shopService.getById(payDto.getShopId());
+		Assert.notNull(shop,"商店信息不存在");
+
+		//该记录没有用户信息
+		BillRecord billRecord = new BillRecord();
+		billRecord.setShopId(shop.getId());
+		billRecord.setPrice(payDto.getMoney());
+		billRecord.setRealPayAmount(payDto.getMoney());
+		billRecord.setPayWay(PayWay.CASH.getName());
+		billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+		billRecord.setBillsTitle(payDto.getBillsTitle());
+		billRecord.setExpireTime(payDto.getExpireTime());
+		billRecord.setType(OrderType.USER_PAY.getName());
+		billRecord.setMallId(shop.getMallId());
+		billRecord.setBillsDesc(payDto.getBillsTitle());
+		billRecordService.updateById(billRecord);
+		return R.data(billRecord);
+	}
+
 	/**
 	 * 商家扫用户付款码时用户端轮询redis中的订单信息
 	 */

+ 1 - 1
src/main/java/org/springblade/modules/ldt/loginuser/entity/LoginUser.java

@@ -90,7 +90,7 @@ public class LoginUser extends BaseEntity {
 	 * 积分数
 	 */
 	@ApiModelProperty(value = "积分数")
-	private Integer point;
+	private BigDecimal point;
 
 	/**
 	 * 余额

+ 322 - 55
src/main/java/org/springblade/modules/ldt/loginuser/service/impl/LoginUserServiceImpl.java

@@ -24,6 +24,7 @@ import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.constant.SystemConstant;
 import org.springblade.common.enums.OrderType;
+import org.springblade.common.enums.PayWay;
 import org.springblade.common.enums.PaymentType;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.tool.api.R;
@@ -52,14 +53,19 @@ import org.springblade.modules.ldt.pointdetail.entity.PointDetail;
 import org.springblade.modules.ldt.pointdetail.service.IPointDetailService;
 import org.springblade.modules.ldt.shop.entity.Shop;
 import org.springblade.modules.ldt.shop.service.IShopService;
+import org.springblade.modules.ldt.shopyingshou.entity.ShopYingshou;
+import org.springblade.modules.ldt.shopyingshou.service.IShopYingshouService;
 import org.springblade.modules.system.service.IParamService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.net.ssl.SNIHostName;
 import java.math.BigDecimal;
 import java.sql.SQLOutput;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -89,6 +95,11 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 	private IParamService paramService;
 	@Autowired
 	private IMallService mallService;
+	@Autowired
+	private IShopYingshouService shopYingshouService;
+	@Autowired
+	private IShopService shopService;
+
 
 
 	@Override
@@ -117,19 +128,19 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		billRecord.setShopId(payDto.getShopId());
 		billRecord.setMallId(shop.getMallId());
 		billRecord.setType(OrderType.USER_PAY.getName());
-		billRecord.setPayStatus(0);
 		billRecord.setBillsTitle(payDto.getBillsTitle());
 		billRecord.setAppId(payDto.getAppId());
 		billRecord.setOpenId(loginUser.getOpenid());
 		billRecord.setExpireTime(payDto.getExpireTime());
 		billRecord.setPayAmount(payDto.getMoney().toString());
 		billRecord.setUserId(payDto.getLoginUserId());
+		billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 		billRecord.setPrice(payDto.getMoney());//总价
 		billRecordService.save(billRecord);
 		billRecord.setSubsidy(BigDecimal.valueOf(1));
 
-		BigDecimal gxServerRate =BigDecimal.valueOf(Long.valueOf(paramService.getValue(CommonConstant.ACTIVITY_SERVICE_RATE))); //国信活动服务费,默认10%;
-		BigDecimal activityServerRate = BigDecimal.valueOf(Long.valueOf(paramService.getValue(CommonConstant.SCORE_SERVIVE_RATE)));//积分服务费
+		BigDecimal gxServerRate =BigDecimal.valueOf(Double.valueOf(paramService.getValue(CommonConstant.ACTIVITY_SERVICE_RATE))); //国信活动服务费,默认10%;
+		BigDecimal activityServerRate = BigDecimal.valueOf(Double.valueOf(paramService.getValue(CommonConstant.SCORE_SERVIVE_RATE)));//积分服务费
 		Map<String,Member> memberMap = this.getMembers(shop,payDto);
 		Member shopMember = memberMap.get("shopMember");//商店会员
 		Member mallMember = memberMap.get("mallMember");//商场会员
@@ -153,7 +164,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		//用户应付金额 = 商品价格* 小B折扣*大B折扣+国信活动服务费
 		BigDecimal yingfu = payDto.getMoney().multiply(billRecord.getSubsidy()).add(payDto.getMoney().multiply(activityServerRate));
 		billRecord.setYingfuAmount(yingfu);
-		//判断用户积分是否足够抵扣 : (用户应付金额 - 用户积分价值*(1+国信服务费率))     0
+
 
 		//1.先看该用户在该大B下的积分够不够用
 		//获取该大B的渠道信息
@@ -163,105 +174,276 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 			PointChannel pointChannel = pointChannelService.getBaseMapper().selectOne(new QueryWrapper<>(new PointChannel()).lambda()
 				.eq(PointChannel::getType, SystemConstant.PointChannelType.MALL.getValue())
 				.eq(PointChannel::getRelationId, shop.getMallId()));
+			if(pointChannel == null){//没有则创建
+				pointChannel = new PointChannel();
+				pointChannel.setType(SystemConstant.PointChannelType.MALL.getValue());
+				pointChannel.setRelationId(mall.getId());
+				pointChannel.setSort(1);
+				if(mall.getIsOpenMember() != 1){
+					Assert.isTrue(false,"商场未开启会员中心");
+				}
+				pointChannel.setPointValue(mall.getPoint().multiply(BigDecimal.valueOf(100)).divide(mall.getPointValue()));//100积分等于多少积分价值
+				pointChannel.setDiscount(BigDecimal.valueOf(100));
+				pointChannel.setName(mall.getName());
+				pointChannel.setLogo(mall.getPic());
+				pointChannel.setPaymentDays(mall.getPaymentDays()!= null? mall.getPaymentDays():0);
+			}
 			//获取该用户在该商场的可用积分
 			if(pointChannel != null){
 				ChannelUserPoint channelUserPoint = channelUserPointService.getBaseMapper().selectOne(new QueryWrapper<>(new ChannelUserPoint()).lambda()
 					.eq(ChannelUserPoint::getUserId,loginUser.getId()).eq(ChannelUserPoint::getChannelId,pointChannel.getId()));
 				//渠道积分价值
+				if(channelUserPoint == null){//没有则创建
+					channelUserPoint = new ChannelUserPoint();
+					channelUserPoint.setUserId(loginUser.getId());
+					channelUserPoint.setChannelId(pointChannel.getId());
+					channelUserPoint.setTotalPoint(BigDecimal.ZERO);
+					channelUserPoint.setUsablePoint(BigDecimal.ZERO);
+					channelUserPoint.setUsedPoint(BigDecimal.ZERO);
+					channelUserPoint.setChannelName(mall.getName());
+					channelUserPoint.setUserPhone(loginUser.getNickName());
+					channelUserPointService.save(channelUserPoint);
+				}
 
 				BigDecimal channelPointValue = channelUserPoint.getUsablePoint().multiply(pointChannel.getPointValue()).divide(BigDecimal.valueOf(100));
 				//判断大B渠道的积分是否足够支付
 				boolean channelScoreEnough = yingfu.subtract(channelPointValue.multiply(BigDecimal.ONE.add(gxServerRate))).compareTo(BigDecimal.ZERO) > 0 ? false : true;
 
 				if(channelScoreEnough){//大B渠道的积分足够支付
+					billRecord.setRealPayAmount(BigDecimal.ZERO);
+					billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+					billRecord.setPayWay(PayWay.POINT.getName());//全部由积分支付
+
 					PointDetail pointDetail = new PointDetail();
 					pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
 					pointDetail.setBillRecordId(billRecord.getId());
 					pointDetail.setUserId(payDto.getLoginUserId());
+					pointDetail.setMemberId(shopMember.getId());
 					pointDetail.setGxRewardPointValue(yingfu.multiply(gxServerRate));
 					pointDetail.setPoint(yingfu.multiply(mall.getPoint()).divide(mall.getPointValue()));
 					pointDetail.setPointValue(yingfu);
 					pointDetail.setLogo(mall.getPic());
-					pointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+					pointDetail.setBillRecordStatus(billRecord.getPayStatus());
 					pointDetail.setShopId(shop.getId());
+					pointDetail.setChannelId(pointChannel.getId());
 					pointDetail.setName(mall.getName());
 					pointDetailService.save(pointDetail);
-					billRecord.setRealPayAmount(BigDecimal.ZERO);
+
 					//扣除该用户在该大B渠道的积分价值
-					channelUserPoint.setUsedPoint(channelUserPoint.getUsedPoint().add(pointDetail.getPoint()));
-					channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().subtract(pointDetail.getPoint()));
+					channelUserPoint.setUsedPoint(channelUserPoint.getUsedPoint().add(pointDetail.getPoint()).add(pointDetail.getGxRewardPointValue()));
+					channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().subtract(pointDetail.getPoint()).subtract(pointDetail.getGxRewardPointValue()));
 					channelUserPointService.updateById(channelUserPoint);
 
+
 					billRecordService.updateById(billRecord);
+					//商家应收明细
+					this.saveShopYingShou(billRecord,pointChannel,pointDetail,shop);
 
 					//商场积分成本
 					if(mall.getIsOpenMember() == 1){//商场开启会员中心
-						PointDetail mallSendPoint = new PointDetail();
-						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.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
-						//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分数/商场会员中心的积分价值
-						mallSendPoint.setPointValue(mallSendPoint.getPoint().multiply(mall.getPoint()).divide(mall.getPointValue()));
-						mallSendPoint.setBillRecordId(billRecord.getId());
-						mallSendPoint.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-						pointDetailService.save(mallSendPoint);
-						//新增该用户在该商场渠道的积分和积分价值
-						channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().add(mallSendPoint.getPoint()));
-						channelUserPoint.setTotalPoint(channelUserPoint.getTotalPoint().add(mallSendPoint.getPoint()));
-						channelUserPointService.updateById(channelUserPoint);
+						this.addMallPointValue(mall,loginUser,billRecord,channelUserPoint);
 					}
-
-
 					//新增该用户的积分余额--商家积分成本
 					if(shop.getIsOpenMember() == 1){//判断该商店是否开启会员中心
-						PointDetail shopPointDetail = new PointDetail();
-						shopPointDetail.setMallId(mall.getId());
-						shopPointDetail.setShopId(shop.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()));
-						//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分数/商家会员中心的积分价值
-						shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPoint()).divide(shop.getPointValue()));
+						this.addShopPointValue(mall,shop,loginUser,billRecord);
 					}
 
-
-
 					return billRecord;
 				}else{//大B渠道的积分不足支付,
 					if(channelPointValue.compareTo(BigDecimal.ZERO) == 0){//大B渠道积分价值为零,扣用户余额
 						if(loginUser.getPointValue().compareTo(BigDecimal.ZERO) == 0){//用户余额为0
 							billRecord.setRealPayAmount(yingfu);
+							billRecord.setPayWay(PayWay.CASH.getName());//现金支付
+							billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 							billRecordService.updateById(billRecord);
+
+							//用户余额为0时用户需要全额支付,待支付回调成功后才会发放积分
 							return billRecord;
 						}else{//余额不为0
 							boolean userAccoutEnough = yingfu.subtract(loginUser.getPointValue().multiply(BigDecimal.ONE.add(gxServerRate))).compareTo(BigDecimal.ZERO) > 0 ? false : true;
 							if(userAccoutEnough){//余额够扣
 								//直接扣余额
 								billRecord.setRealPayAmount(BigDecimal.ZERO);
+								billRecord.setPayWay(PayWay.POINT.getName());
+								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+
+								PointDetail pointDetail = new PointDetail();
+								pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
+								pointDetail.setBillRecordId(billRecord.getId());
+								pointDetail.setMemberId(shopMember.getId());
+								pointDetail.setUserId(payDto.getLoginUserId());
+								pointDetail.setGxRewardPointValue(yingfu.multiply(gxServerRate));
+								pointDetail.setPoint(yingfu.multiply(shop.getPoint()).divide(shop.getPointValue()));
+								pointDetail.setPointValue(yingfu);
+								pointDetail.setLogo(shop.getCover());
+								pointDetail.setBillRecordStatus(billRecord.getPayStatus());
+								pointDetail.setShopId(shop.getId());
+								pointDetail.setName(shop.getName());
+								pointDetailService.save(pointDetail);
+
+								//该用户的余额 = 余额 - 支付的积分价值-国信积分服务费
+								loginUser.setPointValue(loginUser.getPointValue().subtract(pointDetail.getPointValue()).subtract(pointDetail.getGxRewardPointValue()));
+								this.updateById(loginUser);
+
+								//商场积分成本
+								if(mall.getIsOpenMember() == 1){//商场开启会员中心
+									this.addMallPointValue(mall,loginUser,billRecord,channelUserPoint);
+								}
+								//新增该用户的积分余额--商家积分成本
+								if(shop.getIsOpenMember() == 1){//判断该商店是否开启会员中心
+									this.addShopPointValue(mall,shop,loginUser,billRecord);
+								}
+
+								billRecordService.updateById(billRecord);
+
+								return billRecord;
+							}else{//余额不够扣
+								//国信积分服务费
+								BigDecimal gxRewardPointValue = loginUser.getPointValue().multiply(gxServerRate);
+								//可抵扣的余额
+								BigDecimal userEnablePointValue = loginUser.getPointValue().multiply(BigDecimal.ONE.subtract(gxServerRate));
+
+								//用户实际付款 = 应付 - 可用余额
+								billRecord.setRealPayAmount(yingfu.subtract(userEnablePointValue));
+								billRecord.setPayWay(PayWay.MIX.getName());
+								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+
+								PointDetail pointDetail = new PointDetail();
+								pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
+								pointDetail.setBillRecordId(billRecord.getId());
+								pointDetail.setMemberId(shopMember.getId());
+								pointDetail.setUserId(payDto.getLoginUserId());
+								pointDetail.setGxRewardPointValue(gxRewardPointValue);
+								pointDetail.setPoint(userEnablePointValue.multiply(shop.getPoint()).divide(shop.getPointValue()));
+								pointDetail.setPointValue(userEnablePointValue);
+								pointDetail.setLogo(shop.getCover());
+								pointDetail.setBillRecordStatus(billRecord.getPayStatus());
+								pointDetail.setShopId(shop.getId());
+								pointDetail.setName(shop.getName());
+								pointDetailService.save(pointDetail);
+
+								//该用户的余额 = 0 待支付回调后才能扣余额
+//								loginUser.setPointValue(BigDecimal.ZERO);
+//								this.updateById(loginUser);
+
+								billRecordService.updateById(billRecord);
+
+								return billRecord;
+							}
+						}
+					}else{ //大B渠道积分不为0且不够扣,先扣大B渠道积分价值,再扣用户余额
+						billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+						//大B渠道国信积分服务费
+						BigDecimal channelGxPointValue = channelUserPoint.getUsablePoint().multiply(gxServerRate);
+						//大B渠道可抵用积分
+						BigDecimal channelEnablePointValue = channelUserPoint.getUsablePoint().multiply(BigDecimal.ONE.subtract(gxServerRate));
+						PointDetail channelPointDetail = new PointDetail();
+						channelPointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
+						channelPointDetail.setBillRecordId(billRecord.getId());
+						channelPointDetail.setUserId(payDto.getLoginUserId());
+						channelPointDetail.setGxRewardPointValue(channelGxPointValue);
+						channelPointDetail.setPoint(channelEnablePointValue.multiply(mall.getPoint()).divide(mall.getPointValue()));
+						channelPointDetail.setPointValue(channelEnablePointValue);
+						channelPointDetail.setLogo(mall.getPic());
+						channelPointDetail.setBillRecordStatus(billRecord.getPayStatus());
+						channelPointDetail.setShopId(shop.getId());
+						channelPointDetail.setName(mall.getName());
+						pointDetailService.save(channelPointDetail);
+
+						//扣除该用户在该大B渠道的积分价值
+						channelUserPoint.setUsedPoint(channelUserPoint.getUsedPoint().add(channelPointDetail.getPoint()).add(channelPointDetail.getGxRewardPointValue()));
+						channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().subtract(channelPointDetail.getPoint()).subtract(channelPointDetail.getGxRewardPointValue()));
+						channelUserPointService.updateById(channelUserPoint);
+
+						//商家应收明细
+						this.saveShopYingShou(billRecord,pointChannel,channelPointDetail,shop);
+
+
+						//还应支付余额
+						yingfu = yingfu.subtract(channelEnablePointValue);
+						//判断用户是否有余额可扣
+						if(loginUser.getPointValue().compareTo(BigDecimal.ZERO) > 0 ){//用户有余额可扣
+							boolean userAccoutEnough = yingfu.subtract(loginUser.getPointValue().multiply(BigDecimal.ONE.add(gxServerRate))).compareTo(BigDecimal.ZERO) > 0 ? false : true;
+							if(userAccoutEnough){//用户余额够扣,扣用户余额即可
+								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+								billRecord.setPayWay(PayWay.POINT.getName());
+								billRecord.setRealPayAmount(BigDecimal.ZERO);
+								//扣除的国信积分服务费
+								BigDecimal gxRewardPointValue  = yingfu.multiply(gxServerRate);
+
+								PointDetail pointDetail = new PointDetail();
+								pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
+								pointDetail.setBillRecordId(billRecord.getId());
+								pointDetail.setMemberId(shopMember.getId());
+								pointDetail.setUserId(payDto.getLoginUserId());
+								pointDetail.setGxRewardPointValue(gxRewardPointValue);
+								pointDetail.setPoint(yingfu.multiply(shop.getPoint()).divide(shop.getPointValue()));
+								pointDetail.setPointValue(yingfu);
+								pointDetail.setLogo(shop.getCover());
+								pointDetail.setBillRecordStatus(billRecord.getPayStatus());
+								pointDetail.setShopId(shop.getId());
+								pointDetail.setName(shop.getName());
+								pointDetailService.save(pointDetail);
+
+								//该用户的余额 = 余额 - 支付的积分价值-国信积分服务费
+								loginUser.setPointValue(loginUser.getPointValue().subtract(pointDetail.getPointValue()).subtract(pointDetail.getGxRewardPointValue()));
+								this.updateById(loginUser);
+
+								//商场积分成本
+								if(mall.getIsOpenMember() == 1){//商场开启会员中心
+									this.addMallPointValue(mall,loginUser,billRecord,channelUserPoint);
+								}
+								//新增该用户的积分余额--商家积分成本
+								if(shop.getIsOpenMember() == 1){//判断该商店是否开启会员中心
+									this.addShopPointValue(mall,shop,loginUser,billRecord);
+								}
+
+
+
+								billRecordService.updateById(billRecord);
+
+								return billRecord;
+
+							}else{//余额不够扣,先扣除余额,再支付
+								//国信积分服务费
+								BigDecimal gxRewardPointValue = loginUser.getPointValue().multiply(gxServerRate);
+								//可抵扣的余额
+								BigDecimal userEnablePointValue = loginUser.getPointValue().multiply(BigDecimal.ONE.subtract(gxServerRate));
+
+								//用户实际付款 = 应付 - 可用余额
+								billRecord.setRealPayAmount(yingfu.subtract(userEnablePointValue));
+								billRecord.setPayWay(PayWay.MIX.getName());
+								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+
+								PointDetail pointDetail = new PointDetail();
+								pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
+								pointDetail.setBillRecordId(billRecord.getId());
+								pointDetail.setMemberId(shopMember.getId());
+								pointDetail.setUserId(payDto.getLoginUserId());
+								pointDetail.setGxRewardPointValue(gxRewardPointValue);
+								pointDetail.setPoint(userEnablePointValue.multiply(shop.getPoint()).divide(shop.getPointValue()));
+								pointDetail.setPointValue(userEnablePointValue);
+								pointDetail.setLogo(shop.getCover());
+								pointDetail.setBillRecordStatus(billRecord.getPayStatus());
+								pointDetail.setShopId(shop.getId());
+								pointDetail.setName(shop.getName());
+								pointDetailService.save(pointDetail);
+
+								//该用户的余额 = 0 待支付回调后才能扣余额
+//								loginUser.setPointValue(BigDecimal.ZERO);
+//								this.updateById(loginUser);
+
+								billRecordService.updateById(billRecord);
+
+								return billRecord;
 							}
+						}else{//用户无余额可扣
+							billRecord.setRealPayAmount(yingfu);
+							billRecord.setPayWay(PayWay.MIX.getName());
+							billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
+							billRecordService.updateById(billRecord);
+							return billRecord;
 						}
-					}else{ //先扣大B渠道积分价值,再扣用户余额
-						PointDetail pointDetail = new PointDetail();
-						pointDetail.setType(SystemConstant.PointDetailType.USER_PAY.getValue());
-						pointDetail.setBillRecordId(billRecord.getId());
-						pointDetail.setUserId(payDto.getLoginUserId());
-						pointDetail.setGxRewardPointValue(yingfu);
-						pointDetail.setPoint(yingfu.multiply(mall.getPoint()).divide(mall.getPointValue()));
-						pointDetail.setPointValue(yingfu);
-						pointDetail.setLogo(mall.getPic());
-						pointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
-						pointDetail.setShopId(shop.getId());
-						pointDetail.setName(mall.getName());
-						pointDetailService.save(pointDetail);
 					}
 				}
 			}
@@ -325,6 +507,8 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 			shopMember.setPointValue(BigDecimal.ZERO);
 			shopMember.setUserId(payDto.getLoginUserId());
 			memberService.save(shopMember);
+			shop.setMemberCount(shop.getMemberCount()+1);
+			shopService.updateById(shop);
 			memberMap.put("shopMember",shopMember);
 			//获取该用户在该商场的会员信息
 			if(shop.getMallId() != null){//该商店有商场信息
@@ -341,6 +525,8 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 					mallMember.setType(SystemConstant.MALLORSHOP.MALL.getValue());
 					mallMember.setMallId(shop.getMallId());
 					memberService.save(mallMember);
+					Mall mall = mallService.getById(shop.getMallId());
+					mall.setMemberCount(mall.getMemberCount()+1);
 					memberMap.put("mallMember",mallMember);
 				}
 			}
@@ -350,5 +536,86 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		return memberMap;
 	}
 
+	/**
+	 * 当用户不需要支付时新增商家的积分成本,增加用户的渠道可用积分
+	 * @param mall
+	 * @param loginUser
+	 * @param billRecord
+	 * @param channelUserPoint
+	 */
+
+	private void addMallPointValue(Mall mall,LoginUser loginUser,BillRecord billRecord,ChannelUserPoint channelUserPoint){
+		PointDetail mallSendPoint = new PointDetail();
+		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.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
+		//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分数/商场会员中心的积分价值
+		mallSendPoint.setPointValue(mallSendPoint.getPoint().multiply(mall.getPoint()).divide(mall.getPointValue()));
+		mallSendPoint.setBillRecordId(billRecord.getId());
+		mallSendPoint.setBillRecordStatus(billRecord.getPayStatus());
+		pointDetailService.save(mallSendPoint);
+		//新增该用户在该商场渠道的积分和积分价值
+		channelUserPoint.setUsablePoint(channelUserPoint.getUsablePoint().add(mallSendPoint.getPoint()));
+		channelUserPoint.setTotalPoint(channelUserPoint.getTotalPoint().add(mallSendPoint.getPoint()));
+		channelUserPointService.updateById(channelUserPoint);
+	}
+
+	/**
+	 *  当用户不需要支付时新增商店的积分成本,增加用户的可用积分(余额)
+	 * @param mall
+	 * @param shop
+	 * @param loginUser
+	 * @param billRecord
+	 */
+	private void addShopPointValue(Mall mall, Shop shop,LoginUser loginUser,BillRecord billRecord){
+		PointDetail shopPointDetail = new PointDetail();
+		shopPointDetail.setMallId(mall.getId());
+		shopPointDetail.setShopId(shop.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()));
+		//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分数/商家会员中心的积分价值
+		shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPoint()).divide(shop.getPointValue()));
+		shopPointDetail.setBillRecordStatus(billRecord.getPayStatus());
+		shopPointDetail.setBillRecordId(billRecord.getId());
+		pointDetailService.save(shopPointDetail);
+		//新增用户的余额(积分价值)
+		loginUser.setPointValue(loginUser.getPointValue().add(shopPointDetail.getPointValue()));
+		loginUser.setPoint(loginUser.getPoint().add(shopPointDetail.getPoint()));
+		this.updateById(loginUser);
+	}
+
+	/**
+	 * 当用户不需要支付时直接新增商家应收明细
+	 * @param billRecord
+	 * @param pointChannel
+	 * @param pointDetail
+	 * @param shop
+	 */
+	private void saveShopYingShou(BillRecord billRecord,PointChannel pointChannel,PointDetail pointDetail,Shop shop){
+		ShopYingshou shopYingshou = new ShopYingshou();
+		shopYingshou.setBillRecordId(billRecord.getId());
+		shopYingshou.setBillRecordStatus(billRecord.getPayStatus());
+		shopYingshou.setChannelId(pointChannel.getId());
+		shopYingshou.setChannelLogo(pointChannel.getLogo());
+		shopYingshou.setChannelName(pointChannel.getName());
+		shopYingshou.setJsStatus(SystemConstant.JieSuanStatus.jsing.getValue());
+		shopYingshou.setPaymentDays(pointChannel.getPaymentDays());
+		shopYingshou.setJsTime(LocalDateTime.now().plusDays(Long.valueOf(pointChannel.getPaymentDays())));//当前时间加上账期
+		shopYingshou.setPoint(pointDetail.getPoint());
+		shopYingshou.setPointValue(pointDetail.getPointValue());
+		shopYingshou.setShopId(shop.getId());
+		shopYingshouService.save(shopYingshou);
+	}
+
 
 }

+ 1 - 0
src/main/java/org/springblade/modules/ldt/mall/controller/AppMallController.java

@@ -204,6 +204,7 @@ public class AppMallController {
 	@ApiOperation(value = "商场创建会员中心", notes = "传入商场")
 	public R createMemberCenter(@RequestBody Mall mall) {
 		Mall oldEntity = mallService.getById(mall.getId());
+		Assert.isFalse(oldEntity.getIsOpenMember() == 1,"该商场已经创建过会员中心,不可重复创建");
 		Assert.notNull(oldEntity, "商场不存在");
 		Assert.notNull(mall.getPoint(), "积分数不能为空");
 		Assert.notNull(mall.getPointValue(), "积分对应的积分价值不能为空");

+ 1 - 0
src/main/java/org/springblade/modules/ldt/mall/controller/MallController.java

@@ -130,6 +130,7 @@ public class MallController extends BladeController {
 			pointChannel.setSort(1);
 			if(mallService.save(mall)){
 				pointChannel.setRelationId(mall.getId());
+				pointChannel.setPaymentDays(mall.getPaymentDays());
 				return R.status(pointChannelService.save(pointChannel));
 			}
 

+ 7 - 1
src/main/java/org/springblade/modules/ldt/mall/entity/Mall.java

@@ -139,7 +139,13 @@ public class Mall extends BaseEntity {
 	 * 积分总价值
 	 */
 	@ApiModelProperty(value = "积分总价值")
-	private Integer totalPointValue;
+	private BigDecimal totalPointValue;
+
+	/**
+	 * 已核销的积分价值
+	 */
+	@ApiModelProperty(value = "已核销的积分价值")
+	private BigDecimal hadVerifyPointValue;
 
 	/**
 	 * 图片

+ 1 - 0
src/main/java/org/springblade/modules/ldt/mall/mapper/MallMapper.xml

@@ -28,6 +28,7 @@
         <result column="pic" property="pic"/>
         <result column="introduce" property="introduce"/>
         <result column="payment_days" property="paymentDays"/>
+        <result column="had_verify_point_value" property="hadVerifyPointValue"/>
     </resultMap>
 
     <resultMap id="mallResultVOMap" type="org.springblade.modules.ldt.mall.vo.MallVO" extends="mallResultMap">

+ 4 - 0
src/main/java/org/springblade/modules/ldt/pointdetail/dto/PointDetailDTO.java

@@ -31,4 +31,8 @@ import lombok.EqualsAndHashCode;
 public class PointDetailDTO extends PointDetail {
 	private static final long serialVersionUID = 1L;
 
+	private String monthTime;
+
+
+
 }

+ 10 - 0
src/main/java/org/springblade/modules/ldt/pointdetail/entity/PointDetail.java

@@ -111,5 +111,15 @@ public class PointDetail extends BaseEntity {
 	@ApiModelProperty(value = "关联的支付记录状态")
 	private Integer billRecordStatus;
 
+	/**
+	 * 渠道id
+	 */
+	@ApiModelProperty(value = "渠道id")
+	private Long channelId;
+
+
+
+
+
 
 }

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

@@ -73,6 +73,7 @@ public class AppShopController {
 	@ApiOperation(value = "商店创建会员中心", notes = "传入商店")
 	public R createMemberCenter(@RequestBody Shop shop) {
 		Shop oldEntity = shopService.getById(shop.getId());
+		Assert.isFalse(oldEntity.getIsOpenMember() == 1,"该商家已经创建过会员中心,不可重复创建");
 		Assert.notNull(oldEntity, "商店不存在");
 		Assert.isTrue( SystemConstant.AuditStatus.PASS.getValue() == oldEntity.getAuditStatus(),
 			"商店还没通过审核,不能创建会员中心,请先联系商场审核");
@@ -112,6 +113,8 @@ public class AppShopController {
 		return R.data(pages);
 	}
 
+
+
 	/**
 	 * 通过商店id获取会员列表
 	 */

+ 4 - 1
src/main/java/org/springblade/modules/ldt/shop/entity/Shop.java

@@ -226,7 +226,7 @@ public class Shop extends BaseEntity {
 	 * 积分总价值
 	 */
 	@ApiModelProperty(value = "积分总价值")
-	private Integer totalPointValue;
+	private BigDecimal totalPointValue;
 
 	/**
 	 * 是否已开启会员中心
@@ -240,6 +240,9 @@ public class Shop extends BaseEntity {
 	@ApiModelProperty(value = "可提现总金额")
 	private BigDecimal withdrawTotalPrice;
 
+	@ApiModelProperty("总应收")
+	private BigDecimal totalFunkPrice;
+
 	/**
 	 * 提现密码
 	 */

+ 1 - 1
src/main/java/org/springblade/modules/ldt/shopyingshou/entity/ShopYingshou.java

@@ -68,7 +68,7 @@ public class ShopYingshou extends BaseEntity {
 	* 积分价值
 	*/
 		@ApiModelProperty(value = "积分价值")
-		private String pointValue;
+		private BigDecimal pointValue;
 	/**
 	* 关联的支付id
 	*/

+ 103 - 0
src/main/java/org/springblade/modules/payment/listener/UserPayListener.java

@@ -1,12 +1,32 @@
 package org.springblade.modules.payment.listener;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.checkerframework.checker.units.qual.A;
+import org.springblade.common.constant.SystemConstant;
+import org.springblade.core.log.logger.BladeLogger;
+import org.springblade.modules.ldt.billrecord.entity.BillRecord;
+import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
+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.mall.entity.Mall;
+import org.springblade.modules.ldt.mall.service.IMallService;
+import org.springblade.modules.ldt.pointdetail.entity.PointDetail;
+import org.springblade.modules.ldt.pointdetail.service.IPointDetailService;
+import org.springblade.modules.ldt.shop.entity.Shop;
+import org.springblade.modules.ldt.shop.service.IShopService;
 import org.springblade.modules.payment.entity.SuccessParams;
 import org.springblade.modules.payment.event.UserPayEvent;
+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.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * @author: lianghanqiang
  * @description: 用户付款回调
@@ -15,11 +35,94 @@ import org.springframework.transaction.annotation.Transactional;
 @Component
 public class UserPayListener {
 
+	@Autowired
+	private IBillRecordService billRecordService;
+	@Autowired
+	private IPointDetailService pointDetailService;
+	@Autowired
+	private IChannelUserPointService channelUserPointService;
+	@Autowired
+	private BladeLogger bladeLogger;
+	@Autowired
+	private IPointChannelService pointChannelService;
+	@Autowired
+	private IMallService mallService;
+	@Autowired
+	private IShopService shopService;
 
 	@EventListener
 	@Async
 	@Transactional
 	public void PaySuccess(UserPayEvent userPayEvent){
 		SuccessParams successParams = userPayEvent.getSuccessParams();
+
+		System.out.println("用户支付成功的回调数据:"+successParams);
+		//用户支付成功的回调数据:SuccessParams(billId=1425261064655839233, platformId=1013202108110000002503142099, orderId=null, status=success, orderType=USER_PAY)
+		BillRecord billRecord = billRecordService.getById(successParams.getBillId());
+		if(billRecord ==null ){
+			bladeLogger.error("第三方支付返回的订单不存在",successParams.toString());
+		}else{
+
+			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());
+					shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice() != null ?
+						shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()) : billRecord.getRealPayAmount());
+					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()));
+					channelUserPointService.updateById(channelUserPoint);
+					Mall mall = mallService.getById(billRecord.getMallId());
+					shop.setTotalFunkPrice(shop.getTotalFunkPrice().add(mallPointDetail.getPointValue()));
+					shopService.updateById(shop);
+					mall.setTotalPointValue(mall.getTotalPointValue() != null?mall.getTotalPointValue().add(mallPointDetail.getPointValue()):mallPointDetail.getPointValue());
+					mallService.updateById(mall);
+				}
+
+				/**
+				 * 商场送积分的待确认记录
+				 */
+				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.setWithdrawTotalPrice(shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()));
+					shop.setSales(shop.getSales() != null?shop.getSales()+1:1);
+					shop.setTotalPointValue(shop.getTotalPointValue() != null ? shop.getTotalPointValue().add(shopPointDetail.getPointValue()):shopPointDetail.getPointValue());
+					shopService.updateById(shop);
+					shopPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+					pointDetailService.updateById(shopPointDetail);
+
+
+				}
+
+			}
+		}
 	}
 }