RefundItemController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace console\controllers;
  3. use biz\product\classes\ProductClass;
  4. use biz\stat\classes\StatItemClass;
  5. use bizGhs\order\classes\OrderClass;
  6. use bizGhs\order\classes\OrderItemClass;
  7. use bizGhs\order\classes\RefundOrderClass;
  8. use bizGhs\order\classes\RefundOrderItemClass;
  9. use yii\console\Controller;
  10. class RefundItemController extends Controller
  11. {
  12. // ./yii refund-item/complete
  13. public function actionComplete()
  14. {
  15. $list = RefundOrderItemClass::getAllByCondition([], null, '*', null, true);
  16. if (empty($list)) {
  17. return false;
  18. }
  19. foreach ($list as $key => $item) {
  20. $orderSn = $item->orderSn ?? '';
  21. if (empty($orderSn)) {
  22. continue;
  23. }
  24. $refund = RefundOrderClass::getByCondition(['orderSn' => $orderSn], true);
  25. if (empty($refund)) {
  26. continue;
  27. }
  28. $sjId = $refund->sjId ?? 0;
  29. $shopId = $refund->shopId ?? 0;
  30. $item->sjId = $sjId;
  31. $item->shopId = $shopId;
  32. $item->save();
  33. $date = date('Ymd', strtotime($refund->addTime));
  34. StatItemClass::refundReplace($item, $date);
  35. }
  36. }
  37. // ./yii refund-item/order
  38. public function actionOrder()
  39. {
  40. $list = OrderClass::getAllByCondition([], null, '*', null, true);
  41. echo "数量:" . count($list) . "\n";
  42. if (empty($list)) {
  43. return false;
  44. }
  45. foreach ($list as $key => $order) {
  46. $status = $order->status ?? 0;
  47. if (in_array($status, [1, 5])) {
  48. continue;
  49. }
  50. $orderSn = $order->orderSn ?? '';
  51. if (empty($orderSn)) {
  52. continue;
  53. }
  54. $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  55. if (!empty($itemList)) {
  56. foreach ($itemList as $itemInfo) {
  57. if ($itemInfo->id == 3381) {
  58. echo "找到3381 \n";
  59. }
  60. $sjId = $itemInfo->sjId ?? 0;
  61. $shopId = $itemInfo->shopId ?? 0;
  62. $productId = $itemInfo->productId ?? 0;
  63. if (empty($sjId) || empty($shopId)) {
  64. $p = ProductClass::getById($productId, true);
  65. $sjId = $p->sjId ?? 0;
  66. $shopId = $p->shopId ?? 0;
  67. $itemInfo->sjId = $sjId;
  68. $itemInfo->shopId = $shopId;
  69. $itemInfo->save();
  70. echo "发现没有sjId shopId 已经补充 orderItemId:{$itemInfo->id} sjId:{$sjId} shopId:{$shopId} 如果是0表示没有补到 \n";
  71. }
  72. $date = date('Ymd', strtotime($order->addTime));
  73. StatItemClass::replace($itemInfo, $date);
  74. }
  75. }
  76. }
  77. }
  78. }