fix
This commit is contained in:
parent
3b91e25501
commit
cca1ea711d
|
@ -8,7 +8,6 @@ import (
|
|||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart/internal/svc"
|
||||
"fusenapi/server/shopping-cart/internal/types"
|
||||
"fusenapi/service/repositories"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
|
@ -54,6 +53,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
//获取购物车列表
|
||||
carts, _, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{
|
||||
Ids: cartIds,
|
||||
Fields: "id,size_id,product_id,fitting_id",
|
||||
UserId: userinfo.UserId,
|
||||
Page: 1,
|
||||
Limit: len(cartIds),
|
||||
|
@ -65,46 +65,6 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
if len(carts) < len(req.CalculateList) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "please refresh page for the shopping cart has changed!!")
|
||||
}
|
||||
//**************获取相关数据校验变更************
|
||||
var (
|
||||
mapSize = make(map[int64]gmodel.FsProductSize)
|
||||
mapModel = make(map[int64]gmodel.FsProductModel3d)
|
||||
mapTemplate = make(map[int64]gmodel.FsProductTemplateV2)
|
||||
mapSizePrice = make(map[string]gmodel.FsProductPrice)
|
||||
mapProduct = make(map[int64]gmodel.FsProduct)
|
||||
mapResourceMetadata = make(map[string]interface{})
|
||||
)
|
||||
//获取相关信息
|
||||
err = NewGetCartsLogic(l.ctx, l.svcCtx).GetRelationInfo(GetRelationInfoReq{
|
||||
Carts: carts,
|
||||
MapSize: mapSize,
|
||||
MapModel: mapModel,
|
||||
MapTemplate: mapTemplate,
|
||||
MapSizePrice: mapSizePrice,
|
||||
MapProduct: mapProduct,
|
||||
MapResourceMetadata: mapResourceMetadata,
|
||||
})
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||
}
|
||||
//定义map收集变更信息
|
||||
mapCartChange := make(map[int64]string)
|
||||
mapSnapshot := make(map[int64]gmodel.CartSnapshot)
|
||||
//校验购物车数据是否变更
|
||||
err = l.svcCtx.Repositories.NewShoppingCart.VerifyShoppingCartSnapshotDataChange(repositories.VerifyShoppingCartSnapshotDataChangeReq{
|
||||
Carts: carts,
|
||||
MapSize: mapSize,
|
||||
MapModel: mapModel,
|
||||
MapTemplate: mapTemplate,
|
||||
MapCartChange: mapCartChange,
|
||||
MapSnapshot: mapSnapshot,
|
||||
MapProduct: mapProduct,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error("VerifyShoppingCartSnapshotDataChange err:", err.Error())
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "system err:failed to check shopping cart change data")
|
||||
}
|
||||
//**************************
|
||||
sizeIds := make([]int64, 0, len(carts))
|
||||
productIds := make([]int64, 0, len(carts))
|
||||
fittingIds := make([]int64, 0, len(carts))
|
||||
|
@ -148,10 +108,6 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
}
|
||||
//请求的数量
|
||||
reqPurchaseQuantity := mapCalculateQuantity[cart.Id].PurchaseQuantity
|
||||
//传入数量是<= 0则取数据库的
|
||||
if reqPurchaseQuantity <= 0 {
|
||||
reqPurchaseQuantity = *cart.PurchaseQuantity
|
||||
}
|
||||
isSelected := int64(0)
|
||||
if mapCalculateQuantity[cart.Id].IsSelected {
|
||||
isSelected = 1
|
||||
|
@ -179,8 +135,8 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
updData := &gmodel.FsShoppingCart{
|
||||
PurchaseQuantity: &reqPurchaseQuantity,
|
||||
}
|
||||
//如果是没有变更且是选中则累加总价
|
||||
if _, ok = mapCartChange[cart.Id]; !ok && isSelected == 1 {
|
||||
//如果是选中则累加总价
|
||||
if isSelected == 1 {
|
||||
subTotalPrice += totalPrice
|
||||
updData.IsSelected = &isSelected
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user