Commit 465ee58b by 杨树贤

Merge branch 'ysx-新客活动价兼容-20251111'

parents 87991c4b eec49b35
......@@ -73,4 +73,5 @@ type ActivityCheckData struct {
ClassId int
OrgId int
Source int
NewCustomer int
}
......@@ -16,6 +16,8 @@ type RequestParams struct {
ShowSpuExtra string
// 用户权限相关参数
Power PowerParams
//是否展示新客价格
NewCustomer string
}
// PowerParams 用户权限参数
......@@ -49,6 +51,6 @@ func ExtractRequestParams(ctx *gin.Context) RequestParams {
Invoice: ctx.Request.FormValue("power[invoice]"),
SpecialInvoice: ctx.Request.FormValue("power[special_invoice]"),
},
NewCustomer: ctx.Request.FormValue("new_customer"),
}
}
......@@ -55,9 +55,17 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
var hasActivity bool
nowTimestamp := int(time.Now().Unix())
for _, activity := range activities {
//判断状态
if activity.Status != 1 {
continue
}
//判断是否要新客判断,默认是不需要判断,所以要跳过新客活动
if checkData.NewCustomer != 1 {
if activity.UserScope == 3 {
continue
}
}
//判断时间是否过期
if activity.StartTime > nowTimestamp || activity.EndTime < nowTimestamp {
continue
......
......@@ -67,7 +67,8 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
showSkuDetail := params.ShowSkuDetail
//是否展示spu额外信息
showSpuExtra := params.ShowSpuExtra
//是否展示新客价格
newCustomer := params.NewCustomer
//批量获取商品详情
skuArr := gredis.Hmget("default_r", "sku", goodsIds)
//为了性能着想,这边也先去批量获取spu的信息
......@@ -213,9 +214,8 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
//处理活动
sku.AcType = 0
sku.AllowCoupon = 1
//这里获取活动价格和活动类型(折扣打折活动)
sku = ls.GetActivity(sku)
sku = ls.GetActivity(sku, newCustomer)
priceService := PriceService{}
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断
......@@ -343,7 +343,7 @@ func (ls *LyService) LyGoodsDetail(ctx context.Context, params RequestParams, go
}
// 获取活动
func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
func (ls *LyService) GetActivity(sku model.LySku, showNewCustomerPrice string) model.LySku {
//去判断是否有活动(促销打折活动和满赠活动)
checkData := model.ActivityCheckData{
SupplierId: int(sku.SupplierId),
......@@ -355,6 +355,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
ClassId: sku.ClassID2,
OrgId: sku.OrgId,
Source: sku.Source,
NewCustomer: gconv.Int(showNewCustomerPrice),
}
var activityService ActivityService
priceActivity, giftActivity := activityService.GetActivityData(checkData)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment