|
@@ -0,0 +1,131 @@
|
|
|
+package kd.cosmic.jkjt.fi.cas.opplugin;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
+import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
+import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
|
|
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
+import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
+import kd.bos.util.StringUtils;
|
|
|
+import kd.cosmic.jkjt.siit.HttpUtilAction;
|
|
|
+import kd.cosmic.jkjt.tmc.util.ParamsUtil;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 付款处理-取消确认付款
|
|
|
+ * @author wanghaiuw_kd
|
|
|
+ * @date 2025/08/26
|
|
|
+ */
|
|
|
+public class PaymentCancelPay2EROpPlugin extends AbstractOperationServicePlugIn {
|
|
|
+ private static final Log logger = LogFactory.getLog(PaymentCancelPay2EROpPlugin.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
|
|
+ super.beforeExecuteOperationTransaction(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
+ super.beginOperationTransaction(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void endOperationTransaction(EndOperationTransactionArgs e) {
|
|
|
+ super.endOperationTransaction(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
|
+ super.afterExecuteOperationTransaction(e);
|
|
|
+
|
|
|
+ DynamicObject[] billEntities = e.getDataEntities();
|
|
|
+
|
|
|
+ if(billEntities.length > 0){
|
|
|
+ List<Long> ids = (List) Arrays.stream(billEntities).map((o) -> {
|
|
|
+ return o.getLong("id");
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ QFilter qFilter = new QFilter("id", QCP.in, ids);
|
|
|
+
|
|
|
+ //先找到批量的pkid
|
|
|
+ List<Object> list = QueryServiceHelper.queryPrimaryKeys("cas_paybill", qFilter.toArray(), null, Integer.MAX_VALUE);
|
|
|
+
|
|
|
+ //根据pkid找到完整的对象
|
|
|
+ DynamicObjectType type = EntityMetadataCache.getDataEntityType("cas_paybill");
|
|
|
+ DynamicObject[] paymentArray = BusinessDataServiceHelper.load(list.toArray(), type);
|
|
|
+
|
|
|
+ synStatus2ER(paymentArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param billEntities
|
|
|
+ */
|
|
|
+ private void synStatus2ER(DynamicObject[] billEntities){
|
|
|
+ DynamicObject commonParams = ParamsUtil.getCommonParamsAllField();
|
|
|
+
|
|
|
+ String url = "";
|
|
|
+ if(commonParams != null ){
|
|
|
+ url = commonParams.getString("nckd_fiurl");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(url)) {
|
|
|
+ url = url + "/api/financial/FinancialPayment/paymentUpdate";
|
|
|
+
|
|
|
+ for (DynamicObject dataEntity : billEntities) {
|
|
|
+ String billStatus = dataEntity.getString("billstatus");
|
|
|
+ String apisourcebillno = dataEntity.getString("nckd_apisourcebillno");
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(apisourcebillno) || "D".equals(billStatus)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, String> headers = new ConcurrentHashMap<>(1);
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("businessNumber", apisourcebillno);
|
|
|
+ json.put("paymentStatus", "2");
|
|
|
+ json.put("failCode", "");
|
|
|
+ json.put("failReason", "取消确认付款");
|
|
|
+ json.put("payDate", "");
|
|
|
+ json.put("serialNumber", "");
|
|
|
+ json.put("detailNumber", "");
|
|
|
+
|
|
|
+ logger.info("PaymentCancelPay2EROpPlugin:" + json.toJSONString());
|
|
|
+
|
|
|
+ String appReturnStr = HttpUtilAction.doPost(url, json.toJSONString(), headers);
|
|
|
+
|
|
|
+ logger.info("PaymentCancelPay2EROpPlugin:" + appReturnStr);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(appReturnStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject appReturnJson = JSONObject.parseObject(appReturnStr);
|
|
|
+
|
|
|
+ if ("200".equals(appReturnJson.getString("code"))) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ logger.info("PaymentCancelPay2EROpPlugin: ER system is invalid");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|