1, 'delivery_mode|notin'=>'shopyjdf'); //check shop permission $organization_permissions = kernel::single('desktop_user')->get_organization_permission(); if($organization_permissions){ $base_filter['user_org_id'] = $organization_permissions; } $this->finder('ome_mdl_shop', array( 'title' => $title, 'base_filter' => $base_filter,//只显示线上店铺,不包含门店线下店铺 'actions' => array( array('label' => '添加店铺', 'href' => 'index.php?app=ome&ctl=admin_shop&act=addterminal&finder_id=' . $_GET['finder_id'], 'target' => 'dialog::{width:900,height:600,title:\'添加店铺\'}'), array('label' => '查看绑定关系', 'href' => 'index.php?app=ome&ctl=admin_shop&act=view_bindrelation', 'target' => '_blank'), array('label' => '消息订阅', 'submit' => 'index.php?app=ome&ctl=admin_shop&act=invoiceAddGroup', 'target' => 'dialog::{width:600,height:200,title:\'消息订阅\'}'), ), 'finder_cols' => 'column_bind_status,column_edit,shop_bn,name,shop_type,node_id,node_type,active', 'use_buildin_new_dialog' => false, 'use_buildin_set_tag' => false, 'use_buildin_recycle' => true, 'use_buildin_export' => true, 'use_buildin_import' => false, 'use_buildin_filter' => true, 'use_buildin_customcols' => true, 'orderBy' => 's_status DESC, node_type DESC', )); } /** * 网店节点显示 * @param null * @return null */ public function shopnode() { $this->pagedata['node_id'] = base_shopnode::node_id($this->app->app_id); $this->pagedata['node_type'] = base_shopnode::node_type($this->app->app_id); $this->page('admin/system/shopnode.html'); } /* * 添加前端店铺 */ function addterminal() { $this->_editterminal(); } /* * 编辑前端店铺 */ function editterminal($shop_id) { $this->_editterminal($shop_id); } function _editterminal($shop_id = NULL) { $oShop = $this->app->model("shop"); $operationOrgObj = $this->app->model('operation_organization'); $orgs = $operationOrgObj->getList('*', array(), 0, -1); $this->pagedata['orgs'] = $orgs; $shoptype = ome_shop_type::get_shop_type(); $shop_type = array(); $i = 0; if ($shoptype){ foreach ($shoptype as $k => $v) { $shop_type[$i]['type_value'] = $k; $shop_type[$i]['type_label'] = $v; $i++; } } if ($shop_id) { $shop = $oShop->dump($shop_id); $shop_config = unserialize($shop['config']); $this->pagedata['shop'] = $shop; $this->pagedata['shop_config'] = $shop_config; $propsMdl = app::get('ome')->model('shop_props'); $propsList = $propsMdl->getlist('*', ['shop_id' => $shop_id]); $arr_props = array(); foreach($propsList as $v){ $arr_props[$v['props_col']] = $v['props_value']; } } $this->pagedata['shop_type'] = $shop_type; $this->pagedata['title'] = '添加/编辑店铺'; //自定义 $customcols = kernel::single('ome_shop')->getcols(); foreach($customcols as $k=>$v){ if($arr_props[$v['col_key']]){ $customcols[$k]['col_value'] = $arr_props[$v['col_key']]; } } $this->pagedata['customcols'] = $customcols; $this->display("admin/system/terminal.html"); } /** * 申请绑定关系 * @param string $app_id * @param string $callback 异步返回地址 * @param string $api_url API通信地址 */ /** * 店铺绑定三步引导页面 */ function bind_guide() { $shop_id = $_GET['shop_id']; $step = isset($_GET['step']) ? intval($_GET['step']) : null; // null 表示未指定,会自动跳转到未完成的步骤 if (!$shop_id) { $this->splash('error', '', '店铺ID不能为空'); return; } // 获取店铺信息 $shopObj = app::get('ome')->model('shop'); $shop = $shopObj->dump($shop_id, '*'); if (!$shop) { $this->splash('error', '', '店铺不存在'); return; } // 判断企业认证状态(参考 system.php) $entId = base_enterprise::ent_id(); $entAc = base_enterprise::ent_ac(); $entEmail = base_enterprise::ent_email(); $is_certified = !empty($entId); // 企业认证状态:如果 ent_id 有值,就表示企业认证成功 // 系统节点与证书(展示用) $system_node_id = base_shopnode::node_id('ome'); $system_certificate_id = base_certificate::get('certificate_id'); // 获取 version_tier,如果为 tn-open,则按照非淘宝逻辑处理 $version_tier = app::get('entermembercenter')->getConf('version_tier'); $is_tn_open = ($version_tier == 'tn-open'); // 判断是否需要奇门授权(淘系店铺:淘宝/天猫同一逻辑) // 注意:如果 version_tier=tn-open,即使店铺类型是淘宝/天猫,也按照非淘宝逻辑处理 $is_taobao = in_array($shop['shop_type'], array('taobao', 'tmall')) && !$is_tn_open; $need_qimen = false; $is_qimen_binded = false; $secretKeyDisplay = ''; $qimen_rebind_url = ''; $qimen_channel_id = ''; $is_super = kernel::single('desktop_user')->is_super(); // 只有淘宝店铺才需要奇门授权(但 tn-open 版本不需要) if ($is_taobao) { // 检查奇门聚石塔内外互通渠道是否已配置 $channelObj = kernel::single('channel_channel'); $qimenChannel = $channelObj->getQimenJushitaErp(); if (!empty($qimenChannel) && !empty($qimenChannel['channel_id'])) { $need_qimen = true; $qimen_channel_id = $qimenChannel['channel_id']; $qimen_rebind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; // 判断是否已授权:检查 app_key 和 secret_key 是否都有值 if (!empty($qimenChannel['app_key']) && !empty($qimenChannel['secret_key'])) { $is_qimen_binded = true; // 处理 secret_key 打码显示(参考 system.php) $len = strlen($qimenChannel['secret_key']); if ($len <= 4) { // 长度小于等于4,全部显示星号 $secretKeyDisplay = str_repeat('*', $len); } else { // 显示前2位和后2位,中间用星号 $secretKeyDisplay = substr($qimenChannel['secret_key'], 0, 2) . str_repeat('*', $len - 4) . substr($qimenChannel['secret_key'], -2); } } } } else { // 非淘宝店铺,不需要奇门授权 $qimenChannel = array(); } // 节点绑定状态(只检查 node_id) $is_node_binded = !empty($shop['node_id']); // 店铺绑定状态:对于淘宝店铺,需要同时满足 node_id 和奇门授权;对于非淘宝店铺(包括 version_tier=tn-open),只需要 node_id // 注意:步骤3(店铺绑定)的完成状态只检查 node_id,不依赖奇门授权 // 但是最终的"店铺绑定完成"状态需要两者都完成 // 注意:version_tier=tn-open 时,即使店铺类型是淘宝/天猫,也按照非淘宝逻辑处理(不需要奇门授权) if ($is_taobao) { // 淘宝店铺:需要同时满足 node_id 和奇门授权才算完全绑定完成 $is_shop_binded = $is_node_binded && $is_qimen_binded; } else { // 非淘宝店铺(包括 version_tier=tn-open):只需要 node_id $is_shop_binded = $is_node_binded; } // 获取对接方式(从店铺配置的adapter字段) $config = unserialize($shop['config']); if (!is_array($config)) { $config = array(); } $adapter = isset($config['adapter']) ? $config['adapter'] : ''; // 商家自研对接不需要奇门授权,直接走店铺绑定 if ($adapter == 'openapi') { $need_qimen = false; } // 检查是否已有节点,如果有节点则不允许修改对接方式 $has_node = !empty($shop['node_id']); // 获取适配器列表 $adapter_list = kernel::single('ome_auth_config')->getAdapterList(); $this->pagedata['adapter_list'] = $adapter_list; $this->pagedata['has_node'] = $has_node; // 计算当前步骤(现在有5步:0对接方式、1企业认证、2奇门授权(淘宝)/店铺绑定(非淘宝)、3店铺绑定(淘宝)、4完成) // 注意:如果对接方式是 openapi(商家自研对接),不需要企业认证,跳过步骤1 // 注意:对于淘宝店铺,步骤2是奇门授权,步骤3是店铺绑定 $need_enterprise_auth = ($adapter != 'openapi'); // openapi 不需要企业认证 if (empty($adapter)) { $current_step = 0; $status_text = '选择对接方式'; $step_text = '请选择对接方式'; $bind_url = ''; } elseif ($need_enterprise_auth && !$is_certified) { // 需要企业认证且未认证 $current_step = 1; $status_text = '未认证企业'; $step_text = '请先完成企业认证'; // 生成企业认证URL(参考 system.php) $bind_url = base_enterprise::generate_auth_url(); } elseif ($is_taobao && $need_qimen && !$is_qimen_binded) { // 淘宝店铺:步骤2是奇门授权 $current_step = 2; $status_text = '待绑奇门'; $step_text = '请完成奇门绑定授权'; // 使用channel控制器的apply_bindrelation方法 $qimen_channel_id = !empty($qimenChannel['channel_id']) ? $qimenChannel['channel_id'] : ''; $bind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; } elseif (!$is_node_binded) { // 节点未绑定:对于淘宝店铺是步骤3,对于非淘宝店铺是步骤2 // 注意:这里只检查 node_id,不依赖奇门授权 $current_step = $is_taobao ? 3 : 2; $status_text = '待绑店铺'; $step_text = '请完成店铺绑定'; // 如果是商家自研对接(openapi),使用 bindNodeId 页面,否则使用 apply_bindrelation iframe if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=bind'; } else { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=apply_bindrelation&shop_id=' . $shop_id; } } else { // 已绑定节点的情况 // 对于 openapi:仍然使用 bindNodeId 页面,传递 unbind,用于展示/解绑 if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=unbind'; // 当前步骤仍保持在店铺绑定步骤,方便查看配置 $current_step = $is_taobao ? 3 : 2; $status_text = '店铺绑定已完成'; $step_text = '可查看或取消绑定'; } else { // 所有步骤都已完成(对于淘宝店铺需要 node_id 和奇门授权都完成) $current_step = 4; $status_text = '已完成'; $step_text = ''; $bind_url = ''; } } // 特殊处理:如果用户请求特定步骤 // 步骤0(对接方式)是前提,必须完成才能进行其他步骤 // 如果对接方式未选择,无论用户请求哪个步骤,都强制跳转到步骤0 if (empty($adapter) && $step !== null && $step != 0) { // 对接方式未选择,强制跳转到步骤0 $step = 0; $current_step = 0; $status_text = '选择对接方式'; $step_text = '请先完成对接方式,才能进行后续步骤'; $bind_url = ''; } elseif ($step === null) { // 如果未指定 step 参数,使用计算出的 current_step(自动跳转到未完成的步骤) $step = $current_step; } elseif ($step == 0) { // 第0步:对接方式选择 $current_step = 0; $status_text = '选择对接方式'; $step_text = '请选择对接方式'; $bind_url = ''; } elseif ($step == 1) { // 第1步:企业认证 // 如果对接方式是 openapi,不需要企业认证 // 但是,如果用户直接点击步骤指示器中的"企业认证",应该允许显示步骤1的内容 // 只有在点击"下一步"按钮时,才自动跳过步骤1 // 这里直接显示步骤1的内容,允许用户查看 $current_step = 1; $status_text = '企业认证'; if (!$need_enterprise_auth) { // openapi 默认不强制企业认证,但应展示认证 iframe $step_text = '当前对接方式为商家自研对接,企业认证可选;如需认证请完成下方流程'; // 生成企业认证URL(与矩阵一致) $bind_url = base_enterprise::generate_auth_url(); } else { $step_text = '请完成企业认证'; // 生成企业认证URL(参考 system.php) $bind_url = base_enterprise::generate_auth_url(); } } elseif ($step == 2) { // 第2步:根据是否是淘宝店铺显示不同内容 $current_step = 2; if ($is_taobao) { // 淘宝店铺:步骤2是奇门授权 $qimen_channel_id = !empty($qimenChannel['channel_id']) ? $qimenChannel['channel_id'] : ''; if ($need_qimen) { // 需要奇门授权 if (!$is_qimen_binded) { // 奇门未绑定:显示待绑定状态 $status_text = '待绑奇门'; $step_text = '请完成奇门绑定授权'; // 使用channel控制器的apply_bindrelation方法 $bind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; } else { // 奇门已绑定:显示已完成状态,但允许查看第2步 $status_text = '奇门授权已完成'; $step_text = '奇门授权已完成,可以继续下一步'; // 已授权也保持加载同一授权页,方便复查/重授权 $bind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; } } else { // 商家自研:奇门为可选,但若未授权且有渠道,仍提供授权 iframe if (!$is_qimen_binded && $qimen_channel_id) { $status_text = '待绑奇门(可选)'; $step_text = '当前为商家自研对接,奇门授权可选;如需授权请完成下方流程'; $bind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; } elseif (!$is_qimen_binded) { // 无渠道可授权 $status_text = '奇门授权(可选)'; $step_text = '当前未配置奇门渠道,如需使用奇门功能,请联系管理员配置'; $bind_url = ''; } else { $status_text = '奇门授权已完成(可选)'; $step_text = '奇门授权已完成,可以继续下一步'; // 已授权也保持加载同一授权页,方便复查/重授权 $bind_url = 'index.php?app=channel&ctl=admin_channel&act=apply_bindrelation&p[]=' . $qimen_channel_id; } } } else { // 非淘宝店铺:步骤2是店铺绑定(只检查 node_id) if ($is_node_binded) { $status_text = '店铺绑定已完成'; $step_text = '可查看或取消绑定'; if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=unbind'; } else { // 如果已有节点且非自研,不加载绑定页面 $bind_url = ''; } } else { $status_text = '待绑店铺'; $step_text = '请完成店铺绑定'; // 如果是商家自研对接(openapi),使用 bindNodeId 页面,否则使用 apply_bindrelation iframe if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=bind'; } else { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=apply_bindrelation&shop_id=' . $shop_id; } } } } elseif ($step == 3) { // 第3步:仅淘宝店铺有步骤3(店铺绑定) if ($is_taobao) { // 淘宝店铺:步骤3是店铺绑定(只检查 node_id,不依赖奇门授权) $current_step = 3; if ($is_node_binded) { $status_text = '店铺绑定已完成'; $step_text = '可查看或取消绑定'; if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=unbind'; } else { $bind_url = ''; } } else { $status_text = '待绑店铺'; $step_text = '请完成店铺绑定'; // 如果是商家自研对接(openapi),使用 bindNodeId 页面,否则使用 apply_bindrelation iframe if ($adapter == 'openapi') { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=bindNodeId&p[0]=' . $shop_id . '&p[1]=bind'; } else { $bind_url = 'index.php?app=ome&ctl=admin_shop&act=apply_bindrelation&shop_id=' . $shop_id; } } } else { // 非淘宝店铺:步骤3不存在,自动跳转到第4步(完成页面) $step = 4; $current_step = 4; $status_text = '已完成'; $step_text = ''; $bind_url = ''; } } elseif ($step == 4) { // 第4步:完成页面 $current_step = 4; // 检查所有步骤是否完成(用于判断是否真正完成) $all_steps_completed = true; $incomplete_steps = array(); // 步骤0:对接方式 if (empty($adapter)) { $all_steps_completed = false; $incomplete_steps[] = array('step' => 0, 'name' => '对接方式'); } // 步骤1:企业认证(如果不需要企业认证,跳过) if ($need_enterprise_auth && !$is_certified) { $all_steps_completed = false; $incomplete_steps[] = array('step' => 1, 'name' => '企业认证'); } // 步骤2:对于淘宝店铺是奇门授权,对于非淘宝店铺是店铺绑定 if ($is_taobao) { if ($need_qimen && !$is_qimen_binded) { $all_steps_completed = false; $incomplete_steps[] = array('step' => 2, 'name' => '奇门授权'); } } else { if (!$is_node_binded) { $all_steps_completed = false; $incomplete_steps[] = array('step' => 2, 'name' => '店铺绑定'); } } // 步骤3:对于淘宝店铺是店铺绑定 if ($is_taobao && !$is_node_binded) { $all_steps_completed = false; $incomplete_steps[] = array('step' => 3, 'name' => '店铺绑定'); } if ($all_steps_completed) { $status_text = '已完成'; $step_text = ''; $is_completed = true; // 所有步骤都完成 } else { // 有未完成的步骤,列出未完成项 $status_text = '未完成'; $step_names = array(); foreach ($incomplete_steps as $incomplete) { $step_names[] = $incomplete['name']; } $step_text = '以下步骤尚未完成:' . implode('、', $step_names); $is_completed = false; // 有未完成的步骤 } $bind_url = ''; } elseif ($step > $current_step) { // 如果URL参数中的step与当前实际步骤不符,进行调整 // 但第0步、第1步和第2步、第3步已经在上面特殊处理了,允许用户访问任何步骤 // 不进行自动调整,允许用户访问任何步骤 } // 判断是否所有步骤都已完成(用于显示"完成"按钮) // 判断逻辑:如果当前步骤是最后一步,或者所有必需的步骤都已完成,则显示"完成"按钮 $is_completed = false; if ($step == 4) { // 第4步肯定是完成状态 $is_completed = true; } elseif ($step == 3 && $is_taobao) { // 淘宝店铺:第3步(店铺绑定)是最后一步,应该显示完成按钮 $is_completed = true; } elseif ($step == 2 && !$is_taobao) { // 非淘宝店铺:第2步(店铺绑定)是最后一步,应该显示完成按钮 $is_completed = true; } // 计算每个步骤的实际完成状态(用于步骤指示器显示) // 如果对接方式是 openapi,步骤1(企业认证)自动标记为已完成 // 对于淘宝店铺:步骤2是奇门授权,步骤3是店铺绑定 // 对于非淘宝店铺:步骤2是店铺绑定,步骤3不存在 // 注意:步骤3(店铺绑定)的完成状态只检查 node_id,不依赖奇门授权 // 步骤完成态(用于指示器显示):openapi 时不自动勾选奇门,避免未绑定显示完成 if ($is_taobao) { if ($adapter == 'openapi') { $step2_completed = $is_qimen_binded; // 可选,但未绑定不打勾 } else { $step2_completed = $need_qimen ? $is_qimen_binded : true; } } else { $step2_completed = $is_node_binded; } $step_completed = array( 0 => !empty($adapter), // 步骤0:对接方式已选择 // 不再将可选认证默认标绿,只有真实完成才标记完成 1 => $is_certified, 2 => $step2_completed, // 步骤2:淘宝店铺是奇门授权(openapi 不自动完成),非淘宝店铺是店铺绑定 3 => $is_taobao ? $is_node_binded : false, // 步骤3:淘宝店铺是店铺绑定(只检查 node_id),非淘宝店铺不存在 ); // 获取店铺绑定信息(如果有节点,即使奇门未授权也显示节点信息) $bind_info = array(); if ($is_node_binded) { // 节点ID $bind_info['node_id'] = $shop['node_id']; // 节点类型 $bind_info['node_type'] = $shop['node_type']; // 店铺名称 $bind_info['shop_name'] = !empty($shop['name']) ? $shop['name'] : (!empty($shop['shop_name']) ? $shop['shop_name'] : ''); // 授权到期时间(从 addon 字段中获取) $addon = !empty($shop['addon']) ? (is_string($shop['addon']) ? unserialize($shop['addon']) : $shop['addon']) : array(); $bind_info['expire_time'] = ''; if (!empty($addon['session_expire_time'])) { $bind_info['expire_time'] = $addon['session_expire_time']; } } // 设置页面数据 $finder_id = isset($_GET['finder_id']) ? $_GET['finder_id'] : ''; $this->pagedata['shop_id'] = $shop_id; $this->pagedata['shop'] = $shop; $this->pagedata['shop_name'] = $shop['shop_name']; $this->pagedata['shop_url'] = $shop['shop_url']; $this->pagedata['step'] = $step; $this->pagedata['current_step'] = $current_step; $this->pagedata['status_text'] = $status_text; $this->pagedata['step_text'] = $step_text; $this->pagedata['bind_url'] = $bind_url; $this->pagedata['need_qimen'] = $need_qimen; $this->pagedata['adapter'] = $adapter; $this->pagedata['is_taobao'] = $is_taobao; $this->pagedata['finder_id'] = $finder_id; $this->pagedata['is_completed'] = $is_completed; $this->pagedata['step_completed'] = $step_completed; // 未完成步骤列表(如果存在) $this->pagedata['incomplete_steps'] = isset($incomplete_steps) ? $incomplete_steps : array(); // 店铺绑定信息(如果已绑定) $this->pagedata['bind_info'] = $bind_info; $this->pagedata['is_node_binded'] = $is_node_binded; // 节点绑定状态(只检查 node_id) $this->pagedata['is_shop_binded'] = $is_shop_binded; // 店铺绑定状态(对于淘宝店铺需要同时满足 node_id 和奇门授权) // 奇门渠道信息 $this->pagedata['is_qimen_binded'] = $is_qimen_binded; $this->pagedata['qimen_channel'] = $qimenChannel; $this->pagedata['secret_key_display'] = $secretKeyDisplay; $this->pagedata['qimen_rebind_url'] = $qimen_rebind_url; $this->pagedata['qimen_channel_id'] = $qimen_channel_id; $this->pagedata['is_super'] = $is_super; // 系统节点与证书信息 $this->pagedata['system_node_id'] = $system_node_id; $this->pagedata['system_certificate_id'] = $system_certificate_id; // 企业信息 $this->pagedata['ent_id'] = $entId; $this->pagedata['ent_ac'] = $entAc; $this->pagedata['ent_email'] = $entEmail; $this->pagedata['is_certified'] = $is_certified; $this->pagedata['need_enterprise_auth'] = $need_enterprise_auth; // 是否需要企业认证(openapi 不需要) // 渲染模板 $this->display('admin/shop/bind_guide.html'); } function apply_bindrelation($app_id = 'ome', $callback = '', $api_url = '', $show_type = 'shop|shopex') { $Certi = base_certificate::get('certificate_id'); $Token = base_certificate::get('token'); $Node_id = base_shopnode::node_id($app_id); $token = $Token; $sess_id = kernel::single('base_session')->sess_id(); $apply['certi_id'] = $Certi; if ($Node_id) $apply['node_idnode_id'] = $Node_id; $apply['sess_id'] = $sess_id; $apply['certi_ac'] = base_certificate::getCertiAC($apply); $Ofunc = kernel::single('ome_rpc_func'); $app_xml = $Ofunc->app_xml(); $api_v = $app_xml['api_ver']; //给矩阵发送session过期的回打地址。 $sess_callback = kernel::base_url(true) . kernel::url_prefix() . '/openapi/ome.shop/shop_session'; // 如果callback为空,则使用默认回调地址 if (empty($callback)) { $callback = kernel::openapi_url('openapi.ome.shop', 'shop_callback', array('shop_id' => $_GET['shop_id'])); } // 如果api_url为空,则使用默认api_url if (empty($api_url)) { $api_url = kernel::base_url(true) . kernel::url_prefix() . '/api'; } $params = array( 'source' => 'apply', 'api_v' => $api_v, 'certi_id' => $apply['certi_id'], 'node_id' => $apply['node_idnode_id'], 'sess_id' => $apply['sess_id'], 'certi_ac' => $apply['certi_ac'], 'callback' => $callback, 'api_url' => $api_url, 'sess_callback' => $sess_callback, 'show_type' => $show_type, 'version_source' => 'onex-oms',//识别唯品会JIT绑定标识 ); // 检测绑定状态(针对淘宝店铺) $bind_step = 1; // 默认第一步:绑定店铺 $shop_id = isset($_GET['shop_id']) ? $_GET['shop_id'] : null; $qimen_channel_bind_status = false; // 检查奇门channel是否已绑定(无论是否有shop_id都要检查) $channelMdl = app::get('channel')->model('channel'); $qimenChannel = $channelMdl->getList('channel_id,node_id', array('channel_type' => 'qimen'), 0, 1); $qimen_channel_id = null; if (!empty($qimenChannel)) { $qimen_channel_id = $qimenChannel[0]['channel_id']; if (!empty($qimenChannel[0]['node_id'])) { $qimen_channel_bind_status = true; } } $bind_type = ''; if ($shop_id) { $oShop = $this->app->model("shop"); $shop = $oShop->dump($shop_id, 'node_id,node_type,shop_type'); if ($shop) { // 将 shop_type 赋值给 bind_type if (!empty($shop['shop_type'])) { $bind_type = $shop['shop_type']; } // 检测是否已完成第一步:店铺绑定(淘系店铺:淘宝/天猫) if (!empty($shop['node_id']) && in_array($shop['node_type'], array('taobao', 'tmall'))) { $bind_step = 2; // 进入第二步:绑定奇门ERP } } } // 将 bind_type 添加到 params 中 if ($bind_type) { $params['bind_type'] = $bind_type; } $finder_id = isset($_GET['finder_id']) ? $_GET['finder_id'] : ''; $this->pagedata['bind_step'] = $bind_step; $this->pagedata['shop_id'] = $shop_id; $this->pagedata['qimen_channel_bind_status'] = $qimen_channel_bind_status; $this->pagedata['qimen_channel_id'] = $qimen_channel_id; $this->pagedata['finder_id'] = $finder_id; $this->pagedata['qimen_apply_url'] = 'https://open.taobao.com/docV3.htm?docId=109580&docType=1&source=search'; $this->pagedata['license_iframe_url'] = MATRIX_RELATION_URL . '?' . http_build_query($params); // $this->pagedata['license_iframe'] = ''; $this->display('admin/system/apply_terminal.html'); } /* * 查看绑定关系 */ function view_bindrelation() { $Certi = base_certificate::get('certificate_id'); $Token = base_certificate::get('token'); $Node_id = base_shopnode::node_id('ome'); $token = $Token; $sess_id = kernel::single('base_session')->sess_id(); $apply['certi_id'] = $Certi; $apply['node_idnode_id'] = $Node_id; $apply['sess_id'] = $sess_id; $apply['certi_ac'] = base_certificate::getCertiAC($apply); $Ofunc = kernel::single('ome_rpc_func'); $app_xml = $Ofunc->app_xml(); $api_v = $app_xml['api_ver']; $callback = urlencode(kernel::openapi_url('openapi.ome.shop', 'shop_callback', array())); $api_url = kernel::base_url(true) . kernel::url_prefix() . '/api'; $api_url = urlencode($api_url); $op_id = kernel::single('desktop_user')->get_login_name(); $op_user = kernel::single('desktop_user')->get_name(); $params = '&op_id=' . $op_id . '&op_user=' . $op_user; $show_alipay_subscribe_auth = 0; if (app::get('finance')->is_installed()) { $show_alipay_subscribe_auth = 1; } $params = array( 'op_id' => $op_id, 'op_user' => $op_user, 'source' => 'accept', 'show_alipay_subscribe_auth' => $show_alipay_subscribe_auth, 'api_v' => $api_v, 'certi_id' => $apply['certi_id'], 'node_id' => $Node_id, 'sess_id' => $apply['sess_id'], 'certi_ac' => $apply['certi_ac'], 'callback' => $callback, 'api_url' => $api_url, 'show_type' => 'shop|shopex|pay', ); echo sprintf('