shinnosuke
2026-08-06 e5c6b415449d0b7a5e9027dba009e46543004dc0
talent-card-server/src/main/java/com/talentcard/server/business/order/OrderService.java
@@ -110,15 +110,20 @@
   public Map<String, Object> detail(String orderNo) {
      List<Map<String, Object>> rows = query("""
            select o.id, o.order_no, o.talent_id, tu.name as talent_name, tu.mobile as talent_mobile,
                   o.card_id, tc.card_no, tc.card_level, o.benefit_id, b.benefit_name,
                   o.card_id, tc.card_no, coalesce(tc.card_level, tu.talent_level) as talent_level, o.benefit_id, b.benefit_name,
                   o.product_id, o.product_name_snapshot, o.product_cover_url_snapshot,
                   p.product_name, p.cover_url as product_cover_url,
                   o.merchant_id, m.merchant_name, m.merchant_type, m.contact_mobile,
                   m.cover_url as merchant_cover_url, o.store_id, o.order_type,
                   o.order_amount, o.subsidy_amount, o.pay_amount, o.order_status,
                   o.order_amount, o.subsidy_amount, o.base_pay_amount, o.pay_amount, o.coupon_id, o.coupon_amount,
                   mc.coupon_name, o.order_status,
                   o.verify_status, o.created_at, o.updated_at
            from benefit_order o
            left join talent_user tu on tu.id = o.talent_id
            left join talent_card tc on tc.id = o.card_id
            left join benefit b on b.id = o.benefit_id
            left join merchant_product p on p.id = o.product_id and p.deleted = 0
            left join merchant_coupon mc on mc.id = o.coupon_id and mc.deleted = 0
            left join merchant m on m.id = o.merchant_id
            where o.deleted = 0 and o.order_no = ?
            """, orderNo);
@@ -133,10 +138,13 @@
            order by id desc limit 1
            """, detail.get("id"));
      detail.put("verifyTime", verificationRows.isEmpty() ? null : verificationRows.get(0).get("verifyTime"));
      Object itemId = detail.get("productId") == null ? detail.get("benefitId") : detail.get("productId");
      Object itemName = firstNonNull(detail.get("productNameSnapshot"), detail.get("productName"), detail.get("benefitName"));
      Object itemCover = firstNonNull(detail.get("productCoverUrlSnapshot"), detail.get("productCoverUrl"), detail.get("merchantCoverUrl"));
      detail.put("items", List.of(Map.of(
            "id", detail.get("benefitId") == null ? "-" : String.valueOf(detail.get("benefitId")),
            "name", detail.get("benefitName") == null ? "-" : detail.get("benefitName"),
            "coverUrl", detail.get("merchantCoverUrl") == null ? "" : detail.get("merchantCoverUrl"),
            "id", itemId == null ? "-" : String.valueOf(itemId),
            "name", itemName == null ? "-" : itemName,
            "coverUrl", itemCover == null ? "" : itemCover,
            "amount", detail.get("orderAmount") == null ? 0 : detail.get("orderAmount")
      )));
      detail.put("payments", query("""
@@ -155,6 +163,11 @@
      return detail;
   }
   private Object firstNonNull(Object... values) {
      for (Object value : values) if (value != null && !String.valueOf(value).isBlank()) return value;
      return null;
   }
   @Transactional(readOnly = true)
   public PageResult<Map<String, Object>> refunds(
         String orderType,