ShopController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace console\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\shop\classes\ShopClass;
  5. use bizGhs\custom\classes\CustomClass;
  6. use yii\console\Controller;
  7. use Yii;
  8. class ShopController extends Controller
  9. {
  10. public function actionCustom()
  11. {
  12. $custom = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  13. if (empty($custom)) {
  14. echo '空';
  15. return false;
  16. }
  17. foreach ($custom as $item) {
  18. $shopId = $item->shopId ?? 0;
  19. $shop = ShopClass::getById($shopId, true);
  20. if ($shop->mainId != $item->mainId) {
  21. echo "客户id:{$item->id} {$shop->mainId} {$item->mainId}\n";
  22. if (!empty($shop->mainId)) {
  23. $item->mainId = $shop->mainId;
  24. $item->save();
  25. }
  26. }
  27. $ownShopId = $item->ownShopId ?? 0;
  28. $ownShop = ShopClass::getById($ownShopId, true);
  29. if ($ownShop->mainId != $item->ownMainId) {
  30. echo "客户own {$item->id} {$item->ownMainId} {$ownShop->mainId}\n";
  31. if (!empty($ownShop->mainId)) {
  32. $item->ownMainId = $ownShop->mainId;
  33. $item->save();
  34. }
  35. }
  36. }
  37. }
  38. public function actionGhs()
  39. {
  40. $ghs = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  41. if (empty($ghs)) {
  42. echo '空';
  43. return false;
  44. }
  45. foreach ($ghs as $item) {
  46. $shopId = $item->shopId ?? 0;
  47. $mainId = $item->mainId ?? 0;
  48. $shop = ShopClass::getById($shopId, true);
  49. if ($shop->mainId != $mainId) {
  50. echo "ghs {$item->id} {$mainId} {$shop->mainId} \n";
  51. }
  52. $ownShopId = $item->ownShopId ?? 0;
  53. $ownMainId = $item->ownMainId ?? 0;
  54. $ownShop = ShopClass::getById($ownShopId, true);
  55. if ($ownShop->mainId != $ownMainId) {
  56. echo "ghs own {$item->id} {$ownMainId} {$ownShop->mainId} \n";
  57. if (!empty($ownShop->mainId)) {
  58. $item->ownMainId = $ownShop->mainId;
  59. $item->save();
  60. }
  61. }
  62. }
  63. }
  64. }