Browse Source

测试专用

develop
李可松 4 years ago
parent
commit
29425379f4
  1. 17
      app/Http/Controllers/Api/TestController.php

17
app/Http/Controllers/Api/TestController.php

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Api;
use App\Models\Order;
use App\Models\OrderProductItem;
use App\Models\Product;
/**
@ -14,6 +16,19 @@ class TestController
public function index()
{
//test
return Product::query()->whereIn('id', explode(',', '1,2,3,4,5,6'))->get(['id AS product_id', 'supplier_id']);
$ids = Order::all(['id AS order_id', 'product_ids', 'agent_id', 'agent_product_id']);
foreach ($ids as $v) {
$item = Product::query()->whereIn('id', explode(',', $v['product_ids']))
->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray();
foreach ($item as $v2) {
if (!OrderProductItem::query()->where(['order_id' => $v['order_id'], 'product_id' => $v2['product_id']])->exists()) {
$v2['order_id'] = $v['order_id'];
$v2['agent_id'] = $v['agent_id'];
$v2['agent_product_id'] = $v['agent_product_id'];
OrderProductItem::query()->create($v2);
}
}
}
return '';
}
}
Loading…
Cancel
Save