初始化项目
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\store\model\card;
|
||||
|
||||
use app\common\model\card\CardLog as CardLogModel;
|
||||
|
||||
/**
|
||||
* 兑换明细模型
|
||||
* Class CardLog
|
||||
* @package app\store\model\card
|
||||
*/
|
||||
class CardLog extends CardLogModel
|
||||
{
|
||||
/**
|
||||
* 获取余额变动明细列表
|
||||
* @param array $param
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList(array $param = [])
|
||||
{
|
||||
// 设置查询条件
|
||||
$filter = $this->getFilter($param);
|
||||
// 获取列表数据
|
||||
return $this->alias('log')
|
||||
->field('log.*')
|
||||
->where($filter)
|
||||
->join('user', 'user.user_id = log.user_id')
|
||||
->join('card', 'card.card_id = log.card_id')
|
||||
->order(['log.create_time' => 'desc'])
|
||||
->paginate(15);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置查询条件
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
private function getFilter(array $param): array
|
||||
{
|
||||
// 设置默认的检索数据
|
||||
$params = $this->setQueryDefaultValue($param, [
|
||||
'user_id' => 0, // 用户ID
|
||||
'search' => '', // 用户昵称
|
||||
'card_number' => '', // 卡号
|
||||
'betweenTime' => [] // 起止时间
|
||||
]);
|
||||
// 检索查询条件
|
||||
$filter = [];
|
||||
// 用户ID
|
||||
$params['user_id'] > 0 && $filter[] = ['log.user_id', '=', $params['user_id']];
|
||||
// 用户昵称
|
||||
!empty($params['search']) && $filter[] = ['user.nick_name', 'like', "%{$params['search']}%"];
|
||||
// 用户昵称
|
||||
!empty($params['card_number']) && $filter[] = ['card.card_number', 'like', "%{$params['card_number']}%"];
|
||||
// 起止时间
|
||||
if (!empty($params['betweenTime'])) {
|
||||
$times = between_time($params['betweenTime']);
|
||||
$filter[] = ['log.create_time', '>=', $times['start_time']];
|
||||
$filter[] = ['log.create_time', '<', $times['end_time'] + 86400];
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\store\model\card;
|
||||
|
||||
use app\common\model\card\CardPrint as CardPrintModel;
|
||||
|
||||
/**
|
||||
* 兑换卡打印记录模型
|
||||
* Class CardPrint
|
||||
* @package app\store\model\card
|
||||
*/
|
||||
class CardPrint extends CardPrintModel
|
||||
{
|
||||
/**
|
||||
* 获取兑换卡打印记录列表
|
||||
* @param array $param
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public function getList(array $param = [])
|
||||
{
|
||||
// 设置查询条件
|
||||
$filter = $this->getFilter($param);
|
||||
// 获取列表数据
|
||||
$list = $this->alias('print')
|
||||
->field('print.*')
|
||||
->where($filter)
|
||||
->order(['print.create_time' => 'desc'])
|
||||
->paginate(15);
|
||||
// 生成下载url
|
||||
foreach ($list as &$item) {
|
||||
$item['download_url'] = base_url() . $item['file_path'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置查询条件
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
private function getFilter(array $param): array
|
||||
{
|
||||
// 设置默认的检索数据
|
||||
$params = $this->setQueryDefaultValue($param, [
|
||||
'batch' => '', // 批号
|
||||
'betweenTime' => [] // 起止时间
|
||||
]);
|
||||
// 检索查询条件
|
||||
$filter = [];
|
||||
// 起止时间
|
||||
if (!empty($params['betweenTime'])) {
|
||||
$times = between_time($params['betweenTime']);
|
||||
$filter[] = ['print.create_time', '>=', $times['start_time']];
|
||||
$filter[] = ['print.create_time', '<', $times['end_time'] + 86400];
|
||||
}
|
||||
!empty($params['batch']) && $filter[] = ['batch', 'like', '%' . trim($params['batch']) . '%'];
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换下载状态
|
||||
* @param $is_download
|
||||
* @return false|int
|
||||
*/
|
||||
public function changeStatus($is_download)
|
||||
{
|
||||
return $this->save(['is_download' => $is_download, 'download_time' => time()]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user