Merge branch 'refs/heads/master' into 支付优化测试

# Conflicts:
#	yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/storeorder/StoreOrderServiceImpl.java
This commit is contained in:
seesaw
2024-10-23 09:54:23 +08:00
4 changed files with 30 additions and 11 deletions

View File

@ -490,18 +490,20 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
.eq(DiningPlatesDO::getDiningPlatesNum, diningPlatesNum)
.eq(DiningPlatesDO::getStoreId, storeId));
LocalDateTime bindingTime = diningPlatesDO.getBindingTime();
long seconds = Duration.between(bindingTime, LocalDateTime.now()).getSeconds();
if(diningPlatesDO == null ) {
map.put("data", "absent");
map.put("msg",null);
}else if (diningPlatesDO.getUserId() == null){
map.put("data", "unbind");
map.put("msg",null);
}else if (seconds <= 3){
}else {
if (diningPlatesDO.getBindingTime()!=null){
LocalDateTime bindingTime = diningPlatesDO.getBindingTime();
long seconds = Duration.between(bindingTime, LocalDateTime.now()).getSeconds();
if(seconds <=3){
throw exception(DINING_PLATES_TIME);
}
else {
}
unbind(diningPlatesNum,storeId);
map.put("data", "bind");
map.put("msg","餐盘已解绑");

View File

@ -23,6 +23,7 @@ import cn.iocoder.yudao.module.member.service.amount.DeductionService;
import cn.iocoder.yudao.module.member.service.card.CardService;
import cn.iocoder.yudao.module.member.service.storeorderdetail.StoreOrderDetailService;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -65,6 +66,9 @@ public class StoreOrderServiceImpl implements StoreOrderService {
@Resource
private StringRedisTemplate storeOrderRedisTemplate;
@Override
public Integer createStoreOrder(StoreOrderSaveReqVO createReqVO) {
// 插入
@ -168,7 +172,8 @@ public class StoreOrderServiceImpl implements StoreOrderService {
@Override
@Transactional(rollbackFor = Exception.class)
public String codePay(StoreOrderDto dto) {
String s = validateJWT(dto.getJwt());
String s = storeOrderRedisTemplate.opsForValue().get(dto.getJwt());
if (StrUtil.isBlank(s)) {
return "二维码过期";
}

View File

@ -12,6 +12,7 @@ import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -915,12 +916,12 @@ public class MemberUserServiceImpl implements MemberUserService {
if(StrUtil.isNotEmpty(url)){
return url;
}
String jwt = generateJWT(userId); // 1分钟后过期
String encode = DigestUtil.md5Hex(userId.toString()+System.currentTimeMillis());
String fileName = "QRCode_" + userId + ".png";
String path = QRCodeWithJWTUtil.BASE_PATH+fileName;
QRCodeWithJWTUtil.generateQRCode(jwt, 350, 350, path); // 生
memberUserRedisTemplate.opsForValue().set(redisKey,path,60, TimeUnit.SECONDS);
QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path); // 生
memberUserRedisTemplate.opsForValue().set(redisKey,path,180, TimeUnit.SECONDS);
memberUserRedisTemplate.opsForValue().set(encode,userId.toString(),180, TimeUnit.SECONDS);
return path;
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.member.util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@ -10,6 +11,7 @@ import cn.hutool.jwt.JWTUtil;
import java.io.File;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -63,4 +65,13 @@ public class QRCodeWithJWTUtil {
}
return null;
}
public static void main(String[] args) {
String encode = DigestUtil.md5Hex("340"+ System.currentTimeMillis());
System.out.println(encode);
String fileName = "QRCode_" + "test" + ".png";
String path = QRCodeWithJWTUtil.BASE_PATH+fileName;
QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path);
}
}