Ver Fonte

1.采购申请单列表、详情
2.修复库存预警字段问题

FengChaoYu há 2 semanas atrás
pai
commit
66b86aa4d2

+ 20 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsApplyPurchaseBean.java

@@ -0,0 +1,20 @@
+package com.gree.mall.manager.bean.goods;
+
+import com.gree.mall.manager.plus.entity.GoodsApplyPurchase;
+import com.gree.mall.manager.plus.entity.GoodsApplyPurchaseItem;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class GoodsApplyPurchaseBean extends GoodsApplyPurchase {
+
+    @ApiModelProperty(value = "商品明细")
+    List<GoodsApplyPurchaseItem> items;
+}

+ 77 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsApplyPurchaseVO.java

@@ -0,0 +1,77 @@
+package com.gree.mall.manager.bean.goods;
+
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel
+@ZfireField(tbName = "a")
+public class GoodsApplyPurchaseVO {
+
+    @ApiModelProperty(value = "单据编号")
+    private String id;
+
+    @ApiModelProperty(value = "单据状态")
+    private ExamineStatusEnum status;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "商户编号")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "商户名称")
+    private String companyWechatName;
+
+//    @ZfireField(hide = true)
+//    @ApiModelProperty(value = "供应商编号")
+//    private String venderId;
+//
+//    @ApiModelProperty(value = "供应商名称")
+//    private String venderName;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "仓储id")
+    private String storageId;
+
+    @ApiModelProperty(value = "入库仓库")
+    private String storageName;
+
+    @ApiModelProperty(value = "采购总数量")
+    private Integer totalQty;
+
+    @ApiModelProperty(value = "采购总金额")
+    private BigDecimal totalAmount;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "提交人")
+    private String submitBy;
+
+    @ApiModelProperty(value = "提交时间")
+    private Date submitTime;
+
+    @ApiModelProperty(value = "审核人")
+    private String examineBy;
+
+    @ApiModelProperty(value = "审核时间")
+    private Date examineTime;
+
+}

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsPurchaseBean.java

@@ -4,9 +4,11 @@ import com.gree.mall.manager.plus.entity.GoodsPurchase;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 import java.util.List;
 
