Ppintuanorder.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 Ppintuanorder extends BaseModel
  16. {
  17. const PINTUANORDER_STATE_CLOSE = 0;
  18. const PINTUANORDER_STATE_NORMAL = 1;
  19. const PINTUANORDER_STATE_SUCCESS = 2;
  20. private $pintuanorder_state_array = array(
  21. self::PINTUANORDER_STATE_CLOSE => '拼团取消',
  22. self::PINTUANORDER_STATE_NORMAL => '参团中',
  23. self::PINTUANORDER_STATE_SUCCESS => '拼团成功'
  24. );
  25. /**
  26. * 获取拼团订单表列表
  27. * @access public
  28. * @author csdeshang
  29. * @param type $condition 条件
  30. * @return type
  31. */
  32. public function getPpintuanorderList($condition)
  33. {
  34. $ppintuanorder_list = Db::name('ppintuanorder')->alias('ppintuanorder')->field('ppintuanorder.*,order.buyer_id,order.buyer_name,order.order_state')
  35. ->join('order order', 'ppintuanorder.order_id=order.order_id', 'LEFT')
  36. ->where($condition)
  37. ->select()->toArray();
  38. if (!empty($ppintuanorder_list)) {
  39. foreach ($ppintuanorder_list as $key => $ppintuanorder) {
  40. $ppintuanorder_list[$key]['pintuanorder_state_text'] = $this->pintuanorder_state_array[$ppintuanorder['pintuanorder_state']];
  41. //参与者头像
  42. $ppintuanorder_list[$key]['pintuanorder_avatar'] = get_member_avatar_for_id($ppintuanorder['buyer_id']);
  43. $ppintuanorder_list[$key]['order_state_text'] = get_order_state($ppintuanorder);
  44. }
  45. }
  46. return $ppintuanorder_list;
  47. }
  48. /**
  49. * 获取拼团订单表列表
  50. * @access public
  51. * @author csdeshang
  52. * @param type $condition 条件
  53. * @return type
  54. */
  55. public function getPpintuanvrorderList($condition)
  56. {
  57. $ppintuanorder_list = Db::name('ppintuanorder')->alias('ppintuanorder')->field('ppintuanorder.*,vrorder.buyer_id,vrorder.buyer_name,vrorder.order_state')
  58. ->join('vrorder vrorder', 'ppintuanorder.order_id=vrorder.order_id', 'LEFT')
  59. ->where($condition)
  60. ->select()->toArray();
  61. if (!empty($ppintuanorder_list)) {
  62. foreach ($ppintuanorder_list as $key => $ppintuanorder) {
  63. $ppintuanorder_list[$key]['pintuanorder_state_text'] = $this->pintuanorder_state_array[$ppintuanorder['pintuanorder_state']];
  64. //参与者头像
  65. $ppintuanorder_list[$key]['pintuanorder_avatar'] = get_member_avatar_for_id($ppintuanorder['buyer_id']);
  66. $ppintuanorder_list[$key]['order_state_text'] = get_order_state($ppintuanorder);
  67. }
  68. }
  69. return $ppintuanorder_list;
  70. }
  71. /**
  72. * 获取拼团订单表列表
  73. * @access public
  74. * @author csdeshang
  75. * @param type $condition 条件
  76. * @return type
  77. */
  78. public function getOnePpintuanorder($condition)
  79. {
  80. return Db::name('ppintuanorder')->where($condition)->find();
  81. }
  82. /**
  83. * 增加拼团订单
  84. * @access public
  85. * @author csdeshang
  86. * @param type $data 参数内容
  87. * @return type
  88. */
  89. public function addPpintuanorder($data)
  90. {
  91. return Db::name('ppintuanorder')->insertGetId($data);
  92. }
  93. /**
  94. * 编辑拼团订单
  95. * @access public
  96. * @author csdeshang
  97. * @param type $condition 条件
  98. * @param type $data 数据
  99. * @return type
  100. */
  101. public function editPpintuanorder($condition, $data)
  102. {
  103. return Db::name('ppintuanorder')->where($condition)->update($data);
  104. }
  105. }