payordermodel.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sicilon_IT
  5. * Date: 2021/6/25
  6. * Time: 15:27
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class payordermodel extends Model
  11. {
  12. protected $table = 't_payorder';
  13. /*
  14. * 20210625
  15. */
  16. public function insinfo($arr)
  17. {
  18. $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
  19. return $this->id;
  20. }
  21. /*
  22. * 20210625
  23. */
  24. public function updpaytimebypreid($preid)
  25. {
  26. $where_arr['prepay_id'] = $preid;
  27. $where_arr['orderstatus'] = 0;
  28. $update_arr['ispay'] = 1;
  29. $update_arr['orderstatus'] = 1;
  30. $update_arr['paytime'] = date('Y-m-d H:i:s');
  31. $this->where($where_arr)->update($update_arr);
  32. }
  33. /*
  34. * 20210627
  35. */
  36. public function updorederstatusbyorderno($orderno, $openid, $updarr)
  37. {
  38. $where_arr['outorderno'] = $orderno;
  39. $where_arr['openid'] = $openid;
  40. $where_arr['orderstatus'] = 0;
  41. $rcount = $this->where($where_arr)->update($updarr);
  42. return $rcount;
  43. }
  44. /*
  45. * 20210814
  46. */
  47. public function selinfobyorder($orderno)
  48. {
  49. $where_arr['outorderno'] = $orderno;
  50. $rec = $this->where($where_arr)->find();
  51. return $rec;
  52. }
  53. /**
  54. * 根据订单id改订单信息
  55. * 20211108
  56. * wj
  57. */
  58. public function updorederstatusbyid($id, $updarr)
  59. {
  60. $where_arr['id'] = $id;
  61. $where_arr['orderstatus'] = 0;
  62. $rcount = $this->where($where_arr)->update($updarr);
  63. return $rcount;
  64. }
  65. /**
  66. * 获取订单总量
  67. * 202112228
  68. * wj
  69. */
  70. public function getcount()
  71. {
  72. $count = $this->where([])->count();
  73. return $count;
  74. }
  75. /**
  76. * 获取分析数据
  77. * 20211117
  78. * wj
  79. */
  80. public function statistics()
  81. {
  82. $sql = "select ispay,count(*) as count from " . $this->table . " group by ispay";
  83. $list = $this->query("select * from (" . $sql . ") as t");
  84. return $list;
  85. }
  86. /*
  87. * 20211228
  88. * wj
  89. */
  90. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  91. {
  92. $sqlObj = $this->alias('po')->join("t_userinfo u", "po.wid=u.id")->where($where);
  93. if ("count" != $field) {
  94. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  95. if ($row) {
  96. $data = $sqlObj->find();
  97. } else {
  98. $data = $sqlObj->select();
  99. }
  100. } else {
  101. $data = $sqlObj = $sqlObj->count();
  102. }
  103. return $data;
  104. }
  105. }