CardBatchController.php 3.5 KB

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