@@ -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(){
@@ -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 class="form-group layer-footer">
@@ -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(){
+}
@@ -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]"));