发放标识
This commit is contained in:
@@ -0,0 +1,113 @@
|
|||||||
|
package com.czg.market.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聊天消息表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-12-04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("chat_message")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ChatMessage implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息ID
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private BigInteger id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者ID
|
||||||
|
*/
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者ID(单聊=对方ID,群聊=群ID)
|
||||||
|
*/
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群ID
|
||||||
|
*/
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聊天类型:1=单聊,2=群聊
|
||||||
|
*/
|
||||||
|
private Integer chatType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型:1=文本/常用语/表情,2=图片,3=订单, 4 优惠券 5视频
|
||||||
|
*/
|
||||||
|
private Integer msgType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文本/表情代码/常用语ID(仅msg_type=1)
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片URL(仅msg_type=2)
|
||||||
|
*/
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单ID(仅msg_type=3)
|
||||||
|
*/
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券信息 (仅msg_type=4)
|
||||||
|
*/
|
||||||
|
private String coupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已读:0=未读,1=已读
|
||||||
|
*/
|
||||||
|
private Integer isRead;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime sendTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话ID:单聊=min(from,to)_max(from,to),群聊=group_群ID
|
||||||
|
*/
|
||||||
|
private String sessionId;
|
||||||
|
|
||||||
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* chat_coupon的 id
|
||||||
|
*/
|
||||||
|
private Long chatCouponId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 领取
|
||||||
|
*/
|
||||||
|
private Integer couponClaim;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -66,10 +66,13 @@ public interface MkShopCouponRecordService extends IService<MkShopCouponRecord>
|
|||||||
|
|
||||||
Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO, String source);
|
Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO, String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组装 群聊活动优惠券
|
||||||
|
*/
|
||||||
MkShopCouponRecord assembleRecord(Long chatCouponId, ShopCoupon coupon);
|
MkShopCouponRecord assembleRecord(Long chatCouponId, ShopCoupon coupon);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠券发放
|
* 群聊活动优惠券发放
|
||||||
*/
|
*/
|
||||||
void grantChatCoupon(MkShopCouponRecord record, Integer number);
|
void grantChatCoupon(MkShopCouponRecord record, Integer number);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,12 +19,14 @@ import com.czg.account.vo.CouponReceiveVo;
|
|||||||
import com.czg.account.vo.UserCouponVo;
|
import com.czg.account.vo.UserCouponVo;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.*;
|
import com.czg.market.dto.*;
|
||||||
|
import com.czg.market.entity.ChatMessage;
|
||||||
import com.czg.market.entity.MkShopCouponRecord;
|
import com.czg.market.entity.MkShopCouponRecord;
|
||||||
import com.czg.market.entity.ShopCoupon;
|
import com.czg.market.entity.ShopCoupon;
|
||||||
import com.czg.market.entity.SmsPushEventUser;
|
import com.czg.market.entity.SmsPushEventUser;
|
||||||
import com.czg.market.service.MkShopCouponRecordService;
|
import com.czg.market.service.MkShopCouponRecordService;
|
||||||
import com.czg.market.vo.CouponRecordCountVO;
|
import com.czg.market.vo.CouponRecordCountVO;
|
||||||
import com.czg.market.vo.UserCouponVO;
|
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.MkShopCouponRecordMapper;
|
||||||
import com.czg.service.market.mapper.ShopCouponMapper;
|
import com.czg.service.market.mapper.ShopCouponMapper;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
@@ -37,6 +39,7 @@ import jakarta.annotation.Resource;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@@ -66,6 +69,8 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
private AShopUserService aShopUserService;
|
private AShopUserService aShopUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private ShopCouponMapper couponService;
|
private ShopCouponMapper couponService;
|
||||||
|
@Resource
|
||||||
|
private ChatMessageMapper chatMessageMapper;
|
||||||
|
|
||||||
private static final List<String> TARGET_KEY = Arrays.asList("消费赠券", "充值赠券", "管理员赠送", "兑换码兑换", "群聊发放", "生日赠券", "购买会员赠券", "短信发放", "公众号发放", "用户弹窗领取");
|
private static final List<String> TARGET_KEY = Arrays.asList("消费赠券", "充值赠券", "管理员赠送", "兑换码兑换", "群聊发放", "生日赠券", "购买会员赠券", "短信发放", "公众号发放", "用户弹窗领取");
|
||||||
|
|
||||||
@@ -544,6 +549,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void grantChatCoupon(MkShopCouponRecord record, Integer number) {
|
public void grantChatCoupon(MkShopCouponRecord record, Integer number) {
|
||||||
ShopCoupon coupon = couponService.selectOneById(record.getCouponId());
|
ShopCoupon coupon = couponService.selectOneById(record.getCouponId());
|
||||||
AssertUtil.isNull(coupon, "优惠券不存在");
|
AssertUtil.isNull(coupon, "优惠券不存在");
|
||||||
@@ -557,7 +563,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
if (coupon.getStatus() != 1) {
|
if (coupon.getStatus() != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coupon.setGiftNum(coupon.getGiftNum() + number);
|
//组装 发放优惠券
|
||||||
if ("fixed".equals(record.getValidType())) {
|
if ("fixed".equals(record.getValidType())) {
|
||||||
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
||||||
//固定时间
|
//固定时间
|
||||||
@@ -573,9 +579,20 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
}
|
}
|
||||||
mapper.insertBatchSelective(recordList, 10);
|
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();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
ShopCoupon newCoupon = new ShopCoupon();
|
ShopCoupon newCoupon = new ShopCoupon();
|
||||||
newCoupon.setGiftNum(coupon.getGiftNum());
|
newCoupon.setGiftNum(coupon.getGiftNum() + number);
|
||||||
if (coupon.getSyncId() != null) {
|
if (coupon.getSyncId() != null) {
|
||||||
queryWrapper.and(q -> {
|
queryWrapper.and(q -> {
|
||||||
q.eq(ShopCoupon::getId, coupon.getSyncId()).or(q1 -> {
|
q.eq(ShopCoupon::getId, coupon.getSyncId()).or(q1 -> {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?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>
|
||||||
Reference in New Issue
Block a user