于继渤 2 лет назад
Родитель
Сommit
436a6f688a

+ 14 - 0
src/main/java/com/dk/mdm/controller/ivt/IntoReturnController.java

@@ -56,4 +56,18 @@ public class IntoReturnController{
         return intoReturnService.insert(intoReturnVO);
     }
 
+
+    /**
+     * @desc   : 冲正
+     * @date   : 2023/10/17 11:29
+     * @author : 于继渤
+     */
+    @ApiOperation(
+            value = "冲正",
+            notes = "冲正"
+    )
+    @PostMapping("righting")
+    public ResponseResultVO<String> righting(@RequestBody IntoReturnVO intoReturnVO) {
+        return intoReturnService.righting(intoReturnVO.getPurId(),intoReturnVO.getIntoReturnIdList());
+    }
 }

+ 1 - 1
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml

@@ -450,7 +450,7 @@
         tmgs.price_purchase AS  list_price_purchase,
         tmgs.sku_images AS  list_sku_images,
 
-        ( tpii.into_qty - tpii.return_qty)  AS list_reject_qty
+        ( tpii.into_qty + tpii.return_qty)  AS list_reject_qty
     </sql>
 
 

+ 4 - 0
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.java

@@ -22,11 +22,15 @@ public interface IntoReturnMapper extends BaseMapper<IntoReturn>{
      */
     List<IntoReturnResponse> selectByCond(IntoReturnQuery intoReturnQuery);
 
+
     /**
      * @desc   : 查询个数
      * @author : 于继渤
      * @date   : 2024/2/28 9:48
      */
     Long countByCond(IntoReturnQuery intoReturnQuery);
+
+    List<IntoReturn> selectReturnList(List<String> intoReturnIdList);
+    IntoReturn selectReturnByRighting(String returnId);
 }
 

+ 25 - 1
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.xml

@@ -327,7 +327,13 @@
             <if test="cpId != null">
                 AND tpir.cp_id = #{cpId}
             </if>
-
+            <!--退货单id集合-->
+            <if test="intoReturnIdList != null and intoReturnIdList.size() > 0">
+                AND tpir.return_id IN
+                <foreach collection="intoReturnIdList" index="index" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </sql>
 
@@ -478,4 +484,22 @@
             )
         </foreach>
     </insert>
