fix: 美团券核销无法转map修复

This commit is contained in:
张松 2024-11-27 15:31:12 +08:00
parent 71a4239741
commit c1dbd68616
1 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
}
private final RestTemplate restTemplate;
private <T> T exec(String url, Integer shopId, Object data) {
private <R, T> R exec(String url, Integer shopId, T data) {
// 获取店铺信息
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
if (shopInfo == null) {
@ -45,7 +45,12 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
// 构造请求实体根据 data 是否为空设置请求体
HttpEntity<Object> entity;
if (data != null) {
Map<String, Object> map = BeanUtil.beanToMap(data);
Map<String, Object> map;
if (data instanceof Map) {
map = (Map<String, Object>) data;
}else {
map = BeanUtil.beanToMap(data, false, false);
}
map.put("title", shopInfo.getShopName());
entity = new HttpEntity<>(map, headers);
} else {
@ -72,7 +77,7 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
}
// 返回数据
return (T) resp.getData();
return (R) resp.getData();
}