66 lines
2.5 KiB
Java
66 lines
2.5 KiB
Java
package tqq9.lc123.cloud.app.plugin.operate.sys;
|
|
|
|
import com.google.gson.Gson;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
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.sdk.plugin.Plugin;
|
|
import tqq9.lc123.cloud.app.plugin.operate.pm.PurOrderBillRebatePlugin;
|
|
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
|
|
/**
|
|
* 返利规则操作插件
|
|
*/
|
|
public class RebateRuleOpPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
|
private final static Log logger = LogFactory.getLog(PurOrderBillRebatePlugin.class);
|
|
private final static HashMap<String, String> tokenMap = new HashMap<String, String>() {{
|
|
put("Authorization", "Bearer b96dad1eb4f84c41bae651162aeacdd3");
|
|
}};
|
|
|
|
|
|
private static String Push_URL;
|
|
|
|
static {
|
|
DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
|
|
new QFilter[]{new QFilter("number", QCP.equals, "FLXT_CreatRule_Url")});
|
|
Push_URL = url != null ? url.getString("name") : null;
|
|
}
|
|
|
|
@Override
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
super.afterExecuteOperationTransaction(e);
|
|
for (DynamicObject dataEntity : e.getDataEntities()) {
|
|
String ruleName = dataEntity.getString("name");//规则名称
|
|
String tqq9_rulestype = dataEntity.getString("tqq9_rulestype");//规则类型
|
|
Integer type = Integer.valueOf(tqq9_rulestype);//规则类型
|
|
Date startTime = dataEntity.getDate("startTime");//返利计算开始时间
|
|
Date endTime = dataEntity.getDate("endTime");//返利计算结束时间
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> bodyMap = new HashMap<>();
|
|
Gson gson = new Gson();
|
|
try {
|
|
String bodyString = HttpRequestUtils.postJson(Push_URL, bodyMap.toString(), tokenMap);
|
|
HashMap map = gson.fromJson(bodyString, HashMap.class);
|
|
Boolean data = (Boolean) map.get("data");
|
|
if (!data) {
|
|
this.getOperationResult().setMessage("返利规则:" + ruleName + ",审核时创建返利规则失败");
|
|
}
|
|
} catch (IOException ex) {
|
|
throw new RuntimeException(ex);
|
|
}
|
|
|
|
}
|
|
}
|
|
} |