You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.5 KiB

<?php
namespace app\integral\model;
use think\model\concern\SoftDelete;
class IntegralLog extends Base
{
use SoftDelete;
// 设置字段自动转换类型
protected $type = [
'remark' => 'serialize'
];
/**
* 类型名称以及统计
* @date 2022-11-18
*/
protected $typeText = [
1 => [
'name' => '积分商城下单减少',
'is_join_statistics' => 0
],
// 共性没有用到,预留
2 => [
'name' => '积分商城退单返还',
'is_join_statistics' => 0
],
3 => [
'name' => '商城下单赠送',
'is_join_statistics' => 1
],
4 => [
'name' => '后台增加',
'is_join_statistics' => 1
],
5 => [
'name' => '后台减少',
'is_join_statistics' => 0
],
6 => [
'name' => '兑换优惠券减少',
'is_join_statistics' => 0
],
// 共性没有用到,预留
7 => [
'name' => '转盘抽奖奖励',
'is_join_statistics' => 1
],
// 共性没有用到,预留
8 => [
'name' => '签到积分赠送',
'is_join_statistics' => 1
],
// 共性没有用到,预留
9 => [
'name' => '分享赠送',
'is_join_statistics' => 1
]
];
/**
* 获取参与到统计的佣金明细类型
* @date 2022-11-01
*/
public function getJoinStatisticsTypes()
{
// 初始类型
$types = [];
foreach ($this->typeText as $k => $v) {
if ($v['is_join_statistics']) {
$types[] = $k;
}
}
return $types;
}
/**
* 查找全部数据--带分页
* @param array $where 查询条件
* @param string $field 查询字段
* @param string $order 排序方式
* @param int $page 当前页数
* @date 2022-11-21
*/
public function listLogWithPage($where, $page, $field = '*', $order = '')
{
if (empty($order)) {
$order = 'id desc';
}
$data_list = $this->field($field)->where($where)->order($order)
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item){
$item['show_create_time'] = date("Y.m.d H:i", $item->getData('create_time'));
unset($item['create_time']);
});
return $data_list;
}
}