123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * CardController.php
- * User: ZhouBenxu
- * Date: 2024/6/27
- * Time: 上午9:35
- * Notes: 储值卡管理
- */
- namespace app\admin\controller\card;
- use app\admin\service\card\CardService;
- use app\admin\validate\card\CardValidate;
- use support\Request;
- use Tinywan\Jwt\JwtToken;
- class CardController
- {
- /**
- * Notes: 储值卡列表
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午10:42
- */
- public function list(Request $request)
- {
- $params = $request->get();
- $params['page'] = $params['page'] ?? 1;
- $params['pageSize'] = $params['pageSize'] ?? 20;
- $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
- // 验证器
- $validate = new CardValidate();
- if (!$validate->scene('list')->check($params)) {
- return json_fail($validate->getError());
- }
- return CardService::getList($params);
- }
- /**
- * Notes: 储值卡详情
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午10:43
- */
- public function info(Request $request)
- {
- $params = $request->get();
- // 验证器
- $validate = new CardValidate();
- if (!$validate->scene('info')->check($params)) {
- return json_fail($validate->getError());
- }
- return CardService::getInfo($params['card_id']);
- }
- /**
- * Notes: 修改储值卡信息
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午10:43
- */
- public function save(Request $request)
- {
- $params = $request->post();
- $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
- // 验证器
- $validate = new CardValidate();
- if (!$validate->scene('save')->check($params)) {
- return json_fail($validate->getError());
- }
- // 校验有效期 0 永久 1增加 2 减少
- return CardService::save($params);
- }
- /**
- * Notes: 删除储值卡信息
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午10:43
- */
- public function delete(Request $request)
- {
- // 验证器
- $validate = new CardValidate();
- if (!$validate->scene('delete')->check($request->post())) {
- return json_fail($validate->getError());
- }
- $card_ids = $request->post('card_ids');
- return CardService::delete($card_ids);
- }
- /**
- * Notes: 储值卡导出
- * User: ZhouBenXu
- * DateTime: 2024/6/28 下午2:44
- * @param Request $request
- * @return \support\Response
- */
- public function exportCard(Request $request)
- {
- return CardService::exportCard($request);
- }
- }
|