AcceptorController.php 5.0 KB

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