ShopController.php 3.3 KB

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