WalletController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Validator\CoinValidator;
  4. use App\Http\Validator\WalletValidator;
  5. use App\Services\Api\AdvertService;
  6. use App\Services\Api\MemberWalletService;
  7. use App\Services\Common\CoinLogService;
  8. /**
  9. * 用户地址簿
  10. * Class WalletController
  11. * @package App\Http\Controllers\Api
  12. */
  13. class WalletController extends webApp
  14. {
  15. public function __construct()
  16. {
  17. $this->service = new MemberWalletService();
  18. }
  19. /**
  20. * 获取列表
  21. * @return array|mixed
  22. */
  23. public function index()
  24. {
  25. $pageSize = request()->post('pageSize', 15);
  26. $type = request()->post('type', 1);
  27. $list = MemberWalletService::make()->getOptionList($this->userId, $type, $pageSize);
  28. return message(1010, true, $list);
  29. }
  30. /**
  31. * 添加地址簿
  32. * @param WalletValidator $validate
  33. * @return array
  34. */
  35. public function add(WalletValidator $validate)
  36. {
  37. $params = $validate->check(request()->post(),'add');
  38. if(!is_array($params)){
  39. return message($params, false);
  40. }
  41. if($this->service->saveData($this->userId, $params)){
  42. return message(1002, true);
  43. }else{
  44. return message($this->service->getError(), true);
  45. }
  46. }
  47. /**
  48. * 删除
  49. * @param WalletValidator $validate
  50. * @return array
  51. */
  52. public function del(WalletValidator $validate)
  53. {
  54. $params = $validate->check(request()->post(),'info');
  55. if(!is_array($params)){
  56. return message($params, false);
  57. }
  58. if($this->service->del($params['id'], $this->userId)){
  59. return message(1002, true);
  60. }else{
  61. return message(1003, true);
  62. }
  63. }
  64. }