koushanshan пре 2 година
родитељ
комит
1e136bc92b

+ 1 - 1
src/main/java/com/dk/mdm/controller/ivt/InboundSaleReturnController.java

@@ -104,6 +104,6 @@ public class InboundSaleReturnController {
     @ApiOperation(value = "获取单据信息(编辑用)", notes = "获取单据信息(编辑用)")
     @PostMapping({"select_by_update/{id}"})
     public ResponseResultVO<?> selectByUpdate(@PathVariable String id) {
-        return inboundService.selectByUpdate(id);
+        return inboundSaleReturnService.selectByUpdate(id);
     }
 }

+ 4 - 1
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.java

@@ -3,6 +3,7 @@ package com.dk.mdm.mapper.ivt;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
+import com.dk.mdm.model.query.ivt.InboundQuery;
 import com.dk.mdm.model.response.ivt.InboundItemResponse;
 import com.dk.mdm.model.response.ivt.InboundResponse;
 import org.apache.ibatis.annotations.Param;
@@ -44,6 +45,8 @@ public interface InboundItemMapper extends BaseMapper<InboundItem>{
      * @date : 2024/2/26 10:36
      */
     int  updateAmount(InboundItem inboundItem);
-	
+
+
+
 }
 

+ 2 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -264,4 +264,6 @@
         </set>
         where item_id = #{itemId}::uuid
     </update>
+
+
 </mapper>

+ 9 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.java

@@ -62,5 +62,14 @@ public interface InboundMapper extends BaseMapper<Inbound>{
      * @date   : 2024/3/8 10:58
      */
     Long countByCond(InboundQuery inboundQuery);
+
+
+    /**
+     * @desc   : 根据传入的信息查询数据(销售退货入库办理用)
+     * @date   : 2024/3/16 16:28
+     * @author : 寇珊珊
+     */
+    InboundResponse selectMessageByOtherQuery(InboundQuery inboundQuery);
+
 }
 

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

@@ -93,6 +93,20 @@
         <result column="cp_id" property="cpId"/>
         <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
         <result column="into_reason_name" property="intoReasonName" />
+        <result column="org_name" property="orgName" />
+        <result column="staff_name" property="staffName" />
+        <result column="cus_code" property="cusCode" />
+        <result column="cus_name" property="cusName" />
+        <result column="cus_phone" property="cusPhone" />
+        <result column="contact_phone" property="contactPhone" />
+        <result column="contact_name" property="contactName" />
+        <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
+        <result column="address_name" property="addressName"/>
+        <result column="address_no" property="addressNo"/>
+        <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
+        <result column="address_full" property="addressFull"/>>
+        <result column="channel_name" property="channelName" />
+        <result column="cus_from_name" property="cusFromName" />
     </resultMap>
 
 
@@ -170,7 +184,6 @@
         <result column="usable_qty" property="usable_qty"/>
         <result column="inv_qty" property="invQty"/>
         <result column="outing_qty" property="outingQty"/>
-
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -496,5 +509,39 @@
     </update>
 
 
+    <!-- 根据id查询带出销售退货单数据(销售退货入库办理用)-->
+    <select id="selectMessageByOtherQuery" resultMap="BaseResultMapResponse">
+        SELECT
+        <include refid="Base_Column_List_Response"/>
+        ,tmo.org_name
+        ,tms.staff_name
+        ,tmc.cus_code
+        ,tmc.cus_name
+        ,tmc.cus_phone
+        ,tmc.address_area
+        ,tmc.address_name
+        ,tmc.address_no
+        ,tmc.address_gcj02
+        ,tmc.address_full
+        ,tmsc.channel_name
+        ,tmsc.channel_name
+        ,tmsc.channel_name
+        ,tmd.data_value  as cus_from_name
+        FROM dkic_b.t_psi_inbound tpi
+        Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
+        Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
+        left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
+        left join dkic_b.t_mst_sale_channel tmsc on tmc.channel_id = tmsc.channel_id
+        left join dkic_b.t_mst_dictionary_data tmd on tmc.cus_from = tmd.data_id
+        <where>
+            <if test="intoId != null and intoId != ''">
+                AND tpi.into_id = #{intoId}::uuid
+            </if>
+            <if test="intoStatus != null and intoStatus != ''">
+                AND tpi.into_status = #{intoStatus}
+            </if>
+        </where>
+    </select>
+
 
 </mapper>

+ 73 - 0
src/main/java/com/dk/mdm/mapper/sale/OutReturnItemMapper.xml

@@ -320,4 +320,77 @@
           and t.return_id = #{id}::uuid
         order by t.item_index
     </select>
