erp/app/Console/Commands/Test.php

124 lines
3.9 KiB
PHP
Raw Normal View History

2022-08-08 16:00:47 +08:00
<?php
namespace App\Console\Commands;
2022-11-04 15:01:55 +08:00
use App\Events\StockUpdateEvent;
2023-04-20 20:43:49 +08:00
use App\Exports\DiffTodayPriceGoodsExport;
2022-11-04 15:01:55 +08:00
use App\Models\BusinessGoodsSku;
use App\Models\BusinessOrder;
2022-08-24 18:09:34 +08:00
use App\Models\GoodsSku;
2023-04-17 18:56:59 +08:00
use App\Models\GoodsType;
use App\Models\Log;
2022-08-08 16:00:47 +08:00
use App\Models\Shop;
2023-07-27 18:30:09 +08:00
use App\Models\ShopSender;
use App\Models\ShopShip;
2023-04-20 20:43:49 +08:00
use App\Models\TodayPrice;
2022-08-08 16:00:47 +08:00
use App\Services\Business\BusinessFactory;
2023-04-26 18:16:17 +08:00
use App\Services\Business\KuaiTuanTuan\FaceSheet;
2023-07-28 15:35:47 +08:00
use App\Services\Ship\WayBillService;
2022-08-09 10:34:36 +08:00
use App\Utils\DateTimeUtils;
2023-07-26 13:58:52 +08:00
use Carbon\Carbon;
2022-08-08 16:00:47 +08:00
use Illuminate\Console\Command;
2022-09-08 01:02:07 +08:00
use Illuminate\Support\Facades\DB;
2022-11-04 15:01:55 +08:00
use App\Jobs\BusinessGoodsSkuIncrQuantity;
2023-04-17 18:56:59 +08:00
use Illuminate\Database\Eloquent\Builder;
2023-04-20 20:43:49 +08:00
use Maatwebsite\Excel\Facades\Excel;
2022-08-08 16:00:47 +08:00
class Test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test';
/**
* The console command description.
*
* @var string
*/
protected $description = '测试';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
2023-07-27 21:28:00 +08:00
2023-07-27 18:30:09 +08:00
public function handle()
{
}
2022-08-08 16:00:47 +08:00
/**
* Execute the console command.
*
* @return mixed
*/
2023-07-27 18:30:09 +08:00
public function old()
2022-08-08 16:00:47 +08:00
{
2023-07-27 18:30:09 +08:00
$resp = [
'pdd_waybill_search_response' => [
'waybill_apply_subscription_cols' => [
[
'wp_type' => 3,
'branch_account_cols' => [
[
'quantity' => 0,
'shipp_address_cols' => [
[
'country' => '中国',
'province' => '云南省',
'city' => '昆明市',
'district' => '官渡区',
'detail' => '肖家营花卉市场1期-2',
],
[
'country' => '中国',
'province' => '云南省',
'city' => '昆明市',
'district' => '官渡区',
'detail' => '肖家营花卉市场1期-3',
],
[
'country' => '中国',
'province' => '云南省',
'city' => '昆明市',
'district' => '官渡区',
'detail' => '肖家营花卉市场1期',
],
]
]
]
]
]
]
];
$shopId = 6;
$shopShip = ShopShip::query()
->where('shop_id', $shopId)
->first();
if (empty($shopShip)) {
exit(1);
}
if (!isset($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'])) {
exit(2);
}
foreach ($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'] as $subCols) {
foreach ($subCols['branch_account_cols'] as $accountCols) {
foreach ($accountCols['shipp_address_cols'] as $item) {
2023-07-27 21:28:00 +08:00
$item['wp_code'] = $subCols['wp_code'];
2023-07-27 18:30:09 +08:00
ShopSender::query()->updateOrCreate(
['shop_id' => $shopId, 'shop_ship_id' => $shopShip->id, 'detail' => $item['detail']],
$item
);
}
}
}
2022-08-08 16:00:47 +08:00
}
}