|
|
@@ -18,14 +18,15 @@ use think\console\Input;
|
|
|
use think\console\Output;
|
|
|
use GuzzleHttp\Client;
|
|
|
use app\common\model\CrontabLog;
|
|
|
-use app\common\model\FengsuSku;
|
|
|
+use app\common\model\ImportSku;
|
|
|
use app\common\model\ShopList;
|
|
|
use app\common\model\ProductConfig;
|
|
|
use app\common\model\ShopDelivery;
|
|
|
use app\common\model\CustomerSpec;
|
|
|
use app\admin\service\FengsuService;
|
|
|
use GuzzleHttp\Psr7\Request;
|
|
|
-
|
|
|
+use app\common\model\ImportList;
|
|
|
+use app\admin\service\JuShuiTanService;
|
|
|
//抖音
|
|
|
class FengSu extends Command
|
|
|
{
|
|
|
@@ -39,9 +40,11 @@ class FengSu extends Command
|
|
|
'Accept' => 'application/json, text/plain, */*',
|
|
|
'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODYwNTQ1MTExNSIsImRhdGFfcGVybWlzc2lvbiI6InByb2R1Y3RDb3N0IiwibmlrZSI6IjE4NjA1NDUxMTE1IiwiY3JlYXRlZCI6MTc2NDEyNTQwMzQ0OSwiZHBJZCI6MTAwNjczLCJleHAiOjE3NjQ3MzAyMDMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTAwNjczfQ.ihv6NRfD2hzU1NQoqttTaZ-mPxqAEXIUICM8MuxVx2tVLEPW9j-uPhHoFz4T3-lH07wTt2ORf1k_SPOQP4PuQg',
|
|
|
'Content-Type' => 'application/json',
|
|
|
- 'platform' => 'dy',
|
|
|
+ // 'platform' => 'dy',
|
|
|
];
|
|
|
|
|
|
+ // 打单平台 1:风速 2:聚水潭
|
|
|
+ protected $type_id=1;
|
|
|
// 指令配置
|
|
|
protected function configure()
|
|
|
{
|
|
|
@@ -53,10 +56,12 @@ class FengSu extends Command
|
|
|
{
|
|
|
$output->writeln('开始同步订单');
|
|
|
|
|
|
- $resquet = $this->getOrderList('dy');
|
|
|
+ $resquet = $this->getOrderList('');
|
|
|
if($resquet['code'] == 0){
|
|
|
if($resquet['data']['total'] > 0){
|
|
|
$list = $resquet['data']['list'];
|
|
|
+ // dump($list);
|
|
|
+ // return;
|
|
|
$this->insertOrder($list);
|
|
|
//dump($resquet);
|
|
|
}else{
|
|
|
@@ -69,7 +74,7 @@ class FengSu extends Command
|
|
|
$output->writeln('ok');
|
|
|
}
|
|
|
|
|
|
- public function getOrderList($platform = 'dy')
|
|
|
+ public function getOrderList($platform = '')
|
|
|
{
|
|
|
$client = new \GuzzleHttp\Client([
|
|
|
'verify' => false,
|
|
|
@@ -88,11 +93,11 @@ class FengSu extends Command
|
|
|
"sort": "CONSIGN_TIME",
|
|
|
"sortAsc": false,
|
|
|
"current": 1,
|
|
|
- "size": 100,
|
|
|
+ "size": 1,
|
|
|
"tradeStatus": 2,
|
|
|
"fromAccountId": [],
|
|
|
- "goodType": 3,
|
|
|
- "goodsFlag": 1
|
|
|
+ "goodType": 2,
|
|
|
+ "goodsFlag": 2
|
|
|
}';
|
|
|
$request = new Request('POST', 'https://fsdy2.fengsutb.com/amount/ship-list-new', $headers, $body);
|
|
|
$res = $client->sendAsync($request)->wait();
|
|
|
@@ -111,33 +116,49 @@ class FengSu extends Command
|
|
|
}
|
|
|
$queue = [];
|
|
|
$shopList = new ShopList();
|
|
|
- $fengsuSku = new FengsuSku();
|
|
|
+ $importSku = new ImportSku();
|
|
|
$productConfig = new ProductConfig();
|
|
|
$shopDelivery = new ShopDelivery();
|
|
|
$customerSpec = new CustomerSpec();
|
|
|
foreach($order_list as $item) {
|
|
|
- dump($item['shopId'], '店铺id');
|
|
|
- $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
|
|
|
+ $goods_id=$item['tradeOrderPrintVos'][0]['goodsId'];
|
|
|
+ $oid=$item['tradeOrderPrintVos'][0]['oid'];
|
|
|
+ $waybill_no=$item['waybillNo'];
|
|
|
+ if(empty($waybill_no)) continue;
|
|
|
+ $add_status = JuShuiTanService::prevent_duplicate_additions($oid,$waybill_no);
|
|
|
+ if($add_status) continue;
|
|
|
+ $status = FengsuService::getAdditionalPrice( $shopList, $importSku, $productConfig, $shopDelivery, $customerSpec, $item);
|
|
|
+
|
|
|
+ $weight=$item['tradeOrderPrintVos'][0]['weight'];
|
|
|
+ $weight=strval($weight);
|
|
|
+ $weight=bcdiv($weight, '500', 2);
|
|
|
+ $weight=(float)$weight;
|
|
|
+ $price=$item['tradeOrderPrintVos'][0]['payment'];
|
|
|
+ $price=strval($price);
|
|
|
+ $price=bcdiv($price, '100', 2);
|
|
|
+ $price=(float)$price;
|
|
|
$queue[] = [
|
|
|
+ 'type_id' => $this->type_id,
|
|
|
'shop_id' => $item['shopId'],
|
|
|
+ 'order_id' => $oid,
|
|
|
'trade_from' => $item['tradeFrom'],
|
|
|
'province' => $item['receiverProvince'],
|
|
|
'city' => $item['receiverCity'],
|
|
|
- 'company_name' => $item['tradeOrderPrintVos'][0]['companyName'],
|
|
|
- 'waybill_no' => $item['waybillNo'],
|
|
|
+ 'company_name' => $item['companyName'],
|
|
|
+ 'waybill_no' => $waybill_no,
|
|
|
'consign_time' => $item['consignTime'],
|
|
|
- 'goods_id' => $item['tradeOrderPrintVos'][0]['goodsId'],
|
|
|
+ 'goods_id' => $goods_id,
|
|
|
'sku_id' => $item['tradeOrderPrintVos'][0]['skuId'],
|
|
|
'num' => $item['tradeOrderPrintVos'][0]['total'],
|
|
|
'goods_title' => $item['tradeOrderPrintVos'][0]['goodsTitle'],
|
|
|
- 'weigh' => $item['tradeOrderPrintVos'][0]['weight'],
|
|
|
- 'price' => bcdiv((string)$item['payment'], '100', 2),
|
|
|
+ 'goods_info' => $item['tradeOrderPrintVos'][0]['skuProp'],
|
|
|
+ 'weight' =>$weight,
|
|
|
+ 'price' => $price,
|
|
|
'status' => $status,
|
|
|
];
|
|
|
}
|
|
|
-
|
|
|
// 保存到数据库
|
|
|
- (new FengsuShip())->saveAll($queue);
|
|
|
+ (new ImportList())->saveAll($queue);
|
|
|
// 更新最后执行时间
|
|
|
CrontabLog::create(['type_id' => 2,'last_time' => date('Y-m-d H:i:s')]);
|
|
|
}
|