xxxrrrdddd 3 rokov pred
rodič
commit
a4246f4be1

+ 5 - 0
application/admin/controller/MobileOrder.php

@@ -116,9 +116,14 @@ class MobileOrder extends Backend
             ]);
             Db::startTrans();
             $model=$this->model->where('id',$ids)->lock(true)->findOrFail();
+            if($data['amount']>$model['amount']){
+                $this->error('退款金额不能大于付款金额');
+            }
             $model['amount_refund']=$data['amount'];
             $model->save();
 
+            Db::commit();
+            $this->success();
         }
     }
     public function status(){

+ 2 - 2
application/admin/view/mobile_order/refund.html

@@ -1,8 +1,8 @@
 <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>
+        <label class="control-label col-xs-12 col-sm-2">{:__('退款金额')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-no" class="form-control" name="row[content]" type="text" data-rule="required">
+            <input id="c-no" class="form-control" name="row[amount]" type="text" data-rule="required" value="{$row.amount}">
         </div>
     </div>
     <div class="form-group layer-footer">

+ 26 - 0
application/common/service/Refund.php

@@ -0,0 +1,26 @@
+<?php
+namespace app\common\service;
+
+
+class Refund{
+    protected $type;
+    protected $amount;
+    protected $types=[
+        1=>'wechat',
+        2=>'alipay',
+    ];
+    public static function setType($type,$amount){
+        $a=new self;
+        $a->type=$type;
+        $a->amount=$amount;
+    }
+    public function refund(){
+        if(!isset($this->types[$this->type])){
+            throw_user('此付款方式不支持退款');
+        }
+        $this->{$this->types[$this->type]}();
+    }
+    public function wechat(){
+
+    }
+}

+ 3 - 0
public/assets/js/backend/mobile_order.js

@@ -147,6 +147,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         add_operation(){
             Controller.api.bindevent();
         },
+        refund(){
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));