Compare commits
2 Commits
10817c01a0
...
f703028fa1
| Author | SHA1 | Date |
|---|---|---|
|
|
f703028fa1 | |
|
|
d01f66d6a4 |
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
package com.czg.market.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.Serial;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券赠送关联表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-09-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MkCouponGiftDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂无意义
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称(来源名称)
|
||||||
|
*/
|
||||||
|
private String sourceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源Id
|
||||||
|
*/
|
||||||
|
private Long sourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 会员开通赠券 2 会员周活动 3消费赠券
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
private String couponName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券ID
|
||||||
|
*/
|
||||||
|
private Long couponId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券数量
|
||||||
|
*/
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
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.io.Serial;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券赠送关联表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-09-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("mk_coupon_gift")
|
||||||
|
public class MkCouponGift implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂无意义
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称(来源名称)
|
||||||
|
*/
|
||||||
|
private String sourceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源Id
|
||||||
|
*/
|
||||||
|
private Long sourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 会员开通赠券 2 会员周活动 3消费赠券
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
private String couponName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券ID
|
||||||
|
*/
|
||||||
|
private Long couponId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券数量
|
||||||
|
*/
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.czg.market.service;
|
||||||
|
|
||||||
|
import com.czg.market.dto.MkCouponGiftDTO;
|
||||||
|
import com.czg.market.entity.MkCouponGift;
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券赠送关联表 服务层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-09-12
|
||||||
|
*/
|
||||||
|
public interface MkCouponGiftService extends IService<MkCouponGift> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券关联表查询
|
||||||
|
*/
|
||||||
|
Page<MkCouponGiftDTO> getCouponGiftPage(Long couponId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据sourceId查询关联券
|
||||||
|
*
|
||||||
|
* @param sourceId 来源Id
|
||||||
|
* @param type 类型 1 会员开通赠券 2 会员周活动 3 消费赠券
|
||||||
|
*/
|
||||||
|
List<MkCouponGiftDTO> getCouponGiftBySourceId(Long sourceId, Integer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增关联券
|
||||||
|
*
|
||||||
|
* @param sourceId 来源ID
|
||||||
|
* @param type 类型 1 会员开通赠券 2 会员周活动 3 消费赠券
|
||||||
|
* @param couponGiftList 券ID-数量
|
||||||
|
*/
|
||||||
|
void addCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联券
|
||||||
|
*
|
||||||
|
* @param sourceId 来源ID
|
||||||
|
* @param type 类型 1 会员开通赠券 2 会员周活动 3 消费赠券
|
||||||
|
* @param couponGiftList 券ID和数量必填
|
||||||
|
*/
|
||||||
|
void upCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除关联券
|
||||||
|
*
|
||||||
|
* @param sourceId 来源ID
|
||||||
|
* @param type 类型 1 会员开通赠券 2 会员周活动 3 消费赠券
|
||||||
|
*/
|
||||||
|
void deleteJoinCouponGift(Long sourceId, Integer type);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.czg.service.market.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.czg.market.entity.MkCouponGift;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券赠送关联表 映射层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-09-12
|
||||||
|
*/
|
||||||
|
public interface MkCouponGiftMapper extends BaseMapper<MkCouponGift> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.czg.market.dto.MkCouponGiftDTO;
|
||||||
|
import com.czg.market.entity.MkCouponGift;
|
||||||
|
import com.czg.market.entity.ShopCoupon;
|
||||||
|
import com.czg.market.service.MkCouponGiftService;
|
||||||
|
import com.czg.market.service.ShopCouponService;
|
||||||
|
import com.czg.service.market.mapper.MkCouponGiftMapper;
|
||||||
|
import com.czg.utils.PageUtil;
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 券赠送关联表 服务层实现。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-09-12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MkCouponGiftServiceImpl extends ServiceImpl<MkCouponGiftMapper, MkCouponGift> implements MkCouponGiftService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ShopCouponService shopCouponService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MkCouponGiftDTO> getCouponGiftPage(Long couponId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
|
queryWrapper.eq(MkCouponGift::getCouponId, couponId)
|
||||||
|
.orderBy(MkCouponGift::getId).desc();
|
||||||
|
return pageAs(PageUtil.buildPage(), queryWrapper, MkCouponGiftDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MkCouponGiftDTO> getCouponGiftBySourceId(Long sourceId, Integer type) {
|
||||||
|
return listAs(new QueryWrapper().eq(MkCouponGift::getSourceId, sourceId).eq(MkCouponGift::getType, type), MkCouponGiftDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList) {
|
||||||
|
if (CollUtil.isNotEmpty(couponGiftList)) {
|
||||||
|
List newCoupons = new ArrayList<>();
|
||||||
|
for (MkCouponGiftDTO giftDTO : couponGiftList) {
|
||||||
|
ShopCoupon coupon = shopCouponService.queryChain().select(ShopCoupon::getTitle)
|
||||||
|
.where(ShopCoupon::getId).eq(giftDTO.getCouponId())
|
||||||
|
.one();
|
||||||
|
if (coupon == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MkCouponGift couponGift = new MkCouponGift();
|
||||||
|
couponGift.setSourceId(sourceId);
|
||||||
|
couponGift.setSourceName(sourceName);
|
||||||
|
couponGift.setType(type);
|
||||||
|
couponGift.setCouponId(giftDTO.getCouponId());
|
||||||
|
couponGift.setNum(giftDTO.getNum());
|
||||||
|
newCoupons.add(couponGift);
|
||||||
|
}
|
||||||
|
saveBatch(newCoupons);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void upCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList) {
|
||||||
|
deleteJoinCouponGift(sourceId, type);
|
||||||
|
addCouponGift(sourceId, sourceName, type, couponGiftList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteJoinCouponGift(Long sourceId, Integer type) {
|
||||||
|
remove(new QueryWrapper().eq(MkCouponGift::getSourceId, sourceId).eq(MkCouponGift::getType, type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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.MkCouponGiftMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue