CardController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * CardController.php
  4. * User: ZhouBenxu
  5. * Date: 2024/6/27
  6. * Time: 上午9:35
  7. * Notes: 储值卡管理
  8. */
  9. namespace app\admin\controller\card;
  10. use app\admin\service\card\CardService;
  11. use app\admin\validate\card\CardValidate;
  12. use support\Request;
  13. use Tinywan\Jwt\JwtToken;
  14. class CardController
  15. {
  16. /**
  17. * Notes: 储值卡列表
  18. * User: ZhouBenXu
  19. * DateTime: 2024/6/28 上午10:42
  20. */
  21. public function list(Request $request)
  22. {
  23. $params = $request->get();
  24. $params['page'] = $params['page'] ?? 1;
  25. $params['pageSize'] = $params['pageSize'] ?? 20;
  26. $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
  27. // 验证器
  28. $validate = new CardValidate();
  29. if (!$validate->scene('list')->check($params)) {
  30. return json_fail($validate->getError());
  31. }
  32. return CardService::getList($params);
  33. }
  34. /**
  35. * Notes: 储值卡详情
  36. * User: ZhouBenXu
  37. * DateTime: 2024/6/28 上午10:43
  38. */
  39. public function info(Request $request)
  40. {
  41. $params = $request->get();
  42. // 验证器
  43. $validate = new CardValidate();
  44. if (!$validate->scene('info')->check($params)) {
  45. return json_fail($validate->getError());
  46. }
  47. return CardService::getInfo($params['card_id']);
  48. }
  49. /**
  50. * Notes: 修改储值卡信息
  51. * User: ZhouBenXu
  52. * DateTime: 2024/6/28 上午10:43
  53. */
  54. public function save(Request $request)
  55. {
  56. $params = $request->post();
  57. $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
  58. // 验证器
  59. $params['validtimes_status'] = $params['validtimes_status'] ?? 3;
  60. $validate = new CardValidate();
  61. if (!$validate->scene('save')->check($params)) {
  62. return json_fail($validate->getError());
  63. }
  64. // 校验有效期 0 永久 1增加 2 减少 3不修改
  65. return CardService::save($params);
  66. }
  67. /**
  68. * Notes: 删除储值卡信息
  69. * User: ZhouBenXu
  70. * DateTime: 2024/6/28 上午10:43
  71. */
  72. public function delete(Request $request)
  73. {
  74. // 验证器
  75. $validate = new CardValidate();
  76. if (!$validate->scene('delete')->check($request->post())) {
  77. return json_fail($validate->getError());
  78. }
  79. $card_ids = $request->post('card_ids');
  80. return CardService::delete($card_ids);
  81. }
  82. /**
  83. * Notes: 储值卡导出
  84. * User: ZhouBenXu
  85. * DateTime: 2024/6/28 下午2:44
  86. * @param Request $request
  87. * @return \support\Response
  88. */
  89. public function exportCard(Request $request)
  90. {
  91. return CardService::exportCard($request);
  92. }
  93. /**
  94. * Notes: 卡状态下拉列表
  95. * User: ZhouBenXu
  96. * DateTime: 2024/7/1 上午9:27
  97. * @return Response
  98. */
  99. public function getStatusList()
  100. {
  101. return CardService::getStatusList();
  102. }
  103. /**
  104. * Notes: 储值卡绑定
  105. * User: ZhouBenXu
  106. * DateTime: 2024/7/2 下午6:08
  107. * @param Request $request
  108. * @return \support\Response
  109. */
  110. public function binding(Request $request)
  111. {
  112. $params = $request->post();
  113. var_dump($params);
  114. $validate = new CardValidate();
  115. if (!$validate->scene('binding')->check($params)) {
  116. return json_fail($validate->getError());
  117. }
  118. return CardService::binding($params);
  119. }
  120. }