Commit 29e8147e by wang

删除test文件

parent 2cff7c1d
......@@ -19,3 +19,4 @@ cmd.exe~
/doc/spuTest
/doc/test3
package main
import (
"fmt"
"github.com/gogf/gf/util/gconv"
)
func main() {
//str:="dfjksldjfksjdkfjskdfjk"
//byteStr:=[]byte(str)
inta:="123123123"
inta2:="1"
s1:=gconv.Int(string(inta))
s2:=gconv.Int(string(inta2))
s3:=gconv.Int([]uint8(inta))
fmt.Println(s3)
fmt.Println(s1,s2)
/*fmt.Println([]byte(inta),byteStr,[]uint8(inta))
uint8S:=[]uint8(inta)
uint8S2:=[]uint8(inta2)
fmt.Println(binary.BigEndian.Uint32(uint8S))
fmt.Println(binary.BigEndian.Uint32(uint8S2))*/
}
package main
import (
"fmt"
"regexp"
"unicode"
)
func main() {
str:="中的开发健康的反馈123123sdfsd"
str2:="fsdfsdf"
fmt.Println(IsChineseChar(str))
fmt.Println(IsChineseChar(str2))
}
func IsChineseChar(str string) bool {
for _, r := range str {
if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {
return true
}
}
return false
}
package main
import "fmt"
func main() {
defer func() {
fmt.Print("最后在还行的")
}()
panic(123)
}
func exec1() {
}
package main
import "fmt"
func main() {
fmt.Println(f2());
//result := watShadowDefer(50)
//fmt.Println(result)
}
func watShadowDefer(i int) (ret int) {
ret = i * 2
if ret > 10 {
fmt.Println(ret)
ret := 10
defer func() int{
ret = ret + 1
return ret
}()
fmt.Println(ret)
}
fmt.Println(ret)
return
}
func f2() (r int) {
t := 5
defer func(t int) {
t = t + 5
fmt.Printf("defer内部 t等于: %d\n",t)
}(t)
fmt.Printf("return 前 t等于: %d\n",t)
return t
}
func test() {
ret:=100
if ret > 10 {
fmt.Println(ret)
ret := 10
/*defer func() {
ret = ret + 1
}()*/
fmt.Println(ret)
}
fmt.Println(ret)
}
package main
import "fmt"
type SS struct {
a int
b int
}
var SSS *SS
func main() {
SSS=&SS{}
SSS.a=2
SSS.b=2
ju(SSS.b)
}
func ju(t int) {
switch t {
case SSS.a :
fmt.Println("a")
case SSS.b:
fmt.Printf("b")
}
}
package main
import (
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
)
type testS struct {
A int `json:"a"`
B string `json:"b"`
}
func main() {
gjsontest()
return
testS:=testS{}
jsonStr:=`{"a":"123","b":"dfdf"}`
err:=json.Unmarshal([]byte(jsonStr),&testS)
fmt.Println(err.Error())
}
func gjsontest() {
s:="dfjklsjdfklsjdfl"
s=`{"a":"bcd"}`
res:=gjson.Parse(s)
if(res.Exists()){
fmt.Printf("1")
}else{
fmt.Printf("2")
}
}
\ No newline at end of file
package main
import (
"fmt"
"strings"
)
func main() {
s:="a b c d e"
s1:=strings.Replace(s," ",",",-1)
fmt.Printf(s1)
}
### 日志
#### 同步调用方法(不需要额外配置)
```json
import ("golang_open_platform/pkg/logger")
logger.SyncInsert("sku_save","记录一下日志",logger.LogLevelError) //记录错误日志
logger.SyncInsert("sku_save","记录一下日志",logger.LogLevelDebug) //记录debug日志
logger.SyncInsert("sku_save","记录一下日志") //默认记录info
```
### 异步日志
#### 配置文件
```ini
[log_config]
1=sku_save,5
2=sku_edit,5
```
比如 sku_save,5 路径 sku_save 即文件夹是 sku 文件名类似 是save_2020-12-10.log
#### 调用示例
```json
import ("golang_open_platform/pkg/logger")
logger.Select("sku_save").Info(errMsg)
logger.Select("sku_save").Error(errMsg)
```
\ No newline at end of file
### 请求参数示例
batch_sn
spu_brief
goods_images
```json
{
"stock": 2055,
"pn": "maritex",
"is_api": 0,
"url": "https://en.maritex.com.pl/acoustics/audio_transducers/magnetic_buzzers_without_driving_circuit/cfd02-e.html",
"goods_name": "CFD02-E6",
"goods_sn": "CFD02-E",
"brand_name": "Changzhou EST ELECTRONICS Co.,Ltd.",
"is_error": 0,
"supplier_id": 17,
"canal": "L0010826",
"mpq": 1,
"moq": 1,
"pdf": "",
"hk_delivery_time": "5-7\u5de5\u4f5c\u65e5",
"cn_delivery_time": "6-12\u5de5\u4f5c\u65e5",
"ladder_price": [
{
"purchases": 1,
"price_cn": 0.2886,
"price_us": 0.2886
},
{
"purchases": 25,
"price_cn": 0.2662,
"price_us": 0.2662
}
],
"attrs":{
"0":{"attr_name":"标准包装","attr_value":"1"},
"2":{"attr_name":"包装","attr_value":"剪切带(CT)11"}
}
}
```
### 批次 redis Self_goods_batch 相关数据
```json
"[{"traceno":"00010486","pcs":"2950.0000","dc":"","goods_id":"10365","add_time":1578363429}]"
2) "[{"traceno":"00010489","pcs":"4500.0000","dc":"","goods_id":"10333","add_time":1578363429}]"
3) "[{"traceno":"00013255","pcs":"1350.0000","dc":0,"goods_id":"10643","add_time":1606109821,"dc_time":0}]"
4) "[{"traceno":"00011909","pcs":"2470.0000","dc":"","goods_id":"10288","add_time":1578363429},{"traceno":"00011910","pcs":"2500.0000","dc":"","goods_id":"10288","add_time":1578363429}]"
5) "[{"traceno":"00071835","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1529244995},{"traceno":"00071836","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1529244995},{"traceno":"00071837","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1529244995},{"traceno":"00071838","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1529244995},{"traceno":"00071839","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1529244995}]"
6) "[{"traceno":"00008706","pcs":"4000.0000","dc":"","goods_id":"11050","add_time":1578363429},{"traceno":"00008978","pcs":"4000.0000","dc":"","goods_id":"11050","add_time":1578363429}]"
7) "[{"traceno":"00071835","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1578240000},{"traceno":"00071836","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1578240000},{"traceno":"00071837","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1578240000},{"traceno":"00071838","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1578240000},{"traceno":"00071839","pcs":"100.0000","dc":"2002","goods_id":"95877","add_time":1578559395,"dc_time":1578240000}]"
8) "[{"traceno":"00008700","pcs":"9820.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00009108","pcs":"10000.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00009109","pcs":"10000.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00071756","pcs":"5.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00071758","pcs":"25.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00071764","pcs":"10.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00071766","pcs":"1.0000","dc":0,"goods_id":"11030","add_time":1579249375,"dc_time":0},{"traceno":"00071874","pcs":"400.0000","dc":"1809","goods_id":"11030","add_time":1579249375,"dc_time":1518969600},{"traceno":"00071876","pcs":"3600.0000","dc":"1810","goods_id":"11030","add_time":1579249375,"dc_time":1519574400},{"traceno":"00071871","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579249375,"dc_time":1514736000},{"traceno":"00071872","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579249375,"dc_time":1514736000},{"traceno":"00071873","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579249375,"dc_time":1514736000},{"traceno":"00071875","pcs":"4000.0000","dc":"1830","goods_id":"11030","add_time":1579249375,"dc_time":1531670400}]"
9) "[{"traceno":"00010485","pcs":"3000.0000","dc":"","goods_id":"10345","add_time":1578363429}]"
10) "[{"traceno":"00008700","pcs":"9820.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00009108","pcs":"10000.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00009109","pcs":"10000.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00071756","pcs":"5.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00071758","pcs":"25.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00071764","pcs":"10.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00071766","pcs":"1.0000","dc":0,"goods_id":"11030","add_time":1579164431,"dc_time":0},{"traceno":"00071874","pcs":"400.0000","dc":"1809","goods_id":"11030","add_time":1579164431,"dc_time":1518969600},{"traceno":"00071876","pcs":"3600.0000","dc":"1810","goods_id":"11030","add_time":1579164431,"dc_time":1519574400},{"traceno":"00071871","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579164431,"dc_time":1514736000},{"traceno":"00071872","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579164431,"dc_time":1514736000},{"traceno":"00071873","pcs":"4000.0000","dc":"1802","goods_id":"11030","add_time":1579164431,"dc_time":1514736000},{"traceno":"00071875","pcs":"4000.0000","dc":"1830","goods_id":"11030","add_time":1579164431,"dc_time":1531670400}]"
11) "[{"traceno":"00008673","pcs":"10000.0000","dc":"","goods_id":"11033","add_time":1578363429},{"traceno":"00009122","pcs":"10000.0000","dc":"","goods_id":"11033","add_time":1578363429},{"traceno":"00024542","pcs":"10000.0000","dc":"","goods_id":"11033","add_time":1578363429},{"traceno":"00024543","pcs":"10000.0000","dc":"","goods_id":"11033","add_time":1578363429}]"
12) "[{"traceno":"00008714","pcs":"4000.0000","dc":"","goods_id":"11051","add_time":1578363429},{"traceno":"00008977","pcs":"4000.0000","dc":"","goods_id":"11051","add_time":1578363429}]
```
package main
import (
"fmt"
)
type MyError struct {
errCode uint8
}
func (e *MyError) Error() string {
switch e.errCode {
case 1:
return "file not found"
case 2:
return "time out"
case 3:
return "permission denied"
default:
return "unknown error"
}
}
// 相当于使用interface进行封箱操作
func GetError1() error {
var err *MyError = nil
return err
}
// 没有使用interface进行封箱操作
func GetError2() *MyError {
var err *MyError = nil
return err
}
func main() {
ret1 := GetError1() //封箱,所以不为nil
fmt.Println(ret1 == nil) //false
e, _ := ret1.(*MyError) //显式拆箱,所以为nil
fmt.Println(e == nil) //true
ret2 := GetError2() // 不用转换,所以为nil
fmt.Println(ret2 == nil) //true
}
package main
import "golang_open_platform/open"
func main() {
open.NewFlow().GetUsedMinNum("a","c")
}
\ No newline at end of file
package main
func main() {
}
package main
import (
"fmt"
)
func main() {
fmt.Println("sdfsdfsdf")
/*tokenStr:="fjksdjfk"
name:="fddsf"
token.NewToken(tokenStr,name).Check()*/
}
package main
import (
"fmt"
"golang_open_platform/token"
"reflect"
)
func main() {
err:=ddd()
if(err==nil){
fmt.Println("等于空")
}else{
fmt.Println("不等于空")
}
CheckError(err)
return
tokenStr:="AbopJDAbopdu800820mcspcq=="
name:="getSkuListById"
s:= open.NewToken(tokenStr,name).Check()
/*if(s==nil){
fmt.Println("等于空")
}else{
fmt.Println("不等于空")
}*/
//return
/*fmt.Println(s)
fmt.Println(s)
fmt.Println(nil)*/
CheckError(nil)
CheckError(s)
/*if(s!=nil){
fmt.Println(s.Code,s.Error())
}*/
}
func ddd()error{
return nil
//return e.NewApiError("djfklsdjfk")
}
/**
检测异常,并抛出异常
*/
func CheckError(err error) {
fmt.Println(reflect.TypeOf(err))
if(err==nil){
fmt.Println("等于空")
}else{
fmt.Println("不等于空")
}
/*if(err!=nil){
fmt.Println("不等于空")
}else{
fmt.Println("等于空")
}*/
/*if err != nil {
fmt.Print(err.Error());
if apiError,ok:=err.(*ApiError);ok{
panic(apiError)
}else{
panic(NewApiError(err.Error()))
}
}*/
}
package main
import (
"fmt"
"time"
)
func main() {
s:=time.Hour.Seconds()*24
a:=time.Minute.Seconds()
fmt.Println(s)
fmt.Println(a)
}
\ No newline at end of file
package main
import (
"fmt"
"github.com/gogf/gf/util/gconv"
"golang_open_platform/pkg/common"
"sync"
"time"
)
type SoucreData []string
var num int
func main() {
c:=make(chan SoucreData)
page:=1;
go func() {
defer close(c)
for{
zySkuEntityS,err:=GetSoucreData(page)
if(len(zySkuEntityS)<=0 || err!=nil){
if(err!=nil){
common.PrintDebugString(err.Error())
}
break
}
c<-zySkuEntityS
page++
}
}()
//消费chan
w:=sync.WaitGroup{}
limits:=make(chan struct{},1)
for soucreData:=range c{
w.Add(1)
limits<- struct{}{}
go func() {
defer func() {
defer w.Done()
<-limits
}()
exec(soucreData)
}()
}
w.Wait()
fmt.Println(num)
}
func GetSoucreData(page int) (soucreData SoucreData,err error) {
if(page >10){
return soucreData,nil
}
pre:="吱吱吱"
for i:=0;i<=100;i++{
randNum:=common.Rand(1,1000000)
soucreData=append(soucreData,pre+gconv.String(randNum))
}
return soucreData,err
}
func exec(s SoucreData) {
time.Sleep(time.Second*5)
for _,v:=range s {
num+=1
common.PrintDebugString(v)
}
}
package main
import "github.com/syyongx/php2go"
func main() {
php2go.Ceil()
}
package main
import "fmt"
//换行符
func main() {
s:="abc\n"
s=s+"erg\n"
fmt.Print(s)
}
package main
import "fmt"
func main() {
s:=[]string{"goods_id","spu_id","brand_id","brand_name","goods_name", "stock","moq","mpq","class_id1","class_name","attrs","ladder_price",}
}
\ No newline at end of file
package main
import "fmt"
func main() {
s:=make([]string,0)
s[0]="fjksdf"
fmt.Println(s)
}
package main
import (
"fmt"
"strings"
)
func main() {
a:="a,b,c,d dfsdf"
sliceA:=strings.Split(a,",")
fmt.Print(sliceA)
}
\ No newline at end of file
### szlc mongodb
### szlc mongodb
```json
{
"stock": [
NumberInt(5),
NumberInt(7380)
],
"tiered": [
[
NumberInt(5),
0.544911
],
[
NumberInt(50),
0.406958
],
[
NumberInt(150),
0.38162
],
[
NumberInt(500),
0.356282
],
[
NumberInt(2500),
0.34502
],
[
NumberInt(5000),
0.339456
]
],
"increment": NumberInt(5),
"pn": "szlc",
"is_api": NumberInt(0),
"encap_sulation_number": NumberInt(4000),
"goods_name": "MCZ1210AH900TA0G",
"sale_count": NumberInt(10280),
"sale_unit": "个",
"url": "http://item.szlcsc.com/147580.html",
"time": NumberInt(1568786720),
"is_error": NumberInt(0),
"goods_id": NumberLong(31000000000),
"goods_sn": "C136265",
"brand_name": "TDK",
"brand_id": NumberInt(1)
}
```
redis Self_szlc_class_mapping
```json
"{"class_id": 10329, "parent_id": 10229, "financial_classify_id": "0"}"
```
\ No newline at end of file
***redis键值: Self_SelfGoods
{
"other_attrs": "",
"goods_id": 203065,
"goods_type": 0,
"supplier_id": 10000,
"brand_id": 4492,
"class_id1": 10152,
"class_id2": 10164,
"goods_name": "RR0603(0201)L1203FTD",
"status": 1,
"encoded": "",
"encap": "0201(0603)",
"packing": 5,
"goods_unit": 1,
"goods_images": "",
"pdf": "",
"goods_brief": "",
"moq": 50,
"mpq": 15000,
"ladder_price": [
{
"purchases": 50,
"price_cn": 0.0044
},
{
"purchases": 1000,
"price_cn": 0.0044
},
{
"purchases": 15000,
"price_cn": 0.0044
}
],
"update_time": 1592218150,
"sku_name": "RR0603(0201)L1203FTD u7f16u5e26 PTC u70edu654fu7535u963b ",
"mpl": 1,
"stock": 0,
"attrs": "",
"cost": "0.000000",
"new_cost": "0.000000",
"supplier_stock": 473349,
"self_supplier_type": 4
}
#############最终结果##########
Array
(
[33072] => Array
(
[other_attrs] => Array
(
[length] =>
[gross_wegiht] => 0.000582
)
[goods_id] => 33072
[goods_type] => 0
[supplier_id] => 10000
[brand_id] => 703
[class_id1] => 161
[class_id2] => 169
[goods_name] => 3362P-1-101LF
[status] => 1
[encoded] => 10141
[encap] => 3362P
[packing] => 8
[goods_unit] => 1
[goods_images] => http://img.ichunt.com/images/goods/bb/a6/bba6b9cb12bf5f581cd4525a9d5995de.png
[pdf] => http://img.ichunt.com/doc/pdf/cms/201809/13/d110c1966263019b39775c419f57b4a2.pdf
[goods_brief] =>
[moq] => 1
[mpq] => 50
[ladder_price] => Array
(
[0] => Array
(
[purchases] => 1
[price_cn] => 0.95
[price_ac] => 0.5944
)
[1] => Array
(
[purchases] => 10
[price_cn] => 0.874
[price_ac] => 0.5944
)
[2] => Array
(
[purchases] => 20
[price_cn] => 0.836
[price_ac] => 0.5944
)
[3] => Array
(
[purchases] => 50
[price_cn] => 0.798
[price_ac] => 0.5944
)
[4] => Array
(
[purchases] => 250
[price_cn] => 0.76
[price_ac] => 0.5944
)
)
[update_time] => 1596436153
[sku_name] => 3362P-1-101LF 精密可调电阻 100Ω(101) 3362P
[mpl] => 1
[stock] => 67
[attrs] => Array
(
[0] => Array
(
[attr_name] => 阻值(欧姆)
[attr_value] => 100Ω(101)
)
[1] => Array
(
[attr_name] => 精度
[attr_value] =>
)
[2] => Array
(
[attr_name] => 温度系数
[attr_value] =>
)
)
[cost] => 0.699248
[new_cost] => 0.602800
[supplier_stock] => 0
[self_supplier_type] => 1
[cn_delivery_time] => 3-7工作日
[brand_name] => BOURNS(伯恩斯)
[supplier_name] => 猎芯自营
[goods_unit_name] => 个
[packing_name] => 管
[mpq_unit_name] => 管
[scm_brand_name] =>
[actual_stock] => 100
[ac_type] => 6
[allow_coupon] => 1
[allow_presale] => 1
[saler_atio] =>
[szlc_price] =>
[class_id1_name] => 电阻
[class_id2_name] => 精密可调电阻
[is_buy] => 1
)
)
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