useraccountaddrecordmodel.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-09-27 08:39:30
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-11-05 14:22:09
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class useraccountaddrecordmodel extends Model
  11. {
  12. protected $table = 't_useraccountaddrecord';
  13. public function insertData($data)
  14. {
  15. $id = $this->insertGetId($data);
  16. return empty($id) ? false : $id;
  17. }
  18. public function getInfo($where, $field = "*", $row = true)
  19. {
  20. $info = $this->field($field)->where($where);
  21. if ($row) {
  22. $info = $info->find();
  23. } else {
  24. $info = $info->select();
  25. }
  26. return empty($info) ? false : $info;
  27. }
  28. public function updateinfo($where, $updateData)
  29. {
  30. $row = $this->where($where)->update($updateData);
  31. return empty($row) ? false : $row;
  32. }
  33. public function deleteinfo($where)
  34. {
  35. $row = $this->where($where)->delete();
  36. return empty($row) ? false : $row;
  37. }
  38. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  39. {
  40. $sqlObj = $this->where($where);
  41. if ("count" != $field) {
  42. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  43. if ($row) {
  44. $data = $sqlObj->find();
  45. } else {
  46. $data = $sqlObj->select();
  47. }
  48. } else {
  49. $data = $sqlObj = $sqlObj->count();
  50. }
  51. return $data;
  52. }
  53. public function getaddrecordlistforreduce($userid, $enddate, $scoretype = 0)
  54. {
  55. $tablesql = "select * from t_useraccountaddrecord where userid='" . $userid . "' and activescore>0 and (enddate is null or enddate <= '" . $enddate . "')";
  56. if ($scoretype > 0) {
  57. $tablesql .= " scoretype='" . $scoretype . "'";
  58. }
  59. $tablesql .= " order by scoretype desc,id asc";
  60. $sql = "select * from (" . $tablesql . ") as tab";
  61. $list = $this->query($sql);
  62. return $list;
  63. }
  64. /*
  65. * 2022-01-03
  66. * steelxu
  67. * 获取指定用户某一天被赠送的积分
  68. */
  69. public function seladdlistbyuid2date($uid,$date){
  70. $strsql="select * from t_useraccountaddrecord where scoretype=2 and userid=".$uid." and createdate >'".$date."' ";
  71. $list=$this->query($strsql);
  72. $list=collection($list)->toArray();
  73. return $list;
  74. }
  75. }