Skip to content

Commit edae50a

Browse files
committed
增加退款按钮渲染
增加退款页面渲染 独立退款请求 绣花代码格式
1 parent 70e7503 commit edae50a

File tree

1 file changed

+146
-18
lines changed

1 file changed

+146
-18
lines changed

src/App/Http/Controllers/Api/OrderController.php

Lines changed: 146 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,163 @@ public function index(Request $request)
3636
->orderBy('order_id', 'DESC')
3737
->pageSize($this->configModel->getPageSize())
3838
->getData($this->orderModel);
39-
$pictureConfig = [ 'width'=>80, 'class'=>'img-responsive', 'alt'=>'支付方式'];
39+
$pictureConfig = [
40+
'width'=>80,
41+
'class'=>'img-responsive',
42+
'alt'=>'支付方式'
43+
];
4044
//组类按钮配置
4145
$groupButton = [
42-
'buttonType'=>'group', 'groupKey'=> 'status', 'group'=> [
43-
'paid'=>['title'=>'退款','apiUrl'=> route('api.admin.omnipay.order.refund'),'type'=>'danger','icon'=>'fa fa-history'],
44-
'unpaid'=>['title'=>'关闭','apiUrl'=> route('api.admin.omnipay.order.close'),'type'=>'warning','icon'=>'fa fa-power-off'],
45-
]
46+
'buttonType'=>'group',
47+
'groupKey'=> 'status',
48+
'group'=> [
49+
'paid'=>[
50+
'title'=>'退款',
51+
'apiUrl'=> route('api.admin.omnipay.order.refundHtml'),
52+
'type'=>'danger',
53+
'icon'=>'fa fa-history'
54+
],
55+
'unpaid'=>[
56+
'title'=>'关闭',
57+
'apiUrl'=> route('api.admin.omnipay.order.close'),
58+
'type'=>'warning',
59+
'icon'=>'fa fa-power-off'
60+
],
61+
]
4662
];
4763
$table = resolve('builderTable')
4864
->data($data['model'])
49-
->column(['prop' => 'id', 'label'=> 'ID', 'width'=> '55'])
50-
->column(['prop' => 'order_id', 'label'=> '订单ID', 'width'=> '200'])
51-
->column(['prop' => 'name', 'label'=> '订单名称', 'minWidth'=> '260'])
52-
->column(['prop' => 'fee', 'label'=> '金额(元)', 'minWidth'=> '100'])
53-
->column(['prop' => 'showStatus', 'label'=> '状态', 'minWidth'=> '120'])
54-
->column(['prop' => 'showGateway','label'=> '付款方式', 'minWidth'=> '120', 'type' => 'picture', 'config'=> $pictureConfig ])
55-
->column(['prop' => 'rightButton','label'=> '操作', 'minWidth'=> '220', 'type' => 'btn']) // 添加新增按钮
56-
->topButton(['buttonType'=>'default', 'apiUrl'=> route('api.admin.system.menu.delete'),'title'=>'批量导出','type'=>'info']) // 添加删除按钮
57-
->rightButton(['buttonType'=>'default', 'apiUrl'=> route('api.admin.system.menu.edit'),'title'=>'详情','type'=>'info','icon'=>'fa fa-eye'])
65+
->column([
66+
'prop' => 'id',
67+
'label'=> 'ID',
68+
'width'=> '55'
69+
])
70+
->column([
71+
'prop' => 'order_id',
72+
'label'=> '订单ID',
73+
'width'=> '200'
74+
])
75+
->column([
76+
'prop' => 'name',
77+
'label'=> '订单名称',
78+
'minWidth'=> '260'
79+
])
80+
->column([
81+
'prop' => 'fee',
82+
'label'=> '金额(元)',
83+
'minWidth'=> '100'
84+
])
85+
->column([
86+
'prop' => 'showStatus',
87+
'label'=> '状态',
88+
'minWidth'=> '120'
89+
])
90+
->column([
91+
'prop' => 'showGateway',
92+
'label'=> '付款方式',
93+
'minWidth'=> '120',
94+
'type' => 'picture',
95+
'config'=> $pictureConfig
96+
])
97+
->column([
98+
'prop' => 'rightButton',
99+
'label'=> '操作',
100+
'minWidth'=> '220',
101+
'type' => 'btn'
102+
]) // 添加新增按钮
103+
->topButton([
104+
'buttonType'=>'default',
105+
'apiUrl'=> route('api.admin.system.menu.delete'),
106+
'title'=>'批量导出',
107+
'type'=>'info'
108+
]) // 添加删除按钮
109+
->rightButton([
110+
'buttonType'=>'default',
111+
'apiUrl'=> route('api.admin.system.menu.edit'),
112+
'title'=>'详情',
113+
'type'=>'info',
114+
'icon'=>'fa fa-eye'
115+
])
58116
->rightButton($groupButton)
59-
->pagination(['total'=>$data['total'], 'pageSize'=>$data['pageSize'], 'pageSizes'=>$pageSizes])
117+
->pagination([
118+
'total'=>$data['total'],
119+
'pageSize'=>$data['pageSize'],
120+
'pageSizes'=>$pageSizes
121+
])
60122
->searchTitle('请输入搜索内容')
61-
->searchSelect(['order_id'=>'订单ID','query_id'=>'第三方ID','uid'=>'用户ID','username'=>'用户名','name'=>'订单名称','fee'=>'订单金额'])
62-
;
123+
->searchSelect([
124+
'order_id'=>'订单ID',
125+
'query_id'=>'第三方ID',
126+
'uid'=>'用户ID',
127+
'username'=>'用户名',
128+
'name'=>'订单名称',
129+
'fee'=>'订单金额'
130+
]);
63131
return resolve('builderHtml')->title('支付订单')->item($table)->response();
64132
}
133+
/**
134+
* [refundHtml 退款页面]
135+
* @param Request $request [description]
136+
* @return [type] [description]
137+
*/
138+
public function refundHtml(Request $request)
139+
{
140+
$order = $this->orderModel->getOrder($request->id);
141+
$builderForm = resolve('builderForm')
142+
->item([
143+
'name' => 'gateway',
144+
'type' => 'height',
145+
'label' => '支付方式'
146+
])
147+
->item([
148+
'name' => 'query_id',
149+
'type' => 'height',
150+
'label' => '查询ID'
151+
])
152+
->item([
153+
'name' => 'order_id',
154+
'type' => 'text',
155+
'label' => '订单id',
156+
'disabled'=>true
157+
])
158+
->item([
159+
'name' => 'name',
160+
'type' => 'text',
161+
'label' => '订单名称',
162+
'disabled'=>true
163+
])
164+
->item([
165+
'name' => 'fee',
166+
'type' => 'text',
167+
'label' => '退款金额'
168+
])
169+
->itemData($order)
170+
->apiUrl('submit', route('api.admin.omnipay.order.refund'));
171+
return resolve('builderHtml')
172+
->title('订单退款')
173+
->item($builderForm)
174+
->config('layout', ['xs' => 24, 'sm' => 20, 'md' => 18, 'lg' => 16])
175+
->response();
176+
}
177+
/**
178+
* [refund 处理退款请求]
179+
* @param Request $request [description]
180+
* @return [type] [description]
181+
*/
65182
public function refund(Request $request)
66183
{
67-
$this->orderModel->refund($request->id);
184+
if ($this->orderModel->refund($request->all())) {
185+
$message = [
186+
'message' => '退款成功!!',
187+
'type' => 'success',
188+
];
189+
} else {
190+
$message = [
191+
'message' => '退款失败!!',
192+
'type' => 'error',
193+
];
194+
}
195+
return resolve('builderHtml')->message($message)->response();
68196
}
69197
public function close(Request $request)
70198
{

0 commit comments

Comments
 (0)