|
|
@@ -261,7 +261,7 @@ class TestController extends Controller
|
|
|
|
|
|
function t1(Request $request)
|
|
|
{
|
|
|
- $user=City::query()->first();
|
|
|
+ $user=City::query()->firstx();
|
|
|
$user['created_at'] = '2020-12-23';
|
|
|
$user->save();
|
|
|
}
|
|
|
@@ -1090,21 +1090,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
dd($requests);
|
|
|
}
|
|
|
|
|
|
- public function syncOrderTracking()
|
|
|
- {
|
|
|
- /** @var OrderTrackingService $orderTrackingService */
|
|
|
- $orderTrackingService = app('OrderTrackingService');
|
|
|
- /** @var OrderService $orderService */
|
|
|
- $orderService = app(OrderService::class);
|
|
|
- /*$owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();*/
|
|
|
- /*$startDate = \Illuminate\Support\Carbon::parse('2020-10-28 00:00:00')->toDateTimeString();*/
|
|
|
- $orderNos = ['SO201205001735', 'SO201204003891', 'SO201204003706', 'SO201204002877', 'SO201203003771'];
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
|
|
|
- ->whereIn('orderno', $orderNos)
|
|
|
- ->get();
|
|
|
- $orderService->updateByWmsOrders($orderHeaders);
|
|
|
- $orderTrackingService->createByWmsOrderHeader($orderHeaders);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
public function testSyncOrderTask()
|
|
|
{
|
|
|
@@ -1296,83 +1282,159 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
ValueStore::query()->where('name','order_last_updated_sync_at')->update(['value'=>'2020-12-22 09:00:00']);
|
|
|
}
|
|
|
|
|
|
- public function testHz(){
|
|
|
- dump('start'.Carbon::now()->toDateTimeString());
|
|
|
- $ownerAreaReportTask=new CreateOwnerAreaReport();
|
|
|
- $ownerAreaReportTask->handle();
|
|
|
- $ownerBillReportTask= new CreateOwnerBillReport();
|
|
|
- $ownerBillReportTask->handle();
|
|
|
- $ownerReportTask= new CreateOwnerReport();
|
|
|
- $ownerReportTask->handle();
|
|
|
- dump('end'.Carbon::now()->toDateTimeString());
|
|
|
+ public function syncOrderTask()
|
|
|
+ {
|
|
|
+ $service = new OrderService();
|
|
|
+ $start_data = Carbon::parse('2020-12-21 10:00:00');
|
|
|
+ $end_data = Carbon::parse('2020-12-21 11:00:00');
|
|
|
+ $orderNos = OracleDOCOrderHeader::query()->selectRaw('orderno')
|
|
|
+ ->where('addTime', '>=', $start_data)
|
|
|
+ ->where('addTime', '<=', $end_data)
|
|
|
+ ->get()->map(function($orderHeader){
|
|
|
+ return $orderHeader->orderno;
|
|
|
+ });
|
|
|
+ $order_no_list = $orderNos->chunk(3000);
|
|
|
+ foreach ($order_no_list as $order_nos) {
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(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,doc_order_details.Location');
|
|
|
+ }, '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,ACT_Allocation_Details.Location');
|
|
|
+ }, 'oracleBASCode' => function ($query) {
|
|
|
+ $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
+ }, 'orderType' => function ($query) {
|
|
|
+ $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
+ }])
|
|
|
+ ->whereIn('DOC_Order_Header.OrderNo', $order_nos)
|
|
|
+ ->get();
|
|
|
+ $service->syncOrder($orderHeaders);
|
|
|
+ unset($orderHeaders);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function syncOrderTracking()
|
|
|
+ {
|
|
|
+ $orderTrackingService = new OrderTrackingService();
|
|
|
+ $orderService = new OrderService();
|
|
|
+ $start_data = Carbon::parse('2020-12-21 10:00:00');
|
|
|
+ $end_data = Carbon::parse('2020-12-21 11:00:00');
|
|
|
+ $orderNos = OracleDOCOrderHeader::query()->selectRaw('orderno')
|
|
|
+ ->where('addTime', '>=', $start_data)
|
|
|
+ ->where('addTime', '<=', $end_data)
|
|
|
+ ->get()->map(function($orderHeader){
|
|
|
+ return $orderHeader->orderno;
|
|
|
+ });
|
|
|
+ $order_no_list = $orderNos->chunk(3000);
|
|
|
+ foreach ($order_no_list as $order_nos) {
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(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,doc_order_details.Location');
|
|
|
+ }, '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,ACT_Allocation_Details.Location');
|
|
|
+ }, 'oracleBASCode' => function ($query) {
|
|
|
+ $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
+ }, 'orderType' => function ($query) {
|
|
|
+ $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
+ }])
|
|
|
+ ->whereIn('DOC_Order_Header.OrderNo', $order_nos)
|
|
|
+ ->get();
|
|
|
+ $orderService->createByWmsOrder($orderHeaders);
|
|
|
+ $orderTrackingService->createByWmsOrderHeader($orderHeaders);
|
|
|
+ unset($orderHeaders);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public function syncOrderTask()
|
|
|
+
|
|
|
+ public function testMbStrPos()
|
|
|
{
|
|
|
- $start_data = Carbon::parse('2020-12-10 00:00:00');
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(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,doc_order_details.Location');
|
|
|
- }, '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,ACT_Allocation_Details.Location');
|
|
|
- }, 'oracleBASCode' => function ($query) {
|
|
|
- $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
- }, 'orderType' => function ($query) {
|
|
|
- $query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
- }])->where('DOC_Order_Header.AddTime', '>', $start_data)
|
|
|
+ $string = '天猫旗舰店';
|
|
|
+ dd((bool)mb_stristr('天猫旗舰店','天猫'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testOrderissue()
|
|
|
+ {
|
|
|
+ $orderIssue_unique = \App\OrderIssue::withTrashed()
|
|
|
+ ->selectRaw('count(1) as count,id,order_id')
|
|
|
+ ->whereNotNull('order_id')
|
|
|
+ ->orderByDesc('created_at')
|
|
|
+ ->groupBy('order_id')
|
|
|
+ ->having('count', '>', 1)
|
|
|
+ ->limit(100)
|
|
|
->get();
|
|
|
- $service = new OrderService();
|
|
|
- $service->syncOrder($orderHeaders);
|
|
|
+ if ($orderIssue_unique->count() == 0) return;
|
|
|
+ foreach ($orderIssue_unique as $item) {
|
|
|
+ $orderIssue_delete = OrderIssue::withTrashed()->where('order_id', $item->order_id)->get();
|
|
|
+ /** @var OrderIssue $order_issue_unique */
|
|
|
+ $order_issue_unique = $orderIssue_delete->whereNull('deleted_at')->first();
|
|
|
+ if (!$order_issue_unique) $order_issue_unique = $orderIssue_delete->first();
|
|
|
+ $ids = [];
|
|
|
+ foreach ($orderIssue_delete as $key => $order_issue) {
|
|
|
+ if ($order_issue->id == $order_issue_unique->id) continue;
|
|
|
+ $ids[] = $order_issue->id;
|
|
|
+ if($order_issue['logistic_number_return'])$order_issue_unique['logistic_number_return'] =$order_issue['logistic_number_return'];
|
|
|
+ if($order_issue['rejecting_status']!='未退回')$order_issue_unique['rejecting_status'] =$order_issue['rejecting_status'];
|
|
|
+ if($order_issue['is_new_rejecting']!='无')$order_issue_unique['is_new_rejecting'] =$order_issue['is_new_rejecting'];
|
|
|
+ if($order_issue['user_workgroup_id'])$order_issue_unique['user_workgroup_id'] =$order_issue['user_workgroup_id'];
|
|
|
+ if($order_issue['imported_status']!='正常')$order_issue_unique['imported_status'] =$order_issue['imported_status'];
|
|
|
+ if($order_issue['custom_code'])$order_issue_unique['custom_code'] =$order_issue['custom_code'];
|
|
|
+ }
|
|
|
+ $order_issue_unique->save();
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__, '修改OrderIssue:' . json_encode($order_issue_unique));
|
|
|
+ $orderIssues = OrderIssue::query()->whereIn('id',$ids)->get();
|
|
|
+ $bool = OrderIssue::query()->whereIn('id',$ids)->forceDelete();
|
|
|
+ if($bool)app('LogService')->log(__METHOD__, __FUNCTION__, '删除OrderIssue:' . json_encode($orderIssues));
|
|
|
+ }
|
|
|
}
|
|
|
- public function cleanOrderIssueRepeat()
|
|
|
+
|
|
|
+ public function testChangeOrderTracking()
|
|
|
{
|
|
|
- ini_set('max_execution_time', 6500);
|
|
|
- ini_set('memory_limit', '1526M');
|
|
|
- for ($i = 0; true; $i++) {
|
|
|
- $orderIssue_unique = \App\OrderIssue::withTrashed()
|
|
|
- ->selectRaw('count(1) as count,id,order_id')
|
|
|
- ->whereNotNull('order_id')
|
|
|
- ->orderByDesc('created_at')
|
|
|
- ->groupBy('order_id')
|
|
|
- ->having('count', '>', 1)
|
|
|
- ->limit(100)
|
|
|
+ /** @var OrderTrackingService $service */
|
|
|
+ $service = app(OrderTrackingService::class);
|
|
|
+ $maxId= \App\OrderTracking::query()->orderByDesc('id')->first();
|
|
|
+ $orderTracking_min = \App\OrderTracking::query()->where('logistic_id',0)->orderBy('id')->first();
|
|
|
+ if(!$maxId)return;
|
|
|
+ $maxId = $maxId->id;
|
|
|
+ $minId= $orderTracking_min->id;
|
|
|
+ $logistic = \App\Logistic::query()->where('name','新杰物流')->first();
|
|
|
+ $logistic_zt = \App\Logistic::query()->where('name','自提')->first();
|
|
|
+ for ($i=$minId;$i<= $maxId;$i+=100){
|
|
|
+ $orderTrackings = \App\OrderTracking::query()
|
|
|
+ ->where('id','>=',$i)
|
|
|
+ ->where('id','<=',$i+100)
|
|
|
+ ->where('logistic_id','=',0)
|
|
|
+ ->where('created_at','!=','0000-00-00 00:00:00')
|
|
|
->get();
|
|
|
- if ($orderIssue_unique->count() == 0) return;
|
|
|
- foreach ($orderIssue_unique as $item) {
|
|
|
- $orderIssue_delete = OrderIssue::withTrashed()->where('order_id', $item->order_id)->get();
|
|
|
- /** @var OrderIssue $order_issue_unique */
|
|
|
- $order_issue_unique = $orderIssue_delete->whereNull('deleted_at')->first();
|
|
|
- if(!$order_issue_unique) $order_issue_unique = $orderIssue_delete->first();
|
|
|
- $ids = [];
|
|
|
- foreach ($orderIssue_delete as $key => $order_issue) {
|
|
|
- if ($order_issue->id == $order_issue_unique->id) continue;
|
|
|
- $ids[] = $order_issue->id;
|
|
|
- if ($order_issue['rejecting_status'] != '未退回') $order_issue_unique['rejecting_status'] = $order_issue['rejecting_status'];
|
|
|
- if ($order_issue['situation_explain']) $order_issue_unique['situation_explain'] = $order_issue['situation_explain'];
|
|
|
- if ($order_issue['order_issue_type_id']) $order_issue_unique['order_issue_type_id'] = $order_issue['order_issue_type_id'];
|
|
|
- if ($order_issue['second_order_id']) $order_issue_unique['second_order_id'] = $order_issue['second_order_id'];
|
|
|
- if ($order_issue['is_new_rejecting'] != '无') $order_issue_unique['is_new_rejecting'] = $order_issue['is_new_rejecting'];
|
|
|
- if ($order_issue['second_client_no']) $order_issue_unique['second_client_no'] = $order_issue['second_client_no'];
|
|
|
- if ($order_issue['final_status']) $order_issue_unique['final_status'] = $order_issue['final_status'];
|
|
|
- if ($order_issue['logistic_indemnity_money']) $order_issue_unique['logistic_indemnity_money'] = $order_issue['logistic_indemnity_money'];
|
|
|
- if ($order_issue['logistic_express_remission']) $order_issue_unique['logistic_express_remission'] = $order_issue['logistic_express_remission'];
|
|
|
- if ($order_issue['baoshi_indemnity_money']) $order_issue_unique['baoshi_indemnity_money'] = $order_issue['baoshi_indemnity_money'];
|
|
|
- if ($order_issue['baoshi_express_remission']) $order_issue_unique['baoshi_express_remission'] = $order_issue['baoshi_express_remission'];
|
|
|
- if ($order_issue['user_workgroup_id']) $order_issue_unique['user_workgroup_id'] = $order_issue['user_workgroup_id'];
|
|
|
- if ($order_issue['custom_code']) $order_issue_unique['custom_code'] = $order_issue['custom_code'];
|
|
|
- if ($order_issue['imported_status']) $order_issue_unique['imported_status'] = $order_issue['imported_status'];
|
|
|
+ if($orderTrackings->count() ==0) continue;
|
|
|
+ $update_params = [['id','logistic_id']];
|
|
|
+ $orderTrackings->each(function($orderTracking)use($logistic_zt,$logistic,&$update_params){
|
|
|
+ $order =$orderTracking->commodities->package->order;
|
|
|
+ $logistic_id = $order->logistic_id;
|
|
|
+ if($logistic_id!=null){
|
|
|
+ if($order->logistic_id == $logistic_zt->id)$logistic_id = $logistic->id;
|
|
|
+ if($logistic_id==0)dd($order,$logistic_id);
|
|
|
+ $update_params[] = [
|
|
|
+ 'id' => $orderTracking->id,
|
|
|
+ 'logistic_id' => $logistic_id,
|
|
|
+ ];
|
|
|
}
|
|
|
- if ($order_issue_unique['deleted_at']) $order_issue_unique['deleted_at'] = null;
|
|
|
- $order_issue_unique->save();
|
|
|
- $order_issue_unique->同步退单状态();
|
|
|
- OrderIssue:: withTrashed()->whereIn('id', $ids)->forceDelete();
|
|
|
- app('LogService')->log(__METHOD__, __FUNCTION__, 'orders_toCombine:' . json_encode($order_issue_unique) . '|toBe OrderId: ' . json_encode($order_issue_unique->id));
|
|
|
- $orderIssueProcessLogs = \App\OrderIssueProcessLog::query()->whereIn('order_issue_id', $ids)->get();
|
|
|
- app('LogService')->log(__METHOD__, __FUNCTION__, 'delete order_issue processLogs:' . json_encode($orderIssueProcessLogs));
|
|
|
- \App\OrderIssueProcessLog::query()->whereIn('order_issue_id', $ids)->forceDelete();
|
|
|
+ });
|
|
|
+ if(count($update_params) > 1){
|
|
|
+ $service->batchUpdate($update_params);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function testHz(){
|
|
|
+ dump('start'.Carbon::now()->toDateTimeString());
|
|
|
+ $ownerAreaReportTask=new CreateOwnerAreaReport();
|
|
|
+ $ownerAreaReportTask->handle();
|
|
|
+ $ownerBillReportTask= new CreateOwnerBillReport();
|
|
|
+ $ownerBillReportTask->handle();
|
|
|
+ $ownerReportTask= new CreateOwnerReport();
|
|
|
+ $ownerReportTask->handle();
|
|
|
+ dump('end'.Carbon::now()->toDateTimeString());
|
|
|
+ }
|
|
|
}
|