【商城接口】--销售退货申请接口:售后入库拦截

This commit is contained in:
zhongqy 2025-12-16 18:15:59 +08:00
parent 2e75b7aa4a
commit 19839d550e
1 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,111 @@
package tqq9.lc123.cloud.app.api.controller;
import com.alibaba.fastjson.JSONObject;
import com.drew.lang.annotations.NotNull;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.openapi.common.custom.annotation.ApiController;
import kd.bos.openapi.common.custom.annotation.ApiParam;
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.StringUtils;
import tqq9.lc123.cloud.app.api.utils.ApiResultExt;
import tqq9.lc123.cloud.app.api.utils.Constants;
import tqq9.lc123.cloud.app.plugin.form.result.CloneBill;
import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils;
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import static tqq9.lc123.cloud.app.plugin.form.result.CloneBill.cloneOperation;
/**
* 销售退货申请接口
*/
@ApiController(value = "SmReturnApplyController", desc = "销售退货申请接口")
public class SmReturnApplyController {
@ApiPostMapping(value = "/closeSmReturnApply", desc = "根据销售退货申请单号做售后入库拦截")
public CustomApiResult<ApiResultExt> closeSmDeliverNotice(@NotNull @ApiParam(value = "销售退货申请单单号", required = true) String orderBillNo) {
//返回值初始化
ApiResultExt resultExt = new ApiResultExt();
List<ApiResultExt.ResultBean> results = new ArrayList<>();
resultExt.setResult(results);
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
results.add(resultBean);
JSONObject key = new JSONObject();
key.put("billno", orderBillNo);
resultBean.setKeys(key);
ApiResultExt.Error error = new ApiResultExt.Error();
resultBean.setErrors(error);
ArrayList<String> rowmsg = new ArrayList<>();
error.setRowMsg(rowmsg);
String errormsg = null;
resultBean.setBillIndex(0);
resultBean.setKeys(key);
resultBean.setNumber(orderBillNo);
resultBean.setType(Constants.TYPE_CLOSE);
String message = null;
DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("sm_returnapply", new QFilter[]{new QFilter("billno", QCP.equals, orderBillNo)});
boolean tqq9_isclose = dataEntity.getBoolean("tqq9_isclose");
if (tqq9_isclose) {
resultExt = ApiResultExt.errorRetrun("sm_returnapply", "该单据已关闭", error, resultExt);
return CustomApiResult.success(resultExt);
}
Map<String, HashSet<Long>> targetBills = BFTrackerServiceHelper.findTargetBills("sm_returnapply", new Long[]{dataEntity.getLong("id")});
//下游存在系统进行提示不允许后续操作
if (null != targetBills && targetBills.size() > 0 && targetBills.containsKey("im_saloutbill")) {
resultExt = ApiResultExt.errorRetrun("sm_returnapply", "存在下游单据,不允许拦截", error, resultExt);
return CustomApiResult.success(resultExt);
}
String entityType = "sm_returnapply";
String entityName;
String label = "tqq9_isclose";
DynamicObject org = dataEntity.getDynamicObject("org");//收货组织
if (null != org) {
String number = org.getString("number");
if ("SHLC".equals(number)) {
DynamicObjectCollection billentry = dataEntity.getDynamicObjectCollection("billentry");
String warehouseCode = null;
for (DynamicObject dynamicObject : billentry) {
DynamicObject warehouse = dynamicObject.getDynamicObject("warehouse");
if (null != warehouse) {
warehouseCode = warehouse.getString("number");
}
}
String orderType = "THRK";
entityName = "WMS-SH-销售退货申请单取消";
message = BillCloseCancelUtils.wmsPartClose(orderType, warehouseCode, orderBillNo, entityType, entityName, label);
} else if ("BJLC".equals(number)) {
String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL");
entityName = "WMS-BJ-销售退货申请单取消";
message = BillCloseCancelUtils.BGSaCancelSalesReturn(orderBillNo, BJ_URL, entityType, entityName, label);
} else if ("GZLC".equals(number)) {
String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL");
entityName = "WMS-GZ-销售退货申请单取消";
message = BillCloseCancelUtils.BGSaCancelSalesReturn(orderBillNo, GZURL, entityType, entityName, label);
}
if (StringUtils.isNotEmpty(message) && message.contains("关闭成功")) {
cloneOperation(dataEntity, "销售退货申请单", "sm_salorder");
}else{
resultExt = ApiResultExt.errorRetrun(entityType, message, error, resultExt);
return CustomApiResult.success(resultExt);
}
}
//回传成功
resultExt.setFailCount(0);
resultExt.setSuccessCount(1);
resultExt.setResult(results);
return CustomApiResult.success(resultExt);
}
}