2 Commits 93441e1eb4 ... 52b2961e8f

Autor SHA1 Mensaje Fecha
  Gao 52b2961e8f 发货 hace 2 años
  Gao 6a98267b7b 发货 hace 2 años

+ 4 - 2
application/admin/controller/Orders.php

@@ -86,8 +86,9 @@ class Orders extends Backend
     public function send($ids){
         $order=$this->model->find($ids);
         if($this->request->isGet()){
+            $companys = Db('LogisticsCompany')->where(['use'=>1])->select();
             $this->assign('row',$order);
-            $this->assign('companys',\app\common\model\LogisticsCompany::all());
+            $this->assign('companys',$companys);
             return $this->fetch();
         }else{
             /*$data=input('row/a');
@@ -109,6 +110,7 @@ class Orders extends Backend
             $data=input('row/a');
             $this->validate($data,[
                 'address_id|发货地'=>['require',],
+                'com_id|物流公司'=>['require',],
                 'remark|备注'=>['max:100'],
             ]);
             Db::startTrans();
@@ -116,7 +118,7 @@ class Orders extends Backend
             if(!$address){
                 $this->error('地址不存在');
             }
-            $order->makeSendSelf($address,$data['remark']??'');
+            $order->makeSendSelf($address,$data['remark']??'',$data['com_id']);
             Db::commit();
             $this->success();
         }

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

@@ -16,6 +16,49 @@
             >
         </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">-->
+
+<!--            <select class="form-control" name="province" >-->
+<!--                <option value="1" >次日达</option>-->
+<!--                <option value="2" >隔日达</option>-->
+<!--                <option value="3" >陆运件</option>-->
+<!--                <option value="4" >省内次日</option>-->
+<!--                <option value="5" >同城次日</option>-->
+<!--            </select>-->
+<!--        </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">-->
+
+<!--            <select class="form-control" name="province" >-->
+<!--                <option value="6" selected>德邦快递-大件快递360</option>-->
+<!--                <option value="7" selected>德邦快递-重包入户</option>-->
+<!--                <option value="8" selected>顺丰速运-顺丰标快</option>-->
+<!--                <option value="9" selected>顺丰速运-顺丰特快</option>-->
+<!--            </select>-->
+<!--        </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-name"-->
+<!--                    data-rule="required"-->
+<!--                    data-params='{}'-->
+<!--                    data-source='{:json_encode($companys)}'-->
+<!--                    class="form-control selectpage"-->
+<!--                    name="row[com_id]"-->
+<!--                    data-multiple="false"-->
+<!--                    type="text"-->
+<!--                    data-pagination="false"-->
+<!--                    value="{$row.logistics.com_id|default=''}"-->
+<!--            >-->
+<!--        </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">

+ 6 - 4
application/common/model/Orders.php

@@ -256,12 +256,11 @@ class Orders extends Model
             $logistics->save($newData);
         }
     }
-    public function makeSendSelf(Address $address,$remark){
-        $com=LogisticsCompany::getSelf();
+    public function makeSendSelf(Address $address,$remark,$comId){
+        $com=LogisticsCompany::where('id','=',$comId)->find();
         $orderAddress = OrderAddress::where(['order_id'=>$this->id])->find()->toArray();
-       // dump($orderAddress);
         $newData=[
-            'com_id'=>$com->id,
+            'com_id'=>$comId,
             'remark'=>$remark,
             'from_area'=>$address->area,
             'from_address'=>$address->address,
@@ -279,6 +278,7 @@ class Orders extends Model
         if($toCity == $fromCity[1]){
             $expType = '同城次日';
         }
+
         $logistics=$this->logistics()->save($newData);
 
         $names=[];
@@ -298,6 +298,8 @@ class Orders extends Model
             ->setCount($this->info()->sum('num'))
             ->setOrderNo($this->order_no)
             ->setExpType($expType)
+            ->setComName($com['code_kd100'])
+            ->setPartnerId($com['partner_id'])
             ->labelOrder();
 
         if(!$res){

+ 4 - 3
extend/logistics/Kd100.php

@@ -107,10 +107,10 @@ 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,
+            //'partnerId'=>config('site.kd100_lo_partnerId')?:null,
+            'partnerId'=>$this->getPartnerId(),
             'partnerKey'=>config('site.kd100_lo_partnerKey')?:null,
             'partnerSecret'=>config('site.kd100_lo_partnerSecret')?:null,
             'partnerName'=>config('site.kd100_lo_partnerName')?:null,
@@ -118,7 +118,8 @@ class Kd100 extends QueryInterface{
             'code'=>config('site.kd100_lo_code')?:null,
             'checkMan'=>config('site.kd100_lo_checkMan')?:null,
             'tbNet'=>config('site.kd100_lo_tbNet')?:null,
-            'kuaidicom'=>$this->logistics->code_kd100,
+          //  'kuaidicom'=>$this->logistics->code_kd100,
+            'kuaidicom'=>$this->getComName(),
             'recMan'=>[
                 'name'=>$this->username,
                 'mobile'=>$this->phone,

+ 37 - 0
extend/logistics/QueryInterface.php

@@ -235,4 +235,41 @@ abstract class QueryInterface{
     {
         return $this->expType;
     }
+
+    protected $comName;
+    /**
+     * 物流公司
+     * @param string $comName
+     */
+    public function setComName(string $comName)
+    {
+        $this->comName = $comName;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getComName(): string
+    {
+        return $this->comName;
+    }
+    protected $partnerId;
+    /**
+     * partnerId
+     * @param string $partnerId
+     */
+    public function setPartnerId(string $partnerId)
+    {
+        $this->partnerId = $partnerId;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getPartnerId(): string
+    {
+        return $this->partnerId;
+    }
 }