+
+
+    <!--查询采购退货数据List -->
+    <select id="selectReturnList" resultMap="BaseResultMapResponse" >
+        SELECT
+        <include refid="Base_Column_List_Join"/>
+        FROM dkic_b.t_psi_into_return  tpir
+        where tpir.return_id = any(#{returnId,typeHandler= UuidListTypeHandler})
+    </select>
+
+
+    <!-- 查询原始数据 冲正用-->
+    <select id="selectReturnByRighting" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_psi_into_return
+        where return_id =#{returnId}::uuid
+    </select>
 </mapper>

+ 2 - 0
src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.java

@@ -40,5 +40,7 @@ public interface PurchaseMapper extends BaseMapper<Purchase>{
     PurchaseResponse  selectById(@Param("purId") String purId);
 
     int updateAmount(Purchase purchase);
+
+    Purchase selectPurchaseByRighting(PurchaseQuery purchaseQuery);
 }
 

+ 16 - 0
src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.xml

@@ -471,4 +471,20 @@
         </set>
         where  pur_id = #{purId}::uuid
     </update>
+
+
+
+    <!-- 查询原始数据 冲正用-->
+    <select id="selectPurchaseByRighting" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List_Left_join"/>
+        FROM dkic_b.t_psi_purchase tpp
+        <where>
+            <if test="orderId!=null">
+                tpp.pur_id = #{purId}::uuid
+            </if>
+
+        </where>
+    </select>
+
 </mapper>

+ 5 - 10
src/main/java/com/dk/mdm/model/query/ivt/IntoReturnQuery.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.JsonTypeHandler;
 import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidListTypeHandler;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -22,6 +23,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  *  入库退货
@@ -371,16 +373,9 @@ public class IntoReturnQuery extends PageInfo<IntoReturnQuery> implements Serial
     private String opDbUser;
 
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
-
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
-
+    @ApiModelProperty(value = "退货单id数组")
+    @TableField(typeHandler = UuidListTypeHandler.class)
+    private List<String> intoReturnIdList;
 
     private static final long serialVersionUID = 1L;
 

+ 4 - 0
src/main/java/com/dk/mdm/model/vo/ivt/IntoReturnVO.java

@@ -374,6 +374,10 @@ public class IntoReturnVO  implements Serializable {
     private List<IntoReturnItemVO> intoReturnItemVOList;
 
 
+    @ApiModelProperty(value = "退货单id数组")
+    private List<String> intoReturnIdList;
+
+
 
     private static final long serialVersionUID = 1L;
 

+ 69 - 4
src/main/java/com/dk/mdm/service/ivt/IntoReturnService.java

@@ -1,5 +1,6 @@
 package com.dk.mdm.service.ivt;
 
+import com.alibaba.fastjson.JSONObject;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
@@ -112,7 +113,7 @@ public class IntoReturnService extends BaseService<IntoReturn> {
             //返回 采购退货明细不可为空,请重新操作
             return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
         }
-        //查询采购订单上的客户信息
+        //查询采购订单
         PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnVO.getPurId());
         //设置总单
         intoReturnVO = this.insertTotal(intoReturnVO, purchaseResponse);
@@ -164,8 +165,8 @@ public class IntoReturnService extends BaseService<IntoReturn> {
         outboundVO.setOrgId(intoReturnVO.getOrgId());
         //员工
         outboundVO.setStaffId(intoReturnVO.getStaffId());
-        //出库状态
-        outboundVO.setOutStatus(Constant.OutStatus.CHUKUZHONG.getName());
+        //出库状态 待出库
+        outboundVO.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
         //供应商
         outboundVO.setSupId(intoReturnVO.getSupId());
         outboundVO.setMakeStaff(authUtils.getStaff().getStaffId());
@@ -207,7 +208,8 @@ public class IntoReturnService extends BaseService<IntoReturn> {
 
         //部门Id
         intoReturnVO.setOrgId(purchaseResponse.getOrgId());
-        intoReturnVO.setReturnStatus("退货状态-通过");
+        //退货状态 通过
+        intoReturnVO.setReturnStatus(Constant.returnStatus.OUT_REJECT_STATUS_ADOPT.getName());
         //出库状态
         intoReturnVO.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
         //制单员
@@ -267,4 +269,67 @@ public class IntoReturnService extends BaseService<IntoReturn> {
     }
 
 
+    //TODO 未完成
+    /**
+     * @desc : 冲正
+     * @date : 2022/6/28 16:58
+     * @author : 于继渤
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<String> righting(String purId, List<String> intoReturnIdList) {
+        //根据订单id查询到订单
+        Purchase purchase = purchaseMapper.selectPurchaseByRighting(new PurchaseQuery().setPurId(purId));
+
+
+        //查询采购退货数据List
+        List<IntoReturn> intoReturnList = intoReturnMapper.selectReturnList(intoReturnIdList);
+
+        //根据订单id查询所有退货单
+        List<IntoReturnResponse> intoReturnResponsesList = intoReturnMapper.selectByCond(new IntoReturnQuery().setIntoReturnIdList(intoReturnIdList));
+
+
+
+        //本次冲正退货总额
+        BigDecimal sumReturnAmount = intoReturnResponsesList.stream().map(IntoReturnResponse::getSumAmount)
+                .reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+//        for (IntoReturn intoReturn : intoReturnList) {
+//
+//
+//        }
+        //订单退货金额、退货数量
+        purchase.setReturnAmt(purchase.getReturnAmt().subtract(intoReturnList.stream()
+                .map(IntoReturn::getSumAmount).reduce(BigDecimal.ZERO, BigDecimal::add)).setScale(2, BigDecimal.ROUND_HALF_UP));
+        purchase.setReturnQty(purchase.getReturnQty().subtract(intoReturnList.stream()
+                .map(IntoReturn::getSumQuantity).reduce(BigDecimal.ZERO, BigDecimal::add)).setScale(6, BigDecimal.ROUND_HALF_UP));
+        return null;
+    }
+
+
+    //TODO 未完成
+    @Transactional(rollbackFor = {Exception.class})
+    public void rightingByIbossReturnSuccess(IntoReturn intoReturn) {
+        //修改原单总单的状态
+        intoReturnMapper.updateById(new IntoReturn().setReturnId(intoReturn.getReturnId()).
+                setReturnStatus("退货状态-冲正"));
+
+
+        //region 根据id查询原始单据信息、生成逆向生成销售退货总单数据
+        //根据id查询原始单据信息
+        IntoReturn intoReturnRig = intoReturnMapper.selectReturnByRighting(intoReturn.getReturnId());
+        Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OUTBOUND.getName(), false);
+        intoReturnRig.setReturnId(codeMap.get("outId").toString()).setReturnNo(codeMap.get("outNote").toString())
+                .setReturnType(Constant.returnType.PURRETURN.getName());
+
+        intoReturnRig.setReturnType("退货类型-冲正");
+        intoReturnRig.setReturnStatus("退货状态-冲正");
+        //退货单状态 冲正
+        intoReturnRig.setMakeTime(LocalDateTime.now());
+        //endregion
+
+
+
+
+    }
+
 }