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

+ 22 - 1
application/admin/controller/OrderVoucher.php

@@ -3,6 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
+use think\Db;
 
 /**
  * 打款凭证
@@ -70,5 +71,25 @@ class OrderVoucher extends Backend
         }
         return $this->view->fetch();
     }
-
+    public function audit($ids){
+        if($this->request->isGet()){
+            $voucher=$this->model->find($ids);
+            $this->assign('refund',$voucher);
+            return $this->fetch();
+        }else{
+            $data=input('row/a');
+            $this->validate($data,[
+                'refund_status'=>['require','in:1,2'],
+            ]);
+            Db::startTrans();
+            $voucher=$this->model->lock(true)->where('id',$ids)->findOrFail();
+            if($voucher['status']){
+                Db::rollback();
+                $this->error('该申请已被审核');
+            }
+            $voucher->makeAudit($data['refund_status']==1);
+            Db::commit();
+            $this->success();
+        }
+    }
 }

+ 1 - 52
application/admin/model/OrderVoucher.php

@@ -5,57 +5,6 @@ namespace app\admin\model;
 use think\Model;
 
 
-class OrderVoucher extends Model
+class OrderVoucher extends \app\common\model\OrderVoucher
 {
-
-    
-
-    
-
-    // 表名
-    protected $table = 'order_voucher';
-    
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
-
-    // 定义时间戳字段名
-    protected $createTime = false;
-    protected $updateTime = false;
-    protected $deleteTime = false;
-
-    // 追加属性
-    protected $append = [
-        'create_time_text',
-        'update_time_text'
-    ];
-    
-
-    
-
-
-
-    public function getCreateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-
-    public function getUpdateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-    protected function setCreateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-    protected function setUpdateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-
 }

+ 15 - 0
application/admin/view/order_voucher/audit.html

@@ -0,0 +1,15 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('审核')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_radios('row[refund_status]',['1'=>'通过',2=>'驳回'])}
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 1 - 0
application/admin/view/order_voucher/index.html

@@ -13,6 +13,7 @@
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="0"
                            data-operate-del="0"
+                           data-operate-audit="{:$auth->check('order_voucher/audit')}"
                            width="100%">
                     </table>
                 </div>

+ 16 - 0
application/common/model/OrderVoucher.php

@@ -5,8 +5,24 @@ namespace app\common\model;
 use think\Model;
 
 /**
+ * @property Orders orders
  */
 class OrderVoucher extends Model
 {
     protected $autoWriteTimestamp=true;
+
+    public function orders(){
+        return $this->belongsTo(Orders::class,'order_id');
+    }
+
+    public function makeAudit($pass){
+        $this['status']=$pass;
+        if($pass){
+            $order=$this->orders;
+            if($order->is_wait_pay){
+                $order->makePay();
+            }
+        }
+        $this->save();
+    }
 }

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

@@ -164,10 +164,14 @@ class Orders extends Model
         if(!$order->isNotPay()){
             return false;
         }
+        $order->makePay();
+        return true;
+    }
+    public function makePay(){
+        $order=$this;
         $order['status']=self::S_WAIT_SEND;
-        $order['pay_time']=$payment['pay_time'];
+        $order['pay_time']=time();
         $order->save();
-        return true;
     }
     #发货
     public function makeSend($logistics,$data){

+ 4 - 4
public/assets/js/backend/order_voucher.js

@@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'bank_name', title: __('Bank_name')},
                         {field: 'bank_username', title: __('Bank_username')},
                         {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
-                        {field: 'status', title: __('状态'),searchList:{0:'未审核',1:'通过',2:'驳回'}},
+                        {field: 'status', title: __('状态'),searchList:{0:'未审核',1:'通过',2:'驳回'},formatter: Table.api.formatter.label},
                         {field: 'create_time', title: __('Create_time'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate:'range'},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                             buttons:[
@@ -39,13 +39,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     title: __('审核'),
                                     classname: 'btn btn-xs btn-info btn-dialog',
                                     icon: 'fa',
-                                    url: 'order_info_refund/audit',
+                                    url: 'order_voucher/audit',
                                     callback: function (data) {
                                         //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
                                         $('.btn-refresh').trigger('click')
                                     },
                                     visible: function (row) {
-                                        return row.refund_status===10 && table.data('operate-audit');
+                                        return row.status===0 && table.data('operate-audit');
                                     }
                                 },
                             ]
@@ -60,7 +60,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         add: function () {
             Controller.api.bindevent();
         },
-        edit: function () {
+        audit: function () {
             Controller.api.bindevent();
         },
         api: {