Merge remote-tracking branch 'origin/hph' into test

# Conflicts:
#	eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java
This commit is contained in:
牛叉闪闪
2024-09-02 14:43:29 +08:00
9 changed files with 124 additions and 227 deletions

View File

@@ -1,185 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.controller;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.TbUserInfo;
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
import cn.ysk.cashier.repository.TbUserInfoRepository;
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
import cn.ysk.cashier.service.TbUserInfoService;
import cn.ysk.cashier.dto.TbUserInfoQueryCriteria;
import cn.ysk.cashier.utils.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2023-11-13
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "/userInfo/list管理")
@RequestMapping("/api/tbUserInfo")
public class TbUserInfoController {
private final TbUserInfoService tbUserInfoService;
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('tbUserInfo:list')")
public void exportTbUserInfo(HttpServletResponse response, TbUserInfoQueryCriteria criteria) throws IOException {
tbUserInfoService.download(tbUserInfoService.queryAll(criteria), response);
}
@GetMapping
@ApiOperation("查询/userInfo/list")
public ResponseEntity<Object> queryTbUserInfo(TbUserInfoQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbUserInfoService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@ApiOperation("新增/userInfo/list")
public ResponseEntity<Object> createTbUserInfo(@Validated @RequestBody TbUserInfo resources){
return new ResponseEntity<>(tbUserInfoService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@ApiOperation("修改/userInfo/list")
public ResponseEntity<Object> updateTbUserInfo(@Validated @RequestBody TbUserInfo resources){
tbUserInfoService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@ApiOperation("删除/userInfo/list")
public ResponseEntity<Object> deleteTbUserInfo(@RequestBody Integer[] ids) {
tbUserInfoService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@Autowired
ValidateCodeUtil validateCodeUtil;
@Autowired
RedisUtils redisUtils;
@GetMapping("sendMsg")
public Object sendMsg(){
Object o= SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(Objects.isNull(o)){
throw new BadRequestException("用户登录信息失效");
}
JSONObject object=JSON.parseObject(JSON.toJSONString(o));
if(Objects.isNull(object)){
throw new BadRequestException("用户登录信息失效");
}
String regex="^\\d{11}$";
if(!object.containsKey("username")||Objects.isNull(object.getString("username"))||
!object.getString("username").matches(regex)
){
throw new BadRequestException("用户登录信息失效");
}
String phone=object.getString("username");
String tempcode="SMS_244665149";
String random = StringUtil.random(6);
try {
validateCodeUtil.requestValidateCodeAli(phone, random,tempcode);
redisUtils.set(phone.concat("#").concat(tempcode),random,300L);
return "{\n" +
" \"code\": 0,\n" +
" \"msg\": \"成功\"\n" +
"}";
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
@Autowired
TbMerchantAccountRepository tbMerchantAccountRepository;
@RequestMapping(value = "modfiyUserInfo",method = RequestMethod.POST)
public ResponseEntity<Object> modfiyUserInfo(@RequestBody Map<String,String> map){
Object o= SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(Objects.isNull(o)){
throw new BadRequestException("用户登录信息失效");
}
JSONObject object=JSON.parseObject(JSON.toJSONString(o));
if(Objects.isNull(object)){
throw new BadRequestException("用户登录信息失效");
}
String regex="^\\d{11}$";
if(!object.containsKey("username")||Objects.isNull(object.getString("username"))||
!object.getString("username").matches(regex)
){
throw new BadRequestException("用户登录信息失效");
}
String tempcode="SMS_244665149";
String phone=object.getString("username");
Object redisCode= redisUtils.get(phone.concat("#").concat(tempcode));
if(Objects.isNull(redisCode)){
throw new BadRequestException("短信验证码已过期");
}
String code= map.get("code");
if(!redisCode.toString().equals(code)){
throw new BadRequestException("短信验证码错误");
}
redisUtils.del(phone.concat("#").concat(tempcode));
String pwd= map.get("pwd");
TbMerchantAccount account= tbMerchantAccountRepository.findByAccount(phone);
if(Objects.isNull(account)){
throw new BadRequestException("账户不存在");
}
account.setPwd(MD5Utils.md5(pwd.concat(account.getAccount()).concat(account.getId().toString())));
account.setUpdatedAt(System.currentTimeMillis());
tbMerchantAccountRepository.save(account);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

View File

@@ -8,6 +8,7 @@ import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.service.shop.TbShopUserService;
import io.swagger.annotations.Api;
@@ -37,6 +38,9 @@ public class TbShopUserController {
private final TbShopUserService tbShopUserService;
private final TbMShopUserService tbMShopUserService;
private final TbShopUserFlowService tbShopUserFlowService;
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportTbShopUser(HttpServletResponse response, TbShopUserQueryCriteria criteria) throws IOException {
@@ -104,4 +108,10 @@ public class TbShopUserController {
tbShopUserService.modfiyAccount(map);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("queryShopUserFlow")
public ResponseEntity<Object> queryShopUserFlow(@RequestParam("userId") Integer userId,@RequestParam("page") Integer page,@RequestParam("pageSize") Integer pageSize){
return new ResponseEntity<>( tbShopUserFlowService.selectByUserId(userId, page, pageSize),HttpStatus.OK);
}
}