AcceptorController.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Http\Validator\MemberValidator;
  5. use App\Http\Validator\MerchantValidator;
  6. use App\Services\Api\AcceptorService;
  7. use App\Services\Api\MemberService;
  8. use App\Services\Api\MerchantCategoryService;
  9. use App\Services\Api\MerchantService;
  10. /**
  11. * 承兑商管理
  12. * @package App\Http\Controllers\Api
  13. */
  14. class AcceptorController extends webApp
  15. {
  16. /**
  17. * 信息
  18. * @return array
  19. */
  20. public function info()
  21. {
  22. $type = request()->post('type', 'detail');
  23. $id = request()->post('id', 0);
  24. $info = AcceptorService::make()->getInfo($this->userId, $type, $id);
  25. if($info){
  26. return showJson(1010, true, $info);
  27. }else{
  28. return showJson(2216, false, [],'404');
  29. }
  30. }
  31. /**
  32. * 商家列表
  33. * @return array
  34. */
  35. public function index()
  36. {
  37. $params = request()->post();
  38. $pageSize = request()->post('pageSize', 6);
  39. $datas = AcceptorService::make()->getDataList($params, $pageSize);
  40. return showJson(1010, true, $datas);
  41. }
  42. /**
  43. * 申请入驻
  44. * @return array
  45. */
  46. public function apply(MerchantValidator $validator)
  47. {
  48. $params = request()->all();
  49. $params = $validator->check($params, 'apply');
  50. if (!is_array($params)) {
  51. return showJson($params, false);
  52. }
  53. if(!$result = MerchantService::make()->apply($this->userId, $params)){
  54. return showJson(MerchantService::make()->getError(), false);
  55. }else{
  56. return showJson(MerchantService::make()->getError(), true, $result);
  57. }
  58. }
  59. /**
  60. * 入驻信息
  61. * @return array
  62. */
  63. public function applyInfo()
  64. {
  65. $info = MerchantService::make()->getApplyInfo($this->userId);
  66. if($info){
  67. return showJson(1010, true, $info);
  68. }else{
  69. return showJson(1009, false);
  70. }
  71. }
  72. /**
  73. * 修改账号信息
  74. * @param $userId
  75. * @param $params
  76. * @return bool
  77. */
  78. public function modify(MerchantValidator $validator)
  79. {
  80. $params = request()->all();
  81. $params = $validator->check($params, 'modify');
  82. if (!is_array($params)) {
  83. return showJson($params, false);
  84. }
  85. if(!MerchantService::make()->modify($this->userId, $params)){
  86. return showJson(MerchantService::make()->getError(),false);
  87. }else{
  88. return showJson(MerchantService::make()->getError(),true);
  89. }
  90. }
  91. /**
  92. * 修改店铺信息
  93. * @param $userId
  94. * @param $params
  95. * @return bool
  96. */
  97. public function saveInfo(MemberValidator $validator)
  98. {
  99. $params = request()->all();
  100. $params = $validator->check($params, 'info');
  101. if (!is_array($params)) {
  102. return showJson($params, false);
  103. }
  104. if(!MerchantService::make()->saveInfo($this->userId, $params)){
  105. return showJson(MerchantService::make()->getError(),false);
  106. }else{
  107. return showJson(MerchantService::make()->getError(),true);
  108. }
  109. }
  110. /**
  111. * 收藏点赞
  112. * @param MerchantValidator $validator
  113. * @return array
  114. */
  115. public function collect(MerchantValidator $validator)
  116. {
  117. $params = request()->all();
  118. $params = $validator->check($params, 'collect');
  119. if (!is_array($params)) {
  120. return showJson($params, false);
  121. }
  122. if(!$result = MerchantService::make()->collect($this->userId, $params)){
  123. return showJson(MerchantService::make()->getError(), false);
  124. }else{
  125. return showJson(MerchantService::make()->getError(), true, $result);
  126. }
  127. }
  128. /**
  129. * 缴纳保证金
  130. * @param MemberValidator $validator
  131. * @return array
  132. */
  133. public function deposit(MemberValidator $validator)
  134. {
  135. $params = request()->all();
  136. $params = $validator->check($params, 'deposit');
  137. if (!is_array($params)) {
  138. return showJson($params, false);
  139. }
  140. if(!$result = MerchantService::make()->deposit($this->userId, $params)){
  141. return showJson(MerchantService::make()->getError(),false);
  142. }else{
  143. return showJson(MerchantService::make()->getError(),true, $result);
  144. }
  145. }
  146. /**
  147. * 退还保证金
  148. * @param MemberValidator $validator
  149. * @return array
  150. */
  151. public function rebackDeposit(MemberValidator $validator)
  152. {
  153. $params = request()->all();
  154. $params = $validator->check($params, 'reback_deposit');
  155. if (!is_array($params)) {
  156. return showJson($params, false);
  157. }
  158. if(!$result = MerchantService::make()->rebackDeposit($this->userId, $params)){
  159. return showJson(MerchantService::make()->getError(),false);
  160. }else{
  161. return showJson(MerchantService::make()->getError(),true);
  162. }
  163. }
  164. }