充值兑换码相关接口
This commit is contained in:
parent
5b6c1a24cd
commit
08814a21a3
|
|
@ -3,10 +3,12 @@ package com.czg.controller.admin;
|
|||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaCheckMainShop;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.market.dto.MkEnableConfigDTO;
|
||||
import com.czg.market.dto.MkRechargeRedemptionConfigDTO;
|
||||
import com.czg.market.entity.MkRechargeRedemptionConfig;
|
||||
import com.czg.market.service.MkEnableConfigService;
|
||||
import com.czg.market.service.MkRechargeRedemptionConfigService;
|
||||
import com.czg.market.vo.MkEnableConfigVO;
|
||||
import com.czg.market.vo.MkRechargeRedemptionCodeVO;
|
||||
import com.czg.market.vo.MkRechargeRedemptionConfigVO;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -35,19 +37,19 @@ public class RechargeRedemptionController {
|
|||
private MkEnableConfigService enableConfigService;
|
||||
|
||||
/**
|
||||
* 配置开关
|
||||
* 开关。可用门店修改
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "rechargeRedemption:enable", name = "充值兑换状态修改")
|
||||
@PutMapping("/{enable}")
|
||||
public CzgResult<Boolean> upEnable(@PathVariable Integer enable) {
|
||||
return CzgResult.success(enableConfigService.upEnable(StpKit.USER.getMainShopId(),StpKit.USER.getLoginIdAsLong(), enable, TableValueConstant.EnableConfig.Type.RECHARGE_REDEMPTION));
|
||||
@PutMapping("/enable")
|
||||
public CzgResult<Boolean> upEnable(@Validated @RequestBody MkEnableConfigDTO dto) {
|
||||
return CzgResult.success(enableConfigService.upEnable(StpKit.USER.getMainShopId(),StpKit.USER.getLoginIdAsLong(), dto, TableValueConstant.EnableConfig.Type.RECHARGE_REDEMPTION));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开关状态
|
||||
* 开关状态,可用门店详情
|
||||
*/
|
||||
@GetMapping("/enable/status")
|
||||
public CzgResult<Integer> upEnable() {
|
||||
public CzgResult<MkEnableConfigVO> upEnable() {
|
||||
return CzgResult.success(enableConfigService.detail(StpKit.USER.getMainShopId(), StpKit.USER.getLoginIdAsLong(), TableValueConstant.EnableConfig.Type.RECHARGE_REDEMPTION));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
package com.czg.market.dto;
|
||||
|
||||
import com.czg.market.entity.MkConsumeCashbackStep;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新客立减 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-09-16
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MkEnableConfigDTO implements Serializable {
|
||||
/**
|
||||
* 可用门店列表
|
||||
*/
|
||||
private List<Long> shopIdList;
|
||||
/**
|
||||
* 类型 all 全部可用 part部分门店可用
|
||||
*/
|
||||
private String useType;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Integer isEnable;
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import java.io.Serializable;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
@ -59,4 +60,7 @@ public class MkEnableConfig implements Serializable {
|
|||
|
||||
private Long shopId;
|
||||
|
||||
private String useType;
|
||||
private String shopIdList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.market.dto.MkEnableConfigDTO;
|
||||
import com.czg.market.vo.MkEnableConfigVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkEnableConfig;
|
||||
|
||||
|
|
@ -12,6 +14,6 @@ import com.czg.market.entity.MkEnableConfig;
|
|||
*/
|
||||
public interface MkEnableConfigService extends IService<MkEnableConfig> {
|
||||
|
||||
Boolean upEnable(Long mainShopId, Long shopId, Integer enable, TableValueConstant.EnableConfig.Type type);
|
||||
Integer detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type);
|
||||
Boolean upEnable(Long mainShopId, Long shopId, MkEnableConfigDTO dto, TableValueConstant.EnableConfig.Type type);
|
||||
MkEnableConfigVO detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
package com.czg.market.vo;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 兑换码明细 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("mk_enable_config")
|
||||
public class MkEnableConfigVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主店id
|
||||
*/
|
||||
private Long mainShopId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 模块类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private Integer isEnable;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
private String useType;
|
||||
private List<Long> shopIdList;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.market.dto.MkEnableConfigDTO;
|
||||
import com.czg.market.vo.MkEnableConfigVO;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MkEnableConfig;
|
||||
|
|
@ -18,7 +24,7 @@ import org.springframework.stereotype.Service;
|
|||
public class MkEnableConfigServiceImpl extends ServiceImpl<MkEnableConfigMapper, MkEnableConfig> implements MkEnableConfigService{
|
||||
|
||||
@Override
|
||||
public Integer detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type) {
|
||||
public MkEnableConfigVO detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type) {
|
||||
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
||||
if (one == null) {
|
||||
one = new MkEnableConfig();
|
||||
|
|
@ -27,22 +33,29 @@ public class MkEnableConfigServiceImpl extends ServiceImpl<MkEnableConfigMapper,
|
|||
one.setShopId(shopId);
|
||||
save(one);
|
||||
}
|
||||
return one.getIsEnable();
|
||||
MkEnableConfigVO configVO = BeanUtil.copyProperties(one, MkEnableConfigVO.class);
|
||||
if (StrUtil.isNotBlank(one.getShopIdList())) {
|
||||
configVO.setShopIdList(JSONArray.parseArray(one.getShopIdList()).toList(Long.class));
|
||||
}
|
||||
return configVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean upEnable(Long mainShopId, Long shopId, Integer enable, TableValueConstant.EnableConfig.Type type) {
|
||||
public Boolean upEnable(Long mainShopId, Long shopId, MkEnableConfigDTO dto, TableValueConstant.EnableConfig.Type type) {
|
||||
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
||||
if (one == null) {
|
||||
one = new MkEnableConfig();
|
||||
one.setMainShopId(mainShopId);
|
||||
one.setIsEnable(enable);
|
||||
one.setIsEnable(dto.getIsEnable());
|
||||
one.setShopId(shopId);
|
||||
save(one);
|
||||
}else {
|
||||
one.setIsEnable(enable);
|
||||
updateById(one);
|
||||
one.setIsEnable(dto.getIsEnable());
|
||||
}
|
||||
return true;
|
||||
|
||||
if ("part".equals(dto.getUseType()) && dto.getShopIdList() != null) {
|
||||
one.setShopIdList(JSONObject.toJSONString(dto.getShopIdList()));
|
||||
}
|
||||
return updateById(one);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue