‘linchangsheng’ 1 month ago
parent
commit
6b19ca2c11

+ 1 - 0
src/main/java/com/gree/mall/manager/bean/goods/GoodsBean.java

@@ -19,6 +19,7 @@ public class GoodsBean extends Goods {
     @ApiModelProperty("轮播图")
     private List<CommonFile> images;
 
+
     private String category1;
     private String category2;
     private String mainName;

+ 60 - 0
src/main/java/com/gree/mall/manager/bean/goods/GoodsVO.java

@@ -0,0 +1,60 @@
+package com.gree.mall.manager.bean.goods;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.plus.entity.Goods;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel
+public class GoodsVO {
+
+    @ZfireField(hide = true)
+    @TableId(value = "goods_id", type = IdType.ID_WORKER_STR)
+    private String goodsId;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "商品类型: COMMON=普通商品  PACKAGE=套购商品")
+    private String goodsType;
+
+    @ApiModelProperty(value = "商品名称")
+    private String goodsName;
+
+    @ApiModelProperty(value = "商品图片")
+    private String imgUrl;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "商品分类id")
+    private String categoryId;
+
+    @ApiModelProperty(value = "商品大类")
+    private String categoryPname;
+
+    @ApiModelProperty(value = "商品小类")
+    private String categoryName;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "大类id")
+    private String categoryPid;
+
+
+
+    @ApiModelProperty(value = "划线价格")
+    private BigDecimal orgGoodsPrice;
+
+    @ApiModelProperty(value = "商品价格")
+    private BigDecimal goodsPrice;
+
+
+    @ApiModelProperty(value = "商品状态 true:上架  false:下架")
+    private Boolean status;
+
+    @ApiModelProperty(value = "排序")
+    private Integer sortNum;
+
+}

+ 3 - 4
src/main/java/com/gree/mall/manager/commonmapper/CustomGoodsMapper.java

@@ -3,12 +3,10 @@ package com.gree.mall.manager.commonmapper;
 import com.baomidou.mybatisplus.annotation.SqlParser;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.gree.mall.manager.bean.goods.GoodsPackageBean;
-import com.gree.mall.manager.bean.goods.GoodsPackageList;
-import com.gree.mall.manager.bean.goods.GoodsSpecBean;
-import com.gree.mall.manager.bean.goods.GoodsTypeCount;
+import com.gree.mall.manager.bean.goods.*;
 import com.gree.mall.manager.plus.entity.Goods;
 import com.gree.mall.manager.plus.entity.GoodsCategory;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -104,4 +102,5 @@ public interface CustomGoodsMapper {
                                                   @Param("status") Boolean status,
                                                   @Param("companyWechatIds")List<String> companyWechatIds);
 
+    IPage<GoodsVO> goodsList(Page page, @Param("ex") ZfireParamBean zfireParam);
 }

+ 32 - 0
src/main/java/com/gree/mall/manager/controller/goods/GoodsController.java

@@ -1,8 +1,12 @@
 package com.gree.mall.manager.controller.goods;
 
+import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dtflys.forest.annotation.Request;
 import com.gree.mall.manager.annotation.ApiNotAuth;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.admin.AdminWebsitVO;
 import com.gree.mall.manager.bean.goods.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
@@ -11,6 +15,8 @@ import com.gree.mall.manager.logic.goods.GoodsLogic;
 import com.gree.mall.manager.plus.entity.Goods;
 import com.gree.mall.manager.plus.entity.User;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -119,6 +125,32 @@ public class GoodsController {
     }
 
 
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "商品列表V2")
+    public ResponseHelper<IPage<GoodsVO>> list(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<GoodsVO> adminDeptVOIPage = goodsLogic.goodsList(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        return ResponseHelper.success(adminDeptVOIPage, new TypeReference<GoodsVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation(value = "商品列表V2导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<GoodsVO> adminDeptVOIPage = goodsLogic.goodsList(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        //3.导出
+        FieldUtils.exportData(adminDeptVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
+    }
+
+
+
 
     @GetMapping("/listbycategory")
     @ApiOperation(value = "商品详情")

+ 32 - 4
src/main/java/com/gree/mall/manager/logic/goods/GoodsLogic.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.ExcelData;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.admin.AdminWebsitVO;
 import com.gree.mall.manager.bean.goods.*;
 import com.gree.mall.manager.commonmapper.CustomGoodsMapper;
 import com.gree.mall.manager.commonmapper.GoodsCheckMapper;
@@ -23,7 +24,10 @@ import com.gree.mall.manager.logic.user.UserLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.DateUtils;
+import com.gree.mall.manager.utils.StringUtil;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -437,6 +441,19 @@ public class GoodsLogic {
         }
         goodsBean.setUpdateTime(new Date());
         goodsBean.setCreateTime(creatDate);
+
+        if (StringUtil.isEmpty(goodsBean.getPutCompanyId())) {
+            goodsBean.setPutCompanyId(goodsBean.getPutCompanyId());
+            String[] split = StringUtils.split(goodsBean.getPutCompanyId(), ",");
+
+            String name ="";
+            for (String s : split) {
+                AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById(s);
+                name = name+adminCompanyWechat.getCompanyName()+",";
+            }
+
+            goodsBean.setPutCompanyName(name);
+        }
         goodsService.save(goodsBean);
 
         if (CollectionUtils.isNotEmpty(goodsBean.getGoodsSpecs())) {
@@ -470,9 +487,9 @@ public class GoodsLogic {
         }
 
         //查询物料信息
-        if (Objects.nonNull(companyWechat) && StringUtils.isNotBlank(companyWechat.getJindCustomerNumber())) {
+   /*     if (Objects.nonNull(companyWechat) && StringUtils.isNotBlank(companyWechat.getJindCustomerNumber())) {
             fucaiLogic.getWuliao(goodsSpecList);
-        }
+        }*/
         //批量保存商品规格
         if(CollectionUtils.isNotEmpty(goodsSpecList))
             goodsSpecService.saveBatch(goodsSpecList);
@@ -599,9 +616,9 @@ public class GoodsLogic {
             Collections.sort(goodsSpecList, (o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
 
             //查询物料信息
-            if (Objects.nonNull(companyWechat) && StringUtils.isNotBlank(companyWechat.getJindCustomerNumber())) {
+/*            if (Objects.nonNull(companyWechat) && StringUtils.isNotBlank(companyWechat.getJindCustomerNumber())) {
                 fucaiLogic.getWuliao(goodsSpecList);
-            }
+            }*/
 
             goodsBean.setGoodsPrice(goodsSpecList.get(0).getPrice());
         }
@@ -1208,4 +1225,15 @@ public class GoodsLogic {
         excelData.setRows(rows);
         ExcelUtils.exportExcel(request, response, fileName, excelData, -1, null);
     }
+
+    public IPage<GoodsVO> goodsList(Page page, ZfireParamBean zfireParam) {
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        //1.组装查询条件
+        FieldUtils.supplyParam(zfireParam, GoodsVO.class,adminUser);
+
+        IPage<GoodsVO> goodsVOIPage = customGoodsMapper.goodsList(page, zfireParam);
+        return goodsVOIPage;
+    }
 }

+ 10 - 0
src/main/resources/mapper/CustomGoodsMapper.xml

@@ -211,6 +211,16 @@
         </choose>
 
     </select>
+    <select id="goodsList" resultType="com.gree.mall.manager.bean.goods.GoodsVO">
+        SELECT
+        ${ex.selected}
+        FROM goods a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 
 
 </mapper>