|
|
@@ -8,6 +8,7 @@ use biz\base\services\BaseService;
|
|
|
use biz\merchant\classes\AdminClass;
|
|
|
use biz\merchant\classes\MerchantAssetClass;
|
|
|
use biz\merchant\classes\MerchantClass;
|
|
|
+use biz\merchant\classes\MerchantExtendClass;
|
|
|
use biz\merchant\classes\ShopClass;
|
|
|
use biz\message\services\TMessageService;
|
|
|
use biz\saas\services\SetAuthService;
|
|
|
@@ -149,24 +150,26 @@ class MerchantService extends BaseService
|
|
|
if (empty($merchant)) {
|
|
|
return false;
|
|
|
}
|
|
|
- $connection = Yii::$app->db;//事务处理
|
|
|
+ $extend = MerchantExtendClass::getByMerchantId($merchantId);
|
|
|
+ if (isset($extend['init']) && $extend['init'] == 1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //事务处理
|
|
|
+ $connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
-
|
|
|
//初始化微信菜单
|
|
|
xhWxMenuService::applyInit($merchant);
|
|
|
-
|
|
|
//微信客户初始化
|
|
|
$return = UserService::syncWxAllUser($merchantId);
|
|
|
$totalNum = isset($return['total']) ? $return['total'] : 0;
|
|
|
MerchantAssetClass::updateByCondition(['merchantId' => $merchantId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]);
|
|
|
-
|
|
|
//模板消息
|
|
|
xhTMessageService::init($merchant);
|
|
|
-
|
|
|
+ //完成初始化标识
|
|
|
+ MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
|
|
|
$transaction->commit();
|
|
|
return true;
|
|
|
-
|
|
|
} catch (Exception $e) {
|
|
|
$transaction->rollBack();
|
|
|
return false;
|