prod_is_dandianpu()) { $dandianpu_mini = 1; } else { $lianmeng_mini = 1; } } elseif ($is_serve) { } else { $store = \app\models\Store::findOne(['id' => $store_id]); if($store->business_model != 1){ $lianmeng_mini = 1; } $self_mini = \app\models\Option::get('self_mini', $store_id, 'store', 0)['value']; if (\Yii::$app->prod_is_dandianpu() && !$self_mini) { $dandianpu_mini = 1; } } // 独立部署 if (!is_open_platform()) { $wechat_config = \app\models\WechatConfig::findOne(['store_id' => $store_id, 'type' => 1, 'is_delete' => 0]); if ($type === self::TYPE_OFFICIAL) { $wechat_config = \app\models\WechatConfig::findOne(['store_id' => $store_id, 'type' => \app\models\WechatConfig::TYPE_CONFIG_MP, 'is_delete' => 0]); } if ($wechat_config) { $ext = $wechat_config->ext ? json_decode($wechat_config->ext, true) : []; $config =[]; $config['app_id'] = $wechat_config->app_id; $config['secret'] = $wechat_config->app_secret; $ext['token'] && $config['token'] = $ext['token']; $ext['aes_key'] && $config['aes_key'] = $ext['aes_key']; $config['response_type'] = 'array'; $app = Factory::miniProgram($config); if ($type === self::TYPE_OFFICIAL) { $app = Factory::officialAccount($config); } } }elseif($dandianpu_mini){ $config =[]; $config['app_id'] = Option::get("one_store_wechat_appid", 0, 'saas')['value']; $config['secret'] = Option::get("one_store_wechat_secret", 0, 'saas')['value']; $config['response_type'] = 'array'; $app = Factory::miniProgram($config); if ($type == self::TYPE_OFFICIAL) { $config['app_id'] = Option::get("one_store_wechat_official_appid", 0, 'saas')['value']; $config['secret'] = Option::get("one_store_wechat_official_secret", 0, 'saas')['value']; $config['token'] = Option::get("one_store_wechat_official_token", 0, 'saas', '')['value']; $config['response_type'] = 'array'; $app = Factory::officialAccount($config); } }elseif($lianmeng_mini){ $config =[]; $config['app_id'] = Option::get("platform_appid", 0, 'saas')['value']; $config['secret'] = Option::get("platform_key", 0, 'saas')['value']; $config['response_type'] = 'array'; $app = Factory::miniProgram($config); }elseif($is_serve){ $config =[]; $config['app_id'] = Option::get("platform_mch_appid", 0, 'saas')['value']; $config['secret'] = Option::get("platform_mch_key", 0, 'saas')['value']; $config['response_type'] = 'array'; $app = Factory::miniProgram($config); } else { if ($type === self::TYPE_OFFICIAL) { $wechat_config = \app\models\WechatConfig::findOne(['store_id' => $store_id, 'type' => \app\models\WechatConfig::TYPE_CONFIG_MP, 'is_delete' => 0]); if ($wechat_config) { $ext = $wechat_config->ext ? json_decode($wechat_config->ext, true) : []; $config = []; $config['app_id'] = $wechat_config->app_id; $config['secret'] = $wechat_config->app_secret; $ext['token'] && $config['token'] = $ext['token']; $ext['aes_key'] && $config['aes_key'] = $ext['aes_key']; $config['response_type'] = 'array'; $app = Factory::officialAccount($config); } goto app_end; } video_shop: $verify_ticket = Option::get("component_verify_ticket",0,'saas')['value']; if (!empty($verify_ticket)) { $config_ = [ 'app_id' => Option::get("platform_third_appid", 0, 'saas')['value'], 'secret' => Option::get("platform_third_secret", 0, 'saas')['value'], 'token' => Option::get("platform_token", 0, 'saas')['value'], 'aes_key' => Option::get("platform_encodingAesKey", 0, 'saas')['value'] ]; $openPlatform = Factory::openPlatform($config_); } $where = [ 'store_id' => $store_id, 'is_cancle' => 0 ]; if ($type == self::TYPE_VIDEO_SHOP) { $where = array_merge($where, [ 'fuwu_type' => 1 ]); } if ($mini_id) { $where = [ 'id' => $mini_id, 'is_cancle' => 0 ]; } $store_mini_list = \app\models\StoreMini::find()->where($where) ->select('id, mini_up, appid, authorizer_refresh_token, is_use, is_self, app_secret')->orderBy(['is_use' => SORT_ASC, 'mini_up' => SORT_DESC])->asArray()->all(); $wechat_config = []; foreach ($store_mini_list as $item) { if (intval($item['is_use']) === 1) { $wechat_config = $item; break; } if (intval($item['mini_up']) === 5) { $wechat_config = $item; break; } if (intval($item['mini_up']) === 2) { $wechat_config = $item; break; } if (intval($item['mini_up']) === 1) { $wechat_config = $item; break; } if (intval($item['mini_up']) === -1) { $wechat_config = $item; break; } if ($mini_id) { $wechat_config = $item; } } if ($wechat_config) { self::$mini_id = $wechat_config['id']; if (intval($wechat_config['is_self']) && $wechat_config['app_secret']) { $config =[]; $config['app_id'] = $wechat_config['appid']; $config['secret'] = $wechat_config['app_secret']; $config['response_type'] = 'array'; $app = Factory::miniProgram($config); } else { if (!empty($openPlatform)) { $app = $openPlatform->miniProgram($wechat_config['appid'], $wechat_config['authorizer_refresh_token']); } } } } app_end: return $app; } }