MoneyLogModel.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * 用户模型
  4. */
  5. namespace app\common\model;
  6. use think\Model;
  7. class MoneyLogModel extends Model
  8. {
  9. protected $name = "money_log";
  10. /**
  11. * 记录
  12. * @param $param
  13. * @return array
  14. * @throws \think\db\exception\DbException
  15. */
  16. public function getLog ($param, $type = 0)
  17. {
  18. $type_conf = config('type.money');
  19. $where = [];
  20. if ($type > 0){
  21. $where[] = ['type', '=', $type];
  22. }
  23. $list = self::where('uid', $param->uid)
  24. ->where($where)
  25. ->withAttr('type', function ($value, $data) use ($type_conf) {
  26. return isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
  27. })
  28. ->order('id', 'desc')
  29. ->paginate($param->data['limit'])
  30. ->toArray();
  31. return $list['data'];
  32. return compact('list', 'history');
  33. }
  34. public function getTeamMoneyLog($param){
  35. $type_conf = config('type.money');
  36. $list = self::where('uid', $param->uid)
  37. ->whereIn('type', [5,7])
  38. ->withAttr('type', function ($value, $data) use ($type_conf) {
  39. return isset($type_conf[$value]) ? $type_conf[$value] : '未知类型';
  40. })
  41. ->order('id', 'desc')
  42. ->paginate($param->data['limit'])
  43. ->toArray();
  44. // $history = self::where([
  45. // ['uid', '=', $param->uid],
  46. // ['state', '=', 1]
  47. // ])->sum('money');
  48. return $list['data'];
  49. }
  50. }