数量统一 领取记录 统一

This commit is contained in:
wangw 2025-09-27 15:20:42 +08:00
parent 670ef1f87b
commit 9063aa5a84
1 changed files with 35 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.QueryReceiveDto;
import com.czg.account.entity.PictureGallery;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo;
@ -28,6 +29,7 @@ import com.czg.utils.AssertUtil;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
@ -80,9 +82,27 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
@Override
public Page<MkShopCouponRecordDTO> getRecord(MkShopCouponRecordDTO mkShopCouponRecordDTO, String startTime, String endTime) {
Map<Long, UserInfo> userInfoMap = new HashMap<>();
if (mkShopCouponRecordDTO.getCouponId() == null) {
throw new CzgException("优惠券Id不能为空");
}
ShopCoupon coupon = couponService.selectOneById(mkShopCouponRecordDTO.getCouponId());
AssertUtil.isNull(coupon, "优惠券不存在");
QueryWrapper recordQueryWrapper = new QueryWrapper();
if (coupon.getSyncId() != null) {
recordQueryWrapper.and(q -> {
q.eq(MkShopCouponRecord::getCouponId, coupon.getId()).or(q1 -> {
q1.eq(MkShopCouponRecord::getCouponSyncId, coupon.getSyncId());
});
});
}else {
recordQueryWrapper.and(q -> {
q.eq(MkShopCouponRecord::getCouponId, coupon.getId()).or(q1 -> {
q1.eq(ShopCoupon::getSyncId, coupon.getId());
});
});
}
recordQueryWrapper.eq(MkShopCouponRecord::getShopId, mkShopCouponRecordDTO.getShopId())
.eq(MkShopCouponRecord::getCouponId, mkShopCouponRecordDTO.getCouponId())
.eq(MkShopCouponRecord::getIsDel, 0)
.eq(MkShopCouponRecord::getStatus, mkShopCouponRecordDTO.getStatus())
.orderBy(MkShopCouponRecord::getCreateTime).desc();
@ -190,7 +210,20 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
record.setUseEndTime(end);
save(record);
}
couponService.update(coupon, true);
QueryWrapper queryWrapper = new QueryWrapper();
ShopCoupon newCoupon = new ShopCoupon();
newCoupon.setLeftNum(coupon.getLeftNum());
if (coupon.getSyncId() != null) {
queryWrapper.and(q -> {
q.eq(ShopCoupon::getId, coupon.getSyncId()).or(q1 -> {
q1.eq(ShopCoupon::getSyncId, coupon.getSyncId());
});
});
couponService.updateByQuery(newCoupon, queryWrapper);
} else {
queryWrapper.eq(ShopCoupon::getId, coupon.getId());
couponService.update(coupon, true);
}
}