Merge pull request !195 from 赵世界/develop
This commit is contained in:
赵世界 2023-08-18 08:57:09 +00:00 committed by Gitee
commit 7baa81ec71
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 43 additions and 0 deletions

View File

@ -7,4 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class Waybill extends Model
{
protected $guarded = [];
public static $BUSINESS_EXPRESS_CODE = 247;
public static $AIR_FREIGHT_CODE = 266;
}

View File

@ -20,6 +20,8 @@ class WayBillService
// 标准模板
public $sfStd = 'https://file-link.pinduoduo.com/sf_std';
public $sfStdTemplate = 'sf_std1677380804913.xml';
// 时效类型
public $timedDeliveryCode;
public function getContents()
{
@ -148,8 +150,35 @@ class WayBillService
return $waybill;
}
private function timedDelivery($order)
{
$this->timedDeliveryCode = Waybill::$BUSINESS_EXPRESS_CODE;
$address = [
'辽宁省' => [],
'吉林省' => [],
'黑龙江省' => [],
'甘肃省' => [],
'海南省' => [],
'宁夏回族自治区' => [
'银川市', '石嘴山市', '吴忠市', '固原市'
],
'青海省' => [
'西宁市', '海东市', '海北藏族自治州', '黄南藏族自治州', '海南藏族自治州', '玉树藏族自治州'
],
];
if (isset($address[$order['recipient_province']])) {
if (empty($address[$order['recipient_province']])) {
$this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE;
}
if ($address[$order['recipient_province']] && in_array($order['recipient_city'], $address[$order['recipient_province']], true)) {
$this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE;
}
}
}
private function prepareRequest($order, $shop)
{
$this->timedDelivery($order);
$senderConfig = $shop->senders[0];
$sender = [
'address' => [
@ -168,6 +197,11 @@ class WayBillService
$items = [];
foreach ($order['items'] as $item) {
if ($item['should_print']) {
// 使用规格编码后删除,此处暂时使用空运名字判断兼容
if (false !== strpos($item['name'], '空运')) {
$this->timedDeliveryCode = Waybill::$AIR_FREIGHT_CODE;
}
$items[] = [
'name' => $item['name'],
'count' => $item['count'],
@ -176,6 +210,11 @@ class WayBillService
}
$orderInfo = [
'logistics_services' => [
'TIMED-DELIVERY' => [
'value' => $this->timedDeliveryCode
],
],
'object_id' => $this->objectId,
'order_info' => [
'order_channels_type' => 'PDD',

View File

@ -51,6 +51,7 @@ class CreateWaybillsTable extends Migration
$table->string('order_sn');
$table->integer('order_id');
$table->integer('participate_no')->default(0);
$table->integer('timed_delivery')->default(247);
$table->string('note')->nullable();
$table->text('items');
$table->tinyInteger('cancel')->default(0);