zhangkaikai 1 жил өмнө
parent
commit
debf0ca5dc

+ 20 - 3
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/CdKeyMgrController.java

@@ -16,6 +16,8 @@ import com.qs.mp.admin.domain.vo.CdKeyGroupVO;
 import com.qs.mp.admin.service.ICdKeyGroupGoodsService;
 import com.qs.mp.admin.service.ICdKeyGroupService;
 import com.qs.mp.admin.service.ICdKeyService;
+import com.qs.mp.channel.domain.Channel;
+import com.qs.mp.channel.service.IChannelService;
 import com.qs.mp.common.core.domain.AjaxResult;
 import com.qs.mp.common.core.page.TableDataInfo;
 import com.qs.mp.common.enums.CdKeyGroupStatusEnum;
@@ -27,6 +29,7 @@ import com.qs.mp.web.controller.BaseController;
 import io.swagger.annotations.*;
 import ma.glasnost.orika.MapperFacade;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -56,6 +59,15 @@ public class CdKeyMgrController extends BaseController {
     @Autowired
     private MapperFacade mapperFacade;
 
+    @Autowired
+    private IChannelService channelService;
+
+    @Value("${cloud.public-bucket-name}")
+    private String publicBucketName;
+
+    @Value("${cloud.region}")
+    private String region;
+
 
     @ApiOperation("兑换码生成")
     @PreAuthorize("@ss.hasPermi('business:cdKey:add')")
@@ -108,6 +120,8 @@ public class CdKeyMgrController extends BaseController {
             cdKeyGroupListVOS = cdKeyGroupList.stream().map(cdKeyGroup -> {
                 CdKeyGroupListVO cdKeyGroupListVO = new CdKeyGroupListVO();
                 BeanUtils.copyProperties(cdKeyGroup, cdKeyGroupListVO);
+                Channel channel = channelService.getById(cdKeyGroup.getChannelId());
+                cdKeyGroupListVO.setSiteName(channel.getSiteName() + channel.getMobile());
                 return cdKeyGroupListVO;
             }).collect(Collectors.toList());
         }
@@ -156,7 +170,9 @@ public class CdKeyMgrController extends BaseController {
         exchangeVOList.forEach(cdKeyExchangeVO -> {
                     cdKeyExchangeVO.setRemainQty((int) unCashedCount);
                     cdKeyExchangeVO.setCashedQty((int) cashedCount);
-                });
+            List<CdKeyGroupGoods> goodsList = cdKeyGroupGoodsService.list(new QueryWrapper<CdKeyGroupGoods>().eq("ref_id", cdKeyExchangeVO.getRefId()));
+            cdKeyExchangeVO.setGoodsName(goodsList.get(0).getTitle());
+            });
         TableDataInfo resp = getDataTable(cdKeyList);
         resp.setRows(exchangeVOList);
         return resp;
@@ -166,14 +182,15 @@ public class CdKeyMgrController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:cdKey:export')")
     @PostMapping("/export")
     public AjaxResult export(@RequestBody CdKeyExportParam param) {
-        List<CdKey> cdKeyExportList = cdKeyService.listByIds(param.getGroupIdList());
+        List<CdKey> cdKeyExportList = cdKeyService.list(new QueryWrapper<CdKey>().in("group_id", param.getGroupIdList()));
         List<CdKeyOrderExcel> excelList = new ArrayList<>();
         cdKeyExportList.forEach(cdKey -> {
             CdKeyOrderExcel cdKeyOrderExcel = new CdKeyOrderExcel();
             cdKeyOrderExcel.setCdKey(cdKey.getCdKey());
             CdKeyGroupGoods groupGoods = cdKeyGroupGoodsService.getOne(new QueryWrapper<CdKeyGroupGoods>().eq("ref_id", cdKey.getRefId()));
             cdKeyOrderExcel.setGoodsName(groupGoods.getTitle());
-            cdKeyOrderExcel.setPicUrl(cdKey.getPicUrl());
+            String picUrl = "https://" + publicBucketName + ".cos." + region + ".myqcloud.com/" + groupGoods.getPicUrl();
+            cdKeyOrderExcel.setPicUrl(picUrl);
             excelList.add(cdKeyOrderExcel);
         });
 

+ 3 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/vo/CdKeyExchangeVO.java

@@ -23,4 +23,7 @@ public class CdKeyExchangeVO extends CdKey{
 
     @ApiModelProperty("未兑数量")
     private Integer remainQty;
+
+    @ApiModelProperty("商品名称")
+    private String goodsName;
 }

+ 5 - 4
mp-service/src/main/java/com/qs/mp/admin/service/impl/CdKeyGroupServiceImpl.java

@@ -10,6 +10,7 @@ import com.qs.mp.admin.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qs.mp.channel.domain.Channel;
 import com.qs.mp.channel.service.IChannelService;
+import com.qs.mp.common.constant.Constants;
 import com.qs.mp.common.enums.*;
 import com.qs.mp.common.exception.ServiceException;
 import com.qs.mp.common.utils.LogUtil;
@@ -100,7 +101,7 @@ public class CdKeyGroupServiceImpl extends ServiceImpl<CdKeyGroupMapper, CdKeyGr
                         throw new ServiceException("关联优惠券信息不存在");
                     }
                     groupGoods.setTitle(coupon.getTitle());
-                    groupGoods.setPicUrl(cdKeyGroupGoods.getPicUrl());
+                    groupGoods.setPicUrl(coupon.getPicUrl());
                     groupGoods.setValue(coupon.getDiscount());
                     groupGoods.setQuantity(cdKeyGroupGoods.getQuantity());
                 } else if (CdKeyGroupGoodsTypeEnum.COUPON_PKG.equals(cdKeyGroupGoods.getType())) {
@@ -110,7 +111,7 @@ public class CdKeyGroupServiceImpl extends ServiceImpl<CdKeyGroupMapper, CdKeyGr
                         throw new ServiceException("关联券包信息不存在");
                     }
                     groupGoods.setTitle(couponPkg.getTitle());
-                    groupGoods.setPicUrl(cdKeyGroupGoods.getPicUrl());
+                    groupGoods.setPicUrl(couponPkg.getPicUrl());
                     groupGoods.setValue(couponPkg.getFacePrice());
                     groupGoods.setQuantity(cdKeyGroupGoods.getQuantity());
                 } else if (CdKeyGroupGoodsTypeEnum.GOODS.equals(cdKeyGroupGoods.getType())) {
@@ -120,12 +121,12 @@ public class CdKeyGroupServiceImpl extends ServiceImpl<CdKeyGroupMapper, CdKeyGr
                         throw new ServiceException("关联商品信息不存在");
                     }
                     groupGoods.setTitle(goods.getTitle());
-                    groupGoods.setPicUrl(cdKeyGroupGoods.getPicUrl());
+                    groupGoods.setPicUrl(goods.getPicUrl());
                     groupGoods.setValue(goods.getValue());
                     groupGoods.setQuantity(cdKeyGroupGoods.getQuantity());
                 } else {
                     groupGoods.setTitle("盲豆");
-                    groupGoods.setPicUrl(cdKeyGroupGoods.getPicUrl());
+                    groupGoods.setPicUrl(Constants.MANGDOU_PIC);
                     groupGoods.setQuantity(cdKeyGroupGoods.getQuantity());
                 }
                 cdKeyGroupGoodsList.add(groupGoods);