From 5c8828c2ec86b64dc69cb49ff0042fde90631d87 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 6 Apr 2019 01:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=20+=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=EF=BC=9A=E4=BC=98=E6=83=A0=E5=8A=B5=E6=9B=B4=E6=96=B0=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/couponCardTemplateList.js | 4 +- .../pages/Promotion/CouponCardTemplateList.js | 2 +- admin-web/src/services/promotion.js | 6 ++ .../AdminsCouponTemplateController.java | 12 ++++ .../mall/promotion/api/CouponService.java | 5 +- .../constant/CouponTemplateStatusEnum.java | 8 ++- .../biz/service/CouponServiceImpl.java | 57 ++++++++++++------- 7 files changed, 68 insertions(+), 26 deletions(-) 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; + } + }