AcceptorController.php 5.0 KB

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