Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
@@ -83,46 +83,49 @@ func (l *CartListLogic) CartList(req *types.CartListReq, userinfo *auth.UserInfo
|
||||
name = *cartRelativeData.ProductList[productIndex].Title
|
||||
productSn = strings.ToLower(*cartRelativeData.ProductList[productIndex].Sn)
|
||||
}
|
||||
capacity := ""
|
||||
var sizeList types.CartSizeItem
|
||||
if sizeIndex, ok := mapProductSize[*v.SizeId]; ok {
|
||||
capacity = *cartRelativeData.ProductSizeList[sizeIndex].Capacity
|
||||
err = json.Unmarshal([]byte(*cartRelativeData.ProductSizeList[sizeIndex].Title), &sizeList)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse product size`s title")
|
||||
}
|
||||
}
|
||||
designSn := ""
|
||||
if designIndex, ok := mapProductDesign[*v.DesignId]; ok {
|
||||
designSn = strings.ToLower(*cartRelativeData.ProductDesignList[designIndex].Sn)
|
||||
}
|
||||
option := types.CartOption{}
|
||||
if model3dIndex, ok := mapProductModel3d[*v.OptionalId]; ok {
|
||||
option.Id = cartRelativeData.ProductModel3dList[model3dIndex].Id
|
||||
option.Title = *cartRelativeData.ProductModel3dList[model3dIndex].Title
|
||||
option.Price = float64(*cartRelativeData.ProductModel3dList[model3dIndex].Price) / float64(100)
|
||||
}
|
||||
pcList, err := l.getPcList(cartRelativeData.ProductPriceList, *v.ProductId, *v.MaterialId, *v.SizeId)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to calculate step price")
|
||||
}
|
||||
rspList = append(rspList, types.CartListRsp{
|
||||
d := types.CartListRsp{
|
||||
Id: v.Id,
|
||||
Cover: *v.Cover,
|
||||
Name: name,
|
||||
Capacity: capacity,
|
||||
Capacity: "",
|
||||
ETA: time.Now().AddDate(0, 0, 60).Format("2006-01-02 15:04:05"),
|
||||
Pcs: *v.BuyNum,
|
||||
ProductSn: productSn,
|
||||
DesignSn: designSn,
|
||||
Option: option,
|
||||
Option: nil,
|
||||
IsCheck: *v.IsCheck,
|
||||
TsTime: v.TsTime.Format("2006-01-02 15:04:05"),
|
||||
PcsList: pcList,
|
||||
Size: sizeList,
|
||||
})
|
||||
Size: nil,
|
||||
}
|
||||
var sizeList types.CartSizeItem
|
||||
if sizeIndex, ok := mapProductSize[*v.SizeId]; ok {
|
||||
d.Capacity = *cartRelativeData.ProductSizeList[sizeIndex].Capacity
|
||||
err = json.Unmarshal([]byte(*cartRelativeData.ProductSizeList[sizeIndex].Title), &sizeList)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse product size`s title")
|
||||
}
|
||||
d.Size = &sizeList
|
||||
}
|
||||
if model3dIndex, ok := mapProductModel3d[*v.OptionalId]; ok {
|
||||
d.Option = &types.CartOption{
|
||||
Id: cartRelativeData.ProductModel3dList[model3dIndex].Id,
|
||||
Title: *cartRelativeData.ProductModel3dList[model3dIndex].Title,
|
||||
Price: float64(*cartRelativeData.ProductModel3dList[model3dIndex].Price) / float64(100),
|
||||
}
|
||||
}
|
||||
rspList = append(rspList, d)
|
||||
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", rspList)
|
||||
}
|
||||
@@ -138,7 +141,7 @@ type GetUserCartRelativeListRsp struct {
|
||||
}
|
||||
|
||||
// 获取阶梯对应的价格
|
||||
func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, productId int64, materialId int64, sizeId int64) (list []types.PcsItem, err error) {
|
||||
func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, productId int64, materialId int64, sizeId int64) (list []*types.PcsItem, err error) {
|
||||
for _, price := range productPriceList {
|
||||
if *price.ProductId != productId || *price.MaterialId != materialId || *price.SizeId != sizeId {
|
||||
continue
|
||||
@@ -159,7 +162,7 @@ func (l *CartListLogic) getPcList(productPriceList []gmodel.FsProductPrice, prod
|
||||
return nil, errors.New("step num or step price item count can`t be 0 ")
|
||||
}
|
||||
for int(*price.MinBuyNum) < stepNumSlice[lenStepNumSlice-1]+5 {
|
||||
list = append(list, types.PcsItem{
|
||||
list = append(list, &types.PcsItem{
|
||||
Num: *price.MinBuyNum,
|
||||
TotalNum: *price.MinBuyNum * *price.EachBoxNum,
|
||||
Title: *price.Title,
|
||||
|
||||
@@ -109,9 +109,9 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address")
|
||||
}
|
||||
//处理订单数据
|
||||
addressItems := make([]types.CartAddr, 0, len(addressList))
|
||||
addressItems := make([]*types.CartAddr, 0, len(addressList))
|
||||
for _, v := range addressList {
|
||||
addressItems = append(addressItems, types.CartAddr{
|
||||
addressItems = append(addressItems, &types.CartAddr{
|
||||
Id: v.Id,
|
||||
Name: *v.Name,
|
||||
FirstName: *v.FirstName,
|
||||
@@ -125,7 +125,7 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
|
||||
IsDefault: *v.IsDefault,
|
||||
})
|
||||
}
|
||||
items := make([]types.CartDetailItem, 0, len(orderDetailList))
|
||||
items := make([]*types.CartDetailItem, 0, len(orderDetailList))
|
||||
totalAmount := int64(0) //订单总金额
|
||||
for _, v := range orderDetailList {
|
||||
thisTotal := (*v.BuyNum) * (*v.Amount)
|
||||
@@ -140,7 +140,7 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, us
|
||||
if productIndex, ok := mapProduct[*v.ProductId]; ok {
|
||||
name = *productList[productIndex].Title
|
||||
}
|
||||
items = append(items, types.CartDetailItem{
|
||||
items = append(items, &types.CartDetailItem{
|
||||
Cover: *v.Cover,
|
||||
Pcs: *v.BuyNum,
|
||||
Amount: fmt.Sprintf("$ %.2f", float64(thisTotal)/100),
|
||||
|
||||
@@ -24,19 +24,19 @@ type CartListReq struct {
|
||||
}
|
||||
|
||||
type CartListRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Cover string `json:"cover"`
|
||||
Name string `json:"name"`
|
||||
Capacity string `json:"capacity"`
|
||||
ETA string `json:"ETA"`
|
||||
Pcs int64 `json:"pcs"`
|
||||
ProductSn string `json:"product_sn"`
|
||||
DesignSn string `json:"designSn"`
|
||||
Option CartOption `json:"option"`
|
||||
IsCheck int64 `json:"is_check"`
|
||||
TsTime string `json:"ts_time"`
|
||||
PcsList []PcsItem `json:"pcs_list"`
|
||||
Size CartSizeItem `json:"size"`
|
||||
Id int64 `json:"id"`
|
||||
Cover string `json:"cover"`
|
||||
Name string `json:"name"`
|
||||
Capacity string `json:"capacity"`
|
||||
ETA string `json:"ETA"`
|
||||
Pcs int64 `json:"pcs"`
|
||||
ProductSn string `json:"product_sn"`
|
||||
DesignSn string `json:"designSn"`
|
||||
Option *CartOption `json:"option"`
|
||||
IsCheck int64 `json:"is_check"`
|
||||
TsTime string `json:"ts_time"`
|
||||
PcsList []*PcsItem `json:"pcs_list"`
|
||||
Size *CartSizeItem `json:"size"`
|
||||
}
|
||||
|
||||
type CartOption struct {
|
||||
@@ -62,16 +62,16 @@ type CartOrderDetailReq struct {
|
||||
}
|
||||
|
||||
type CartOrderDetailRsp struct {
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
AddressId int64 `json:"address_id"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayMethod int64 `json:"pay_method"`
|
||||
PayStep int64 `json:"pay_step"`
|
||||
Subtotal string `json:"subtotal"`
|
||||
Total string `json:"total"`
|
||||
Remaining string `json:"remaining"`
|
||||
AddrList []CartAddr `json:"addr_list"`
|
||||
Items []CartDetailItem `json:"items"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
AddressId int64 `json:"address_id"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayMethod int64 `json:"pay_method"`
|
||||
PayStep int64 `json:"pay_step"`
|
||||
Subtotal string `json:"subtotal"`
|
||||
Total string `json:"total"`
|
||||
Remaining string `json:"remaining"`
|
||||
AddrList []*CartAddr `json:"addr_list"`
|
||||
Items []*CartDetailItem `json:"items"`
|
||||
}
|
||||
|
||||
type CartDetailItem struct {
|
||||
|
||||
Reference in New Issue
Block a user