|
|
@@ -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
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|