diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java index bd125a3..00b9188 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java @@ -36,6 +36,8 @@ public interface TbActivateMapper { TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount); + TbActivate selectByAmountScope(@Param("shopId") String shopId,@Param("amount") BigDecimal amount); + /** * 新增数据 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java index 35d9c79..c542824 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java @@ -1,7 +1,7 @@ package com.chaozhanggui.system.cashierservice.entity; -import java.util.Date; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -24,6 +24,10 @@ public class TbActivate implements Serializable { * 赠送金额 */ private Integer giftAmount; + /** + * 赠送积分 + */ + private Integer giftPoints; /** * 是否使用优惠卷 0否 1是 */ @@ -132,5 +136,13 @@ public class TbActivate implements Serializable { public void setGives(List gives) { this.gives = gives; } + + public Integer getGiftPoints() { + return giftPoints; + } + + public void setGiftPoints(Integer giftPoints) { + this.giftPoints = giftPoints; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index e2fb9d8..77d3ed2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -16,10 +16,12 @@ import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.*; -import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; -import com.chaozhanggui.system.cashierservice.mapper.*; +import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper; +import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper; +import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper; +import com.chaozhanggui.system.cashierservice.mapper.MpShopUserMapper; import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter; import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer; import com.chaozhanggui.system.cashierservice.redis.RedisCst; @@ -918,7 +920,7 @@ public class CartService { Long memberId = Long.valueOf(orderInfo.getMemberId()); if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() != 0) { - memberPointsService.addPoints(memberId, orderInfo.getPointsNum(), "用户未支付订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + memberPointsService.addPoints(memberId, orderInfo.getPointsNum(), "用户未支付订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()), orderInfo.getOrderNo()); } OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(memberId, orderInfo.getOrderAmount()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 3bcf84b..b999481 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1,10 +1,10 @@ package com.chaozhanggui.system.cashierservice.service; +import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -13,7 +13,6 @@ import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.*; -import com.chaozhanggui.system.cashierservice.entity.vo.ActivateInInfoVO; import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; @@ -56,7 +55,6 @@ import java.math.RoundingMode; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Collectors; @Service @Slf4j @@ -97,6 +95,9 @@ public class PayService { @Autowired private TbShopSongOrderMapper tbShopSongOrderMapper; + @Autowired + private TbMemberPointsService tbMemberPointsService; + @Value("${ysk.url}") private String url; @@ -471,7 +472,7 @@ public class PayService { // 设置优惠券信息 OrderCouponInfoDTO couponInfoDTO = new OrderCouponInfoDTO(); - couponInfoDTO.setFullReductionCouponMap(new HashMap(){{ + couponInfoDTO.setFullReductionCouponMap(new HashMap() {{ put(userCouponVo.getId(), userCouponVo); }}); orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); @@ -1491,6 +1492,12 @@ public class PayService { //会员活动 giveActivate(tbShopUser, memberIn.getAmount(), flow.getId()); + //充值送积分 + TbActivate activate = tbActivateMapper.selectByAmountScope(tbShopUser.getShopId(), memberIn.getAmount()); + if (ObjectUtil.isNotNull(activate)) { + tbMemberPointsService.addPoints(Convert.toLong(tbShopUser.getId()), activate.getGiftAmount(), StrUtil.format("充值¥{}送{}积分", memberIn.getAmount(), activate.getGiftAmount()), null, memberIn.getOrderNo()); + } + JSONObject jsonObject = new JSONObject(); jsonObject.put("shopId", memberIn.getShopId()); jsonObject.put("type", "wxMemberIn"); @@ -1684,6 +1691,12 @@ public class PayService { //会员活动 BigDecimal awardAmount = giveActivate(tbShopUser, memberIn.getAmount(), flow.getId()); + + //充值送积分 + TbActivate activate = tbActivateMapper.selectByAmountScope(tbShopUser.getShopId(), memberIn.getAmount()); + if (ObjectUtil.isNotNull(activate)) { + tbMemberPointsService.addPoints(Convert.toLong(tbShopUser.getId()), activate.getGiftAmount(), StrUtil.format("充值¥{}送{}积分", memberIn.getAmount(), activate.getGiftAmount()), null, memberIn.getOrderNo()); + } JSONObject jsonObject = new JSONObject(); jsonObject.put("shopId", memberIn.getShopId()); jsonObject.put("type", "wxMemberIn"); @@ -1700,6 +1713,7 @@ public class PayService { baObj.put("time", flow.getCreateTime()); producer.balance(baObj.toString()); + return "SUCCESS"; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java index 63d1cc5..7fbdf4a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java @@ -93,9 +93,10 @@ public interface TbMemberPointsService extends IService { * @param points 积分 * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分) * @param orderId 订单id,可以为空 + * @param orderNo 订单No,可以为空 * @throws Exception */ - boolean addPoints(Long memberId, int points, String content, Long orderId); + boolean addPoints(Long memberId, int points, String content, Long orderId, String orderNo); /** * 消费赠送积分 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java index 977d305..67ace12 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java @@ -239,7 +239,7 @@ public class TbMemberPointsServiceImpl extends ServiceImpl + @@ -16,7 +17,7 @@ id - , shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time + , shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time + +