HbController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace mall\controllers;
  3. use Yii;
  4. use common\components\util;
  5. use bizHd\hb\classes\HbClass;
  6. class HbController extends BaseController
  7. {
  8. //优惠券列表 ssh 2019.12.11
  9. public function actionList()
  10. {
  11. $get = Yii::$app->request->get();
  12. $where = [];
  13. $where['t.userId'] = $this->userId;
  14. if (isset($get['status'])) {
  15. if($get['status'] == 3){
  16. // 全部状态
  17. }elseif($get['status'] == 2){ // 已失效包含:1作废 与 过期(0未使用但endTime<当前时间) --- 所以当操作作废时,status改为-1,同时将endTime改为当前时间
  18. $where['t.endTime<'] = time();
  19. } else {
  20. $where['t.status'] = $get['status'];
  21. }
  22. }
  23. $list = HbClass::getHbList(['t.*', 's.merchantName', 's.shopName'], $where);
  24. util::success($list);
  25. }
  26. // 单个门店下所有可用红包
  27. public function actionAvailableHb()
  28. {
  29. $where = [];
  30. $where['customId'] = $this->customId;
  31. $where['status'] = 0;
  32. $where['endTime>'] = time();
  33. $list = HbClass::getAllByCondition($where, 'id DESC');
  34. util::success($list);
  35. }
  36. }