ExpressDeliver.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\express;
  11. use app\model\BaseModel;
  12. /**
  13. * 配送员信息
  14. */
  15. class ExpressDeliver extends BaseModel
  16. {
  17. /**
  18. * 获取配送员分页列表
  19. * @param $condition
  20. * @param $field
  21. * @param $order
  22. * @param $page
  23. * @param $page_size
  24. * @return array
  25. */
  26. public function getDeliverPageLists($condition, $field, $order, $page, $page_size)
  27. {
  28. $list = model('express_deliver')->pageList($condition, $field, $order, $page, $page_size);
  29. return $this->success($list);
  30. }
  31. /**
  32. * 获取配送员列表
  33. * @param $condition
  34. * @param string $field
  35. */
  36. public function getDeliverLists($condition, $field = '*')
  37. {
  38. $list = model('express_deliver')->getList($condition, $field);
  39. return $this->success($list);
  40. }
  41. /**
  42. * 添加配送员
  43. * @param $data
  44. * @param string
  45. */
  46. public function addDeliver($data)
  47. {
  48. if (empty($data[ 'deliver_name' ])) {
  49. return $this->error('', '配送员姓名不能为空!');
  50. }
  51. if (empty($data[ 'deliver_mobile' ])) {
  52. return $this->error('', '配送员手机号不能为空!');
  53. }
  54. $data[ 'create_time' ] = time();
  55. $result = model('express_deliver')->add($data);
  56. return $this->success($result);
  57. }
  58. /**
  59. * 编辑配送员
  60. * @param $data
  61. * @param string
  62. */
  63. public function editDeliver($data, $deliver_id)
  64. {
  65. if (empty($data[ 'deliver_name' ])) {
  66. return $this->error('', '配送员姓名不能为空!');
  67. }
  68. if (empty($data[ 'deliver_mobile' ])) {
  69. return $this->error('', '配送员手机号不能为空!');
  70. }
  71. $data[ 'modify_time' ] = time();
  72. $condition = [
  73. [ 'deliver_id', '=', $deliver_id ],
  74. [ 'site_id', '=', $data[ 'site_id' ] ]
  75. ];
  76. if(isset($data['store_id'])){
  77. $condition[] = ['store_id', '=', $data['store_id']];
  78. }
  79. $result = model('express_deliver')->update($data, $condition);
  80. return $this->success($result);
  81. }
  82. /**
  83. * 删除配送员
  84. * @param $data
  85. * @param string
  86. */
  87. public function deleteDeliver($deliver_id, $site_id, $store_id = 0)
  88. {
  89. $condition = [
  90. [ 'deliver_id', 'in', $deliver_id ],
  91. [ 'site_id', '=', $site_id ]
  92. ];
  93. if($store_id > 0){
  94. $condition[] = ['store_id', '=', $store_id];
  95. }
  96. $result = model('express_deliver')->delete($condition);
  97. return $this->success($result);
  98. }
  99. /**
  100. * 配送员信息
  101. * @param $data
  102. * @param string
  103. */
  104. public function getDeliverInfo($deliver_id, $site_id, $store_id = 0)
  105. {
  106. $condition = [
  107. [ 'deliver_id', '=', $deliver_id ],
  108. [ 'site_id', '=', $site_id ]
  109. ];
  110. if($store_id > 0){
  111. $condition[] = ['store_id', '=', $store_id];
  112. }
  113. $info = model('express_deliver')->getInfo($condition, 'deliver_name,deliver_mobile,create_time,modify_time,deliver_id');
  114. return $this->success($info);
  115. }
  116. }