Browse Source

配件配置、配件返还设置

FengChaoYu 8 months ago
parent
commit
ba75a3a66f

+ 24 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitPartsConfigBean.java

@@ -0,0 +1,24 @@
+package com.gree.mall.manager.bean.material.manage;
+
+import com.gree.mall.manager.plus.entity.WebsitPartsRefundConfig;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+@EqualsAndHashCode(callSuper = true)
+@ApiModel
+@Data
+public class WebsitPartsConfigBean extends WebsitPartsRefundConfig {
+
+    @ApiModelProperty(value = "空调倍数")
+    private BigDecimal priceRate1;
+
+    @ApiModelProperty(value = "冰箱倍数")
+    private BigDecimal priceRate2;
+
+    @ApiModelProperty(value = "生活电器倍数")
+    private BigDecimal priceRate3;
+}

+ 62 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitPartsConfigVO.java

@@ -0,0 +1,62 @@
+package com.gree.mall.manager.bean.material.manage;
+
+import com.gree.mall.manager.annotation.ZfireField;
+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 WebsitPartsConfigVO {
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "商户编号")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "商户名称")
+    private String companyWechatName;
+
+    @ApiModelProperty(value = "网点编号")
+    private String websitId;
+
+    @ApiModelProperty(value = "网点名称")
+    private String websitName;
+
+    @ApiModelProperty(value = "新件返还(市区)")
+    private Integer newRefundInner;
+
+    @ApiModelProperty(value = "新件返还(外区)")
+    private Integer newRefundOutside;
+
+    @ApiModelProperty(value = "旧件返还")
+    private Integer oldRefund;
+
+    @ZfireField(tbName = "b")
+    @ApiModelProperty(value = "空调倍数")
+    private BigDecimal priceRate1;
+
+    @ZfireField(tbName = "b")
+    @ApiModelProperty(value = "冰箱倍数")
+    private BigDecimal priceRate2;
+
+    @ZfireField(tbName = "b")
+    @ApiModelProperty(value = "生活电器倍数")
+    private BigDecimal priceRate3;
+
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "是否默认")
+    private Boolean isDefault;
+}

+ 8 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialMapper.java

@@ -275,4 +275,12 @@ public interface MaterialMapper {
      * @return
      */
     IPage<WebsitWorkSettlementVO> websitWorkSettlementPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
+
+    /**
+     * 网点配件配置列表
+     * @param page
+     * @param zfireParamBean
+     * @return
+     */
+    IPage<WebsitPartsConfigVO> websitPartsConfigPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
 }

+ 5 - 4
mall-server-api/src/main/java/com/gree/mall/manager/controller/admin/AdminWebsitController.java

@@ -51,9 +51,10 @@ public class AdminWebsitController {
             @RequestParam(required = false) String channelId,
             @RequestParam(required = false) String categoryId,
             @RequestParam(required = false) String orderSourceId,
-            @RequestParam(required = false) String orderSmallId
+            @RequestParam(required = false) String orderSmallId,
+            @RequestParam(required = false) Boolean queryPartsWebsit
     ) {
-        List<AdminWebsit> list = adminWebsitLogic.list(type, isAll, isIncre, status,streetCode,channelId,categoryId,orderSmallId,orderSourceId);
+        List<AdminWebsit> list = adminWebsitLogic.list(type, isAll, isIncre, status, streetCode, channelId, categoryId, orderSmallId, orderSourceId, queryPartsWebsit);
         return ResponseHelper.success(list);
     }
 
@@ -71,7 +72,7 @@ public class AdminWebsitController {
             @ApiParam(value = "工单来源") @RequestParam(required = false) String orderSource,
             @ApiParam(value = "工单类型") @RequestParam(required = false) String orderSmallId
     ) {
-        List<AdminWebsitList> list = adminWebsitLogic.websitList(type, isAll, isIncre, status,streetCode,channelId,categoryId,orderSmallId,orderSource);
+        List<AdminWebsitList> list = adminWebsitLogic.websitList(type, isAll, isIncre, status, streetCode, channelId, categoryId, orderSmallId, orderSource);
         return ResponseHelper.success(list);
     }
 
