xieruidong 2 年之前
父节点
当前提交
dffab1060c

+ 18 - 0
application/admin/view/orders/send.html

@@ -29,6 +29,24 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('发货地详细地址')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-from_address" class="form-control" data-toggle="city-picker" name="row[from_address]" type="text" value="" />
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('发货人姓名')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-from_username" class="form-control" data-toggle="city-picker" name="row[from_username]" type="text" value="" />
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('发货人手机号')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-from_mobile" class="form-control" data-toggle="city-picker" name="row[from_mobile]" type="text" value="" />
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('备注')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-remark" class="form-control" name="row[remark]" type="text">

+ 1 - 0
application/common/model/LogisticsCompany.php

@@ -6,6 +6,7 @@ use think\Model;
 
 /**
  * 会员余额日志模型
+ * @property string code_kd100
  */
 class LogisticsCompany Extends Model
 {

+ 39 - 1
extend/logistics/Kd100.php

@@ -8,9 +8,11 @@ use Yansongda\Supports\Arr;
 class Kd100 extends QueryInterface{
     protected $key;
     protected $customer;
+    protected $secret;
     public function __construct()
     {
         $this->key=Env::get('logistics.kd100_key','fVczXhfg8960');
+        $this->secret=config('site.kd100_secret')?:'kd100';
         $this->customer=Env::get('logistics.kd100_customer','B20CCD1C0BAFDD7E69CC986A1A0C57E0');
     }
 
@@ -102,7 +104,43 @@ class Kd100 extends QueryInterface{
     public function labelOrder(){
         $params=[
             'printType'=>'IMAGE',
-            'partnerId'=>
+            'partnerId'=>config('site.kd100_lo_partnerId')?:'kd100',
+            'partnerKey'=>config('site.kd100_lo_partnerKey')?:'kd100',
+            'partnerSecret'=>config('site.kd100_lo_partnerSecret')?:'kd100',
+            'partnerName'=>config('site.kd100_lo_partnerName')?:'kd100',
+            'net'=>config('site.kd100_lo_net')?:'kd100',
+            'code'=>config('site.kd100_lo_code')?:'kd100',
+            'checkMan'=>config('site.kd100_lo_checkMan')?:'kd100',
+            'tbNet'=>config('site.kd100_lo_tbNet')?:'kd100',
+            'kuaidicom'=>$this->logistics->code_kd100,
+            'recMan'=>[
+                'name'=>$this->username,
+                'mobile'=>$this->phone,
+                'printAddr'=>$this->getToArea(),
+            ],
+            'sendMan'=>[
+                'name'=>$this->getFromUsername(),
+                'mobile'=>$this->getFromMobile(),
+                'printAddr'=>$this->getFromArea(),
+                'cargo'=>$this->getCargo(),
+                'count'=>$this->getCount(),
+            ],
+            'tempId'=>config('site.kd100_lo_tempId')?:'kd100',
+            'orderId'=>$this->getOrderNo(),
         ];
+        $body=[
+            'method'=>'order',
+            'key'=>$this->key,
+            't'=>time()*1000,
+            'param'=>$params,
+        ];
+        $body['sign']=md5(json_encode($params,256).$body['t'].$body['key'].$this->secret);
+
+        $response=(new Client)->post('https://api.kuaidi100.com/label/order',[
+            'json'=>$body,
+            'http_errors'=>false,
+        ]);
+        $data=json_decode($response->getBody()->getContents(),true);
+        dd($data);
     }
 }

+ 129 - 0
extend/logistics/QueryInterface.php

@@ -8,9 +8,14 @@ abstract class QueryInterface{
     protected $no;
     protected $username;
     protected $phone;
+    protected $fromMobile;
+    protected $fromUsername;
     protected $extend=[];
     /** @var LogisticsCompany */
     protected $logistics;
+    protected $fromArea;
+    protected $toArea;
+    protected $cargo;
     abstract public function query();
     abstract public function maptrack();
     public function setNo($value){
@@ -86,4 +91,128 @@ abstract class QueryInterface{
         $this->extend = $extend;
         return $this;
     }
+
+    /**
+     * @param mixed $fromArea
+     */
+    public function setFromArea($fromArea)
+    {
+        $this->fromArea = $fromArea;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getFromArea()
+    {
+        return $this->fromArea;
+    }
+
+    /**
+     * @param mixed $toArea
+     */
+    public function setToArea($toArea)
+    {
+        $this->toArea = $toArea;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getToArea()
+    {
+        return $this->toArea;
+    }
+
+    /**
+     * @param mixed $fromMobile
+     */
+    public function setFromMobile($fromMobile)
+    {
+        $this->fromMobile = $fromMobile;
+        return $this;
+    }
+
+    /**
+     * @param mixed $fromUsername
+     */
+    public function setFromUsername($fromUsername)
+    {
+        $this->fromUsername = $fromUsername;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getFromMobile()
+    {
+        return $this->fromMobile;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getFromUsername()
+    {
+        return $this->fromUsername;
+    }
+
+    /**
+     * @param mixed $cargo
+     */
+    public function setCargo($cargo)
+    {
+        $this->cargo = $cargo;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getCargo()
+    {
+        return $this->cargo;
+    }
+
+    protected $count=1;
+
+    /**
+     * @return int
+     */
+    public function getCount(): int
+    {
+        return $this->count;
+    }
+
+    /**
+     * @param int $count
+     */
+    public function setCount($count)
+    {
+        $this->count = $count;
+        return $this;
+    }
+
+    /** @var string */
+    protected $orderNo;
+
+    /**
+     * @param string $orderNo
+     */
+    public function setOrderNo(string $orderNo)
+    {
+        $this->orderNo = $orderNo;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getOrderNo(): string
+    {
+        return $this->orderNo;
+    }
 }