BirthdayGiftController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\birthday\classes\BirthdayGiftClass;
  4. use common\components\util;
  5. use Yii;
  6. class BirthdayGiftController extends BaseController
  7. {
  8. public $guestAccess = ['info', 'claim'];
  9. public function actionInfo()
  10. {
  11. $get = Yii::$app->request->get();
  12. $token = trim($get['token'] ?? '');
  13. $account = intval($get['account'] ?? 0);
  14. if (empty($token) || $account <= 0) {
  15. util::fail('参数错误');
  16. }
  17. $data = BirthdayGiftClass::getInfoByToken($account, $token);
  18. util::success($data);
  19. }
  20. public function actionClaim()
  21. {
  22. $post = Yii::$app->request->post();
  23. if (empty($post)) {
  24. $post = Yii::$app->request->get();
  25. }
  26. $token = trim($post['token'] ?? '');
  27. $account = intval($post['account'] ?? 0);
  28. $pickupTime = trim($post['pickupTime'] ?? '');
  29. if (empty($token) || $account <= 0) {
  30. util::fail('参数错误');
  31. }
  32. BirthdayGiftClass::claimByToken($account, $token, $pickupTime);
  33. util::complete('领取成功');
  34. }
  35. }