This commit is contained in:
2025-10-31 15:30:50 +08:00
parent 8db691cb66
commit 8f255a97a3
3 changed files with 44 additions and 2 deletions

View File

@@ -6,7 +6,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.jarvis.domain.GiftCoupon; import com.ruoyi.jarvis.domain.GiftCoupon;
import com.ruoyi.jarvis.domain.OrderRows;
import com.ruoyi.jarvis.service.IGiftCouponService; import com.ruoyi.jarvis.service.IGiftCouponService;
import com.ruoyi.jarvis.service.IOrderRowsService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@@ -25,9 +27,11 @@ import com.ruoyi.common.core.page.TableDataInfo;
public class GiftCouponController extends BaseController { public class GiftCouponController extends BaseController {
private final IGiftCouponService giftCouponService; private final IGiftCouponService giftCouponService;
private final IOrderRowsService orderRowsService;
public GiftCouponController(IGiftCouponService giftCouponService) { public GiftCouponController(IGiftCouponService giftCouponService, IOrderRowsService orderRowsService) {
this.giftCouponService = giftCouponService; this.giftCouponService = giftCouponService;
this.orderRowsService = orderRowsService;
} }
/** /**
@@ -79,7 +83,31 @@ public class GiftCouponController extends BaseController {
*/ */
@GetMapping(value = "/{giftCouponKey}") @GetMapping(value = "/{giftCouponKey}")
public AjaxResult getInfo(@PathVariable("giftCouponKey") String giftCouponKey) { public AjaxResult getInfo(@PathVariable("giftCouponKey") String giftCouponKey) {
return success(giftCouponService.selectGiftCouponByKey(giftCouponKey)); GiftCoupon giftCoupon = giftCouponService.selectGiftCouponByKey(giftCouponKey);
if (giftCoupon != null) {
// 查询关联的订单
OrderRows query = new OrderRows();
query.setGiftCouponKey(giftCouponKey);
List<OrderRows> orders = orderRowsService.selectOrderRowsList(query);
// 将订单列表添加到返回数据中
java.util.Map<String, Object> result = new java.util.HashMap<>();
result.put("giftCoupon", giftCoupon);
result.put("orders", orders);
return success(result);
}
return success(giftCoupon);
}
/**
* 查询礼金关联的订单列表
*/
@GetMapping("/{giftCouponKey}/orders")
public TableDataInfo getOrders(@PathVariable("giftCouponKey") String giftCouponKey) {
startPage();
OrderRows query = new OrderRows();
query.setGiftCouponKey(giftCouponKey);
List<OrderRows> list = orderRowsService.selectOrderRowsList(query);
return getDataTable(list);
} }
/** /**

View File

@@ -79,4 +79,12 @@ public interface OrderRowsMapper
* @return 京粉订单 * @return 京粉订单
*/ */
public OrderRows selectOrderRowsByOrderId(String orderId); public OrderRows selectOrderRowsByOrderId(String orderId);
/**
* 根据礼金Key查询订单列表
*
* @param giftCouponKey 礼金Key
* @return 订单列表
*/
public List<OrderRows> selectOrderRowsByGiftCouponKey(@Param("giftCouponKey") String giftCouponKey);
} }

View File

@@ -383,4 +383,10 @@
<include refid="selectOrderRowsVo"/> <include refid="selectOrderRowsVo"/>
where order_id = #{orderId} where order_id = #{orderId}
</select> </select>
<select id="selectOrderRowsByGiftCouponKey" parameterType="String" resultMap="OrderRowsResult">
<include refid="selectOrderRowsVo"/>
where gift_coupon_key = #{giftCouponKey}
order by order_time desc
</select>
</mapper> </mapper>