+@EqualsAndHashCode(callSuper = true)
 @Data
 @ApiModel
 public class GoodsPurchaseBean extends GoodsPurchase {

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsStockWarningVO.java

@@ -42,7 +42,7 @@ public class GoodsStockWarningVO {
     @ApiModelProperty(value = "商品规格名称")
     private String name;
 
-    @ZfireField(tbName = "c", colName = "goods_name")
+    @ZfireField(tbName = "c", colName = "goods_name", ignoreSelect = true)
     @ApiModelProperty(value = "物料名称")
     private String goodsMaterialName;
 

+ 7 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/CommonMapper.java

@@ -665,4 +665,11 @@ public interface CommonMapper {
      * @return
      */
     IPage<UserLevelGoodsVO> userLevelGoodsPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
+
+    /**
+     * 会员等级商品规格列表
+     * @param page
+     * @return
+     */
+    IPage<GoodsApplyPurchaseVO> goodsApplyPurchaseList(Page page, @Param("ex") ZfireParamBean zfireParamBean);
 }

+ 73 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/goods/GoodsApplyPurchaseController.java

@@ -0,0 +1,73 @@
+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.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.goods.GoodsApplyPurchaseBean;
+import com.gree.mall.manager.bean.goods.GoodsApplyPurchaseVO;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.goods.GoodsApplyPurchaseLogic;
+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;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Slf4j
+@RestController
+@Api(value = "商品采购申请API", tags ={"商品采购申请API"} )
+@RequestMapping(value = "/goods/apply/purchase", produces = "application/json; charset=utf-8")
+public class GoodsApplyPurchaseController {
+
+    @Resource
+    GoodsApplyPurchaseLogic goodsApplyPurchaseLogic;
+
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "商品采购申请-列表")
+    public ResponseHelper<Page<GoodsApplyPurchaseVO>> page(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws Exception {
+        IPage<GoodsApplyPurchaseVO> page = goodsApplyPurchaseLogic.page(zfireParamBean);
+        return ResponseHelper.success(page, new TypeReference<GoodsApplyPurchaseVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation("商品采购申请-导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        //2.查询要导出的内容
+        IPage<GoodsApplyPurchaseVO> baseVOIPage = goodsApplyPurchaseLogic.page(zfireParamBean);
+        //3.导出
+        FieldUtils.exportData(baseVOIPage.getRecords(), zfireParamBean.getExportFields(), request, response);
+    }
+
+    @PostMapping("/detail")
+    @ApiOperation(value = "商品采购申请-详情")
+    public ResponseHelper<GoodsApplyPurchaseBean> detail(
+            @ApiParam(value = "id",required = true) @RequestParam String id
+    ) throws RemoteServiceException {
+        GoodsApplyPurchaseBean detail = goodsApplyPurchaseLogic.detail(id);
+        return ResponseHelper.success(detail);
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "商品采购申请-新增修改")
+    public ResponseHelper save(
+            @ApiParam(value = "object",required = true) @RequestBody GoodsApplyPurchaseBean bean
+    ) throws RemoteServiceException {
+        goodsApplyPurchaseLogic.save(bean);
+        return ResponseHelper.success(bean);
+    }
+}

+ 14 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -13,6 +13,8 @@ import com.gree.mall.manager.utils.ApplicationContextUtils;
 import com.gree.mall.manager.utils.CommonUtils;
 import com.gree.mall.manager.utils.RedisUtil;
 import com.gree.mall.manager.utils.oss.OSSUtil;
+import com.gree.mall.manager.zfire.bean.QueryParamBean;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateUtils;
@@ -475,4 +477,16 @@ public class CommonLogic {
             incrKeyValueService.saveBatch(list);
         }
     }
+
+    public AdminUserCom commonAddQueryFilterParam(ZfireParamBean zfireParamBean) {
+        final AdminUserCom adminUser = getAdminUser();
+        // 过滤账号所能看到的仓库单据
+        if (!adminUser.getType().toString().equals("2")) {
+            QueryParamBean paramBean = new QueryParamBean();
+            paramBean.setParam("a.storage_id")
+                    .setValue(CollectionUtil.isNotEmpty(adminUser.getStorageIds()) ? adminUser.getStorageIds() : Collections.singletonList("1"));
+            zfireParamBean.getParams().add(paramBean);
+        }
+        return adminUser;
+    }
 }

+ 115 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsApplyPurchaseLogic.java

@@ -0,0 +1,115 @@
+package com.gree.mall.manager.logic.goods;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.goods.GoodsApplyPurchaseBean;
+import com.gree.mall.manager.bean.goods.GoodsApplyPurchaseVO;
+import com.gree.mall.manager.commonmapper.CommonMapper;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.GoodsApplyPurchase;
+import com.gree.mall.manager.plus.entity.GoodsApplyPurchaseItem;
+import com.gree.mall.manager.plus.service.GoodsApplyPurchaseItemService;
+import com.gree.mall.manager.plus.service.GoodsApplyPurchaseService;
+import com.gree.mall.manager.plus.service.WebsitVenderService;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class GoodsApplyPurchaseLogic {
+
+    private final CommonLogic commonLogic;
+    private final CommonMapper commonMapper;
+    private final GoodsApplyPurchaseService goodsApplyPurchaseService;
+    private final GoodsApplyPurchaseItemService goodsApplyPurchaseItemService;
+    private final WebsitVenderService websitVenderService;
+
+
+    public IPage<GoodsApplyPurchaseVO> page(ZfireParamBean zfireParamBean) {
+        final AdminUserCom adminUser = commonLogic.commonAddQueryFilterParam(zfireParamBean);
+        FieldUtils.supplyParam(zfireParamBean, GoodsApplyPurchaseVO.class, adminUser);
+        IPage<GoodsApplyPurchaseVO> page = commonMapper.goodsApplyPurchaseList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
+
+        return page;
+    }
+
+    public GoodsApplyPurchaseBean detail(String id) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        String companyId = null;
+        if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
+            companyId = adminUser.getAdminCompanyWechat().getCompanyWechatId();
+        }
+        GoodsApplyPurchaseBean bean = new GoodsApplyPurchaseBean();
+        GoodsApplyPurchase applyPurchase = goodsApplyPurchaseService.lambdaQuery()
+                .eq(StringUtils.isNotBlank(companyId), GoodsApplyPurchase::getCompanyWechatId, companyId)
+                .eq(GoodsApplyPurchase::getId, id)
+                .one();
+
+        if (Objects.nonNull(applyPurchase)) {
+            List<GoodsApplyPurchaseItem> items = goodsApplyPurchaseItemService.lambdaQuery()
+                    .eq(GoodsApplyPurchaseItem::getGoodsApplyPurchaseId, applyPurchase.getId())
+                    .list();
+            List<GoodsApplyPurchaseItem> itemBeans = BeanUtil.copyToList(items, GoodsApplyPurchaseItem.class);
+
+            bean.setItems(itemBeans);
+
+            BeanUtils.copyProperties(applyPurchase, bean);
+        }
+
+        return bean;
+    }
+
+    @Transactional
+    public void save(GoodsApplyPurchaseBean bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        final GoodsApplyPurchase old = goodsApplyPurchaseService.getById(bean.getId());
+
+        if (Objects.nonNull(old)) {
+            goodsApplyPurchaseItemService.lambdaUpdate()
+                    .eq(GoodsApplyPurchaseItem::getGoodsApplyPurchaseId, old.getId())
+                    .remove();
+        } else {
+            bean.setId(IdWorker.getIdStr())
+                    .setStatus(ExamineStatusEnum.SAVE.getKey());
+        }
+
+        bean.setVenderId("0").setVenderName("格力");
+
+        // 检查商品信息唯一
+        checkItemUnique(bean);
+
+
+
+        goodsApplyPurchaseService.saveOrUpdate(bean);
+        goodsApplyPurchaseItemService.saveBatch(bean.getItems());
+    }
+
+    private void checkItemUnique(GoodsApplyPurchaseBean bean) {
+        Map<String, List<GoodsApplyPurchaseItem>> materialGroup = bean.getItems().stream()
+                .collect(Collectors.groupingBy(GoodsApplyPurchaseItem::getGoodsMaterialId));
+
+        for (Map.Entry<String, List<GoodsApplyPurchaseItem>> entry : materialGroup.entrySet()) {
+            if (entry.getValue().size() > 1) {
+                throw new RemoteServiceException("发现重复的商品, 请检查!");
+            }
+        }
+    }
+}

