Просмотр исходного кода

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

changhaoning 2 лет назад
Родитель
Сommit
971e539b82

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

@@ -8,6 +8,7 @@ import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.query.ivt.InboundQuery;
 import com.dk.mdm.model.response.ivt.InboundResponse;
 import com.dk.mdm.model.vo.ivt.InboundVO;
+import com.dk.mdm.model.vo.ivt.IntoReturnVO;
 import com.dk.mdm.service.ivt.InboundReturnService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -65,6 +66,18 @@ public class inboundReturnController {
     }
 
 
-
+    /**
+     * @desc : 作废
+     * @date : 2022/6/28 16:58
+     * @author : 于继渤
+     */
+    @ApiOperation(
+            value = "作废",
+            notes = "作废"
+    )
+    @PostMapping("cancel")
+    public ResponseResultVO<String> cancel(@RequestBody InboundVO inboundVO) {
+        return inboundReturnService.cancel(inboundVO);
+    }
 
 }

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

@@ -269,9 +269,9 @@
             <if test="staffIdList != null and staffIdList.size() > 0">
                 AND tms.staff_id  =any(#{staffIdList, typeHandler=uuidListTypeHandler})
             </if>
-            <if test="intoDateStart != null and intoDateEnd != null">
-                AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
-                AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
             <if test="intoStatusList != null and intoStatusList.size()>0">
                 AND tpi.into_status =
@@ -675,9 +675,9 @@
             <if test=" intoStatus != null and intoStatus != '' ">
                 AND  tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
             </if>
-            <if test="intoDateStart != null and intoDateEnd != null">
-                AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
-                AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
         </where>
         union all
@@ -707,9 +707,9 @@
             <if test="outStatus != null and outStatus != '' ">
                 AND  tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
             </if>
-            <if test="intoDateStart != null and intoDateEnd != null">
-                AND tpo.make_time &gt;= #{intoDateStart}::timestamp with time zone
-                AND tpo.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
         </where>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
@@ -747,9 +747,9 @@
             <if test="intoStatus != null and intoStatus != '' ">
                 AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
             </if>
-            <if test="intoDateStart != null and intoDateEnd != null">
-                AND tpi.make_time &gt;= #{intoDateStart}::timestamp with time zone
-                AND tpi.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
         </where>
         union all
@@ -779,9 +779,9 @@
             <if test="outStatus != null and outStatus != '' ">
                 AND  tpo.out_status LIKE concat('%',my_ex.likequery(#{outStatus}),'%')
             </if>
-            <if test="intoDateStart != null and intoDateEnd != null">
-                AND tpo.make_time &gt;= #{intoDateStart}::timestamp with time zone
-                AND tpo.make_time &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
         </where>
         ) tt

+ 20 - 5
src/main/java/com/dk/mdm/mapper/mac/RecPayMapper.xml

@@ -80,6 +80,16 @@
             <if test="rpNo != null and rpNo != ''">
                 AND t.rp_no LIKE concat('%',my_ex.likequery(#{rpNo}),'%')
             </if>
+            <if test="searchText !=null and searchText != ''">
+                AND (
+                t.rp_no   LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                )
+            </if>
             <if test="rpType != null and rpType != ''">
                 AND t.rp_type = #{rpType}
             </if>
@@ -143,11 +153,11 @@
             <if test="cusName != null and cusName != ''">
                 AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
             </if>
-            <if test="orgIdList != null and orgIdList.size() > 0">
-                AND t.org_id  =any(#{orgIdList, typeHandler=uuidListTypeHandler})
+            <if test="orgIds != null and orgIds.size() > 0">
+                AND t.org_id  =any(#{orgIds, typeHandler=UuidListTypeHandler})
             </if>
-            <if test="staffIdList != null and staffIdList.size() > 0">
-                AND t.staff_id  =any(#{staffIdList, typeHandler=uuidListTypeHandler})
+            <if test="staffIds != null and staffIds.size() > 0">
+                AND t.staff_id  =any(#{staffIds, typeHandler=UuidListTypeHandler})
             </if>
             <if test="makeTimeStart != null and makeTimeEnd != null">
                 AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
@@ -221,7 +231,12 @@
         count(1)
         FROM dkic_b.t_mac_rec_pay as t
          LEFT JOIN dkic_b.t_mst_customer tmc
-                   ON tmc.cus_id = t.object_id and t.rp_type = '收付款类型-收款'
+                   ON tmc.cus_id = t.object_id
+        Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.object_id
+        left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.rp_type
+        left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+        left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+        left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
         <include refid="Condition"/>
     </select>
 

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mst/MoneyAccountMapper.xml

@@ -72,7 +72,7 @@
 
     <!-- 查询表t_mst_money_account,(条件查询+分页)列表 -->
     <select id="selectByCond" resultMap="BaseResultMapResponse">
-        SELECT ma.mac_Type,ma.mac_code,ma.mac_name,ma.remarks
+        SELECT ma.mac_Type,ma.mac_code,ma.mac_name,ma.remarks,ma.mac_receipt_code
              ,ma.cp_id,ma.flg_valid
              ,dd.data_value AS "macTypeName"
              ,ma.mac_id,ma.balance,ma.display_no

+ 2 - 2
src/main/java/com/dk/mdm/model/query/ivt/InboundQuery.java

@@ -193,11 +193,11 @@ public class InboundQuery extends PageInfo<InboundQuery>{
 
     @ApiModelProperty(value = "入库时间开始")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-    private LocalDate intoDateStart;
+    private LocalDate makeTimeStart;
 
     @ApiModelProperty(value = "入库时间结束")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-    private LocalDate intoDateEnd;
+    private LocalDate makeTimeEnd;
 
     /**
      * 商品型号

+ 32 - 3
src/main/java/com/dk/mdm/model/query/mac/RecPayQuery.java

@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 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.UuidTypeHandler;
+import com.dk.common.infrastructure.handler.*;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
@@ -23,6 +21,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  *  收付款单
@@ -92,6 +91,20 @@ public class RecPayQuery extends PageInfo<RecPayQuery> implements Serializable {
     @TableField(typeHandler = UuidTypeHandler.class)
     private String staffId;
 
+    /**
+     * 员工ID
+     */
+    @ApiModelProperty(value = "员工ID")
+    @TableField(typeHandler = UuidListTypeHandler.class)
+    private List<String> staffIds;
+
+    /**
+     * @desc   : 组织部门list
+     */
+    @ApiModelProperty(value = "组织部门list")
+    @TableField(typeHandler = UuidListTypeHandler.class)
+    private List<String> orgIds;
+
 
     /**
      * 收款金额
@@ -125,6 +138,12 @@ public class RecPayQuery extends PageInfo<RecPayQuery> implements Serializable {
 
 
     /**
+     * 小程序的查询条件
+     */
+    @ApiModelProperty(value = "小程序的查询条件")
+    private String searchText;
+
+    /**
      * 收付款日期 (账务日期)
      */
     @Excel(name = "收付款日期 (账务日期)")
@@ -133,6 +152,16 @@ public class RecPayQuery extends PageInfo<RecPayQuery> implements Serializable {
     @TableField(typeHandler = TimestampTypeHandler.class)
     private LocalDate accDate;
 
+    @ApiModelProperty(value = "制单时间开始")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate makeTimeStart;
+
+    @ApiModelProperty(value = "制单时间结束")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate makeTimeEnd;
+
 
     /**
      * 备注

+ 135 - 11
src/main/java/com/dk/mdm/service/ivt/InboundReturnService.java

@@ -11,22 +11,29 @@ 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.mapper.common.CommonMapper;
 import com.dk.mdm.mapper.ivt.InboundItemMapper;
 import com.dk.mdm.mapper.ivt.InboundMapper;
 import com.dk.mdm.mapper.pur.PurchaseItemMapper;
 import com.dk.mdm.mapper.pur.PurchaseMapper;
 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.pur.Purchase;
 import com.dk.mdm.model.pojo.pur.PurchaseItem;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
 import com.dk.mdm.model.query.ivt.InboundQuery;
+import com.dk.mdm.model.query.ivt.IntoReturnItemQuery;
+import com.dk.mdm.model.query.ivt.IntoReturnQuery;
 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.ivt.IntoReturnVO;
 import com.dk.mdm.service.common.CommonService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -68,7 +76,8 @@ public class InboundReturnService extends BaseService<Inbound> {
     @Autowired
     private InboundItemConvert inboundItemConvert;
 
-
+    @Autowired
+    private CommonMapper commonMapper;
     @Pagination
     public ResponseResultVO<PageList<InboundResponse>> selectByCond(InboundQuery inboundQuery) {
         return super.mergeListWithCount(inboundQuery, inboundMapper.selectByInboundReturnCond(inboundQuery), inboundMapper.countByInboundReturnCond(inboundQuery));
@@ -119,21 +128,19 @@ public class InboundReturnService extends BaseService<Inbound> {
                 .setReturnQty(purchaseResponse.getReturnQty().add(inboundVO.getReturnQty()))
                 .setReturnAmt(purchaseResponse.getReturnAmt().add(inboundVO.getReturnAmt()))
         );
-        BigDecimal sumReturnQty = BigDecimal.ZERO;
-        BigDecimal sumReturnAmt = BigDecimal.ZERO;
+
         //反写入库订单明细、反写订单明细
         for (InboundItemVO inboundItemVO : itemList) {
             //根据退货明细中入库明细id查询入库明细数据
             InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId()); //原入库单明细id
             BigDecimal returnQty = inboundItemResponse.getReturnQty().add(inboundItemVO.getReturnQty().setScale(6, BigDecimal.ROUND_HALF_UP));
             BigDecimal returnAmt = inboundItemResponse.getReturnAmt().add(inboundItemVO.getReturnAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
-            sumReturnQty = sumReturnQty.add(returnQty);
-            sumReturnAmt = sumReturnAmt.add(returnAmt);
-            //反写入库单退货数量金额 todo
+
+            //反写入库单退货数量金额
             InboundResponse inboundResponse = inboundMapper.selectById(inboundItemVO.getIntoId()); //原入库单id
             inboundMapper.updateAmount(new Inbound().setIntoId(inboundItemVO.getIntoId())
-                    .setReturnQty(inboundResponse.getReturnQty().add(sumReturnQty))
-                    .setReturnAmt(inboundResponse.getReturnAmt().add(sumReturnAmt)));
+                    .setReturnQty(inboundResponse.getReturnQty().add(returnQty))
+                    .setReturnAmt(inboundResponse.getReturnAmt().add(returnAmt)));
             inboundItemMapper.updateAmount(
                     new InboundItem()
                             .setItemId(inboundItemResponse.getItemId())
@@ -152,8 +159,6 @@ public class InboundReturnService extends BaseService<Inbound> {
 
             );
         }
-        inboundVO.setFromId(inboundVO.getIntoId());
-        inboundVO.setFromNo(inboundVO.getIntoNo());
         inboundVO.setIntoingQty(inboundVO.getReturnQty().multiply(new BigDecimal(-1)));
         inboundVO.setIntoingAmt(inboundVO.getReturnAmt().multiply(new BigDecimal(-1)));
         List<InboundItemVO> list = new ArrayList<>();
@@ -182,6 +187,16 @@ public class InboundReturnService extends BaseService<Inbound> {
         }
 
         inboundVO.setItemList(list);
+        Map<String, Object> map = new HashMap<>();
+        map.put("cpId", inboundVO.getCpId());
+        map.put("code", "IVT_001");
+        //自动办理标识
+        String flgHandleSetting = commonMapper.getSettingValue(map);
+        //自动办理标识为1 自动办理入库
+        if(Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)){
+            inboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
+        }
+        //region  总单
         //获取 id/单号
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALERETURN.getName(), false);
         inboundVO.setIntoId(codeMap.get("outId").toString()).
@@ -189,7 +204,7 @@ public class InboundReturnService extends BaseService<Inbound> {
         //入库类型
         inboundVO.setIntoType(Constant.IntoType.PURRETURN_RETURN.getName());
         //自动入库标识
-        if (inboundVO.getAutomaticFlg()) {
+        if (inboundVO.getFlgAutoHandle()) {
             //已入库
             inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
         } else {
@@ -251,7 +266,116 @@ public class InboundReturnService extends BaseService<Inbound> {
             //实体转换
             InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
             inboundItemMapper.insert(inboundItem);
+            //endregion
+
+        }
+        return ResponseResultUtil.success();
+    }
+
+
+    /**
+     * @desc : 作废
+     * @date : 2022/6/28 16:58
+     * @author : 于继渤
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<String> cancel(InboundVO inboundVO) {
+        //查询当前 采退入库单 负
+        InboundResponse inboundResponse = inboundMapper.selectInboundReturnById(inboundVO.getIntoId());
+        if (inboundResponse.getIntoStatus().equals(Constant.IntoStatus.ZUOFEI.getName())) {
+            //当前单据已经作废,不能重复操
+            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+        }
+        //校验单据是否可以作废
+
+
+        //region  查询当前公司的系统参数  自动办理信息  并赋值
+        Map<String, Object> map = new HashMap<>();
+        map.put("cpId", inboundResponse.getCpId());
+        map.put("code", "IVT_001");
+        //自动办理标识
+        String flgHandleSetting = commonMapper.getSettingValue(map);
+        //自动办理标识为1 自动办理入库
+        if(Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)){
+            inboundResponse.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
+        }
+
+
 
+
+        //TODO  //系统参数自动出入库办理 已出库(未退款)可以作废,已出库(已退款)不可以作废
+        if(inboundResponse.getFlgHandleSetting() &&  inboundResponse.getIntoStatus().equals(Constant.IntoStatus.YIRUKU.getName())){
+            return ResponseResultUtil.error(ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getCode(),
+                    ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getMessage());
+        }
+        //系统参数手动出入库办理 出库中,可以作废,已出库(未收款、已收款),不可以作废
+        if (!inboundResponse.getFlgHandleSetting() && inboundResponse.getIntoStatus().equals(Constant.IntoStatus.YIRUKU.getName())) {
+            return ResponseResultUtil.error(ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getCode(),
+                    ErrorCodeEnum.NO_WAIT_INTO_RETURN_CANCEL.getMessage());
+        }
+        //查询采购单
+        PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
+        if (purchaseResponse == null) {
+            //返回 单据所对应的原始单据不存在,请重新操作
+            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+        }
+        //修改采购单 已入库数量/金额
+        purchaseMapper.updateAmount(
+                new Purchase().setReturnQty(purchaseResponse.getReturnQty().subtract(inboundResponse.getReturnQty()))
+                        .setReturnAmt(purchaseResponse.getReturnAmt().subtract(inboundResponse.getReturnAmt())).setPurId(purchaseResponse.getPurId())
+        );
+
+        List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inboundResponse.getIntoId()));
+        for (InboundItemResponse inboundItemRespons : inboundItemResponses) {
+
+            //查询源入库单明细
+            InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemRespons.getSIntoItemId());
+            if (inboundItemResponse == null) {
+                //返回 单据所对应的原始单据不存在,请重新操作
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+            }
+            //修改入库单明细 已入库退货数量/金额
+            inboundItemMapper.updateAmount(new InboundItem()
+                    .setItemId(inboundItemResponse.getSIntoItemId())
+                    .setReturnQty(inboundItemResponse.getReturnQty().subtract(inboundItemResponse.getReturnQty()))
+                    .setReturnAmt(inboundItemResponse.getReturnAmt().subtract(inboundItemResponse.getReturnAmt()))
+            );
+
+
+            //查询源入库单 修改 已入库退货数量/金额
+            InboundResponse inboundRes = inboundMapper.selectById(inboundItemRespons.getSIntoId());
+            if (inboundRes == null) {
+                //返回 单据所对应的原始单据不存在,请重新操作
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+            }
+            inboundMapper.updateAmount(new Inbound().setIntoId(inboundRes.getIntoId())
+                    .setReturnQty(inboundResponse.getReturnQty().subtract(inboundItemRespons.getReturnQty()))
+                    .setReturnAmt(inboundResponse.getReturnAmt().subtract(inboundItemRespons.getReturnAmt())));
+
+
+            //查询采购单明细
+            PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemRespons.getSPurItemId());
+            if (purchaseItemResponse == null) {
+                //返回 单据所对应的原始单据不存在,请重新操作
+                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ORIGINAL_DOCUMENT_ABSENT.getMessage());
+            }
+            //修改采购单明细 已入库退货数量/金额
+            purchaseItemMapper.updateAmount(
+                    new PurchaseItem()
+                            .setItemId(purchaseItemResponse.getItemId())
+                            .setReturnQty(purchaseItemResponse.getReturnQty().subtract(inboundItemRespons.getReturnQty()))
+                            .setReturnAmt(purchaseItemResponse.getReturnAmt().subtract(inboundItemRespons.getReturnAmt()))
+            );
+        }
+        //修改 负向入库单 状态为作废
+        inboundMapper.updateIntoStatus(new Inbound()
+                .setIntoId(inboundVO.getIntoId())
+                .setIntoStatus(Constant.IntoStatus.ZUOFEI.getName()));
+        //修改 负向入库单明细 状态为作废
+        if (inboundItemResponses != null && inboundItemResponses.size() > 0) {
+            for (InboundItemResponse inboundItemRespons : inboundItemResponses) {
+                inboundItemMapper.updateIntoStatus(new InboundItem().setItemId(inboundItemRespons.getItemId()).setIntoStatus(Constant.IntoStatus.ZUOFEI.getName()));
+            }
         }
         return ResponseResultUtil.success();
     }