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