| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace mall\controllers;
- use bizHd\birthday\classes\BirthdayGiftClass;
- use common\components\util;
- use Yii;
- class BirthdayGiftController extends BaseController
- {
- public $guestAccess = ['info', 'claim'];
- public function actionInfo()
- {
- $get = Yii::$app->request->get();
- $token = trim($get['token'] ?? '');
- $account = intval($get['account'] ?? 0);
- if (empty($token) || $account <= 0) {
- util::fail('参数错误');
- }
- $data = BirthdayGiftClass::getInfoByToken($account, $token);
- util::success($data);
- }
- public function actionClaim()
- {
- $post = Yii::$app->request->post();
- if (empty($post)) {
- $post = Yii::$app->request->get();
- }
- if (BirthdayGiftClass::isSmsClaimPush($post)) {
- Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- try {
- BirthdayGiftClass::claimBySmsPush($post);
- return ['clcode' => '000000'];
- } catch (\Throwable $e) {
- Yii::error('birthday gift sms claim failed: ' . $e->getMessage() . ' params=' . json_encode($post, JSON_UNESCAPED_UNICODE), __METHOD__);
- return ['clcode' => '111111'];
- }
- }
- $token = trim($post['token'] ?? '');
- $account = intval($post['account'] ?? 0);
- $pickupTime = trim($post['pickupTime'] ?? '');
- if (empty($token) || $account <= 0) {
- util::fail('参数错误');
- }
- BirthdayGiftClass::claimByToken($account, $token, $pickupTime);
- util::complete('领取成功');
- }
- }
|