发放问题 领取记录回填

This commit is contained in:
2025-12-04 17:28:32 +08:00
parent 0501fc24e8
commit 0b05b9a67b
4 changed files with 14 additions and 38 deletions

View File

@@ -1,14 +0,0 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.ChatMessage;
/**
* 聊天消息表 映射层。
*
* @author ww
* @since 2025-12-04
*/
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
}

View File

@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.czg.exception.CzgException;
import com.czg.market.dto.ChatCouponDTO;
import com.czg.market.dto.MkShopCouponGiftDTO;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.service.MkShopCouponRecordService;
@@ -128,7 +129,14 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
MkShopCouponRecord record = JSONObject.parseObject(coupon.getCouponJson(), MkShopCouponRecord.class);
record.setShopUserId(shopUserId);
record.setUserId(userId);
recordService.grantChatCoupon(record, coupon.getGetLimit());
// recordService.grantChatCoupon(record, coupon.getGetLimit());
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO()
.setCouponId(coupon.getCouponId())
.setShopId(coupon.getShopId())
.setSourceId(coupon.getId())
.setShopUserId(shopUserId)
.setSource("群聊发放");
recordService.receiveCoupon(giftDTO, coupon.getGetLimit(), false);
}
@Override

View File

@@ -19,14 +19,12 @@ import com.czg.account.vo.CouponReceiveVo;
import com.czg.account.vo.UserCouponVo;
import com.czg.exception.CzgException;
import com.czg.market.dto.*;
import com.czg.market.entity.ChatMessage;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.entity.SmsPushEventUser;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.vo.CouponRecordCountVO;
import com.czg.market.vo.UserCouponVO;
import com.czg.service.market.mapper.ChatMessageMapper;
import com.czg.service.market.mapper.MkShopCouponRecordMapper;
import com.czg.service.market.mapper.ShopCouponMapper;
import com.czg.utils.AssertUtil;
@@ -69,8 +67,6 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
private AShopUserService aShopUserService;
@Resource
private ShopCouponMapper couponService;
@Resource
private ChatMessageMapper chatMessageMapper;
private static final List<String> TARGET_KEY = Arrays.asList("消费赠券", "充值赠券", "管理员赠送", "兑换码兑换", "群聊发放", "生日赠券", "购买会员赠券", "短信发放", "公众号发放", "用户弹窗领取");
@@ -313,6 +309,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
}
@Override
@Transactional
public void receiveCoupon(MkShopCouponGiftDTO giftDTO, Integer number, boolean isLimit) {
if (number == null || number <= 0) {
throw new CzgException("发放数量不能小于0");
@@ -362,6 +359,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
start = coupon.getValidStartTime();
end = coupon.getValidEndTime();
}
List<MkShopCouponRecord> recordList = new ArrayList<>();
for (int i = 0; i < number; i++) {
MkShopCouponRecord record = new MkShopCouponRecord();
record.setShopId(giftDTO.getShopId());
@@ -385,8 +383,9 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
record.setUseStartTime(start);
record.setUseEndTime(end);
save(record);
// save(record);
}
mapper.insertBatchSelective(recordList, 10);
QueryWrapper queryWrapper = new QueryWrapper();
ShopCoupon newCoupon = new ShopCoupon();
newCoupon.setLeftNum(coupon.getLeftNum());
@@ -505,6 +504,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
}
@Override
@Transactional
public Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO, String source) {
Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainIdByShopId).eq(ShopUser::getUserId, rewardCouponDTO.getUserId()));
@@ -580,17 +580,6 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
}
mapper.insertBatchSelective(recordList, 10);
//聊天记录 领取标识
chatMessageMapper.updateByQuery(
new ChatMessage().setCouponClaim(1),
QueryWrapper.create()
.eq(ChatMessage::getShopId, coupon.getShopId())
.eq(ChatMessage::getChatCouponId, record.getSourceId())
.eq(ChatMessage::getMsgType, 4)
.eq(ChatMessage::getToId, record.getUserId())
);
QueryWrapper queryWrapper = new QueryWrapper();
ShopCoupon newCoupon = new ShopCoupon();
newCoupon.setGiftNum(coupon.getGiftNum() + number);

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.market.mapper.ChatMessageMapper">
</mapper>