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