diff --git a/admin-web/src/models/promotion/couponCardTemplateList.js b/admin-web/src/models/promotion/couponCardTemplateList.js index 0add40a0a..ba7735a1b 100644 --- a/admin-web/src/models/promotion/couponCardTemplateList.js +++ b/admin-web/src/models/promotion/couponCardTemplateList.js @@ -1,8 +1,8 @@ import {message} from 'antd'; import { - updateProductRecommendStatus, addCouponCardTemplate, updateCouponCardTemplate, + updateCouponCardTemplateStatus, getCouponCardTemplatePage, } from '../../services/promotion'; import PaginationHelper from '../../../helpers/PaginationHelper'; @@ -123,7 +123,7 @@ export default { * updateStatus({ payload }, { call, put }) { // 请求 - const response = yield call(updateProductRecommendStatus, payload); + const response = yield call(updateCouponCardTemplateStatus, payload); // 响应 if (response.code === 0) { message.info('更新状态成功!'); diff --git a/admin-web/src/pages/Promotion/CouponCardTemplateList.js b/admin-web/src/pages/Promotion/CouponCardTemplateList.js index 4aa904fe4..510c11240 100644 --- a/admin-web/src/pages/Promotion/CouponCardTemplateList.js +++ b/admin-web/src/pages/Promotion/CouponCardTemplateList.js @@ -48,7 +48,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, function handleStatus(record) { Modal.confirm({ title: record.status === 1 ? '确认禁用' : '取消禁用', - content: `${record.productSpuId}`, + content: `${record.title}`, onOk() { dispatch({ type: 'couponCardTemplateList/updateStatus', diff --git a/admin-web/src/services/promotion.js b/admin-web/src/services/promotion.js index 0abb67ce1..bfef93ba3 100644 --- a/admin-web/src/services/promotion.js +++ b/admin-web/src/services/promotion.js @@ -84,3 +84,9 @@ export async function updateCouponCardTemplate(params) { method: 'POST', }); } + +export async function updateCouponCardTemplateStatus(params) { + return request(`/promotion-api/admins/coupon/template/update_status?${stringify(params)}`, { + method: 'POST', + }); +} diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java index b4fed0e2c..ce277c738 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java @@ -2,6 +2,7 @@ package cn.iocoder.mall.promotion.application.controller.admins; import cn.iocoder.common.framework.util.DateUtil; import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.promotion.api.CouponService; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; @@ -131,6 +132,17 @@ public class AdminsCouponTemplateController { return couponService.updateCouponCardTemplate(couponCardTemplateUpdateDTO); } + @PostMapping("/template/update_status") + @ApiOperation(value = "更新优惠劵(码)模板状态") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1"), + @ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"), + }) + public CommonResult updateStatus(@RequestParam("id") Integer id, + @RequestParam("status") Integer status) { + return couponService.updateCouponTemplateStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status); + } + // ========== 优惠劵 ========== // ========== 优惠码 ========== diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java index 977ef9663..01f22c3bd 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java @@ -1,9 +1,11 @@ package cn.iocoder.mall.promotion.api; +import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateStatusEnum; import cn.iocoder.mall.promotion.api.dto.*; public interface CouponService { @@ -52,7 +54,8 @@ public interface CouponService { * @param status 状态 * @return 是否成功 */ - CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status); + CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, + @InEnum(value = CouponTemplateStatusEnum.class, message = "修改状态必须是 {value}") Integer status); // ========== 优惠劵 ========== diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java index 087f1f1d5..af1b88377 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java @@ -1,8 +1,10 @@ package cn.iocoder.mall.promotion.api.constant; +import cn.iocoder.common.framework.core.IntArrayValuable; + import java.util.Arrays; -public enum CouponTemplateStatusEnum { +public enum CouponTemplateStatusEnum implements IntArrayValuable { ENABLE(1, "开启中"), DISABLE(2, "禁用中"), @@ -33,4 +35,8 @@ public enum CouponTemplateStatusEnum { return name; } + @Override + public int[] array() { + return ARRAYS; + } } diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java index 69da446f0..270feaeaf 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java @@ -24,6 +24,8 @@ public class CouponServiceImpl implements CouponService { @Autowired private CouponTemplateMapper couponTemplateMapper; + // ========== 优惠劵(码)模板 ========== + @Override public CommonResult getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO) { CouponTemplatePageBO couponTemplatePageBO = new CouponTemplatePageBO(); @@ -102,27 +104,16 @@ public class CouponServiceImpl implements CouponService { @Override public CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status) { - return null; - } - - @Override - public CommonResult addCouponCard(Integer userId, Integer couponTemplateId) { - return null; - } - - @Override - public CommonResult useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) { - return null; - } - - @Override - public CommonResult cancelUseCouponCard(Integer userId, Integer couponCardId) { - return null; - } - - @Override - public CommonResult useCouponCode(Integer userId, String code) { - return null; + // 校验 CouponCardTemplate 存在 + CouponTemplateDO template = couponTemplateMapper.selectById(couponTemplateId); + if (template == null) { + return ServiceExceptionUtil.error(PromotionErrorCodeEnum.PRODUCT_TEMPLATE_NOT_EXISTS.getCode()); + } + // 更新到数据库 + CouponTemplateDO updateTemplateDO = new CouponTemplateDO().setId(couponTemplateId).setStatus(status); + couponTemplateMapper.update(updateTemplateDO); + // 返回成功 + return CommonResult.success(true); } private CommonResult checkCouponTemplateDateType(Integer dateType, Date validStartTime, Date validEndTime, Integer fixedBeginTerm, Integer fixedEndTerm) { @@ -168,4 +159,28 @@ public class CouponServiceImpl implements CouponService { return CommonResult.success(true); } + // ========== 优惠劵 ========== + + @Override + public CommonResult addCouponCard(Integer userId, Integer couponTemplateId) { + return null; + } + + @Override + public CommonResult useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) { + return null; + } + + @Override + public CommonResult cancelUseCouponCard(Integer userId, Integer couponCardId) { + return null; + } + + // ========== 优惠码 ========== + + @Override + public CommonResult useCouponCode(Integer userId, String code) { + return null; + } + }