Commit 62482bda by huangchengyi

1.0

parent 9652ae21
......@@ -10,7 +10,7 @@ import (
)
const goods_slice_count = 1 //每多少个型号id开启一个协程
const goods_slice_count = 10 //每多少个型号id开启一个协程
/*
查询商品详情(自营或者联营)
......@@ -94,4 +94,3 @@ func Synchronization(c *gin.Context) {
package service
import (
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
"github.com/tidwall/gjson"
......@@ -14,16 +13,31 @@ type ZiyingService struct {
/*
自营数据详情
查询商品详情(自营或者联营)
@doc http://192.168.2.232:3000/project/128/interface/api/649
@param goods_id 支持批量,不建议超过40个,超过会导致处理时间超过2秒,进程异常 : 74564,65897,456464131
@param power[newCustomer] 是否获取新客价 :true
@param power[member] 是否获取会员价 :true
@param power[mobile] 获取会员价时,用户有手机号时必填,用于会员价可见名单。活动价时必须,否则可能导致用户无法享受活动价 :13510507993
@param power[email] 获取会员价时,用户有邮箱时必填,用于会员价可见名单。活动价时必须,否则可能导致用户无法享受活动价 ymx@ichunt.com
@param power[user_id] 获取会员价时,必填,用于会员价可见名单。活动价时必须,否则可能导致用户无法享受活动价,如果用户未登录,可为空,用户是否可见活动价取决于配置 65139
@param power[fast] 仅获取价格与库存 :1
@param power[invoice] 增值税普通发票公司名字,活动价时必须,否则可能导致用户无法享受活动价 :深圳是猎芯科技有限公司
@param power[special_invoice] 增值税专用发票公司名字,活动价时需要,否则可能导致用户无法享受活动价 : 深圳是猎芯科技有限公司
@param power[verify_blacklist] 是否验证黑名单,用于折扣活动提交订单页面与后台下单 :true
*/
func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]interface{}, wg *sync.WaitGroup) {
defer wg.Done();
//redisConn := gredis.Conn("search_r")
/////批量获取商品详情
skuArr := gredis.HgetPi("search_r","Self_SelfGoods",goodsIds)
fmt.Print(skuArr)
for goods_id,info := range skuArr {
redisConn := gredis.Conn("search_r")
defer func() {
wg.Done();
redisConn.Close();
}()
skuArr := gredis.HgetPi("search_r","Self_SelfGoods",goodsIds) //批量获取商品详情
for goods_id,info := range skuArr {
A := orderedmap.New() //初始化有序map,拼接data 数据
A.Set("goods_id",goods_id)
......@@ -33,7 +47,7 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
A.Set("class_id1", gjson.Get(info, "class_id1").String()) //
A.Set("class_id2", gjson.Get(info, "class_id2").String()) //
A.Set("goods_name", gjson.Get(info, "goods_name").String()) //
A.Set("status", gjson.Get(info, "status").String()) //
A.Set("status", gjson.Get(info, "status").Int()) //
A.Set("encoded", gjson.Get(info, "encoded").String()) //
A.Set("encap", gjson.Get(info, "encap").String()) //
A.Set("packing", gjson.Get(info, "packing").String()) //
......@@ -53,10 +67,31 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
A.Set("new_cost", gjson.Get(info, "new_cost").String()) //
A.Set("supplier_stock", gjson.Get(info, "supplier_stock").String()) //
A.Set("self_supplier_type", gjson.Get(info, "self_supplier_type").String()) //
A.Set("cn_delivery_time", gjson.Get(info, "cn_delivery_time").String()) //
//处理货期
cn_delivery_time := gjson.Get(info, "cn_delivery_time").String()
if cn_delivery_time == "" {
cn_delivery_time = "3-7工作日";
}
A.Set("cn_delivery_time", cn_delivery_time) // 货期
A.Set("brand_name", gjson.Get(info, "brand_name").String()) //
A.Set("supplier_name", gjson.Get(info, "supplier_name").String()) //
A.Set("goods_unit_name", gjson.Get(info, "goods_unit_name").String()) //
// 供应商名称
supplier_id := gjson.Get(info, "supplier_id").String()
supplier_name := ""
if supplier_id != "" {
supplier_name,_ = gredis.String(redisConn.Do("HGET","Self_SelfSupplierInfo",supplier_id))
}
A.Set("supplier_name", supplier_name)
// 供应商名称
goods_unit := gjson.Get(info, "goods_unit").String()
goods_unit_name := ""
if goods_unit_name != "" {
goods_unit_name,_ = gredis.String(redisConn.Do("HGET","Self_Unit",goods_unit))
}
A.Set("goods_unit_name", goods_unit_name) //
A.Set("packing_name", gjson.Get(info, "packing_name").String()) //
A.Set("mpq_unit_name", gjson.Get(info, "mpq_unit_name").String()) //
A.Set("scm_brand_name", gjson.Get(info, "scm_brand_name").String()) //
......@@ -66,6 +101,8 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
A.Set("allow_presale", gjson.Get(info, "allow_presale").String()) //
A.Set("saler_atio", gjson.Get(info, "saler_atio").String()) //
A.Set("szlc_price", gjson.Get(info, "szlc_price").String()) //
A.Set("class_id1_name", gjson.Get(info, "class_id1_name").String()) //
A.Set("class_id2_name", gjson.Get(info, "class_id2_name").String()) //
A.Set("is_buy", gjson.Get(info, "is_buy").String()) //
......
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