| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\workerapi\lists;
- use app\workerapi\logic\SaleLogic;
- use app\api\lists\BaseApiDataLists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\group_activity\GroupActivityCategory;
- /**
- * 销售-拼团活动列表
- * Class GroupActivityLists
- * @package app\api\lists\property
- */
- class GroupActivityLists extends BaseApiDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/07/07 18:37
- */
- public function setSearch(): array
- {
- return [
- '=' => [],
- ];
- }
- public function queryWhere()
- {
- // 指定销售
- $sale_id = SaleLogic::getSaleIdByToken($this->params['sale_token']??'00000');
- $where[] = ['b.sale_id', '=', $sale_id];
- if (isset($this->params['start_time']) && !empty($this->params['start_time'])) {
- $monthStart = strtotime(date("Y-m-01",strtotime($this->params['start_time'])));
- $monthEnd = strtotime(date("Y-m-t 23:59:59",strtotime($this->params['start_time'])));
- $where[] = ['start_time', 'between', [$monthStart, $monthEnd]];
- }
- return $where;
- }
-
- /**
- * @notes 获取列表
- * @return array
- */
- public function lists(): array
- {
- $lists = GroupActivityCategory::alias("a")
- ->leftJoin("property_head b","a.property_head_id=b.id")
- ->where($this->queryWhere())
- ->field('a.id,a.title,a.start_time,a.end_time,a.service_time')
- ->limit($this->limitOffset, $this->limitLength)
- ->order('a.id', 'desc')
- ->select()
- ->toArray();
- foreach($lists as &$item) {
- $item['start_time'] = date('Y-m-d', strtotime($item['start_time']));
- $item['end_time'] = date('m-d', $item['end_time']);
- $item['service_time'] = date('Y-m-d', strtotime($item['service_time']));
- }
-
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- */
- public function count(): int
- {
- return GroupActivityCategory::alias("a")
- ->leftJoin("property_head b","a.property_head_id=b.id")
- ->where($this->queryWhere())
- ->count();
- }
- }
|