Commit f81ca555 by huangchengyi

1.0

parent 60c30781
......@@ -2,9 +2,6 @@ package main
import (
"github.com/micro/go-micro/v2"
"goods_machining/protopb/bom"
"goods_machining/service"
"log"
)
......@@ -13,12 +10,4 @@ func main() {
micro.Name("go.micro.grpc.search"))
cService.Init()
err:=bom.RegisterBomServiceHandler(cService.Server(),service.NewBomServiceImpl())
if err!=nil{
log.Fatal(err)
}
if err = cService.Run(); err != nil {
log.Println(err)
}
}
\ No newline at end of file
[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
[redis]
write_host = 192.168.1.235:6379
read_host = 192.168.1.235:6379
write_password = icDb29mLy2s
read_password = icDb29mLy2s
max_idle = 10
max_active = 10
idle_timeout = 20
[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 = 500
max_active = 1000
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 500
max_active = 2000
idle_timeout = 20
[api_redis]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 500
max_active = 1000
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
......@@ -3,7 +3,6 @@ package controller
import (
"github.com/gin-gonic/gin"
"github.com/syyongx/php2go"
"goods_machining/middleware"
"goods_machining/pkg/common"
"goods_machining/service"
"sync"
......@@ -29,22 +28,23 @@ const goods_slice_count = 10 //每多少个型号id开启一个协程
*/
func Synchronization(c *gin.Context) {
common.PrintDebugHeader() //开启debug调试
func Synchronization(ctx *gin.Context) {
common.PrintDebugHeader(ctx) //开启debug调试
zyService := service.ZiyingService{} //实例化自营查询
lyService := service.LyService{} //实例化自营查询
//抽取自营 或者联营 goods_id
GoodsIdStr := middleware.REQUEST["goods_id"]
GoodsIdStr := ctx.Request.FormValue("goods_id")
if GoodsIdStr == "" {
common.Output(1001,"查询型号ID不得为空","")
common.Output(ctx,1001,"查询型号ID不得为空","")
return
}
GoodsRes := make(map[string]interface{}, 0) //接收算好的数据
goodsIdArr := php2go.Explode(",",GoodsIdStr)
GoodsRes := sync.Map{}
wg := sync.WaitGroup{}
goodsIdArr := php2go.Explode(",",GoodsIdStr)
wg := sync.WaitGroup{} //协程
zyGoodsId := make([]string,0)
lyGoodsId := make([]string,0)
......@@ -53,18 +53,18 @@ func Synchronization(c *gin.Context) {
zyGoodsId = append(zyGoodsId,goods_id)
if len(zyGoodsId) >= goods_slice_count {
common.PrintDebugHtml("zy增加协程:")
common.PrintDebugHtml(zyGoodsId)
common.PrintDebugHtml(ctx,"zy增加协程:")
common.PrintDebugHtml(ctx,zyGoodsId)
wg.Add(1) //协程计数一
go zyService.ZyGoodsDetail(zyGoodsId,&GoodsRes,&wg)
go zyService.ZyGoodsDetail(ctx,zyGoodsId,&GoodsRes,&wg)
zyGoodsId = zyGoodsId[:0:0]
}
}else{ //联营
lyGoodsId = append(lyGoodsId,goods_id)
if len(lyGoodsId) >= goods_slice_count {
common.PrintDebugHtml("ly增加协程:")
common.PrintDebugHtml(zyGoodsId)
common.PrintDebugHtml(ctx,"ly增加协程:")
common.PrintDebugHtml(ctx,zyGoodsId)
wg.Add(1)
go lyService.LyGoodsDetail(lyGoodsId,&wg)
......@@ -74,22 +74,30 @@ func Synchronization(c *gin.Context) {
}
if len(zyGoodsId) >0 {
common.PrintDebugHtml("zy增加协程:")
common.PrintDebugHtml(zyGoodsId)
common.PrintDebugHtml(ctx,"zy增加协程:")
common.PrintDebugHtml(ctx,zyGoodsId)
wg.Add(1) //协程计数一
go zyService.ZyGoodsDetail(zyGoodsId,&GoodsRes,&wg)
go zyService.ZyGoodsDetail(ctx,zyGoodsId,&GoodsRes,&wg)
}
if len(lyGoodsId) >= goods_slice_count {
common.PrintDebugHtml("ly增加协程:")
common.PrintDebugHtml(zyGoodsId)
common.PrintDebugHtml(ctx,"ly增加协程:")
common.PrintDebugHtml(ctx,zyGoodsId)
wg.Add(1)
go lyService.LyGoodsDetail(lyGoodsId,&wg)
}
wg.Wait()
common.Output(0,"查询成功",GoodsRes)
//异步map最后转成map
temp := make(map[string]interface{})
GoodsRes.Range(func(k, v interface{}) bool {
s,_ := k.(string)
temp[s] = v
return true
})
common.Output(ctx,0,"查询成功",temp)
}
......
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"runtime"
"strings"
"sync/atomic"
)
var Context *gin.Context
var REQUEST atomic.Value //等同于php 的$_REQUEST,只接收非数组值
type request123 map[string]string
//将gin的上下文放到全局变量
func ContextVars() gin.HandlerFunc {
return func(c *gin.Context) {
fmt.Print("nni")
//接收所有的变量+值
REQUEST123 := make(request123)
c.MultipartForm()
for requestName, requstValue := range c.Request.Form {
REQUEST123[requestName] = strings.TrimSpace(requstValue[0])
}
REQUEST.Store(&REQUEST123)
////将gin的上下文放到全局变量
Context = c
c.Next()
}
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//初始化引擎
r := gin.Default()
r.Use(ContextVars())
r.POST("/user", func(c *gin.Context) {
//name := c.Request.FormValue("name")
d := c.Request.FormValue("power[fast]")
//agc := REQUEST.Load().(*request123)
//fmt.Print((*agc)["name"])
//fmt.Print(&REQUEST)
c.String(http.StatusOK, "Hello %s", d)
})
r.GET("/user", func(c *gin.Context) {
//name := c.Request.MultipartForm.Value["name"]
name := c.Request.FormValue("name")
//agc := REQUEST.Load().(*request123)
//fmt.Print((*agc)["name"])
//fmt.Print(&REQUEST)
c.String(http.StatusOK, "Hello %s", name)
})
r.Run(":9100") // listen and serve on 0.0.0.0:8080
}
\ No newline at end of file
package main
import (
json2 "encoding/json"
"fmt"
"sync"
)
func main() {
// 关键人物出场
var scene sync.Map
// 将键值对保存到sync.Map
scene.Store("greece", 97)
scene.Store("london", 100)
scene.Store("egypt", 200)
// 从sync.Map中根据键取值
fmt.Println(scene.Load("london"))
// 根据键删除对应的键值对
scene.Delete("london")
// 遍历所有sync.Map中的键值对
temp := make(map[string]interface{})
scene.Range(func(k, v interface{}) bool {
fmt.Println("iterate:", k, v)
s,_ := k.(string)
temp[s] = v
return true
})
fmt.Print(temp)
dd,error := json2.Marshal(temp)
fmt.Print(error,string(dd))
}
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/semihalev/gin-stats"
)
func main() {
r := gin.Default()
r.Use(stats.RequestStats())
r.GET("/stats", func(c *gin.Context) {
fmt.Print(stats.RequestStats())
c.JSON(http.StatusOK, stats.Report())
})
// Listen and Server in 0.0.0.0:8080
r.Run(":8080")
}
\ No newline at end of file
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"runtime"
"strings"
)
var Context *gin.Context
var REQUEST map[string]string //等同于php 的$_REQUEST,只接收非数组值
//将gin的上下文放到全局变量
func ContextVars() gin.HandlerFunc {
return func(c *gin.Context) {
fmt.Print("nni")
//接收所有的变量+值
c.MultipartForm()
REQUEST1 := make(map[string]string)
for requestName, requstValue := range c.Request.Form {
REQUEST1[requestName] = strings.TrimSpace(requstValue[0])
}
REQUEST = REQUEST1
}
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//初始化引擎
r := gin.Default()
r.Use(ContextVars())
r.POST("/user", func(c *gin.Context) {
//name := c.PostForm("name")
fmt.Print(REQUEST["name"],"nnini")
c.String(http.StatusOK, "Hello %s", REQUEST["name"])
})
r.Run(":9100") // listen and serve on 0.0.0.0:8080
}
\ No newline at end of file
package middleware
import (
"github.com/gin-gonic/gin"
"strings"
)
var Context *gin.Context
var REQUEST map[string]string //等同于php 的$_REQUEST,只接收非数组值
var REQUEST_MAP map[string][]string //接收参数的数组,只支持二维
//将gin的上下文放到全局变量
func ContextVars() gin.HandlerFunc {
return func(c *gin.Context) {
//接收所有的变量+值
REQUEST = make(map[string]string)
REQUEST_MAP = make(map[string][]string)
c.MultipartForm()
for requestName, requstValue := range c.Request.Form {
values := make([]string,0);
if len(requstValue) == 1 {
REQUEST[requestName] = strings.TrimSpace(requstValue[0])
REQUEST_MAP[requestName] = append(values,requstValue[0])
}
if len(requstValue) > 1 { //接收多维数组
var i int
for i = 0; i < len(requstValue); i++ {
values = append(values,requstValue[i])
}
REQUEST_MAP[requestName] = values
}
}
//将gin的上下文放到全局变量
Context = c
c.Next()
}
}
......@@ -9,6 +9,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"math"
......@@ -16,7 +17,6 @@ import (
"math/rand"
"reflect"
"regexp"
"goods_machining/middleware"
"goods_machining/pkg/config"
"goods_machining/pkg/vars"
"sort"
......@@ -38,7 +38,6 @@ func GInArray(json string,arrK string,targetK string) bool{
for _,a := range s {
c := a.String()
d = append(d,c)
fmt.Print(c,reflect.TypeOf(c))
}
return php2go.InArray(targetK,d)
......@@ -60,27 +59,27 @@ func Sha1(query string, pri_key string) string {
/*
输出header
*/
func PrintDebugHeader() {
if middleware.REQUEST["flag"] == "101" {
middleware.Context.Header("Content-Type", "text/html; charset=utf-8")
func PrintDebugHeader(ctx *gin.Context) {
if ctx.Request.FormValue("flag") == "101" {
ctx.Header("Content-Type", "text/html; charset=utf-8")
}
}
/*
格式化数据直接输出浏览器
@parm jsonStr 需要json输出的内容
*/
func PrintDebugHtml(jsonStr interface{}) {
if middleware.REQUEST["flag"] != "101" || jsonStr == "" {
func PrintDebugHtml(ctx *gin.Context,jsonStr interface{}) {
if ctx.Request.FormValue("flag") != "101" || jsonStr == "" {
return
}
if v, p := jsonStr.(string); p {
middleware.Context.String(200,"</br></br>-----------"+v)
ctx.String(200,"</br></br>-----------"+v)
}else{
jsonData,err := json.Marshal(jsonStr)
if err != nil {
fmt.Println("错误:-----",err)
}
middleware.Context.String(200,"</br></br>-----------"+string(jsonData))
ctx.String(200,"</br></br>-----------"+string(jsonData))
}
}
......@@ -228,9 +227,8 @@ func CopyMapString(distmap map[string]string) map[string]string {
}
//反爬虫加密验证
func CheckSignApi() (resNo int) {
func CheckSignApi(ctx *gin.Context) (resNo int) {
params := make(map[string]string)
ctx := middleware.Context
if ctx == nil {
return
}
......@@ -254,7 +252,7 @@ func CheckSignApi() (resNo int) {
}
//如果是内部验证通过,则内部通过
if auth() {
if auth(ctx) {
return 0
}
......@@ -308,8 +306,7 @@ func CheckSignApi() (resNo int) {
}
//内部免验证通过
func auth() bool {
ctx := middleware.Context
func auth(ctx *gin.Context) bool {
if ctx == nil {
return false
}
......
......@@ -2,14 +2,14 @@ package common
import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/ichunt2019/logger"
log "github.com/sirupsen/logrus"
"os"
"goods_machining/middleware"
"goods_machining/pkg/config"
"goods_machining/pkg/gredis"
"goods_machining/pkg/message"
"os"
"strconv"
"strings"
"time"
......@@ -27,10 +27,9 @@ type SearchApiLog struct {
Method string `json:"method"`
}
func AnalyzeSearchError(code int, ip, errMsg, file, line, method string) (log SearchApiLog) {
func AnalyzeSearchError(ctx *gin.Context,code int, ip, errMsg, file, line, method string) (log SearchApiLog) {
//获取所有参数
request := make(map[string]string)
ctx := middleware.Context
ctx.MultipartForm()
for name, value := range ctx.Request.Form {
if value[0] != "" {
......
......@@ -2,8 +2,8 @@ package common
import (
"encoding/json"
"github.com/gin-gonic/gin"
"runtime"
"goods_machining/middleware"
"strconv"
"strings"
)
......@@ -39,7 +39,7 @@ func ErrorResponse(errCode int, errMsg string) Response {
}
//统一输出,里面还要去处理jsonp
func Output(errCode int, errMsg string, data interface{}) {
func Output(ctx *gin.Context,errCode int, errMsg string, data interface{}) {
if data == nil {
data = []string{}
}
......@@ -49,9 +49,8 @@ func Output(errCode int, errMsg string, data interface{}) {
Data: data,
}
if errCode >= 100 {
SearchApiLogger(errCode, errMsg)
SearchApiLogger(ctx,errCode, errMsg)
}
ctx := middleware.Context
if ctx.DefaultQuery("callback", "") != "" {
ctx.JSONP(200, response)
} else {
......@@ -66,7 +65,7 @@ func Output(errCode int, errMsg string, data interface{}) {
}
//简单的返回数据方法
func ReturnData(errCode int, errMsg string, data interface{}) {
func ReturnData(ctx *gin.Context,errCode int, errMsg string, data interface{}) {
if data == nil {
data = []string{}
if errCode == 0 {
......@@ -78,18 +77,16 @@ func ReturnData(errCode int, errMsg string, data interface{}) {
ErrMsg: errMsg,
Data: data,
}
ctx := middleware.Context
ctx.JSON(200, response)
}
//错误的搜索日志记录
func SearchApiLogger(code int, msg string) {
func SearchApiLogger(ctx *gin.Context,code int, msg string) {
pc, file, line, _ := runtime.Caller(2)
f := runtime.FuncForPC(pc)
ctx := middleware.Context
errMsg := "提示信息:" + msg + ",请求url:" + ctx.Request.URL.String()
lineNo := strconv.Itoa(line)
searchLog := AnalyzeSearchError(code, ctx.ClientIP(), errMsg, file, lineNo, f.Name())
searchLog := AnalyzeSearchError(ctx,code, ctx.ClientIP(), errMsg, file, lineNo, f.Name())
searchLogByte, _ := json.Marshal(searchLog)
WriteSearchErrorLog(string(searchLogByte))
}
......@@ -3,7 +3,6 @@ package routes
import (
"github.com/gin-gonic/gin"
"goods_machining/controller"
"goods_machining/middleware"
)
//初始化路由
......@@ -12,8 +11,6 @@ func InitRouter() *gin.Engine {
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.Cors())
r.Use(middleware.ContextVars())
//联营参数选择搜索
r.GET("synchronization", controller.Synchronization)
......
package service
import (
"github.com/gin-gonic/gin"
"github.com/iancoleman/orderedmap"
"github.com/tidwall/gjson"
"goods_machining/middleware"
"goods_machining/model"
"goods_machining/pkg/common"
"goods_machining/pkg/gredis"
......@@ -30,7 +30,7 @@ type ZiyingService struct {
@param power[special_invoice] 增值税专用发票公司名字,活动价时需要,否则可能导致用户无法享受活动价 : 深圳是猎芯科技有限公司
@param power[verify_blacklist] 是否验证黑名单,用于折扣活动提交订单页面与后台下单 :true
*/
func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]interface{}, wg *sync.WaitGroup) {
func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsRes *sync.Map, wg *sync.WaitGroup) {
redisConn := gredis.Conn("search_r")
defer func() {
......@@ -39,7 +39,7 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
}()
skuArr := gredis.HgetPi("search_r","Self_SelfGoods",goodsIds) //批量获取商品详情
fast := middleware.REQUEST["power[fast]"]
fast := ctx.Request.FormValue("power[fast]")
for goods_id,info := range skuArr {
......@@ -157,7 +157,7 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
//处理活动价
A.Set("ac_type",0)
A.Set("allow_coupon",1)
Ac_price := qs.ActivityPrice(info,&redisConn)
Ac_price := qs.ActivityPrice(ctx,info,&redisConn)
if Ac_price != nil {
keys := Ac_price.Keys()
for _, k := range keys {
......@@ -202,7 +202,8 @@ func (qs *ZiyingService) ZyGoodsDetail(goodsIds []string,goodsRes *map[string]in
A.Set("is_buy",1)
}
(*goodsRes)[goods_id] = A
//最后写入sync map
(*goodsRes).Store(goods_id,A)
}
}
......
package service
import (
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"goods_machining/middleware"
"goods_machining/model"
"goods_machining/pkg/common"
"goods_machining/pkg/gredis"
......@@ -38,13 +38,13 @@ func (qs *ZiyingService) skuLockNum(c *redis.Conn,goodsId string) int64{
/*
获取自营活动价
*/
func (qs *ZiyingService) ActivityPrice(SkuInfo string,c *redis.Conn) *orderedmap.OrderedMap {
func (qs *ZiyingService) ActivityPrice(ctx *gin.Context,SkuInfo string,c *redis.Conn) *orderedmap.OrderedMap {
//新客价处理
if middleware.REQUEST["power[newCustomer]"] == "true" ||
middleware.REQUEST["power[newCustomer]"] == "1" {
if ctx.Request.FormValue("power[newCustomer]") == "true" ||
ctx.Request.FormValue("power[newCustomer]") == "1" {
goodsActivityPrice,_ := gredis.String((*c).Do("get","Self_ActivityPrice_10000_NewCustomer"))
if goodsActivityPrice != "" {
data := qs.HDActivityPrice(goodsActivityPrice,SkuInfo,"5")
data := qs.HDActivityPrice(ctx,goodsActivityPrice,SkuInfo,"5")
if data != nil {
return data
}
......@@ -59,7 +59,7 @@ func (qs *ZiyingService) ActivityPrice(SkuInfo string,c *redis.Conn) *orderedma
//活动价
GoodsActivityPrice,_ := gredis.String((*c).Do("get","Self_ActivityPrice_10000"))
if GoodsActivityPrice != "" {
data := qs.HDActivityPrice(GoodsActivityPrice,SkuInfo,"2")
data := qs.HDActivityPrice(ctx,GoodsActivityPrice,SkuInfo,"2")
if data != nil {
return data
}
......@@ -67,7 +67,7 @@ func (qs *ZiyingService) ActivityPrice(SkuInfo string,c *redis.Conn) *orderedma
//会员价
GoodsActivityPrice,_ = gredis.String((*c).Do("get","Self_ActivityPrice_10000_Member"))
if GoodsActivityPrice != "" {
data := qs.HDActivityPrice(GoodsActivityPrice,SkuInfo,"3")
data := qs.HDActivityPrice(ctx,GoodsActivityPrice,SkuInfo,"3")
if data != nil {
return data
}
......@@ -91,7 +91,7 @@ ac_type说明: 0 没有活动
折扣价 8 自营 and 联营
*/
func (qs *ZiyingService) HDActivityPrice(GoodsActivityPrice string,SkuInfo string,Actype string) *orderedmap.OrderedMap {
func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice string,SkuInfo string,Actype string) *orderedmap.OrderedMap {
visible_roster := gjson.Get(GoodsActivityPrice,"visible_roster").String()
activity_id := gjson.Get(GoodsActivityPrice,"activity_id").String()
is_part := gjson.Get(GoodsActivityPrice,"is_part").String()
......@@ -137,9 +137,9 @@ func (qs *ZiyingService) HDActivityPrice(GoodsActivityPrice string,SkuInfo strin
//会员价处理
if Actype == "3" && is_part == "1" && visible_roster != "" {
visible_roster = ","+visible_roster+","
if php2go.Stripos(visible_roster,","+middleware.REQUEST["power[user_id]"]+",",0) == -1 ||
php2go.Stripos(visible_roster,","+middleware.REQUEST["power[mobile]"]+",",0) == -1 ||
php2go.Stripos(visible_roster,","+middleware.REQUEST["power[email]"]+",",0) == -1 {
if php2go.Stripos(visible_roster,","+ctx.Request.FormValue("power[user_id]")+",",0) == -1 ||
php2go.Stripos(visible_roster,","+ctx.Request.FormValue("power[mobile]")+",",0) == -1 ||
php2go.Stripos(visible_roster,","+ctx.Request.FormValue("power[email]")+",",0) == -1 {
Ratio = false; //不符合新客价
goto End
}
......@@ -148,7 +148,7 @@ func (qs *ZiyingService) HDActivityPrice(GoodsActivityPrice string,SkuInfo strin
if Actype == "2" &&
activity_id != "" &&
activity_type == "2" &&
middleware.REQUEST["power[verify_blacklist]"] == "true" {
ctx.Request.FormValue("power[verify_blacklist]") == "true" {
//redisConn := gredis.Conn("search_r")
//defer redisConn.Close();
......
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