|
@@ -29,6 +29,9 @@ class Order extends Common
|
|
|
case 'unpaid':
|
|
|
$orders = $orders->unpaid();
|
|
|
break;
|
|
|
+ case 'groupon_ing':
|
|
|
+ $orders = $orders->paid()->nosend()->groupon_ing();
|
|
|
+ break;
|
|
|
case 'nosend':
|
|
|
$orders = $orders->pretendPaid()->nosend();
|
|
|
break;
|
|
@@ -206,22 +209,34 @@ class Order extends Common
|
|
|
$this->success('获取成功', $result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //取消原因
|
|
|
+ public function cancel_reason(){
|
|
|
+ $data = [
|
|
|
+ '收货地址或者手机号填错了',
|
|
|
+ '忘记支付密码/余额不足',
|
|
|
+ '无法正常支付',
|
|
|
+ '不想买了',
|
|
|
+ '其他原因',
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success(1, $data);
|
|
|
+ }
|
|
|
|
|
|
// 取消订单,未支付的才可以
|
|
|
public function cancel()
|
|
|
{
|
|
|
$user = auth_user();
|
|
|
$id = $this->request->param('id');
|
|
|
+ $reason = $this->request->param('reason');
|
|
|
|
|
|
- $order = Db::transaction(function () use ($id, $user) {
|
|
|
+ $order = Db::transaction(function () use ($id, $user, $reason) {
|
|
|
$order = OrderModel::canCancel()->where('user_id', $user->id)->with(['items', 'invoice'])->lock(true)->where('id', $id)->find();
|
|
|
if (!$order) {
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
|
|
|
$orderOper = new OrderOper();
|
|
|
- $order = $orderOper->cancel($order, $user, 'user');
|
|
|
+ $order = $orderOper->cancel($order, $user, 'user', $reason);
|
|
|
|
|
|
return $order;
|
|
|
});
|
|
@@ -238,15 +253,16 @@ class Order extends Common
|
|
|
{
|
|
|
$user = auth_user();
|
|
|
$id = $this->request->param('id');
|
|
|
+ $reason = $this->request->param('reason');
|
|
|
|
|
|
$order = OrderModel::paid()->where('user_id', $user->id)->where('id', $id)->find();
|
|
|
if (!$order) {
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
|
|
|
- $order = Db::transaction(function () use ($order, $user) {
|
|
|
+ $order = Db::transaction(function () use ($order, $user, $reason) {
|
|
|
$orderOper = new OrderOper();
|
|
|
- $order = $orderOper->applyRefund($order, $user, 'user');
|
|
|
+ $order = $orderOper->applyRefund($order, $user, 'user',$reason);
|
|
|
|
|
|
return $order;
|
|
|
});
|