24282 7 сар өмнө
parent
commit
ae8f5108d2

+ 19 - 23
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/jd/JdRefundQualityCheckController.java

@@ -1,11 +1,14 @@
 package com.fjhx.victoriatourist.controller.jd;
 package com.fjhx.victoriatourist.controller.jd;
 
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
 import com.fjhx.victoriatourist.service.jd.JdRefundQualityCheckService;
 import com.fjhx.victoriatourist.service.jd.JdRefundQualityCheckService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -33,29 +36,22 @@ public class JdRefundQualityCheckController {
         return jdRefundQualityCheckService.getPage(dto);
         return jdRefundQualityCheckService.getPage(dto);
     }
     }
 
 
-    ///**
-    // * 添加京东售后退货质检
-    // */
-    //@PostMapping("/add")
-    //public void add(@RequestBody JdRefundQualityCheckDto dto) {
-    //    jdRefundQualityCheckService.add(dto);
-    //}
-    //
-    ///**
-    // * 删除京东售后退货质检
-    // */
-    //@PostMapping("/delete")
-    //public void delete(@RequestBody JdRefundQualityCheckDto dto) {
-    //    jdRefundQualityCheckService.delete(dto);
-    //}
-    //
-    ///**
-    // * 京东售后退货质检
-    // */
-    //@PostMapping("/edit")
-    //public void edit(@RequestBody JdRefundQualityCheckDto dto) {
-    //    jdRefundQualityCheckService.edit(dto);
-    //}
+    /**
+     * 处理
+     */
+    @PostMapping("/handle")
+    public void handle(@RequestBody JdRefundQualityCheckDto dto) {
+        jdRefundQualityCheckService.handle(dto);
+    }
+
+    /**
+     * 处理
+     */
+    @PostMapping("/verify")
+    public void verify(@RequestBody JdRefundQualityCheckDto dto) {
+        jdRefundQualityCheckService.verify(dto);
+    }
+
 
 
 
 
 }
 }

+ 4 - 2
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/dto/JdRefundQualityCheckSelectDto.java

@@ -4,6 +4,8 @@ import com.ruoyi.common.core.domain.BaseSelectDto;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 
 
+import java.util.List;
+
 /**
 /**
  * 京东售后退货质检列表查询入参实体
  * 京东售后退货质检列表查询入参实体
  *
  *
@@ -15,8 +17,8 @@ import lombok.Setter;
 public class JdRefundQualityCheckSelectDto extends BaseSelectDto {
 public class JdRefundQualityCheckSelectDto extends BaseSelectDto {
 
 
     /**
     /**
-     * 状态 0待质检 1已质检
+     * 报废处理结果 0无需处理 1待处理 2待确认 3已确认
      */
      */
-    private Integer status;
+    private List<Integer> status;
 
 
 }
 }

+ 42 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/po/JdRefundQualityCheck.java

@@ -5,6 +5,8 @@ import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 
 
+import java.util.Date;
+
 /**
 /**
  * <p>
  * <p>
  * 京东售后退货质检
  * 京东售后退货质检
@@ -43,4 +45,44 @@ public class JdRefundQualityCheck extends BasePo {
      */
      */
     private Integer scrappedCount;
     private Integer scrappedCount;
 
 
+    /**
+     * 报废转良品数量
+     */
+    private Integer scrappedToQualifiedCount;
+
+    /**
+     * 报废转次品数量
+     */
+    private Integer scrappedToDefectiveCount;
+
+    /**
+     * 最终报废数量
+     */
+    private Integer resultScrappedCount;
+
+    /**
+     * 报废处理结果 0无需处理 1待处理 2待确认 3已确认
+     */
+    private Integer scrappedHandleStatus;
+
+    /**
+     * 报废处理人
+     */
+    private Long scrappedHandleUserId;
+
+    /**
+     * 报废处理时间
+     */
+    private Date scrappedHandleTime;
+
+    /**
+     * 报废确认人
+     */
+    private Long scrappedVerifyUserId;
+
+    /**
+     * 报废确认时间
+     */
+    private Date scrappedVerifyTime;
+
 }
 }

+ 2 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/vo/JdRefundQualityCheckVo.java

@@ -20,4 +20,6 @@ public class JdRefundQualityCheckVo extends JdRefundQualityCheck {
     private String userName;
     private String userName;
     private String outNo;
     private String outNo;
     private String partCode;
     private String partCode;
+    private String handleUserName;
+    private String verifyUserName;
 }
 }

+ 5 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/JdRefundQualityCheckService.java

@@ -1,6 +1,7 @@
 package com.fjhx.victoriatourist.service.jd;
 package com.fjhx.victoriatourist.service.jd;
 
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.po.JdRefundQualityCheck;
 import com.fjhx.victoriatourist.entity.jd.po.JdRefundQualityCheck;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
