Bladeren bron

扣积分

LIDEXI 4 jaren geleden
bovenliggende
commit
23fd4fdd6f
18 gewijzigde bestanden met toevoegingen van 403 en 98 verwijderingen
  1. 4 1
      src/main/java/org/springblade/common/enums/PayWay.java
  2. 1 1
      src/main/java/org/springblade/modules/ldt/activityjoinrecord/entity/ActivityJoinRecord.java
  3. 1 1
      src/main/java/org/springblade/modules/ldt/appaccount/controller/AppAccountController.java
  4. 11 0
      src/main/java/org/springblade/modules/ldt/billrecord/wrapper/BillRecordWrapper.java
  5. 6 0
      src/main/java/org/springblade/modules/ldt/channeluserpoint/entity/ChannelUserPoint.java
  6. 1 0
      src/main/java/org/springblade/modules/ldt/channeluserpoint/mapper/ChannelUserPointMapper.xml
  7. 157 20
      src/main/java/org/springblade/modules/ldt/loginuser/controller/LoginUserController.java
  8. 6 0
      src/main/java/org/springblade/modules/ldt/loginuser/entity/LoginUser.java
  9. 60 13
      src/main/java/org/springblade/modules/ldt/loginuser/service/impl/LoginUserServiceImpl.java
  10. 1 1
      src/main/java/org/springblade/modules/ldt/mall/controller/AppMallController.java
  11. 4 3
      src/main/java/org/springblade/modules/ldt/shop/controller/AppShopController.java
  12. 5 0
      src/main/java/org/springblade/modules/payment/entity/SuccessParams.java
  13. 108 51
      src/main/java/org/springblade/modules/payment/listener/UserPayListener.java
  14. 1 0
      src/main/java/org/springblade/modules/payment/plugin/YeePayPlugin.java
  15. 7 6
      src/main/java/org/springblade/wx/controller/WxAppController.java
  16. 15 0
      src/main/java/org/springblade/wx/dto/JumpWxa.java
  17. 14 0
      src/main/java/org/springblade/wx/dto/SchemeDto.java
  18. 1 1
      src/main/resources/application.yml

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

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

+ 1 - 1
src/main/java/org/springblade/modules/ldt/activityjoinrecord/entity/ActivityJoinRecord.java

