打印日志

This commit is contained in:
Guoqs
2024-08-30 13:48:27 +08:00
parent 8b06de887f
commit abdba7c92e
6 changed files with 78 additions and 11 deletions

View File

@@ -209,7 +209,7 @@ public class MemberController extends BaseController {
logger.error("查询用户账户信息", e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
}
logger.info("查询用户账户信息 param memberId:{}, result:{}", memberId, response);
logger.info("查询用户账户信息, param:{}, result:{}", memberId, response);
return response;
}

View File

@@ -92,7 +92,7 @@ public class OccupyOrderController extends BaseController {
*/
@GetMapping("/getOccupyOrderDetail/{occupyCode}")
public RestApiResponse<?> getOccupyOrderDetail(@PathVariable("occupyCode") String occupyCode) {
logger.info("查询占桩订单详情页 param:{}", occupyCode);
// logger.info("查询占桩订单详情页 param:{}", occupyCode);
RestApiResponse<?> response = null;
try {
OccupyOrderDetailVO vo = orderPileOccupyService.getOccupyOrderDetail(occupyCode);
@@ -101,7 +101,7 @@ public class OccupyOrderController extends BaseController {
logger.error("查询占桩订单详情页 error,", e);
response = new RestApiResponse<>(e);
}
logger.info("查询占桩订单详情页 result:{}", response);
logger.info("查询占桩订单详情页, param:{}, result:{}", occupyCode, response);
return response;
}

View File

@@ -287,7 +287,7 @@ public class OrderController extends BaseController {
*/
@PostMapping("/queryUninvoicedOrderList")
public RestApiResponse<?> queryUninvoicedOrderList(HttpServletRequest request, @RequestBody QueryOrderDTO dto) {
logger.info("查询未开发票订单 param:{}", JSON.toJSONString(dto));
// logger.info("查询未开发票订单 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response;
try {
String memberId = getMemberIdByAuthorization(request);

View File

@@ -220,7 +220,7 @@ public class PersonPileController extends BaseController {
logger.error("获取某枪口某段时间内累计信息 error", e);
response = new RestApiResponse<>(e);
}
logger.info("获取某枪口某段时间内累计信息 result:{}", response);
logger.info("获取某枪口某段时间内累计信息, params:{}, result:{}", JSON.toJSONString(dto), response);
return response;
}
@@ -235,7 +235,7 @@ public class PersonPileController extends BaseController {
*/
@RequestMapping("/getChargingRecord")
public RestApiResponse<?> getChargingRecord(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto) {
logger.info("获取个人桩充电记录 params:{}", JSON.toJSONString(dto));
// logger.info("获取个人桩充电记录 params:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
String memberId = getMemberIdByAuthorization(request);
@@ -249,7 +249,7 @@ public class PersonPileController extends BaseController {
logger.error("获取个人桩充电记录 error", e);
response = new RestApiResponse<>(e);
}
logger.info("获取个人桩充电记录 result:{}", response);
logger.info("获取个人桩充电记录, params:{}, result:{}", JSON.toJSONString(dto), JSON.toJSONString(response));
return response;
}

View File

@@ -617,4 +617,69 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return url.replace(Constants.URL_DELIMITER, "");
}
/**
* 含有unicode 的字符串转一般字符串
* @param unicodeStr 混有 Unicode 的字符串
* @return
*/
public static String unicodeStr2String(String unicodeStr) {
int length = unicodeStr.length();
int count = 0;
//正则匹配条件,可匹配“\\u”1到4位一般是4位可直接使用 String regex = "\\\\u[a-f0-9A-F]{4}";
String regex = "\\\\u[a-f0-9A-F]{1,4}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(unicodeStr);
StringBuffer sb = new StringBuffer();
while(matcher.find()) {
String oldChar = matcher.group();//原本的Unicode字符
String newChar = unicode2String(oldChar);//转换为普通字符
// int index = unicodeStr.indexOf(oldChar);
// 在遇见重复出现的unicode代码的时候会造成从源字符串获取非unicode编码字符的时候截取索引越界等
int index = matcher.start();
sb.append(unicodeStr.substring(count, index));//添加前面不是unicode的字符
sb.append(newChar);//添加转换后的字符
count = index+oldChar.length();//统计下标移动的位置
}
sb.append(unicodeStr.substring(count, length));//添加末尾不是Unicode的字符
return sb.toString();
}
/**
* 字符串转换unicode
* @param string
* @return
*/
public static String string2Unicode(String string) {
StringBuffer unicode = new StringBuffer();
for (int i = 0; i < string.length(); i++) {
// 取出每一个字符
char c = string.charAt(i);
// 转换为unicode
unicode.append("\\u" + Integer.toHexString(c));
}
return unicode.toString();
}
/**
* unicode 转字符串
* @param unicode 全为 Unicode 的字符串
* @return
*/
public static String unicode2String(String unicode) {
StringBuffer string = new StringBuffer();
String[] hex = unicode.split("\\\\u");
for (int i = 1; i < hex.length; i++) {
// 转换出每一个代码点
int data = Integer.parseInt(hex[i], 16);
// 追加成string
string.append((char) data);
}
return string.toString();
}
}

View File

@@ -762,11 +762,13 @@ public abstract class AbstractProgramLogic implements InitializingBean {
// 余额支付最大下发200
BigDecimal defaultAmount = Constants.BALANCE_PAY_MAX_AMOUNT;
if (totalAccountAmount.compareTo(defaultAmount) < 0) {
principalBalancePay = memberVO.getPrincipalBalance();
giftBalancePay = memberVO.getGiftBalance();
// 总余额小于200下发全部余额
principalBalancePay = memberVO.getPrincipalBalance(); // 本金余额全部支付
giftBalancePay = memberVO.getGiftBalance(); // 赠送金额全部支付
} else {
principalBalancePay = defaultAmount.min(memberVO.getPrincipalBalance());
giftBalancePay = defaultAmount.subtract(principalBalancePay);
// 总余额大于200下发200
principalBalancePay = defaultAmount.min(memberVO.getPrincipalBalance()); // 本金余额与200取最小值
giftBalancePay = defaultAmount.subtract(principalBalancePay); // defaultAmount - principalBalancePay 为赠送金支付金额
}
Map<String, BigDecimal> resultMap = Maps.newHashMap();
resultMap.put("principalBalancePay", principalBalancePay);