feat:订单编号生成 订单编号
This commit is contained in:
@@ -194,6 +194,8 @@ public class RedisConstant {
|
|||||||
*/
|
*/
|
||||||
public static final String COOLINGPERIOD_FIRSTLOGIN_KEY = "coolingPeriodFirstLoginCache:{0}";
|
public static final String COOLINGPERIOD_FIRSTLOGIN_KEY = "coolingPeriodFirstLoginCache:{0}";
|
||||||
|
|
||||||
|
public static final String REDIS_KEY_PREFIX = "daily_id:{0}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 七天
|
* 七天
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class CoolDateUtils {
|
|||||||
public static final String DATE_FORMAT_SEC_5 = "yyyy.MM.dd HH:mm";
|
public static final String DATE_FORMAT_SEC_5 = "yyyy.MM.dd HH:mm";
|
||||||
public static final String DATE_FORMAT_SEC_6 = "yyyy.MM.dd";
|
public static final String DATE_FORMAT_SEC_6 = "yyyy.MM.dd";
|
||||||
public static final String DATE_FORMAT_SEC_7 = "yyyy/MM/dd HH:mm";
|
public static final String DATE_FORMAT_SEC_7 = "yyyy/MM/dd HH:mm";
|
||||||
|
public static final String DATE_FORMAT_SEC_8 = "yyyyMMdd";
|
||||||
|
|
||||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
||||||
@@ -136,6 +137,14 @@ public class CoolDateUtils {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前日期 yyyyMMdd
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static final String getToday(){
|
||||||
|
DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT_SEC_8);
|
||||||
|
return LocalDate.now().format(DATE_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前日期字符串 (yyyy-MM-dd)
|
* 获取当前日期字符串 (yyyy-MM-dd)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis常量工具类
|
* redis常量工具类
|
||||||
@@ -113,4 +115,8 @@ public class RedisConstantUtil {
|
|||||||
return active + "_" + RedisConstant.GET_AI_MODULE + eid;
|
return active + "_" + RedisConstant.GET_AI_MODULE + eid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPaymentReceiptCode(String today){
|
||||||
|
return active + "_" + MessageFormat.format(RedisConstant.REDIS_KEY_PREFIX, today);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.cool.store.utils;
|
package com.cool.store.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +17,10 @@ import java.util.Random;
|
|||||||
*/
|
*/
|
||||||
public class UUIDUtils {
|
public class UUIDUtils {
|
||||||
|
|
||||||
|
private static final String ID_PREFIX = "12";
|
||||||
|
|
||||||
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(CoolDateUtils.DATE_FORMAT_SEC_8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
|
* 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
|
||||||
*/
|
*/
|
||||||
@@ -29,22 +36,8 @@ public class UUIDUtils {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
// 生成 UUID 方法
|
// 生成 UUID 方法
|
||||||
public static String generateCustomUUID() {
|
public static String generateCustomUUID(Integer randomCount) {
|
||||||
// 获取当前时间戳(毫秒)
|
String today = LocalDate.now().format(DATE_FORMATTER);
|
||||||
long timestamp = System.currentTimeMillis();
|
return ID_PREFIX + today + String.format("%04d", randomCount);
|
||||||
|
|
||||||
// 生成4位随机数字(0000 - 9999)
|
|
||||||
int randomNumber = new Random().nextInt(10000);
|
|
||||||
String randomDigits = String.format("%04d", randomNumber);
|
|
||||||
|
|
||||||
// 生成2个随机大写字母
|
|
||||||
String randomLetters = "";
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
char c = (char) ('A' + random.nextInt(26));
|
|
||||||
randomLetters += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
return timestamp + randomDigits + randomLetters;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,4 +68,10 @@ public class FranchiseFeePayInfoResponse {
|
|||||||
|
|
||||||
@ApiModelProperty("认领状态 0-待认领 1-已认领")
|
@ApiModelProperty("认领状态 0-待认领 1-已认领")
|
||||||
private Integer xgjClaimStatus;
|
private Integer xgjClaimStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付状态 45:待缴费 50:已缴费")
|
||||||
|
private Integer payStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("付款单编号")
|
||||||
|
private String paymentReceiptCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public interface LinePayService {
|
|||||||
|
|
||||||
Long submitFranchiseFeePayInfo(LinePaySubmitRequest request, String userId);
|
Long submitFranchiseFeePayInfo(LinePaySubmitRequest request, String userId);
|
||||||
|
|
||||||
|
String getPaymentReceiptCode();
|
||||||
|
|
||||||
List<FranchiseFeePayInfoResponse> getFranchiseFeePayInfoList(Long shopId);
|
List<FranchiseFeePayInfoResponse> getFranchiseFeePayInfoList(Long shopId);
|
||||||
|
|
||||||
Boolean deleteFranchiseFeePayInfo(Long id,String userId);
|
Boolean deleteFranchiseFeePayInfo(Long id,String userId);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cool.store.constants.CommonConstants;
|
import com.cool.store.constants.CommonConstants;
|
||||||
|
import com.cool.store.constants.RedisConstant;
|
||||||
import com.cool.store.context.LoginUserInfo;
|
import com.cool.store.context.LoginUserInfo;
|
||||||
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||||
import com.cool.store.dao.LineInfoDAO;
|
import com.cool.store.dao.LineInfoDAO;
|
||||||
@@ -24,6 +25,8 @@ import com.cool.store.request.LinePaySubmitRequest;
|
|||||||
import com.cool.store.response.FranchiseFeePayInfoResponse;
|
import com.cool.store.response.FranchiseFeePayInfoResponse;
|
||||||
import com.cool.store.service.LinePayService;
|
import com.cool.store.service.LinePayService;
|
||||||
import com.cool.store.service.UserAuthMappingService;
|
import com.cool.store.service.UserAuthMappingService;
|
||||||
|
import com.cool.store.utils.CoolDateUtils;
|
||||||
|
import com.cool.store.utils.RedisConstantUtil;
|
||||||
import com.cool.store.utils.RedisUtilPool;
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
import com.cool.store.utils.UUIDUtils;
|
import com.cool.store.utils.UUIDUtils;
|
||||||
import com.cool.store.utils.poi.DateUtils;
|
import com.cool.store.utils.poi.DateUtils;
|
||||||
@@ -42,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -54,6 +58,7 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class LinePayServiceImpl implements LinePayService {
|
public class LinePayServiceImpl implements LinePayService {
|
||||||
|
|
||||||
|
|
||||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||||
private String eid;
|
private String eid;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -77,6 +82,8 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
private RedisUtilPool redisUtilPool;
|
private RedisUtilPool redisUtilPool;
|
||||||
@Resource
|
@Resource
|
||||||
private UserAuthMappingService userAuthMappingService;
|
private UserAuthMappingService userAuthMappingService;
|
||||||
|
@Resource
|
||||||
|
RedisConstantUtil redisConstantUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinePayVO getLinePayInfo(Long lineId, Integer businessType, Long shopId) {
|
public LinePayVO getLinePayInfo(Long lineId, Integer businessType, Long shopId) {
|
||||||
@@ -182,7 +189,7 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
if (linePayDO.getId() != null) {
|
if (linePayDO.getId() != null) {
|
||||||
linePayDAO.updateLinePay(linePayDO);
|
linePayDAO.updateLinePay(linePayDO);
|
||||||
} else {
|
} else {
|
||||||
linePayDO.setPaymentReceiptCode(UUIDUtils.generateCustomUUID());
|
linePayDO.setPaymentReceiptCode(getPaymentReceiptCode());
|
||||||
linePayDAO.addLinePay(linePayDO);
|
linePayDAO.addLinePay(linePayDO);
|
||||||
}
|
}
|
||||||
if (shopSubStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_71.getShopSubStageStatus()))
|
if (shopSubStageInfo.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_71.getShopSubStageStatus()))
|
||||||
@@ -204,6 +211,19 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPaymentReceiptCode(){
|
||||||
|
//当前日期
|
||||||
|
String today = CoolDateUtils.getToday();
|
||||||
|
String redisKey = redisConstantUtil.getPaymentReceiptCode(today);
|
||||||
|
Long sequence = redisUtilPool.incrby(redisKey, 1);
|
||||||
|
//第一次设置过期时间 一天
|
||||||
|
if (sequence==1){
|
||||||
|
redisUtilPool.expire(redisKey,RedisConstant.ONE_DAY_SECONDS);
|
||||||
|
}
|
||||||
|
return "12" + today + String.format("%04d", sequence);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FranchiseFeePayInfoResponse> getFranchiseFeePayInfoList(Long shopId) {
|
public List<FranchiseFeePayInfoResponse> getFranchiseFeePayInfoList(Long shopId) {
|
||||||
List<LinePayDO> list = linePayDAO.getFranchiseFeePayInfoByShopId(shopId);
|
List<LinePayDO> list = linePayDAO.getFranchiseFeePayInfoByShopId(shopId);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.cool.store.controller.webb;
|
package com.cool.store.controller.webb;
|
||||||
|
|
||||||
|
import com.cool.store.constants.RedisConstant;
|
||||||
import com.cool.store.dao.*;
|
import com.cool.store.dao.*;
|
||||||
import com.cool.store.dto.FoodTokenDTO;
|
import com.cool.store.dto.FoodTokenDTO;
|
||||||
import com.cool.store.dto.GetAccessTokenDTO;
|
import com.cool.store.dto.GetAccessTokenDTO;
|
||||||
@@ -25,8 +26,12 @@ import com.cool.store.response.oppty.OpportunityInfoPageResponse;
|
|||||||
import com.cool.store.service.*;
|
import com.cool.store.service.*;
|
||||||
import com.cool.store.service.impl.CommonService;
|
import com.cool.store.service.impl.CommonService;
|
||||||
import com.cool.store.service.impl.UserAuthMappingServiceImpl;
|
import com.cool.store.service.impl.UserAuthMappingServiceImpl;
|
||||||
|
import com.cool.store.utils.CoolDateUtils;
|
||||||
|
import com.cool.store.utils.RedisConstantUtil;
|
||||||
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -304,4 +309,16 @@ public class PCTestController {
|
|||||||
return ResponseResult.success(thirdFoodService.getFoodToken(dto));
|
return ResponseResult.success(thirdFoodService.getFoodToken(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
LinePayService linePayService;
|
||||||
|
@GetMapping("/getToday")
|
||||||
|
@ApiOperation("getToday")
|
||||||
|
public ResponseResult<Boolean> getToday() {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
System.out.println(linePayService.getPaymentReceiptCode());
|
||||||
|
}
|
||||||
|
return ResponseResult.success(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user