package com.yem.wm.im.merchantapply.validator;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;

public class MerChantApplySaveValidator extends AbstractValidator {

    @Override
    public void validate() {
        //校验跟组织下有无同名称客户
        ExtendedDataEntity[] dataEntities = this.getDataEntities();
        for (ExtendedDataEntity dataEntity : dataEntities) {
            DynamicObject Obj = dataEntity.getDataEntity();
            DynamicObjectCollection standardColl = Obj.getDynamicObjectCollection("yem_merchantapply_e");
            if (standardColl.size() > 0) {
                for (DynamicObject standardobj : standardColl) {
                    if ("customerGroupStandard".equals(standardobj.getDynamicObject("yem_standardid").getString("number"))) {
                        DynamicObject groupObj = standardobj.getDynamicObject("yem_groupid");
                        if (groupObj == null) {
                            this.addErrorMessage(dataEntity, "请在分类标准中选择分类！");
                        }
                    }
                }
            } else {
                this.addErrorMessage(dataEntity, "请在分类标准中选择分类！");
            }
        }
    }
}
