Commit 3b851ac0 by 杨树贤

temp

parent cd4c7fbe
......@@ -20,4 +20,4 @@ cmd.exe~
/doc/test3
/.history
/.vscode
.codeiumignore
......@@ -69,4 +69,5 @@ type ActivityCheckData struct {
GoodsId string
Canal string
ClassId int
OrgId int
}
......@@ -24,8 +24,16 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
supplierId := checkData.SupplierId
redisCon := gredis.Conn("default_r")
defer redisCon.Close()
var redisKey string
//区分猎芯和华云
if checkData.OrgId == 1 {
redisKey = gconv.String(supplierId)
} else {
redisKey = gconv.String(supplierId) + "_" + gconv.String(checkData.OrgId)
}
//处理单品促销活动(打折活动)
activityStr, _ := redis.String(redisCon.Do("hget", "lie_price_activity", supplierId))
activityStr, _ := redis.String(redisCon.Do("hget", "lie_price_activity", redisKey))
if activityStr != "" {
var activities []model.Activity
err := json.Unmarshal([]byte(activityStr), &activities)
......
......@@ -7,11 +7,12 @@ import (
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"go_sku_server/service/sorter"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"sort"
"sync"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
......@@ -143,7 +144,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.BrandPack = brandPack
}
//获取供应链标准品牌
//什么是供应链的标准品牌 供应链那边报关的时候要求他们的标准品牌,所以要吧自己的品牌映射上去
//继来那边对接的标准品牌(下单的时候)
......@@ -161,9 +161,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.AcType = 0
sku.AllowCoupon = 1
//这里获取活动价格和活动类型
sku = ls.GetActivity(sku)
//最小起订量要大于阶梯价的最小阶梯数量
if len(sku.LadderPrice) > 0 {
//排序
......@@ -174,7 +171,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku.Moq = purchases
}
}
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断,如果是爱智,不需要走价格体系
//这里获取活动价格和活动类型(折扣打折活动)
sku = ls.GetActivity(sku)
priceService := PriceService{}
//这里又有一个判断,如果是非猎芯的,目前只有爱智,通过org_id来判断
//1是猎芯,3是爱智
switch sku.OrgId {
//case为0是为了兼容价格体系之前的价格
......@@ -188,6 +190,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取自定义价格后的阶梯价
customPriceService := CustomPrice{}
sku.CustomPriceList, _ = customPriceService.getCustomPriceList(sku)
sku = priceService.GetActivityPrice(sku)
}
case 3:
//如果是寄售的,不走价格体系
......@@ -202,7 +205,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if (sku.OrgId == 3 && len(sku.LadderPrice) == 2 && sku.LadderPrice[0].Purchases != 0) ||
(sku.OrgId == 3 && len(sku.LadderPrice) == 3 && sku.LadderPrice[0].Purchases == 0) ||
(sku.OrgId == 3 && len(sku.LadderPrice) == 4 && sku.LadderPrice[0].Purchases == 0) {
priceService := PriceService{}
sku.LadderPrice = priceService.GetIEdgePrice(sku.LadderPrice)
} else {
//判断是不是华云的,如果是的话,还要判断是不是有成本价和销售限价,如果是的话,要把销售限价去掉,因为走的价格体系的前提是有成本价的时候
......@@ -220,11 +222,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
if sku.OrgId == 3 {
sku.LadderPrice = customPriceService.transformIEdgeLadderPrice(sku)
}
}
break
default:
break
sku = priceService.GetActivityPrice(sku)
}
//仅提供价格和库存
......@@ -256,6 +255,9 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//判断是否可以购买
sku.IsBuy = ls.GetIsBuy(sku)
if sku.IsBuy ==0 && sku.OrgId != 1 {
sku.AcType = 0;
}
sku.Stock = ls.GetStock(sku)
......@@ -287,6 +289,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
Canal: sku.Canal,
GoodsName: sku.GoodsName,
ClassId: sku.ClassID2,
OrgId: sku.OrgId,
}
var activityService ActivityService
priceActivity, giftActivity := activityService.GetActivityData(checkData)
......@@ -352,7 +355,7 @@ func (ls *LyService) GetSpuExtra(spuId string) (spuExtra model.SpuExtra) {
} `bson:"image_list" json:"old_image_list"`
}
var oldSpuExtra OldSpuExtra
err = mongodb.DB("ichunt").C("spu_extra").Find(bson.M{"spu_id": spuId}).One(&oldSpuExtra)
mongodb.DB("ichunt").C("spu_extra").Find(bson.M{"spu_id": spuId}).One(&oldSpuExtra)
for _, image := range oldSpuExtra.OldImageList {
spuExtra.ImageList = append(spuExtra.ImageList, struct {
......
......@@ -2,20 +2,21 @@ package service
import (
"encoding/json"
"github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model"
c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
_ "go_sku_server/pkg/mongo"
"go_sku_server/service/sorter"
_ "gopkg.in/mgo.v2/bson"
"sort"
"strconv"
"strings"
"github.com/gomodule/redigo/redis"
_ "github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
_ "gopkg.in/mgo.v2/bson"
)
// 获取图片信息
......@@ -290,11 +291,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//没有阶梯价格,直接跳过
if len(sku.LadderPrice) == 0 {
//sku.Original = nil
return sku
}
priceService := PriceService{}
flag := 0
var data []model.LadderPrice
var originalPrice []model.OriginPrice
sort.Sort(sorter.OriginPriceSorter(sku.OriginalPrice))
......@@ -322,15 +321,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data[key].Purchases = price.Purchases
//下面的价格,还要乘于折扣系数
if price.PriceUs != 0 {
priceUs := c.MyRound(price.PriceUs, 4)
priceUs = c.MyRound(c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd), 4)
priceUs := c.MyRound(c.MulFloat(price.PriceUs, sku.DiscountRatio.RatioUsd), 4)
data[key].PriceUs = priceUs
price.PriceUs = priceUs
}
if price.PriceCn != 0 {
priceCn := c.MyRound(price.PriceCn, 4)
priceCn = c.MyRound(c.MulFloat(price.PriceCn, sku.DiscountRatio.Ratio), 4)
priceCn := c.MyRound(c.MulFloat(price.PriceCn, sku.DiscountRatio.Ratio), 4)
data[key].PriceCn = priceCn
price.PriceCn = priceCn
}
......@@ -338,32 +335,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//专卖成本价
data[key].PriceCostUs = price.PriceCostUs
data[key].PriceCostCn = price.PriceCostCn
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
//价格与原价一样
if data[key].PriceCn == tempAcPrice && key < 2 {
//flag++
//if flag >= 2 || (len(ladderPrice) < 2) {
// sku.AcType = 0
// continue
//}
}
data[key].PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
data[key].PriceAcUs = priceAcUs
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 && priceAcUs <= 0 {
sku.AcType = 0
}
}
}
} else {
data = make([]model.LadderPrice, len(sku.LadderPrice))
......@@ -513,40 +484,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
RatioUsd: priceRatio.RatioUsd,
})
sku.PriceRatio = showPriceRatioList
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
priceAc := c.MyRound(c.MulFloat(data[key].PriceCn, (sku.Ratio/100)), 4)
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if data[key].PriceCn == priceAc && key < 2 {
flag++
}
data[key].PriceAc = priceAc
var priceAcUs float64
if sku.RatioUs > 0 {
priceAcUs = c.MyRound(c.MulFloat(data[key].PriceUs, (sku.RatioUs/100)), 4)
data[key].PriceAcUs = priceAcUs
}
if priceAc <= 0 && priceAcUs <= 0 {
sku.AcType = 0
break
} else {
if sku.AcType == 4 {
data[key].PriceCn = priceAc
sku.AcType = 0
}
}
}
}
//判断原始价格有变化,那就要覆盖
if len(originalPrice) > 0 {
......
package service
import (
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"go_sku_server/model"
c "go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
......@@ -12,6 +8,11 @@ import (
"sort"
"strconv"
"strings"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
)
type PriceService struct {
......@@ -775,3 +776,78 @@ func (ps *PriceService) GetIEdgePrice(ladderPrice []model.LadderPrice) []model.L
return ladderPrice
}
// 单独拎出来处理活动价
func (ps *PriceService) GetActivityPrice(sku model.LySku) model.LySku {
if len(sku.LadderPrice) == 0 {
return sku
}
if sku.SupplierId == 17 {
for index, price := range sku.LadderPrice {
//联营或者专卖 同时 存在活动价格
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
tempAcPrice := c.MyRound(c.MulFloat(price.PriceCn, sku.Ratio/100), 4)
//价格与原价一样
if price.PriceCn == tempAcPrice && index < 2 {
//flag++
//if flag >= 2 || (len(ladderPrice) < 2) {
// sku.AcType = 0
// continue
//}
}
price.PriceAc = tempAcPrice
priceAcUs := c.MyRound(c.MulFloat(price.PriceUs, sku.RatioUs/100), 4)
price.PriceAcUs = priceAcUs
sku.LadderPrice[index].PriceAc = tempAcPrice
sku.LadderPrice[index].PriceAcUs = priceAcUs
//优惠价后等于0,就代表没有搞活动
if tempAcPrice <= 0 && priceAcUs <= 0 {
sku.AcType = 0
}
}
}
} else {
for index, price := range sku.LadderPrice {
//处理活动价和原价相同的情况
if (sku.GoodsType == 1 || sku.GoodsType == 2 || sku.GoodsType == 6) && sku.AcType > 1 && sku.Ratio > 0 {
if sku.Ratio == 100 {
//sku.AcType = 0
//continue
}
priceAc := c.MyRound(c.MulFloat(price.PriceCn, (sku.Ratio/100)), 4)
//为什么$kp < 2,如果第一阶梯或第二阶梯价格和活动价一样,就不输出活动价了
//活动价都是有样式的和平时不一样,如果价格一样,但是样子是活动价,客户会迷惑,所以不输出即可,保持原来的样式
if price.PriceCn == priceAc && index < 2 {
// flag++
}
sku.LadderPrice[index].PriceAc = priceAc
var priceAcUs float64
if sku.RatioUs > 0 {
priceAcUs = c.MyRound(c.MulFloat(price.PriceUs, (sku.RatioUs/100)), 4)
sku.LadderPrice[index].PriceAcUs = priceAcUs
}
if priceAc <= 0 && priceAcUs <= 0 {
sku.AcType = 0
break
} else {
if sku.AcType == 4 {
sku.LadderPrice[index].PriceCn = priceAc
sku.AcType = 0
}
}
}
}
}
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