@@ -85,7 +85,7 @@ public class ActivityJoinRecord extends BaseEntity {
 	private BigDecimal finalSupplyPrice;
 
 	/**
-	 * 国信活动服务费率
+	 * 国信活动服务费率(百分比)
 	 */
 	@ApiModelProperty(value = "国信活动服务费率")
 	private BigDecimal gxRewardSupply;

+ 1 - 1
src/main/java/org/springblade/modules/ldt/appaccount/controller/AppAccountController.java

@@ -240,7 +240,7 @@ public class AppAccountController extends BladeController {
 
 //	public static void main(String[] args) {
 //
-//		System.out.println((DigestUtil.hex("ac3c655d24a78327f1e6a53e25aa1e46")));;
+//		System.out.println((DigestUtil.hex("f810af89007929fe7642ca763a137586")));;
 //
 //	}
 

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

@@ -3,6 +3,7 @@ package org.springblade.modules.ldt.billrecord.wrapper;
 import com.alibaba.fastjson.support.geo.Point;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.springblade.common.constant.SystemConstant;
+import org.springblade.common.enums.PayWay;
 import org.springblade.core.mp.support.BaseEntityWrapper;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.modules.ldt.billrecord.entity.BillRecord;
@@ -36,6 +37,16 @@ public class BillRecordWrapper extends BaseEntityWrapper<BillRecord, BillRecordV
 	public BillRecordVO entityVO(BillRecord billRecord) {
 		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)){
+				billRecordVO.setPayWay(PayWay.ALIPAY.getName());
+				billRecordVO.setUserName("支付宝用户");
+			}else if(billRecord.getPayWay().equals(PayWay.WECHAT)){
+				billRecordVO.setPayWay(PayWay.WECHAT.getName());
+				billRecordVO.setUserName("微信用户");
+			}
+
+		}
 		if(loginUser != null){
 			billRecordVO.setUserAvator(loginUser.getAvatar());
 			billRecordVO.setUserName(loginUser.getNickName());

+ 6 - 0
src/main/java/org/springblade/modules/ldt/channeluserpoint/entity/ChannelUserPoint.java

@@ -69,6 +69,12 @@ public class ChannelUserPoint extends BaseEntity {
 	*/
 		@ApiModelProperty(value = "可用积分")
 		private BigDecimal usablePoint;
+
+	/**
+	 * 可用积分
+	 */
+	@ApiModelProperty(value = "可用积分价值")
+	private BigDecimal usablePointValue;
 	/**
 	* 已经核销的积分总数
 	*/

+ 1 - 0
src/main/java/org/springblade/modules/ldt/channeluserpoint/mapper/ChannelUserPointMapper.xml

@@ -18,6 +18,7 @@
         <result column="channel_name" property="channelName"/>
         <result column="total_point" property="totalPoint"/>
         <result column="usable_point" property="usablePoint"/>
+        <result column="usable_point_value" property="usablePointValue"/>
         <result column="used_point" property="usedPoint"/>
     </resultMap>
 

+ 157 - 20
src/main/java/org/springblade/modules/ldt/loginuser/controller/LoginUserController.java

@@ -18,6 +18,7 @@ package org.springblade.modules.ldt.loginuser.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Assert;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -42,11 +43,22 @@ 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.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.dto.LoginUserDTO;
 import org.springblade.modules.ldt.loginuser.dto.PayDto;
+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;
+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.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -57,11 +69,12 @@ import org.springblade.modules.ldt.loginuser.service.ILoginUserService;
 import org.springblade.core.boot.ctrl.BladeController;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 /**
- *  控制器
+ * 控制器
  *
  * @author BladeX
  * @since 2021-07-28
@@ -78,7 +91,7 @@ public class LoginUserController extends BladeController {
 	private final IBillRecordService billRecordService;
 
 	private final static String USER_INFO = "userId:";
-	private final RedisTemplate<String,String> redisTemplate;
+	private final RedisTemplate<String, String> redisTemplate;
 
 
 	/**
@@ -98,8 +111,8 @@ public class LoginUserController extends BladeController {
 	@GetMapping("/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入loginUser")
-	public R<IPage<LoginUser>> list(@RequestParam Map<String,Object> loginUser, Query query) {
-		IPage<LoginUser> pages = loginUserService.page(Condition.getPage(query), Condition.getQueryWrapper(loginUser,LoginUser.class));
+	public R<IPage<LoginUser>> list(@RequestParam Map<String, Object> loginUser, Query query) {
+		IPage<LoginUser> pages = loginUserService.page(Condition.getPage(query), Condition.getQueryWrapper(loginUser, LoginUser.class));
 		return R.data(pages);
 	}
 
@@ -154,6 +167,7 @@ public class LoginUserController extends BladeController {
 	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
 		return R.status(loginUserService.deleteLogic(Func.toLongList(ids)));
 	}
+
 	/**
 	 * 登录
 	 */
@@ -171,27 +185,27 @@ public class LoginUserController extends BladeController {
 	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "用户扫码支付", notes = "传入loginUser")
 	public R<BillRecord> payBefore(@RequestBody PayDto payDto) {
-		if(payDto.getSecret() != null){
+		if (payDto.getSecret() != null) {
 			String id = OtpUtils.getIdFormCode(payDto.getSecret());
 			boolean validate = OtpUtils.validate(id, payDto.getSecret());
-			if(validate){
+			if (validate) {
 
-			}else {
+			} else {
 //				Assert.isTrue(false,"用户授权无效");
 			}
 			payDto.setLoginUserId(Long.valueOf(id));
 
 		}
-		Assert.notNull(payDto.getLoginUserId(),"用户信息不能为空");
-		Assert.notNull(payDto.getMoney(),"商品价格不能为空");
-		Assert.notNull(payDto.getShopId(),"商店信息不能为空");
+		Assert.notNull(payDto.getLoginUserId(), "用户信息不能为空");
+		Assert.notNull(payDto.getMoney(), "商品价格不能为空");
+		Assert.notNull(payDto.getShopId(), "商店信息不能为空");
 		Shop shop = shopService.getById(payDto.getShopId());
-		Assert.notNull(shop,"商店信息不存在");
+		Assert.notNull(shop, "商店信息不存在");
 		LoginUser loginUser = loginUserService.getById(payDto.getLoginUserId());
-		Assert.notNull(loginUser,"用户信息不存在");
+		Assert.notNull(loginUser, "用户信息不存在");
 		BillRecord billRecord = this.loginUserService.payBefore(loginUser, shop, payDto);
-		if(payDto.getType() == 2) {//商户扫用户付款码需要存缓存
-			redisTemplate.opsForValue().set(CacheNames.SHOPSCANUSER+"::"+USER_INFO+payDto.getLoginUserId(), JSON.toJSONString(billRecord),5, TimeUnit.MINUTES);
+		if (payDto.getType() != null && 2 == payDto.getType()) {//商户扫用户付款码需要存缓存
+			redisTemplate.opsForValue().set(CacheNames.SHOPSCANUSER + "::" + USER_INFO + payDto.getLoginUserId(), JSON.toJSONString(billRecord), 5, TimeUnit.MINUTES);
 		}
 		return R.data(billRecord);
 	}
@@ -204,10 +218,10 @@ public class LoginUserController extends BladeController {
 	@ApiOperation(value = "非平台用户扫码支付生成预订单", notes = "传入loginUser")
 	public R<BillRecord> payBeforeForNormal(@RequestBody PayDto payDto) {
 
-		Assert.notNull(payDto.getMoney(),"商品价格不能为空");
-		Assert.notNull(payDto.getShopId(),"商店信息不能为空");
+		Assert.notNull(payDto.getMoney(), "商品价格不能为空");
+		Assert.notNull(payDto.getShopId(), "商店信息不能为空");
 		Shop shop = shopService.getById(payDto.getShopId());
-		Assert.notNull(shop,"商店信息不存在");
+		Assert.notNull(shop, "商店信息不存在");
 
 		//该记录没有用户信息
 		BillRecord billRecord = new BillRecord();
@@ -222,7 +236,7 @@ public class LoginUserController extends BladeController {
 		billRecord.setType(OrderType.USER_PAY.getName());
 		billRecord.setMallId(shop.getMallId());
 		billRecord.setBillsDesc(payDto.getBillsTitle());
-		billRecordService.updateById(billRecord);
+		billRecordService.save(billRecord);
 		return R.data(billRecord);
 	}
 
@@ -234,7 +248,7 @@ public class LoginUserController extends BladeController {
 	@ApiOperation(value = "用户扫码支付", notes = "传入loginUser")
 	public R<BillRecord> payBefore(BillRecord billRecord) {
 		String s = redisTemplate.opsForValue().get(CacheNames.SHOPSCANUSER + "::" + USER_INFO + billRecord.getUserId());
-		if(s != null){
+		if (s != null) {
 			JSONObject billRecord1 = JSON.parseObject(s);
 			return R.data(billRecord1.toJavaObject(BillRecord.class));
 		}
@@ -250,7 +264,130 @@ public class LoginUserController extends BladeController {
 	@ApiOperation(value = "清除缓存", notes = "传入loginUser")
 	public R clearBillRecordCache(BillRecord billRecord) {
 
-		return R.data(redisTemplate.delete(CacheNames.SHOPSCANUSER+"::"+USER_INFO+billRecord.getUserId()));
+		return R.data(redisTemplate.delete(CacheNames.SHOPSCANUSER + "::" + USER_INFO + billRecord.getUserId()));
+	}
+
+	private final IPointDetailService pointDetailService;
+	private final IPointChannelService pointChannelService;
+	private final IChannelUserPointService channelUserPointService;
+	private final IMallService mallService;
+	private final IMemberService memberService;
+	private final IShopYingshouService shopYingshouService;
+	/**
+	 * /**
+	 * * 清除缓存
+	 */
+	@PostMapping("/moniCallBack")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "模拟回调", notes = "传入loginUser")
+	public R moniCallBack(@RequestBody BillRecord params) {
+		BillRecord billRecord = billRecordService.getById(params.getId());
+		if(billRecord ==null ){
+//			bladeLogger.error("第三方支付返回的订单不存在",successParams.toString());
+		}else{
+
+			Shop shop = shopService.getById(billRecord.getShopId());
+
+			if(SystemConstant.BillRecordPayStatus.PAYING.getValue() == billRecord.getPayStatus()){//只处理待支付订单变成已支付成功的情况
+
+				if(billRecord.getUserId() == null){//非平台用户支付直接增加用户可提现余额,无需赠送积分
+					billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
+					billRecordService.updateById(billRecord);
+					shop.setWithdrawTotalPrice(shop.getWithdrawTotalPrice() != null ?
+						shop.getWithdrawTotalPrice().add(billRecord.getRealPayAmount()) : billRecord.getRealPayAmount());
+					shopService.updateById(shop);
+					return R.data(true);
+				}
+
+				/**                  平台用户支付回调                 **/
+				//增加商户的可提现余额
+				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()
+						.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);
+				}
+
+				/**
+				 * 商场送积分的待确认记录
+				 */
+				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);
+
+				}
+
+				/**   判断是否有商家待应收记录   **/
+				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);
+
+			}
+		}
+		return R.data(true);
 	}
 
 

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

@@ -98,5 +98,11 @@ public class LoginUser extends BaseEntity {
 	@ApiModelProperty(value = "余额")
 	private BigDecimal pointValue;
 
+	/**
+	 * 积分渠道的总价值
+	 */
+	@ApiModelProperty(value = "积分渠道的总价值")
+	private BigDecimal channelUserPoint;
+
 
 }

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

@@ -63,7 +63,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.net.ssl.SNIHostName;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.SQLOutput;
+import java.text.DecimalFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.HashMap;
@@ -123,7 +125,8 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 	@Override
 	@Transactional
 	public BillRecord payBefore(LoginUser loginUser,Shop shop, PayDto payDto) {
-
+		DecimalFormat decimalFormat = new DecimalFormat("0.00");
+		decimalFormat.setRoundingMode(RoundingMode.CEILING);
 		BillRecord billRecord = new BillRecord();
 		billRecord.setShopId(payDto.getShopId());
 		billRecord.setMallId(shop.getMallId());
@@ -132,15 +135,15 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		billRecord.setAppId(payDto.getAppId());
 		billRecord.setOpenId(loginUser.getOpenid());
 		billRecord.setExpireTime(payDto.getExpireTime());
-		billRecord.setPayAmount(payDto.getMoney().toString());
+		billRecord.setPayAmount(decimalFormat.format(payDto.getMoney()));
 		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(Double.valueOf(paramService.getValue(CommonConstant.ACTIVITY_SERVICE_RATE))); //国信活动服务费,默认10%;
-		BigDecimal activityServerRate = BigDecimal.valueOf(Double.valueOf(paramService.getValue(CommonConstant.SCORE_SERVIVE_RATE)));//积分服务费
+		BigDecimal gxServerRate =BigDecimal.valueOf(0); //国信活动服务费
+		BigDecimal scoreServerRate = 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");//商场会员
@@ -150,11 +153,11 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		//先查询该小B的活动折扣
 		List<ActivityJoinRecord> activityJoinRecords = activityJoinRecordService.getBaseMapper().selectList(new QueryWrapper<>(new ActivityJoinRecord()).lambda()
 			.eq(ActivityJoinRecord::getJoinType, SystemConstant.MALLORSHOP.SHOP.getValue())
-			.eq(ActivityJoinRecord::getJoinId, payDto.getShopId()).eq(ActivityJoinRecord::getAuditStatus,SystemConstant.AuditStatus.PASS.getValue()));
+			.eq(ActivityJoinRecord::getJoinId, payDto.getShopId()));
 		if(activityJoinRecords.size()>0){//小B参与了大B的活动
 			//联营折扣
 			billRecord.setSubsidy(activityJoinRecords.get(0).getFinalSupplyPrice().divide(BigDecimal.valueOf(100)));
-			gxServerRate = activityJoinRecords.get(0).getGxRewardSupply();
+			gxServerRate = activityJoinRecords.get(0).getGxRewardSupply().divide(BigDecimal.valueOf(100));
 		}else{//小B没有参加大B的活动,查看小B是否自己有创建活动
 
 		}
@@ -162,7 +165,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 
 
 		//用户应付金额 = 商品价格* 小B折扣*大B折扣+国信活动服务费
-		BigDecimal yingfu = payDto.getMoney().multiply(billRecord.getSubsidy()).add(payDto.getMoney().multiply(activityServerRate));
+		BigDecimal yingfu = payDto.getMoney().multiply(billRecord.getSubsidy().add(gxServerRate));
 		billRecord.setYingfuAmount(yingfu);
 
 
@@ -182,11 +185,12 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 				if(mall.getIsOpenMember() != 1){
 					Assert.isTrue(false,"商场未开启会员中心");
 				}
-				pointChannel.setPointValue(mall.getPoint().multiply(BigDecimal.valueOf(100)).divide(mall.getPointValue()));//100积分等于多少积分价值
+				pointChannel.setPointValue(mall.getPointValue().multiply(BigDecimal.valueOf(100)).divide(mall.getPoint()));//100积分等于多少积分价值
 				pointChannel.setDiscount(BigDecimal.valueOf(100));
 				pointChannel.setName(mall.getName());
 				pointChannel.setLogo(mall.getPic());
 				pointChannel.setPaymentDays(mall.getPaymentDays()!= null? mall.getPaymentDays():0);
+				pointChannelService.save(pointChannel);
 			}
 			//获取该用户在该商场的可用积分
 			if(pointChannel != null){
@@ -207,10 +211,11 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 
 				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;
+				boolean channelScoreEnough = yingfu.subtract(channelPointValue.multiply(BigDecimal.ONE.add(scoreServerRate))).compareTo(BigDecimal.ZERO) > 0 ? false : true;
 
 				if(channelScoreEnough){//大B渠道的积分足够支付
 					billRecord.setRealPayAmount(BigDecimal.ZERO);
+					billRecord.setPayAmount(BigDecimal.ZERO.toString());
 					billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
 					billRecord.setPayWay(PayWay.POINT.getName());//全部由积分支付
 
@@ -253,10 +258,45 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 					if(channelPointValue.compareTo(BigDecimal.ZERO) == 0){//大B渠道积分价值为零,扣用户余额
 						if(loginUser.getPointValue().compareTo(BigDecimal.ZERO) == 0){//用户余额为0
 							billRecord.setRealPayAmount(yingfu);
+							billRecord.setPayAmount(decimalFormat.format(yingfu));
 							billRecord.setPayWay(PayWay.CASH.getName());//现金支付
 							billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 							billRecordService.updateById(billRecord);
 
+							//商场带确认赠送积分
+							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.getPointValue()).divide(mall.getPoint()));
+							mallSendPoint.setBillRecordId(billRecord.getId());
+							mallSendPoint.setBillRecordStatus(billRecord.getPayStatus());
+							pointDetailService.save(mallSendPoint);
+
+							//商户赠送积分待确认
+							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.getPointValue()).divide(shop.getPoint()));
+							shopPointDetail.setBillRecordStatus(billRecord.getPayStatus());
+							shopPointDetail.setBillRecordId(billRecord.getId());
+							pointDetailService.save(shopPointDetail);
+
+
 							//用户余额为0时用户需要全额支付,待支付回调成功后才会发放积分
 							return billRecord;
 						}else{//余额不为0
@@ -264,6 +304,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 							if(userAccoutEnough){//余额够扣
 								//直接扣余额
 								billRecord.setRealPayAmount(BigDecimal.ZERO);
+								billRecord.setPayAmount(BigDecimal.ZERO.toString());
 								billRecord.setPayWay(PayWay.POINT.getName());
 								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
 
@@ -305,6 +346,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 
 								//用户实际付款 = 应付 - 可用余额
 								billRecord.setRealPayAmount(yingfu.subtract(userEnablePointValue));
+								billRecord.setPayAmount(decimalFormat.format(billRecord.getRealPayAmount()));
 								billRecord.setPayWay(PayWay.MIX.getName());
 								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 
@@ -368,6 +410,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
 								billRecord.setPayWay(PayWay.POINT.getName());
 								billRecord.setRealPayAmount(BigDecimal.ZERO);
+								billRecord.setPayAmount(BigDecimal.ZERO.toString());
 								//扣除的国信积分服务费
 								BigDecimal gxRewardPointValue  = yingfu.multiply(gxServerRate);
 
@@ -412,6 +455,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 
 								//用户实际付款 = 应付 - 可用余额
 								billRecord.setRealPayAmount(yingfu.subtract(userEnablePointValue));
+								billRecord.setPayAmount(decimalFormat.format(billRecord.getRealPayAmount()));
 								billRecord.setPayWay(PayWay.MIX.getName());
 								billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 
@@ -439,6 +483,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 							}
 						}else{//用户无余额可扣
 							billRecord.setRealPayAmount(yingfu);
+							billRecord.setPayAmount(decimalFormat.format(yingfu));
 							billRecord.setPayWay(PayWay.MIX.getName());
 							billRecord.setPayStatus(SystemConstant.BillRecordPayStatus.PAYING.getValue());
 							billRecordService.updateById(billRecord);
@@ -527,6 +572,7 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 					memberService.save(mallMember);
 					Mall mall = mallService.getById(shop.getMallId());
 					mall.setMemberCount(mall.getMemberCount()+1);
+					mallService.updateById(mall);
 					memberMap.put("mallMember",mallMember);
 				}
 			}
@@ -554,8 +600,8 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		mallSendPoint.setPrice(billRecord.getPrice());//总价
 		//商场送的积分数 = 总价*商场会员中心每消费一元赠送的积分数
 		mallSendPoint.setPoint(billRecord.getPrice().multiply(mall.getConsumeOnePoint()));
-		//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分数/商场会员中心的积分价值
-		mallSendPoint.setPointValue(mallSendPoint.getPoint().multiply(mall.getPoint()).divide(mall.getPointValue()));
+		//商场赠送的积分价值 = 商场送的积分数*商场会员中心的积分价值/商场会员中心的积分数
+		mallSendPoint.setPointValue(mallSendPoint.getPoint().multiply(mall.getPointValue()).divide(mall.getPoint()));
 		mallSendPoint.setBillRecordId(billRecord.getId());
 		mallSendPoint.setBillRecordStatus(billRecord.getPayStatus());
 		pointDetailService.save(mallSendPoint);
@@ -583,8 +629,8 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 		shopPointDetail.setPrice(billRecord.getPrice());
 		//商家送的积分 = 总价*商家的会议中心每消费一元赠送的积分数
 		shopPointDetail.setPoint(billRecord.getPrice().multiply(shop.getConsumeOnePoint()));
-		//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分数/商家会员中心的积分价值
-		shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPoint()).divide(shop.getPointValue()));
+		//商家赠送的积分价值 = 商家送的积分数*商家会员中心的积分价值/商家会员中心的积分数
+		shopPointDetail.setPointValue(shopPointDetail.getPoint().multiply(shop.getPointValue()).divide(shop.getPoint()));
 		shopPointDetail.setBillRecordStatus(billRecord.getPayStatus());
 		shopPointDetail.setBillRecordId(billRecord.getId());
 		pointDetailService.save(shopPointDetail);
