|
|
@@ -6,6 +6,7 @@ namespace App\Http\Controllers;
|
|
|
use App\Authority;
|
|
|
use App\Batch;
|
|
|
use App\Carrier;
|
|
|
+use App\City;
|
|
|
use App\Commodity;
|
|
|
use App\CommodityBarcode;
|
|
|
use App\Console\Commands\SyncWMSOrderTask;
|
|
|
@@ -17,6 +18,7 @@ use App\InventoryAccount;
|
|
|
use App\LaborReport;
|
|
|
use App\Log;
|
|
|
use App\Logistic;
|
|
|
+use App\Menu;
|
|
|
use App\OracleActAllocationDetails;
|
|
|
use App\OracleBasSKU;
|
|
|
use App\OracleDOCOrderHeader;
|
|
|
@@ -47,7 +49,6 @@ use App\Services\LogisticService;
|
|
|
use App\Services\LogService;
|
|
|
use App\Services\OracleDocAsnHerderService;
|
|
|
use App\Services\OracleDOCOrderHeaderService;
|
|
|
-use App\Services\OrderPackageReceivedSyncService;
|
|
|
use App\Services\OrderCommodityService;
|
|
|
use App\Services\OrderPackageService;
|
|
|
use App\Services\OrderService;
|
|
|
@@ -67,6 +68,7 @@ use App\Warehouse;
|
|
|
use App\Waybill;
|
|
|
use App\WaybillPriceModel;
|
|
|
use Carbon\Carbon;
|
|
|
+use ChangeColumnOrderIdToOrderIssues;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
@@ -127,15 +129,17 @@ class TestController extends Controller
|
|
|
echo \request()->input("name");
|
|
|
exit();
|
|
|
}
|
|
|
- public function mergeCarrier(){
|
|
|
+
|
|
|
+ public function mergeCarrier()
|
|
|
+ {
|
|
|
$carriers = Carrier::query()->get();
|
|
|
$logistics = [];
|
|
|
$map = [];
|
|
|
- foreach ($carriers as $carrier){
|
|
|
+ foreach ($carriers as $carrier) {
|
|
|
$map[$carrier->name] = $carrier->id;
|
|
|
- $lo = Logistic::query()->where("name",$carrier->name)->first();
|
|
|
- if ($lo){
|
|
|
- if ($lo->type == '快递'){
|
|
|
+ $lo = Logistic::query()->where("name", $carrier->name)->first();
|
|
|
+ if ($lo) {
|
|
|
+ if ($lo->type == '快递') {
|
|
|
// $lo->update(["type"=>"全部"]);$lo->save();
|
|
|
}
|
|
|
continue;
|
|
|
@@ -143,52 +147,54 @@ class TestController extends Controller
|
|
|
$logistics[] = [
|
|
|
"name" => $carrier->name,
|
|
|
'mobile' => $carrier->mobile,
|
|
|
- 'delivery_fee'=> $carrier->delivery_fee,
|
|
|
- 'remark'=> $carrier->remark,
|
|
|
+ 'delivery_fee' => $carrier->delivery_fee,
|
|
|
+ 'remark' => $carrier->remark,
|
|
|
"type" => "物流"
|
|
|
];
|
|
|
}
|
|
|
Logistic::query()->insert($logistics);
|
|
|
- $ls = Logistic::query()->where("type","物流")->get();
|
|
|
+ $ls = Logistic::query()->where("type", "物流")->get();
|
|
|
$result = [];
|
|
|
- foreach ($ls as $l)
|
|
|
- {
|
|
|
- if (isset($map[$l->name]))$result[$map[$l->name]] = $l->id;
|
|
|
+ foreach ($ls as $l) {
|
|
|
+ if (isset($map[$l->name])) $result[$map[$l->name]] = $l->id;
|
|
|
}
|
|
|
- LogService::log(__METHOD__,"同步承运商",json_encode($result));
|
|
|
- foreach ($result as $tag => $val){
|
|
|
- Waybill::query()->where("logistic_id",$tag)->update([
|
|
|
+ LogService::log(__METHOD__, "同步承运商", json_encode($result));
|
|
|
+ foreach ($result as $tag => $val) {
|
|
|
+ Waybill::query()->where("logistic_id", $tag)->update([
|
|
|
"logistic_id" => $val
|
|
|
]);
|
|
|
- WaybillPriceModel::query()->where("logistic_id",$tag)->update([
|
|
|
+ WaybillPriceModel::query()->where("logistic_id", $tag)->update([
|
|
|
"logistic_id" => $val
|
|
|
]);
|
|
|
- DB::table("logistic_user")->where("logistic_id",$tag)->update([
|
|
|
+ DB::table("logistic_user")->where("logistic_id", $tag)->update([
|
|
|
"logistic_id" => $val
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
- public function updateLaborRemark(){
|
|
|
- $laborReports=LaborReport::query()->with(['remarks'=>function($query){
|
|
|
+
|
|
|
+ public function updateLaborRemark()
|
|
|
+ {
|
|
|
+ $laborReports = LaborReport::query()->with(['remarks' => function ($query) {
|
|
|
return $query->whereNotNull('mark');
|
|
|
}])->get();
|
|
|
$updateParams = [[
|
|
|
- 'id','remark','updated_at'
|
|
|
+ 'id', 'remark', 'updated_at'
|
|
|
]];
|
|
|
- $updated_at=Carbon::now()->toDateTimeString();
|
|
|
- foreach ($laborReports as $laborReport){
|
|
|
- if ($laborReport->remarks){
|
|
|
+ $updated_at = Carbon::now()->toDateTimeString();
|
|
|
+ foreach ($laborReports as $laborReport) {
|
|
|
+ if ($laborReport->remarks) {
|
|
|
$updateParams[] = [
|
|
|
- 'id'=>$laborReport->id,
|
|
|
- 'remark'=>$laborReport->remarks->mark,
|
|
|
- 'updated_at'=>$updated_at,
|
|
|
+ 'id' => $laborReport->id,
|
|
|
+ 'remark' => $laborReport->remarks->mark,
|
|
|
+ 'updated_at' => $updated_at,
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
- if(count($updateParams) > 1){
|
|
|
- app(BatchUpdateService::class)->batchUpdate('labor_reports',$updateParams);
|
|
|
+ if (count($updateParams) > 1) {
|
|
|
+ app(BatchUpdateService::class)->batchUpdate('labor_reports', $updateParams);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
function packageFromLog(Request $request)
|
|
|
{ //x $packagesBatch=Package::where('batch_number',$batch_number)->first();
|
|
|
ini_set('max_execution_time', 2500);
|
|
|
@@ -215,6 +221,7 @@ class TestController extends Controller
|
|
|
});
|
|
|
dd($uploaded . '/' . $count);
|
|
|
}
|
|
|
+
|
|
|
function issues()
|
|
|
{
|
|
|
/** @var OrderPackageService $orderPackageService */
|
|
|
@@ -227,16 +234,19 @@ class TestController extends Controller
|
|
|
$orderPackageService->createdByOrder($item);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
function tlog(Request $request)
|
|
|
{
|
|
|
- app('LogService')->log(__METHOD__,'cczdelme'.__FUNCTION__,json_encode($request->all()),null);
|
|
|
+ app('LogService')->log(__METHOD__, 'cczdelme' . __FUNCTION__, json_encode($request->all()), null);
|
|
|
}
|
|
|
+
|
|
|
function setCache(Request $request)
|
|
|
{
|
|
|
$today = now();
|
|
|
Cache::put('storedTest', $today);
|
|
|
return "cacheing:'$today'<script>localStorage.setItem('storedTest','{$today}')</script>";
|
|
|
}
|
|
|
+
|
|
|
function getCache(Request $request)
|
|
|
{
|
|
|
$cache = Cache::get('storedTest');
|
|
|
@@ -245,8 +255,11 @@ class TestController extends Controller
|
|
|
|
|
|
function t1(Request $request)
|
|
|
{
|
|
|
- throw new \Exception('aaaaaa');
|
|
|
+ $user=City::query()->first();
|
|
|
+ $user['created_at'] = '2020-12-23';
|
|
|
+ $user->save();
|
|
|
}
|
|
|
+
|
|
|
function packageT(Request $request)
|
|
|
{
|
|
|
$package = Package::where('created_at', '<', '2020-07-08')->whereNotNull('logistic_number')->first();
|
|
|
@@ -519,56 +532,57 @@ class TestController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function test5(){
|
|
|
- ini_set('max_execution_time',2500);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
+ public function test5()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 2500);
|
|
|
+ ini_set('memory_limit', '1526M');
|
|
|
//清理冗余条码
|
|
|
// $this->cleanBarcode();
|
|
|
|
|
|
- while(true){
|
|
|
+ while (true) {
|
|
|
$toDay = Carbon::now();
|
|
|
$skus = DB::select(DB::raw('select sku from commodities group by sku,owner_id having count(*)>1 limit 500 '));
|
|
|
- $skus = array_column($skus,'sku');
|
|
|
+ $skus = array_column($skus, 'sku');
|
|
|
|
|
|
- $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku',$skus)->get();
|
|
|
+ $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku', $skus)->get();
|
|
|
|
|
|
|
|
|
- if (count($commodities) < 1)return "SUCCESS";
|
|
|
+ if (count($commodities) < 1) return "SUCCESS";
|
|
|
$commodityMap = [];
|
|
|
$commodityDel = [];
|
|
|
$commodityTag = [];
|
|
|
$commodityBar = [];
|
|
|
$createBarcodes = [];
|
|
|
$logs = [];
|
|
|
- foreach ($commodities as $commodity){
|
|
|
- if ($commodityMap[$commodity->sku.'_'.$commodity->owner_id] ?? false){
|
|
|
- $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
|
|
|
+ foreach ($commodities as $commodity) {
|
|
|
+ if ($commodityMap[$commodity->sku . '_' . $commodity->owner_id] ?? false) {
|
|
|
+ $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
|
|
|
$logs[] = [
|
|
|
'id' => $commodity->id,
|
|
|
'sku' => $commodity->sku,
|
|
|
- 'owner_id'=>$commodity->owner_id,
|
|
|
- 'code'=>$codes,
|
|
|
+ 'owner_id' => $commodity->owner_id,
|
|
|
+ 'code' => $codes,
|
|
|
];
|
|
|
$commodityDel[] = $commodity->id;
|
|
|
- $commodityTag[$commodity->id] = $commodityMap[$commodity->sku.'_'.$commodity->owner_id];
|
|
|
+ $commodityTag[$commodity->id] = $commodityMap[$commodity->sku . '_' . $commodity->owner_id];
|
|
|
|
|
|
- $arr = array_diff($codes,$commodityBar[$commodity->sku.'_'.$commodity->owner_id]);
|
|
|
- foreach ($arr as $code){
|
|
|
- if (!$code)continue;
|
|
|
+ $arr = array_diff($codes, $commodityBar[$commodity->sku . '_' . $commodity->owner_id]);
|
|
|
+ foreach ($arr as $code) {
|
|
|
+ if (!$code) continue;
|
|
|
$createBarcodes[] = [
|
|
|
'code' => $code,
|
|
|
- 'commodity_id' => $commodityMap[$commodity->sku.'_'.$commodity->owner_id],
|
|
|
+ 'commodity_id' => $commodityMap[$commodity->sku . '_' . $commodity->owner_id],
|
|
|
'created_at' => $toDay,
|
|
|
];
|
|
|
}
|
|
|
- }else{
|
|
|
- $commodityMap[$commodity->sku.'_'.$commodity->owner_id] = $commodity->id;
|
|
|
- $commodityBar[$commodity->sku.'_'.$commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
|
|
|
+ } else {
|
|
|
+ $commodityMap[$commodity->sku . '_' . $commodity->owner_id] = $commodity->id;
|
|
|
+ $commodityBar[$commodity->sku . '_' . $commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
|
|
|
}
|
|
|
}
|
|
|
- dd($commodityMap,$commodityDel,$commodityTag);
|
|
|
- app('LogService')->log(__METHOD__,'清理商品',json_encode($logs,JSON_UNESCAPED_UNICODE));
|
|
|
- app('LogService')->log(__METHOD__,'重新分配商品',json_encode($commodityTag,JSON_UNESCAPED_UNICODE));
|
|
|
+ dd($commodityMap, $commodityDel, $commodityTag);
|
|
|
+ app('LogService')->log(__METHOD__, '清理商品', json_encode($logs, JSON_UNESCAPED_UNICODE));
|
|
|
+ app('LogService')->log(__METHOD__, '重新分配商品', json_encode($commodityTag, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存盘点任务
|
|
|
app('InventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
|
|
|
@@ -577,13 +591,14 @@ class TestController extends Controller
|
|
|
app('StoreCheckingReceiveItemService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新入库盘收一体
|
|
|
app('OrderPackageCommoditiesService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新订单商品
|
|
|
|
|
|
- app('LogService')->log(__METHOD__,'删除商品与对应条码',json_encode($commodityDel,JSON_UNESCAPED_UNICODE));
|
|
|
- CommodityBarcode::query()->whereIn('commodity_id',$commodityDel)->delete();
|
|
|
+ app('LogService')->log(__METHOD__, '删除商品与对应条码', json_encode($commodityDel, JSON_UNESCAPED_UNICODE));
|
|
|
+ CommodityBarcode::query()->whereIn('commodity_id', $commodityDel)->delete();
|
|
|
Commodity::destroy($commodityDel);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function cleanBarcode(){
|
|
|
+ private function cleanBarcode()
|
|
|
+ {
|
|
|
|
|
|
$logCommodityBarcodes = CommodityBarcode::query()->where('code', "")->get();
|
|
|
if (count($logCommodityBarcodes) > 0) app('LogService')->log(__METHOD__, "纠正商品-删除空条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
|
|
|
@@ -604,30 +619,31 @@ where (c.code,c.commodity_id) in (select code,commodity_id from commodity_barcod
|
|
|
CommodityBarcode::destroy($barcodeDelete);
|
|
|
}
|
|
|
|
|
|
- private function multiCodes(){
|
|
|
+ private function multiCodes()
|
|
|
+ {
|
|
|
|
|
|
- $barcode='BG10B1014C002100';
|
|
|
- $commodity=Commodity::whereHas('barcodes', function (Builder $query)use($barcode){
|
|
|
- $query->where('code',$barcode);
|
|
|
- })->where('owner_id',4)->first();
|
|
|
+ $barcode = 'BG10B1014C002100';
|
|
|
+ $commodity = Commodity::whereHas('barcodes', function (Builder $query) use ($barcode) {
|
|
|
+ $query->where('code', $barcode);
|
|
|
+ })->where('owner_id', 4)->first();
|
|
|
$codes = $commodity->barcodes->map(function ($barcode) {
|
|
|
- return $barcode->code??'';
|
|
|
+ return $barcode->code ?? '';
|
|
|
});
|
|
|
- foreach($codes as $code){
|
|
|
- $commodity=Commodity::whereHas('barcodes', function (Builder $query)use($barcode){
|
|
|
- $query->where('code',$barcode);
|
|
|
- })->where('owner_id',4)->get();
|
|
|
+ foreach ($codes as $code) {
|
|
|
+ $commodity = Commodity::whereHas('barcodes', function (Builder $query) use ($barcode) {
|
|
|
+ $query->where('code', $barcode);
|
|
|
+ })->where('owner_id', 4)->get();
|
|
|
dump($commodity);
|
|
|
}
|
|
|
die();
|
|
|
- $commodityBuilder=Commodity::query();
|
|
|
- $commodityBuilder->where('owner_id',4)->first();
|
|
|
- $commodityBuilder->whereHas('barcodes', function (Builder $query)use($barcode,$codes){
|
|
|
- foreach($codes as $code){
|
|
|
- $query->orWhere('code',$code);
|
|
|
- }
|
|
|
- });
|
|
|
- dd($commodity, $codes,$commodityBuilder->get());
|
|
|
+ $commodityBuilder = Commodity::query();
|
|
|
+ $commodityBuilder->where('owner_id', 4)->first();
|
|
|
+ $commodityBuilder->whereHas('barcodes', function (Builder $query) use ($barcode, $codes) {
|
|
|
+ foreach ($codes as $code) {
|
|
|
+ $query->orWhere('code', $code);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ dd($commodity, $codes, $commodityBuilder->get());
|
|
|
}
|
|
|
|
|
|
public function correctCommodity()
|
|
|
@@ -694,7 +710,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
}
|
|
|
$updateCommodities[$del->commodity_id] = $target->commodity_id;
|
|
|
}
|
|
|
- if (count($updateCommodities) > 0){
|
|
|
+ if (count($updateCommodities) > 0) {
|
|
|
app('InventoryAccountMissionService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存盘点任务
|
|
|
app('InventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
|
|
|
app('InventoryDailyLogService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存每日记录
|
|
|
@@ -716,6 +732,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
|
|
|
Commodity::destroy($deleteCommodities);
|
|
|
}
|
|
|
+
|
|
|
/*1*/
|
|
|
function socket(Request $request)
|
|
|
{/**/
|
|
|
@@ -777,23 +794,26 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
{
|
|
|
/** @var CacheService $cacheService */
|
|
|
$cacheService = app('CacheService');
|
|
|
- $authorities=$cacheService->getOrExecute('userxx',function (){
|
|
|
+ $authorities = $cacheService->getOrExecute('userxx', function () {
|
|
|
return Authority::with('roles')->get();
|
|
|
});
|
|
|
dd($authorities);
|
|
|
}
|
|
|
+
|
|
|
public function output2()
|
|
|
{
|
|
|
dump(Cache::get('aa'));
|
|
|
Cache::put('aa', '2223', 5);
|
|
|
}
|
|
|
+
|
|
|
public function usage()
|
|
|
{
|
|
|
dd(Request::all());
|
|
|
}
|
|
|
+
|
|
|
public function relating()
|
|
|
{
|
|
|
- dd(OrderIssue::query()->where('id',182)->paginate()->total());
|
|
|
+ dd(OrderIssue::query()->where('id', 182)->paginate()->total());
|
|
|
}
|
|
|
|
|
|
public function updateOrdersWarehouse()
|
|
|
@@ -809,10 +829,11 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$warehouse = Warehouse::query()->get();
|
|
|
$warehouse_map = $dataHandlerService->dataHeader(['code'], $warehouse);
|
|
|
for ($i = 0; $i < $count; $i += $page) {
|
|
|
- $min = $i;$max = $i + $page;
|
|
|
+ $min = $i;
|
|
|
+ $max = $i + $page;
|
|
|
$orders = Order::query()->where('id', '>=', $min)->where('id', '<=', $max)->get();
|
|
|
$orderNos = array_diff(array_unique(data_get($orders, '*.code')), ['', ' ', '*', null]);
|
|
|
- if (count($orderNos)==0) continue;
|
|
|
+ if (count($orderNos) == 0) continue;
|
|
|
/** @var Collection $orderHeaders */
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()->whereIn('orderno', $orderNos)->get();
|
|
|
if ($orderHeaders->count() == 0) continue;
|
|
|
@@ -838,16 +859,16 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
public function syncSendOrder()
|
|
|
{
|
|
|
$order_issues = OrderIssue::query()->whereNotNull('second_client_no')->get();
|
|
|
- $client_nos = data_get($order_issues,'*.second_client_no');
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
|
|
|
- ->whereIn('SOReference1',$client_nos)
|
|
|
- ->with(['oracleBASCustomer'=>function($query){
|
|
|
+ $client_nos = data_get($order_issues, '*.second_client_no');
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(implode(',', OracleDOCOrderHeaderService::$columns))
|
|
|
+ ->whereIn('SOReference1', $client_nos)
|
|
|
+ ->with(['oracleBASCustomer' => function ($query) {
|
|
|
$query->selectRaw('BAS_CUSTOMER.CustomerID,BAS_CUSTOMER.Customer_Type,BAS_CUSTOMER.Descr_C,BAS_CUSTOMER.Active_Flag');
|
|
|
- },'oracleDOCOrderDetails'=>function($query){
|
|
|
+ }, 'oracleDOCOrderDetails' => function ($query) {
|
|
|
$query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
|
|
|
- }, 'actAllocationDetails'=>function($query){
|
|
|
+ }, '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');
|
|
|
- },'oracleBASCode'=>function($query){
|
|
|
+ }, 'oracleBASCode' => function ($query) {
|
|
|
$query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
}])
|
|
|
->get();
|
|
|
@@ -860,19 +881,19 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
/**
|
|
|
* @var OrderService $orderService
|
|
|
*/
|
|
|
- $carbon =Carbon::now()->subMinutes(30);
|
|
|
- var_dump('$orderHeader',new Carbon());
|
|
|
- $orderHeader_start = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
|
|
|
- ->with(['oracleBASCustomer'=>function($query){
|
|
|
+ $carbon = Carbon::now()->subMinutes(30);
|
|
|
+ var_dump('$orderHeader', new Carbon());
|
|
|
+ $orderHeader_start = 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){
|
|
|
+ }, 'oracleDOCOrderDetails' => function ($query) {
|
|
|
$query->selectRaw('doc_order_details.orderNo,doc_order_details.customerid,doc_order_details.sku,doc_order_details.QtyOrdered');
|
|
|
- }, 'actAllocationDetails'=>function($query){
|
|
|
+ }, '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){
|
|
|
+ }, 'oracleBASCode' => function ($query) {
|
|
|
$query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
}])
|
|
|
- ->where('DOC_Order_Header.addTime','>=',$carbon)
|
|
|
+ ->where('DOC_Order_Header.addTime', '>=', $carbon)
|
|
|
// ->where('DOC_Order_Header.editTime','>=',$carbon)
|
|
|
->get();
|
|
|
var_dump((string)Carbon::now());
|
|
|
@@ -884,74 +905,79 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
// orderService getCreateOrderModelsByWMSOrderHeaders
|
|
|
}
|
|
|
|
|
|
- public function testOrderPackages(){
|
|
|
+ public function testOrderPackages()
|
|
|
+ {
|
|
|
$batch_number = 'W201114000104';
|
|
|
$weight = 0.3;
|
|
|
- OrderPackage::createPackagesFromBatchCode($batch_number,$weight);
|
|
|
+ OrderPackage::createPackagesFromBatchCode($batch_number, $weight);
|
|
|
}
|
|
|
|
|
|
- public function view(){
|
|
|
+ public function view()
|
|
|
+ {
|
|
|
return view('test');
|
|
|
}
|
|
|
|
|
|
- public function cleanOrderRepeat(){
|
|
|
+ public function cleanOrderRepeat()
|
|
|
+ {
|
|
|
|
|
|
- ini_set('max_execution_time',6500);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
- for($i=0;true;$i++){
|
|
|
- $orders_repeating=Order::query()
|
|
|
+ ini_set('max_execution_time', 6500);
|
|
|
+ ini_set('memory_limit', '1526M');
|
|
|
+ for ($i = 0; true; $i++) {
|
|
|
+ $orders_repeating = Order::query()
|
|
|
->selectRaw('count(*) as count, code, id')
|
|
|
->whereNotNull('code')
|
|
|
->groupBy('code')
|
|
|
->having('count', '>', 1)
|
|
|
->limit(100)
|
|
|
->get();
|
|
|
- if($orders_repeating->count()==0)break;
|
|
|
- $orders_repeating->each(function ($order){
|
|
|
- $code_repeating=$order['code'];
|
|
|
- $orders_toCombine=Order::query()
|
|
|
- ->where('code',$code_repeating)
|
|
|
+ if ($orders_repeating->count() == 0) break;
|
|
|
+ $orders_repeating->each(function ($order) {
|
|
|
+ $code_repeating = $order['code'];
|
|
|
+ $orders_toCombine = Order::query()
|
|
|
+ ->where('code', $code_repeating)
|
|
|
->orderByDesc('updated_at')
|
|
|
->get();
|
|
|
- $orderId_unique=(function()use($orders_toCombine){
|
|
|
- $order_toLive=$orders_toCombine->first();
|
|
|
- foreach($orders_toCombine as $key=>$order_toEliminate){
|
|
|
- if($key==0)continue;
|
|
|
- if(!$order_toLive['batch_id'])$order_toLive['batch_id']=$order_toEliminate['batch_id'];
|
|
|
- if(!$order_toLive['owner_id'])$order_toLive['owner_id']=$order_toEliminate['owner_id'];
|
|
|
- if(!$order_toLive['status'])$order_toLive['status']=$order_toEliminate['status'];
|
|
|
- if(!$order_toLive['created_at'])$order_toLive['created_at']=$order_toEliminate['created_at'];
|
|
|
- if(!$order_toLive['code'])$order_toLive['code']=$order_toEliminate['code'];
|
|
|
- if(!$order_toLive['shop_id'])$order_toLive['shop_id']=$order_toEliminate['shop_id'];
|
|
|
- if(!$order_toLive['owner_id'])$order_toLive['owner_id']=$order_toEliminate['owner_id'];
|
|
|
- if(!$order_toLive['client_code'])$order_toLive['client_code']=$order_toEliminate['client_code'];
|
|
|
- if(!$order_toLive['logistic_id'])$order_toLive['logistic_id']=$order_toEliminate['logistic_id'];
|
|
|
- if(!$order_toLive['consignee_name'])$order_toLive['consignee_name']=$order_toEliminate['consignee_name'];
|
|
|
- if(!$order_toLive['consignee_phone'])$order_toLive['consignee_phone']=$order_toEliminate['consignee_phone'];
|
|
|
- if(!$order_toLive['province'])$order_toLive['province']=$order_toEliminate['province'];
|
|
|
- if(!$order_toLive['city'])$order_toLive['city']=$order_toEliminate['city'];
|
|
|
- if(!$order_toLive['district'])$order_toLive['district']=$order_toEliminate['district'];
|
|
|
- if(!$order_toLive['address'])$order_toLive['address']=$order_toEliminate['address'];
|
|
|
- if(!$order_toLive['wms_status'])$order_toLive['wms_status']=$order_toEliminate['wms_status'];
|
|
|
- if(!$order_toLive['status'])$order_toLive['status']=$order_toEliminate['status'];
|
|
|
- if(!$order_toLive['warehouse_id'])$order_toLive['warehouse_id']=$order_toEliminate['warehouse_id'];
|
|
|
- if(!$order_toLive['wms_edittime'])$order_toLive['wms_edittime']=$order_toEliminate['wms_edittime'];
|
|
|
+ $orderId_unique = (function () use ($orders_toCombine) {
|
|
|
+ $order_toLive = $orders_toCombine->first();
|
|
|
+ foreach ($orders_toCombine as $key => $order_toEliminate) {
|
|
|
+ if ($key == 0) continue;
|
|
|
+ if (!$order_toLive['batch_id']) $order_toLive['batch_id'] = $order_toEliminate['batch_id'];
|
|
|
+ if (!$order_toLive['owner_id']) $order_toLive['owner_id'] = $order_toEliminate['owner_id'];
|
|
|
+ if (!$order_toLive['status']) $order_toLive['status'] = $order_toEliminate['status'];
|
|
|
+ if (!$order_toLive['created_at']) $order_toLive['created_at'] = $order_toEliminate['created_at'];
|
|
|
+ if (!$order_toLive['code']) $order_toLive['code'] = $order_toEliminate['code'];
|
|
|
+ if (!$order_toLive['shop_id']) $order_toLive['shop_id'] = $order_toEliminate['shop_id'];
|
|
|
+ if (!$order_toLive['owner_id']) $order_toLive['owner_id'] = $order_toEliminate['owner_id'];
|
|
|
+ if (!$order_toLive['client_code']) $order_toLive['client_code'] = $order_toEliminate['client_code'];
|
|
|
+ if (!$order_toLive['logistic_id']) $order_toLive['logistic_id'] = $order_toEliminate['logistic_id'];
|
|
|
+ if (!$order_toLive['consignee_name']) $order_toLive['consignee_name'] = $order_toEliminate['consignee_name'];
|
|
|
+ if (!$order_toLive['consignee_phone']) $order_toLive['consignee_phone'] = $order_toEliminate['consignee_phone'];
|
|
|
+ if (!$order_toLive['province']) $order_toLive['province'] = $order_toEliminate['province'];
|
|
|
+ if (!$order_toLive['city']) $order_toLive['city'] = $order_toEliminate['city'];
|
|
|
+ if (!$order_toLive['district']) $order_toLive['district'] = $order_toEliminate['district'];
|
|
|
+ if (!$order_toLive['address']) $order_toLive['address'] = $order_toEliminate['address'];
|
|
|
+ if (!$order_toLive['wms_status']) $order_toLive['wms_status'] = $order_toEliminate['wms_status'];
|
|
|
+ if (!$order_toLive['status']) $order_toLive['status'] = $order_toEliminate['status'];
|
|
|
+ if (!$order_toLive['warehouse_id']) $order_toLive['warehouse_id'] = $order_toEliminate['warehouse_id'];
|
|
|
+ if (!$order_toLive['wms_edittime']) $order_toLive['wms_edittime'] = $order_toEliminate['wms_edittime'];
|
|
|
}
|
|
|
$order_toLive->save();
|
|
|
return $order_toLive['id'];
|
|
|
})();
|
|
|
- $orderIds_toRemove=(function()use($orders_toCombine){
|
|
|
+ $orderIds_toRemove = (function () use ($orders_toCombine) {
|
|
|
$orders_toCombine->shift();
|
|
|
- return $orders_toCombine->map(function($order){return $order['id'];});
|
|
|
+ return $orders_toCombine->map(function ($order) {
|
|
|
+ return $order['id'];
|
|
|
+ });
|
|
|
})();
|
|
|
- OrderPackage::query()->whereIn('order_id',$orderIds_toRemove)->update(['order_id'=>$orderId_unique]);
|
|
|
- OrderIssue::query()->whereIn('order_id',$orderIds_toRemove)->update(['order_id'=>$orderId_unique]);
|
|
|
- OrderCommodity::query()->whereIn('order_id',$orderIds_toRemove)->update(['order_id'=>$orderId_unique]);
|
|
|
- OrderBin::query()->whereIn('order_id',$orderIds_toRemove)->update(['order_id'=>$orderId_unique]);
|
|
|
+ OrderPackage::query()->whereIn('order_id', $orderIds_toRemove)->update(['order_id' => $orderId_unique]);
|
|
|
+ OrderIssue::query()->whereIn('order_id', $orderIds_toRemove)->update(['order_id' => $orderId_unique]);
|
|
|
+ OrderCommodity::query()->whereIn('order_id', $orderIds_toRemove)->update(['order_id' => $orderId_unique]);
|
|
|
+ OrderBin::query()->whereIn('order_id', $orderIds_toRemove)->update(['order_id' => $orderId_unique]);
|
|
|
Order::destroy($orderIds_toRemove);
|
|
|
- app('LogService')->log(__METHOD__,__FUNCTION__,'orders_toCombine:'.json_encode($orderIds_toRemove).'|toBe OrderId: '.json_encode($orderId_unique));
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__, 'orders_toCombine:' . json_encode($orderIds_toRemove) . '|toBe OrderId: ' . json_encode($orderId_unique));
|
|
|
});
|
|
|
- app('LogService')->log(__METHOD__,__FUNCTION__,'orders_repeating:'.$orders_repeating->toJson());
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__, 'orders_repeating:' . $orders_repeating->toJson());
|
|
|
}
|
|
|
echo $i;
|
|
|
}
|
|
|
@@ -960,12 +986,12 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
{
|
|
|
$client_no = null;
|
|
|
$items = null;
|
|
|
- $order=(new OrderTrackingImport())->getOrder($client_no,$items);
|
|
|
- if($order['id']) echo 'yes1';
|
|
|
+ $order = (new OrderTrackingImport())->getOrder($client_no, $items);
|
|
|
+ if ($order['id']) echo 'yes1';
|
|
|
|
|
|
|
|
|
$order = Order::query()->create([
|
|
|
- 'code'=>'null'.Str::uuid(),'client_code' => 'asdfdfdg','web_order_number' => 'sadfdsf'
|
|
|
+ 'code' => 'null' . Str::uuid(), 'client_code' => 'asdfdfdg', 'web_order_number' => 'sadfdsf'
|
|
|
]);
|
|
|
dd($order);
|
|
|
// $order=(new OrderTrackingImport())->getOrder('92024765871-SDO130000986796QX',$items);
|
|
|
@@ -1015,8 +1041,8 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
|
|
|
public function reNewBatches3()
|
|
|
{
|
|
|
- $batches=Batch::query()->where('id',6384)->get('code');
|
|
|
- $batchCodes = $batches->map(function($batch){
|
|
|
+ $batches = Batch::query()->where('id', 6384)->get('code');
|
|
|
+ $batchCodes = $batches->map(function ($batch) {
|
|
|
return $batch['code'];
|
|
|
})->toArray();
|
|
|
// $batchCodes = ['W201201000037',
|
|
|
@@ -1034,23 +1060,23 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
// 'W201201000074',
|
|
|
// 'W201201000075',
|
|
|
// 'W201201000076',];
|
|
|
- $requests=[];
|
|
|
+ $requests = [];
|
|
|
// $logs=Log::query()->select('description')->where('CREATED_AT','>','2020-11-11')
|
|
|
// ->where('type',"issued_newBatch")
|
|
|
// ->get();
|
|
|
// dd($logs);
|
|
|
- foreach($batchCodes as $code){
|
|
|
+ foreach ($batchCodes as $code) {
|
|
|
// $request=Cache::get('temp'.$code)['description'];
|
|
|
- $request=Log::query()->select('description')->where('CREATED_AT','>','2020-12-16')
|
|
|
- ->where('type',"issued_newBatch")
|
|
|
- ->where('description','like',"%{$code}%")
|
|
|
+ $request = Log::query()->select('description')->where('CREATED_AT', '>', '2020-12-16')
|
|
|
+ ->where('type', "issued_newBatch")
|
|
|
+ ->where('description', 'like', "%{$code}%")
|
|
|
->first();
|
|
|
- if($request){
|
|
|
- $response=Zttp::post('https://wcs.baoshi56.com/api/thirdPart/flux/sorting/newBatch',
|
|
|
+ if ($request) {
|
|
|
+ $response = Zttp::post('https://wcs.baoshi56.com/api/thirdPart/flux/sorting/newBatch',
|
|
|
json_decode($request['description'])
|
|
|
);
|
|
|
- app('LogService')->log(__METHOD__,__FUNCTION__,$response->body());
|
|
|
- $requests[]=$response->body();
|
|
|
+ app('LogService')->log(__METHOD__, __FUNCTION__, $response->body());
|
|
|
+ $requests[] = $response->body();
|
|
|
}
|
|
|
// Cache::put('temp'.$code,$request);
|
|
|
// $requests[]=$request;
|
|
|
@@ -1066,37 +1092,39 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$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'];
|
|
|
+ $orderNos = ['SO201205001735', 'SO201204003891', 'SO201204003706', 'SO201204002877', 'SO201203003771'];
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
|
|
|
- ->whereIn('orderno',$orderNos)
|
|
|
+ ->whereIn('orderno', $orderNos)
|
|
|
->get();
|
|
|
$orderService->updateByWmsOrders($orderHeaders);
|
|
|
$orderTrackingService->createByWmsOrderHeader($orderHeaders);
|
|
|
}
|
|
|
|
|
|
- public function testSyncOrderTask(){
|
|
|
+ public function testSyncOrderTask()
|
|
|
+ {
|
|
|
dump('hendle...');
|
|
|
dump((string)Carbon::now());
|
|
|
- dump(memory_get_usage()/1024/1024);
|
|
|
+ dump(memory_get_usage() / 1024 / 1024);
|
|
|
$task = new SyncWMSOrderTask();
|
|
|
$task->handle();
|
|
|
dump((string)Carbon::now());
|
|
|
dump('hendle...end');
|
|
|
- dump(memory_get_usage()/1024/1024);
|
|
|
- dump(memory_get_peak_usage()/1024/1024);
|
|
|
+ dump(memory_get_usage() / 1024 / 1024);
|
|
|
+ dump(memory_get_peak_usage() / 1024 / 1024);
|
|
|
return view('test');
|
|
|
}
|
|
|
+
|
|
|
public function testSyncWaveNo()
|
|
|
{
|
|
|
- $waveHeader = OracleDOCWaveHeader::query()->where('waveno','W201209000024')->first();
|
|
|
+ $waveHeader = OracleDOCWaveHeader::query()->where('waveno', 'W201209000024')->first();
|
|
|
// Batch::query()->create([
|
|
|
// 'code' => $waveHeader->waveno,
|
|
|
// 'wms_created_at' => $waveHeader->addtime,
|
|
|
// 'remark' => $waveHeader->descr,
|
|
|
// 'wms_status' => '99',
|
|
|
// ]);
|
|
|
- $waveHeaderDetails = OracleDOCWaveDetails::query()->where('waveno',$waveHeader->waveno)->get();
|
|
|
- $orderNos = $waveHeaderDetails->map(function($item){
|
|
|
+ $waveHeaderDetails = OracleDOCWaveDetails::query()->where('waveno', $waveHeader->waveno)->get();
|
|
|
+ $orderNos = $waveHeaderDetails->map(function ($item) {
|
|
|
return $item->orderno;
|
|
|
});
|
|
|
$orderHeaderService = new OracleDOCOrderHeaderService();
|
|
|
@@ -1105,57 +1133,59 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$orderService->syncOrderByWMSOrderHeaders($orderHeaders);
|
|
|
}
|
|
|
|
|
|
- public function testSyncOrderTracking(){
|
|
|
+ public function testSyncOrderTracking()
|
|
|
+ {
|
|
|
$orderTrackingService = new OrderTrackingService();
|
|
|
- $items = OrderTracking::query()->with('commodities.package.order')->where('created_at','>=','2020-12-01 00:00:00')->get();
|
|
|
- $orderNos = $items->map(function ($orderTracking){
|
|
|
- return $orderTracking->commodities->package->order->code;
|
|
|
+ $items = OrderTracking::query()->with('commodities.package.order')->where('created_at', '>=', '2020-12-01 00:00:00')->get();
|
|
|
+ $orderNos = $items->map(function ($orderTracking) {
|
|
|
+ return $orderTracking->commodities->package->order->code;
|
|
|
});
|
|
|
- $update_params =[['id','client','order_remark']];
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->whereIn('OrderNo',$orderNos)->get();
|
|
|
+ $update_params = [['id', 'client', 'order_remark']];
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->whereIn('OrderNo', $orderNos)->get();
|
|
|
foreach ($items as $orderTracking) {
|
|
|
$order = $orderTracking->commodities->package->order;
|
|
|
- $orderHeader = $orderHeaders->where('orderno',$order->code)->first();
|
|
|
- if(!$orderHeader)continue;
|
|
|
- if(empty($order))continue;
|
|
|
- $params = $orderTrackingService->getParamsByOrderHeaderAndOrder($orderHeader,$order);
|
|
|
- if($params['client'] != $orderTracking->client || $params['order_remark'] != $orderTracking->order_remark ){
|
|
|
- $update_params[] = [
|
|
|
- 'id' => $orderTracking->id,
|
|
|
- 'client' => $params['client'] ,
|
|
|
- 'order_remark' =>$params['order_remark']
|
|
|
- ];
|
|
|
+ $orderHeader = $orderHeaders->where('orderno', $order->code)->first();
|
|
|
+ if (!$orderHeader) continue;
|
|
|
+ if (empty($order)) continue;
|
|
|
+ $params = $orderTrackingService->getParamsByOrderHeaderAndOrder($orderHeader, $order);
|
|
|
+ if ($params['client'] != $orderTracking->client || $params['order_remark'] != $orderTracking->order_remark) {
|
|
|
+ $update_params[] = [
|
|
|
+ 'id' => $orderTracking->id,
|
|
|
+ 'client' => $params['client'],
|
|
|
+ 'order_remark' => $params['order_remark']
|
|
|
+ ];
|
|
|
}
|
|
|
}
|
|
|
- if(count($update_params) == 0)return ;
|
|
|
+ if (count($update_params) == 0) return;
|
|
|
$orderTrackingService->batchUpdate($update_params);
|
|
|
}
|
|
|
|
|
|
- public function editOrderTracking(){
|
|
|
- $orderTrackingService = new OrderTrackingService();
|
|
|
- $dataHandlerService = new DataHandlerService();
|
|
|
- $orderTrackings = OrderTracking::query()->with('commodities.package')->where('client','like','天猫%')->get();
|
|
|
+ public function editOrderTracking()
|
|
|
+ {
|
|
|
+ $orderTrackingService = new OrderTrackingService();
|
|
|
+ $dataHandlerService = new DataHandlerService();
|
|
|
+ $orderTrackings = OrderTracking::query()->with('commodities.package')->where('client', 'like', '天猫%')->get();
|
|
|
$orderTracking_arr = $orderTrackings->chunk(100);
|
|
|
foreach ($orderTracking_arr as $items) {
|
|
|
- $update_params = [['id','order_client_code']];
|
|
|
- $order_nos = array_unique(data_get($items,'*.commodities.package.order.code'));
|
|
|
+ $update_params = [['id', 'order_client_code']];
|
|
|
+ $order_nos = array_unique(data_get($items, '*.commodities.package.order.code'));
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()
|
|
|
- ->with(['oracleDOCOrderDetails', 'actAllocationDetails','oracleBASCode','oracleBASCustomer'])
|
|
|
- ->whereIn('DOC_Order_Header.OrderNo',$order_nos)->get();
|
|
|
- $orderHeader_map = $dataHandlerService->dataHeader(['orderno'],$orderHeaders);
|
|
|
+ ->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode', 'oracleBASCustomer'])
|
|
|
+ ->whereIn('DOC_Order_Header.OrderNo', $order_nos)->get();
|
|
|
+ $orderHeader_map = $dataHandlerService->dataHeader(['orderno'], $orderHeaders);
|
|
|
foreach ($items as $orderTracking) {
|
|
|
$commodities = $orderTracking->commodities;
|
|
|
- $orderHeader = $dataHandlerService->getKeyValue(['orderno'=>$commodities->package->order->code],$orderHeader_map);
|
|
|
- $order_client_code = $orderTrackingService->get_d_edit_03($orderHeader,$commodities);
|
|
|
+ $orderHeader = $dataHandlerService->getKeyValue(['orderno' => $commodities->package->order->code], $orderHeader_map);
|
|
|
+ $order_client_code = $orderTrackingService->get_d_edit_03($orderHeader, $commodities);
|
|
|
$update_params[] = [
|
|
|
'id' => $orderTracking->id,
|
|
|
'order_client_code' => $order_client_code
|
|
|
];
|
|
|
}
|
|
|
$orderTrackingService->batchUpdate($update_params);
|
|
|
- unset($update_params,$orderHeaders,$orderHeader_map);
|
|
|
+ unset($update_params, $orderHeaders, $orderHeader_map);
|
|
|
}
|
|
|
- unset($orderTrackings,$orderTracking_arr);
|
|
|
+ unset($orderTrackings, $orderTracking_arr);
|
|
|
}
|
|
|
|
|
|
public function testUpdateSkuNameBarcodeToCommodity_id()
|
|
|
@@ -1258,7 +1288,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
/**@var CommodityService $commodityService */
|
|
|
$commodityService = app(CommodityService::class);
|
|
|
dump('start' . (string)Carbon::now());
|
|
|
- $commodities = $commodityService->get_($ownerIds, $skus,[],true);
|
|
|
+ $commodities = $commodityService->get_($ownerIds, $skus, [], true);
|
|
|
dump('end' . (string)Carbon::now());
|
|
|
}
|
|
|
|
|
|
@@ -1271,22 +1301,71 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
public function syncOrderTask()
|
|
|
{
|
|
|
$start_data = Carbon::parse('2020-12-10 00:00:00');
|
|
|
- $orderHeaders = OracleDOCOrderHeader::query()->selectRaw(implode(',',OracleDOCOrderHeaderService::$columns))
|
|
|
- ->with(['oracleBASCustomer'=>function($query){
|
|
|
+ $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){
|
|
|
+ }, '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){
|
|
|
+ }, '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){
|
|
|
+ }, 'oracleBASCode' => function ($query) {
|
|
|
$query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
- },'orderType'=>function($query){
|
|
|
+ }, 'orderType' => function ($query) {
|
|
|
$query->selectRaw('BAS_Codes.CodeID,BAS_Codes.CodeName_C,BAS_Codes.Code');
|
|
|
- }])->where('DOC_Order_Header.AddTime','>',$start_data)
|
|
|
+ }])->where('DOC_Order_Header.AddTime', '>', $start_data)
|
|
|
->get();
|
|
|
$service = new OrderService();
|
|
|
$service->syncOrder($orderHeaders);
|
|
|
}
|
|
|
+ public function cleanOrderIssueRepeat()
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ ->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 ($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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function testGetLogisticNumbers(): array
|
|
|
{
|