<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script import="app/app_login_check.js"><![CDATA[
            function bp_master_query() {
                var bpMaster_list_details;
                var bp_account_list_details;
                try {
                    var bpMaster_list_bm = $bm('app.bp_master.bp_master_query');
                    if (!$ctx.parameter.bp_id) {
                        $ctx.parameter.bp_id = null;
                    }
                    if (!$ctx.parameter.bp_name) {
                        $ctx.parameter.bp_name = null;
                    }
                    if (!$ctx.parameter.bank_account_id) {
                        $ctx.parameter.bank_account_id = null;
                    }
                    var bpMaster_list_map = bpMaster_list_bm.queryAsMap({
                        bp_id: $ctx.parameter.bp_id,
						user_id:$ctx.parameter.user_id, 
						bp_name:$ctx.parameter.bp_name,            
                        searchInput: $ctx.parameter.searchInput,
                        pagesize: $ctx.parameter.pagesize,
                        offsize: $ctx.parameter.offsize
                    });
                    bpMaster_list_details = bpMaster_list_map.getChildren();
                   
                   
                   
                   
                   
                    $ctx.parameter.return_status = 'S';
                    $ctx.parameter.return_message = '执行成功';
                } catch (e) {
                    $ctx.success = "true";
                    $ctx.parameter.return_status = 'E';
                    $ctx.parameter.return_message = String(e);
                }
            
                //返回结果
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    bpMaster_list: []
                };
                var bpMaster_list = result.bpMaster_list;
                var account_list = result.account_list;
              if (bpMaster_list_details) {
                    for (var i = 0;i < bpMaster_list_details.length;i++) {
                         var bpmaster_list_detail = bpMaster_list_details[i];
                        bpMaster_list.push({
                            "bp_id": String(bpmaster_list_detail.bp_id),
                            "bp_class": bpmaster_list_detail.bp_class,
                            "bp_class_n": bpmaster_list_detail.bp_class_n,
								  "bp_code": bpmaster_list_detail.bp_code,
								  "bp_name": bpmaster_list_detail.bp_name,
								  "bp_type_n": bpmaster_list_detail.bp_type_n,
								  "bp_type": bpmaster_list_detail.bp_type,
								  "bp_category_n": bpmaster_list_detail.bp_category_n,
								  "legal_form_n": bpmaster_list_detail.legal_form_n,
								  "legal_form": bpmaster_list_detail.legal_form,
								  "business_license_num": bpmaster_list_detail.business_license_num,
								  "founded_date": bpmaster_list_detail.founded_date,
								  "registered_capital": bpmaster_list_detail.registered_capital,
								  "corporate_code": bpmaster_list_detail.corporate_code,
								  "phone": bpmaster_list_detail.phone,
								  "liv_province": bpmaster_list_detail.liv_province,
									"liv_province_n": bpmaster_list_detail.liv_province_n,
								
								  "liv_city_n": bpmaster_list_detail.liv_city_n,
								  "liv_city": bpmaster_list_detail.liv_city,
								  "liv_street": bpmaster_list_detail.liv_street,
								  "office_space": bpmaster_list_detail.office_space,
								  "contact_person": bpmaster_list_detail.contact_person,
								  "cell_phone": bpmaster_list_detail.cell_phone,
								  "taxpayer_type": bpmaster_list_detail.taxpayer_type,
								
								  "taxpayer_type_n": bpmaster_list_detail.taxpayer_type_n,
								  "tax_registry_num": bpmaster_list_detail.tax_registry_num,
								  "invoice_bp_address_phone_num": bpmaster_list_detail.invoice_bp_address_phone_num,
								  "invoice_title": bpmaster_list_detail.invoice_title,
								  "invoice_bp_bank_account": bpmaster_list_detail.invoice_bp_bank_account,
								  "gender": bpmaster_list_detail.gender,
								  "gender_n": bpmaster_list_detail.gender_n,
								  "id_card_no": bpmaster_list_detail.id_card_no,
								  "id_type": bpmaster_list_detail.id_type,
								  "id_type_n": bpmaster_list_detail.id_type_n,
								  "date_of_birth": bpmaster_list_detail.date_of_birth,
								  "marital_status": bpmaster_list_detail.marital_status,
								  "marital_status_n": bpmaster_list_detail.marital_status_n,
								
								  "liv_district": bpmaster_list_detail.liv_district,
								  "liv_district_n": bpmaster_list_detail.liv_district_n,
								  "academic_background": bpmaster_list_detail.academic_background,
								  "academic_background_n": bpmaster_list_detail.academic_background_n,
								  "industry": bpmaster_list_detail.industry,
								  "work_unit": bpmaster_list_detail.work_unit,
								  "work_unit_phone": bpmaster_list_detail.work_unit_phone,
								  "id_number": bpmaster_list_detail.id_number,
								
								  "monthly_income": Number(bpmaster_list_detail.monthly_income),
								  "contact_person": bpmaster_list_detail.contact_person,
								  "cell_phone": bpmaster_list_detail.cell_phone,
								  "organization_code": bpmaster_list_detail.organization_code
								  
								                           
                        });
                    }
            }
                
              
                $ctx.parameter.json = JSON.stringify(result);
            }
            if ($ctx.parameter.return_status != 'E' && $ctx.parameter.return_status != 'TIMEOUT') {
                bp_master_query();
            }
        ]]></s:server-script>
    </a:init-procedure>
    <a:service-output output="/parameter/@json"/>
</a:service>