package yem.wm.cm.csrm.qcc;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;

import java.util.*;

/**
 * @program: yem-cosmic
 * @description:
 * @author: zsf
 * @create: 2024-05-30 11:54
 **/
public class QccFakeData {
    private final static String KEYNO = "9151010078813015XE";
    private final static String ENEITY = "yem_cm_merchantapply";

    public static Map<String,Object> setCompanyBaseInfor(DynamicObject merchan) {
        //获取底表数据进行集成
        if (merchan.getBoolean("yem_isadmit")){
            String billno = merchan.getString("billno");
            DynamicObject merchantApply = BusinessDataServiceHelper.loadSingle("yem_cm_merchantapply", new QFilter[]{new QFilter("billno", QCP.equals, billno)});
            String yemSocietycreditcode = (String) merchantApply.get("yem_societycreditcode");
            merchantApply.set("yem_nameqcc", "西安云易贸");// 客商名称(企查查)
            merchantApply.set("yem_registranumber", yemSocietycreditcode);// 注册号
            merchantApply.set("yem_suppliertype", "A");// 客商类型
            merchantApply.set("yem_moreclienttype", "A");//客商用途
            merchantApply.set("yem_admittanceexplain", "客商经营状态优秀，可以进行准入");//准入原因
            merchantApply.set("yem_businessaddress", "陕西省西安市高新区");//地点
            merchantApply.set("yem_regcapitals", 50000000);// 注册资本
            merchantApply.set("yem_paidincapitals",50000000);// 实缴资本
            merchantApply.set("yem_establishdate", new Date());// 成立日期
            merchantApply.set("yem_artificialperson","法定代表人");// 法定代表人
            DynamicObjectCollection manageExceCheck = merchantApply.getDynamicObjectCollection("yem_manageexcecheck");
            for (int i = 0; i < 2; i++) {
                DynamicObject addNew = manageExceCheck.addNew();
                addNew.set("yem_inclusionreason", "未授权");
                addNew.set("yem_inclusiondate", new Date());
                addNew.set("yem_removereason", "已进行授权");
                addNew.set("yem_removedate", new Date());
                addNew.set("yem_decisionoffice", "西安");
                addNew.set("yem_removedecisionoffi", "北京");
            }
            merchantApply.set("yem_ao", manageExceCheck.size());
            merchantApply.set("yem_ap",3);
            merchantApply.set("yem_ep",6);
            HashMap<String, Object> reData = new HashMap<>();
            reData.put("data",merchantApply);
            reData.put("flag",true);
            return reData;
        }else{
            merchan.set("yem_nameqcc", "客商名称");// 客商名称(企查查)
            merchan.set("yem_suppliertype", "A");// 客商类型
            merchan.set("yem_moreclienttype", "A");//客商用途
            merchan.set("yem_merchantstype", "A");//客商用途
            merchan.set("yem_regcapitals", 50000);// 注册资本
            merchan.set("yem_paidincapitals",50000);// 实缴资本
            DynamicObjectCollection manageExceCheck = merchan.getDynamicObjectCollection("yem_manageexcecheck");
            for (int i = 0; i < 3; i++) {
                DynamicObject addNew = manageExceCheck.addNew();
                addNew.set("yem_inclusionreason", "未授权");
                addNew.set("yem_inclusiondate", new Date());
                addNew.set("yem_removereason", "已经进行授权");
                addNew.set("yem_removedate", new Date());
                addNew.set("yem_decisionoffice", "北京");
                addNew.set("yem_removedecisionoffi", "上海");
            }
            merchan.set("yem_ao", 3);
            merchan.set("yem_ja",3);
            merchan.set("yem_ep",6);
            HashMap<String, Object> reData = new HashMap<>();
            reData.put("data",merchan);
            reData.put("flag",true);
            return reData;
        }
    }
}
