Commit 6616cd53 by mushishixian

临时禁止TI购买商品

parent 685089af
Showing with 216 additions and 212 deletions
package service package service
import ( import (
"fmt" "fmt"
"github.com/gin-gonic/gin" "go_sku_server/model"
"github.com/gogf/gf/util/gconv" "go_sku_server/pkg/gredis"
"github.com/gomodule/redigo/redis" "go_sku_server/service/sorter"
"github.com/syyongx/php2go" "sort"
"github.com/tidwall/gjson" "sync"
"go_sku_server/model"
"go_sku_server/pkg/gredis" "github.com/gin-gonic/gin"
"go_sku_server/service/sorter" "github.com/gogf/gf/util/gconv"
"sort" "github.com/gomodule/redigo/redis"
"sync" "github.com/syyongx/php2go"
) "github.com/tidwall/gjson"
)
type LyService struct {
} type LyService struct {
}
type Power struct {
UserId string `json:"user_id"` type Power struct {
Mobile string `json:"mobile"` UserId string `json:"user_id"`
Email string `json:"email"` Mobile string `json:"mobile"`
Member string `json:"member"` Email string `json:"email"`
VerifyBlacklist string `json:"verify_blacklist"` Member string `json:"member"`
Invoice string `json:"invoice"` VerifyBlacklist string `json:"verify_blacklist"`
SpecialInvoice string `json:"special_invoice"` Invoice string `json:"invoice"`
} SpecialInvoice string `json:"special_invoice"`
}
/*
联营数据详情 /*
*/ 联营数据详情
func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) { */
redisConn := gredis.Conn("search_r") func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan sync.Map) {
defer func() { redisConn := gredis.Conn("search_r")
redisConn.Close() defer func() {
}() redisConn.Close()
fast := ctx.Request.FormValue("power[fast]") }()
showAttr := ctx.Request.FormValue("show_attr") fast := ctx.Request.FormValue("power[fast]")
//批量获取商品详情 showAttr := ctx.Request.FormValue("show_attr")
skuArr := gredis.Hmget("default_r", "sku", goodsIds) //批量获取商品详情
//为了性能着想,这边也先去批量获取spu的信息 skuArr := gredis.Hmget("default_r", "sku", goodsIds)
var spuService SpuService //为了性能着想,这边也先去批量获取spu的信息
spuList := spuService.getSpuList(skuArr) var spuService SpuService
spuList := spuService.getSpuList(skuArr)
GoodsRes := sync.Map{}
for goodsId, skuStr := range skuArr { GoodsRes := sync.Map{}
if skuStr == "" { for goodsId, skuStr := range skuArr {
GoodsRes.Store(goodsId, false) if skuStr == "" {
continue GoodsRes.Store(goodsId, false)
} continue
//初始化有序map,拼接data 数据 }
sku := model.InitSkuData(skuStr) //初始化有序map,拼接data 数据
sku.GoodsId = goodsId sku := model.InitSkuData(skuStr)
spu := spuList[sku.SpuId] sku.GoodsId = goodsId
//读取包装字段的缓存 spu := spuList[sku.SpuId]
if sku.SupplierId == 7 { //读取包装字段的缓存
//sku_raw_map哪里写入(成意写的) if sku.SupplierId == 7 {
packing, _ := redis.String(redisConn.Do("HGET", "sku_raw_map", goodsId)) //sku_raw_map哪里写入(成意写的)
sku.Packing = gjson.Get(packing, "pack").String() packing, _ := redis.String(redisConn.Do("HGET", "sku_raw_map", goodsId))
} sku.Packing = gjson.Get(packing, "pack").String()
sku = ls.GetGoodsImages(sku, spu) }
//pdf sku = ls.GetGoodsImages(sku, spu)
pdf := gjson.Get(spu, "pdf").String() //pdf
spuLargeImage := gjson.Get(spu, "images_l").String() pdf := gjson.Get(spu, "pdf").String()
if pdf == "" || (php2go.Strlen(spuLargeImage) < 5) { spuLargeImage := gjson.Get(spu, "images_l").String()
sku.Pdf = "" if pdf == "" || (php2go.Strlen(spuLargeImage) < 5) {
} else { sku.Pdf = ""
sku.Pdf = pdf } else {
} sku.Pdf = pdf
}
//处理分类
//fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数 //处理分类
if fast != "1" { //fast的参数含义,为了节省开销性能的参数,传1就不会去分类这些参数
sku = ls.GetGoodsClass(sku, spu) if fast != "1" {
} sku = ls.GetGoodsClass(sku, spu)
}
//获取商品名称
if sku.GoodsName == "" { //获取商品名称
sku.GoodsName = gjson.Get(spu, "spu_name").String() if sku.GoodsName == "" {
} sku.GoodsName = gjson.Get(spu, "spu_name").String()
}
//获取品牌名称
brandId := gjson.Get(spu, "brand_id").Int() //获取品牌名称
brandName, _ := redis.String(redisConn.Do("HGET", "brand", brandId)) brandId := gjson.Get(spu, "brand_id").Int()
sku.BrandName = brandName brandName, _ := redis.String(redisConn.Do("HGET", "brand", brandId))
fmt.Println(showAttr) sku.BrandName = brandName
//获取税务信息 fmt.Println(showAttr)
if fast != "1" { //仅提供价格和库存 //获取税务信息
if sku.GoodsName != "" && brandId != 0 { if fast != "1" { //仅提供价格和库存
sku.ErpTax = ls.GetErpTax(sku.GoodsName, brandName) if sku.GoodsName != "" && brandId != 0 {
} sku.ErpTax = ls.GetErpTax(sku.GoodsName, brandName)
sku.SupplierName = ls.GetPoolSupplierName(sku.SupplierId) }
if showAttr == "1" { sku.SupplierName = ls.GetPoolSupplierName(sku.SupplierId)
//获取属性 if showAttr == "1" {
sku.Attrs = ls.GetSpuAttr(sku.SpuId) //获取属性
} sku.Attrs = ls.GetSpuAttr(sku.SpuId)
if sku.Attrs == nil { }
sku.Attrs = []interface{}{} if sku.Attrs == nil {
} sku.Attrs = []interface{}{}
} }
}
//获取供应链标准品牌
//获取供应链标准品牌 //什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去
//什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去 //继来那边对接的标准品牌(下单的时候)
//继来那边对接的标准品牌(下单的时候) sku.ScmBrand = ls.GetScmBrand(brandId)
sku.ScmBrand = ls.GetScmBrand(brandId)
//获取新版的标准品牌
//获取新版的标准品牌 sku.StandardBrand = ls.GetStandardBrand(brandId)
sku.StandardBrand = ls.GetStandardBrand(brandId)
//处理过期
//处理过期 if gjson.Get(skuStr, "is_expire").Int() != 0 {
if gjson.Get(skuStr, "is_expire").Int() != 0 { sku.LadderPrice = nil
sku.LadderPrice = nil }
}
//处理活动
//处理活动 sku.AcType = 0
sku.AcType = 0 sku.AllowCoupon = 1
sku.AllowCoupon = 1 sku.BrandId = brandId
sku.BrandId = brandId
sku = ls.GetActivity(sku)
sku = ls.GetActivity(sku)
//处理阶梯价数据
//处理阶梯价数据 if len(sku.LadderPrice) > 0 {
if len(sku.LadderPrice) > 0 { //排序
//排序 sort.Sort(sorter.LadderPriceSorter(sku.LadderPrice))
sort.Sort(sorter.LadderPriceSorter(sku.LadderPrice)) //取出第一个阶梯价
//取出第一个阶梯价 purchases := sku.LadderPrice[0].Purchases
purchases := sku.LadderPrice[0].Purchases if purchases > sku.Moq {
if purchases > sku.Moq { sku.Moq = purchases
sku.Moq = purchases }
} }
} //获取系数
//获取系数 sku = ls.GetCoefficient(sku)
sku = ls.GetCoefficient(sku)
//仅提供价格和库存
//仅提供价格和库存 if fast != "1" {
if fast != "1" { if sku.SupplierId != 0 {
if sku.SupplierId != 0 { sku.SuppExtendFee = ls.GetExtendFee(sku.SupplierId, sku.Canal)
sku.SuppExtendFee = ls.GetExtendFee(sku.SupplierId, sku.Canal) }
} //还要处理货期
//还要处理货期 delivery := ls.GetDelivery(sku.SupplierId, sku.Canal)
delivery := ls.GetDelivery(sku.SupplierId, sku.Canal) if delivery["cn_delivery"] != "" {
if delivery["cn_delivery"] != "" { sku.CnDeliveryTime = delivery["cn_delivery"]
sku.CnDeliveryTime = delivery["cn_delivery"] }
} if delivery["hk_delivery"] != "" {
if delivery["hk_delivery"] != "" { sku.HkDeliveryTime = delivery["hk_delivery"]
sku.HkDeliveryTime = delivery["hk_delivery"] }
} }
}
//处理是否可以购买
//处理是否可以购买 if sku.Mpq == 0 {
if sku.Mpq == 0 { sku.Mpq = 1
sku.Mpq = 1 }
}
if len(sku.LadderPrice) > 0 {
if len(sku.LadderPrice) > 0 { sku.LadderPriceResult = sku.LadderPrice
sku.LadderPriceResult = sku.LadderPrice } else {
} else { sku.LadderPriceResult = []int{}
sku.LadderPriceResult = []int{} }
}
//这边有个临时逻辑,如果供应商id是TI的,就库存为0
//判断是否可以购买 if sku.SupplierId == 1679 {
sku.IsBuy = ls.GetIsBuy(sku) sku.Stock = 0
}
////过期修改库存为0
//if sku.IsExpire == 1 { //判断是否可以购买
// sku.Stock = 0 sku.IsBuy = ls.GetIsBuy(sku)
//}
////过期修改库存为0
var TagService TagsService //if sku.IsExpire == 1 {
sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0) // sku.Stock = 0
//}
//用spuInfo补全信息
sku = ls.CombineSup(sku, spu) var TagService TagsService
//最后一步,将sku的全部信息放到有序map里面 sku.GoodsTag = TagService.GetTags(sku.GoodsId, 0)
GoodsRes.Store(goodsId, sku)
//(*goodsRes)[goodsId] = A //用spuInfo补全信息
sku = ls.CombineSup(sku, spu)
} //最后一步,将sku的全部信息放到有序map里面
ch <- GoodsRes GoodsRes.Store(goodsId, sku)
} //(*goodsRes)[goodsId] = A
//获取活动 }
func (ls *LyService) GetActivity(sku model.LySku) model.LySku { ch <- GoodsRes
//去判断是否有活动(促销打折活动和满赠活动) }
checkData := model.ActivityCheckData{
SupplierId: int(sku.SupplierId), //获取活动
BrandId: int(sku.BrandId), func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
GoodsId: sku.GoodsId, //去判断是否有活动(促销打折活动和满赠活动)
Canal: sku.Canal, checkData := model.ActivityCheckData{
ClassId: sku.ClassID2, SupplierId: int(sku.SupplierId),
} BrandId: int(sku.BrandId),
var activityService ActivityService GoodsId: sku.GoodsId,
priceActivity, giftActivity := activityService.GetActivityData(checkData) Canal: sku.Canal,
if priceActivity.HasActivity { ClassId: sku.ClassID2,
sku.AcType = 10 }
sku.Ratio = priceActivity.Ratio var activityService ActivityService
sku.ActivityInfo = priceActivity priceActivity, giftActivity := activityService.GetActivityData(checkData)
} if priceActivity.HasActivity {
if giftActivity.HasActivity { sku.AcType = 10
sku.HasGiftActivity = gconv.Int(giftActivity.HasActivity) sku.Ratio = priceActivity.Ratio
sku.GiftActivity = giftActivity sku.ActivityInfo = priceActivity
} }
if giftActivity.HasActivity {
//获取是否能使用优惠券 sku.HasGiftActivity = gconv.Int(giftActivity.HasActivity)
if giftActivity.AllowCoupon == 2 || priceActivity.AllowCoupon == 2 { sku.GiftActivity = giftActivity
sku.AllowCoupon = 2 }
}
return sku //获取是否能使用优惠券
} if giftActivity.AllowCoupon == 2 || priceActivity.AllowCoupon == 2 {
sku.AllowCoupon = 2
}
return sku
}
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