MedalLogModel.php 920 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use app\common\model\TimeModel;
  4. use think\Model;
  5. class MedalLogModel extends Model
  6. {
  7. protected $name = "medal_log";
  8. /**
  9. * 记录
  10. * @param $param
  11. * @return array
  12. * @throws \think\db\exception\DbException
  13. */
  14. public function getLog ($param)
  15. {
  16. $type_conf = config('type.medal');
  17. $list = self::where('uid', $param->uid)
  18. ->withAttr('type', function ($value, $data) use ($type_conf) {
  19. return isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
  20. })
  21. ->order('create_at', 'desc')
  22. ->paginate($param->data['limit'])
  23. ->toArray();
  24. // $history = self::where([
  25. // ['uid', '=', $param->uid],
  26. // ['state', '=', 1]
  27. // ])->sum('money');
  28. return $list['data'];
  29. return compact('list', 'history');
  30. }
  31. }