erp/app/Console/Commands/Test.php

122 lines
3.8 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Events\StockUpdateEvent;
use App\Exports\DiffTodayPriceGoodsExport;
use App\Models\BusinessGoodsSku;
use App\Models\BusinessOrder;
use App\Models\GoodsSku;
use App\Models\GoodsType;
use App\Models\Log;
use App\Models\Shop;
use App\Models\ShopSender;
use App\Models\ShopShip;
use App\Models\TodayPrice;
use App\Services\Business\BusinessFactory;
use App\Services\Business\KuaiTuanTuan\FaceSheet;
use App\Utils\DateTimeUtils;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Jobs\BusinessGoodsSkuIncrQuantity;
use Illuminate\Database\Eloquent\Builder;
use Maatwebsite\Excel\Facades\Excel;
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();
}
public function handle()
{
}
/**
* Execute the console command.
*
* @return mixed
*/
public function old()
{
$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) {
ShopSender::query()->updateOrCreate(
['shop_id' => $shopId, 'shop_ship_id' => $shopShip->id, 'detail' => $item['detail']],
$item
);
}
}
}
}
}