ShopController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 bizGhs\order\classes\OrderClass;
  7. use bizGhs\order\models\Order;
  8. use yii\console\Controller;
  9. use Yii;
  10. class ShopController extends Controller
  11. {
  12. public function actionOrder()
  13. {
  14. $query = new \yii\db\Query();
  15. $query->from(Order::tableName());
  16. $query->where(['>', 'id', 0]);
  17. foreach ($query->batch() as $orderList) {
  18. foreach ($orderList as $order) {
  19. $payTime = $order['payTime'] ?? '';
  20. if (!empty($payTime) && $payTime != '0000-00-00 00:00:00') {
  21. $addTime = $order['addTime'] ?? '';
  22. if ($payTime > $addTime) {
  23. echo "id:{$order['id']} {$payTime} {$addTime}\n";
  24. }
  25. }
  26. }
  27. }
  28. }
  29. public function actionCustom()
  30. {
  31. $custom = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  32. if (empty($custom)) {
  33. echo '空';
  34. return false;
  35. }
  36. foreach ($custom as $item) {
  37. $shopId = $item->shopId ?? 0;
  38. $shop = ShopClass::getById($shopId, true);
  39. if ($shop->mainId != $item->mainId) {
  40. echo "客户id:{$item->id} {$shop->mainId} {$item->mainId}\n";
  41. if (!empty($shop->mainId)) {
  42. $item->mainId = $shop->mainId;
  43. $item->save();
  44. }
  45. }
  46. $ownShopId = $item->ownShopId ?? 0;
  47. $ownShop = ShopClass::getById($ownShopId, true);
  48. if ($ownShop->mainId != $item->ownMainId) {
  49. echo "客户own {$item->id} {$item->ownMainId} {$ownShop->mainId}\n";
  50. if (!empty($ownShop->mainId)) {
  51. $item->ownMainId = $ownShop->mainId;
  52. $item->save();
  53. }
  54. }
  55. }
  56. }
  57. public function actionGhs()
  58. {
  59. $ghs = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
  60. if (empty($ghs)) {
  61. echo '空';
  62. return false;
  63. }
  64. foreach ($ghs as $item) {
  65. $shopId = $item->shopId ?? 0;
  66. $mainId = $item->mainId ?? 0;
  67. $shop = ShopClass::getById($shopId, true);
  68. if ($shop->mainId != $mainId) {
  69. echo "ghs {$item->id} {$mainId} {$shop->mainId} \n";
  70. }
  71. $ownShopId = $item->ownShopId ?? 0;
  72. $ownMainId = $item->ownMainId ?? 0;
  73. $ownShop = ShopClass::getById($ownShopId, true);
  74. if ($ownShop->mainId != $ownMainId) {
  75. echo "ghs own {$item->id} {$ownMainId} {$ownShop->mainId} \n";
  76. if (!empty($ownShop->mainId)) {
  77. $item->ownMainId = $ownShop->mainId;
  78. $item->save();
  79. }
  80. }
  81. }
  82. }
  83. }