Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -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