63 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Java
		
	
	
	
		
		
			
		
	
	
			63 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Java
		
	
	
	
| 
								 | 
							
								package tqq9.lc123.cloud.app.plugin.operate.pm;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import kd.bos.dataentity.entity.DynamicObject;
							 | 
						||
| 
								 | 
							
								import kd.bos.dataentity.utils.StringUtils;
							 | 
						||
| 
								 | 
							
								import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
							 | 
						||
| 
								 | 
							
								import kd.bos.entity.plugin.PreparePropertysEventArgs;
							 | 
						||
| 
								 | 
							
								import kd.bos.entity.plugin.args.AfterOperationArgs;
							 | 
						||
| 
								 | 
							
								import kd.bos.entity.plugin.args.BeforeOperationArgs;
							 | 
						||
| 
								 | 
							
								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.plugin.sample.dynamicform.pcform.form.template.RegisterListener;
							 | 
						||
| 
								 | 
							
								import kd.bos.servicehelper.BusinessDataServiceHelper;
							 | 
						||
| 
								 | 
							
								import kd.bos.servicehelper.operation.SaveServiceHelper;
							 | 
						||
| 
								 | 
							
								import kd.sdk.plugin.Plugin;
							 | 
						||
| 
								 | 
							
								import org.junit.Before;
							 | 
						||
| 
								 | 
							
								import tqq9.lc123.cloud.app.plugin.operate.im.ReturnStockSyncNotifierPlugin;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 返利规则操作插件
							 | 
						||
| 
								 | 
							
								 * 反写返利规则信息至采购合同
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								public class RebateRulesReverPurOrderPlugin extends AbstractOperationServicePlugIn implements Plugin {
							 | 
						||
| 
								 | 
							
								    private final static Log logger = LogFactory.getLog(RebateRulesReverPurOrderPlugin.class);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @Override
							 | 
						||
| 
								 | 
							
								    public void onPreparePropertys(PreparePropertysEventArgs e) {
							 | 
						||
| 
								 | 
							
								        super.onPreparePropertys(e);
							 | 
						||
| 
								 | 
							
								        e.getFieldKeys().add("tqq9_conm_purcontract");
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @Override
							 | 
						||
| 
								 | 
							
								    public void afterExecuteOperationTransaction(AfterOperationArgs e) {
							 | 
						||
| 
								 | 
							
								        super.afterExecuteOperationTransaction(e);
							 | 
						||
| 
								 | 
							
								        String operationKey = e.getOperationKey();
							 | 
						||
| 
								 | 
							
								        if (StringUtils.equals(operationKey, "save")) {
							 | 
						||
| 
								 | 
							
								            DynamicObject[] dataEntities = e.getDataEntities();
							 | 
						||
| 
								 | 
							
								            for (DynamicObject dataEntity : dataEntities) {
							 | 
						||
| 
								 | 
							
								                DynamicObject tqq9_conm_purcontract = dataEntity.getDynamicObject("tqq9_conm_purcontract");
							 | 
						||
| 
								 | 
							
								                if (tqq9_conm_purcontract != null) {
							 | 
						||
| 
								 | 
							
								                    DynamicObject conm_purcontract = BusinessDataServiceHelper.loadSingle("conm_purcontract", new QFilter[]{new QFilter("id", QCP.equals, tqq9_conm_purcontract.getLong("id"))});
							 | 
						||
| 
								 | 
							
								                    conm_purcontract.set("tqq9_rebate", dataEntity);
							 | 
						||
| 
								 | 
							
								                    SaveServiceHelper.save(new DynamicObject[]{conm_purcontract});
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        if (StringUtils.equals(operationKey, "delete")) {
							 | 
						||
| 
								 | 
							
								            DynamicObject[] dataEntities = e.getDataEntities();
							 | 
						||
| 
								 | 
							
								            for (DynamicObject dataEntity : dataEntities) {
							 | 
						||
| 
								 | 
							
								                DynamicObject tqq9_conm_purcontract = dataEntity.getDynamicObject("tqq9_conm_purcontract");
							 | 
						||
| 
								 | 
							
								                if (tqq9_conm_purcontract != null) {
							 | 
						||
| 
								 | 
							
								                    DynamicObject conm_purcontract = BusinessDataServiceHelper.loadSingle("conm_purcontract", new QFilter[]{new QFilter("id", QCP.equals, tqq9_conm_purcontract.getLong("id"))});
							 | 
						||
| 
								 | 
							
								                    conm_purcontract.set("tqq9_rebate", null);
							 | 
						||
| 
								 | 
							
								                    SaveServiceHelper.save(new DynamicObject[]{conm_purcontract});
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |