|
|
@@ -133,6 +133,7 @@ use Firebase\JWT\JWT;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
|
|
|
+use Illuminate\Database\Eloquent\Model;
|
|
|
use Illuminate\Database\QueryException;
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
use Illuminate\Http\Request;
|
|
|
@@ -211,8 +212,113 @@ class TestController extends Controller
|
|
|
}
|
|
|
return $update;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @param Model|\stdClass $waybill
|
|
|
+ */
|
|
|
+ private function formatWaybillData($waybill):array
|
|
|
+ {
|
|
|
+ $waybill->loadMissing([
|
|
|
+ "order.shop","owner","order.warehouse.province","order.warehouse.city","order.warehouse.county"
|
|
|
+ ]);
|
|
|
+ $date = date('Y-m-d H:i:s', $waybill->deliver_at ? strtotime($waybill->deliver_at) : now()->getTimestamp());
|
|
|
+ $data = [
|
|
|
+ 'logisticID' => config('api_logistic.DB.prod.sign').date("YmdHis").mt_rand(1000, 9999).$waybill->order->id,
|
|
|
+ 'custOrderNo' => $waybill->order->client_code ?? '',
|
|
|
+ 'needTraceInfo' => config('api_logistic.DB.prod.needTraceInfo'),
|
|
|
+ 'companyCode' => config('api_logistic.DB.prod.company_code'),
|
|
|
+ 'orderType' => $waybill->order_type,
|
|
|
+ 'transportType' => $waybill->transport_type,
|
|
|
+ 'customerCode' => config('api_logistic.DB.prod.customer_Code'),
|
|
|
+ 'sender' => [
|
|
|
+ 'companyName' => '宝时物流',
|
|
|
+ 'businessNetworkNo' => '',
|
|
|
+ 'name' => '宝时物流',
|
|
|
+ 'mobile' => '',
|
|
|
+ 'phone' => '021-6316561',
|
|
|
+ 'province' => $waybill->order->warehouse->province->name ?? '',
|
|
|
+ 'city' => $waybill->order->warehouse->city->name ?? '',
|
|
|
+ 'country' => $waybill->order->warehouse->county->name ?? '',
|
|
|
+ 'town' => '',
|
|
|
+ 'address' => $waybill->order->warehouse->address ?? '',
|
|
|
+ ],
|
|
|
+ 'receiver' => [
|
|
|
+ 'toNetworkNo' => '',
|
|
|
+ 'name' => $waybill->order->consignee_name ?? '',
|
|
|
+ 'phone' => $waybill->order->consignee_phone ?? '',
|
|
|
+ 'mobile' => $waybill->order->consignee_phone ?? '',
|
|
|
+ 'province' => $waybill->order->province ?? '',
|
|
|
+ 'city' => $waybill->order->city ?? "",
|
|
|
+ 'county' => $waybill->order->district ?? '',
|
|
|
+ 'town' => '',
|
|
|
+ 'address' => $waybill->order->address ?? '',
|
|
|
+ 'companyName' => ''
|
|
|
+ ],
|
|
|
+ 'packageInfo' => [
|
|
|
+ 'cargoName' => $waybill->cargo_name ?? '',
|
|
|
+ 'totalNumber' => $waybill->total_number ?? '',
|
|
|
+ 'totalWeight' => $waybill->total_weight ?? '',
|
|
|
+ 'totalVolume' => '',
|
|
|
+ 'packageService' => $waybill->package_service ?? '',
|
|
|
+ 'deliveryType' => $waybill->deliveryType_id,
|
|
|
+ ],
|
|
|
+ 'gmtCommit' => $date,
|
|
|
+ 'payType' => $waybill->pay_type,
|
|
|
+ 'addServices' => [
|
|
|
+ 'insuranceValue' => '',
|
|
|
+ 'codType' => '',
|
|
|
+ 'reciveLoanAccount' => '',
|
|
|
+ 'accountName' => '',
|
|
|
+ 'codValue' => '',
|
|
|
+ 'backSignBill' => $waybill->back_sign_bill
|
|
|
+ ],
|
|
|
+ 'smsNotify' => config('api_logistic.DB.prod.smsNotify'),
|
|
|
+ 'sendStartTime' => $date,
|
|
|
+ 'sendEndTime' => date('Y-m-d ', $waybill->deliver_at ? strtotime($waybill->deliver_at) : now()->getTimestamp()).'23:59:59',
|
|
|
+ 'originalWaybillNumber' => $waybill->wms_bill_number ?? '',
|
|
|
+ 'remark' => $waybill->dispatch_remark ?? '',
|
|
|
+ 'isOut' => 'N',
|
|
|
+ 'passwordSigning' => config('api_logistic.DB.prod.passwordSigning'),
|
|
|
+ 'isdispatched' => '',
|
|
|
+ 'ispresaleorder'=> '',
|
|
|
+ 'isCenterDelivery' => '',
|
|
|
+// 'orderExtendFields' => [
|
|
|
+// 'value' => '',
|
|
|
+// 'key' => ''
|
|
|
+// ]
|
|
|
+ ];
|
|
|
+ $param = json_encode($data);
|
|
|
+ $timestamp = (integer)getMillisecond();
|
|
|
+ return ["params"=>$param,"timestamp"=>$timestamp,
|
|
|
+ "digest"=>base64_encode(md5($param.config('api_logistic.DB.prod.app_key').$timestamp)),
|
|
|
+ "companyCode" => config('api_logistic.DB.prod.company_code')];
|
|
|
+ }
|
|
|
public function test(Request $request)
|
|
|
{
|
|
|
+ $waybill = Waybill::query()->where("waybill_number","BSDB2112284814")
|
|
|
+ ->first();
|
|
|
+ $waybill->load("order");
|
|
|
+ if (!$waybill->order){
|
|
|
+ dd("德邦单号获取失败1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $update = $this->paramDefault($waybill);
|
|
|
+ $waybill->update($update);
|
|
|
+ $bill = app('DbOpenService')->getDbOrderNo($waybill);
|
|
|
+ if (!$bill || $bill["result"]=="false"){
|
|
|
+ dd($bill);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $waybill->update([
|
|
|
+ "carrier_bill"=>$bill['mailNo'],
|
|
|
+ "waybill_number"=>$bill['mailNo'],
|
|
|
+ "station_no"=>$bill['stationNo'],
|
|
|
+ "arrived_org_simple_name"=>$bill['arrivedOrgSimpleName'],
|
|
|
+ "much_higher_delivery"=>$bill['muchHigherDelivery'],
|
|
|
+ ]);
|
|
|
+ if (!app("WaybillService")->notifyFlux($waybill)){
|
|
|
+ dd("德邦单号回传FLUX失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
dd(1);
|
|
|
$c = "test";
|
|
|
$a = function ($b)use($c){
|