scorebusinessmodel.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-10-29 16:06:41
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-12-31 17:46:42
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class scorebusinessmodel extends Model
  11. {
  12. protected $table = 't_scorebusiness';
  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 getinfobyweight($where)
  54. {
  55. $sql = "select * from " . $this->table . " where typeid='" . $where['typeid'] . "' and type='" . $where['type'] . "' and isactive=1 and
  56. (
  57. (starttime<='" . $where['time'] . "' and endtime>='" . $where['time'] . "') or
  58. (starttime is null or endtime is null)
  59. )
  60. order by weight desc limit 0,1";
  61. $data = $this->query("select * from (" . $sql . ") as t");
  62. return empty($data) ? false : $data[0];
  63. }
  64. }