Browse Source

兑换码

zhangkaikai 1 year ago
parent
commit
672de508f6

+ 2 - 2
mp-admin/src/main/java/com/qs/mp/web/controller/api/user/UserMineController.java

@@ -421,10 +421,10 @@ public class UserMineController extends BaseApiController {
     public AjaxResult ticketExchange(@RequestBody CdKeyExchangeParam param) {
     public AjaxResult ticketExchange(@RequestBody CdKeyExchangeParam param) {
         CdKey cdKey = cdKeyService.getOne(new QueryWrapper<CdKey>().eq("cd_key", param.getCdKey()));
         CdKey cdKey = cdKeyService.getOne(new QueryWrapper<CdKey>().eq("cd_key", param.getCdKey()));
         if (cdKey == null) {
         if (cdKey == null) {
-            return AjaxResult.error("兑换商品不存在");
+            return AjaxResult.error("兑换不存在");
         }
         }
         if (cdKey.getStatus() == 1) {
         if (cdKey.getStatus() == 1) {
-            return AjaxResult.error("该商品已被兑换");
+            return AjaxResult.error("兑换码已被兑换");
         }
         }
         // 判断兑换码是否失效
         // 判断兑换码是否失效
         CdKeyGroup cdKeyGroup = cdKeyGroupService.getById(cdKey.getGroupId());
         CdKeyGroup cdKeyGroup = cdKeyGroupService.getById(cdKey.getGroupId());

+ 7 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/CdKeyGroup.java

@@ -49,6 +49,13 @@ public class CdKeyGroup implements Serializable {
     @TableField("site_name")
     @TableField("site_name")
     private String siteName;
     private String siteName;
 
 
+    /**
+     * 兑换码组标题
+     */
+    @ApiModelProperty("兑换码组标题")
+    @TableField("title")
+    private String title;
+
     /**
     /**
      * 兑换码数量
      * 兑换码数量
      */
      */

+ 3 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/param/CdKeyCreateParam.java

@@ -20,6 +20,9 @@ public class CdKeyCreateParam {
     @ApiModelProperty(value = "渠道id", required = true)
     @ApiModelProperty(value = "渠道id", required = true)
     private Long channelId;
     private Long channelId;
 
 
+    @ApiModelProperty(value = "兑换码组标题",required = true)
+    private String title;
+
     @NotNull(message = "数量不能为空")
     @NotNull(message = "数量不能为空")
     @ApiModelProperty(value = "数量", required = true)
     @ApiModelProperty(value = "数量", required = true)
     private Integer quantity;
     private Integer quantity;

+ 5 - 1
mp-service/src/main/java/com/qs/mp/admin/domain/param/CdKeyQueryParam.java

@@ -1,5 +1,8 @@
 package com.qs.mp.admin.domain.param;
 package com.qs.mp.admin.domain.param;
 
 
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.qs.mp.common.enums.CdKeyGroupStatusEnum;
 import lombok.Data;
 import lombok.Data;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -31,5 +34,6 @@ public class CdKeyQueryParam {
     @ApiModelProperty("门店名称")
     @ApiModelProperty("门店名称")
     private String siteName;
     private String siteName;
     @ApiModelProperty("状态")
     @ApiModelProperty("状态")
-    private String status;
+    @JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
+    private CdKeyGroupStatusEnum status;
 }
 }

+ 11 - 0
mp-service/src/main/java/com/qs/mp/admin/service/impl/CdKeyGroupServiceImpl.java

@@ -77,6 +77,16 @@ public class CdKeyGroupServiceImpl extends ServiceImpl<CdKeyGroupMapper, CdKeyGr
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public String createCdKeyGroup(CdKeyCreateParam param) {
     public String createCdKeyGroup(CdKeyCreateParam param) {
+
+        Integer totalQuantity = param.getQuantity();
+        Integer goodsQuantity = 0;
+        for (CdKeyGroupGoods cdKeyGroupGoods : param.getGoodsList()) {
+            goodsQuantity += cdKeyGroupGoods.getQuantity();
+        }
+        if (!totalQuantity.equals(goodsQuantity)) {
+            throw new ServiceException("兑换码数量不一致");
+        }
+
         Channel channel = channelService.getById(param.getChannelId());
         Channel channel = channelService.getById(param.getChannelId());
         if (channel == null) {
         if (channel == null) {
             LogUtil.error(logger,"门店不存在,channelId:{0}", param.getChannelId());
             LogUtil.error(logger,"门店不存在,channelId:{0}", param.getChannelId());
@@ -85,6 +95,7 @@ public class CdKeyGroupServiceImpl extends ServiceImpl<CdKeyGroupMapper, CdKeyGr
         // 生成兑换码组
         // 生成兑换码组
         CdKeyGroup cdKeyGroup = mapperFacade.map(param, CdKeyGroup.class);
         CdKeyGroup cdKeyGroup = mapperFacade.map(param, CdKeyGroup.class);
         cdKeyGroup.setGroupId(bizIdGenerator.newId());
         cdKeyGroup.setGroupId(bizIdGenerator.newId());
+        cdKeyGroup.setTitle(param.getTitle());
         cdKeyGroup.setStatus(CdKeyGroupStatusEnum.WAITING);
         cdKeyGroup.setStatus(CdKeyGroupStatusEnum.WAITING);
         cdKeyGroup.setSiteName(channel.getName());
         cdKeyGroup.setSiteName(channel.getName());
         cdKeyGroup.setCreatedTime(new Date());
         cdKeyGroup.setCreatedTime(new Date());