优化交易创建流程,客户管理新增折扣与来源字段及功能

This commit is contained in:
2026-03-27 16:16:55 +08:00
parent 75ad12efb3
commit 7e8d824ba6
26 changed files with 523 additions and 140 deletions

View File

@@ -643,7 +643,7 @@ func CreateResource(c *fiber.Ctx) error {
}
// 创建套餐
err = s.Resource.CreateResourceByBalance(authCtx.User.ID, time.Now(), req.CreateResourceData)
err = s.Resource.CreateResourceByBalance(authCtx.User, req.CreateResourceData)
if err != nil {
return err
}
@@ -670,28 +670,28 @@ func ResourcePrice(c *fiber.Ctx) error {
}
// 获取套餐价格
sku, err := s.Resource.GetSku(req.CreateResourceData.Code())
if err != nil {
return err
}
// sku, err := s.Resource.GetSku(req.CreateResourceData.Code())
// if err != nil {
// return err
// }
_, amount, discounted, couponApplied, err := s.Resource.GetPrice(sku, req.Count(), nil, nil)
// _, amount, discounted, couponApplied, err := s.Resource.GetPrice(sku, req.Count(), nil, nil)
// if err != nil {
// return err
// }
detail, err := req.TradeDetail(nil)
if err != nil {
return err
}
// 计算折扣
return c.JSON(ResourcePriceResp{
Discount: float32(sku.Discount.Discount) / 100,
Price: amount.StringFixed(2),
Discounted: discounted.StringFixed(2),
CouponApplied: couponApplied.StringFixed(2),
Price: detail.Amount.StringFixed(2),
Discounted: detail.Actual.StringFixed(2),
})
}
type ResourcePriceResp struct {
Price string `json:"price"`
Discount float32 `json:"discounted"`
Discounted string `json:"discounted_price"`
CouponApplied string `json:"coupon_applied"`
Price string `json:"price"`
Discounted string `json:"discounted_price"`
}