123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace app\controller\api\pc;
- use app\Request;
- use app\services\order\StoreOrderRefundServices;
- use app\services\order\StoreOrderServices;
- class RefundController
- {
-
- protected $services;
-
- public function __construct(StoreOrderRefundServices $services)
- {
- $this->services = $services;
- }
-
- public function lst(Request $request)
- {
- $where = $request->getMore([
- ['refund_type', '', '', 'refundTypes']
- ]);
- $where['uid'] = $request->uid();
- $where['is_cancel'] = 0;
- $list = $this->services->getRefundOrderList($where);
- return app('json')->successful($list);
- }
-
- public function detail(StoreOrderRefundServices $services, Request $request, $uni)
- {
- $orderData = $services->refundDetail($uni);
- return app('json')->successful('ok', $orderData);
- }
-
- public function cancelApply(Request $request, $uni)
- {
- if (!strlen(trim($uni))) return app('json')->fail('参数错误');
- $orderRefund = $this->services->get(['order_id' => $uni, 'is_cancel' => 0]);
- if (!$orderRefund || $orderRefund['uid'] != $request->uid()) {
- return app('json')->fail('订单不存在');
- }
- if (!in_array($orderRefund['refund_type'], [1, 2, 4, 5])) {
- return app('json')->fail('当前状态不能取消申请');
- }
- $this->services->update($orderRefund['id'], ['is_cancel' => 1]);
- $this->services->cancelOrderRefundCartInfo((int)$orderRefund['id'], (int)$orderRefund['store_order_id'], $orderRefund);
- return app('json')->success('取消成功');
- }
-
- public function delRefundOrder(Request $request, $uni)
- {
- if (!strlen(trim($uni))) return app('json')->fail('参数错误');
- $orderRefund = $this->services->get(['order_id' => $uni, 'is_del' => 0]);
- if (!$orderRefund || $orderRefund['uid'] != $request->uid()) {
- return app('json')->fail('订单不存在');
- }
- if (!in_array($orderRefund['refund_type'], [3, 6])) {
- return app('json')->fail('当前状态不能删除退款单');
- }
- $this->services->update($orderRefund['id'], ['is_del' => 1]);
-
- $orderServices = app()->make(StoreOrderServices::class);
- $orderServices->update($orderRefund['store_order_id'], ['is_del' => 1]);
- return app('json')->success('删除成功');
- }
- }
|