后端 + 前端:优惠劵更新状态功能
This commit is contained in:
parent
f8ae2153ba
commit
5c8828c2ec
@ -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('更新状态成功!');
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
});
|
||||
}
|
||||
|
@ -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<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return couponService.updateCouponTemplateStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
|
||||
}
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
@ -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<Boolean> updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status);
|
||||
CommonResult<Boolean> updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId,
|
||||
@InEnum(value = CouponTemplateStatusEnum.class, message = "修改状态必须是 {value}") Integer status);
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public class CouponServiceImpl implements CouponService {
|
||||
@Autowired
|
||||
private CouponTemplateMapper couponTemplateMapper;
|
||||
|
||||
// ========== 优惠劵(码)模板 ==========
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponTemplatePageBO> getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO) {
|
||||
CouponTemplatePageBO couponTemplatePageBO = new CouponTemplatePageBO();
|
||||
@ -102,27 +104,16 @@ public class CouponServiceImpl implements CouponService {
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardBO> addCouponCard(Integer userId, Integer couponTemplateId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> cancelUseCouponCard(Integer userId, Integer couponCardId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardBO> 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<Boolean> 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<CouponCardBO> addCouponCard(Integer userId, Integer couponTemplateId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> cancelUseCouponCard(Integer userId, Integer couponCardId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardBO> useCouponCode(Integer userId, String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user