@@ -22,4 +23,8 @@ public interface JdRefundQualityCheckService extends BaseService<JdRefundQuality
      */
      */
     Page<JdRefundQualityCheckVo> getPage(JdRefundQualityCheckSelectDto dto);
     Page<JdRefundQualityCheckVo> getPage(JdRefundQualityCheckSelectDto dto);
 
 
+    void handle(JdRefundQualityCheckDto dto);
+
+    void verify(JdRefundQualityCheckDto dto);
+
 }
 }

+ 21 - 18
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/impl/JdRefundNotQualityCheckServiceImpl.java

@@ -89,22 +89,23 @@ public class JdRefundNotQualityCheckServiceImpl extends ServiceImpl<JdRefundNotQ
         Collection<JdRefundQualityCheck> jdRefundQualityChecks = qualityCheckMap.values();
         Collection<JdRefundQualityCheck> jdRefundQualityChecks = qualityCheckMap.values();
         for (JdRefundQualityCheck jdRefundQualityCheck : jdRefundQualityChecks) {
         for (JdRefundQualityCheck jdRefundQualityCheck : jdRefundQualityChecks) {
 
 
-            jdRefundQualityCheck.setCode(code);
-
             // 产品id
             // 产品id
             Long productId = jdRefundQualityCheck.getProductId();
             Long productId = jdRefundQualityCheck.getProductId();
+            Integer qualifiedCount = jdRefundQualityCheck.getQualifiedCount();
+            Integer defectiveCount = jdRefundQualityCheck.getDefectiveCount();
+            Integer scrappedCount = jdRefundQualityCheck.getScrappedCount();
+
+            jdRefundQualityCheck.setCode(code);
+            jdRefundQualityCheck.setScrappedToQualifiedCount(0);
+            jdRefundQualityCheck.setScrappedToDefectiveCount(0);
+            jdRefundQualityCheck.setResultScrappedCount(0);
+            jdRefundQualityCheck.setScrappedHandleStatus(scrappedCount == 0 ? 0 : 1);
 
 
             // 待质检数量
             // 待质检数量
             JdRefundNotQualityCheck jdRefundNotQualityCheck = notQualityCheckMap.get(productId);
             JdRefundNotQualityCheck jdRefundNotQualityCheck = notQualityCheckMap.get(productId);
 
 
             int notCheckCount = jdRefundNotQualityCheck == null ? 0 : jdRefundNotQualityCheck.getQuantity();
             int notCheckCount = jdRefundNotQualityCheck == null ? 0 : jdRefundNotQualityCheck.getQuantity();
-
-            Integer qualifiedCount = jdRefundQualityCheck.getQualifiedCount();
-            Integer defectiveCount = jdRefundQualityCheck.getDefectiveCount();
-            Integer scrappedCount = jdRefundQualityCheck.getScrappedCount();
-
             int totalCheckCount = qualifiedCount + defectiveCount + scrappedCount;
             int totalCheckCount = qualifiedCount + defectiveCount + scrappedCount;
-
             if (notCheckCount < totalCheckCount) {
             if (notCheckCount < totalCheckCount) {
                 ProductInfo productInfo = productInfoService.getById(productId);
                 ProductInfo productInfo = productInfoService.getById(productId);
 
 
@@ -116,16 +117,18 @@ public class JdRefundNotQualityCheckServiceImpl extends ServiceImpl<JdRefundNotQ
             jdRefundNotQualityCheck.setQuantity(notCheckCount - totalCheckCount);
             jdRefundNotQualityCheck.setQuantity(notCheckCount - totalCheckCount);
 
 
             // 修改库存
             // 修改库存
-            stockService.update(q -> q
-                    .eq(Stock::getProductId, jdRefundQualityCheck.getProductId())
-                    .eq(Stock::getWarehouseId, WAREHOUSE_ID)
-                    // 良品入库
-                    .setSql(qualifiedCount > 0, "quantity = quantity + " + qualifiedCount)
-                    // 次品入库
-                    .setSql(defectiveCount > 0, getUpdateStockSql(3, defectiveCount))
-                    // 减少锁定库存
-                    .setSql(qualifiedCount + defectiveCount > 0, getUpdateStockSql(2, qualifiedCount + defectiveCount))
-            );
+            if (qualifiedCount + defectiveCount > 0) {
+                stockService.update(q -> q
+                        .eq(Stock::getProductId, jdRefundQualityCheck.getProductId())
+                        .eq(Stock::getWarehouseId, WAREHOUSE_ID)
+                        // 良品入库
+                        .setSql(qualifiedCount > 0, "quantity = quantity + " + qualifiedCount)
+                        // 次品入库
+                        .setSql(defectiveCount > 0, getUpdateStockSql(3, defectiveCount))
+                        // 减少锁定库存
+                        .setSql(qualifiedCount + defectiveCount > 0, getUpdateStockSql(2, qualifiedCount + defectiveCount))
+                );
+            }
 
 
         }
         }
 
 

+ 83 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/impl/JdRefundQualityCheckServiceImpl.java

@@ -2,15 +2,31 @@ package com.fjhx.victoriatourist.service.jd.impl;
 
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.common.utils.Assert;
+import com.fjhx.item.entity.product.po.ProductInfo;
+import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdRefundQualityCheckSelectDto;
 import com.fjhx.victoriatourist.entity.jd.po.JdRefundQualityCheck;
 import com.fjhx.victoriatourist.entity.jd.po.JdRefundQualityCheck;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
 import com.fjhx.victoriatourist.entity.jd.vo.JdRefundQualityCheckVo;
 import com.fjhx.victoriatourist.mapper.jd.JdRefundQualityCheckMapper;
 import com.fjhx.victoriatourist.mapper.jd.JdRefundQualityCheckMapper;
 import com.fjhx.victoriatourist.service.jd.JdRefundQualityCheckService;
 import com.fjhx.victoriatourist.service.jd.JdRefundQualityCheckService;
+import com.fjhx.wms.entity.stock.po.Stock;
+import com.fjhx.wms.service.stock.StockService;
+import com.ruoyi.common.core.domain.BaseIdPo;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
 import com.ruoyi.common.utils.wrapper.SqlField;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.Date;
+
+import static com.fjhx.victoriatourist.service.jd.impl.JdRefundServiceImpl.WAREHOUSE_ID;
+import static com.fjhx.victoriatourist.service.jd.impl.JdRefundServiceImpl.getUpdateStockSql;
+
 
 
 /**
 /**
  * <p>
  * <p>
@@ -23,6 +39,12 @@ import org.springframework.stereotype.Service;
 @Service
 @Service
 public class JdRefundQualityCheckServiceImpl extends ServiceImpl<JdRefundQualityCheckMapper, JdRefundQualityCheck> implements JdRefundQualityCheckService {
 public class JdRefundQualityCheckServiceImpl extends ServiceImpl<JdRefundQualityCheckMapper, JdRefundQualityCheck> implements JdRefundQualityCheckService {
 
 
+    @Autowired
+    private ProductInfoService productInfoService;
+
+    @Autowired
+    private StockService stockService;
+
     @Override
     @Override
     public Page<JdRefundQualityCheckVo> getPage(JdRefundQualityCheckSelectDto dto) {
     public Page<JdRefundQualityCheckVo> getPage(JdRefundQualityCheckSelectDto dto) {
         IWrapper<JdRefundQualityCheck> wrapper = getWrapper()
         IWrapper<JdRefundQualityCheck> wrapper = getWrapper()
@@ -32,9 +54,70 @@ public class JdRefundQualityCheckServiceImpl extends ServiceImpl<JdRefundQuality
                         new SqlField("pi.custom_code"),
                         new SqlField("pi.custom_code"),
                         new SqlField("su.user_name")
                         new SqlField("su.user_name")
                 )
                 )
+                .in("jrqc", JdRefundQualityCheck::getScrappedHandleStatus, dto.getStatus())
                 .orderByDesc("jrqc", JdRefundQualityCheck::getId);
                 .orderByDesc("jrqc", JdRefundQualityCheck::getId);
         Page<JdRefundQualityCheckVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         Page<JdRefundQualityCheckVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
         return page;
     }
     }
 
 
+    @Override
+    public synchronized void handle(JdRefundQualityCheckDto dto) {
+        JdRefundQualityCheck jdRefundQualityCheck = getById(dto.getId());
+        Assert.notEmpty(jdRefundQualityCheck, "数据不存在");
+        Assert.eqTrue(jdRefundQualityCheck.getScrappedHandleStatus() == 1, "该记录已处理,请勿重复操作");
+
+        dto.setScrappedToQualifiedCount(ObjectUtils.defaultIfNull(dto.getScrappedToQualifiedCount(), 0));
+        dto.setScrappedToDefectiveCount(ObjectUtils.defaultIfNull(dto.getScrappedToDefectiveCount(), 0));
+        dto.setResultScrappedCount(ObjectUtils.defaultIfNull(dto.getResultScrappedCount(), 0));
+
+        if (jdRefundQualityCheck.getScrappedCount() !=
+                dto.getScrappedToQualifiedCount() + dto.getScrappedToDefectiveCount() + dto.getResultScrappedCount()) {
+
+            Long productId = jdRefundQualityCheck.getProductId();
+            ProductInfo productInfo = productInfoService.getById(productId);
+
+            throw new ServiceException("物品【" + productInfo.getCustomCode() + "】转良品数量+转次品数量+最终报废数量 必须等于 报废数量");
+        }
+
+        update(q -> q.eq(BaseIdPo::getId, dto.getId())
+                .set(JdRefundQualityCheck::getScrappedToQualifiedCount, dto.getScrappedToQualifiedCount())
+                .set(JdRefundQualityCheck::getScrappedToDefectiveCount, dto.getScrappedToDefectiveCount())
+                .set(JdRefundQualityCheck::getResultScrappedCount, dto.getResultScrappedCount())
+                .set(JdRefundQualityCheck::getScrappedHandleStatus, 2)
+                .set(JdRefundQualityCheck::getScrappedHandleTime, new Date())
+                .set(JdRefundQualityCheck::getScrappedHandleUserId, SecurityUtils.getUserId())
+        );
+
+    }
+
+    @Override
+    public void verify(JdRefundQualityCheckDto dto) {
+        JdRefundQualityCheck jdRefundQualityCheck = getById(dto.getId());
+        Assert.notEmpty(jdRefundQualityCheck, "数据不存在");
+        Assert.eqTrue(jdRefundQualityCheck.getScrappedHandleStatus() == 2, "该记录已处理,请勿重复操作");
+
+        Integer scrappedCount = jdRefundQualityCheck.getScrappedCount();
+        Integer qualifiedCount = jdRefundQualityCheck.getScrappedToQualifiedCount();
+        Integer defectiveCount = jdRefundQualityCheck.getScrappedToDefectiveCount();
+
+        // 修改库存
+        stockService.update(q -> q
+                .eq(Stock::getProductId, jdRefundQualityCheck.getProductId())
+                .eq(Stock::getWarehouseId, WAREHOUSE_ID)
+                // 良品入库
+                .setSql(qualifiedCount > 0, "quantity = quantity + " + qualifiedCount)
+                // 次品入库
+                .setSql(defectiveCount > 0, getUpdateStockSql(3, defectiveCount))
+                // 减少锁定库存
+                .setSql(getUpdateStockSql(2, scrappedCount))
+        );
+
+        update(q -> q.eq(BaseIdPo::getId, dto.getId())
+                .set(JdRefundQualityCheck::getScrappedHandleStatus, 3)
+                .set(JdRefundQualityCheck::getScrappedVerifyTime, new Date())
+                .set(JdRefundQualityCheck::getScrappedVerifyUserId, SecurityUtils.getUserId())
+        );
+    }
+
 }
 }
+

+ 15 - 1
hx-victoriatourist/src/main/resources/mapper/jd/JdRefundQualityCheckMapper.xml

@@ -10,14 +10,28 @@
                jrqc.scrapped_count,
                jrqc.scrapped_count,
                jrqc.create_user,
                jrqc.create_user,
                jrqc.create_time,
                jrqc.create_time,
+
+               jrqc.scrapped_to_qualified_count,
+               jrqc.scrapped_to_defective_count,
+               jrqc.result_scrapped_count,
+               jrqc.scrapped_handle_status,
+               jrqc.scrapped_handle_user_id,
+               jrqc.scrapped_handle_time,
+               jrqc.scrapped_verify_user_id,
+               jrqc.scrapped_verify_time,
+
                pi.name        as product_name,
                pi.name        as product_name,
                pi.custom_code as product_custom_code,
                pi.custom_code as product_custom_code,
                pi.spec        as product_spec,
                pi.spec        as product_spec,
                pi.unit        as product_unit,
                pi.unit        as product_unit,
-               su.user_name
+               su.nick_name   as user_name,
+               su2.nick_name  as handle_user_name,
+               su3.nick_name  as verify_user_name
         from jd_refund_quality_check jrqc
         from jd_refund_quality_check jrqc
                  Left Join bytesailing_item.product_info pi ON jrqc.product_id = pi.id
                  Left Join bytesailing_item.product_info pi ON jrqc.product_id = pi.id
                  left join bytesailing_base.sys_user su ON jrqc.create_user = su.user_id
                  left join bytesailing_base.sys_user su ON jrqc.create_user = su.user_id
+                 left join bytesailing_base.sys_user su2 ON jrqc.scrapped_handle_user_id = su2.user_id
+                 left join bytesailing_base.sys_user su3 ON jrqc.scrapped_verify_user_id = su3.user_id
             ${ew.customSqlSegment}
             ${ew.customSqlSegment}
     </select>
     </select>