|
|
@@ -2,14 +2,16 @@
|
|
|
|
|
|
namespace saas\controllers;
|
|
|
|
|
|
+use Yii;
|
|
|
use biz\admin\services\AdminService;
|
|
|
use biz\merchant\services\MerchantService;
|
|
|
use common\components\util;
|
|
|
-use Yii;
|
|
|
+use common\components\weixinUtil;
|
|
|
+use common\services\xhMerchantService;
|
|
|
|
|
|
class MerchantController extends BaseController
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//商家列表 shish 2019.12.20
|
|
|
public function actionList()
|
|
|
{
|
|
|
@@ -17,7 +19,7 @@ class MerchantController extends BaseController
|
|
|
$list = MerchantService::getSaasMerchant($where);
|
|
|
util::success($list);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//获取当前登陆老板的帐号详情,官网购买套餐时使用 shish 2020.1.11
|
|
|
public function actionLoginAccount()
|
|
|
{
|
|
|
@@ -38,5 +40,147 @@ class MerchantController extends BaseController
|
|
|
$merchant = MerchantService::getMerchantById(12358);
|
|
|
util::success($merchant);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function actionBindOpen()
|
|
|
+ {
|
|
|
+ $account = Yii::$app->request->get('account', 0);
|
|
|
+ $merchant = MerchantService::getById($account);
|
|
|
+ if (empty($merchant)) {
|
|
|
+ util::fail('没有找到商家');
|
|
|
+ }
|
|
|
+ $wxAppId = $merchant['wxAppId'];
|
|
|
+ $miniAppId = $merchant['miniAppId'];
|
|
|
+ $openAppId = $merchant['openAppId'];
|
|
|
+
|
|
|
+ echo "<pre>";
|
|
|
+
|
|
|
+ $id = Yii::$app->request->get('id', 0);
|
|
|
+ //创建平台,并将公众号绑定到平台
|
|
|
+ if ($id == 1) {
|
|
|
+ weixinUtil::createOpenAccount($wxAppId, $this->merchant);
|
|
|
+ $return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ if ($return['errcode'] == 0) {
|
|
|
+ $openAppId = $return['open_appid'];
|
|
|
+ xhMerchantService::updateById($this->merchantId, ['openAppId' => $openAppId]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //将小程序绑定到平台
|
|
|
+ if ($id == 2) {
|
|
|
+ $openAppId = $merchant['openAppId'];
|
|
|
+ $r = weixinUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
|
|
|
+ print_r($r);
|
|
|
+ }
|
|
|
+ //查询公众号 小程序的绑定情况
|
|
|
+ if ($id == 3) {
|
|
|
+ $return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ $return = weixinUtil::getOpenAccount($miniAppId, $this->merchant, true);
|
|
|
+ print_r($return);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置小程序服务器域名
|
|
|
+ if ($id == 4) {
|
|
|
+ weixinUtil::setDomain($this->merchant);
|
|
|
+ weixinUtil::setWebViewDomain($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //为授权的小程序帐号上传小程序代码
|
|
|
+ if ($id == 5) {
|
|
|
+ $tId = $_GET['tId'];
|
|
|
+ weixinUtil::miniCommit($this->merchant, $tId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取小程序体验码
|
|
|
+ if ($id == 6) {
|
|
|
+ weixinUtil::getExperienceQrCode($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取授权小程序帐号已设置的类目
|
|
|
+ if ($id == 7) {
|
|
|
+ weixinUtil::getMiniCategory($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取小程序的第三方提交代码的页面配置
|
|
|
+ if ($id == 8) {
|
|
|
+ weixinUtil::getMiniPage($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //将第三方提交的代码包提交审核
|
|
|
+ if ($id == 9) {
|
|
|
+ weixinUtil::miniSubmitAudit($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询最新一次提交的审核状态
|
|
|
+ if ($id == 10) {
|
|
|
+ weixinUtil::miniGetLatestAuditStatus($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //发布已通过审核的小程序
|
|
|
+ if ($id == 11) {
|
|
|
+ weixinUtil::miniRelease($this->merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //撤回审核
|
|
|
+ if ($id == 12) {
|
|
|
+ weixinUtil::rollbackCheck($this->merchant);
|
|
|
+ }
|
|
|
+ //生成 申请会员页 的小程序码
|
|
|
+ if ($id == 13) {
|
|
|
+ weixinUtil::generateMemberCode($this->merchant);
|
|
|
+ }
|
|
|
+ //解绑小程序和公众号绑定的平台
|
|
|
+ if ($id == 14) {
|
|
|
+ weixinUtil::unbindAccount($this->merchant);
|
|
|
+ weixinUtil::unbindMiniProgram($this->merchant);
|
|
|
+ }
|
|
|
+ Yii::$app->end();
|
|
|
+
|
|
|
+ $r = weixinUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
|
|
|
+ print_r($r);
|
|
|
+ echo $miniAppId . ' ' . $openAppId . ' ';
|
|
|
+
|
|
|
+ $return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ die;
|
|
|
+
|
|
|
+ $return = weixinUtil::createOpenAccount($wxAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ die;
|
|
|
+
|
|
|
+ $r = weixinUtil::bindOpenAccount($miniAppId, $openAppId, $merchant);
|
|
|
+ print_r($r);
|
|
|
+ echo $miniAppId . ' ' . $openAppId . ' ';
|
|
|
+
|
|
|
+ $return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ $return = weixinUtil::getOpenAccount($miniAppId, $this->merchant);
|
|
|
+ print_r($return);
|
|
|
+ die;
|
|
|
+
|
|
|
+ if ($return['errcode'] == 0) {
|
|
|
+ $openAppId = isset($return['open_appid']) ? $return['open_appid'] : '';
|
|
|
+ } else {
|
|
|
+ $return = weixinUtil::createOpenAccount($wxAppId, $this->merchant);
|
|
|
+ if ($return['errcode'] == 0) {
|
|
|
+ $openAppId = isset($return['open_appid']) ? $return['open_appid'] : '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ echo "<br />openAppId:" . $openAppId . "<br />";
|
|
|
+ if (!empty($openAppId)) {
|
|
|
+ xhMerchantService::updateById($this->merchantId, ['openAppId' => $openAppId]);
|
|
|
+ $r = weixinUtil::bindOpenAccount($miniAppId, $openAppId, $merchant);
|
|
|
+ echo "绑定小程序结果:<br />";
|
|
|
+ print_r($r);
|
|
|
+ }
|
|
|
+ echo "<br /><br />";
|
|
|
+ $return = weixinUtil::getOpenAccount($wxAppId, $merchant);
|
|
|
+ echo "微信appId:{$wxAppId}<br />";
|
|
|
+ print_r($return);
|
|
|
+ $return = weixinUtil::getOpenAccount($miniAppId, $merchant);
|
|
|
+ echo "<br />小程序appId:{$miniAppId}<br />";
|
|
|
+ print_r($return);
|
|
|
+ }
|
|
|
|
|
|
}
|