@@ -618,4 +664,5 @@ public class LoginUserServiceImpl extends BaseServiceImpl<LoginUserMapper, Login
 	}
 
 
+
 }

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

@@ -175,7 +175,7 @@ public class AppMallController {
 
 			//今日营收
 			List<BillRecord> billRecords = billRecordService.getBaseMapper().selectList(new QueryWrapper<>(new BillRecord()).lambda()
-				.eq(BillRecord::getMallId, mallId).eq(BillRecord::getPayStatus, SystemConstant.BillRecordPayStatus.PAYED)
+				.eq(BillRecord::getMallId, mallId).eq(BillRecord::getPayStatus, SystemConstant.BillRecordPayStatus.PAYED.getValue())
 				.gt(BillRecord::getCreateTime, todayDate));
 
 			todayIncome = billRecords.stream().map(BillRecord::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);

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

@@ -149,7 +149,8 @@ public class AppShopController {
 			.eq(ShopYingshou::getShopId,shopYingshou.getShopId())
 			.eq(ShopYingshou::getBillRecordStatus,SystemConstant.BillRecordPayStatus.PAYED.getValue())
 			.eq(ShopYingshou::getJsStatus,SystemConstant.JieSuanStatus.jsing.getValue())
-			.like(ShopYingshou::getUpdateTime,selectMonth));
+			.like(ShopYingshou::getUpdateTime,selectMonth)
+			.orderByDesc(ShopYingshou::getUpdateTime));
 		return R.data(pages);
 	}
 
