|
@@ -15,6 +15,7 @@ use biz\saas\services\SetAuthService;
|
|
|
use biz\saas\services\SetMealService;
|
|
use biz\saas\services\SetMealService;
|
|
|
use biz\user\services\UserService;
|
|
use biz\user\services\UserService;
|
|
|
use biz\weixin\classes\WxOpenClass;
|
|
use biz\weixin\classes\WxOpenClass;
|
|
|
|
|
+use biz\weixin\services\WxMenuService;
|
|
|
use common\components\business;
|
|
use common\components\business;
|
|
|
use common\components\util;
|
|
use common\components\util;
|
|
|
use common\services\xhTMessageService;
|
|
use common\services\xhTMessageService;
|
|
@@ -158,16 +159,31 @@ class MerchantService extends BaseService
|
|
|
$connection = Yii::$app->db;
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
try {
|
|
|
|
|
+
|
|
|
//初始化微信菜单
|
|
//初始化微信菜单
|
|
|
- xhWxMenuService::applyInit($merchant);
|
|
|
|
|
|
|
+ $hasMenu = WxMenuService::getByCondition(['merchantId' => $merchantId]);
|
|
|
|
|
+ if (empty($hasMenu)) {
|
|
|
|
|
+ xhWxMenuService::applyInit($merchant);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//微信客户初始化
|
|
//微信客户初始化
|
|
|
- $return = UserService::syncWxAllUser($merchantId);
|
|
|
|
|
- $totalNum = isset($return['total']) ? $return['total'] : 0;
|
|
|
|
|
- MerchantAssetClass::updateByCondition(['merchantId' => $merchantId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]);
|
|
|
|
|
|
|
+ $hasUser = UserService::getByCondition(['merchantId' => $merchantId]);
|
|
|
|
|
+ if (empty($hasUser)) {
|
|
|
|
|
+ $return = UserService::syncWxAllUser($merchantId);
|
|
|
|
|
+ $totalNum = isset($return['total']) ? $return['total'] : 0;
|
|
|
|
|
+ MerchantAssetClass::updateByCondition(['merchantId' => $merchantId], ['totalFans' => $totalNum, 'totalUser' => $totalNum]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//模板消息
|
|
//模板消息
|
|
|
- xhTMessageService::init($merchant);
|
|
|
|
|
|
|
+ $hasMessage = TMessageService::getByCondition(['merchantId'=>$merchantId]);
|
|
|
|
|
+ if(empty($hasMessage)){
|
|
|
|
|
+ xhTMessageService::init($merchant);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//完成初始化标识
|
|
//完成初始化标识
|
|
|
MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
|
|
MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
|
|
|
|
|
+
|
|
|
$transaction->commit();
|
|
$transaction->commit();
|
|
|
return true;
|
|
return true;
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|