| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Http\Controllers;
- use App\Components\AsyncResponse;
- use App\Services\ReplenishmentService;
- use Illuminate\Http\Request;
- class ReplenishmentController extends Controller
- {
- use AsyncResponse;
- public function getReplenishmentInfoByCustomer(Request $request)
- {
- $this->gate("库存管理-补货列表");
- $customer=$request->input('customer');
- if (!$customer)$this->error('请选择指定货主!');
- /** @var ReplenishmentService $service */
- $service = app('ReplenishmentService');
- $orders=$service->getOrderInfoRecentMonthByCustomer($customer);
- $skuArr=array_diff(array_unique(data_get($orders, '*.sku')), ['', '*', null]);
- $info=$service->getEaInventoryByCustomerAndSku($customer,$skuArr);
- $rsInfo=$service->getRsInventoryByCustomerAndSku($customer,$skuArr);
- //将整合后拣货位信息 结合订单汇总
- foreach ($orders as &$order){
- if(isset($info[$order['sku']])){
- $item = $info[$order['sku']];
- $order['amount']=($order['amount']-$item['qty']);
- $order['eaLocation']=$item['locationid'];
- }else{
- $order['eaLocation']=[];
- }
- if(isset($rsInfo[$order['sku']])){
- $rsItem = $rsInfo[$order['sku']];
- $order['rsLocation']=$rsItem['locationid'];
- }else{
- $order['rsLocation']=[];
- }
- }
- if (count($orders)>0)$this->success($orders);
- else $this->error('未查询到相应信息!');
- }
- }
|