WalletController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. parent::__construct();
  18. $this->service = new MemberWalletService();
  19. }
  20. /**
  21. * 获取列表
  22. * @return array|mixed
  23. */
  24. public function index()
  25. {
  26. $pageSize = request()->post('pageSize', 15);
  27. $type = request()->post('type', 1);
  28. $list = MemberWalletService::make()->getOptionList($this->userId, $type, $pageSize);
  29. return message(1010, true, $list);
  30. }
  31. /**
  32. * 添加地址簿
  33. * @param WalletValidator $validate
  34. * @return array
  35. */
  36. public function add(WalletValidator $validate)
  37. {
  38. $params = $validate->check(request()->post(),'add');
  39. if(!is_array($params)){
  40. return message($params, false);
  41. }
  42. if($this->service->saveData($this->userId, $params)){
  43. return message(1002, true);
  44. }else{
  45. return message($this->service->getError(), true);
  46. }
  47. }
  48. /**
  49. * 删除
  50. * @param WalletValidator $validate
  51. * @return array
  52. */
  53. public function del(WalletValidator $validate)
  54. {
  55. $params = $validate->check(request()->post(),'info');
  56. if(!is_array($params)){
  57. return message($params, false);
  58. }
  59. if($this->service->del($params['id'], $this->userId)){
  60. return message(1002, true);
  61. }else{
  62. return message(1003, true);
  63. }
  64. }
  65. }