first commit
This commit is contained in:
69
app/adminapi/lists/mall/MallGoodsLists.php
Normal file
69
app/adminapi/lists/mall/MallGoodsLists.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace app\adminapi\lists\mall;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\mall\MallGoods;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 积分、抽奖奖品列表
|
||||
* Class MallGoodsLists
|
||||
* @package app\adminapi\listsmall
|
||||
*/
|
||||
class MallGoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author BD
|
||||
* @date 2024/10/14 23:57
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['title', 'type', 'type2', 'is_show', 'create_time'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取积分、抽奖奖品列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2024/10/14 23:57
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$items = MallGoods::where($this->searchWhere)
|
||||
->field(['id', 'title', 'image', 'price', 'content', 'money', 'point', 'win_rate', 'num', 'type', 'type2', 'is_show', 'sort', 'langs', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['type' => 'desc','sort' => 'desc','id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($items as &$item) {
|
||||
$item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取积分、抽奖奖品数量
|
||||
* @return int
|
||||
* @author BD
|
||||
* @date 2024/10/14 23:57
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return MallGoods::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
||||
94
app/adminapi/lists/mall/MallGoodsRecordLists.php
Normal file
94
app/adminapi/lists/mall/MallGoodsRecordLists.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
namespace app\adminapi\lists\mall;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\mall\MallGoodsRecord;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 奖品记录列表
|
||||
* Class MallGoodsRecordLists
|
||||
* @package app\adminapi\listsmall
|
||||
*/
|
||||
class MallGoodsRecordLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author BD
|
||||
* @date 2024/03/19 02:29
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['mgr.sn', 'mgr.type2', 'mgr.type'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @author BD
|
||||
* @date 2024/03/19 02:29
|
||||
*/
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
// 用户编号
|
||||
if (!empty($this->params['user_info'])) {
|
||||
$where[] = ['u.sn|u.account|u.mobile', '=', $this->params['user_info']];
|
||||
}
|
||||
|
||||
// 下单时间
|
||||
if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
|
||||
$time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])];
|
||||
$where[] = ['mgr.create_time', 'between', $time];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取奖品记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2024/10/15 14:00
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'mgr.id,mgr.sn,mgr.user_id,mgr.m_goods_title,mgr.m_goods_image,mgr.price,mgr.type,mgr.type2,mgr.remark,mgr.create_time';
|
||||
$field .= ',u.account,u.sn as u_sn,u.mobile';
|
||||
return MallGoodsRecord::alias('mgr')
|
||||
->join('user u', 'u.id = mgr.user_id')
|
||||
->field($field)
|
||||
->where($this->queryWhere())
|
||||
->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['mgr.id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取奖品记录数量
|
||||
* @return int
|
||||
* @author BD
|
||||
* @date 2024/10/15 14:00
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return MallGoodsRecord::alias('mgr')
|
||||
->join('user u', 'u.id = mgr.user_id')
|
||||
->where($this->queryWhere())
|
||||
->where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user