Ppintuanorder.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * 拼团订单辅助,用于判断拼团订单是归属于哪一个团长的
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. * ============================================================================
  10. * DSMall多用户商城
  11. * ============================================================================
  12. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  13. * 网站地址: http://www.csdeshang.com
  14. * ----------------------------------------------------------------------------
  15. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  16. * 不允许对程序代码以任何形式任何目的的再发布。
  17. * ============================================================================
  18. * 数据层模型
  19. */
  20. class Ppintuanorder extends BaseModel {
  21. const PINTUANORDER_STATE_CLOSE = 0;
  22. const PINTUANORDER_STATE_NORMAL = 1;
  23. const PINTUANORDER_STATE_SUCCESS = 2;
  24. private $pintuanorder_state_array = array(
  25. self::PINTUANORDER_STATE_CLOSE => '拼团取消',
  26. self::PINTUANORDER_STATE_NORMAL => '参团中',
  27. self::PINTUANORDER_STATE_SUCCESS => '拼团成功'
  28. );
  29. /**
  30. * 获取拼团订单表列表
  31. * @access public
  32. * @author csdeshang
  33. * @param type $condition 条件
  34. * @return type
  35. */
  36. public function getPpintuanorderList($condition) {
  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. $ppintuanorder_list = Db::name('ppintuanorder')->alias('ppintuanorder')->field('ppintuanorder.*,vrorder.buyer_id,vrorder.buyer_name,vrorder.order_state')
  60. ->join('vrorder vrorder', 'ppintuanorder.order_id=vrorder.order_id','LEFT')
  61. ->where($condition)
  62. ->select()->toArray();
  63. if (!empty($ppintuanorder_list)) {
  64. foreach ($ppintuanorder_list as $key => $ppintuanorder) {
  65. $ppintuanorder_list[$key]['pintuanorder_state_text'] = $this->pintuanorder_state_array[$ppintuanorder['pintuanorder_state']];
  66. //参与者头像
  67. $ppintuanorder_list[$key]['pintuanorder_avatar'] = get_member_avatar_for_id($ppintuanorder['buyer_id']);
  68. $ppintuanorder_list[$key]['order_state_text'] = get_order_state($ppintuanorder);
  69. }
  70. }
  71. return $ppintuanorder_list;
  72. }
  73. /**
  74. * 获取拼团订单表列表
  75. * @access public
  76. * @author csdeshang
  77. * @param type $condition 条件
  78. * @return type
  79. */
  80. public function getOnePpintuanorder($condition) {
  81. return Db::name('ppintuanorder')->where($condition)->find();
  82. }
  83. /**
  84. * 增加拼团订单
  85. * @access public
  86. * @author csdeshang
  87. * @param type $data 参数内容
  88. * @return type
  89. */
  90. public function addPpintuanorder($data) {
  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. return Db::name('ppintuanorder')->where($condition)->update($data);
  103. }
  104. }