记得上下班打卡 | git大法好,push需谨慎

Commit 413b8857 authored by anjiabin's avatar anjiabin

优化支付代码

parent d45adfb0
......@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
* @date 2021/7/13 19:36
*/
@Data
public class DragonOrdersDto implements Serializable {
public class DragonOrdersDto implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
......@@ -103,4 +103,14 @@ public class DragonOrdersDto implements Serializable {
* deleted_at
*/
private LocalDateTime deletedAt;
private static final DragonOrdersDto obj = new DragonOrdersDto();
public static DragonOrdersDto getNew() {
try {
return (DragonOrdersDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new DragonOrdersDto();
}
}
}
......@@ -58,7 +58,7 @@ public class DragonServiceCommonBiz {
orders.setCreatedAt(LocalDateTime.now());
// orders.setUpdatedAt();
DragonOrdersDto ordersDto = new DragonOrdersDto();
DragonOrdersDto ordersDto = DragonOrdersDto.getNew();
BeanUtil.copy(orders,ordersDto);
long startTime = System.currentTimeMillis();
//放到redis缓存中
......
......@@ -14,14 +14,13 @@ public class DataUtils {
private long keyExpireTime = 3600*24*7;
public void createPayOrder(String code, DragonOrdersDto ordersDto) {
if (!redisUtil.hasKey(DragonConstant.REDIS_KET_PAY_CODE + code)) {
redisUtil.set(DragonConstant.REDIS_KET_PAY_CODE + code, ordersDto,keyExpireTime);
}
}
public DragonOrdersDto getPayOrderByCode(String code) {
if (redisUtil.hasKey(DragonConstant.REDIS_KET_PAY_CODE + code)) {
return (DragonOrdersDto) redisUtil.get(DragonConstant.REDIS_KET_PAY_CODE + code);
Object obj = redisUtil.get(DragonConstant.REDIS_KET_PAY_CODE + code);
if(obj!=null){
return (DragonOrdersDto) obj;
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment