From 26c4c691bb079dd14d111372bb92ee0b6a9bedb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 9 Aug 2023 15:43:16 +0800 Subject: [PATCH 1/5] 1 --- .../purchase/tao_vegetable/store_sku2.go | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index 4be767488..75c968b8a 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -1,13 +1,8 @@ package tao_vegetable import ( + "bytes" "fmt" - "io/ioutil" - "net/http" - "regexp" - "strings" - "time" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" request1475 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability1475/request" @@ -26,6 +21,12 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" + "image/jpeg" + "io/ioutil" + "net/http" + "regexp" + "strings" + "time" ) const ( @@ -445,6 +446,22 @@ func checkNameLength(name string, weight int, uint string) string { return lastName[0:60] } +// 图片压缩,大于3M +func decodeImg(data []byte) []byte { + if float64(len(data))/float64(1024)/float64(1024) > float64(3) { + jpgimg, err := jpeg.Decode(strings.NewReader(string(data))) // 文件解码成图像对象 + if err != nil { + return nil + } + var buf bytes.Buffer + err = jpeg.Encode(&buf, jpgimg, &jpeg.Options{Quality: 30}) + if err != nil { + return nil + } + return buf.Bytes() + } + return data +} func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *string { vendorImg, _ := dao.GetVendorImg(skuId, vendorId) result := make([]string, 0, 0) @@ -468,6 +485,8 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri if strings.Contains(string(body), "Document not found") || len(body) == 0 { continue } + // 检查图片大小 + body = decodeImg(body) newImg, _ := api.UploadImg(&request1475.AlibabaWdkPictureUploadRequest{ PictureCategoryId: utils.Int64ToPointer(0), Img: &body, @@ -513,10 +532,16 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri } } + if vendorImg.Img == "" && vendorImg.Img2 == "" && vendorImg.Img3 == "" && vendorImg.Img4 == "" && vendorImg.Img5 == "" && vendorImg.DescImg == "" { + return nil + } + + taoImgs.SkuID = skuId + taoImgs.VendorID = vendorId if isCreate { - taoImgs.SkuID = skuId - taoImgs.VendorID = vendorId dao.CreateEntity(dao.GetDB(), taoImgs) + } else { + dao.UpdateEntity(dao.GetDB(), taoImgs, "Img", "Img2", "Img3", "Img4", "Img5", "DescImg") } // 商品图片最多五张 @@ -563,6 +588,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), OnlineSaleFlag: utils.Int64ToPointer(onlineStatus), SubTitle: utils.String2Pointer("小时达"), + AllowAppSale: utils.Int64ToPointer(onlineStatus), //CleanSkuMemberPrice: utils.Int64ToPointer(model.YES), } updateSkuList = append(updateSkuList, updateSku) From 060d8e5f11c10e30a3e82f41b46a0ca1efe4832b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 9 Aug 2023 15:53:02 +0800 Subject: [PATCH 2/5] 1 --- business/partner/purchase/tao_vegetable/store_sku2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index 75c968b8a..0408b587a 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -532,7 +532,7 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri } } - if vendorImg.Img == "" && vendorImg.Img2 == "" && vendorImg.Img3 == "" && vendorImg.Img4 == "" && vendorImg.Img5 == "" && vendorImg.DescImg == "" { + if taoImgs.Img == "" && taoImgs.Img2 == "" && taoImgs.Img3 == "" && taoImgs.Img4 == "" && taoImgs.Img5 == "" && taoImgs.DescImg == "" { return nil } From 1edb98d9f677d269d78146231ea7bec5b808a53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 9 Aug 2023 16:01:51 +0800 Subject: [PATCH 3/5] 1 --- business/partner/purchase/tao_vegetable/store_sku2.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index 0408b587a..40db59398 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -532,18 +532,11 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri } } - if taoImgs.Img == "" && taoImgs.Img2 == "" && taoImgs.Img3 == "" && taoImgs.Img4 == "" && taoImgs.Img5 == "" && taoImgs.DescImg == "" { - return nil - } - - taoImgs.SkuID = skuId - taoImgs.VendorID = vendorId if isCreate { + taoImgs.SkuID = skuId + taoImgs.VendorID = vendorId dao.CreateEntity(dao.GetDB(), taoImgs) - } else { - dao.UpdateEntity(dao.GetDB(), taoImgs, "Img", "Img2", "Img3", "Img4", "Img5", "DescImg") } - // 商品图片最多五张 if len(result) > 5 { return utils.String2Pointer(strings.Join(result[1:], ",")) From 19f7a93c8d61a3dd7ffb314d98daedeb295edf73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 9 Aug 2023 16:46:10 +0800 Subject: [PATCH 4/5] 1 --- business/jxstore/cms/sync.go | 3 - business/jxstore/misc/misc.go | 264 +----------------- .../purchase/tao_vegetable/store_sku2.go | 1 + 3 files changed, 7 insertions(+), 261 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index d7ee63754..5ca595ff7 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -486,9 +486,6 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v // func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { - if len(vendorIDs) > 0 && vendorIDs[0] == model.VendorIDTaoVegetable { - globals.SugarLogger.Debugf("=====================storeIDs: %s", utils.Format4Output(storeIDs, false)) - } isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 funcParam := func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 327ba08b1..275ec8279 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -285,24 +285,7 @@ func Init() { ScheduleTimerFunc("RefreshSyncSkuListTao", func() { syncStoreSkuTao() }, []string{ - "14:25:00", - "16:25:00", - "18:52:00", - "20:25:00", - "21:25:00", - "22:25:00", - "23:25:00", - "00:25:00", - "01:25:00", - "02:25:00", - "03:25:00", - "04:25:00", - "05:25:00", - "06:25:00", - "07:25:00", - "08:25:00", - "10:25:00", - "12:25:00", + "16:50:00", }) } @@ -657,244 +640,9 @@ func syncStoreSkuTiktok() { tasksch.HandleTask(task, nil, true).Run() } -var syncLen = 0 -var beijin = []int{ - //669113, - //669111, - //669110, - //669109, - //669108, - //669107, - //669106, - //669103, - //669100, - //669099, - //669098, - //669097, - //669096, - //669095, - //669094, - //669093, - //669092, - //669091, - //669087, - //669086, - //669085, - //669084, // zheer - //669083, - //669082, - //669079, - //669078, - //669077, - //669075, - //669074, - //669072, - //669070, - //669067, - //669064, - //669063, - //669062, - //669060, - //669059, - //669056, - //669055, - //669054, - //669050, - //669049, - //669047, // - //669046, - //669045, - //669042, - //669041, - //669038, - //669036, - //669035, - //669033, - //669032, // zher - //669031, - //669027, - //669025, - //669024, - //669022, - //669021, - //669020, - //669017, - //669015, /// zher - //669014, - //669012, - //669009, - //669007, - //669002, - //669000, - //668999, - //668997, - //668996, - //668993, // - //668988, - //668986, - //668984, - //668966, - //668963, - //668961, - //668958, - //668954, - //668950, - //668948, - //668946, - //668943, /// - //668938, - //668928, - //668910, - //668907, - //668900, - //668897, - 668896, - 668891, - 668889, - 668883, - 668882, - 668868, - 668860, - 668855, - 668853, - 668850, - 668849, - 668843, - 668838, - 668807, - 668802, - 668784, - 668773, - 668771, - 668767, - 668766, - 668755, - 668749, - 668728, - 668724, - 668722, - 668721, - 668716, - 668706, - 668704, - 668699, - 668697, - 668695, - 668693, - 668692, - 668688, - 668686, - 668682, - 668680, - 668679, - 668678, - 668672, - 668666, - 668662, - 668660, - 668659, - 668656, - 668655, - 668654, - 668649, - 668648, - 668643, - 668642, - 668640, - 668636, - 668632, - 668631, - 668629, - 668624, - 668616, - 668613, - 668608, - 668594, - 668548, - 668543, - 668540, - 668537, - 668530, - 668512, - 668258, - 668257, - 668256, - 668254, - 668203, - 668190, - 668186, - 668185, - 668182, - 668170, - 668169, - 668168, - 668166, - 668165, - 668164, - 668157, - 668156, - 668125, - 668121, - 668095, - 668094, - 668071, - 667959, - 667745, - 667744, - 667743, - 667563, - 667562, - 667561, - 667560, - 667559, - 667558, - 667556, - 667420, - 667332, - 667308, - 667305, - 667304, - 667299, - 667292, - 667285, - 667281, - 667278, - 667263, - 667001, - 666975, - 666677, - 666667, - 666666, - 103408, - 103184, - 103174, - 103127, - 103113, - 102925, - 102740, - 102736, - 102630, - 102383, - 102180, - 101942, - 101897, - 101875, - 101036, - 100840, - 100743, - 100654, - 100471, - 100144, - 100135, - 100129, - 100126, - 100123, - 100115, -} - // syncStoreSkuTao 同步商品到淘鲜达 func syncStoreSkuTao() { - syncFlag := 0 + syncFlag := 57 task := tasksch.NewParallelTask("syncStoreSkuTao ", nil, jxcontext.AdminCtx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { step := batchItemList[0].(int) @@ -902,11 +650,12 @@ func syncStoreSkuTao() { db := dao.GetDB() switch step { case 0: - if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达消息:", utils.Format4Output(beijin[syncLen:syncLen+5], false)); err != nil { + + if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达消息:", utils.Format4Output("开始同步", false)); err != nil { globals.SugarLogger.Debugf("SendUserMessage := %s", utils.Format4Output(err, false)) } - enterprise_msg.SendUserMessage("18981810340", "淘鲜达同步消息", utils.Format4Output(beijin[syncLen:syncLen+5], false), utils.Format4Output(beijin[syncLen:syncLen+5], false)) - _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDTaoVegetable}, beijin[syncLen:syncLen+5], false, nil, nil, syncFlag, true, true) + enterprise_msg.SendUserMessage("18981810340", "淘鲜达同步消息", utils.Format4Output("开始同步", false), utils.Format4Output("开始同步", false)) + _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDTaoVegetable}, nil, false, nil, nil, syncFlag, true, true) errList.AddErr(err) case 1: SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID) @@ -915,7 +664,6 @@ func syncStoreSkuTao() { return retVal, err }, []int{0, 1}) tasksch.HandleTask(task, nil, true).Run() - syncLen += 5 } func doDailyWork2() { diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index 40db59398..bf961bb86 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -537,6 +537,7 @@ func uploadImg(api *tao_vegetable.API, skuId, vendorId int, imgs []string) *stri taoImgs.VendorID = vendorId dao.CreateEntity(dao.GetDB(), taoImgs) } + // 商品图片最多五张 if len(result) > 5 { return utils.String2Pointer(strings.Join(result[1:], ",")) From 55713f7477f34124c0e10f8c91da9152a14e2406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 10 Aug 2023 16:51:19 +0800 Subject: [PATCH 5/5] 1 --- business/jxstore/misc/misc.go | 2 +- business/partner/purchase/jx/localjx/order.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 275ec8279..163b4a6ad 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -642,7 +642,7 @@ func syncStoreSkuTiktok() { // syncStoreSkuTao 同步商品到淘鲜达 func syncStoreSkuTao() { - syncFlag := 57 + syncFlag := 0 task := tasksch.NewParallelTask("syncStoreSkuTao ", nil, jxcontext.AdminCtx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { step := batchItemList[0].(int) diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index e007f652a..67301c40b 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -1221,7 +1221,7 @@ func jxOrder2GoodsOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, deliveryAd order.Flag = 1 if jxOrder.OrderType == model.OrderTypeMatter { order.WaybillVendorID = model.VendorIDJDWL - order.ConsigneeAddress = deliveryAddress.Address + order.ConsigneeAddress = fmt.Sprintf("%s%s", deliveryAddress.Address, deliveryAddress.DetailAddress) } } //如果是自提单就设置