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.
bjhedasx/app/distribution/model/DistributionCommissionLog.php

107 lines
2.5 KiB

<?php
namespace app\distribution\model;
use think\model\concern\SoftDelete;
class DistributionCommissionLog extends Base
{
use SoftDelete;
/**
* 设置字段自动转换类型
* @date 2022-08-19
*/
protected $type = [
'remark' => 'serialize'
];
/**
* 类型名称以及统计
* @date 2022-08-19
*/
protected $typeText = [
1 => [
'name' => '充值获得',
'is_join_statistics' => 1
],
2 => [
'name' => '商城购物获得',
'is_join_statistics' => 1
],
3 => [
'name' => '积分商城购物获得',
'is_join_statistics' => 1
],
// 共性没有用到,预留
4 => [
'name' => '转出',
'is_join_statistics' => 0
],
5 => [
'name' => '系统增加',
'is_join_statistics' => 1
],
6 => [
'name' => '系统减少',
'is_join_statistics' => 0
],
7 => [
'name' => '提现',
'is_join_statistics' => 0
],
8 => [
'name' => '提现失败返还',
'is_join_statistics' => 0
]
];
/**
* 获取类型名称
* @date 2022-08-19
*/
public function getTypeTextAttr($value, $data)
{
return $this->typeText[$data['type']];
}
/**
* 获取参与到统计的佣金明细类型
* @date 2022-08-19
*/
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-08
*/
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;
}
}