|
|
@@ -13,6 +13,8 @@ use App\Services\common\BatchUpdateService;
|
|
|
use App\Services\common\DataHandlerService;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Support\Collection;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class OrderPackageService
|
|
|
{
|
|
|
@@ -507,5 +509,52 @@ class OrderPackageService
|
|
|
return collect();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // TODO
|
|
|
+ public function createPackagesFromBatchCode($batchCode,$weight)
|
|
|
+ {
|
|
|
+ /**
|
|
|
+ * @var OrderService $orderService
|
|
|
+ */
|
|
|
+ $now = Carbon::now();
|
|
|
+ $orderService = app(Order::class);
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->select(implode(',',OracleDOCOrderHeaderService::$columns))
|
|
|
+ ->with(['oracleBASCustomer'=>function($query){
|
|
|
+ $query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
|
|
|
+ },'oracleDOCOrderDetails'=>function($query){
|
|
|
+ $query->selectRaw('doc_order_details.orderNo,doc_order_details.CustomerId,doc_order_details.sku,doc_order_details.QtyOrdered');
|
|
|
+ }, 'actAllocationDetails'=>function($query){
|
|
|
+ $query->selectRaw('ACT_Allocation_Details.AllocationDetailsID,ACT_Allocation_Details.OrderNo,ACT_Allocation_Details.Qty_Each,ACT_Allocation_Details.PickToTraceID,ACT_Allocation_Details.CustomerID,ACT_Allocation_Details.Sku');
|
|
|
+ },'oracleBASCode'=>function($query){
|
|
|
+ $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
+ }])
|
|
|
+ ->where('Doc_Order_Header.WaveNo',$batchCode)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $orderService->syncOrder($orderHeaders);
|
|
|
+ $orders = Order::query()->with('packages')->whereIn('code',data_get($orderHeaders,'*.orderno'))->get();
|
|
|
+ $update_params = [[
|
|
|
+ 'id','weight','weighed_at','status','batch_number'
|
|
|
+ ]];
|
|
|
+ foreach ($orderHeaders as $orderHeader) {
|
|
|
+ $order = $orders->where('code',$orderHeader->orderno)->first();
|
|
|
+ if(!$order){
|
|
|
+ app('LogService')->log(__METHOD__,"此包裹在WMS未找到order",json_encode($orderHeader),Auth::user()['id']);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $order->packages->each(function($package)use(&$update_params,$weight,$batchCode,$now){
|
|
|
+ $update_params[] = [
|
|
|
+ 'id' => $package->id,
|
|
|
+ 'weight' =>$weight,
|
|
|
+ 'weighed_at'=>$now,
|
|
|
+ 'status' =>"已上传",
|
|
|
+ 'batch_number' => $batchCode
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(count($update_params)==1)return;
|
|
|
+ DB::transaction(function ()use($update_params){
|
|
|
+ $this->batchUpdate($update_params);
|
|
|
+ });
|
|
|
+ app('LogService')->log(__METHOD__,"批量录入包裹成功",json_encode($update_params),Auth::user()['id']);
|
|
|
+ }
|
|
|
}
|