新功能(#78): 预算订单 API 返回 promo_discount 字段
PreOrderResponse 新增 promo_discount 字段,未接入促销时默认返回 0。 促销命中逻辑待 HIF-76 接入后生效。 Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -708,6 +708,7 @@ type (
|
|||||||
Price int64 `json:"price"`
|
Price int64 `json:"price"`
|
||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
Discount int64 `json:"discount"`
|
Discount int64 `json:"discount"`
|
||||||
|
PromoDiscount int64 `json:"promo_discount"`
|
||||||
GiftAmount int64 `json:"gift_amount"`
|
GiftAmount int64 `json:"gift_amount"`
|
||||||
Coupon string `json:"coupon"`
|
Coupon string `json:"coupon"`
|
||||||
CouponDiscount int64 `json:"coupon_discount"`
|
CouponDiscount int64 `json:"coupon_discount"`
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
|
|||||||
|
|
||||||
amount := int64(math.Round(float64(price) * discount))
|
amount := int64(math.Round(float64(price) * discount))
|
||||||
discountAmount := price - amount
|
discountAmount := price - amount
|
||||||
|
var promoDiscount int64
|
||||||
var couponAmount int64
|
var couponAmount int64
|
||||||
if req.Coupon != "" {
|
if req.Coupon != "" {
|
||||||
couponInfo, err := l.svcCtx.CouponModel.FindOneByCode(l.ctx, req.Coupon)
|
couponInfo, err := l.svcCtx.CouponModel.FindOneByCode(l.ctx, req.Coupon)
|
||||||
@@ -185,6 +186,7 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
|
|||||||
Price: price,
|
Price: price,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
Discount: discountAmount,
|
Discount: discountAmount,
|
||||||
|
PromoDiscount: promoDiscount,
|
||||||
GiftAmount: deductionAmount,
|
GiftAmount: deductionAmount,
|
||||||
Coupon: req.Coupon,
|
Coupon: req.Coupon,
|
||||||
CouponDiscount: couponAmount,
|
CouponDiscount: couponAmount,
|
||||||
|
|||||||
@@ -2012,6 +2012,7 @@ type PreOrderResponse struct {
|
|||||||
Price int64 `json:"price"`
|
Price int64 `json:"price"`
|
||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
Discount int64 `json:"discount"`
|
Discount int64 `json:"discount"`
|
||||||
|
PromoDiscount int64 `json:"promo_discount"`
|
||||||
GiftAmount int64 `json:"gift_amount"`
|
GiftAmount int64 `json:"gift_amount"`
|
||||||
Coupon string `json:"coupon"`
|
Coupon string `json:"coupon"`
|
||||||
CouponDiscount int64 `json:"coupon_discount"`
|
CouponDiscount int64 `json:"coupon_discount"`
|
||||||
|
|||||||
Reference in New Issue
Block a user