Ppintuanorder.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * 拼团订单辅助,用于判断拼团订单是归属于哪一个团长的
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. * ============================================================================
  10. *
  11. * ============================================================================
  12. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  13. * 网站地址: https://www.valimart.net/
  14. * ----------------------------------------------------------------------------
  15. *
  16. * ============================================================================
  17. * 数据层模型
  18. */
  19. class Ppintuanorder extends BaseModel {
  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. $ppintuanorder_list = Db::name('ppintuanorder')->alias('ppintuanorder')->field('ppintuanorder.*,order.buyer_id,order.buyer_name,order.order_state')
  37. ->join('order order', 'ppintuanorder.order_id=order.order_id','LEFT')
  38. ->where($condition)
  39. ->select()->toArray();
  40. if (!empty($ppintuanorder_list)) {
  41. foreach ($ppintuanorder_list as $key => $ppintuanorder) {
  42. $ppintuanorder_list[$key]['pintuanorder_state_text'] = $this->pintuanorder_state_array[$ppintuanorder['pintuanorder_state']];
  43. //参与者头像
  44. $ppintuanorder_list[$key]['pintuanorder_avatar'] = get_member_avatar_for_id($ppintuanorder['buyer_id']);
  45. $ppintuanorder_list[$key]['order_state_text'] = get_order_state($ppintuanorder);
  46. }
  47. }
  48. return $ppintuanorder_list;
  49. }
  50. /**
  51. * 获取拼团订单表列表
  52. * @access public
  53. * @author csdeshang
  54. * @param type $condition 条件
  55. * @return type
  56. */
  57. public function getPpintuanvrorderList($condition) {
  58. $ppintuanorder_list = Db::name('ppintuanorder')->alias('ppintuanorder')->field('ppintuanorder.*,vrorder.buyer_id,vrorder.buyer_name,vrorder.order_state')
  59. ->join('vrorder vrorder', 'ppintuanorder.order_id=vrorder.order_id','LEFT')
  60. ->where($condition)
  61. ->select()->toArray();
  62. if (!empty($ppintuanorder_list)) {
  63. foreach ($ppintuanorder_list as $key => $ppintuanorder) {
  64. $ppintuanorder_list[$key]['pintuanorder_state_text'] = $this->pintuanorder_state_array[$ppintuanorder['pintuanorder_state']];
  65. //参与者头像
  66. $ppintuanorder_list[$key]['pintuanorder_avatar'] = get_member_avatar_for_id($ppintuanorder['buyer_id']);
  67. $ppintuanorder_list[$key]['order_state_text'] = get_order_state($ppintuanorder);
  68. }
  69. }
  70. return $ppintuanorder_list;
  71. }
  72. /**
  73. * 获取拼团订单表列表
  74. * @access public
  75. * @author csdeshang
  76. * @param type $condition 条件
  77. * @return type
  78. */
  79. public function getOnePpintuanorder($condition) {
  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. return Db::name('ppintuanorder')->insertGetId($data);
  91. }
  92. /**
  93. * 编辑拼团订单
  94. * @access public
  95. * @author csdeshang
  96. * @param type $condition 条件
  97. * @param type $data 数据
  98. * @return type
  99. */
  100. public function editPpintuanorder($condition, $data) {
  101. return Db::name('ppintuanorder')->where($condition)->update($data);
  102. }
  103. }