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'); } }