feat: #10000 成本同步

This commit is contained in:
赵世界 2023-09-06 17:02:48 +08:00
parent 6380543412
commit 496d46ee76
4 changed files with 54 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace App\Console\Commands;
use App\Events\CreateLogisticEvent;
use App\Events\StockUpdateEvent;
use App\Exports\DiffTodayPriceGoodsExport;
use App\Jobs\SyncCostToMiaoXuan;
use App\Models\BusinessGoodsSku;
use App\Models\BusinessOrder;
use App\Models\GoodsSku;

View File

@ -203,7 +203,7 @@ class BusinessOrderController extends Controller
];
$data = [];
foreach ($documents as &$document) {
$documentData['data']['list'][0]['text'] = '[跟团号: ' . $document['participate_no'] . '] ';
$documentData['data']['list'][0]['text'] = $document['participate_no'] ? '[跟团号: ' . $document['participate_no'] . '] ' : '';
$documentID = $document['documentID'];
$count = 0;
foreach ($document['items'] as $item) {

View File

@ -2,6 +2,7 @@
namespace App\Imports;
use App\Jobs\SyncCostToMiaoXuan;
use App\Models\DailyStockRecord;
use App\Models\GoodsSku;
use App\Models\TodayPrice;
@ -54,6 +55,7 @@ class InventoryImport implements ToArray, SkipsEmptyRows
'cost' => $row[4],
]);
}
SyncCostToMiaoXuan::dispatch($row[0], $row[4]);
$updateIds[] = $goodsSku['id'];
DailyStockRecord::query()->where('sku_id', $goodsSku['id'])->where('day', $day)->update([
'arrived_today_num' => $row[3],

View File

@ -0,0 +1,50 @@
<?php
namespace App\Jobs;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyncCostToMiaoXuan implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $externalSkuId;
public $cost;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($externalSkuId, $cost)
{
$this->externalSkuId = $externalSkuId;
$this->cost = $cost;
}
/**
* Execute the job.
*
* @return void
* @throws GuzzleException
*/
public function handle()
{
$url = 'http://shop.chutang66.com/miaoxuan/cost';
$method = 'PUT';
$headers = [
'headers' => ['Content-type' => 'application/x-www-form-urlencoded;charset=UTF-8'],
'form_params' => [
'external_sku_id' => $this->externalSkuId,
'cost' => $this->cost,
]
];
(new Client())->request($method, $url, $headers);
}
}