basePath . "/utils/Alipay/alipaySdk/aop/AopClient.php"; class AlipayThirdForm extends Model { /** * @var mixed */ public $alipay_aes_key; public $appid; public $method; public $sign_type; public $sign; public $version = "1.0"; public $charset; public $biz_content; public $timestamp; public $auth_code; public $baseUrl = "https://openapi.alipay.com/gateway.do"; public $private_key; public $public_key; public $license_no; //营业执照编号 public $license_pic; //营业执照照片 public $template_version; //模版版本号 public $ext; //ext public $template_id; //模版ID public $app_version; //版本号 public $bundle_id; //小程序投放的端参数 public $AppName; public $AppEnglishName; public $AppSlogan; public $AppLogo; public $AppDesc; public $ServicePhone; public $ServiceEmail; public $MiniCategoryIds; public $page_num; public $page_size; public $auditData; //审核资料 public $is_filter; public $gray_strategy; public $route_url; public $mode; public $page_redirection; public $route_pattern; public $mini_id; public $version_id; public $role; public $logon_id; public $license_name; public $license_date; public $is_long_effective; public $alipay_account; public $legal_personal_name; public $contact_name; public $merchant_id; public $bind_store_id; public $apply_msg; public $store_id; public $is_use; public $fun = 'setPicture'; public $params_data; public $id; public $status; public $delivery_booth_code; /*支付回调url*/ private static $notify_url = 'alipay/notify'; public function rules() { return [ [["is_use","page_num", "page_size", 'is_filter', 'gray_strategy', 'version_id', 'role', 'is_long_effective', 'merchant_id', "bind_store_id", 'store_id', 'id', 'delivery_booth_code', 'status'], 'integer'], [ [ "appid", "method", "sign_type", "sign", "version", "charset", "biz_content", "timestamp", "auth_code", "baseUrl", "license_no", "license_pic", "template_version", "ext", "template_id", "app_version", "bundle_id", "AppName", "AppEnglishName", "AppSlogan", "AppLogo", "AppDesc", "ServicePhone", "ServiceEmail", "MiniCategoryIds", "auditData", "route_pattern", "page_redirection", "mode", "route_url", "page_num", "page_size", "gray_strategy", "url_param", "query_param", "describe", "color", "size", "mini_id", "logon_id", "license_name", "license_date", "apply_msg" ], 'string' ], [['params_data'], 'safe'] ]; } public function __construct($config = []) { parent::__construct($config); $this->appid = Option::get("alipay_appid", 0, 'saas')['value']; $this->timestamp = date("Y-m-d H:i:s"); $this->sign_type = "RSA2"; $this->charset = "utf-8"; $this->private_key = Option::get("alipay_app_private_key", 0, 'saas')['value']; $this->public_key = Option::get("alipay_public_key", 0, 'saas')['value']; $this->alipay_aes_key = Option::get("alipay_aes_key", 0, 'saas')['value']; if(is_open_platform()){ // $aop->appId = Option::get("alipay_appid",0,'saas')['value'];; // $aop->rsaPrivateKey = Option::get("alipay_app_private_key",0,'saas')['value']; // $aop->alipayrsaPublicKey=Option::get("alipay_public_key",0,'saas')['value']; }else{ $value = Option::get(Option::OPTOPN_KEY, $this->store_id ?? get_store_id(), 'alipay')['value']; $conf = json_decode($value, true); $this->appid = $conf['app_id']; $this->private_key = $conf['app_private_key']; $this->public_key = $conf['alipay_public_key']; } } /** * 公共参数请求 * @return \$1|false|mixed|\SimpleXMLElement * @throws \Exception * * */ public function miniCommon($request, $is_hidden_biz_content = 0, $id = 0, $is_hidden_token = 0, $is_new = 0) { try { $auth_token = ""; $mini_id = $this->mini_id; if (!empty($this->bind_store_id)) { $StoreAliMini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id, 'is_cancel' => 0, 'is_use' => 1])->select('id')->orderBy('id desc')->one(); $mini_id = $StoreAliMini->id; } if (!empty($id != false ? $id : $mini_id)) { $mini = StoreAliMini::findOne($id != false ? $id : $mini_id); $auth_token = $mini->auth_token; } if (empty($auth_token) && $is_new == 1) { $auth_token = Option::get("ali_template_token", 0, 'saas')['value']; } //换取token $aop = new AopClient(); $aop->gatewayUrl = $this->baseUrl; $aop->appId = $this->appid; $aop->rsaPrivateKey = $this->private_key; $aop->alipayrsaPublicKey = $this->public_key; $aop->encryptKey = $this->alipay_aes_key; $aop->encryptType = "AES"; $aop->apiVersion = '1.0'; $aop->signType = $this->sign_type; $aop->postCharset = $this->charset; if ($is_hidden_biz_content == 0) { $request->setBizContent($this->biz_content); } if (!empty($auth_token) && empty($is_hidden_token)) { $result = $aop->execute($request, null, $auth_token); } else { $result = $aop->execute($request); } \Yii::error($result); $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; return $result->$responseNode; } catch (\Exception $e) { return (object)[ 'sub_msg' => $e->getMessage() ]; } } /** * 传递授权回调参数 * @return array */ public function getParams() { $uri_data = urlencode(json_encode([ 'platformCode' => 'O', 'taskType' => 'INTERFACE_AUTH', 'agentOpParam' => [ 'redirectUri' => \Yii::$app->request->hostInfo . '/index.php/alipay/token', 'appTypes' => ['TINYAPP'], 'isvAppId' => $this->appid, 'state' => base64_encode(get_store_id() . '_mini') ] ], JSON_UNESCAPED_UNICODE)); $uri = "https://b.alipay.com/page/message/tasksDetail?bizData=" . $uri_data; return [ 'code' => 0, 'url' => $uri, 'msg' => "获取成功" ]; } /** * 保存授权码 * 获取保存AuthToken以及小程序信息 * 同时获取aes密钥 * 通过授权码AuthCode换取AuthToken * */ public function setAuthCode() { try { $param = [ "grant_type" => "authorization_code", "code" => $this->auth_code ]; $store_id = $this->store_id; $this->biz_content = json_encode($param); $this->method = "alipay.open.auth.token.app"; $request = new AlipayOpenAuthTokenAppRequest(); $result = $this->miniCommon($request, 0, 0, 0, 0); \Yii::error($result); $token = $result->tokens[0]; if (!empty($result->code) && $result->code == 10000) { $mini = StoreAliMini::find()->where(['auth_app_id' => $token->auth_app_id, 'is_cancel' => 0])->one(); if (empty($mini)) { $mini = new StoreAliMini(); $mini->store_id = ($store_id ?: get_store_id()); $mini->auth_app_id = $token->auth_app_id; } if ((int)$mini->store_id !== (int)($store_id ?: get_store_id())) { throw new \Exception('已经授权给本平台的其他商城,不可重复授权'); } $mini->auth_code = $this->auth_code; $mini->userid = $token->user_id; $mini->is_cancel = 0; $mini->auth_token = $token->app_auth_token; $mini->refresh_token = json_encode([ 'app_refresh_token' => $token->app_refresh_token, 'end_time' => time() * 1 + $token->re_expires_in ]); $res = $mini->save(); if ($res) { //获取应用aes密钥 $res = $this->aesAuth(0, $mini->id); if ($res['code'] === 0) { $res = $this->getAppTokenInfo($mini->id); if ($res['code'] === 0) { $res = $this->updateMiniVersion($mini->id); if ($res['code'] === 0) { $res = $this->getMiniBaseInfo($mini->id); if ($res['code'] !== 0) { throw new \Exception($res['msg']); } } else { throw new \Exception($res['msg']); } } else { throw new \Exception($res['msg']); } } else { throw new \Exception($res['msg']); } } else { throw new \Exception($mini->errors); } } else { throw new \Exception($result->sub_msg); } return [ 'code' => 0, 'msg' => "success" ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() . $e->getLine() ]; } } /** * 授权应用aes密钥设置/查询 */ public function aesAuth($is_get = 0, $id = 0) { $t = \Yii::$app->db->beginTransaction(); try { $store_id = $this->store_id; $mini = StoreAliMini::findOne($id); $auth_app_id = Option::get("ali_template_appid", 0, 'saas')['value'];; if (!empty($mini)) { $auth_app_id = $mini->auth_app_id; } if (empty($auth_app_id)) { throw new \Exception("请先配置小程序信息"); } \Yii::error($auth_app_id); $param = [ "merchant_app_id" => $auth_app_id ]; \Yii::error($param); $this->biz_content = json_encode($param); $this->method = "alipay.open.auth.app.aes.set"; $request = new AlipayOpenAuthAppAesSetRequest(); if ($is_get == 1) { $this->method = "alipay.open.auth.app.aes.get"; $request = new AlipayOpenAuthAppAesGetRequest(); } if (empty($id)) { $is_new = 1; } else { $is_new = 0; } $result = $this->miniCommon($request, 0, $id, 1, $is_new); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { if (!empty($id) && !empty($mini)) { $mini->aes_key = $result->aes_key; } else { Option::set('ali_template_aes', $result->aes_key, 0, 'saas'); return [ 'code' => 0, 'msg' => "获取成功", 'data' => $result->aes_key ]; } $res = $mini->save(); if ($res) { $t->commit(); $data['aes_key'] = $mini->aes_key; $data['app_id'] = $mini->auth_app_id; $data['alipay_public_key'] = ""; $data['app_public_key'] = ""; $data['app_private_key'] = ""; $data['user_id'] = $mini->userid; $data['name'] = $mini->license_name; $bind_store_id = $mini->store_id; $res = Option::set(Option::OPTOPN_KEY, Json::encode($data), $bind_store_id, 'alipay'); if ($res) { \Yii::$app->cache->delete('alipay_config_cache_' . !empty($this->bind_store_id) ? $this->bind_store_id : ($store_id ?: get_store_id())); \Yii::$app->cache->set('alipay_config_cache_' . !empty($this->bind_store_id) ? $this->bind_store_id : ($store_id ?: get_store_id()), Json::encode($data)); } return [ 'code' => 0, 'msg' => "操作成功" ]; } else { throw new \Exception($mini->errors); } } else { throw new \Exception($result->sub_msg . $result->code); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 个人账户升级为个体工商户 */ public function updateBussiness($id = 0) { $t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($id != 0 ? $id : $this->mini_id); if (empty($mini)) { throw new \Exception("授权失败"); } $mini->license_no = $this->license_no; $mini->license_pic = $this->license_pic; $index = strpos($this->license_pic, \Yii::$app->request->hostName); $len = $index + strlen(\Yii::$app->request->hostName); $license_pic = substr($this->license_pic, $len); $license_pic = $this->image2Base64(\Yii::$app->basePath . $license_pic); if ($license_pic == false) { throw new \Exception("图片转Base64失败"); } $param = [ "license_no" => $this->license_no, "license_pic" => $license_pic ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.individual.business.certify"; $request = new AlipayOpenMiniIndividualBusinessCertifyRequest(); $request->setLicenseNo($this->license_no); $request->setLicensePic($license_pic); $result = $this->miniCommon($request, 1); if (!empty($result->code) && $result->code == 10000) { $mini->is_merchant = $result->certify_result ? 1 : 0; $res = $mini->save(); if ($res) { $t->commit(); return [ 'code' => 0, 'msg' => "操作成功" ]; } else { throw new \Exception($mini->errors); } } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 查询某个应用授权AppAuthToken的授权信息 */ public function getAppTokenInfo($id) { $t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ "app_auth_token" => $mini->auth_token ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.auth.token.app.query"; $request = new AlipayOpenAuthTokenAppQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $t->commit(); return [ 'code' => 0, 'msg' => "获取成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序基于模板上传版本 */ public function updateMiniVersion($id = 0) { //$t = \Yii::$app->db->beginTransaction(); try { $store_id = $this->store_id; $id = !empty($id) ? $id : $this->mini_id; if (!empty($this->bind_store_id)) { $StoreAliMini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); $id = $StoreAliMini->id; } $mini = StoreAliMini::findOne($id); $store_id = $mini->store_id; $version = StoreAliMiniVersion::find()->where(['mini_id' => $id]) ->orderBy("create_time desc") ->asArray() ->one(); if ($version['is_submit'] == 1) { $res = $this->miniAuditCancel(); if ($res['code'] !== 0) { throw new \Exception("有版本代码正在审核"); } } if ($version['is_submit'] == 2 || $version['is_submit'] == 3) { $res = $this->miniVersionCancel(); if ($res['code'] !== 0) { throw new \Exception("有版本代码需要处理"); } } if (empty($version)) { $app_version = date('y') . '.' . sprintf("%03d", $id) . '.' . sprintf("%03d", 1); } else { \Yii::error("版本号:" . $version['template_version']); $app_version = substr($version['template_version'], 7); \Yii::error("版本号:" . $app_version); $app_version = date('y') . '.' . sprintf("%03d", $id) . '.' . sprintf("%03d", $app_version + 1); } \Yii::error("版本号:" . $app_version); if (empty($mini)) { throw new \Exception("没有进行授权"); } $self_mini = Option::get('self_mini', $store_id ?: get_store_id(), 'store', 0)['value']; $ext = json_encode([ 'extEnable' => true, 'ext' => [ 'self_mini' => $self_mini ? 1 : 0, 'shopId' => $this->appid, 'mini_id' => $id, 'store_id' => ($store_id ?: get_store_id()), 'apiurl' => "https://" . \Yii::$app->request->hostName ] ]); $param = [ 'ext' => $ext, 'template_id' => Option::get("ali_template_appid", 0, 'saas')['value'], 'app_version' => $app_version, ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.upload"; $request = new AlipayOpenMiniVersionUploadRequest(); $result = $this->miniCommon($request, 0, $id); if (!empty($result->code) && $result->code == 10000) { $MiniVersion = new StoreAliMiniVersion(); $MiniVersion->mini_id = $id; $MiniVersion->template_version = $app_version; $MiniVersion->create_time = time(); $MiniVersion->is_up = 1; $res = $MiniVersion->save(); if ($res) { $this->setSafeDomain($id); $store_version = StoreAliMiniVersion::find()->where(['mini_id' => $id]) ->andWhere(['<>', 'id', $MiniVersion->id]) ->orderBy("create_time desc") ->asArray()->all(); if ($store_version) { foreach ($store_version as $item) { $this->delMiniVersion($item['template_version']); } } //$t->commit(); return [ 'code' => 0, 'msg' => "构建成功", 'data' => $result, "res" => $MiniVersion->errors ]; } else { throw new \Exception(json_encode($MiniVersion->errors)); } } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { //$t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序查询版本构建状态 * alipay.open.mini.version.build.query */ public function getMiniStatus() { try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); } else { $mini_id = $this->mini_id; $mini = StoreAliMini::findOne($mini_id); } if (empty($mini)) { throw new \Exception("没有进行授权"); } $version = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); $param = [ 'app_version' => $version->template_version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.build.query"; $request = new AlipayOpenMiniVersionBuildQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "获取成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序查询版本列表 * alipay.open.mini.version.build.query */ public function getMiniVersionList() { try { $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $this->method = "alipay.open.mini.version.list.query"; $request = new AlipayOpenMiniVersionListQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "获取成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序删除版本 * alipay.open.mini.version.delete */ public function delMiniVersion($version = '') { //$t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($this->mini_id); $where = []; if ($version) { $where['template_version'] = $version; } $MiniVersion = StoreAliMiniVersion::find()->where(array_merge(['mini_id' => $this->mini_id], $where))->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $version ?: $MiniVersion->template_version, ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.delete"; $request = new AlipayOpenMiniVersionDeleteRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $MiniVersion->delete(); //$t->commit(); return [ 'code' => 0, 'msg' => "删除成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { //$t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序生成体验版 * alipay.open.mini.experience.create */ public function createMiniExperience() { $t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($this->mini_id); $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version, ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.experience.create"; $request = new AlipayOpenMiniExperienceCreateRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { StoreAliMiniVersion::updateAll(['is_experience' => 0, 'experience_url' => ''], ['and', ['<>', 'id', $MiniVersion->id], ['mini_id' => $this->mini_id]]); $res = $this->createMiniExperienceQrcode(); if ($res['code'] === 0) { $MiniVersion->is_experience = 1; $MiniVersion->experience_url = $res['url']; $MiniVersion->save(); $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $res['url'] ]; } else { throw new \Exception("获取体验码失败"); } } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 获取体验码 * alipay.open.mini.experience.query */ public function createMiniExperienceQrcode() { try { $mini = StoreAliMini::findOne($this->mini_id); $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version, 'bundle_id' => $this->bundle_id ?? "com.alipay.alipaywallet", ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.experience.query"; $request = new AlipayOpenMiniExperienceQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $msg = "获取成功"; if ($result->status == "expVersionPackaging") { $msg = "体验版打包中"; } elseif ($result->status == "notExpVersion") { $msg = "非体验版"; } return [ 'code' => 0, 'msg' => $msg, 'url' => $result->exp_qr_code_url ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序取消体验版 * alipay.open.mini.experience.create() */ public function createMiniExperienceCancel() { $t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($this->mini_id); $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.experience.cancel"; $request = new AlipayOpenMiniExperienceCancelRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $MiniVersion->is_experience = 0; $MiniVersion->experience_url = ""; $MiniVersion->save(); $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 查询小程序基础信息 * alipay.open.mini.baseinfo.query() */ public function getMiniBaseInfo($id = 0, $type = 0) { $t = \Yii::$app->db->beginTransaction(); try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); $id = $mini->id; } else { $mini = StoreAliMini::findOne($id != 0 ? $id : $this->mini_id); } if (empty($mini)) { throw new \Exception("没有进行授权"); } $this->method = "alipay.open.mini.baseinfo.query"; $request = new AlipayOpenMiniBaseinfoQueryRequest(); $result = $this->miniCommon($request, 1, $id != 0 ? $id : $this->mini_id); if (!empty($result->code) && $result->code == 10000) { if ($type === 0) { $mini->app_name = $result->app_name; $mini->app_desc = $result->app_desc; $mini->app_slogan = $result->app_slogan; $mini->app_english_name = $result->app_english_name; $mini->service_email = $result->service_email; $mini->service_phone = $result->service_phone; $mini->app_logo = $result->app_logo; } $mini->category_name = $result->category_names; $res = $mini->save(); if ($res) { $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result, 'category' => $result->category_names ]; } else { throw new \Exception("插入数据错误"); } } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序修改基础信息 * alipay.open.mini.baseinfo.modify(小程序修改基础信息) */ public function setMiniBaseInfo() { $t = \Yii::$app->db->beginTransaction(); try { $mini_id = $this->mini_id; if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); $mini_id = $mini->id; } else { $mini = StoreAliMini::findOne($mini_id); } if (empty($mini)) { throw new \Exception("没有进行授权"); } $mini_category_ids = ''; if (!empty($this->bind_store_id) && !empty($this->MiniCategoryIds)) { foreach ($this->MiniCategoryIds as $item) { $arr = []; foreach ($item as $child) { array_push($arr, $child['value']); } $str = implode('_', $arr); $mini_category_ids .= $str . ';'; } } else { $mini_category_ids = implode(';', $this->MiniCategoryIds); } $mini_category_ids = "XS1020_XS2167_XS3188"; $category_label = "购物_零售门店_综合零售门店"; $this->method = "alipay.open.mini.baseinfo.modify"; $request = new AlipayOpenMiniBaseinfoModifyRequest(); $mini->app_name = $this->AppName; $mini->app_english_name = $this->AppEnglishName; $mini->app_slogan = $this->AppSlogan; if (empty($this->bind_store_id)) { !empty($this->license_no) && $mini->license_no = $this->license_no; !empty($this->license_pic) && $mini->license_pic = $this->license_pic; !empty($this->license_name) && $mini->license_name = $this->license_name; !empty($this->is_long_effective) && $mini->is_long_effective = $this->is_long_effective; !empty($this->license_date) && $mini->license_date = $this->license_date; $mini->is_long_effective = !empty($mini->is_long_effective) ? 1 : 0; } $mini->app_logo = $this->AppLogo; $mini->app_desc = $this->AppDesc; $mini->service_phone = $this->ServicePhone; $mini->service_email = $this->ServiceEmail; $mini->mini_categoryIds = $mini_category_ids; $mini->category_data = json_encode($this->MiniCategoryIds); $mini->category_name = $category_label;//$category_label; $res = $mini->save(); if ($res) { if (empty($this->bind_store_id)) { $res = $this->updateBussiness($mini_id); if ($res['code'] !== 0) { throw new \Exception($res['msg']); } } \Yii::error($this->AppName); \Yii::error($this->AppEnglishName); \Yii::error($this->AppSlogan); \Yii::error($this->AppLogo); \Yii::error($this->AppDesc); \Yii::error($this->ServicePhone); \Yii::error($this->ServiceEmail); \Yii::error($this->MiniCategoryIds); $request->setAppName($this->AppName); //小程序应用名称。 $request->setAppEnglishName($this->AppEnglishName); //小程序应用英文名称。 $request->setAppSlogan($this->AppSlogan); //小程序应用简介 $request->setAppLogo("@" . $this->saveTempImage($this->AppLogo)); //小程序应用logo图标,图片格式必须为:png、jpeg、jpg,建议上传像素为180*180。 $request->setAppDesc($this->AppDesc); //小程序应用描述,20-200个字 $request->setServicePhone($this->ServicePhone); //小程序客服电话。 $request->setServiceEmail($this->ServiceEmail); //小程序客服邮箱。 $request->setMiniCategoryIds($mini_category_ids); //新小程序前台类目。格式为 第一个一级类目_第一个二级类目;第二个一级类目_第二个二级类目_第二个三级类目。详细类目可以通过 $result = $this->miniCommon($request, 1); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } throw new \Exception("信息保存失败"); } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 查询使用模板的小程序列表 * alipay.open.mini.template.usage.query(查询使用模板的小程序列表) */ // public function getTemplateUsage(){ // try { // $mini = StoreAliMini::find()->where(['store_id'=>get_store_id()])->one(); // if(empty($mini)){ // throw new \Exception("没有进行授权"); // } // $param = [ // 'template_id'=>$this->template_id, // 'page_num'=>$this->page_num, // 'page_size'=>$this->page_size, // 'template_version'=>$this->template_version, // 'bundle_id'=>$this->bundle_id, // ]; // $this->biz_content = json_encode($param); // $this->method = "alipay.open.mini.template.usage.query"; // $request = new AlipayOpenMiniTemplateUsageQueryRequest(); // $result = $this->miniCommon($request); // if(!empty($result->code)&&$result->code == 10000){ // return [ // 'code'=>0, // 'msg'=>"成功", // 'data'=>$result // ]; // }else{ // throw new \Exception($result->sub_msg); // } // }catch (\Exception $e){ // return [ // 'code'=>1, // 'msg'=>$e->getMessage() // ]; // } // } /** * 添加成员 * alipay.open.app.members.create(添加成员) */ public function miniAddMember() { try { $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $role = $this->role; switch ($role) { case 0: throw new \Exception("请选择身份"); break; case 1: $role = "DEVELOPER"; break; case 2: $role = "EXPERIENCER"; break; } $param = [ 'logon_id' => $this->logon_id, 'role' => $role ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.app.members.create"; $request = new AlipayOpenAppMembersCreateRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 删除成员 */ public function delMember() { try { $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'user_id' => '2088722902205229', 'role' => 'EXPERIENCER' ]; $this->biz_content = json_encode($param); $request = new AlipayOpenAppMembersDeleteRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch(\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 获取成员列表 */ public function getRoleList() { try { $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $role = $this->role; switch ($role) { case 0: throw new \Exception("请选择身份"); break; case 1: $role = "DEVELOPER"; break; case 2: $role = "EXPERIENCER"; break; } $param = [ 'role' => $role ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.app.members.query"; $request = new AlipayOpenAppMembersQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 获取审核资料 * */ public function getMiniApplyInfo() { $mini = StoreAliMini::find()->alias('sam') ->where(['sam.id' => $this->mini_id, 'samv.id' => $this->version_id]) ->select(" sam.id, sam.license_name, sam.license_date, sam.is_long_effective, sam.license_no, sam.license_pic, sam.mini_categoryIds, sam.app_name, sam.app_english_name, sam.app_slogan, sam.app_logo, sam.app_desc, sam.service_phone, sam.service_email, samv.mini_id, samv.id as version_id, samv.desc, samv.template_version as version ") ->leftJoin(['samv' => StoreAliMiniVersion::tableName()], 'sam.id = samv.mini_id') ->asArray() ->one(); return [ 'code' => 0, 'msg' => "获取成功", 'data' => $mini ]; } /** * 小程序提交审核 * alipay.open.mini.version.audit.apply(小程序提交审核) */ public function miniAuditApply() { $t = \Yii::$app->db->beginTransaction(); try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); } else { $mini = StoreAliMini::findOne($this->auditData['id']); } $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $mini->id])->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $this->method = "alipay.open.mini.version.audit.apply"; $request = new AlipayOpenMiniVersionAuditApplyRequest(); $auditData = $this->auditData; if (!empty($this->bind_store_id)) { $mini_category_ids = $auditData['mini_category_ids']; } else { $mini_category_ids = implode(';', $auditData['mini_category_ids']); } $auditData['version_desc'] = '商城当面付上线商城当面付上线商城当面付上线商城当面付上线商城当面付上线商城当面付上线商城当面付上线商城当面付上线'; !empty($auditData['service_phone']) && $request->setServicePhone($auditData['service_phone']); //小程序手机号 !empty($auditData['service_email']) && $request->setServiceEmail($auditData['service_email']); //小程序邮箱地址 $request->setVersionDesc($auditData['version_desc']); //小程序版本描述,30-500个字符。 $request->setRegionType("CHINA"); //小程序服务区 !empty($auditData['license_no']) && $request->setLicenseNo($auditData['license_no']); //营业执照号 !empty($auditData['mini_category_ids']) && $request->setMiniCategoryIds($mini_category_ids); !empty($auditData['license_name']) && $request->setLicenseName($auditData['license_name']); //营业执照名称 !empty($auditData['license_pic']) && $request->setFirstLicensePic("@" . $this->saveTempImage($auditData['license_pic'])); //营业执照 $request->setLicenseValidDate(!empty($auditData['is_long_effective']) ? '9999-12-31' : $auditData['license_date']); //营业执照有效期 $request->setAppVersion($MiniVersion->template_version); //小程序版本号 !empty($auditData['app_name']) && $request->setAppName($auditData['app_name']); //小程序名称 !empty($auditData['app_english_name']) && $request->setAppEnglishName($auditData['app_english_name']); //英文名称 // if (mb_strlen($auditData['app_slogan']) > 16) { // return [ // 'code' => 1, // 'msg' => '小程序功能描述字数不能超过16个' // ]; // } !empty($auditData['app_slogan']) && $request->setAppSlogan($auditData['app_slogan']); //小程序应用简介,一句话描述小程序功能 !empty($auditData['app_logo']) && $request->setAppLogo("@" . $this->saveTempImage($auditData['app_logo'])); //小程序logo图标 // if (mb_strlen($auditData['app_desc']) < 10 || mb_strlen($auditData['app_desc']) > 100) { // return [ // 'code' => 1, // 'msg' => '小程序应用描述字数在10-100个' // ]; // } !empty($auditData['app_desc']) && $request->setAppDesc($auditData['app_desc']); //小程序应用描述 // !empty($auditData['first_special_license_pic']) && $request->setFirstSpecialLicensePic($auditData['first_special_license_pic']); //特殊资质 if (!empty($auditData['other_data'])) { foreach ($auditData['other_data'] as $index => &$item) { if ($index === 0) { $request->setFirstSpecialLicensePic("@" . $this->saveTempImage($item)); } if ($index === 1) { $request->setSecondSpecialLicensePic("@" . $this->saveTempImage($item)); } if ($index === 2) { $request->setThirdSpecialLicensePic("@" . $this->saveTempImage($item)); } } } $mini->license_name = $auditData['license_name']; $mini->license_date = $auditData['license_date']; $mini->is_long_effective = $auditData['is_long_effective']; $mini->license_no = $auditData['license_no']; $mini->license_pic = $auditData['license_pic']; $mini->mini_categoryIds = $mini_category_ids; $mini->app_name = $auditData['app_name']; $mini->app_english_name = $auditData['app_english_name']; $mini->app_slogan = $auditData['app_slogan']; $mini->app_logo = $auditData['app_logo']; $mini->app_desc = $auditData['app_desc']; $mini->service_phone = $auditData['service_phone']; $mini->service_email = $auditData['service_email']; $mini->category_name = json_encode($auditData['mini_category_ids']); $mini->other_data = json_encode($auditData['other_data']); if (empty($this->bind_store_id)) { $res = $mini->save(); } else { $res = true; } if ($res) { $result = $this->miniCommon($request, 1, $mini->id); if (!empty($result->code) && $result->code != 10000) { throw new \Exception($result->sub_msg); } $MiniVersion->is_submit = 1; $res = $MiniVersion->save(); if ($res) { $t->commit(); return [ 'code' => 0, 'msg' => "开始审核", 'data' => $result, ]; } else { return $MiniVersion->errors; } } else { return $mini->errors; } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() . $e->getLine() . $e->getFile() ]; } } /** * 小程序撤销审核 * alipay.open.mini.version.audit.cancel(小程序撤销审核) */ public function miniAuditCancel() { $t = \Yii::$app->db->beginTransaction(); try { $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.audit.cancel"; $request = new AlipayOpenMiniVersionAuditCancelRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $MiniVersion->is_submit = 0; $MiniVersion->save(); $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序类目树查询 * alipay.open.mini.category.query(小程序类目树查询) */ public function getCategoryList() { try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id')->orderBy('id desc')->one(); } else { $mini = StoreAliMini::findOne($this->mini_id); } if (empty($mini)) { throw new \Exception("没有进行授权"); } $is_filter = $this->is_filter == 1; $param = [ "is_filter" => $is_filter ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.category.query"; $request = new AlipayOpenMiniCategoryQueryRequest(); $result = $this->miniCommon($request, 0, 0, 1); if (!empty($result->code) && $result->code == 10000) { $arr = json_decode(json_encode($result->mini_category_list), true); $data = $this->getdata($arr); return [ 'code' => 0, 'msg' => "成功", 'data' => $data ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //处理子父级数据 public function getdata($data, $id = "0") { foreach ($data as $k => $v) { if ($v['parent_category_id'] == $id) { $v['children'] = $this->getdata($data, $v['category_id']); $arr[] = $v; } } return $arr; } /** * 小程序退回开发 * alipay.open.mini.version.audited.cancel(小程序退回开发) */ public function miniVersionCancel() { $t = \Yii::$app->db->beginTransaction(); try { $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy("create_time desc")->one(); $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.audited.cancel"; $request = new AlipayOpenMiniVersionAuditedCancelRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $MiniVersion->is_submit = 0; $MiniVersion->save(); $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序版本详情查询 * alipay.open.mini.version.detail.query(小程序版本详情查询) */ public function miniVersionDetail($version = '') { try { $mini = StoreAliMini::findOne($this->mini_id); $MiniVersion = StoreAliMiniVersion::findOne(['mini_id' => $this->mini_id, 'template_version' => $version, 'is_back' => 0]); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.detail.query"; $request = new AlipayOpenMiniVersionDetailQueryRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $reject_reason = ''; switch ($result->status) { case 'AUDITING': //审核中 $status = 1; break; case 'WAIT_RELEASE': //待上架 $status = 2; break; case 'AUDIT_REJECT'://审核驳回 $status = 3; $reject_reason = $result->reject_reason; break; case 'RELEASE'://已上架 $status = 4; break; default ://构建中 $status = 0; break; } $MiniVersion->is_submit = $status; $MiniVersion->fail_reason = $reject_reason; $MiniVersion->fail_time = time(); $MiniVersion->save(); return [ 'code' => 0, 'msg' => "成功", 'data' => [ 'status' => $status, 'fail_reason' => $reject_reason ] ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序灰度上架 * alipay.open.mini.version.gray.online(小程序灰度上架) */ // public function miniGrayOnline(){ // try { // $mini = StoreAliMini::find()->where(['store_id'=>get_store_id()])->one(); // if(empty($mini)){ // throw new \Exception("没有进行授权"); // } // $gray_strategy = 'p'.(int)abs($this->gray_strategy);//只支持10/30/50 // $param = [ // 'app_version'=>$this->app_version, // 'gray_strategy'=>$gray_strategy, // 'bundle_id'=>$this->bundle_id, // ]; // $this->biz_content = json_encode($param); // $this->method = "alipay.open.mini.version.gray.online"; // $request = new AlipayOpenMiniVersionGrayOnlineRequest(); // $result = $this->miniCommon($request); // if(!empty($result->code)&&$result->code == 10000){ // return [ // 'code'=>0, // 'msg'=>"成功", // 'data'=>$result // ]; // }else{ // throw new \Exception($result->sub_msg); // } // }catch (\Exception $e){ // return [ // 'code'=>1, // 'msg'=>$e->getMessage() // ]; // } // } /** * 小程序结束灰度 * alipay.open.mini.version.gray.cancel(小程序结束灰度) */ // public function miniGrayCancel(){ // try { // $mini = StoreAliMini::find()->where(['store_id'=>get_store_id()])->one(); // if(empty($mini)){ // throw new \Exception("没有进行授权"); // } // $param = [ // 'app_version'=>$this->app_version, // 'bundle_id'=>$this->bundle_id, // ]; // $this->biz_content = json_encode($param); // $this->method = "alipay.open.mini.version.gray.cancel"; // $request = new AlipayOpenMiniVersionGrayCancelRequest(); // $result = $this->miniCommon($request); // if(!empty($result->code)&&$result->code == 10000){ // return [ // 'code'=>0, // 'msg'=>"成功", // 'data'=>$result // ]; // }else{ // throw new \Exception($result->sub_msg); // } // }catch (\Exception $e){ // return [ // 'code'=>1, // 'msg'=>$e->getMessage() // ]; // } // } /** * 小程序上架 * alipay.open.mini.version.online(小程序上架) */ public function miniOnline() { $t = \Yii::$app->db->beginTransaction(); try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id,aes_key,auth_app_id,userid,license_name')->orderBy('id desc')->one(); $mini_id = $mini->id; } else { $mini_id = $this->mini_id; $mini = StoreAliMini::findOne($mini_id); } $MiniVersion = StoreAliMiniVersion::find()->where(['mini_id' => $mini_id])->orderBy("create_time desc")->one(); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'app_version' => $MiniVersion->template_version ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.version.online"; $request = new AlipayOpenMiniVersionOnlineRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $MiniVersion->is_submit = 4; $res = $MiniVersion->save(); if ($res) { $t->commit(); return [ 'code' => 0, 'msg' => '成功', 'data' => $result ]; } else { throw new \Exception("保存数据错误"); } } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 暂停/开始使用 */ public function unbind() { try { if (!empty($this->bind_store_id)) { $mini = StoreAliMini::find()->where(['store_id' => $this->bind_store_id])->select('id,app_name,aes_key,auth_app_id,userid,license_name')->orderBy('id desc')->one(); $mini_id = $mini->id; } else { $mini_id = $this->mini_id; $mini = StoreAliMini::findOne($mini_id); } if (empty($mini)) { throw new \Exception("数据错误,获取小程序信息失败"); } if ($this->is_use == 1 || empty($this->is_use)) { StoreAliMini::updateAll(['is_use' => 2], ['store_id' => $this->store_id]); $mini->is_use = 1; } elseif ($this->is_use == 2) { $mini->is_use = 2; } $res = $mini->save(); if ($res) { //设置店铺的appid if($mini->is_use == 1){ $store = Store::findOne($mini->store_id); $store->app_auth_token = $mini->auth_token; if (!$store->save()) { throw new \Exception(json_encode($store->errors)); } $value = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay'); $new_value = json_decode($value['value'],true); $new_value['name'] = $mini->app_name; $new_value['app_id'] = $mini->auth_app_id; $new_value['user_id'] = $mini->userid; $new_value['is_saas'] = 1; $value['value'] = json_encode($new_value); \Yii::$app->cache->delete('alipay_config_cache_business_' . get_store_id()); \Yii::$app->cache->set('alipay_config_cache_business_' . get_store_id(), $value['value']); unset($new_value['is_saas']); $value['value'] = json_encode($new_value); Option::set(Option::OPTOPN_KEY, $value['value'], get_store_id(), 'alipay'); } return [ 'code' => 0, 'msg' => "设置成功", 'data' => $res ]; } else { throw new \Exception("数据库添加失败"); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 小程序生成推广二维码接口 * alipay.open.app.qrcode.create(小程序生成推广二维码接口) */ public function miniQrcodeCreate() { $t = \Yii::$app->db->beginTransaction(); try { $mini = StoreAliMini::findOne($this->mini_id); if (empty($mini)) { throw new \Exception("没有进行授权"); } $param = [ 'url_param' => "pages/home/home", 'query_param' => "mini_id=" . $this->mini_id, 'describe' => "小程序开发上线使用" ]; $this->biz_content = json_encode($param); $this->method = "alipay.open.app.qrcode.create"; $request = new AlipayOpenAppQrcodeCreateRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } /** * 图片转base64 */ public function image2Base64($file) { if ($fp = fopen($file, "rb", 0)) { $gambar = fread($fp, filesize($file)); fclose($fp); $base64 = chunk_split(base64_encode($gambar)); return $base64; } else { return false; } } /** * 获取列表 */ public function getMiniList() { $query = StoreAliMini::find()->where(['store_id' => get_store_id()]) ->select("id, userid, auth_app_id, license_name, license_no, app_logo, app_name, category_name, mini_categoryIds, apply_phone_msg, is_get_phone, apply_phone_fail, batch_status, is_use, shop_status, batch_no, order_cancel"); if ($this->AppName) { $query->andWhere(['LIKE', 'app_name', $this->AppName]); } if ((int)$this->is_use !== 0) { $query->andWhere(['is_use'=> $this->is_use]); } $query->andWhere(['is_cancel' => 0]); $pagination = pagination_make($query); $admins = $pagination['list']; foreach ($admins as &$admin) { if(!$admin['auth_app_id']){ $admin['mini_isv_query'] = (array)$this->getMiniShenheStatus($admin['id']); } if (!empty($admin['batch_no'])) { $this->getBatchStatus($admin['id'], $admin['batch_no']); } $version = StoreAliMiniVersion::find()->where(['mini_id' => $admin['id']])->orderBy('create_time desc')->asArray()->one(); \Yii::error($version); $admin['is_submit'] = !empty($version['is_submit']) ? $version['is_submit'] * 1 : 0; $admin['mini_status'] = 1; if (empty($version)) { $admin['mini_status'] = 0; if ($admin['order_cancel'] == 1) { $admin['mini_status'] = -1; } } else { $this->mini_id = $admin['id']; $detail_res = $this->miniVersionDetail($version['template_version']); if ($detail_res['code'] === 0) { [$admin['status'], $admin['fail_reason']] = $detail_res['data']; } $res = $this->createMiniExperienceQrcode(); if ($res['code'] === 0) { $admin['experience_url'] = $res['url']; } } $admin['apply_msg'] = []; if (!empty($admin['apply_phone_msg'])) { $admin['apply_msg'] = json_decode($admin['apply_phone_msg']); } $admin['batch_status'] *= 1; //$admin['is_get_phone'] = empty($this->getField($admin['id'])['data']) ? 2 : $admin['is_get_phone']; $admin['is_experience'] = !empty($version['is_experience']) ? $version['is_experience'] : 0; $admin['experience_url'] = !empty($version['experience_url']) ? $version['experience_url'] : ''; $admin['mini_categoryIds'] = !empty($admin['mini_categoryIds']) ? explode(';', $admin['mini_categoryIds']) : []; $admin['getClientConfig'] = \app\modules\client\models\v1\StoreConfigForm::getClientConfig($admin['store_id'], $admin['id']); } return [ 'code' => 0, 'msg' => "获取成功", 'data' => $admins, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'], ]; } /** * 获取版本列表 */ // public function getMiniVersionList(){ // $query = StoreAliMiniVersion::find()->where(['mini_id'=>$this->mini_id])->select("id,template_version,create_time,is_up,is_experience,experience_url,is_submit,is_put"); // $pagination = pagination_make($query); // $admins = $pagination['list']; // return [ // 'code'=>0, // 'msg'=>"获取成功", // 'data'=>$admins, // 'pageNo' => $pagination['pageNo'], // 'totalCount' => $pagination['totalCount'], // ]; // } /** * 获取修改信息 */ public function getMiniInfo() { $query = StoreAliMini::find()->where(['id' => $this->mini_id]) ->select("id, app_name, app_english_name, app_slogan, app_logo, app_desc, service_phone, ,alipay_account, contact_name, batch_status, shop_status, service_email, license_no, license_pic, license_name, license_date, is_long_effective, category_name, mini_categoryIds, other_data, order_cancel, batch_no"); $mini_info = $query->asArray()->one(); $version_info = StoreAliMiniVersion::find()->where(['mini_id' => $this->mini_id])->orderBy('create_time desc')->select('template_version, is_submit, fail_reason')->one(); $mini_info['mini_status'] = 1; if (!empty($version_info)) { $mini_info['version'] = $version_info->template_version; $mini_info['is_submit'] = $version_info->is_submit; $mini_info['fail_reason'] = $version_info->fail_reason; } else { $mini_info['mini_status'] = 0; if ($mini_info['order_cancel'] == 1) { $mini_info['mini_status'] = -1; } } $mini_info['reject_reason'] = ''; $result = $this->getBatchStatus(0, $mini_info['batch_no']); if ($result['code'] === 0) { $mini_info['reject_reason'] = $result['reject_reason']; } $mini_info['other_data'] = $mini_info['other_data'] ? json_decode($mini_info['other_data'], true) : []; $mini_info['mini_category_ids'] = !empty($mini_info['mini_categoryIds']) ? explode(';', $mini_info['mini_categoryIds']) : []; $store_shop = StoreAliShop::findOne(['mini_id' => $this->mini_id]); if ($store_shop) { $store_shop->business_address = json_decode($store_shop->business_address, true); $store_shop->qualifications = json_decode($store_shop->qualifications, true); $store_shop->created_at = date("Y-m-d H:i:s", $store_shop->created_at); $mini_info['store_shop'] = $store_shop; } return [ 'code' => 0, 'msg' => "获取成功", 'data' => $mini_info, ]; } /** * 单一版本信息 */ // public function getVersionInfo(){ // $mini = StoreAliMiniVersion::find()->where(['id'=>$this->version_id])->select('id,create_time,template_version as version,is_up,is_experience,experience_url,is_submit,is_put')->asArray()->one(); // $mini['create_time'] = date("Y-m-d H:i:s",$mini['create_time']); // return [ // 'code'=>0, // 'msg'=>"获取成功", // 'data'=>$mini // ]; // } /** * isv服务商代商户创建小程序 */ public function isvCreateMini() { $t = \Yii::$app->db->beginTransaction(); try { if (!empty($this->bind_store_id)) { $store_id = $this->bind_store_id; $mini = StoreAliMini::find()->where(['store_id' => $store_id])->select('id')->orderBy('id desc')->one(); $mini_id = $mini->id; } else { $mini_id = $this->mini_id; $store_id = get_store_id(); } if (!empty($mini_id)) { $ali_mini = StoreAliMini::find()->where(['id' => $mini_id])->one(); } else { //$ali_mini = StoreAliMini::find()->where(['license_no'=>$this->license_no])->one(); //if(!empty($ali_mini)){ //throw new \Exception("营业执照信息已经存在"); // } $ali_mini = new StoreAliMini(); } $new_mini = StoreAliMini::find()->where(['store_id' => $store_id])->orderBy('id desc')->one(); $out_order_no = date("YmdHis") . sprintf("%03d", $store_id) . sprintf("%03d", $new_mini->id + 1); $param = [ 'create_mini_request' => [ 'out_order_no' => $out_order_no, 'alipay_account' => $this->alipay_account, 'legal_personal_name' => $this->legal_personal_name, 'cert_name' => $this->license_name, 'cert_no' => $this->license_no, 'app_name' => $this->AppName, 'contact_phone' => $this->ServicePhone, 'contact_name' => $this->contact_name, 'is_individual' => true ] ]; $ali_mini->store_id = $store_id; $ali_mini->license_name = $this->license_name; $ali_mini->order_no = $out_order_no; $ali_mini->license_no = $this->license_no; $ali_mini->app_name = $this->AppName; $ali_mini->service_phone = $this->ServicePhone; $ali_mini->license_pic = $this->license_pic; $ali_mini->alipay_account = $this->alipay_account; $ali_mini->legal_personal_name = $this->legal_personal_name; if (!empty($this->merchant_id)) { $ali_mini->merchant_id = $this->merchant_id; } $ali_mini->contact_name = $this->contact_name; $res = $ali_mini->save(); if ($res) { $this->biz_content = json_encode($param); $this->method = "alipay.open.mini.isv.create"; $request = new AlipayOpenMiniIsvCreateRequest(); $result = $this->miniCommon($request); if (!empty($result->code) && $result->code == 10000) { $ali_mini->order_no_ali = $result->order_no; $ali_mini->save(); $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result, 'id' => $ali_mini->id ]; } throw new \Exception($result->sub_msg); } else { throw new \Exception("插入数据失败"); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile() ]; } } //查询商户某个产品的签约状态 public function signstatusOk($pid = '', $product_codes = ''){ $res = $this->agentQuery($pid, $product_codes); if ($res['code'] == 0 && $res['data']->sign_status_list[0]) { return $res['data']->sign_status_list[0]->status == 'valid'; } return false; } public function agentQuery($pid = '', $product_codes = ''){ try { $data = [ 'pid' => $pid, 'product_codes' => [$product_codes], ]; $this->biz_content = json_encode($data); $request = new AlipayOpenAgentSignstatusQueryRequest(); $result = $this->miniCommon($request); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //创建事务 public function agentCreate($id = 0) { $t = \Yii::$app->db->beginTransaction(); try { if (!empty($this->bind_store_id)) { $store_id = $this->bind_store_id; $mini = StoreAliMini::find()->where(['store_id' => $store_id])->select('id,batch_status,batch_no,alipay_account,contact_name,service_phone,service_email,')->orderBy('id desc')->one(); $id = $mini->id; } else { $id = !empty($id) ? $id : $this->mini_id; $mini = StoreAliMini::findOne($id); } \Yii::error(json_encode($mini)); if (empty($mini) || empty($mini->auth_token)) { throw new \Exception("查询不到任何信息"); } $params_data = [ "alipay_account" => $this->params_data['alipay_account'] ?: $mini->alipay_account, "contact_name" => $this->params_data['contact_name'] ?: $mini->contact_name, "service_phone" => $this->params_data['service_phone'] ?: $mini->service_phone, "service_email" => $this->params_data['service_email'] ?: $mini->service_email ]; $data = [ 'account' => $params_data['alipay_account'], 'contact_info' => [ 'contact_name' => $params_data['contact_name'], 'contact_mobile' => $params_data['service_phone'], 'contact_email' => $params_data['service_email'] ] ]; $this->method = "alipay.open.agent.create"; $this->biz_content = json_encode($data); $request = new AlipayOpenAgentCreateRequest(); $batch_no = $mini->batch_no; $res = [ 'code' => 0, 'msg' => "执行成功" ]; if ($mini->batch_status == 0 || $mini->batch_status == 1 || $mini->batch_status == 7 || $mini->batch_status == 8) { $result = $this->miniCommon($request, 0, 0, 1); if (!empty($result->code) && $result->code == 10000) { $mini->alipay_account = $params_data['alipay_account']; $mini->contact_name = $params_data['contact_name']; $mini->service_phone = $params_data['service_phone']; $mini->service_email = $params_data['service_email']; $mini->batch_no = $result->batch_no; $mini->batch_status = 1; $res = $mini->save(); if (!$res) { throw new \Exception("保存信息失败"); } $batch_no = $result->batch_no; } else { throw new \Exception($result->sub_msg); } } if ($mini->batch_status === 1 || $mini->batch_status === 4) { $res = $this->faceToFace($id, $batch_no); \Yii::error("当面付"); \Yii::error($res); if ($res['code'] === 1) { throw new \Exception($res['msg']); } if ($res['code'] !== 2) { $res = $this->agentConfirm($id, $batch_no); \Yii::error("事务提交"); \Yii::error($res); if ($res['code'] !== 0) { throw new \Exception($res['msg']); } $res = $this->getBatchStatus($id, $batch_no); \Yii::error("查询状态"); \Yii::error($res); if ($res['code'] !== 0) { throw new \Exception($res['msg']); } } } // if ($mini->batch_status === 2) { // $res = $this->agentConfirm($id, $batch_no); // \Yii::error("事务提交"); // \Yii::error($res); // if ($res['code'] !== 0) { // throw new \Exception($res['msg']); // } // } // if ($mini->batch_status === 3) { // $res = $this->getBatchStatus($id, $batch_no); // \Yii::error("查询状态"); // \Yii::error($res); // if ($res['code'] !== 0) { // throw new \Exception($res['msg']); // } // } $t->commit(); return [ 'code' => 0, 'msg' => '成功' ]; } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //当面付签约 public function faceToFace($id = 0, $batch_no = '') { try { if (!empty($this->bind_store_id)) { $store_id = $this->bind_store_id; $mini = StoreAliMini::find()->where(['store_id' => $store_id])->select('id,batch_no,mini_categoryIds,app_logo')->orderBy('id desc')->one(); } else { $mini_id = !empty($id) ? $id : $this->mini_id; $mini = StoreAliMini::findOne($mini_id); } if (empty($mini)) { throw new \Exception("查询不到任何信息"); } $this->method = "alipay.open.agent.facetoface.sign"; $request = new AlipayOpenAgentFacetofaceSignRequest(); $request->setBatchNo($batch_no); $request->setMccCode("A0002_B0201"); $request->setRate('0.38'); $request->setSignAndAuth(true); $request->setShopSignBoardPic('@' . $this->saveTempImage($this->params_data['app_logo'])); \Yii::error($id); $result = $this->miniCommon($request, 1, $mini_id, 1); \Yii::error($result); if ((!empty($result->code) && $result->code == 10000) || $result->sub_code == "ANT_PRODUCT_CONFLICT") { $mini->batch_status = 2; if ($result->sub_code == "ANT_PRODUCT_CONFLICT") { $mini->batch_status = 2; } $res = $mini->save(); if ($res) { if ($result->sub_code == "ANT_PRODUCT_CONFLICT") { return [ 'code' => 2, 'msg' => "成功", 'data' => $result ]; } return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception("添加数据失败"); } } throw new \Exception($result->sub_msg); } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() . $e->getLine() ]; } } //提交事务 public function agentConfirm($id = 0, $batch_no = '') { try { if (!empty($this->bind_store_id)) { $store_id = $this->bind_store_id; $mini = StoreAliMini::find()->where(['store_id' => $store_id])->select('id,batch_no')->orderBy('id desc')->one(); } else { $mini_id = !empty($id) ? $id : $this->mini_id; $mini = StoreAliMini::findOne($mini_id); } if (empty($mini)) { throw new \Exception("查询不到任何信息"); } $data = [ 'batch_no' => $batch_no ]; $this->method = "alipay.open.agent.confirm"; $this->biz_content = json_encode($data); $request = new AlipayOpenAgentConfirmRequest(); $result = $this->miniCommon($request, 0, $id, 1); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { $mini->batch_status = 3; $res = $mini->save(); if ($res) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception("添加数据失败"); } } throw new \Exception($result->sub_msg); } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //查询状态 public function getBatchStatus($id = 0, $batch = '') { try { \Yii::error("查询状态"); if (!empty($this->bind_store_id)) { $store_id = $this->bind_store_id; \Yii::error($store_id); $mini = StoreAliMini::find()->where(['store_id' => $store_id])->select('id,batch_no,alipay_account')->orderBy('id desc')->one(); } else { $mini_id = !empty($id) ? $id : $this->mini_id; \Yii::error($mini_id); $mini = StoreAliMini::findOne($mini_id); } \Yii::error($mini); if (empty($mini)) { throw new \Exception("查询不到任何信息"); } $data = [ 'batch_no' => $batch ]; $this->method = "alipay.open.agent.order.query"; $this->biz_content = json_encode($data); $request = new AlipayOpenAgentOrderQueryRequest(); $result = $this->miniCommon($request, 0, $id, 1); \Yii::error("查询状态查询状态查询状态查询状态"); \Yii::error(json_encode($result)); if (!empty($result->code) && $result->code == 10000) { $status = $result->order_status; $msg = "成功"; switch ($status) { case "MERCHANT_INFO_HOLD": //异常单 4 $mini->batch_status = 4; $msg = "订单异常"; break; case "MERCHANT_AUDITING": //审核中 3 $mini->batch_status = 3; $msg = "订单审核中"; break; case "MERCHANT_CONFIRM": //待确认 5 $mini->batch_status = 5; $msg = "等待商户确认,请注意查收支付宝消息通知"; break; case "MERCHANT_CONFIRM_SUCCESS": //商户确认成功 6 $mini->batch_status = 6; $msg = "商户确认成功"; break; case "MERCHANT_CONFIRM_TIME_OUT": //商户超时未确认 7 $mini->batch_status = 7; $msg = "商户超时未确认"; break; case "MERCHANT_APPLY_ORDER_CANCELED": //审核失败或商户拒绝 8 $mini->batch_status = 8; $msg = $result->reject_reason; break; } $res = $mini->save(); if ($res) { \app\modules\alliance\models\store\SalesmanNewStoreForm::aliPushFaceToFace($result, $mini); return [ 'code' => 0, 'msg' => "成功", 'data' => $result, 'reject_reason' => $msg ]; } else { throw new \Exception("添加数据失败"); } } throw new \Exception($result->sub_msg); } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //关联普通二维码 public function bindQrcode($id) { $t = \Yii::$app->db->beginTransaction(); try { $qrcode = AggregateQrcode::find()->where(['ali_mini_id' => $id])->one(); if (empty($qrcode->param_url) || empty($qrcode->ali_url)) { throw new \Exception("参数错误"); } $data = [ "route_url" => $qrcode->param_url, 'mode' => "FUZZY", "page_redirection" => $qrcode->ali_url ]; \Yii::error($data); $this->method = "alipay.open.mini.qrcode.bind"; $this->biz_content = json_encode($data); $request = new AlipayOpenMiniQrcodeBindRequest(); $result = $this->miniCommon($request, 0, $id); if (!empty($result->code) && $result->code == 10000) { $qrcode->ali_status = 1; $res = $qrcode->save(); if (!$res) { throw new \Exception('保存数据失败,绑定二维码成功'); } $t->commit(); return [ 'code' => 0, 'msg' => "成功", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //支付 public function payconfig($id, $out_trade_no, $user_id, $pay_price) { $t = \Yii::$app->db->beginTransaction(); try { $data = [ "out_trade_no" => $out_trade_no, 'total_amount' => $pay_price, "subject" => "当面付", "buyer_id" => $user_id ]; $this->method = "alipay.trade.create"; $this->biz_content = json_encode($data); $request = new AlipayTradeCreateRequest(); $request->setNotifyUrl(pay_notify_url(self::$notify_url)); $result = $this->miniCommon($request, 0, $id, 0, 1); if (!empty($result->code) && $result->code == 10000) { $t->commit(); $data = [ 'trade_no' => $result->trade_no, 'order_no' => $out_trade_no ]; return [ 'code' => 0, 'msg' => "成功", 'data' => $data ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { $t->rollBack(); return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //获取敏感字段 public function getField($id = 0) { try { $mini_id = !empty($id) ? $id : $this->mini_id; \Yii::error($mini_id); $mini = StoreAliMini::findOne($mini_id); $this->method = "alipay.open.app.api.query"; $request = new AlipayOpenAppApiQueryRequest(); $result = $this->miniCommon($request, 1, $mini->id); \Yii::error("获取敏感字段"); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { if (!empty($result->apis)) { $scene = $this->getScene($mini->id); if ($scene['code'] === 0) { return [ 'code' => 0, 'msg' => "成功", 'data' => $scene['data'] ]; } throw new \Exception($scene['msg']); } return [ 'code' => 0, 'msg' => "成功", 'data' => [] ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //获取敏感字段使用场景 public function getScene($id) { try { if (empty($id)) { throw new \Exception("未知的小程序信息"); } $data = [ 'field_name' => 'mobile', 'api_name' => 'getPhoneNumber' ]; $this->method = "alipay.open.app.api.scene.query"; $this->biz_content = json_encode($data); $request = new AlipayOpenAppApiSceneQueryRequest(); $result = $this->miniCommon($request, 0, $id); \Yii::error("获取敏感字段场景值"); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { return [ 'code' => 0, 'msg' => "成功", 'data' => $result->auth_field_scene ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //申请接入敏感字段 public function applyPhone() { try { $apply_msg = $this->apply_msg; $mini_id = $apply_msg['id']; if (empty($mini_id)) { throw new \Exception("获取小程序信息失败"); } \Yii::error($mini_id); $mini = StoreAliMini::findOne($mini_id); $this->method = "alipay.open.app.api.field.apply"; $request = new AlipayOpenAppApiFieldApplyRequest(); !empty($apply_msg['video']) && $request->setVideo('@' . $this->saveTempImage($apply_msg['video'])); foreach ($apply_msg['picture'] as $index => $item) { \Yii::error($item); \Yii::error($this->saveTempImage($item)); switch ($index) { case 0: $request->setPicture1('@' . $this->saveTempImage($item)); break; case 1: $request->setPicture2('@' . $this->saveTempImage($item)); break; case 2: $request->setPicture3('@' . $this->saveTempImage($item)); break; case 3: $request->setPicture4('@' . $this->saveTempImage($item)); break; case 4: $request->setPicture5('@' . $this->saveTempImage($item)); break; } } $data = [ 'api_name' => "getPhoneNumber", 'field_name' => "mobile", "package_code" => "20180927110154092444", 'scene_code' => $apply_msg['scene_code'], 'qps_answer' => $apply_msg['qps_answer'], 'customer_answer' => $apply_msg['customer_answer'], 'memo' => $apply_msg['memo'], 'tiny_app_template_id' => Option::get("ali_template_appid", 0, 'saas')['value'] ]; $request->setAuthFieldApply(json_encode($data)); $result = $this->miniCommon($request, 1, $apply_msg['id']); \Yii::error($result); $mini->apply_phone_msg = json_encode($apply_msg); $mini->save(); if (!empty($result->code) && $result->code == 10000) { $mini->is_get_phone = 1; $mini->save(); return [ 'code' => 0, 'msg' => "开始审核", 'data' => $result ]; } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //手动查询手机号申请状态 public function getPhoneStatus($id) { try { $mini_id = $this->mini_id; $mini = StoreAliMini::find()->where(['id' => $mini_id])->select("id,is_get_phone,apply_phone_fail,auth_app_id")->one(); if (empty($mini)) { throw new \Exception("获取小程序信息失败"); } $this->method = "alipay.open.app.api.field.query"; $request = new AlipayOpenAppApiFieldQueryRequest(); $result = $this->miniCommon($request, 1, $mini_id); \Yii::error("获取敏感字段申请状态"); \Yii::error($result); if (!empty($result->code) && $result->code == 10000) { $data = $result->auth_field_response->records; $data_arr = json_decode(json_encode($data), true); \Yii::error($data_arr); $status = $data_arr[0]['status']; if ($status === "AGREE") { $mini->is_get_phone = 2; } elseif ($status === "REJECT" || $status === "INVALID") { $reason = !empty($data->reason) ? $data->reason : ''; $mini->is_get_phone = 3; $mini->apply_phone_fail = $reason; } if ($mini->save()) { return [ 'code' => 0, 'msg' => "成功", 'data' => $data, 'status' => $status ]; } throw new \Exception("保存数据错误" . json_encode($mini->errors)); } else { throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } //获取网络图片到临时目录 public function saveTempImage($url) { if (strpos($url, 'http') === false) { $url = 'http:' . trim($url); } if (!is_dir(\Yii::$app->runtimePath . '/image')) { mkdir(\Yii::$app->runtimePath . '/image'); } $save_path = \Yii::$app->runtimePath . '/image/' . md5($url) . '.jpg'; CurlHelper::download($url, $save_path); return $save_path; } public function ImageSize($path) { // 原始图片路径 $original_img_path = $path; // 缩小后的图片路径 $compressed_img_path = $path; // 目标文件大小(以兆字节为单位) $target_size_mb = 4.9; // 加载原始图片 $original_img = imagecreatefromjpeg($original_img_path); // 获取原始图片的宽度和高度 $width = imagesx($original_img); $height = imagesy($original_img); // 计算目标图片的质量 $target_quality = 80; do { // 创建新的画布 $compressed_img = imagecreatetruecolor($width, $height); // 将原始图片复制到新的画布中 imagecopyresampled($compressed_img, $original_img, 0, 0, 0, 0, $width, $height, $width, $height); // 将新画布保存为 JPEG 格式的图片 imagejpeg($compressed_img, $compressed_img_path, $target_quality); // 获取压缩后的图片大小(以字节为单位) $compressed_size = filesize($compressed_img_path); // 计算压缩后的图片大小(以兆字节为单位) $compressed_size_mb = $compressed_size / 1024 / 1024; // 调整目标质量,直到达到目标大小 $target_quality -= 5; } while ($compressed_size_mb > $target_size_mb); } public function getIsvCreateMini() { $mini = StoreAliMini::find()->where(['id' => $this->mini_id])->select("id, license_name, license_no,app_name, license_pic, service_phone, alipay_account, legal_personal_name, contact_name, order_cancel")->asArray()->one(); $version = StoreAliMiniVersion::find()->where(['mini_id' => $mini['id']])->orderBy('create_time desc')->asArray()->one(); $mini['mini_status'] = 1; if (empty($version)) { $mini['mini_status'] = 0; if ($mini['order_cancel'] == 1) { $mini['mini_status'] = -1; } } return [ 'code' => 0, 'msg' => "获取成功", 'data' => $mini ]; } // 获取小程序审核状态 public function getMiniShenheStatus($id){ try { $store_ali_mini = StoreAliMini::findOne($id); if (!$store_ali_mini || !$store_ali_mini->order_no) { return false; } $data = [ "order_no" => $store_ali_mini->order_no_ali, ]; $this->method = "alipay.open.mini.isv.query"; $this->biz_content = json_encode($data); $request = new AlipayOpenMiniIsvQueryRequest(); $result = $this->miniCommon($request,0,$id); if(!empty($result->code)&&$result->code == 10000){ return $result; }else{ throw new \Exception($result->sub_msg); } }catch (\Exception $e){ return [ 'code'=> 2, 'msg'=>$e->getMessage() ]; } } public function setSafeDomain($id) { try { $store_ali_mini = StoreAliMini::findOne($id); if (!$store_ali_mini) { return false; } $data = [ "safe_domain" => \Yii::$app->request->hostName, ]; $this->method = "alipay.open.mini.safedomain.create"; $this->biz_content = json_encode($data); $request = new AlipayOpenMiniSafedomainCreateRequest(); $result = $this->miniCommon($request,0, $id); if(!empty($result->code)&&$result->code == 10000){ return $result; }else{ throw new \Exception($result->sub_msg); } } catch (\Exception $e) { return [ 'code'=> 1, 'msg'=>$e->getMessage() ]; } } /** * 各个行业场景服务接入资料 * https://opendocs.alipay.com/mini/03ci0w * https://opendocs.alipay.com/pre-open/02bijq * @return type */ public function getServiceCats() { $cacheKey = 'alipay_alipay_app_service_cats'; $cats = \Yii::$app->cache->get($cacheKey); if($cats){ return [ 'code' => 0, 'data' => $cats ]; } // $url = 'https://ideservice.alipay.com/cms/site/queryCatalogContent.json'; // $json = file_get_contents($url); // $res = json_decode($json, true); //// var_dump($res);die; // $larkRawText = $res['data']['content']['larkRawText']; $larkRawText = '
支付宝服务接入能力中各服务 Schema 根据行业场景会有所不同。开发者需根据实际行业类型选用对应 服务类型、服务 Schema 模板 等信息。
说明:
服务类型
categoryId
类型名称
一级类型
二级类型
三级类型
C000003264
餐饮
餐饮
预定
C000003265
餐饮
餐饮
预点餐自提
C000003266
餐饮
餐饮
外卖
C000003267
餐饮
餐饮
排队
C000003268
餐饮
餐饮
到店点餐
C000003270
车主生活
车辆零配件/用品精品
在线订购
C000003273
车主生活
代驾
挪车服务
C000003274
车主生活
代驾
代驾服务
C100845235
车主生活
代驾
挪车码
C000003282
车主生活
停车服务
停车缴费
C100948906
车主生活
停车服务
停车场查询
C000003297
公共管理和社会组织
公益
公益活动报名
C000003298
公共管理和社会组织
公益
爱心捐赠
C100948921
公共管理和社会组织
公益
公益林
C100949075
公共管理和社会组织
公益
献血服务
C000003320
交通出行
打车/租车
在线租汽车
C000003321
交通出行
打车/租车
在线打车
C000003322
交通出行
打车/租车
共享单车
C000003323
交通出行
公共交通
在线购票
C000003324
交通出行
公共交通
公交线路查询
C000003325
交通出行
公共交通
交通卡充值办理
C000003326
交通出行
公共交通
公交乘车码
C100845240
交通出行
公共交通
地铁线路查询
C100845241
交通出行
公共交通
乘车记录
C100845418
交通出行
公共交通
实时公交
C100948778
交通出行
公共交通
地铁乘车码
C101246799
交通出行
公共交通
服务大厅
C101247583
交通出行
公共交通
公交NFC
C101247775
交通出行
公共交通
地铁服务大厅
C101247877
交通出行
公共交通
实时地铁
C101248046
交通出行
公共交通
地铁NFC
C000003329
交通出行
航空出行
在线值机
C000003330
交通出行
航空出行
机票预订
C100955087
交通出行
航空出行
行程通知
C101051368
交通出行
航空出行
机票退/改签
C101051499
交通出行
航空出行
临时乘机证明
C101051662
交通出行
航空出行
安检服务
C101249402
交通出行
航空出行
航班动态
C101249523
交通出行
航空出行
行李服务
C101249722
交通出行
航空出行
机场交通
C101250264
交通出行
航空出行
客票验真
C101250384
交通出行
航空出行
电子发票
C101250541
交通出行
航空出行
机上餐饮
C101250670
交通出行
航空出行
升舱服务
C000003335
交通出行
铁路出行
火车票预订
C100955249
交通出行
铁路出行
行程通知
C101248313
交通出行
铁路出行
扫码乘车
C101248418
交通出行
铁路出行
订餐服务
C101248574
交通出行
铁路出行
城际乘车码
C101248698
交通出行
铁路出行
接送站服务
C101248824
交通出行
铁路出行
火车票退改签
C101249910
交通出行
铁路出行
车票查询
C101250087
交通出行
铁路出行
车票报销
C000003352
教育培训
学校
找兼职服务
C000003353
教育培训
学校
校园缴费
C000003354
教育培训
学校
学生码服务
C000003355
教育培训
学校
校招服务
C000003356
教育培训
学校
校园码服务
C000003359
教育培训
学校
校园考试/竞赛查询
C000003360
教育培训
学校
校园考试/竞赛报名
C000003361
教育培训
学校
校园一卡通充值
C000003362
教育培训
学校
校园食堂点餐配送
C000003363
教育培训
学校
助学贷款在线还款
C000003578
教育培训
学校
校园水控
C100934869
教育培训
学校
高考服务
C101056796
教育培训
学校
校园公益
C000003372
金融理财
金融-股票基金
证券期货
C000003373
金融理财
金融-股票基金
证券期货
C000003374
金融理财
金融-股票基金
金融咨询
C000003375
金融理财
金融-股票基金
基金
C000003376
金融理财
金融-股票基金
股票
C000003388
酒旅景区
酒店/旅馆/民宿
住宿预订
C000003389
酒旅景区
酒店/旅馆/民宿
入住办理
C000003390
酒旅景区
酒店/旅馆/民宿
在线订购
C000003391
酒旅景区
酒店/旅馆/民宿
发票预约
C100934870
酒旅景区
酒店/旅馆/民宿
订单查询
C100977348
酒旅景区
酒店/旅馆/民宿
住中服务
C000003400
零售批发
零售门店-食品
自助买单
C000003401
零售批发
零售门店-食品
O2O到家
C000003402
零售批发
零售门店-食品
门店扫码购
C000003403
零售批发
零售门店-食品
到店自提/到点自提
C000003404
零售批发
零售门店-食品
电子小票
C000003419
商业生活
地产中介
在线找房
C000003420
商业生活
地产中介
房屋委托
C000003421
商业生活
法律咨询
在线法律咨询
C000003422
商业生活
法律咨询
申请法律援助
C000003423
商业生活
法律咨询
律师事务所查询
C000003424
商业生活
法律咨询
律师查询
C000003425
商业生活
法律咨询
法律服务预约
C000003452
商业生活
广告图文
会展布置
C000003453
商业生活
广告图文
广告牌制作
C000003454
商业生活
广告图文
广告牌设计服务
C000003455
商业生活
广告图文
打印服务
C000003470
商业生活
家政/清洁/维修
维修服务
C000003471
商业生活
家政/清洁/维修
清洗护理
C000003472
商业生活
家政/清洁/维修
开锁换锁
C000003473
商业生活
家政/清洁/维修
管道疏通
C000003474
商业生活
家政/清洁/维修
保姆服务
C000003475
商业生活
家政/清洁/维修
保洁服务
C101016922
商业生活
家政/清洁/维修
搬家服务
C000003480
商业生活
其他商业生活服务
失物招领
C000003481
商业生活
其他商业生活服务
登报服务
C000003482
商业生活
其他商业生活服务
保安和监控服务
C000003487
商业生活
洗浴养生
在线预定
C000003488
商业生活
洗浴养生
在线订购
C000003490
商业生活
丽人
在线预定
C101011135
商业生活
丽人
上门服务
C000003492
商业生活
征信
企业征信查询
C000003494
商业生活
装修装饰
装修在线咨询
C000003495
商业生活
装修装饰
装修预约
C000003496
商业生活
装修装饰
在线找装修公司
C000003497
商业生活
装修装饰
在线订购
C000003498
商业生活
装修装饰
建筑/工程测量服务
C000003499
商业生活
装修装饰
预约上门
C000003500
商业生活
装修装饰
预约到店
C000003501
商业生活
装修装饰
同城配送
C000003502
商业生活
自助售卖
自助游戏机
C000003503
商业生活
自助售卖
自助饮水
C000003504
商业生活
自助售卖
自助洗衣
C000003505
商业生活
自助售卖
自助售卖
C000003506
商业生活
自助售卖
自助KTV
C000003509
生活缴费
水电煤缴费
自来水缴费
C000003510
生活缴费
水电煤缴费
有线电视缴费
C000003511
生活缴费
水电煤缴费
煤气缴费
C000003512
生活缴费
水电煤缴费
缴费账单查询
C000003513
生活缴费
水电煤缴费
电力缴费
C100845245
生活缴费
水电煤缴费
新增水费户号
C100845246
生活缴费
水电煤缴费
综合生活缴费
C100845421
生活缴费
水电煤缴费
新增电费户号
C100845422
生活缴费
水电煤缴费
新增燃气费户号
C100845423
生活缴费
水电煤缴费
缴费余额查询
C100846641
生活缴费
水电煤缴费
自动缴费管理
C000003517
网络通讯
网络电话、传真服务
网络电话、传真服务
C000003546
休闲娱乐
健身房/瑜伽/舞蹈
在线预约
C000003547
休闲娱乐
健身房/瑜伽/舞蹈
在线订购
C000003548
休闲娱乐
健身房/瑜伽/舞蹈
预约私教
C000003551
休闲娱乐
网络社交
网络社交
C000003552
休闲娱乐
网络社交
婚恋服务
C000003553
休闲娱乐
网络图书/视频/音乐
在线阅读
C000003554
休闲娱乐
网络图书/视频/音乐
在线影视
C000003555
休闲娱乐
网络图书/视频/音乐
在线音乐
C101170467
休闲娱乐
网络图书/视频/音乐
会员充值
C000003556
休闲娱乐
文化场馆/体育场馆
场馆预定
C000003557
休闲娱乐
文化场馆/体育场馆
场馆购票
C000003558
休闲娱乐
游乐园/嘉年华
在线购票
C000003559
休闲娱乐
院线影城/演出赛事
在线购票
C100845234
车主生活
车主服务
通勤信息查询
C100845411
车主生活
车主服务
限行查询
C100948780
车主生活
车主服务
车展查询
C100948781
车主生活
车主服务
驾考驾培查询
C100948782
车主生活
车主服务
拍照识车
C100948783
车主生活
车主服务
车辆召回查询
C100948900
车主生活
车主服务
驾照查分
C100948901
车主生活
车主服务
自驾出行查询
C100948902
车主生活
车主服务
违章高发地查询
C101021804
车主生活
车主服务
车联网服务
C100948923
公共管理和社会组织
民政生育
养老服务
C100949077
公共管理和社会组织
民政生育
婚姻服务
C100949078
公共管理和社会组织
民政生育
生育服务
C100948925
公共管理和社会组织
人才就业
人才认定/申报
C100949079
公共管理和社会组织
人才就业
劳动保障
C100949080
公共管理和社会组织
人才就业
人才信息查询
C100949081
公共管理和社会组织
人才就业
就业创业失业
C100949311
公共管理和社会组织
文体机构
综合文体服务
C100949325
公共管理和社会组织
文体机构
综合图书馆服务
C100949195
公共管理和社会组织
司法
法院诉讼缴费
C100949196
公共管理和社会组织
司法
拍卖服务
C100949197
公共管理和社会组织
司法
监狱服务
C100949308
公共管理和社会组织
司法
机构查询
C100949309
公共管理和社会组织
司法
公证服务
C100949310
公共管理和社会组织
司法
综合司法服务
C100949328
商业生活
气象环保
天气查询
C100949458
商业生活
气象环保
灾害预警
C101198629
商业生活
宠物
宠物医疗
C101198742
商业生活
宠物
宠物托运
C101198861
商业生活
宠物
上门喂养
C101199042
商业生活
宠物
宠物认养
C101241861
商业生活
宠物
宠物寄养
C101242015
商业生活
宠物
宠物训练
C101242142
商业生活
宠物
宠物殡葬
C101242250
商业生活
宠物
宠物防丢
C101242442
商业生活
宠物
宠物食品/用品
C101242571
商业生活
宠物
宠物摄影
C101242694
商业生活
宠物
宠物救助
C101242846
商业生活
宠物
电子犬证
C101249135
交通出行
公共服务
路线规划
C101249282
交通出行
公共服务
乘车记录
C000003269
车主生活
高速ETC
ETC服务
C000003271
车主生活
车辆销售/二手车销售
汽车销售服务
C000003272
车主生活
车辆销售/二手车销售
汽车报价
C100845232
车主生活
车辆销售/二手车销售
车辆估值
C100948779
车主生活
车辆销售/二手车销售
车企/品牌查询
C100948898
车主生活
车辆销售/二手车销售
新车查询
C100948899
车主生活
车辆销售/二手车销售
4S店/经销商查询
C101165507
车主生活
车辆销售/二手车销售
车辆试驾
C000003275
车主生活
道路救援
交通急救服务
C000003276
车主生活
电动车/两轮车充换电
充电桩
C000003279
车主生活
汽车洗美/维修养护
汽车维修
C000003280
车主生活
汽车洗美/维修养护
汽车保养
C100845412
车主生活
汽车洗美/维修养护
洗车服务
C100948784
车主生活
汽车洗美/维修养护
汽车保养查询
C100948785
车主生活
汽车洗美/维修养护
故障查询
C100948903
车主生活
汽车洗美/维修养护
洗车点查询
C100948904
车主生活
汽车洗美/维修养护
汽车车品/零配件查询
C100948905
车主生活
汽车洗美/维修养护
汽车改装查询
C000003281
车主生活
汽车租赁
租车服务
C000003284
公共管理和社会组织
公安交管
违章查缴
C000003285
公共管理和社会组织
公安交管
摇号选号
C000003286
公共管理和社会组织
公安交管
违法处理服务
C000003287
公共管理和社会组织
公安交管
事故处理服务
C000003290
公共管理和社会组织
公安交管
年检、过户服务
C000003293
公共管理和社会组织
公安交管
驾驶证服务
C000003295
公共管理和社会组织
公安交管
车辆基础信息服务
C000003296
公共管理和社会组织
公安交管
车辆报废服务
C000003300
公共管理和社会组织
社保
社保缴费
C000003301
公共管理和社会组织
社保
社保办理
C000003302
公共管理和社会组织
社保
社保查询
C000003303
公共管理和社会组织
社保
年度权益账单查询
C000003304
公共管理和社会组织
社保
公积金提取
C000003305
公共管理和社会组织
社保
公积金贷款
C000003306
公共管理和社会组织
社保
公积金查询
C000003308
公共管理和社会组织
社保
电子社保卡
C100845239
公共管理和社会组织
社保
综合公积金服务
C100845417
公共管理和社会组织
社保
综合社保服务
C100949082
公共管理和社会组织
社保
省直专区
C000003311
公共管理和社会组织
政务
专利/商标服务
C000003312
公共管理和社会组织
政务
政府热线
C000003313
公共管理和社会组织
政务
疫情查询
C000003314
公共管理和社会组织
政务
投诉举报
C000003316
公共管理和社会组织
政务
行政费用缴纳
C000003317
公共管理和社会组织
政务
行政罚款缴纳
C000003318
公共管理和社会组织
政务
工商注册
C000003319
公共管理和社会组织
政务
非税缴纳
C100949199
公共管理和社会组织
政务
政务办事
C100949312
公共管理和社会组织
政务
办事查询
C100949313
公共管理和社会组织
政务
公共支付
C100949314
公共管理和社会组织
政务
综合政务服务
C100949315
公共管理和社会组织
政务
企业服务
C100949316
公共管理和社会组织
政务
综合疫情服务
C100949317
公共管理和社会组织
政务
新冠疫苗预约
C100949318
公共管理和社会组织
政务
健康码
C100949319
公共管理和社会组织
政务
人员登记
C000003328
交通出行
公路客运
在线购票
C000003331
交通出行
加油
站点加油服务
C000003332
交通出行
加油
油卡余额查询
C000003333
交通出行
加油
油卡充值
C000003334
交通出行
加油
加油开票
C100949320
交通出行
加油
加油站查询
C000003336
交通出行
游轮出行
船票预订
C000003337
教育培训
儿童教育
在线题库
C000003338
教育培训
儿童教育
在线缴费
C000003339
教育培训
儿童教育
亲子活动报名
C000003340
教育培训
儿童教育
课程售卖
C000003341
教育培训
儿童教育
公益活动报名
C000003342
教育培训
儿童教育
儿童消费管理
C000003343
教育培训
培训机构
在线题库
C000003346
教育培训
培训机构
线上课程服务
C000003347
教育培训
培训机构
考试/竞赛咨询
C000003348
教育培训
培训机构
考试/竞赛查询
C000003349
教育培训
培训机构
考试/竞赛报名
C000003350
教育培训
培训机构
驾考服务
C000003351
教育培训
培训机构
出国留学咨询
C000003577
教育培训
培训机构
线下课程服务
C100935058
教育培训
培训机构
高考服务
C000003364
金融理财
保险
在线购买保险
C000003365
金融理财
保险
保险理赔
C100949322
金融理财
保险
购车贷款
C100949451
金融理财
保险
车抵贷
C100949452
金融理财
保险
车主贷款
C000003368
金融理财
金融
信用卡申请
C000003369
金融理财
金融
信用卡还款
C000003370
金融理财
金融
信用管理
C000003371
金融理财
金融
外币汇兑
C100949323
金融理财
金融
普惠金融
C000003377
金融理财
金融-借贷
借贷
C000003378
金融理财
金融-借贷
还贷
C000003380
酒旅景区
景区/旅游
旅游签证服务
C000003381
酒旅景区
景区/旅游
景区租赁
C000003383
酒旅景区
景区/旅游
景区预约购票
C000003384
酒旅景区
景区/旅游
景区导览讲解
C000003385
酒旅景区
景区/旅游
接送机服务
C000003386
酒旅景区
景区/旅游
国际驾照认证
C000003387
酒旅景区
景区/旅游
导游预定
C100949327
酒旅景区
景区/旅游
景区年卡
C100979934
酒旅景区
景区/旅游
景区小交通
C000003392
零售批发
零售门店
自助买单
C000003393
零售批发
零售门店
预约上门
C000003394
零售批发
零售门店
预约到店
C000003395
零售批发
零售门店
O2O到家
C000003396
零售批发
零售门店
门店扫码购
C000003397
零售批发
零售门店
到店自提/到点自提
C000003398
零售批发
零售门店
电子小票
C000003399
零售批发
零售门店
同城配送
C101026598
零售批发
零售门店
全渠道商城
C000003405
零售批发
零售门店-眼镜
O2O到家
C000003406
零售批发
零售门店-眼镜
到店自提/到点自提
C000003407
零售批发
零售门店-眼镜
电子小票
C000003408
零售批发
零售平台
在线订购(电商)
C000003409
零售批发
零售平台
到店自提/到点自提
C101021805
零售批发
零售平台
社区团购
C000003414
零售批发
综合体
停车缴费
C100955248
零售批发
综合体
支付即积分
C000003417
商业生活
宠物护理
宠物美容
C101037250
商业生活
宠物护理
宠物护理查询
C000003426
商业生活
工具
字典
C000003427
商业生活
工具
重名查询
C000003428
商业生活
工具
在线制作喜帖
C000003429
商业生活
工具
在线取名
C000003430
商业生活
工具
预约/报名表单制作
C000003431
商业生活
工具
疫苗种类查询
C000003432
商业生活
工具
信息查询与管理
C000003433
商业生活
工具
图片处理
C000003434
商业生活
工具
投票
C000003435
商业生活
工具
天气
C000003436
商业生活
工具
税费计算器
C000003437
商业生活
工具
日历
C000003438
商业生活
工具
企业人员管理
C000003439
商业生活
工具
企业库存管理
C000003440
商业生活
工具
垃圾分类查询
C000003441
商业生活
工具
健康记录服务
C000003442
商业生活
工具
记账
C000003443
商业生活
工具
计算器
C000003444
商业生活
工具
汇率换算
C000003445
商业生活
工具
房贷计算器
C000003446
商业生活
工具
发票查询
C000003447
商业生活
工具
菜谱查询
C000003448
商业生活
工具
备忘录
C000003449
商业生活
工具
报价/比价
C000003450
商业生活
工具
办公工具
C000003451
商业生活
工具
AR识别
C101056915
商业生活
工具
合约服务
C000003456
商业生活
回收租赁
充电宝查找
C100845251
商业生活
回收租赁
回收服务
C100845427
商业生活
回收租赁
在线租赁
C100861963
商业生活
回收租赁
充电宝租赁
C100862141
商业生活
回收租赁
其他共享租赁
C101137996
商业生活
回收租赁
线下回收服务
C000003462
商业生活
会计/金融咨询
在线咨询
C000003463
商业生活
婚庆摄影
证件照在线制作
C000003464
商业生活
婚庆摄影
在线冲印
C000003465
商业生活
婚庆摄影
摄影预约
C000003466
商业生活
婚庆摄影
摄影订购
C000003467
商业生活
婚庆摄影
婚庆服务咨询
C000003468
商业生活
婚庆摄影
婚庆服务预约
C000003469
商业生活
婚庆摄影
到店冲印
C000003477
商业生活
母婴护理
孕期保健预约
C000003478
商业生活
母婴护理
月嫂预定
C000003479
商业生活
母婴护理
婴儿护理预约
C000003483
商业生活
人才招聘
人才招聘服务
C000003484
商业生活
生活服务平台
跑腿服务
C000003485
商业生活
物业管理
物业缴费
C000003486
商业生活
物业管理
物业服务
C000003507
生活缴费
话费宽带缴费
话费充值
C000003508
生活缴费
话费宽带缴费
余额查询
C100845242
生活缴费
话费宽带缴费
话费账单查询
C100845243
生活缴费
话费宽带缴费
话费不足提醒
C100845244
生活缴费
话费宽带缴费
宽带到期提醒
C100845419
生活缴费
话费宽带缴费
话费自动充值
C100845420
生活缴费
话费宽带缴费
宽带缴费提醒
C101069023
生活缴费
话费宽带缴费
流量不足提醒
C101093024
生活缴费
话费宽带缴费
宽带办理
C101093125
生活缴费
话费宽带缴费
号卡办理
C101093261
生活缴费
话费宽带缴费
流量充值
C000003515
网络通讯
软件开发
软件及应用开发服务
C000003516
网络通讯
软件开发
互联网数据服务
C000003518
网络通讯
网络推广
网络推广服务
C000003519
网络通讯
网络推广
网络公关服务
C000003520
网络通讯
网络推广
市场调查
C000003521
网络通讯
网络推广
广告传媒服务
C000003522
网络通讯
信息论坛
信息检索服务
C000003523
物流运输
物流仓储
同城即时配送服务
C000003524
物流运输
物流仓储
铁路运输服务
C000003525
物流运输
物流仓储
收件
C000003526
物流运输
物流仓储
快递柜服务
C000003527
物流运输
物流仓储
寄件
C000003529
物流运输
物流仓储
海运/船舶运输服务
C000003530
物流运输
物流仓储
国际货运服务
C000003531
物流运输
物流仓储
查件
C000003532
物流运输
物流仓储
仓储服务
C100977473
物流运输
物流仓储
拉货服务
C000003535
休闲娱乐
彩票
开奖查询
C000003536
休闲娱乐
彩票
奖金计算
C000003537
休闲娱乐
歌舞厅/KTV
在线预定
C000003538
休闲娱乐
歌舞厅/KTV
在线订购
C000003540
休闲娱乐
歌舞厅/KTV
扫码点歌服务
C000003541
休闲娱乐
歌舞厅/KTV
到店订购
C000003549
休闲娱乐
棋牌桌游/电玩网吧
在线预定
C000003550
休闲娱乐
棋牌桌游/电玩网吧
在线订购
C000003560
医疗卫生
健康护理机构
在线咨询
C000003561
医疗卫生
健康护理机构
在线订购
C000003562
医疗卫生
健康护理机构
健康咨询
C000003563
医疗卫生
健康护理机构
健康体检
C000003564
医疗卫生
健康护理机构
护理预约
C000003565
医疗卫生
线上医疗
在线问诊
C000003566
医疗卫生
线上医疗
预约挂号
C100949453
医疗卫生
线上医疗
核酸检测预约
C000003567
医疗卫生
医药器械销售
在线订购
C000003568
医疗卫生
医药器械销售
同城配送
C000003569
医疗卫生
医药销售
在线订购
C000003570
医疗卫生
医药销售
同城配送
C000003571
医疗卫生
医院
在线问诊
C000003572
医疗卫生
医院
预约挂号
C000003573
医疗卫生
医院
疫苗预约
C000003574
医疗卫生
医院
健康体检
C000003575
医疗卫生
医院
报告查询
C100949324
医疗卫生
医院
新冠疫苗预约
C100949454
医疗卫生
医院
疫苗/疫情相关查询
C101011137
医疗卫生
医院
挂号记录查询
C101011138
医疗卫生
医院
在线建档
C101011139
医疗卫生
医院
候诊查询
C101011140
医疗卫生
医院
入院登记
C101011141
医疗卫生
医院
住院押金
C101011142
医疗卫生
医院
出院结算
C101011143
医疗卫生
医院
科室介绍
C101011144
医疗卫生
医院
院内导航
C101011146
医疗卫生
医院
病案复印
C101011147
医疗卫生
医院
电子健康卡
C101011148
医疗卫生
医院
预约护理
C101011308
医疗卫生
医院
门诊缴费
C101011309
医疗卫生
医院
线上取号
C101011310
医疗卫生
医院
预约床位
C101011311
医疗卫生
医院
缴费记录查询
C101011312
医疗卫生
医院
住院清单
C101011313
医疗卫生
医院
医院介绍
C101011314
医疗卫生
医院
专家介绍
C101011315
医疗卫生
医院
来院导航
C101011316
医疗卫生
医院
就医指南
C101011317
医疗卫生
医院
智能导诊
C101011318
医疗卫生
医院
电子发票
C101011319
医疗卫生
医院
中药代煎
C101011320
医疗卫生
医院
在线续方
C101036010
医疗卫生
医院
医院推荐内部专用
C100845248
公共管理和社会组织
户政服务
身份证办理
C100845249
公共管理和社会组织
户政服务
居住证办理
C100845250
公共管理和社会组织
户政服务
证明开具
C100845424
公共管理和社会组织
户政服务
身份证挂失
C100845425
公共管理和社会组织
户政服务
居住证挂失
C100845426
公共管理和社会组织
户政服务
户口查询
C100949076
公共管理和社会组织
户政服务
落户认定
C100949193
公共管理和社会组织
户政服务
电子证件
C100949194
公共管理和社会组织
户政服务
临时身份证明
C100949306
公共管理和社会组织
户政服务
办件进度查询
C100845236
公共管理和社会组织
出入境服务
证件查询
C100845237
公共管理和社会组织
出入境服务
预约办证
C100845414
公共管理和社会组织
出入境服务
再次签注
C100928482
支付宝内部专用
商家服务
商家工具
C100928640
支付宝内部专用
商家服务
商家权益
C101100964
支付宝内部专用
商家服务
商家团购
C100948776
公共管理和社会组织
医保
医保电子凭证
C100948777
公共管理和社会组织
医保
综合医保服务
C100948895
公共管理和社会组织
医保
医保查询
C100948896
公共管理和社会组织
医保
医保办理
C100948897
公共管理和社会组织
医保
医保缴费
C101011136
公共管理和社会组织
医保
医保购险
C101011307
公共管理和社会组织
医保
医保购药
C100948787
公共管理和社会组织
房产服务
综合房产服务
C100948788
公共管理和社会组织
房产服务
不动产办理
C100948907
公共管理和社会组织
房产服务
不动产查询
C100948908
公共管理和社会组织
房产服务
不动产证明
C100948909
公共管理和社会组织
房产服务
房产摇号
C100948912
公共管理和社会组织
税务
综合税务服务
C100948913
公共管理和社会组织
税务
申报信息查询
C100948914
公共管理和社会组织
税务
证明查询
C100948915
公共管理和社会组织
税务
纳税评估查询
C100948916
公共管理和社会组织
税务
办理点查询
C100948917
公共管理和社会组织
税务
税务缴费
C100948918
公共管理和社会组织
工商
综合工商服务
C100948919
公共管理和社会组织
工商
企业机构查询
C100948920
公共管理和社会组织
工商
个体工商户查询
C100949326
休闲娱乐
体育赛事
线上报名
C100949456
休闲娱乐
体育赛事
赛事查询
C100954641
休闲娱乐
体育赛事
赛时点播
C100954642
休闲娱乐
体育赛事
比赛数据榜
C100954769
休闲娱乐
体育赛事
赛事投票
C100955086
休闲娱乐
体育赛事
体育互动
C101021689
休闲娱乐
体育赛事
赛事报名
C101021690
休闲娱乐
体育赛事
赛事购票
C101021803
休闲娱乐
体育赛事
亚运会开闭幕式报名
C101017045
商业生活
综合生活服务平台
上门服务