| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- /**
- * 用户模型
- */
- namespace app\common\model;
- use think\Model;
- class MoneyLogModel extends Model
- {
- protected $name = "money_log";
- /**
- * 记录
- * @param $param
- * @return array
- * @throws \think\db\exception\DbException
- */
- public function getLog ($param, $type = 0)
- {
- $type_conf = config('type.money');
- $where = [];
- if ($type > 0){
- $where[] = ['type', '=', $type];
- }
- $list = self::where('uid', $param->uid)
- ->where($where)
- ->withAttr('type', function ($value, $data) use ($type_conf) {
- return isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
- })
- ->order('id', 'desc')
- ->paginate($param->data['limit'])
- ->toArray();
- return $list['data'];
- return compact('list', 'history');
- }
- /**
- * 团队奖金
- * @param $param
- * @return array
- * @throws \think\db\exception\DbException
- */
- public function getTeamMoneyLog($param){
- $type_conf = config('type.money');
- $total = self::where('uid', $param->uid)
- ->whereIn('type', [5,7])->sum('money');
- $list = self::where('uid', $param->uid)
- ->whereIn('type', [5,7])
- ->withAttr('type', function ($value, $data) use ($type_conf) {
- return isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
- })
- ->order('id', 'desc')
- ->paginate($param->data['limit'])
- ->toArray();
- return ['list'=>$list['data'],'total'=>$total,'count'=>$list['total']];
- }
- }
|