| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace addons\Community\api\modules\v1\controllers;
- use addons\Community\common\service\SignService;
- use api\controllers\OnAuthController;
- use Yii;
- class SignController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- /**
- * 自提核销
- * @return mixed|null
- */
- public function actionCreate()
- {
- $data = Yii::$app->request->post();
- $valid = Yii::$app->services->validate->validate($data, [
- [['order_no'], 'string'],
- [['order_no'], 'required']
- ]);
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new SignService())->create($this->mall_id, $data['order_no'], $this->user_id);
- return is_string($ret) ? $this->error($ret) : $this->success('核销成功');
- }
- /**
- * 团长代替买家进行收货
- * @return mixed|null
- */
- public function actionReceive()
- {
- $data = Yii::$app->request->post();
- $valid = Yii::$app->services->validate->validate($data, [
- [['order_no'], 'string'],
- [['order_id'], 'integer'],
- // [['order_no'], 'required'], // 变成ID了 - 因为使用ID核销
- ]);
- if (empty($data['order_no']) && empty($data['order_id'])) {
- return $this->error("订单编号不能为空");
- }
- if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $ret = (new SignService())->create($this->mall_id,
- !empty($data['order_no']) ? $data['order_no'] : $data['order_id'], $this->user_id,
- !empty($data['order_no']) ? 'order_no' : 'id');
- return is_string($ret) ? $this->error($ret) : $this->success('收货成功');
- }
- }
|