|
@@ -1,9 +1,12 @@
|
|
|
package com.dk.mdm.service.mac;
|
|
package com.dk.mdm.service.mac;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
+import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
|
|
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
import com.dk.common.model.pojo.PageList;
|
|
import com.dk.common.model.pojo.PageList;
|
|
|
|
|
+import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.infrastructure.convert.mac.OtherReceivableConvert;
|
|
import com.dk.mdm.infrastructure.convert.mac.OtherReceivableConvert;
|
|
@@ -25,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -74,7 +76,7 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @desc : 查询订单明细(货物、收款、附件)
|
|
|
|
|
|
|
+ * @desc : 查询明细(货物、收款、附件)
|
|
|
* @author : 付斌
|
|
* @author : 付斌
|
|
|
* @date : 2024-02-28 13:25
|
|
* @date : 2024-02-28 13:25
|
|
|
*/
|
|
*/
|
|
@@ -105,10 +107,10 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
|
|
|
.setObjectType(Constant.ObjectType.CUS.getName());
|
|
.setObjectType(Constant.ObjectType.CUS.getName());
|
|
|
// 转化实体
|
|
// 转化实体
|
|
|
OtherReceivable otherReceivable = otherReceivableConvert.convertToPo(otherReceivableVO);
|
|
OtherReceivable otherReceivable = otherReceivableConvert.convertToPo(otherReceivableVO);
|
|
|
- // 订单总单保存
|
|
|
|
|
|
|
+ // 总单保存
|
|
|
super.insert(otherReceivable);
|
|
super.insert(otherReceivable);
|
|
|
|
|
|
|
|
- // 订单明细保存
|
|
|
|
|
|
|
+ // 明细保存
|
|
|
if (otherReceivableVO.getItemList() != null && otherReceivableVO.getItemList().size() > 0) {
|
|
if (otherReceivableVO.getItemList() != null && otherReceivableVO.getItemList().size() > 0) {
|
|
|
for (OtherReceivableItemVO otherReceivableItemVO : otherReceivableVO.getItemList()) {
|
|
for (OtherReceivableItemVO otherReceivableItemVO : otherReceivableVO.getItemList()) {
|
|
|
OtherReceivableItem otherReceivableItem = otherReceivableItemConvert.convertToPo(otherReceivableItemVO);
|
|
OtherReceivableItem otherReceivableItem = otherReceivableItemConvert.convertToPo(otherReceivableItemVO);
|
|
@@ -117,6 +119,7 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 应收记账
|
|
|
accountService.accReceivable(otherReceivable.getReceivableId(),"t_mac_other_receivable");
|
|
accountService.accReceivable(otherReceivable.getReceivableId(),"t_mac_other_receivable");
|
|
|
return ResponseResultUtil.success();
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
}
|
|
@@ -130,35 +133,71 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
|
|
|
rollbackFor = {Exception.class}
|
|
rollbackFor = {Exception.class}
|
|
|
)
|
|
)
|
|
|
public ResponseResultVO<?> update(OtherReceivableVO otherReceivableVO) {
|
|
public ResponseResultVO<?> update(OtherReceivableVO otherReceivableVO) {
|
|
|
- // 明细实体(避免并发,需要再查一遍)
|
|
|
|
|
- OtherReceivableItem otherReceivableItemForUpdate;
|
|
|
|
|
- // 转化实体
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 先更新收款单总表,否则id又更错了
|
|
|
OtherReceivable otherReceivable = otherReceivableConvert.convertToPo(otherReceivableVO);
|
|
OtherReceivable otherReceivable = otherReceivableConvert.convertToPo(otherReceivableVO);
|
|
|
- //删除的
|
|
|
|
|
- List<OtherReceivableItemVO> deleteOtherReceivableItemVOList = otherReceivableVO.getDeleteItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
|
|
|
|
|
- if (deleteOtherReceivableItemVOList.size() > 0) {
|
|
|
|
|
- for (OtherReceivableItemVO otherReceivableItemVO : deleteOtherReceivableItemVOList) {
|
|
|
|
|
- otherReceivableItemMapper.deleteById(otherReceivableItemVO.getItemId());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 新增的
|
|
|
|
|
- List<OtherReceivableItemVO> insertOtherReceivableItemVOList = otherReceivableVO.getItemList().stream().filter(it -> it.getItemId() == null).collect(Collectors.toList());
|
|
|
|
|
- for (OtherReceivableItemVO otherReceivableItemVO : insertOtherReceivableItemVOList) {
|
|
|
|
|
- OtherReceivableItem otherReceivableItem = otherReceivableItemConvert.convertToPo(otherReceivableItemVO);
|
|
|
|
|
- otherReceivableItem.setReceivableId(otherReceivable.getReceivableId()).setCpId(otherReceivable.getCpId());
|
|
|
|
|
- otherReceivableItemMapper.insert(otherReceivableItem);
|
|
|
|
|
|
|
+ super.update(otherReceivable, new UpdateWrapper<OtherReceivable>().lambda().eq(OtherReceivable::getReceivableId,
|
|
|
|
|
+ UUID.fromString(otherReceivable.getReceivableId())));
|
|
|
|
|
+
|
|
|
|
|
+ // 应收反记账
|
|
|
|
|
+ accountService.reverseReceivable(otherReceivableVO.getReceivableId(),"t_mac_other_receivable");
|
|
|
|
|
+
|
|
|
|
|
+ // 将之前的明细全部删除
|
|
|
|
|
+ List<OtherReceivableItem> otherReceivableItemOriginalList = otherReceivableItemMapper.selectByZIdForUpdate(otherReceivableVO.getReceivableId());
|
|
|
|
|
+ for (OtherReceivableItem otherReceivableItem : otherReceivableItemOriginalList) {
|
|
|
|
|
+ otherReceivableItemMapper.deleteById(otherReceivableItem.getItemId());
|
|
|
}
|
|
}
|
|
|
- // 编辑的
|
|
|
|
|
- List<OtherReceivableItemVO> editOtherReceivableItemVOList = otherReceivableVO.getItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
|
|
|
|
|
- for (OtherReceivableItemVO otherReceivableItemVO : editOtherReceivableItemVOList) {
|
|
|
|
|
- otherReceivableItemForUpdate = otherReceivableItemMapper.selectByIdForUpdate(otherReceivableItemVO.getItemId());
|
|
|
|
|
- OtherReceivableItem otherReceivableItem = otherReceivableItemConvert.convertToPo(otherReceivableItemVO);
|
|
|
|
|
- otherReceivableItemService.updateByUuid(otherReceivableItem);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 明细保存
|
|
|
|
|
+ if (otherReceivableVO.getItemList() != null && otherReceivableVO.getItemList().size() > 0) {
|
|
|
|
|
+ for (OtherReceivableItemVO otherReceivableItemVO : otherReceivableVO.getItemList()) {
|
|
|
|
|
+ OtherReceivableItem otherReceivableItem = otherReceivableItemConvert.convertToPo(otherReceivableItemVO);
|
|
|
|
|
+ otherReceivableItem.setItemId(null).setReceivableId(otherReceivableVO.getReceivableId()).setCpId(otherReceivableVO.getCpId());
|
|
|
|
|
+ otherReceivableItemMapper.insert(otherReceivableItem);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 应收记账
|
|
|
|
|
+ accountService.accReceivable(otherReceivableVO.getReceivableId(),"t_mac_other_receivable");
|
|
|
|
|
+ return ResponseResultUtil.success();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return ResponseResultUtil.success(super.update(otherReceivable, new UpdateWrapper<OtherReceivable>().lambda().eq(OtherReceivable::getReceivableId,
|
|
|
|
|
- UUID.fromString(otherReceivable.getReceivableId()))));
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc : 获取信息(编辑用)
|
|
|
|
|
+ * @author : 付斌
|
|
|
|
|
+ * @date : 2024-03-02 17:27
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseResultVO<?> getOtherReceivableForUpdate(String id) {
|
|
|
|
|
+ Map<String, Object> dataInfo = new HashMap<>();
|
|
|
|
|
+ OtherReceivableResponse otherReceivableResponse = otherReceivableMapper.selectById(id);
|
|
|
|
|
+ dataInfo.put("data", otherReceivableResponse);
|
|
|
|
|
+
|
|
|
|
|
+ // 商品明细
|
|
|
|
|
+ List<OtherReceivableItemResponse> otherReceivableItemResponse = otherReceivableItemMapper.selectByCond(new OtherReceivableItemQuery().setReceivableId(id));
|
|
|
|
|
+ dataInfo.put("dataItem", otherReceivableItemResponse);
|
|
|
|
|
+ return ResponseResultUtil.success(dataInfo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc : 作废
|
|
|
|
|
+ * @author : 付斌
|
|
|
|
|
+ * @date : 2024-03-08 16:38
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseResultVO<?> invalid(String id) {
|
|
|
|
|
+ OtherReceivable otherReceivableForUpdate = otherReceivableMapper.selectByIdForUpdate(id);
|
|
|
|
|
+ // 并发校验
|
|
|
|
|
+ if (!otherReceivableForUpdate.getFlgValid()) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果所在月份已结账,则不能作废 todo
|
|
|
|
|
+
|
|
|
|
|
+ // 应收反记账
|
|
|
|
|
+ accountService.reverseReceivable(id,"t_mac_other_receivable");
|
|
|
|
|
+
|
|
|
|
|
+ // 作废
|
|
|
|
|
+ OtherReceivable otherReceivableUpdate = new OtherReceivable();
|
|
|
|
|
+ otherReceivableUpdate.setFlgValid(false).setReceivableId(id);
|
|
|
|
|
+ super.updateByUuid(otherReceivableUpdate);
|
|
|
|
|
+ return ResponseResultUtil.success();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|