admin/app/frontend/modules/order/controllers/OperationController.php

136 lines
3.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Created by PhpStorm.
* Author:
* Date: 2017/3/3
* Time: 下午2:30
*/
namespace app\frontend\modules\order\controllers;
use app\common\components\ApiController;
use app\common\exceptions\AppException;
use app\common\models\Order;
use app\frontend\modules\order\services\OrderService;
use app\frontend\modules\order\services\MiniMessageService;
class OperationController extends ApiController
{
public $transactionActions = ['*'];
protected $params;
protected $order;
/**
* @return \Illuminate\Http\JsonResponse|void
* @throws \app\common\exceptions\ShopException
*/
public function __construct()
{
parent::__construct(); // TODO: Change the autogenerated stub
}
public function preAction()
{
parent::preAction(); // TODO: Change the autogenerated stub
$this->params = request()->input();
if (!isset($this->params['order_id'])) {
return $this->errorJson('order_id 不能为空!');
}
$this->order = app('OrderManager')->make('Order')->find($this->params['order_id']);
if (!isset($this->order)) {
return $this->errorJson('未找到该订单!');
}
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function pay()
{
OrderService::orderPay($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function cancelPay()
{
OrderService::orderCancelPay($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function send()
{
OrderService::orderSend($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function cancelSend()
{
OrderService::orderCancelSend($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function Receive()
{
$restrictAccess = \app\common\services\RequestTokenService::limitRepeat('f_order_receive'. $this->params['order_id']);
if (!$restrictAccess) {
throw new AppException('短时间内重复操作请等待10秒后再操作');
}
OrderService::orderReceive($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function Delete()
{
OrderService::orderDelete($this->params);
return $this->successJson();
}
/**
* @return \Illuminate\Http\JsonResponse
* @throws \app\common\exceptions\AppException
*/
public function Close()
{
$restrictAccess = \app\common\services\RequestTokenService::limitRepeat('f_order_close'. $this->params['order_id']);
if (!$restrictAccess) {
throw new AppException('短时间内重复操作请等待10秒后再操作');
}
OrderService::orderClose($this->params);
//$ingress = \Yunshop::request()->ingress;
//$type = \Yunshop::request()->type;
// if ($ingress == 'weChatApplet' && $type == 2){
// $order = Order::find(\Yunshop::request()->orderId);
// (new MiniMessageService($order,'',2,'订单取消通知'))->received();
// }
return $this->successJson();
}
}