分享相关代码 注释掉

优惠券 管理端重写 使用的地方 注释
This commit is contained in:
2025-09-11 16:10:38 +08:00
parent 65ba0e18ce
commit 35d257bc56
23 changed files with 1292 additions and 91 deletions

View File

@@ -0,0 +1,15 @@
package com.czg.service.market.mapper;
import com.czg.market.entity.ShopCoupon;
import com.mybatisflex.core.BaseMapper;
/**
* 优惠券信息表 映射层。
*
* @author ww
* @since 2025-09-11
*/
public interface ShopCouponMapper extends BaseMapper<ShopCoupon> {
}

View File

@@ -0,0 +1,66 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.exceptions.ValidateException;
import com.czg.market.dto.ShopCouponDTO;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.service.ShopCouponService;
import com.czg.service.market.mapper.ShopCouponMapper;
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.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
/**
* 优惠券信息表 服务层实现。
*
* @author ww
* @since 2025-09-11
*/
@DubboService
public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCoupon> implements ShopCouponService{
@Override
public Page<ShopCouponDTO> getCouponPage(ShopCouponDTO param) {
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
queryWrapper.eq(ShopCoupon::getShopId, param.getShopId())
.eq(ShopCoupon::getCouponType, param.getCouponType())
.orderBy(ShopCoupon::getCreateTime).desc();
return pageAs(PageUtil.buildPage(), queryWrapper, ShopCouponDTO.class);
}
@Override
public ShopCouponDTO getCouponById(Long id) {
AssertUtil.isNull(id, "优惠券ID不能为空");
return getOneAs(new QueryWrapper().eq(ShopCoupon::getId, id), ShopCouponDTO.class);
}
@Override
public void addCoupon(ShopCouponDTO param) {
ShopCoupon coupon = BeanUtil.toBean(param, ShopCoupon.class);
save(coupon);
}
@Override
public void updateCouponById(ShopCouponDTO param) {
if (param.getGiveNum() != null && param.getGiveNum() != -10086) {
ShopCoupon tbShopCoupon = getById(param.getId());
if (param.getGiveNum() < tbShopCoupon.getGiveNum()) {
throw new ValidateException("修改失败 发放数量不可减少");
} else {
param.setLeftNum(tbShopCoupon.getLeftNum() + tbShopCoupon.getGiveNum() - param.getGiveNum());
}
}
ShopCoupon coupon = BeanUtil.toBean(param, ShopCoupon.class);
updateById(coupon,true);
}
@Override
public void deleteCoupon(Long id) {
AssertUtil.isNull(id, "优惠券ID不能为空");
removeById(id);
}
}

View File

@@ -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.ShopCouponMapper">
</mapper>