+
+    <!-- 根据id修改-->
+    <update id="updateById" parameterType="com.dk.mdm.model.pojo.sale.OutReturnItem">
+        update dkic_b.t_psi_into_return_item
+        <set>
+            <if test=" et!=null and et.returnId != null">
+                return_id = #{et.returnId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.intoId != null">
+                into_id = #{et.intoId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.intoItemId != null">
+                into_item_id = #{et.intoItemId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.purId != null">
+                pur_id = #{et.purId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.purItemId != null">
+                pur_item_id = #{et.purItemId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.itemIndex != null">
+                item_index = #{et.itemIndex,jdbcType=INTEGER},
+            </if>
+            <if test=" et!=null and et.skuId != null">
+                sku_id = #{et.skuId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.itemQty != null">
+                item_qty = #{et.itemQty,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.priceStd != null">
+                price_std = #{et.priceStd,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.amtStd != null">
+                amt_std = #{et.amtStd,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.priceReturn != null">
+                price_return = #{et.priceReturn,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.itemAmt != null">
+                item_amt = #{et.itemAmt,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.nonStdCode != null">
+                non_std_code = #{et.nonStdCode,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.intoStatus != null">
+                into_status = #{et.intoStatus,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.intoingQty != null">
+                intoing_qty = intoing_qty + #{et.intoingQty,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoingAmt != null">
+                intoing_amt = intoing_amt + #{et.intoingAmt,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoQty != null">
+                into_qty = into_qty + #{et.intoQty,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoAmt != null">
+                into_amt = into_amt + #{et.intoAmt,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.remarks != null">
+                remarks = #{et.remarks,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.flgValid != null">
+                flg_valid = #{et.flgValid,jdbcType=BOOLEAN},
+            </if>
+            <if test=" et!=null and et.cpId != null">
+                cp_id = #{et.cpId,jdbcType=INTEGER},
+            </if>
+        </set>
+        where item_id = #{et.itemId,typeHandler=UuidTypeHandler}
+        and  sum_quantity >= (into_qty + intoing_qty)
+    </update>
+
 </mapper>

+ 4 - 0
src/main/java/com/dk/mdm/mapper/sale/OutReturnMapper.java

@@ -3,7 +3,9 @@ package com.dk.mdm.mapper.sale;
 import com.dk.mdm.model.pojo.sale.OutReturn;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.sale.OutReturnQuery;
+import com.dk.mdm.model.response.ivt.IntoReturnResponse;
 import com.dk.mdm.model.response.sale.OutReturnResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -33,5 +35,7 @@ public interface OutReturnMapper extends BaseMapper<OutReturn>{
      * @date   : 2024-03-03 9:25
      */
     OutReturnResponse selectById(String id);
+
+
 }
 

+ 114 - 0
src/main/java/com/dk/mdm/mapper/sale/OutReturnMapper.xml

@@ -475,4 +475,118 @@
             )
         </foreach>
     </insert>
+
+    <!-- 根据id修改-->
+    <update id="updateById" parameterType="com.dk.mdm.model.pojo.sale.OutReturn">
+        update dkic_b.t_psi_out_return
+        <set>
+            <if test=" et!=null and et.returnNo != null">
+                return_no = #{et.returnNo,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.returnType != null">
+                return_type = #{et.returnType,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.orderId != null">
+                order_id = #{et.orderId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.orderNo != null">
+                order_no = #{et.orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.orgId != null">
+                org_id = #{et.orgId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.staffId != null">
+                staff_id = #{et.staffId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.cusId != null">
+                cus_id = #{et.cusId,typeHandler=UuidTypeHandler},
+            </if>
+            <if test=" et!=null and et.addressArea != null">
+                address_area = #{et.addressArea,typeHandler=JsonTypeHandler},
+            </if>
+            <if test=" et!=null and et.addressName != null">
+                address_name = #{et.addressName,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.addressNo != null">
+                address_no = #{et.addressNo,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.addressGcj02 != null">
+                address_gcj02 = #{et.addressGcj02,typeHandler=JsonTypeHandler},
+            </if>
+            <if test=" et!=null and et.addressFull != null">
+                address_full = #{et.addressFull,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.contactName != null">
+                contact_name = #{et.contactName,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.contactPhone != null">
+                contact_phone = #{et.contactPhone,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.salesChannel != null">
+                sales_channel = #{et.salesChannel,jdbcType=OTHER},
+            </if>
+            <if test=" et!=null and et.pickupDate != null">
+                pickup_date = #{et.pickupDate,jdbcType=DATE},
+            </if>
+            <if test=" et!=null and et.sumQuantity != null">
+                sum_quantity = #{et.sumQuantity,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.sumStandard != null">
+                sum_standard = #{et.sumStandard,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.sumAmount != null">
+                sum_amount = #{et.sumAmount,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.saleDiscount != null">
+                sale_discount = #{et.saleDiscount,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.returnStatus != null">
+                return_status = #{et.returnStatus,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.intoStatus != null">
+                into_status = #{et.intoStatus,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.intoingQty != null">
+                intoing_qty = intoing_qty + #{et.intoingQty,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoingAmt != null">
+                intoing_amt = intoing_amt + #{et.intoingAmt,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoQty != null">
+                into_qty =into_qty + #{et.intoQty,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.intoAmt != null">
+                into_amt =into_amt + #{et.intoAmt,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.amtReceivable != null">
+                amt_receivable = #{et.amtReceivable,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.amtHandle != null">
+                amt_handle = #{et.amtHandle,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.amtResidue != null">
+                amt_residue = #{et.amtResidue,jdbcType=NUMERIC},
+            </if>
+            <if test=" et!=null and et.remarks != null">
+                remarks = #{et.remarks,jdbcType=VARCHAR},
+            </if>
+            <if test=" et!=null and et.annexPaths != null">
+                annex_paths = #{et.annexPaths,typeHandler=JsonTypeHandler},
+            </if>
+            <if test=" et!=null and et.makeStaff != null">
+                make_staff = #{et.makeStaff,jdbcType=OTHER},
+            </if>
+            <if test=" et!=null and et.makeTime != null">
+                make_time = #{et.makeTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test=" et!=null and et.flgValid != null">
+                flg_valid = #{et.flgValid,jdbcType=BOOLEAN},
+            </if>
+            <if test=" et!=null and et.cpId != null">
+                cp_id = #{et.cpId,jdbcType=INTEGER},
+            </if>
+        </set>
+        where return_id = #{et.returnId,typeHandler=UuidTypeHandler}
+        and  sum_quantity >= (into_qty + intoing_qty)
+    </update>
 </mapper>

