Supplier.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\shop\controller\supplier;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\supplier\Supplier as SupplierModel;
  5. use app\shop\model\supplier\Apply as ApplyModel;
  6. use app\shop\model\supplier\Category as CategoryModel;
  7. use app\shop\model\supplier\DepositRefund as DepositRefundModel;
  8. use app\shop\model\supplier\ServiceApply as ServiceApplyModel;
  9. /**
  10. * 供应商控制器
  11. */
  12. class Supplier extends Controller
  13. {
  14. /**
  15. * 店员列表
  16. */
  17. public function index()
  18. {
  19. // 供应商列表
  20. $model = new SupplierModel;
  21. $list = $model->getList($this->postData());
  22. return $this->renderSuccess('', compact('list'));
  23. }
  24. /**
  25. * 添加供应商
  26. */
  27. public function add()
  28. {
  29. $model = new SupplierModel;
  30. $category = CategoryModel::getALL();
  31. if($this->request->isGet()){
  32. return $this->renderSuccess('', compact('category'));
  33. }
  34. // 新增记录
  35. if ($model->add($this->postData())) {
  36. return $this->renderSuccess('', '添加成功');
  37. }
  38. return $this->renderError($model->getError() ?: '添加失败');
  39. }
  40. /**
  41. * 编辑供应商
  42. */
  43. public function edit($shop_supplier_id)
  44. {
  45. $model = SupplierModel::detail($shop_supplier_id, ['logo', 'business', 'superUser.user']);
  46. $category = CategoryModel::getALL();
  47. if($this->request->isGet()){
  48. return $this->renderSuccess('', compact('model','category'));
  49. }
  50. if ($model->edit($this->postData())) {
  51. return $this->renderSuccess('', '更新成功');
  52. }
  53. return $this->renderError($model->getError() ?: '更新失败');
  54. }
  55. /**
  56. * 删除店员
  57. */
  58. public function delete($shop_supplier_id)
  59. {
  60. // 店员详情
  61. $model = SupplierModel::detail($shop_supplier_id);
  62. if (!$model->setDelete()) {
  63. return $this->renderError('删除失败');
  64. }
  65. return $this->renderSuccess('', $model->getError() ?: '删除成功');
  66. }
  67. /**
  68. * 供应商待审核
  69. */
  70. public function apply()
  71. {
  72. // 供应商列表
  73. $model = new ApplyModel;
  74. $list = $model->getList($this->postData());
  75. return $this->renderSuccess('', compact('list'));
  76. }
  77. /**
  78. * 供应商待审核详情
  79. */
  80. public function audit($supplier_apply_id){
  81. $model = ApplyModel::detail($supplier_apply_id, ['businessImage','user','category']);
  82. if($this->request->isGet()){
  83. return $this->renderSuccess('', compact('model'));
  84. }
  85. if ($model->audit($this->postData())) {
  86. return $this->renderSuccess('', '操作成功');
  87. }
  88. return $this->renderError($model->getError() ?: '操作失败', []);
  89. }
  90. /**
  91. * 退押金列表
  92. */
  93. public function refund()
  94. {
  95. $model = new DepositRefundModel;
  96. $list = $model->getList($this->postData());
  97. return $this->renderSuccess('', compact('list'));
  98. }
  99. /**
  100. * 退押金审核
  101. */
  102. public function submit($deposit_refund_id)
  103. {
  104. $model = DepositRefundModel::detail($deposit_refund_id);
  105. if ($model->submit($this->postData())) {
  106. return $this->renderSuccess('操作成功');
  107. }
  108. return $this->renderError($model->getError() ?: '操作失败');
  109. }
  110. /**
  111. * 服务保障申请列表
  112. */
  113. public function security()
  114. {
  115. $model = new ServiceApplyModel;
  116. $list = $model->getList($this->postData());
  117. return $this->renderSuccess('', compact('list'));
  118. }
  119. /**
  120. * 服务保障审核
  121. */
  122. public function verify($service_apply_id)
  123. {
  124. $model = ServiceApplyModel::getdetail($service_apply_id);
  125. if ($model->verify($this->postData())) {
  126. return $this->renderSuccess('操作成功');
  127. }
  128. return $this->renderError($model->getError() ?: '操作失败');
  129. }
  130. /**
  131. * 开启禁止
  132. */
  133. public function recycle($shop_supplier_id, $is_recycle)
  134. {
  135. // 商品详情
  136. $model = SupplierModel::detail($shop_supplier_id);
  137. if (!$model->setRecycle($is_recycle)) {
  138. return $this->renderError('操作失败');
  139. }
  140. return $this->renderSuccess('操作成功');
  141. }
  142. }