| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- use think\Model;
- class XzLogModel extends Model
- {
- protected $name = 'xz_log';
- /**
- * 关联user
- * @return \think\model\relation\BelongsTo
- */
- public function user ()
- {
- return $this->belongsTo('app\common\model\UserModel', 'uid', 'id');
- }
- /**
- * 记录
- * @param $param
- * @return array
- * @throws \think\db\exception\DbException
- */
- public function getLog ($param)
- {
- $type_conf = config('type.xz');
- $list = self::where('uid', $param->uid)
- ->withAttr('type', function ($value, $data) use ($type_conf) {
- $typeStr = isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
- if (in_array($value , [5,6])){
- $uid_user = Db::name('user')->where('id', $data['uid2'])->find();
- if ($uid_user){
- $typeStr = $typeStr."(".$uid_user['mobile'].")";
- }
- }
- return $typeStr;
- })
- ->order('create_at', 'desc')
- ->paginate($param->data['limit'])
- ->toArray();
- // $history = self::where([
- // ['uid', '=', $param->uid],
- // ['state', '=', 1]
- // ])->sum('money');
- return $list['data'];
- return compact('list', 'history');
- }
- }
|