京东打印
This commit is contained in:
parent
e850b3d336
commit
2019a88fb9
@ -9,6 +9,7 @@ use App\Models\BusinessOrder;
|
||||
use App\Models\BusinessOrderItem;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Models\Shop;
|
||||
use App\Models\Waybill;
|
||||
use App\Services\WayBill\JingDong\WayBillService;
|
||||
use App\Utils\DateTimeUtils;
|
||||
use Carbon\Carbon;
|
||||
@ -37,7 +38,7 @@ class BusinessOrderController extends Controller
|
||||
$builder->whereIn('id', $ids);
|
||||
}
|
||||
|
||||
if($request->get("is_export")){
|
||||
if ($request->get("is_export")) {
|
||||
$params = $request->validate([
|
||||
'confirm_at_start' => 'required',
|
||||
'confirm_at_end' => 'required',
|
||||
@ -52,7 +53,7 @@ class BusinessOrderController extends Controller
|
||||
throw new \Exception("导出时间超出一个月");
|
||||
}
|
||||
|
||||
return Excel::download(new BusinessOrderExport($builder->get()->toArray()), $startDate . '~' . $endDate."订单数据" . '.xlsx');
|
||||
return Excel::download(new BusinessOrderExport($builder->get()->toArray()), $startDate . '~' . $endDate . "订单数据" . '.xlsx');
|
||||
}
|
||||
$businessOrders = $builder->orderByDesc('confirm_at')
|
||||
->paginate($request->get('per_page'));
|
||||
@ -248,9 +249,11 @@ class BusinessOrderController extends Controller
|
||||
$orderIds = $request->input('order_ids');
|
||||
$orderIds = explode(',', $orderIds);
|
||||
BusinessOrder::query()
|
||||
->where('id', $orderIds)
|
||||
->whereIn('id', $orderIds)
|
||||
->increment('print_status');
|
||||
|
||||
Waybill::query()
|
||||
->where('order', $orderIds)
|
||||
->update(['status' => Waybill::$STATUS_PRINT_SUCCESS]);
|
||||
return response(['message' => 'success']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class ShopSendsController extends Controller
|
||||
'district.required' => '请选择地区',
|
||||
'detail.required' => '请填写详细地址',
|
||||
]);
|
||||
$params['wp_code'] = $params['wp_code'] ?? 'jd';
|
||||
$params['wp_code'] = $params['wp_code'] ?? 'JD';
|
||||
$params['country'] = $params['country'] ?? '中国';
|
||||
if (empty($params['id'])) {
|
||||
$shopSender = new ShopSender();
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\traits\Filter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShopSender extends Model
|
||||
{
|
||||
use Filter;
|
||||
protected $guarded = [];
|
||||
|
||||
//查询字段
|
||||
|
||||
@ -10,4 +10,8 @@ class Waybill extends Model
|
||||
|
||||
public static $BUSINESS_EXPRESS_CODE = 247;
|
||||
public static $AIR_FREIGHT_CODE = 266;
|
||||
|
||||
public static $STATUS_CREATE_WAYBILL_CODE = 1;
|
||||
public static $STATUS_CREATE_WAYBILL_ENCRYPTED_DATA = 2;
|
||||
public static $STATUS_PRINT_SUCCESS = 3;
|
||||
}
|
||||
|
||||
@ -374,7 +374,6 @@ class KuaiTuanTuan extends BusinessClient
|
||||
public function createLogistic($orderSn, $waybillNo)
|
||||
{
|
||||
[$type, $appendParams] = Order::createOrderLogistic($orderSn, $waybillNo);
|
||||
|
||||
return $this->doRequest($type, $appendParams);
|
||||
}
|
||||
|
||||
|
||||
@ -136,8 +136,8 @@ class JingDongService
|
||||
"channelOrderId" => $pickupData['order_sn'],
|
||||
"promiseTimeType" => 26,//22:医药冷链 26:冷链专送,29医药专送
|
||||
"goodsType" => 7,//1:普通,2:生鲜常温,5:鲜活,6:控温,7:冷藏,8:冷冻,9:深冷;21:医药冷藏,23:医药控温,24:医药常温,25:医药冷冻,27:医药深冷
|
||||
//"pickUpStartTime" => Carbon::today()->startOfDay()->addHours(19)->toDateTimeString(),
|
||||
//"pickUpEndTime" => Carbon::today()->startOfDay()->addHours(21)->toDateTimeString(),
|
||||
//"pickUpStartTime" => Carbon::today()->startOfDay()->addDays(2)->addHours(19)->toDateTimeString(),
|
||||
//"pickUpEndTime" => Carbon::today()->startOfDay()->addDays(2)->addHours(21)->toDateTimeString(),
|
||||
];
|
||||
|
||||
$response = $this->request($body, $path);
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Services\WayBill\JingDong;
|
||||
|
||||
use App\Events\CreateLogisticEvent;
|
||||
use App\Http\Enum\BusinessOrderShippingStatus;
|
||||
use App\Models\BusinessOrder;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Models\ShopSender;
|
||||
use App\Models\ShopShip;
|
||||
@ -38,6 +40,7 @@ class WayBillService
|
||||
if (empty($waybill->waybill_code)) {
|
||||
$resp = $jingDongService->createOrder($waybill);
|
||||
if (isset($resp['waybillNo'])) {
|
||||
$waybill->status = Waybill::$STATUS_CREATE_WAYBILL_CODE;
|
||||
$waybill->waybill_code = $resp['waybillNo'];
|
||||
$waybill->save();
|
||||
//物流发货
|
||||
@ -50,6 +53,7 @@ class WayBillService
|
||||
usleep(0.5 * 1000000);
|
||||
$resp = $jingDongService->pullData($waybill);
|
||||
if (!empty($resp[0]['perPrintData'])) {
|
||||
$waybill->status = Waybill::$STATUS_CREATE_WAYBILL_ENCRYPTED_DATA;
|
||||
$waybill->templateUrl = $this->templateUrl;
|
||||
$waybill->encryptedData = $resp[0]['perPrintData'];
|
||||
$waybill->save();
|
||||
@ -215,6 +219,12 @@ class WayBillService
|
||||
$orders = $orders->toArray();
|
||||
// 订单拆分组合
|
||||
foreach ($orders as $order) {
|
||||
if ($order['shipping_status'] != BusinessOrderShippingStatus::UNSHIP) {
|
||||
continue;
|
||||
}
|
||||
if ($order['cancel_status'] == 1) {
|
||||
continue;
|
||||
}
|
||||
$info = [
|
||||
'id' => $order['id'],
|
||||
'shop_id' => $order['shop_id'],
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFieldToWaybillsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumns('waybills', ["status"])) {
|
||||
return;
|
||||
}
|
||||
Schema::table('waybills', function (Blueprint $table) {
|
||||
$table->integer('status')->default(0)->comment('状态 0待申请物流单 1已申请物流 2已申请面单 3已打印');
|
||||
$table->index('order_id');
|
||||
$table->index('order_sn');
|
||||
$table->index('waybill_code');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('waybills', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('status');
|
||||
$table->dropIndex('order_id');
|
||||
$table->dropIndex('order_sn');
|
||||
$table->dropIndex('waybill_code');
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user