delivery_order.model.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * 订单管理
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. // 提货订单状态
  11. define('DELIVERY_ORDER_DEFAULT', 10); // 未到站
  12. define('DELIVERY_ORDER_ARRIVE', 20); // 已到站
  13. define('DELIVERY_ORDER_PICKUP', 30); // 已提取
  14. class delivery_orderModel extends Model {
  15. private $order_state = array(
  16. DELIVERY_ORDER_DEFAULT => '未到站',
  17. DELIVERY_ORDER_ARRIVE => '已到站',
  18. DELIVERY_ORDER_PICKUP => '已提取'
  19. );
  20. public function __construct(){
  21. parent::__construct('delivery_order');
  22. }
  23. /**
  24. * 取单条订单信息
  25. * @param unknown $condition
  26. * @param string $fields
  27. */
  28. public function getDeliveryOrderInfo($condition = array(), $fields = '*') {
  29. return $this->field($fields)->where($condition)->find();
  30. }
  31. /**
  32. * 插入订单支付表信息
  33. * @param array $data
  34. * @return int 返回 insert_id
  35. */
  36. public function addDeliveryOrder($data) {
  37. return $this->insert($data);
  38. }
  39. /**
  40. * 更改信息
  41. *
  42. * @param unknown_type $data
  43. * @param unknown_type $condition
  44. */
  45. public function editDeliveryOrder($data,$condition) {
  46. return $this->where($condition)->update($data);
  47. }
  48. /**
  49. * 更改信息(包裹到达物流自提服务站)
  50. *
  51. * @param unknown_type $data
  52. * @param unknown_type $condition
  53. */
  54. public function editDeliveryOrderArrive($data, $condition) {
  55. $data['dlyo_state'] = DELIVERY_ORDER_ARRIVE;
  56. return $this->editDeliveryOrder($data, $condition);
  57. }
  58. /**
  59. * 更改信息(买家从物流自提服务张取走包裹)
  60. *
  61. * @param unknown_type $data
  62. * @param unknown_type $condition
  63. */
  64. public function editDeliveryOrderPickup($data, $condition) {
  65. $data['dlyo_state'] = DELIVERY_ORDER_PICKUP;
  66. return $this->editDeliveryOrder($data, $condition);
  67. }
  68. /**
  69. * 取订单列表信息
  70. *
  71. * @param unknown $condition
  72. * @param string $fields
  73. * @param number $page
  74. * @param string $order
  75. * @param string $limit
  76. */
  77. public function getDeliveryOrderList($condition = array(), $fields = '*', $page = 0, $order = 'order_id desc', $limit = '') {
  78. return $this->field($fields)->where($condition)->order($order)->limit($limit)->page($page)->select(array('cache'=>false));
  79. }
  80. /**
  81. * 取未到站订单列表
  82. *
  83. * @param unknown $condition
  84. * @param string $fields
  85. * @param number $page
  86. * @param string $order
  87. * @param string $limit
  88. */
  89. public function getDeliveryOrderDefaultList($condition = array(), $fields = '*', $page = 0, $order = 'order_id desc', $limit = '') {
  90. $condition['dlyo_state'] = DELIVERY_ORDER_DEFAULT;
  91. return $this->getDeliveryOrderList($condition,$fields,$page,$order,$limit);
  92. }
  93. /**
  94. * 取未到站/已到站订单列表
  95. *
  96. * @param unknown $condition
  97. * @param string $fields
  98. * @param number $page
  99. * @param string $order
  100. * @param string $limit
  101. */
  102. public function getDeliveryOrderDefaultAndArriveList($condition = array(), $fields = '*', $page = 0, $order = 'order_id desc', $limit = '') {
  103. $condition['dlyo_state'] = array('neq', DELIVERY_ORDER_PICKUP);
  104. return $this->getDeliveryOrderList($condition,$fields,$page,$order,$limit);
  105. }
  106. /**
  107. * 取订单状态
  108. * @return multitype:string
  109. */
  110. public function getDeliveryOrderState() {
  111. return $this->order_state;
  112. }
  113. /**
  114. * 删除
  115. *
  116. * @param unknown_type $condition
  117. */
  118. public function delDeliveryOrder($condition) {
  119. return $this->where($condition)->delete();
  120. }
  121. }