예제 #1
0
 /**
  * List all test wechat accounts
  *
  * <b>Request Type</b>: GET<br/><br/>
  * <b>Request Endpoint</b>:http://{server-domain}/api/management/channel/test-wechat-list<br/><br/>
  * <b>Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used to create test wechat account.
  * <br/><br/>
  *
  * <b>Response Example</b>:<br/>
  * <pre>
  * [
  *     {
  *         accountType: "SUBSCRIPTION_ACCOUNT"
  *         appId: "wx5c208e957d25a9fe"
  *         appSecret: "79ac3d410703781ece8e99f162419b48"
  *         channel: "WEIXIN"
  *         channelAccount: "gh_3beb200f225e"
  *         createTime: 1431597000381
  *         encodingAESKey: "1QW34RDFB567UI34DGT60OWSMFJKE432WASXLPO0I7R"
  *         id: "55546fc8e4b0d8376000b858"
  *         name: "唯1のse彩"
  *         serviceUrl: "http://dev.wx.quncrm.com/wechat/wx5c208e957d25a9fe"
  *         status: "ENABLE"
  *         token: "XF3E2FF34DFD4457FASAF34565FDA3562"
  *     }
  * ]
  * </pre>
  */
 public function actionTestWechatList()
 {
     //update account information and insert the new channel
     $accountId = $this->getAccountId();
     $account = Account::findByPk($accountId);
     $result = [];
     $testWechatIds = Channel::getWechatByAccount($accountId, true);
     if (!empty($testWechatIds)) {
         $result = Yii::$app->weConnect->getAccounts($testWechatIds);
     }
     return $result;
 }
예제 #2
0
 /**
  * Sync the stores data from wechat
  */
 public function actionSync()
 {
     $accountId = Token::getAccountId();
     $result = ['finished' => true];
     $account = Account::find()->select(['syncWechat'])->where(['_id' => $accountId, 'isDeleted' => Account::NOT_DELETED])->one();
     $wechat = Channel::getWechatByAccount($accountId, false);
     if (!empty($wechat)) {
         $unsyncWechat = array_diff($wechat, (array) $account->syncWechat);
         if (!empty($unsyncWechat)) {
             $args = ['accountId' => $accountId . '', 'channels' => $unsyncWechat, 'description' => 'Direct: Sync the stores data from wechat'];
             $token = Yii::$app->job->create('backend\\modules\\channel\\job\\StoreSync', $args);
             $result = ['finished' => false, 'token' => $token];
         }
     }
     return $result;
 }