Commit e82002d5 by huangchengyi

1.0

parent 430b4d83
......@@ -3,20 +3,23 @@ package main
import (
"flag"
"goods_machining/boot"
"goods_machining/service"
)
//定时任务计算系数价格
func main() {
var path string
flag.StringVar(&path, "config", "conf", "配置文件")
var mod string;
flag.StringVar(&mod, "m", "all", "请输入模块id") // 单独计算某个模块,默认计算全部,0计算全部
var goods_id string;
flag.StringVar(&goods_id, "goods_id", "", "请输入模块id") // 单独计算某个模块,默认计算全部,0计算全部
flag.Parse()
if err := boot.Boot(path); err != nil {
panic(err)
}
ZyCronService := service.ZyCronService{}
ZyCronService.ZyDiscount(goods_id)
}
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
sz_api_url = http://192.168.2.232:60004
[es]
url = http://192.168.2.232:9200
urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map
[database]
user_name = root
password = root
host = 192.168.2.239
database = test
table_prefix =
type = mysql
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize=100
[ZIYING_CACHE]
is_no_ziying_cache=true
#是否是测试环境
[IS_SZ]
is_sz = true
#自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE]
agg_table = sz_ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE]
firstLists_table = sz_ziying_first_lists
\ No newline at end of file
[gorm]
mode = debug
[spu]
user_name = spu
password = spu
host = 192.168.1.234
database = liexin_spu
table_prefix =lie_
type = mysql
[liexin_data]
user_name = spu
password = spu
host = 192.168.1.234
database = liexin_data
table_prefix =lie_
type = mysql
#线上地址
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = liexin_ass
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
table_prefix =lie_
type = mysql
[cms]
user_name = ichuntcms
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
table_prefix =
type = mysql
[DINGDING]
SEARCH_API_MONITOR = 6d0fa85e01a02c39347d011ae973fd21b76c6c7ce582d3ea470c6b65a318848d
\ No newline at end of file
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST=bom_sku_list
;联营数据更新-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_UPDATE_LIST=search_sku_update_list
;联营数据新增-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_LIST=search_sku_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST=ziying_bom_items_list
; bom更新数据队列
ZIYING_MQ_BOM_SKU_LIST=ziying_bom_sku_list
\ No newline at end of file
[default_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 2000
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 2000
idle_timeout = 20
[api_redis]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 2000
idle_timeout = 20
\ No newline at end of file
;存放本系统所有的redis键值对和解析
[redis_all]
;供应商redis的首key
SUPPLIER_REDIS_PRE=SUPPLIER_REDIS_INFO_
;需要展示的供应商列表
SUPPLIER_REDIS_LIST_PRE=SUPPLIER_REDIS_LIST_INFO_
;新增sku时判读sku是否存在
SKU_UNIQUE_JUDGE=sku_unique_judge
;新增sku时判读sku是否存在
SPU_UNIQUE_JUDGE=spu_unique_judge
;品牌信息判断,根据md5后的品牌名称获取id
BRAND_NAME_ALL=brand_name_all
;所有联营sku缓存
SKU=sku
;所有联营spu缓存
SPU=spu
;品牌id,获取品牌名称
BRAND=brand
;供应商品牌信息判断,存在多对一的情况,根据md5后的品牌名称获取标准品牌id
SUPPLIER_BRAND_ALL=supplier_brand_all
;统计调用外联接口的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_TOTAL_PRE=search_api_total_
;统计调用外联接口失败的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_ERORR_PRE=search_api_overtime_
;曝光时间记录哈希集合
SEARCH_SHOW_SKU_TIME=search_show_sku_time
;获取关税信息,根据goods_name,brand_name获取
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营外链原始映射
SKU_RAW_MAP=sku_raw_map
;digikey秘钥
digikey_access_token=digikey_access_token
;查属性id获取属性名称 ,表 lie_class_attr eg: hget("class_attr_by_id",101) = "容差"
class_attr_by_id = class_attr_by_id
;查属名称性获取属性id ,对应表 lie_class_attr eg: hget("class_attr_by_val", "容差") = 101
class_attr_by_val=class_attr_by_val
;查 参数值id 获取 参数值,表lie_class_attr_value eg: hget("class_attr_value_by_id",65) = "1.8W"
class_attr_value_by_id=class_attr_value_by_id
;查 参数值 获取 参数id,表lie_class_attr_value eg: hget("class_attr_value_by_val", "1.8W") = 65
class_attr_value_by_val=class_attr_value_by_val
[redis_ziyin]
AGG_TABLE=sz_ziying_class_aggs
FIRST_LISTS_TABLE=ziying_first_lists
ZIYING_CLASS_KEY=ziying_class_string
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营所有sku
SKU=sku
;存放联营所有spu
SPU=SPU
;存放digikey 型号映射
SKU_RAW_MAP=sku_raw_map
POOL_ALIKE_GOODS=pool_alike_goods
[blacklist_type]
1 = invoice
2 = special_invoice
3 = user_id
4 = mobile
5 = email
\ No newline at end of file
......@@ -100,5 +100,10 @@ func Synchronization(ctx *gin.Context) {
common.Output(ctx,0,"查询成功",temp)
}
/*
健康监测
*/
func Health(ctx *gin.Context) {
ctx.String(200,"ok")
}
package mongo
import (
"fmt"
"gopkg.in/mgo.v2"
"goods_machining/pkg/config"
"gopkg.in/mgo.v2"
"strconv"
)
......@@ -30,8 +29,8 @@ func getconn(mongoConfig config.MongoDbDatabase) (*mgo.Session ,error){
if err != nil {
return nil ,err
}
fmt.Println("url",url)
fmt.Println("maxPoolSizeInt",maxPoolSizeInt)
//fmt.Println("url",url)
//fmt.Println("maxPoolSizeInt",maxPoolSizeInt)
session.SetPoolLimit(maxPoolSizeInt)
session.SetMode(mgo.Monotonic, true)
myDB :=session.DB(mongoConfig.Database)
......
......@@ -16,5 +16,9 @@ func InitRouter() *gin.Engine {
r.GET("synchronization", controller.Synchronization)
r.POST("synchronization",controller.Synchronization)
//心跳
r.GET("Health", controller.Health)
r.POST("Health",controller.Health)
return r
}
......@@ -25,7 +25,6 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
var (
i int
goodsIdTemp string
dbSpu = mysql.Conn("liexin_data") //spu实例化链接
redisConn = gredis.Conn("search_r")
)
......@@ -45,24 +44,24 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
start = (i-1)*page_size
}
sql := "select goods_id,class_id,brand_id,cost,ladder_price from lie_goods where self_supplier_type = 1 and stock >0 and status=1 limit "+common.MyIntToStr(page_size)+","+common.MyIntToStr(start);
sql := "select goods_id,class_id2,brand_id,cost,ladder_price from lie_goods where self_supplier_type = 1 and stock >0 and status=1 limit "+common.MyIntToStr(page_size)+","+common.MyIntToStr(start);
if checkGoodsId != "" {
sql = "select goods_id,class_id,brand_id,cost,ladder_price from lie_goods where self_supplier_type = 1 and stock >0 and status=1 limit "+checkGoodsId;
sql = "select goods_id,class_id2,brand_id,cost,ladder_price from lie_goods where goods_id="+checkGoodsId;
}
goodsInfos, err := dbSpu.QueryString(sql)
if err != nil || len(goodsInfos) == 0{
fmt.Print("查询没有数据")
fmt.Print("查询没有数据",err)
break;
}
for _,a := range goodsInfos{
now_goods_id := a["goods_id"]
now_class_id := a["class_id"]
now_class_id := a["class_id2"]
now_brand_id := a["brand_id"]
/********开始计算系数******/
fmt.Println("开始计算系数"+goodsIdTemp)
fmt.Println("开始计算系数"+now_goods_id)
goodsBatch,_ := gredis.String(redisConn.Do("HGET","Self_goods_batch",now_goods_id)) //获取商品批次信息
apiGoodsList := gjson.Get(goodsBatch, "dc_time").Array()
apiGoodsList := gjson.Get("{\"Parts\":"+goodsBatch+"}", "Parts").Array()
var EarlyBatchTime int64 = 0; //最早的批次
for _, goods := range apiGoodsList {
......@@ -78,7 +77,7 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
if EarlyBatchTime == 0 {
fmt.Println("没有批次信息,goods_id :"+now_goods_id)
continue;
break;
}
//查询所有的系数列表
ratioAll, _ := redis.Values(redisConn.Do("hgetall", "Self_goods_ratio"))
......@@ -124,12 +123,14 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
//不参与分类的商品
if info["class_id"] != "" {
if php2go.Stripos(info["class_id"],","+now_class_id+",",0) > -1 {
fmt.Println("1002 不参与分类的商品"+now_goods_id)
continue;
}
}
//不参与分类的商品
if info["brand_id"] != "" {
if php2go.Stripos(info["class_id"],","+now_brand_id+",",0) > -1 {
if php2go.Stripos(info["brand_id"],","+now_brand_id+",",0) > -1 {
fmt.Println("1003 不参与分类的商品"+now_goods_id)
continue;
}
}
......@@ -155,13 +156,19 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
}
}
fmt.Print(EarlyBatchTime,"<br/>")
fmt.Print(twoYearsAgotime,"<br/>")
if isExpire == false {
fmt.Println("1001 本商品不存在过期"+now_goods_id)
fmt.Println("1001 本商品不存在过期"+now_goods_id,info)
continue;
}
//处理清库存系数,几个系数符合,往下面算
var ratioPrice float64;
ratioPrice = common.MyFloat64(a["cost"]) * common.MyFloat64(info["ratio"])
fmt.Print(ratioPrice,"<br/>")
//查询立创数据
szlcPriceStr,_ := gredis.String(redisConn.Do("HGET","Self_szlc_price",now_goods_id)) //获取立创价格
if szlcPriceStr != "" { //有立创的价格
......@@ -216,6 +223,11 @@ func (a *ZyCronService) ZyDiscount(checkGoodsId string) {
break OuterLoop; //只跑一个跳出所有循环
}
}
if checkGoodsId != "" {
break;
}
}
fmt.Print("计算完毕")
......
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