|
|
@@ -280,6 +280,47 @@ class InitController extends Controller
|
|
|
|
|
|
self::migrationDel();
|
|
|
|
|
|
+ //客户和供应商的中央化
|
|
|
+ self::ghsCustomMain();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //客户和供应商的中央化 ssh 20220506
|
|
|
+ public static function ghsCustomMain()
|
|
|
+ {
|
|
|
+ $map = [];
|
|
|
+ $allShop = ShopClass::getAllByCondition(['id>' => 0], null, '*', null, true);
|
|
|
+ if (!empty($allShop)) {
|
|
|
+ foreach ($allShop as $single) {
|
|
|
+ $mainId = $single->mainId ?? 0;
|
|
|
+ $shopId = $single->id ?? 0;
|
|
|
+ $map[$shopId] = $mainId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
|
|
|
+ if (!empty($customList)) {
|
|
|
+ foreach ($customList as $custom) {
|
|
|
+ $shopId = $custom->shopId ?? 0;
|
|
|
+ $mainId = $map[$shopId] ?? 0;
|
|
|
+ $custom->mainId = $mainId;
|
|
|
+ $ownShopId = $custom->ownShopId ?? 0;
|
|
|
+ $ownMainId = $map[$ownShopId] ?? 0;
|
|
|
+ $custom->ownMainId = $ownMainId;
|
|
|
+ $custom->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $ghsList = GhsClass::getByCondition(['id>' => 0], null, '*', null, true);
|
|
|
+ foreach ($ghsList as $ghs) {
|
|
|
+ $shopId = $ghs->shopId ?? 0;
|
|
|
+ $mainId = $map[$shopId] ?? 0;
|
|
|
+ $ghs->mainId = $mainId;
|
|
|
+ $ownShopId = $ghs->ownShopId ?? 0;
|
|
|
+ $ownMainId = $map[$ownShopId] ?? 0;
|
|
|
+ $ghs->ownMainId = $ownMainId;
|
|
|
+ $ghs->save();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|