| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace mall\controllers;
- use Yii;
- use common\components\util;
- use bizHd\hb\classes\HbClass;
- class HbController extends BaseController
- {
- //优惠券列表 ssh 2019.12.11
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['t.userId'] = $this->userId;
- $status = $get['status'] ?? '';
- if ($status != '') {
- $where['t.status'] = $get['status'];
- }
- $respond = HbClass::getHbList(['t.*', 's.merchantName', 's.shopName'], $where);
- if (!empty($respond['list'])) {
- foreach ($respond['list'] as &$v) {
- $v['customName'] = $v['custom']['name'] ?? '';
- if ($v['status'] == 0 && $v['endTime'] < time()) {
- //发现红包已过期,需要作废,多有处作废操作,搜索关键词 cancellation_hb
- $id = $v['id'];
- HbClass::updateById($id, ['status' => -1]);
- }
- }
- }
- util::success($respond);
- }
- // 单个门店下所有可用红包
- public function actionAvailableHb()
- {
- $where = [];
- $where['customId'] = $this->customId;
- $where['status'] = 0;
- $where['beginTime<='] = time();
- $list = HbClass::getAllByCondition($where, 'id DESC');
- //已经过期的就不再显示,并且作废,多有处作废操作,搜索关键词 cancellation_hb
- if (!empty($list)) {
- foreach ($list as $k => $v) {
- if ($v['status'] == 0 && $v['endTime'] < time()) {
- unset($list[$k]);
- $id = $v['id'];
- HbClass::updateById($id, ['status' => -1]);
- }
- }
- }
- util::success($list);
- }
- }
|