|
|
@@ -73,18 +73,27 @@ class CustomClass extends BaseClass
|
|
|
|
|
|
public static function pullOtherShopCustom($data)
|
|
|
{
|
|
|
- $toShopId = $data['toShopId'] ?? 0;
|
|
|
- $fromShopId = $data['fromShopId'] ?? 0;
|
|
|
- //指定当前环境为批发商,重要!!!
|
|
|
- Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
- $fromCustomList = CustomClass::getAllByCondition(['ownShopId' => $fromShopId], null, '*');
|
|
|
- if (!empty($fromCustomList)) {
|
|
|
- foreach ($fromCustomList as $fromCustomer) {
|
|
|
- $exist = CustomClass::exists(['ownShopId' => $toShopId, 'shopId' => $fromCustomer['shopId']]);
|
|
|
- if (!$exist) {
|
|
|
- CustomClass::build($toShopId, $fromCustomer['shopId'], $fromCustomer['name']);
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $toShopId = $data['toShopId'] ?? 0;
|
|
|
+ $fromShopId = $data['fromShopId'] ?? 0;
|
|
|
+ //指定当前环境为批发商,重要!!!
|
|
|
+ Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
+ $fromCustomList = CustomClass::getAllByCondition(['ownShopId' => $fromShopId], null, '*');
|
|
|
+ if (!empty($fromCustomList)) {
|
|
|
+ foreach ($fromCustomList as $fromCustomer) {
|
|
|
+ $exist = CustomClass::exists(['ownShopId' => $toShopId, 'shopId' => $fromCustomer['shopId']]);
|
|
|
+ if (!$exist) {
|
|
|
+ CustomClass::build($toShopId, $fromCustomer['shopId'], $fromCustomer['name']);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ $transaction->commit();
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ noticeUtil::push("拉取客户报报错:{$fromShopId} {$toShopId},报错内容:" . $exception->getMessage(), '15280215347');
|
|
|
}
|
|
|
return true;
|
|
|
}
|