Merge remote-tracking branch 'origin/test' into test
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);
|
||||
|
||||
/**
|
||||
* 组装 群聊活动优惠券
|
||||
*/
|
||||
MkShopCouponRecord assembleRecord(Long chatCouponId, ShopCoupon coupon);
|
||||
|
||||
/**
|
||||
* 优惠券发放
|
||||
* 群聊活动优惠券发放
|
||||
*/
|
||||
void grantChatCoupon(MkShopCouponRecord record, Integer number);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,6 +37,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
@@ -308,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");
|
||||
@@ -357,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());
|
||||
@@ -380,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());
|
||||
@@ -500,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()));
|
||||
@@ -520,6 +525,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
MkShopCouponRecord record = new MkShopCouponRecord();
|
||||
record.setShopId(coupon.getShopId());
|
||||
record.setCouponName(coupon.getTitle());
|
||||
record.setName(coupon.getTitle());
|
||||
record.setCouponId(coupon.getId());
|
||||
record.setCouponSyncId(coupon.getSyncId());
|
||||
record.setSourceId(chatCouponId);
|
||||
@@ -532,6 +538,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
record.setMaxDiscountAmount(coupon.getMaxDiscountAmount());
|
||||
record.setCreateTime(LocalDateTime.now());
|
||||
record.setIsDel(0);
|
||||
record.setValidType(coupon.getValidType());
|
||||
if ("fixed".equals(coupon.getValidType())) {
|
||||
record.setDaysToTakeEffect(coupon.getDaysToTakeEffect());
|
||||
record.setValidDays(coupon.getValidDays());
|
||||
@@ -543,6 +550,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void grantChatCoupon(MkShopCouponRecord record, Integer number) {
|
||||
ShopCoupon coupon = couponService.selectOneById(record.getCouponId());
|
||||
AssertUtil.isNull(coupon, "优惠券不存在");
|
||||
@@ -556,7 +564,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
if (coupon.getStatus() != 1) {
|
||||
return;
|
||||
}
|
||||
coupon.setGiftNum(coupon.getGiftNum() + number);
|
||||
//组装 发放优惠券
|
||||
if ("fixed".equals(record.getValidType())) {
|
||||
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
||||
//固定时间
|
||||
@@ -574,7 +582,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
ShopCoupon newCoupon = new ShopCoupon();
|
||||
newCoupon.setGiftNum(coupon.getGiftNum());
|
||||
newCoupon.setGiftNum(coupon.getGiftNum() + number);
|
||||
if (coupon.getSyncId() != null) {
|
||||
queryWrapper.and(q -> {
|
||||
q.eq(ShopCoupon::getId, coupon.getSyncId()).or(q1 -> {
|
||||
|
||||
Reference in New Issue
Block a user