Gao пре 2 година
родитељ
комит
8ed02d270d
3 измењених фајлова са 37 додато и 3 уклоњено
  1. 15 2
      application/common/model/Orders.php
  2. 3 1
      extend/logistics/Kd100.php
  3. 19 0
      extend/logistics/QueryInterface.php

+ 15 - 2
application/common/model/Orders.php

@@ -2,6 +2,7 @@
 
 namespace app\common\model;
 
+use app\admin\controller\City;
 use app\admin\model\Address;
 use app\admin\model\AdminMoneyLog;
 use app\common\service\GyeUdun;
@@ -257,8 +258,8 @@ class Orders extends Model
     }
     public function makeSendSelf(Address $address,$remark){
         $com=LogisticsCompany::getSelf();
-
-
+        $orderAddress = OrderAddress::where(['order_id'=>$this->id])->find()->toArray();
+       // dump($orderAddress);
         $newData=[
             'com_id'=>$com->id,
             'remark'=>$remark,
@@ -269,6 +270,15 @@ class Orders extends Model
             //'md_link'=>$label,
             //'trans_no'=>$data['kuaidinum'],
         ];
+        $newData = array_filter($newData);
+        $cityId = explode(',',$orderAddress['area']);
+        $toCity = Area::where(['id'=>$cityId[1]])->value('name');
+        $fromCitys = Address::where(['id'=>$address->id])->value('area');
+        $fromCity = explode("/",$fromCitys);
+        $expType = '';
+        if($toCity == $fromCity[1]){
+            $expType = '同城次日';
+        }
         $logistics=$this->logistics()->save($newData);
 
         $names=[];
@@ -287,7 +297,9 @@ class Orders extends Model
             ->setCargo(implode('&',$names))
             ->setCount($this->info()->sum('num'))
             ->setOrderNo($this->order_no)
+            ->setExpType($expType)
             ->labelOrder();
+
         if(!$res){
             throw_user($data);
         }
@@ -298,6 +310,7 @@ class Orders extends Model
         if(!is_dir($dir)){
             @mkdir($dir,0755,true);
         }
+        dump($saveName);  dump($data['label']);
         file_put_contents($saveName,file_get_contents($data['label']));
         $label=request()->domain().$pubname.'/'.$filename;
 

+ 3 - 1
extend/logistics/Kd100.php

@@ -107,6 +107,7 @@ class Kd100 extends QueryInterface{
         if(file_exists($dir."/{$orderNo}")){
 
         }
+       // dump(config('kd100_lo_partnerId'));die;
         $params=[
             'printType'=>'IMAGE',
             'partnerId'=>config('site.kd100_lo_partnerId')?:null,
@@ -132,6 +133,7 @@ class Kd100 extends QueryInterface{
             'tempId'=>config('site.kd100_lo_tempId')?:'3f733ac0e8ca4ebfaadfc2d9b9ca2519',
             'orderId'=>$this->getOrderNo(),
             'cargo'=>$this->getCargo(),
+            'expType'=>$this->getExpType(),
         ];
         $body=[
             'method'=>'order',
@@ -140,7 +142,7 @@ class Kd100 extends QueryInterface{
             'param'=>json_encode($params,256),
         ];
         $body['sign']=strtoupper(md5($body['param'].$body['t'].$body['key'].$this->secret));
-
+      //  dump($body);
         $response=(new Client)->post('https://api.kuaidi100.com/label/order',[
             'form_params'=>$body,
             'http_errors'=>false,

+ 19 - 0
extend/logistics/QueryInterface.php

@@ -209,6 +209,7 @@ abstract class QueryInterface{
         return $this;
     }
 
+
     /**
      * @return string
      */
@@ -216,4 +217,22 @@ abstract class QueryInterface{
     {
         return $this->orderNo;
     }
+
+    protected $expType;
+    /**
+     * @param string $expType
+     */
+    public function setExpType(string $expType)
+    {
+        $this->expType = $expType;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getExpType(): string
+    {
+        return $this->expType;
+    }
 }