@@ -171,7 +172,7 @@ public class AppShopController {
 		}
 		IPage<BillRecord> pages = billRecordService.page(Condition.getPage(query),new QueryWrapper<>(new BillRecord()).lambda()
 				.eq(BillRecord::getShopId,billRecord.getShopId()).eq(BillRecord::getPayStatus,1)
-				.like(BillRecord::getUpdateTime,selectMonth));
+				.like(BillRecord::getUpdateTime,selectMonth).orderByDesc(BillRecord::getUpdateTime));
 
 		return R.data(BillRecordWrapper.build(loginUserService,pointDetailService).pageVO(pages));
 
@@ -214,7 +215,7 @@ public class AppShopController {
 
 			//今日营收
 			List<BillRecord> billRecords = billRecordService.getBaseMapper().selectList(new QueryWrapper<>(new BillRecord()).lambda()
-				.eq(BillRecord::getShopId, shopId).eq(BillRecord::getPayStatus, SystemConstant.BillRecordPayStatus.PAYED)
+				.eq(BillRecord::getShopId, shopId).eq(BillRecord::getPayStatus, SystemConstant.BillRecordPayStatus.PAYED.getValue())
 				.gt(BillRecord::getCreateTime, todayDate));
 
 			todayIncome = billRecords.stream().map(BillRecord::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);

+ 5 - 0
src/main/java/org/springblade/modules/payment/entity/SuccessParams.java

@@ -39,4 +39,9 @@ public class SuccessParams {
 	 * 订单类型
 	 */
 	private String orderType;
+
+	/**
+	 * payChannel支付渠道
+	 */
+	private String payChannel;
 }

+ 108 - 51
src/main/java/org/springblade/modules/payment/listener/UserPayListener.java

@@ -10,12 +10,17 @@ 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.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;
 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.payment.entity.SuccessParams;
 import org.springblade.modules.payment.event.UserPayEvent;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,10 +54,16 @@ public class UserPayListener {
 	private IMallService mallService;
 	@Autowired
 	private IShopService shopService;
+	@Autowired
+	private IMemberService memberService;
+	@Autowired
+	private IShopYingshouService shopYingshouService;
+	@Autowired
+	private ILoginUserService loginUserService;
 
 	@EventListener
 	@Async
-	@Transactional
+//	@Transactional
 	public void PaySuccess(UserPayEvent userPayEvent){
 		SuccessParams successParams = userPayEvent.getSuccessParams();
 
@@ -62,67 +73,113 @@ public class UserPayListener {
 		if(billRecord ==null ){
 			bladeLogger.error("第三方支付返回的订单不存在",successParams.toString());
 		}else{
+			String shopId = billRecord.getShopId().toString();
+			synchronized (shopId.intern()){//对商户加锁
+				Shop shop = shopService.getById(billRecord.getShopId());
 
-			Shop shop = shopService.getById(billRecord.getShopId());
+				if(SystemConstant.BillRecordPayStatus.PAYING.getValue() == billRecord.getPayStatus() && "success".equals(successParams.getStatus())){//只处理待支付订单变成已支付成功的情况
 
-			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);
-				}
+					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());
+						shopService.updateById(shop);
+						return;
+					}
 
-				/**
-				 * 商场送积分的待确认记录
-				 */
-				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());
+					shop.setTradeTimes(shop.getTradeTimes() != null ? shop.getTradeTimes() +1 : 1);
 					shopService.updateById(shop);
-					shopPointDetail.setBillRecordStatus(SystemConstant.BillRecordPayStatus.PAYED.getValue());
-					pointDetailService.updateById(shopPointDetail);
+					//支付成功增加商场和商家的积分成本,增加用户的可用积分余额
 
+					//查询是否有商场送积分的待确认记录
+					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()
+							.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);
+						//增加会员
+					}
+
+					/**
+					 * 商场送积分的待确认记录
+					 */
+					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);
 
