Pbargainorder.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * 砍价订单辅助,用于判断砍价订单是归属于哪一个团长的
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 数据层模型
  14. */
  15. class Pbargainorder extends BaseModel
  16. {
  17. public $page_info;
  18. public $lock = false;
  19. const PINTUANORDER_STATE_CLOSE = 0;
  20. const PINTUANORDER_STATE_NORMAL = 1;
  21. const PINTUANORDER_STATE_SUCCESS = 2;
  22. const PINTUANORDER_STATE_FAIL = 3;
  23. private $bargainorder_state_array = array(
  24. self::PINTUANORDER_STATE_CLOSE => '砍价取消',
  25. self::PINTUANORDER_STATE_NORMAL => '砍价中',
  26. self::PINTUANORDER_STATE_SUCCESS => '砍价成功',
  27. self::PINTUANORDER_STATE_FAIL => '砍价失败'
  28. );
  29. /**
  30. * 获取砍价订单表列表
  31. * @access public
  32. * @author csdeshang
  33. * @param type $condition 条件
  34. * @return type
  35. */
  36. public function getPbargainorderList($condition, $pagesize = '')
  37. {
  38. $res = Db::name('pbargainorder')->where($condition)->order('bargainorder_id desc');
  39. if ($this->lock) {
  40. $res = $res->lock(true);
  41. }
  42. if ($pagesize) {
  43. $res = $res->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  44. $pbargainorder_list = $res->items();
  45. $this->page_info = $res;
  46. } else {
  47. $pbargainorder_list = $res->select()->toArray();
  48. }
  49. return $pbargainorder_list;
  50. }
  51. /**
  52. * 获取砍价订单表列表
  53. * @access public
  54. * @author csdeshang
  55. * @param type $condition 条件
  56. * @return type
  57. */
  58. public function getOnePbargainorder($condition, $lock = false)
  59. {
  60. return Db::name('pbargainorder')->where($condition)->lock($lock)->find();
  61. }
  62. /**
  63. * 获取砍价订单表数量
  64. * @access public
  65. * @author csdeshang
  66. * @param type $condition 条件
  67. * @return type
  68. */
  69. public function getPbargainorderCount($condition)
  70. {
  71. return Db::name('pbargainorder')->where($condition)->count();
  72. }
  73. /**
  74. * 增加砍价订单
  75. * @access public
  76. * @author csdeshang
  77. * @param type $data 参数内容
  78. * @return type
  79. */
  80. public function addPbargainorder($data)
  81. {
  82. return Db::name('pbargainorder')->insertGetId($data);
  83. }
  84. /**
  85. * 编辑砍价订单
  86. * @access public
  87. * @author csdeshang
  88. * @param type $condition 条件
  89. * @param type $data 数据
  90. * @return type
  91. */
  92. public function editPbargainorder($condition, $data)
  93. {
  94. return Db::name('pbargainorder')->where($condition)->update($data);
  95. }
  96. /**
  97. * 砍价状态数组
  98. * @access public
  99. * @author csdeshang
  100. * @return type
  101. */
  102. public function getBargainorderStateArray()
  103. {
  104. return $this->bargainorder_state_array;
  105. }
  106. }