|
|
@@ -27,6 +27,9 @@ public class OrderController {
|
|
|
@Autowired
|
|
|
private OrderService orderService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private com.haha.common.config.CommonConfig commonConfig;
|
|
|
+
|
|
|
/**
|
|
|
* 获取订单列表
|
|
|
*
|
|
|
@@ -77,7 +80,9 @@ public class OrderController {
|
|
|
product.put("name", item.getString("product_name"));
|
|
|
product.put("price", item.getDouble("price"));
|
|
|
product.put("quantity", item.getInteger("product_num"));
|
|
|
- product.put("image", item.getString("pic"));
|
|
|
+ // 处理图片链接
|
|
|
+ String picUrl = item.getString("pic");
|
|
|
+ product.put("image", normalizeImageUrl(picUrl));
|
|
|
products.add(product);
|
|
|
}
|
|
|
orderMap.put("products", products);
|
|
|
@@ -172,7 +177,9 @@ public class OrderController {
|
|
|
product.put("name", item.getString("product_name"));
|
|
|
product.put("price", item.getDouble("price"));
|
|
|
product.put("quantity", item.getInteger("product_num"));
|
|
|
- product.put("image", item.getString("pic"));
|
|
|
+ // 处理图片链接
|
|
|
+ String picUrl = item.getString("pic");
|
|
|
+ product.put("image", normalizeImageUrl(picUrl));
|
|
|
Double price = item.getDouble("price");
|
|
|
Integer quantity = item.getInteger("product_num");
|
|
|
product.put("subtotal", price != null && quantity != null ? price * quantity : 0);
|
|
|
@@ -267,6 +274,28 @@ public class OrderController {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 标准化图片 URL
|
|
|
+ * 如果图片链接已经是完整的 URL(包含 http://或 https://),则保持不变
|
|
|
+ * 否则添加配置的图片域名前缀
|
|
|
+ *
|
|
|
+ * @param picUrl 原始图片链接
|
|
|
+ * @return 标准化后的图片链接
|
|
|
+ */
|
|
|
+ private String normalizeImageUrl(String picUrl) {
|
|
|
+ if (picUrl == null || picUrl.isEmpty()) {
|
|
|
+ return picUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果已经是完整的 URL(以 http://或 https://开头),则直接返回
|
|
|
+ if (picUrl.startsWith("http://") || picUrl.startsWith("https://")) {
|
|
|
+ return picUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 否则添加域名前缀
|
|
|
+ return commonConfig.getImageDomainPrefix() + picUrl;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取订单状态文本
|
|
|
*/
|