+					}
+
+					/**   判断是否有商家待应收记录   **/
+					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);
+
+				}
 			}
+
 		}
 	}
 }

+ 1 - 0
src/main/java/org/springblade/modules/payment/plugin/YeePayPlugin.java

@@ -115,6 +115,7 @@ public class YeePayPlugin implements Payment {
 		Assert.notNull(successParams,"订单回调参数数据获取失败!");
 
 		successParams.setPlatformId(jsonObject.getString("uniqueOrderNo"));
+		successParams.setPayChannel(jsonObject.getString("channel"));
 		successParams.setStatus(
 			"SUCCESS".equals(jsonObject.getString("status")) ?
 			SuccessParams.PAY_STATUS_SUCCESS:

+ 7 - 6
src/main/java/org/springblade/wx/controller/WxAppController.java

@@ -9,6 +9,7 @@ import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -17,6 +18,8 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.wx.config.WXConfiger;
 import org.springblade.wx.dto.DataDto;
+import org.springblade.wx.dto.JumpWxa;
+import org.springblade.wx.dto.SchemeDto;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
@@ -77,16 +80,14 @@ public class WxAppController {
 	@ApiOperation("获取GenerateScheme")
 	@GetMapping("/getGenerateScheme")
 	public R getGenerateScheme() {
+		SchemeDto schemeDto = new SchemeDto();
+		schemeDto.setJump_wxa(new JumpWxa("/pages/checkstand/index",""));
 		String accessToken = (String)this.getAccessTokenOfClient().getData();
 		String url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=" + accessToken;
-		HashMap<String, Object> jumpWxa = new HashMap(2);
-		jumpWxa.put("path", "/pages/checkstand/index");
-		jumpWxa.put("query", "");
-		HashMap<String, Object> paramMap = new HashMap(1);
-		paramMap.put("jump_wxa", jumpWxa);
+
 		String s = HttpRequest.post(url)
 			.header(Header.CONTENT_TYPE, "application/json")
-			.body(JSON.toJSONString(jumpWxa))
+			.body(JSONObject.toJSON(schemeDto).toString())
 			.execute().body();
 		JSONObject jsonObject = JSON.parseObject(s);
 		return R.data(jsonObject);

+ 15 - 0
src/main/java/org/springblade/wx/dto/JumpWxa.java

@@ -0,0 +1,15 @@
+package org.springblade.wx.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * Created By lidexi in 2021/8/13
+ **/
+@Data
+@AllArgsConstructor
+public class JumpWxa {
+
+	private String path;
+	private String query;
+}

+ 14 - 0
src/main/java/org/springblade/wx/dto/SchemeDto.java

@@ -0,0 +1,14 @@
+package org.springblade.wx.dto;
+
+import lombok.Data;
+
+/**
+ * Created By lidexi in 2021/8/13
+ **/
+@Data
+public class SchemeDto {
+
+	private JumpWxa jump_wxa;
+}
+
+

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

@@ -177,7 +177,7 @@ blade:
   #jackson配置
   jackson:
     #null自动转空值
-    null-to-empty: true
+    null-to-empty: false
     #大数字自动转字符串
     big-num-to-string: true
     #支持text文本请求,与报文加密同时开启