| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Http\Validator\AcceptorValidator;
- use App\Http\Validator\MemberValidator;
- use App\Http\Validator\MerchantValidator;
- use App\Services\Api\AcceptorService;
- use App\Services\Api\MemberService;
- use App\Services\Api\MerchantService;
- /**
- * 承兑商管理
- * @package App\Http\Controllers\Api
- */
- class AcceptorController extends webApp
- {
- /**
- * 信息
- * @return array
- */
- public function info()
- {
- $id = request()->post('id', 0);
- $userId = request()->post('user_id', 0);
- $info = AcceptorService::make()->getInfo($id,'', $userId?$userId:$this->userId);
- if($info){
- return showJson(1010, true, $info);
- }else{
- return showJson(2216, false, [],'404');
- }
- }
- /**
- * 商家列表
- * @return array
- */
- public function index()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 6);
- $params['user_id'] = $this->userId;
- $datas = AcceptorService::make()->getDataList($params, $pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 申请入驻
- * @return array
- */
- public function apply(AcceptorValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'apply');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!$result = AcceptorService::make()->apply($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error, false,'',$error==3011?'405':-1);
- }else{
- return showJson(AcceptorService::make()->getError(), true, $result);
- }
- }
- /**
- * 入驻信息
- * @return array
- */
- public function applyInfo()
- {
- $info = AcceptorService::make()->getApplyInfo($this->userId);
- if($info){
- return showJson(1010, true, $info);
- }else{
- return showJson(1009, false);
- }
- }
- /**
- * 修改账号信息
- * @param $userId
- * @param $params
- * @return bool
- */
- public function modify(MerchantValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'modify');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!MerchantService::make()->modify($this->userId, $params)){
- return showJson(MerchantService::make()->getError(),false);
- }else{
- return showJson(MerchantService::make()->getError(),true);
- }
- }
- /**
- * 修改店铺信息
- * @param $userId
- * @param $params
- * @return bool
- */
- public function saveInfo(MemberValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'info');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!MerchantService::make()->saveInfo($this->userId, $params)){
- return showJson(MerchantService::make()->getError(),false);
- }else{
- return showJson(MerchantService::make()->getError(),true);
- }
- }
- /**
- * 收藏点赞
- * @param MerchantValidator $validator
- * @return array
- */
- public function collect(MerchantValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'collect');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!$result = MerchantService::make()->collect($this->userId, $params)){
- return showJson(MerchantService::make()->getError(), false);
- }else{
- return showJson(MerchantService::make()->getError(), true, $result);
- }
- }
- /**
- * 充值交易额度
- * @param AcceptorValidator $validator
- * @return array
- */
- public function recharge(AcceptorValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'recharge');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!$result = AcceptorService::make()->recharge($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error,false,'',($error==2035?405:-1));
- }else{
- return showJson(AcceptorService::make()->getError(),true, $result);
- }
- }
- /**
- * 提现
- * @param MemberValidator $validator
- * @return array
- */
- public function withdraw(MemberValidator $validator)
- {
- $params = request()->all();
- $scene = isset($params['scene'])? $params['scene'] : 'withdraw';
- $params = $validator->check($params, $scene);
- if (!is_array($params)) {
- return showJson($params, false);
- }
- $params['user_type'] = 3;
- if(!$result = AcceptorService::make()->withdraw($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error,false,'',$error==2035?405:-1);
- }else{
- return showJson(AcceptorService::make()->getError(),true, $result);
- }
- }
- /**
- * C2C交易-购买星豆
- * @param MemberValidator $validator
- * @return array
- */
- public function buyxd(MemberValidator $validator)
- {
- $params = request()->all();
- $scene = isset($params['scene'])? $params['scene'] : 'recharge';
- $params = $validator->check($params, $scene);
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!$result = AcceptorService::make()->buyxd($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error,false, [],$error== 2035? 405:-1);
- }else{
- return showJson(AcceptorService::make()->getError(),true, $result);
- }
- }
- /**
- * C2C交易-购买星豆
- * @param MemberValidator $validator
- * @return array
- */
- public function sellxd(MemberValidator $validator)
- {
- $params = request()->all();
- $scene = isset($params['scene'])? $params['scene'] : 'recharge';
- $params = $validator->check($params, $scene);
- if (!is_array($params)) {
- return showJson($params, false);
- }
- if(!$result = AcceptorService::make()->sellxd($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error,false, [],$error== 2035? 405:0);
- }else{
- return showJson(AcceptorService::make()->getError(),true, $result);
- }
- }
- /**
- * 取消
- * @return array
- */
- public function cancel()
- {
- $params = request()->post();
- if(!$result = AcceptorService::make()->cancel($this->userId, $params)){
- $error = AcceptorService::make()->getError();
- return showJson($error,false, [],$error== 2035? 405:0);
- }else{
- return showJson(AcceptorService::make()->getError(),true, $result);
- }
- }
- }
|