+ 3 - 3
src/main/java/com/dk/mdm/model/pojo/sale/OutReturn.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.*;
 import com.dk.common.model.pojo.PageInfo;
+import com.dk.common.model.vo.AnnexVO;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.AllArgsConstructor;
@@ -300,10 +301,9 @@ public class OutReturn extends PageInfo<OutReturn> implements Serializable {
     /**
      * 附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)
      */
-    @Excel(name = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
-    @ApiModelProperty(value = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
+    @ApiModelProperty(value = "附件")
     @TableField(typeHandler = JsonTypeHandler.class)
-    private JSONObject annexPaths;
+    private List<AnnexVO> annexPaths;
 
 
     /**

+ 52 - 0
src/main/java/com/dk/mdm/model/response/ivt/InboundResponse.java

@@ -354,6 +354,58 @@ public class InboundResponse extends PageInfo<InboundResponse> implements Serial
     @ApiModelProperty(value = "入库原因")
     private String intoReasonName;
 
+    @Excel(name = "客户编号")
+    @ApiModelProperty(value = "客户编号")
+    private String cusCode;
+
+    @Excel(name = "客户名称")
+    @ApiModelProperty(value = "客户名称")
+    private String cusName;
+
+    @Excel(name = "客户电话")
+    @ApiModelProperty(value = "客户电话")
+    private String cusPhone;
+
+    @Excel(name = "行政区划 (a1:省 a2:市 a3:区)")
+    @ApiModelProperty(value = "行政区划 (a1:省 a2:市 a3:区)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressArea;
+
+    @Excel(name = "小区或POI")
+    @ApiModelProperty(value = "小区或POI")
+    private String addressName;
+
+    @Excel(name = "门牌号")
+    @ApiModelProperty(value = "门牌号")
+    private String addressNo;
+
+    @Excel(name = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    @ApiModelProperty(value = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressGcj02;
+
+    @Excel(name = "详细地址")
+    @ApiModelProperty(value = "详细地址")
+    private String addressFull;
+
+    @Excel(name = "联系人")
+    @ApiModelProperty(value = "联系人")
+    private String contactName;
+
+    @Excel(name = "联系电话")
+    @ApiModelProperty(value = "联系电话")
+    private String contactPhone;
+
+    @Excel(name = "销售渠道")
+    @ApiModelProperty(value = "销售渠道")
+    private String channelName;
+
+
+    @Excel(name = "客户来源")
+    @ApiModelProperty(value = "客户来源")
+    private String cusFromName;
+
+
     private static final long serialVersionUID = 1L;
 
 }

+ 5 - 3
src/main/java/com/dk/mdm/model/response/sale/OutReturnResponse.java

@@ -9,6 +9,7 @@ import com.dk.common.infrastructure.handler.JsonTypeHandler;
 import com.dk.common.infrastructure.handler.TimestampTypeHandler;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.dk.common.model.pojo.PageInfo;
+import com.dk.common.model.vo.AnnexVO;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -22,6 +23,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  *  出库退货
@@ -301,10 +303,10 @@ public class OutReturnResponse extends PageInfo<OutReturnResponse> implements Se
     /**
      * 附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)
      */
-    @Excel(name = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
-    @ApiModelProperty(value = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
+    @Excel(name = "附件信息")
+    @ApiModelProperty(value = "附件信息")
     @TableField(typeHandler = JsonTypeHandler.class)
-    private JSONObject annexPaths;
+    private List<AnnexVO> AnnexPaths;
 
 
     /**

+ 3 - 3
src/main/java/com/dk/mdm/model/vo/sale/OutReturnVO.java

@@ -9,6 +9,7 @@ import com.dk.common.infrastructure.handler.JsonTypeHandler;
 import com.dk.common.infrastructure.handler.TimestampTypeHandler;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.dk.common.model.pojo.PageInfo;
+import com.dk.common.model.vo.AnnexVO;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -301,10 +302,9 @@ public class OutReturnVO extends PageInfo<OutReturnVO> implements Serializable {
     /**
      * 附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)
      */
-    @Excel(name = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
-    @ApiModelProperty(value = "附件 (index(显示顺序)、name(文件名)、path(路径)、type(类型)、time(上传时间)...)")
+    @ApiModelProperty(value = "附件")
     @TableField(typeHandler = JsonTypeHandler.class)
-    private JSONObject annexPaths;
+    private List<AnnexVO> annexPaths;
 
 
     /**

+ 267 - 130
src/main/java/com/dk/mdm/service/ivt/InboundSaleReturnService.java

@@ -13,32 +13,20 @@ import com.dk.common.response.ResponseResultVO;
 import com.dk.common.service.BaseService;
 import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
 import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
-import com.dk.mdm.infrastructure.convert.ivt.IntoReturnConvert;
-import com.dk.mdm.infrastructure.convert.ivt.IntoReturnItemConvert;
 import com.dk.mdm.mapper.ivt.InboundItemMapper;
 import com.dk.mdm.mapper.ivt.InboundMapper;
-import com.dk.mdm.mapper.ivt.IntoReturnItemMapper;
-import com.dk.mdm.mapper.ivt.IntoReturnMapper;
-import com.dk.mdm.mapper.pur.PurchaseItemMapper;
-import com.dk.mdm.mapper.pur.PurchaseMapper;
+import com.dk.mdm.mapper.sale.OutReturnItemMapper;
+import com.dk.mdm.mapper.sale.OutReturnMapper;
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
-import com.dk.mdm.model.pojo.ivt.IntoReturn;
-import com.dk.mdm.model.pojo.ivt.IntoReturnItem;
-import com.dk.mdm.model.pojo.pur.Purchase;
-import com.dk.mdm.model.pojo.pur.PurchaseItem;
+import com.dk.mdm.model.pojo.sale.OutReturn;
+import com.dk.mdm.model.pojo.sale.OutReturnItem;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
 import com.dk.mdm.model.query.ivt.InboundQuery;
-import com.dk.mdm.model.query.pur.PurchaseItemQuery;
 import com.dk.mdm.model.response.ivt.InboundItemResponse;
 import com.dk.mdm.model.response.ivt.InboundResponse;
-import com.dk.mdm.model.response.ivt.IntoReturnItemResponse;
-import com.dk.mdm.model.response.ivt.IntoReturnResponse;
-import com.dk.mdm.model.response.pur.PurchaseItemResponse;
-import com.dk.mdm.model.response.pur.PurchaseResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
-import com.dk.mdm.model.vo.pur.PurchaseVO;
 import com.dk.mdm.service.common.CommonService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -77,10 +65,10 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
     private InboundItemConvert inboundItemConvert;
 
     @Autowired
-    private IntoReturnMapper intoReturnMapper;
+    private OutReturnMapper outReturnMapper;
 
     @Autowired
-    private IntoReturnItemMapper intoReturnItemMapper;
+    private OutReturnItemMapper outReturnItemMapper;
 
     @Autowired
     private CommonService commonService;
@@ -98,8 +86,8 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 查询明细
-     * @date   : 2024/3/15 16:43
+     * @desc : 查询明细
+     * @date : 2024/3/15 16:43
      * @author : 寇珊珊
      */
     @Pagination
@@ -115,7 +103,6 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
     }
 
 
-
     /**
      * @desc : 销售退货入库新建
      * @date : 2024/3/7 14:13
@@ -149,7 +136,7 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
                     .setIntoingQty(BigDecimal.ZERO)
                     .setIntoingAmt(BigDecimal.ZERO)
             ;
-        }else{
+        } else {
             inboundVO.setIntoQty(BigDecimal.ZERO)
                     .setIntoAmt(BigDecimal.ZERO)
             ;
@@ -162,22 +149,22 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
         //region 销售退货
         if (inboundVO.getFromId() != null) {
-            IntoReturn intoReturn = new IntoReturn();
+            OutReturn outReturn = new OutReturn();
 //            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            intoReturn.setReturnId(inboundVO.getFromId());
 //            intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(inboundVO.getIntoingQty()));
 //            intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(inboundVO.getIntoingAmt()));
 //            intoReturn.setOutQty(intoReturnResponse.getOutQty().add(inboundVO.getIntoAmt()));
 //            intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(inboundVO.getIntoQty()));
-            intoReturn.setOutingQty(inboundVO.getIntoingQty().negate());
-            intoReturn.setOutingAmt(inboundVO.getIntoingAmt().negate());
-            intoReturn.setOutQty(inboundVO.getIntoAmt());
-            intoReturn.setOutAmt(inboundVO.getIntoQty());
-            //出库状态
-            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
-            intoReturn.setOutStatus(outStatus);
+            outReturn.setReturnId(inboundVO.getFromId());
+            outReturn.setIntoingQty(inboundVO.getIntoingQty().negate());
+            outReturn.setIntoingAmt(inboundVO.getIntoingAmt().negate());
+            outReturn.setIntoQty(inboundVO.getIntoAmt());
+            outReturn.setIntoAmt(inboundVO.getIntoQty());
+            //入库状态
+            String intoStatus = this.setIntoStatus(outReturn.getIntoingQty(), outReturn.getIntoQty());
+            outReturn.setIntoStatus(intoStatus);
             //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
+            int countRow = outReturnMapper.updateById(outReturn);
             //数量超出
             if (countRow == 0) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
@@ -203,8 +190,8 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
                         .setIntoAmt(inboundItemVO.getIntoingAmt())
                         .setIntoingQty(BigDecimal.ZERO)
                         .setIntoingAmt(BigDecimal.ZERO)
-                       ;
-            }else{
+                ;
+            } else {
                 inboundItemVO
                         .setIntoQty(BigDecimal.ZERO)
                         .setIntoAmt(BigDecimal.ZERO);
@@ -228,22 +215,43 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
             //region 销售退货明细
             if (inboundItemVO.getFromItemId() != null) {
-//                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
-//                intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
+                //region todo 可能无用代码
+                //                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
+//           intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
 //                intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
 //                intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
 //                intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
-                intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
-                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
-                intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
-                intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
-                intoReturnItem.setOutStatus(outStatus);
+                //endregion
+
+                //region  todo 出库可能用到 用不到记得删掉
+//                IntoReturnItem intoReturnItem = new IntoReturnItem();
+//                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+//                intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
+//                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
+//                intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
+//                intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
+//                //出库状态
+//                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+//                intoReturnItem.setOutStatus(outStatus);
+//                //修改
+//                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+//                //数量超出
+//                if (countRow == 0) {
+//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//                }
+                //endregion
+
+                OutReturnItem outReturnItem = new OutReturnItem();
+                outReturnItem.setItemId(inboundItemVO.getFromItemId());
+                outReturnItem.setIntoQty(inboundItemVO.getIntoQty());
+                outReturnItem.setIntoAmt(inboundItemVO.getIntoAmt());
+                outReturnItem.setIntoingQty(inboundItemVO.getIntoingQty());
+                outReturnItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
+                //入库状态
+                String intoStatus = this.setIntoStatus(outReturnItem.getIntoingQty(), outReturnItem.getIntoQty());
+                outReturnItem.setIntoStatus(intoStatus);
                 //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+                int countRow = outReturnItemMapper.updateById(outReturnItem);
                 //数量超出
                 if (countRow == 0) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
@@ -318,22 +326,43 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
             //region  销售退货明细
             if (inboundItemVO.getFromItemId() != null) {
+                //endregion todo  可能无用的代码
 //                    IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
 //                    intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
 //                    intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
 //                    intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
 //                    intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
-                intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
-                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
-                intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
-                intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
-                intoReturnItem.setOutStatus(outStatus);
+                //endregion
+
+                //region todo 出库可能用到的代码  用不到记得删掉
+//                IntoReturnItem intoReturnItem = new IntoReturnItem();
+//                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+//
+//                intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
+//                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
+//                intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
+//                intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
+//                //出库状态
+//                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+//                intoReturnItem.setOutStatus(outStatus);
+//                //修改
+//                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+//                //数量超出
+//                if (countRow == 0) {
+//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//                }
+                //endregion
+                OutReturnItem outReturnItem = new OutReturnItem();
+                outReturnItem.setItemId(inboundItemVO.getFromItemId());
+                outReturnItem.setIntoQty(inboundItemVO.getIntoQty());
+                outReturnItem.setIntoAmt(inboundItemVO.getIntoAmt());
+                outReturnItem.setIntoingQty(inboundItemVO.getIntoingQty());
+                outReturnItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
+                //入库状态
+                String intoStatus = this.setIntoStatus(outReturnItem.getIntoingQty(), outReturnItem.getIntoQty());
+                outReturnItem.setIntoStatus(intoStatus);
                 //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+                int countRow = outReturnItemMapper.updateById(outReturnItem);
                 //数量超出
                 if (countRow == 0) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
@@ -344,15 +373,15 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
         //endregion
 
         //region 删除明细
-        BigDecimal sumDelOutQty = BigDecimal.ZERO;
-        BigDecimal sumDelOutAmt = BigDecimal.ZERO;
-        BigDecimal sumDelOutingQty = BigDecimal.ZERO;
-        BigDecimal sumDelOutingAmt = BigDecimal.ZERO;
+        BigDecimal sumDelIntoQty = BigDecimal.ZERO;
+        BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
+        BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
+        BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
         if (inboundVO.getDeleteItemList() != null) {
-            sumDelOutQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-            sumDelOutAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-            sumDelOutingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-            sumDelOutingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
             for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
                 if (inboundItemVO.getItemId() != null) {
                     InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
@@ -365,23 +394,44 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
                 }
                 //region  销售退货明细
                 if (inboundItemVO.getFromItemId() != null) {
-                    //region 销售退货订单明细
+                    //region todo  可能无用的代码
 //                        IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                    IntoReturnItem intoReturnItem = new IntoReturnItem();
-                    intoReturnItem.setItemId(inboundItemVO.getFromItemId());
 //                        intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemVO.getIntoQty()));
 //                        intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemVO.getIntoAmt()));
 //                        intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().subtract(inboundItemVO.getIntoingQty()));
 //                        intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().subtract(inboundItemVO.getIntoingAmt()));
-                    intoReturnItem.setOutQty(inboundItemVO.getIntoQty().negate());
-                    intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().negate());
-                    intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty().negate());
-                    intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt().negate());
-                    //出库状态
-                    String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
-                    intoReturnItem.setOutStatus(outStatus);
+                    //endregion
+
+                    //region todo  出库可能用到的代码  用过后记得删除
+//                    IntoReturnItem intoReturnItem = new IntoReturnItem();
+//                    intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+//                    intoReturnItem.setOutQty(inboundItemVO.getIntoQty().negate());
+//                    intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().negate());
+//                    intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty().negate());
+//                    intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt().negate());
+//                    //出库状态
+//                    String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+//                    intoReturnItem.setOutStatus(outStatus);
+//                    //修改
+//                    int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+//                    //数量超出
+//                    if (countRow == 0) {
+//                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//                    }
+                    //endregion
+
+                    //region 销售退货订单明细
+                    OutReturnItem outReturnItem = new OutReturnItem();
+                    outReturnItem.setItemId(inboundItemVO.getFromItemId());
+                    outReturnItem.setIntoQty(inboundItemVO.getIntoQty().negate());
+                    outReturnItem.setIntoAmt(inboundItemVO.getIntoAmt().negate());
+                    outReturnItem.setIntoingQty(inboundItemVO.getIntoingQty().negate());
+                    outReturnItem.setIntoingAmt(inboundItemVO.getIntoingAmt().negate());
+                    //入库状态
+                    String intoStatus = this.setIntoStatus(outReturnItem.getIntoingQty(), outReturnItem.getIntoQty());
+                    outReturnItem.setIntoStatus(intoStatus);
                     //修改
-                    int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+                    int countRow = outReturnItemMapper.updateById(outReturnItem);
                     //数量超出
                     if (countRow == 0) {
                         throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
@@ -396,22 +446,17 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
         //region 编辑总单
         InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
-        BigDecimal sumOutQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-        BigDecimal sumOutAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-        BigDecimal sumOutingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-        BigDecimal sumOutingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-        inboundVO.setIntoQty(sumOutQty);
-        inboundVO.setIntoAmt(sumOutAmt);
-        inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumOutingQty));
-        inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumOutingAmt));
-        //已入库数量==入库中数量   入库完成
-        if (inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty()) == 0) {
-            //已入库
-            inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
-        } else {
-            //入库中
-            inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
-        }
+        BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+        BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+        BigDecimal sumIntoingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+        BigDecimal sumIntoingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+        inboundVO.setIntoQty(sumIntoQty);
+        inboundVO.setIntoAmt(sumIntoAmt);
+        inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumIntoingQty));
+        inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoingAmt));
+        //入库状态
+        String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
+        inboundVO.setIntoStatus(intoStatus);
         //实体转换
         Inbound inbound = inboundConvert.convertToPo(inboundVO);
         //修改
@@ -423,28 +468,50 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
         //region  修改销售退货订单
         if (inboundVO.getFromId() != null) {
+            //region todo  可能无用的代码
             //查询
 //                IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            IntoReturn intoReturn = new IntoReturn();
-            intoReturn.setReturnId(inboundVO.getFromId());
-//                intoReturn.setOutQty(intoReturnResponse.getOutQty().add(sumOutQty).subtract(sumDelOutQty));
-//                intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(sumOutAmt).subtract(sumDelOutAmt));
-//                intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(sumOutQty).subtract(sumDelOutingQty));
-//                intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(sumOutAmt).subtract(sumDelOutingAmt));
-            intoReturn.setOutQty(sumOutQty.subtract(sumDelOutQty));
-            intoReturn.setOutAmt(sumOutAmt.subtract(sumDelOutAmt));
-            intoReturn.setOutingQty((sumOutQty.add(sumDelOutingQty)).negate());
-            intoReturn.setOutingAmt((sumOutAmt.add(sumDelOutingAmt)).negate());
+//                intoReturn.setOutQty(intoReturnResponse.getOutQty().add(sumIntoQty).subtract(sumDelIntoQty));
+//                intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(sumIntoAmt).subtract(sumDelIntoAmt));
+//                intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(sumIntoQty).subtract(sumDelIntoingQty));
+//                intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(sumIntoAmt).subtract(sumDelIntoingAmt));
+            //endregion
+
+            //region todo 出库可能用到的代码 用完记得删除
+//            IntoReturn intoReturn = new IntoReturn();
+//            intoReturn.setReturnId(inboundVO.getFromId());
+//            intoReturn.setOutQty(sumIntoQty.subtract(sumDelIntoQty));
+//            intoReturn.setOutAmt(sumIntoAmt.subtract(sumDelIntoAmt));
+//            intoReturn.setOutingQty((sumIntoQty.add(sumDelIntoingQty)).negate());
+//            intoReturn.setOutingAmt((sumIntoAmt.add(sumDelIntoingAmt)).negate());
+//            //入库状态
+//            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
+//            intoReturn.setOutStatus(outStatus);
+//            //修改
+//            int countRow = intoReturnMapper.updateById(intoReturn);
+//            //数量超出
+//            if (countRow == 0) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//            }
+            //endregion
+
+            OutReturn outReturn = new OutReturn();
+            outReturn.setReturnId(inboundVO.getFromId());
+            outReturn.setIntoQty(sumIntoQty.subtract(sumDelIntoQty));
+            outReturn.setIntoAmt(sumIntoAmt.subtract(sumDelIntoAmt));
+            outReturn.setIntoingQty((sumIntoQty.add(sumDelIntoingQty)).negate());
+            outReturn.setIntoingAmt((sumIntoAmt.add(sumDelIntoingAmt)).negate());
             //入库状态
-            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
-            intoReturn.setOutStatus(outStatus);
+            String outReturnIntoStatus = this.setIntoStatus(outReturn.getIntoingQty(), outReturn.getIntoQty());
+            outReturn.setIntoStatus(outReturnIntoStatus);
             //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
+            int countRow = outReturnMapper.updateById(outReturn);
             //数量超出
             if (countRow == 0) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
             }
 
+
         }
         //endregion
 
@@ -469,28 +536,51 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
         //region 修改订单数据信息
         if (inboundVO.getFromId() != null) {
+            //region  todo 可能无用的代码
             //查询
 //            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            //赋值
-            IntoReturn intoReturn = new IntoReturn();
-            intoReturn.setReturnId(inboundVO.getFromId());
 //            intoReturn.setOutQty(intoReturnResponse.getOutQty().add(inboundResponse.getIntoQty()));
 //            intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(inboundResponse.getIntoAmt()));
 //            intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(inboundResponse.getIntoQty()));
 //            intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(inboundResponse.getIntoAmt()));
-            intoReturn.setOutQty(inboundResponse.getIntoQty());
-            intoReturn.setOutAmt(inboundResponse.getIntoAmt());
-            intoReturn.setOutingQty(inboundResponse.getIntoQty().negate());
-            intoReturn.setOutingAmt(inboundResponse.getIntoAmt().negate());
-            //出库状态
-            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
-            intoReturn.setOutStatus(outStatus);
+            //endregion
+
+            //region todo 出库可能用到的代码 用完记得删除
+            //赋值
+//            IntoReturn intoReturn = new IntoReturn();
+//            intoReturn.setReturnId(inboundVO.getFromId());
+//            intoReturn.setOutQty(inboundResponse.getIntoQty());
+//            intoReturn.setOutAmt(inboundResponse.getIntoAmt());
+//            intoReturn.setOutingQty(inboundResponse.getIntoQty().negate());
+//            intoReturn.setOutingAmt(inboundResponse.getIntoAmt().negate());
+//            //入库状态
+//            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
+//            intoReturn.setOutStatus(outStatus);
+//            //修改
+//            int countRow = intoReturnMapper.updateById(intoReturn);
+//            //数量超出
+//            if (countRow == 0) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//            }
+            //endregion
+
+            //赋值
+            OutReturn outReturn = new OutReturn();
+            outReturn.setReturnId(inboundVO.getFromId());
+            outReturn.setIntoQty(inboundResponse.getIntoQty());
+            outReturn.setIntoAmt(inboundResponse.getIntoAmt());
+            outReturn.setIntoingQty(inboundResponse.getIntoQty().negate());
+            outReturn.setIntoingAmt(inboundResponse.getIntoAmt().negate());
+            //入库状态
+            String intoStatus = this.setIntoStatus(outReturn.getIntoingQty(), outReturn.getIntoQty());
+            outReturn.setIntoStatus(intoStatus);
             //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
+            int countRow = outReturnMapper.updateById(outReturn);
             //数量超出
             if (countRow == 0) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
             }
+
         }
         //endregion
 
@@ -514,27 +604,51 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
         for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
             //region 修改销售退货明细数据信息
             if (inboundItemResponse.getFromItemId() != null) {
+                //region todo 可能无用的代码
                 //查询
 //                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemResponse.getFromItemId());
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemResponse.getFromItemId());
 //                intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemResponse.getIntoQty()));
 //                intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemResponse.getIntoAmt()));
 //                intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemResponse.getIntoQty()));
 //                intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemResponse.getIntoAmt()));
-                intoReturnItem.setOutQty(inboundItemResponse.getIntoQty().negate());
-                intoReturnItem.setOutAmt(inboundItemResponse.getIntoAmt().negate());
-                intoReturnItem.setOutingQty(inboundItemResponse.getIntoQty());
-                intoReturnItem.setOutingAmt(inboundItemResponse.getIntoAmt());
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
-                intoReturnItem.setOutStatus(outStatus);
+                //endregion
+
+                //region todo 出库可能用到的代码 用完记得删除
+//                IntoReturnItem intoReturnItem = new IntoReturnItem();
+//                intoReturnItem.setItemId(inboundItemResponse.getFromItemId());
+//                intoReturnItem.setOutQty(inboundItemResponse.getIntoQty().negate());
+//                intoReturnItem.setOutAmt(inboundItemResponse.getIntoAmt().negate());
+//                intoReturnItem.setOutingQty(inboundItemResponse.getIntoQty());
+//                intoReturnItem.setOutingAmt(inboundItemResponse.getIntoAmt());
+//                //入库状态
+//                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+//                intoReturnItem.setOutStatus(outStatus);
+//                //修改
+//                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+//                //数量超出
+//                if (countRow == 0) {
+//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+//                }
+                //endregion
+
+
+                OutReturnItem outReturnItem = new OutReturnItem();
+                outReturnItem.setItemId(inboundItemResponse.getFromItemId());
+                outReturnItem.setIntoQty(inboundItemResponse.getIntoQty().negate());
+                outReturnItem.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
+                outReturnItem.setIntoingQty(inboundItemResponse.getIntoQty());
+                outReturnItem.setIntoingAmt(inboundItemResponse.getIntoAmt());
+                //入库状态
+                String intoStatus = this.setIntoStatus(outReturnItem.getIntoingQty(), outReturnItem.getIntoQty());
+                outReturnItem.setIntoStatus(intoStatus);
                 //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
+                int countRow = outReturnItemMapper.updateById(outReturnItem);
                 //数量超出
                 if (countRow == 0) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
                 }
+
+
             }
             //endregion
 
@@ -575,7 +689,7 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
         //入库状态
         String intoStatus = null;
         //已入库数量>0 入库中数量>0
-        if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0 ) {
+        if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
             //入库中
             intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
         }
@@ -585,7 +699,7 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
             intoStatus = Constant.IntoStatus.DAIRUKU.getName();
         }
         //已入库数量>0 入库中数量=0
-        else if (intoQty.compareTo(BigDecimal.ZERO) >0 && intoingQty.compareTo(BigDecimal.ZERO)==0) {
+        else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
             //已入库
             intoStatus = Constant.IntoStatus.YIRUKU.getName();
         }
@@ -602,9 +716,9 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
         //出库状态
         String outStatus = null;
         //已出库数量>0 出库中数量>0
-        if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0 ) {
+        if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
             //出库中
-            outStatus =Constant.OutStatus.CHUKUZHONG.getName();
+            outStatus = Constant.OutStatus.CHUKUZHONG.getName();
         }
         //出入库数量=0 出库中数量=0
         else if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
@@ -612,7 +726,7 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
             outStatus = Constant.OutStatus.DAICHUKU.getName();
         }
         //已出库数量>0 出库中数量=0
-        else if (outQty.compareTo(BigDecimal.ZERO) >0 && outingQty.compareTo(BigDecimal.ZERO)==0) {
+        else if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
             //已出库
             outStatus = Constant.OutStatus.YICHUKU.getName();
         }
@@ -621,4 +735,27 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
 
 
 
+    /**
+     * @desc   : 获取单据信息(编辑用)
+     * @date   : 2024/3/16 16:28
+     * @author : 寇珊珊
+     */
+    public ResponseResultVO<?> selectByUpdate(String id) {
+        Map<String, Object> dataInfo = new HashMap<>();
+        //总单
+        InboundResponse inboundResponse = inboundMapper.selectMessageByOtherQuery(new InboundQuery().setIntoId(id).setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName()));
+        //单据不存在
+        if(inboundResponse==null){
+            return ResponseResultUtil.error(ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_INBOUND_QUANTITY.getCode(),
+                    ErrorCodeEnum.THERE_ORDER_IS_NOT_CAN_INBOUND_QUANTITY.getMessage());
+        }
+        dataInfo.put("data", inboundResponse);
+        // 明细
+        List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inboundResponse.getIntoId()));
+        dataInfo.put("dataItem", inboundItemResponses);
+        return ResponseResultUtil.success(dataInfo);
+    }
+
+
+
 }