+ 6 - 16
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsPurchaseLogic.java

@@ -15,7 +15,6 @@ import com.gree.mall.manager.enums.CodeAccStatusEnum;
 import com.gree.mall.manager.enums.CodeAccTypeEnum;
 import com.gree.mall.manager.enums.ExamineStatusEnum;
 import com.gree.mall.manager.enums.IsYesNoEnum;
-import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.manager.enums.base.BaseEnum;
 import com.gree.mall.manager.enums.material.DirectFlagEnum;
 import com.gree.mall.manager.enums.material.GoodsMaterialTypeEnum;
@@ -24,7 +23,6 @@ import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
-import com.gree.mall.manager.zfire.bean.QueryParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
@@ -37,7 +35,10 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -60,7 +61,7 @@ public class GoodsPurchaseLogic {
     private final GoodsMaterialStockLogic goodsMaterialStockLogic;
 
     public IPage<GoodsPurchaseVO> page(ZfireParamBean zfireParamBean) {
-        final AdminUserCom adminUser = commonAddQueryFilterParam(zfireParamBean);
+        final AdminUserCom adminUser = commonLogic.commonAddQueryFilterParam(zfireParamBean);
         FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseVO.class, adminUser);
         IPage<GoodsPurchaseVO> page = commonMapper.goodsPurchaseList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
 
@@ -68,7 +69,7 @@ public class GoodsPurchaseLogic {
     }
 
     public IPage<GoodsPurchaseItemVO> itemPage(ZfireParamBean zfireParamBean) {
-        final AdminUserCom adminUser = commonAddQueryFilterParam(zfireParamBean);
+        final AdminUserCom adminUser = commonLogic.commonAddQueryFilterParam(zfireParamBean);
         FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseItemVO.class, adminUser);
         IPage<GoodsPurchaseItemVO> page = commonMapper.goodsPurchaseItemList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
 
@@ -929,15 +930,4 @@ public class GoodsPurchaseLogic {
         }
     }
 
-    private AdminUserCom commonAddQueryFilterParam(ZfireParamBean zfireParamBean) {
-        final AdminUserCom adminUser = commonLogic.getAdminUser();
-        // 过滤账号所能看到的仓库单据
-        if (!adminUser.getType().toString().equals("2")) {
-            QueryParamBean paramBean = new QueryParamBean();
-            paramBean.setParam("a.storage_id")
-                    .setValue(CollectionUtil.isNotEmpty(adminUser.getStorageIds()) ? adminUser.getStorageIds() : Collections.singletonList("1"));
-            zfireParamBean.getParams().add(paramBean);
-        }
-        return adminUser;
-    }
 }

+ 13 - 1
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1149,7 +1149,8 @@
     </select>
     <select id="goodsStockWarningList" resultType="com.gree.mall.manager.bean.goods.GoodsStockWarningVO">
         SELECT
-        ${ex.selected}
+        ${ex.selected},
+        c.goods_name AS goods_material_name
         FROM goods_storage_warning_record a LEFT JOIN goods b ON a.goods_id = b.goods_id
         LEFT JOIN goods_material c ON a.goods_material_id = c.id
         ${ex.query}
@@ -1301,5 +1302,16 @@
         ${ex.orderBy}
     </select>
 
+    <select id="goodsApplyPurchaseList" resultType="com.gree.mall.manager.bean.goods.GoodsApplyPurchaseVO">
+        SELECT
+        ${ex.selected}
+        FROM goods_apply_purchase a
+        ${ex.query}
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
+
 
 </mapper>