海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
908 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Models\Order;
  4. use App\Models\OrderProductItem;
  5. use App\Models\Product;
  6. /**
  7. * 仅用于测试
  8. * Class TController
  9. * @package App\Http\Controllers\Api
  10. */
  11. class TestController
  12. {
  13. public function index()
  14. {
  15. //test
  16. $ids = Order::orderBy('id')->get(['id AS order_id', 'product_ids', 'agent_id', 'agent_product_id']);
  17. foreach ($ids as $v) {
  18. $item = Product::query()->whereIn('id', explode(',', $v['product_ids']))
  19. ->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray();
  20. foreach ($item as $v2) {
  21. if (!OrderProductItem::query()->where(['order_id' => $v['order_id'], 'product_id' => $v2['product_id']])->exists()) {
  22. $v2['order_id'] = $v['order_id'];
  23. $v2['agent_id'] = $v['agent_id'];
  24. $v2['agent_product_id'] = $v['agent_product_id'];
  25. OrderProductItem::query()->create($v2);
  26. }
  27. }
  28. }
  29. return '';
  30. }
  31. }