| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace addons\Area\api\modules\v1\controllers;
- use addons\Area\common\service\OrderService;
- use api\controllers\OnAuthController;
- use Yii;
- use Exception;
- /**
- * Class OrderController
- * @package api\modules\order\controllers
- */
- class OrderController extends OnAuthController
- {
- public $modelClass = '';
- /**
- *
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [
- 'get-confirm-receive-data'
- ];
- /**
- * 订单预览
- * @Author bing
- * @DateTime 2021-09-24 19:46:46
- * @return void
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- public function actionPreview()
- {
- $request = Yii::$app->request;
- try {
- if ($request->isPost) {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['level', 'district_id'], 'integer'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $post['mall_id'] = $this->mall_id;
- $post['user_id'] = $this->user_id;
- $data = (new OrderService())->preview($post);
- return $this->success('操作成功', $data);
- }
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- /**
- * 创建订单
- * @Author bing
- * @DateTime 2021-09-22 09:31:22
- * @return void
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- public function actionCreate()
- {
- $request = Yii::$app->request;
- try {
- if ($request->isPost) {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['level', 'district_id'], 'integer'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $post['mall_id'] = $this->mall_id;
- $post['user_id'] = $this->user_id;
- $data = (new OrderService())->created($post);
- return $this->success('操作成功', $data);
- }
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- }
|