@@ -138,7 +139,7 @@ public class AdminWebsitController {
 
     @PostMapping("/import")
     @ApiOperation(value = "网点管理-导入(下载模板:网点管理导入模板.xlsx)")
-    public ResponseHelper<String> importData (
+    public ResponseHelper<String> importData(
             @RequestPart("file") MultipartFile file
     ) throws Exception {
         adminWebsitLogic.importData(file);

+ 73 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/material/manage/WebsitPartsConfigController.java

@@ -0,0 +1,73 @@
+package com.gree.mall.manager.controller.material.manage;
+
+import cn.hutool.core.lang.TypeReference;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsConfigBean;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsConfigVO;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.material.manage.WebsitPartsConfigLogic;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+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 java.util.List;
+
+@Slf4j
+@RestController
+@Api(value = "配件配置", tags ={"配件配置"} )
+@RequestMapping(value = "/parts/refund/config", produces = "application/json; charset=utf-8")
+public class WebsitPartsConfigController {
+
+    @Resource
+    WebsitPartsConfigLogic websitPartsConfigLogic;
+
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "网点价格管理-列表")
+    public ResponseHelper<IPage<WebsitPartsConfigVO>> page(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) {
+        IPage<WebsitPartsConfigVO> page = websitPartsConfigLogic.page(zfireParamBean);
+        return ResponseHelper.success(page, new TypeReference<WebsitPartsConfigVO>() {});
+    }
+
+    @PostMapping("/detail")
+    @ApiOperation("配件返还配置详情")
+    public ResponseHelper<WebsitPartsConfigBean> detail(
+            @ApiParam(value = "purchaseId", required = true) @RequestParam String id
+    ) throws Exception {
+        return ResponseHelper.success(websitPartsConfigLogic.detail(id));
+    }
+
+    @PostMapping("/add")
+    @ApiOperation("配件返还配置添加")
+    public ResponseHelper add(@RequestBody WebsitPartsConfigBean bean) throws Exception {
+
+        websitPartsConfigLogic.add(bean);
+
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/edit")
+    @ApiOperation("配件返还配置编辑")
+    public ResponseHelper edit(@RequestBody WebsitPartsConfigBean bean) throws Exception {
+
+        websitPartsConfigLogic.edit(bean);
+
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/batch/del")
+    @ApiOperation("配件返还配置批量删除")
+    public ResponseHelper batchDel(@RequestBody List<String> ids) throws Exception {
+
+        websitPartsConfigLogic.batchDel(ids);
+
+        return ResponseHelper.success();
+    }
+}

+ 5 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -107,8 +107,8 @@ public class AdminWebsitLogic {
         return parentList;
     }
 
-    public List<AdminWebsit> list(String type, Boolean isAll, Boolean isIncre, Boolean status,String streetCode, String channelId, String categoryId,
-                                  String orderSmallId, String orderSourceId) {
+    public List<AdminWebsit> list(String type, Boolean isAll, Boolean isIncre, Boolean status, String streetCode, String channelId, String categoryId,
+                                  String orderSmallId, String orderSourceId, Boolean queryPartsWebsit) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
 
@@ -132,6 +132,9 @@ public class AdminWebsitLogic {
                 .eq(status != null, AdminWebsit::getStatus, status)
                 .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()) && (isAll == null || !isAll), AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
                 .in(CollectionUtils.isNotEmpty(adminUser.getCompanyWechatIds()), AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatIds())
+                .and(Objects.nonNull(queryPartsWebsit) && queryPartsWebsit, v -> v.isNotNull(AdminWebsit::getPartsWebsitId)
+                        .or()
+                        .ne(AdminWebsit::getPartsWebsitId, ""))
                 .list();
         return list;
     }

+ 0 - 3
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/OldRefundManageInnerLogic.java

@@ -28,11 +28,8 @@ public class OldRefundManageInnerLogic {
     @Transactional(rollbackFor = Exception.class)
     public void submit(WebsitPartsOldRefundManage partsOldRefundManage) throws Exception {
         AdminUserCom adminUser = commonLogic.getAdminUser();
-//        PartsOldRefundManage partsOldRefundManage = partsOldRefundManageService.getById(applyNo);
         if (!partsOldRefundManage.getFlag().equals(PartsOrderFlagEnum.SAVE.getKey())) {
             return;
-//            throw new RemoteServiceException(partsOldRefundManage.getApplyNo() + "单据状态:"
-//                    + PartsExamineFlagEnum.valueOf(partsOldRefundManage.getFlag()).getDesc() + ",提交失败");
         }
 
         DateTime curDate = DateUtil.date();

+ 155 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsConfigLogic.java

@@ -0,0 +1,155 @@
+package com.gree.mall.manager.logic.material.manage;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsConfigBean;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsConfigVO;
+import com.gree.mall.manager.commonmapper.MaterialMapper;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.MaterialConfig;
+import com.gree.mall.manager.plus.entity.WebsitPartsRefundConfig;
+import com.gree.mall.manager.plus.service.MaterialConfigService;
+import com.gree.mall.manager.plus.service.WebsitPartsRefundConfigService;
+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 java.util.List;
+import java.util.Objects;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WebsitPartsConfigLogic {
+
+    private final CommonLogic commonLogic;
+    private final MaterialMapper materialMapper;
+    private final MaterialConfigService materialConfigService;
+    private final WebsitPartsRefundConfigService websitPartsRefundConfigService;
+
+    public IPage<WebsitPartsConfigVO> page(ZfireParamBean zfireParamBean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        FieldUtils.materialParam(zfireParamBean, WebsitPartsConfigVO.class, adminUser);
+        final IPage<WebsitPartsConfigVO> page = materialMapper.websitPartsConfigPage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
+        if (CollectionUtil.isEmpty(page.getRecords()) && adminUser.getType() == 0) {
+            final WebsitPartsRefundConfig refundConfig = websitPartsRefundConfigService.lambdaQuery()
+                    .eq(WebsitPartsRefundConfig::getCompanyWechatId, adminUser.getCompanyWechatId())
+                    .eq(WebsitPartsRefundConfig::getIsDefault, true)
+                    .one();
+            final MaterialConfig materialConfig = materialConfigService.lambdaQuery()
+                    .eq(MaterialConfig::getCompanyWechatId, adminUser.getCompanyWechatId())
+                    .one();
+
+            WebsitPartsConfigVO vo = new WebsitPartsConfigVO();
+            vo.setCompanyWechatId(adminUser.getCompanyWechatId());
+            vo.setCompanyWechatName(adminUser.getCompanyName());
+            vo.setOldRefund(refundConfig.getOldRefund());
+            vo.setNewRefundInner(refundConfig.getNewRefundInner());
+            vo.setNewRefundOutside(refundConfig.getNewRefundOutside());
+            vo.setPriceRate1(materialConfig.getPriceRate1());
+            vo.setPriceRate2(materialConfig.getPriceRate2());
+            vo.setPriceRate3(materialConfig.getPriceRate3());
+            page.getRecords().add(vo);
+        }
+        return page;
+    }
+
+    public WebsitPartsConfigBean detail(String id) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        MaterialConfig centerConfig = materialConfigService.lambdaQuery()
+                .eq(MaterialConfig::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .last("limit 1")
+                .one();
+
+        final WebsitPartsRefundConfig config = websitPartsRefundConfigService.getById(id);
+
+        WebsitPartsConfigBean bean = new WebsitPartsConfigBean();
+        BeanUtils.copyProperties(config, bean);
+        bean.setPriceRate1(centerConfig.getPriceRate1());
+        bean.setPriceRate2(centerConfig.getPriceRate2());
+        bean.setPriceRate3(centerConfig.getPriceRate3());
+
+        return bean;
+    }
+
+    public void add(WebsitPartsConfigBean bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        if (Objects.isNull(bean.getNewRefundInner()) || bean.getNewRefundInner().compareTo(0) <= 0) {
+            throw new RemoteServiceException("新件返还(市区)不能为空或少于等于0");
+        }
+        if (Objects.isNull(bean.getNewRefundOutside()) || bean.getNewRefundOutside().compareTo(0) <= 0) {
+            throw new RemoteServiceException("新件返还(外区)不能为空或少于等于0");
+        }
+        if (Objects.isNull(bean.getOldRefund()) || bean.getOldRefund().compareTo(0) <= 0) {
+            throw new RemoteServiceException("旧件返还不能为空或少于等于0");
+        }
+        final Integer defaultCount = websitPartsRefundConfigService.lambdaQuery()
+                .eq(WebsitPartsRefundConfig::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .isNull(WebsitPartsRefundConfig::getWebsitId)
+                .count();
+        if (defaultCount <= 0) {
+            throw new RemoteServiceException("缺少默认配置");
+        }
+        if (StringUtils.isNotBlank(bean.getWebsitId())) {
+            final Integer existCount = websitPartsRefundConfigService.lambdaQuery()
+                    .eq(WebsitPartsRefundConfig::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                    .eq(WebsitPartsRefundConfig::getWebsitId, bean.getWebsitId())
+                    .count();
+            if (existCount > 0) {
+                throw new RemoteServiceException(bean.getWebsitName() + "已存在配置");
+            }
+        }
+        WebsitPartsRefundConfig config = new WebsitPartsRefundConfig();
+        config.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName())
+                .setNewRefundInner(bean.getNewRefundInner())
+                .setNewRefundOutside(bean.getNewRefundOutside())
+                .setOldRefund(bean.getOldRefund())
+                .insert();
+    }
+
+    public void edit(WebsitPartsConfigBean bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        WebsitPartsRefundConfig oldRefundConfig = websitPartsRefundConfigService.getById(bean.getId());
+        if (oldRefundConfig.getIsDefault() && adminUser.getType() == 0) {
+            throw new RemoteServiceException("非商户账号不能修改默认记录");
+        }
+        oldRefundConfig.setOldRefund(bean.getOldRefund())
+                .setNewRefundInner(bean.getNewRefundInner())
+                .setNewRefundOutside(bean.getNewRefundOutside())
+                .updateById();
+    }
+
+    public void batchDel(List<String> ids) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        final Integer count = websitPartsRefundConfigService.lambdaQuery()
+                .in(WebsitPartsRefundConfig::getId, ids)
+                .eq(WebsitPartsRefundConfig::getCompanyWechatId, adminUser.getCompanyWechatId())
+                .eq(WebsitPartsRefundConfig::getIsDefault, true)
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("默认记录不能删除");
+        }
+        websitPartsRefundConfigService.lambdaUpdate()
+                .in(WebsitPartsRefundConfig::getId, ids)
+                .eq(WebsitPartsRefundConfig::getCompanyWechatId, adminUser.getCompanyWechatId())
+                .eq(WebsitPartsRefundConfig::getIsDefault, false)
+                .remove();
+    }
+}

+ 19 - 0
mall-server-api/src/main/resources/mapper/MaterialMapper.xml

@@ -556,4 +556,23 @@
         </if>
         ${ex.orderBy}
     </select>
+
+    <select id="websitPartsConfigPage"
+            resultType="com.gree.mall.manager.bean.material.manage.WebsitPartsConfigVO">
+        SELECT
+            ${ex.selected}
+        FROM
+            websit_parts_refund_config a LEFT JOIN material_config b ON a.company_wechat_id = b.company_wechat_id
+        ${ex.query}
+        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
+            AND a.websit_id IN
+            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 </mapper>