diff --git a/business/bidding/bidding.go b/business/bidding/bidding.go index 3d556f7f2..d315c4f40 100644 --- a/business/bidding/bidding.go +++ b/business/bidding/bidding.go @@ -1,11 +1,13 @@ package bidding import ( + "fmt" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" + "strings" ) // 获取招标信息 @@ -82,3 +84,20 @@ func GetBrandPayOrder(brandID int, created string) (map[string]interface{}, erro } return result, nil } + +func QueryNeedDeleteSku() string { + var ddId = []int64{ + 3592874112982368249, 3592874112940433384, 3592744342617513942, 3592744342583915237, 3592874190300147609, 3592874190182716852, 3592744267514307517, 3592744267514307518, 3592876722099516085, 3592876722065951498, 3592874737925265106, 3592874737858139868, 3592874361931079567, 3592874362115593491, 3592744246073029217, 3592744243925530274, 3592874117168262707, 3592874117235398789, 3592875133020295634, 3592875132928047816, 3592875311303377588, 3592875311118859624, 3592875607555443133, 3592875607656121909, 3592874194595104394, 3592874194477702630, 3592744767785707224, 3592744767735336038, 3592876337733461607, 3592876337616009832, 3592579467513589810, 3592579467412927143, 3592706293468649462, 3592706293535784889, 3592744920382871323, 3592744920391263249, 3592706650059989389, 3592706649900605011, 3592875158647518351, 3592875158823638485, 3592875472297590656, 3592875472297590658, 3592875730062691828, 3592875729878181516, 3592579796070209506, 3592579795944352814, 3592579821840004272, 3592579821714192028, 3592876056463423982, 3592876056295648209, 3592707010677855976, 3592707010795324965, 3592579952777756852, 3592579954992392786, 3592745126415478421, 3592745126415478423, 3592876445040536891, 3592876445040536892, 3592874701317357464, 3592874701283795174, 3592706899184901160, 3592706899008729117, 3595274789255833614, 3595274789138382989, 3592875914612068298, 3592875914746322223, 3592707279230777862, 3592707279113351382, 3592580320056211507, 3592580320022659986, 3592744727117718996, 3592744729265219568, 3592707307215142972, 3592707307030587925, 3592745233739324364, 3592745233789643596, 3592579203188538144, 3592579203331137922, 3595275714653476099, 3595275714653476100, 3592745238218837831, 3592745238151698214, 3592745227347183385, 3592745227347183387, 3592707133268978134, 3592707133227016709, 3592583597057513876, 3592583596990407672, 3595275293864146035, 3595275293797001232, 3592580736609295960, 3592580736542230482, 3592745459384494613, 3592745457127966928, 3592875463749567642, 3592875461627264447, 3592876949699215849, 3592876949699215846, 3592876954061278574, 3592876954061278578, 3595275130730871566, 3595275130655360773, 3592707015148991459, 3592707015090296881, 3592876752256520160, 3592876752264948230, 3592880454526750420, 3592880454392533150, 3592747909688486367, 3592747911810800008, 3592876599793569838, 3592876599609044830, 3595275718998772843, 3595275719065925781, 3592877989081306705, 3592877989081306701, 3592581015664725906, 3592581015782163353, 3592877222429635324, 3592877222547030149, 3592582942041494281, 3592582942007929873, 3592877737959918413, 3592877737892801190, 3592581174737953495, 3592581174746295391, 3592877688550988674, 3592877688383229551, 3592877112975072431, 3592877112907926506, 3592877499572454983, 3592877499580844036, 3592746024189439676, 3592746024197827307, 3592877046461762524, 3592877046335972286, 3592877078497858311, 3592877080762828568, 3592877308328969516, 3592877308463199281, 3592706924937930626, 3592706924963041149, 3592581451603962805, 3592581451763319584, 3592879271263256001, 3592879271238071971, 3592581610568027710, 3592581610702301157, 3592581627747951625, 3592581627815037921, 3595275139304062736, 3595275139312445832, 3592878453071975489, 3592878452887422635, 3592876958356210371, 3592876958423367151, 3595275442099240023, 3595275442116016769, 3592581720215560776, 3592581720089723007, 3595275257289827609, 3595275257289827610, 3592707137522007318, 3592707137429707847, 3592877982705944081, 3592877982773075902, 3592581784547786704, 3592581784547786705, 3595275869448483181, 3595275869456848589, 3592582141130708434, 3592582140996510817, 3592707159030370174, 3592707158971693380, 3592581833906353832, 3592581833856051516, 3592707807394302824, 3592707807444604679, 3592877933380945634, 3592877933196408451, 3592581447392856405, 3592581447451553341, 3592877984786310479, 3592877984786310480, 3592582145383730226, 3592582145291487480, 3592582218373058171, 3592582218431742670, 3592879047790718816, 3592879047740367380, 3592582308533802487, 3592582308500241784, 3595276730589444142, 3595276730463553916, 3592746058373027057, 3592746058490469678, 3592877594070126043, 3592877593893972540, 3592582422350407239, 3592582422409118259, 3592877909624416528, 3592877909758587717, 3595275847847822453, 3595275847797484427, 3592878302563559290, 3592878302613891355, 3595275852209857367, 3595275852142751066, 3595274718405594296, 3595274718363681415, 3592582579083190468, 3592582579150283180, 3592582585659866418, 3592582585592737507, 3592582589887707260, 3592582589946438767, 3592707648665035870, 3592707648530860027, 3592707670139884174, 3592707669955340571, 3592878476560042076, 3592878478833407691, 3595275980991772195, 3595275980991772196, 3592877213965536802, 3592877213839659392, 3592877780775400640, 3592877780842483681, 3592748023496758301, 3592748023320591733, 3592583053794499430, 3592583053802888779, 3595275985236455798, 3595275985236455797, 3595276592974310188, 3595276593167228935, 3592879913360821134, 3592879913360821135, 3592878794454754516, 3592878794337330504, 3592583167560830566, 3592583167443390264, 3592583174003234873, 3592583174003234874, 3595275289451726903, 3595275289451726904, 3592879150995783227, 3592879150962226825, 3592878916794242429, 3592878916911635068, 3595276983958949521, 3595276983816351033, 3595274971624168076, 3595274971825482993, 3592879578286290819, 3592879578168870786, 3592878382070782235, 3592878382196627598, 3592878291985540158, 3592878291876447565, 3592878577525328438, 3592878577491779009, 3592706570494029867, 3592706570561178803, 3592877503749958113, 3592877503875795438, 3592583680809406656, 3592583680868094654, 3595277308086325755, 3595277308136683479, 3592878833134616506, 3592878833042387007, 3595275965909096649, 3595275965959375455, 3595276386866171557, 3595276386933329551, 3592877447915383702, 3592877447915383705, 3592880136682347034, 3592880136632038159, 3592707614305288517, 3592707614171077306, 3592878957663539795, 3592878957546087011, 3592580274967437972, 3592580274782866808, 3592707691480544588, 3592707691547640995, 3592879621202428503, 3592879621277914105, 3592880673469399403, 3592880673385484725, 3592878399317760827, 3592878399359730452, 3592879077989684432, 3592879077964550463, 3592879034855518921, 3592879034905840484, 3592879717805608953, 3592879717839165600, 3592583124678223806, 3592583124577576623, 3592584337821952103, 3592584338006534661, 3595276490062856667, 3595276490088042269, 3592747080625605329, 3592747080759782354, 3592584576360445299, 3592584576276519767, 3592584580487633241, 3592584580537946902, 3592584584832939618, 3592584584832939616, 3592879752115012197, 3592879752115012192, 3592747806609258845, 3592747806424753522, 3592584627782567638, 3592584627916796246, 3592584634342447894, 3592584634174684110, 3592879756410027959, 3592879756410027958, 3592880465197016328, 3592880465129934240, 3592584150990855178, 3592584150990855180, 3595276721965906807, 3595276721991120207, 3592879174601281178, 3592879172344800421, 3595276784150649431, 3595276784301663462, 3595276726168595710, 3595276726118315682, 3592880905481493661, 3592880905489903645, 3592584056686149618, 3592584056677747287, 3592879900450810541, 3592879900291382002, 3592878257516755226, 3592878257650959920, 3592876659881165060, 3592876659923121364, 3592746956138629355, 3592746956071556656, 3592748317702021062, 3592748317609750925, 3592880254626211945, 3592880254743650219, 3592585192696642313, 3592585192688215660, 3592586212625517845, 3592586212625517844, 3592708657982366547, 3592708657848187656, 3592880690749931956, 3592880692830330698, 3592747769917494885, 3592747770102046767, 3592748094187541522, 3592748094304977025, 3592708668585594347, 3592708668652682995, 3595277333906480878, 3595277333856158113, 3592880843221286867, 3592880843204494692, 3592880729337535342, 3592880729303961913, 3592585501934269683, 3592585501808436938, 3592746947481573812, 3592746947481573811, 3592880697125255297, 3592880697183986668, 3595277312431644708, 3595277312381296630, 3595276079725735061, 3595276079927013434, 3592585641394839530, 3592585641344549950, 3592585742326576605, 3592585742452448664, 3592585753156299642, 3592585753064006340, 3592585757358982306, 3592585757358982307, 3592585768096393968, 3592585768096393970, 3592881371435118565, 3592881371401603263, 3592881684850304905, 3592881684850304907, 3592747946170578806, 3592747946128593609, 3592879722134162651, 3592879722100609546, 3592586064575001967, 3592586062301659912, 3592879258193762965, 3592879258311243793, 3592881330683260996, 3592881328552586998, 3595277327464051187, 3595277327464051186, 3592708784658744199, 3592708784675524355, 3592880306165795448, 3592880306341949939, 3592877029223186318, 3592877029265156457, 3592586395295856826, 3592586397434925778, 3592748545159086097, 3592748545318485237, 3592880093564939823, 3592880095896973072, 3592881959778519818, 3592881959778519823, 3592880673502970826, 3592880673502970829, 3592881502431659706, 3592881502498718756, 3592748156464588479, 3592748156514920477, 3595277870911631455, 3595277870777406388, 3592586597159294199, 3592586597092174289, 3592880798057028774, 3592880798082202717, 3592881964073531969, 3592881964073531973, 3592881906217315323, 3592881906183702955, 3592586910591277024, 3592586910557693906, 3592881985548346799, 3592881985548346796, 3592881989977554036, 3592881989977554038, 3592881564750642632, 3592881564733861471, 3592586996549305549, 3592586996457043544, 3592748510849665709, 3592748510967154417, 3592881137359436272, 3592881137409722530, 3592587080301156250, 3592587080158557910, 3592877186048201463, 3592877185922426340, 3592877082843201263, 3592877082843201265, 3592877072055444195, 3592877072055444193, 3592881373582596894, 3592881371502227741, 3595278147802793477, 3595278147752444226, 3595277806503890513, 3595277806470348862, 3592587007194479417, 3592587007227990144, 3592748772976941741, 3592748772792347130, 3592877181744845712, 3592877181753276213, 3592587350791824629, 3592587350825372054, 3592586992254345145, 3592586992271157136, 3592882221905757908, 3592882221897383343, 3592708937054571146, 3592708937054571147, 3592877024995342343, 3592877024928267254, 3592882464386850812, 3592882464470729298, 3595278137132475383, 3595278137015023673, 3592882565402524824, 3592882565494763519, 3592879037179102577, 3592879037002968161, 3592881931928353175, 3592881931995486704, 3592744479972534409, 3592744480157106912, 3592875624810859507, 3592875624810859506, 3592875296203909139, 3592875296136791147, 3592878102847587118, 3592878102897935612, 3592876840269780957, 3592876840177518109, 3592876717838076991, 3592876717770957632, 3592748571088306219, 3592748571046363981, 3592748549571505296, 3592748549454082711, 3592876827410064233, 3592876827359762271, 3592877993443363842, 3592877993510500705, 3592881936189800134, 3592881936248535081, 3592747707799840506, 3592747707690834981, 3592747692658398170, 3592747692608066856, 3592747868819221472, 3592747866738832055, 3592878173873915099, 3592878173831998876, 3592878193209639829, 3592878193159351086, 3595276341861344083, 3595276341903287928, 3592876709181044503, 3592876709181044501, 3592880997840105564, 3592880997655547593, 3592748354175643228, 3592748354150509429, 3592881201842639017, 3592881201842639018, 3592882288410633241, 3592882288410633238, 3592748777171205176, 3592748777271879303, 3592877016271214939, 3592877016220848388, 3592747759180101626, 3592747759297544581, 3595276700398780919, 3595276700398780921, 3592747117082470219, 3592747117199911262, 3592881556118760740, 3592881556001283376, 3592708690177850566, 3592708690060408623, 3592881274680920101, 3592881274798405739, 3592881274865453906, 3592881274731263317, 3592881351990335712, 3592881352107792971, 3592881128702385567, 3592881128836575273, 3592706282865459829, 3592706282840314360, 3592583208388173122, 3592583206148423521, 3592745583863053944, 3592745583779165176, 3592878496021628601, 3592878495996473416, 3592584146695934374, 3592584146695934377, 3592881981253409613, 3592881981203050547, 3592746762932225799, 3592746762915473170, 3592586749563519648, 3592586749446062727, 3592879299113403015, 3592879299138569897, 3592881425172594285, 3592881425189314362, 3592747454421946914, 3592747454237395040, 3592880490899740552, 3592880491033937718, 3595277651801199624, 3595277651868292922, 3592880085159534683, 3592880084974980679, 3592708653502827415, 3592708653553179781, 3592881096490127568, 3592881096624326756, 3592876649143752159, 3592876649001148175, 3595277810597557438, 3595277810647854190, 3592881725652513009, 3592881725702827503, 3592877020700399907, 3592877020566160067, 3592876348353424056, 3592876348529601153, 3592882380718895833, 3592882380819545110, 3592876913141645931, 3592876913141645934, 3592878053455468553, 3592878053623257702, 3592880175169277423, 3592880175328720082, 3592748817889518885, 3592748818057329000, 3592881133131569487, 3592881132997340055, 3592881422974724476, 3592881422857326447, 3592877005533794464, 3592877005533794465, 3592745607518910355, 3592745607586020751, 3592746492340927665, 3592746492349296178, 3592747048413351235, 3592747048530772186, 3592879232423975728, 3592879232474312161, 3592881154505710711, 3592881154539267723, 3595277501552843658, 3595277501410225911, 3595276543766727635, 3595276543758352999, + } + + var dd = make([]string, 0, 0) + for _, v := range ddId { + skuObj := &model.StoreSkuBind{} + if err := dao.GetRow(dao.GetDB(), skuObj, "select * from store_sku_bind s where s.dd_id = ?", []interface{}{utils.Int64ToStr(v)}...); err != nil || skuObj.ID == 0 { + dd = append(dd, utils.Int64ToStr(v)) + } + } + fmt.Println("dd_id ", len(ddId)) + fmt.Println("dd2 ", len(dd)) + return strings.Join(dd, ",") +} diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index 50eb81d43..e8d5d9ce4 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -1,6 +1,7 @@ package cms import ( + "encoding/json" "errors" "fmt" "git.rosy.net.cn/jx-callback/globals/api/apimanager" @@ -949,6 +950,7 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s } func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isExd bool) (num int64, err error) { + globals.SugarLogger.Debugf("==========payload %s", utils.Format4Output(payload, false)) userName := ctx.GetUserName() skuName := &model.SkuName{} skuName.ID = nameID @@ -1024,6 +1026,9 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf panic(r) } }() + globals.SugarLogger.Debugf("UpdateEntityLogically 1 := %s", utils.Format4Output(skuName, false)) + globals.SugarLogger.Debugf("UpdateEntityLogically 2 := %s", utils.Format4Output(valid, false)) + globals.SugarLogger.Debugf("UpdateEntityLogically 3 := %s", userName) // valid[model.FieldJdSyncStatus] = model.SyncFlagModifiedMask | skuName.JdSyncStatus if num, err = dao.UpdateEntityLogically(db, skuName, valid, userName, nil); err != nil { dao.Rollback(db, txDB) @@ -1035,6 +1040,7 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return 0, err } } + if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil { if places, ok := payload["places"].([]interface{}); ok { if _, err = dao.DeleteSkuNamePlace(db, nameID, nil); err != nil { @@ -1080,6 +1086,28 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return 0, err } if len(skuIDs) > 0 { + // 判断是否改价 + nowPrice, _ := payload["price"].(json.Number).Int64() + if skuName.Price != int(nowPrice) && nowPrice != 0 { + + for _, v1 := range payload["skus"].([]interface{}) { + v := v1.(map[string]interface{}) + skuInfo := &aa{} + if err := utils.Map2StructByJson(v, skuInfo, false); err != nil { + globals.SugarLogger.Debugf("errr %v", err) + continue + } + var skuPrice int64 = 0 + if payload["unit"] == "份" { // 商品规格等于份的时候,标准重量保持为500g + skuPrice = int64(float64(skuInfo.SpecQuality) / float64(500) * float64(nowPrice)) + } else { + skuPrice = nowPrice + } + SetUpdateSkuPriceIfChange(db, skuPrice, nowPrice, skuInfo.Id) + } + } + + // 更新skuIds对应在store_sku_bind中的价格体系,解决老版本改价之前关注的商品,在价格修改后,store_sku_bind中京西价未修改的问题 if _, err = SetStoreSkuSyncStatus2(db, nil, partner.GetSingleStoreVendorIDs(), skuIDs, model.SyncFlagModifiedMask); err != nil { dao.Rollback(db, txDB) return 0, err @@ -1106,6 +1134,21 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return num, err } +type aa struct { + Id int `json:"id"` + SpecQuality int `json:"specQuality"` + SpecUnit string `json:"specUnit"` + Weight int `json:"weight"` + Status string `json:"status"` + Comment string `json:"comment"` + MinOrderCount int `json:"minOrderCount"` + LadderBoxNum int `json:"ladderBoxNum"` + LadderBoxPrice int `json:"ladderBoxPrice"` + EclpID string `json:"eclpID"` + CategoryID []interface{} `json:"categoryID"` + ExdSkuID string `json:"exdSkuID"` +} + func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, nameID int, payload map[string]interface{}, skuNameExt *model.SkuNameExt, isDelete bool) (flag bool) { if isDelete { skuVendorCatMaps, _ := dao.GetSkuVendorCategoryMaps(db, []int{nameID}, nil, nil) @@ -1189,6 +1232,13 @@ func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeIDs []int, vendorIDs, skuIDs []i return num, nil } +func SetUpdateSkuPriceIfChange(db *dao.DaoDB, skuPrice, nowPrice int64, skuId int) error { + sql := ` UPDATE store_sku_bind s SET s.price = ?,s.unit_price = ? WHERE s.sku_id = ? AND s.deleted_at = ?` + param := []interface{}{skuPrice, nowPrice, skuId, utils.DefaultTimeValue} + _, err := dao.ExecuteSQL(db, sql, param...) + return err +} + func UpdateSkuImg(ctx *jxcontext.Context, skuID int, payload map[string]interface{}) (string, error) { var ( db = dao.GetDB() diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index ca58d8aa3..c9ece74c9 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1628,9 +1628,11 @@ func DeleteStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } } //删除抖店映射 - if _, err1 := dao.ExecuteSQL(db, "DELETE FROM freight_template WHERE freight_template.store_id = ? ", storeID); err != nil { + //if vendorID == model.VendorIDDD { + if _, err1 := dao.ExecuteSQL(db, "DELETE FROM freight_template WHERE freight_template.store_id = ? ", storeID); err1 != nil { err = fmt.Errorf("%v,%v", err, err1) } + //} return num, err } @@ -4453,6 +4455,7 @@ func RefreshTiktokShopToken(ctx *jxcontext.Context) (err error) { v.UpdatedAt = time.Now() v.StoreBrandName = "定时任务更新" dao.UpdateEntity(db, v, "Token", "UpdatedAt", "StoreBrandName") + tiktok_store.HttpToGuoYuan(utils.Struct2MapByJson(v), "token") } } } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index ea0614765..ef96e6dc6 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -184,11 +184,9 @@ func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFla switch step { case 0: if singleStoreHandler != nil { - globals.SugarLogger.Debugf("==SyncStoreCategories===") _, err = SyncStoreCategories(ctx, task, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, false, isContinueWhenError) } case 1: - globals.SugarLogger.Debugf("==syncStoreSkuNew===") err = syncStoreSkuNew(ctx, task, causeFlag, false, vendorID, storeID, vendorOrgCode, nameIDs, skuIDs, excludeSkuIDs, useVendorPriceDirectly, isContinueWhenError) } return result, err diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 1ef8763d0..7c85a0fcb 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -245,11 +245,6 @@ func Init() { orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI, model.VendorIDDD}, 0, curDate, curDate, true, true) }, 5*time.Second, 10*time.Minute) - //刷新抖音门店token - ScheduleTimerFuncByInterval(func() { - cms.RefreshTiktokShopToken(jxcontext.AdminCtx) - }, 60*time.Second, 30*time.Minute) - // 抖音更新门店商品 if beego.BConfig.RunMode != "jxgy" { ScheduleTimerFunc("RefreshSyncSkuList", func() { @@ -257,6 +252,13 @@ func Init() { }, []string{"11:30:00"}) } + //刷新抖音门店token + if beego.BConfig.RunMode != "jxgy" { + ScheduleTimerFuncByInterval(func() { + cms.RefreshTiktokShopToken(jxcontext.AdminCtx) + }, 60*time.Second, 30*time.Minute) + } + // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { bidding.LoadingLogistics(nil) diff --git a/business/jxutils/enterprise_msg/enterprise_send_msg.go b/business/jxutils/enterprise_msg/enterprise_send_msg.go index 9c496c079..adf659e61 100644 --- a/business/jxutils/enterprise_msg/enterprise_send_msg.go +++ b/business/jxutils/enterprise_msg/enterprise_send_msg.go @@ -1,30 +1,31 @@ package enterprise_msg import ( + "fmt" enterprise "git.rosy.net.cn/baseapi/platformapi/enterprise_wechat" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" ) var enterpriseUserIdMap = map[string]string{ - "18080188338": "ShiFeng", - "13541389991": "ZhuMin", - "18982250714": "LaoZhaoTongXue", - "15680070110": "LiRongWei", - "18582617275": "TangXiaoLei", - "18583684218": "JingXiCaiShi-YanXiaoKang18583684218", - "17344357115": "YuanYe", - "18011597879": "YunYing7879", - "13608076295": "ZhangJiaLin", - "18981810340": "LiuLei", - "18744776542": "WuTingQi", - "17358644830": "ShengTianBanZi1376", - "15729837802": "ZhangShuWei", - "1": "2f43b42fd833d1e77420a8dae7419000", // 未设置号码 - "15928865396": "HeJiaMeng2", - "18780171617": "TianQinXin", - "17381914617": "TianQinXin2", - "15881105234": "WenShiQi", + "18080188338": "ShiFeng", + "13541389991": "ZhuMin", + "18982250714": "LaoZhaoTongXue", + "15680070110": "LiRongWei", + "18582617275": "TangXiaoLei", + "18583684218": "JingXiCaiShi-YanXiaoKang18583684218", + "17344357115": "YuanYe", + "18011597879": "YunYing7879", + "13608076295": "ZhangJiaLin", + "18981810340": "LiuLei", + "187447 76542": "WuTingQi", + "17358644830": "ShengTianBanZi1376", + "15729837802": "ZhangShuWei", + "1": "2f43b42fd833d1e77420a8dae7419000", // 未设置号码 + "15928865396": "HeJiaMeng2", + "18780171617": "TianQinXin", + "17381914617": "TianQinXin2", + "15881105234": "WenShiQi", } // SendUserMessage 发送文本卡片 @@ -35,11 +36,32 @@ func SendUserMessage(phone, title, description, url string) error { if id, ok := enterpriseUserIdMap[phone]; ok { enterpriseUserId = id } else { - enterpriseUserId, err = api.EnterpriseChatMin.GetUserIdByMobile(phone) + userList, err := api.EnterpriseChatMin.GetEnterpriseStaffInfo(enterprise.ParentDepartmentId) if err != nil { - enterpriseUserId = enterpriseUserIdMap["18981810340"] + globals.SugarLogger.Errorf("获取企业微信全职人员信息错误 : %v", err) + return err + } + for _, v := range userList { + if v.Mobile == "" { + api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{ + Touser: "ShiFeng", + Msgtype: enterprise.MsgTypeText, + Agentid: enterprise.EnterpriseAgentid, + Text: struct { + Content string `json:"content"` + }{Content: fmt.Sprintf("用户[%s]未添加企业微信联系电话,请联系添加电话号码[企业微信联系电话与京西系统保持一致!]", v.Name)}, + Safe: 0, + EnableIdTrans: 0, + EnableDuplicateCheck: 0, + DuplicateCheckInterval: 0, + }) + continue + } + if v.Mobile == phone { + enterpriseUserId = v.Userid + } + enterpriseUserIdMap[v.Mobile] = v.Userid } - enterpriseUserIdMap[phone] = enterpriseUserId } err = api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{ @@ -55,24 +77,6 @@ func SendUserMessage(phone, title, description, url string) error { DuplicateCheckInterval: 0, }) return err - // - //msg := &enterprise.EnterpriseSendMsgReq{ - // Touser: enterpriseUserId, - // Msgtype: enterprise.MsgTypeTextCard, - // Agentid: enterprise.EnterpriseAgentid, - // Textcard: enterprise.TextCardObject{ - // Title: title, - // Description: description, - // Url: url, - // Btntxt: "详情", - // }, - //} - //return api.EnterpriseChatMin.SendMsgToUser(msg) -} - -// SendUserMessageText 发送文本消息 -func SendUserMessageText() { - } func SendEnterpriseUserMessage(msgType, phone, title, content string) (err error) { diff --git a/business/model/store_sku.go b/business/model/store_sku.go index 7e84ef0e8..16768b358 100644 --- a/business/model/store_sku.go +++ b/business/model/store_sku.go @@ -118,7 +118,7 @@ type StoreSkuBind struct { YbID int64 `orm:"column(yb_id);index"` JdsID int64 `orm:"column(jds_id);index"` JdsWareID int64 `orm:"column(jds_ware_id)"` - //GmID string `orm:"column(gm_id)"` + // GmID string `orm:"column(gm_id)"` // WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId // WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId DdID int64 `orm:"column(dd_id);index"` // 子品主商品id diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 77a908022..f4d92ddb1 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -387,17 +387,19 @@ func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *mod // 将订单从购物平台配送转为自送 func (p *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) { if globals.EnableEbaiStoreWrite { - if err = api.EbaiAPI.OrderSwitchselfdelivery(order.VendorOrderID); err != nil { - if strings.Contains(err.Error(), "301251") { - api.EbaiAPI.OrderCancelDelivery(order.VendorOrderID) // 取消呼叫众包骑手 - } - if utils.IsErrMatch(err, "301251", nil) { - if deliveryStatus, err2 := api.EbaiAPI.OrderDeliveryGet(order.VendorOrderID); err2 == nil { - deliveryStatus := utils.Int64ToStr(utils.MustInterface2Int64(deliveryStatus["status"])) - if deliveryStatus == ebaiapi.WaybillStatusSelfDelivery { - err = nil - } else if deliveryStatus == ebaiapi.WaybillStatusDeliveryCancled { - p.trySyncCancelStatus(order.VendorOrderID) + if order.DeliveryType == model.OrderDeliveryTypePlatform { + if err = api.EbaiAPI.OrderSwitchselfdelivery(order.VendorOrderID); err != nil { + if strings.Contains(err.Error(), "301251") { + api.EbaiAPI.OrderCancelDelivery(order.VendorOrderID) // 取消呼叫众包骑手 + } + if utils.IsErrMatch(err, "301251", nil) { + if deliveryStatus, err2 := api.EbaiAPI.OrderDeliveryGet(order.VendorOrderID); err2 == nil { + deliveryStatus := utils.Int64ToStr(utils.MustInterface2Int64(deliveryStatus["status"])) + if deliveryStatus == ebaiapi.WaybillStatusSelfDelivery { + err = nil + } else if deliveryStatus == ebaiapi.WaybillStatusDeliveryCancled { + p.trySyncCancelStatus(order.VendorOrderID) + } } } } diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index 9bf6d126a..9211a667a 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -14,29 +14,31 @@ import ( // OnOrderMsg 抖音 func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackResponse) { - globals.SugarLogger.Debugf("GetCallbackOrderId tiktok msg %s", utils.Format4Output(msg, false)) if CurPurchaseHandler != nil { orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) - globals.SugarLogger.Debugf("shopId %d", shopId) - //if shopId != 0 { - //storeDetail, err := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), utils.Int64ToStr(shopId), model.VendorIDDD, "") - //globals.SugarLogger.Debugf("==storeDetail=: %s", utils.Format4Output(storeDetail, false)) - //globals.SugarLogger.Debugf("==err=: %s", utils.Format4Output(err, false)) - //if err != nil || storeDetail == nil || storeDetail.Store.ID == 0 { - // // 当前订单所属门店不属于菜市时,将消息推送到果园 - // gyMsg := map[string]interface{}{"tag": msgId, "msg_id": utils.Int64ToStr(time.Now().Unix()) + msgId, "data": msg} - // // 通知到果园 - // gyResult, err := HttpToGuoYuan(gyMsg, "order") - // if err != nil { - // return tiktokShop.Err2CallbackResponse(err, "") - // } - // result, _ := ioutil.ReadAll(gyResult.Body) - // var guoYuan *tiktokShop.CallbackResponse - // if err := json.Unmarshal(result, guoYuan); err != nil { - // return tiktokShop.Err2CallbackResponse(err, "") - // } - // return guoYuan + globals.SugarLogger.Debugf("order_id %s,%s", orderId, shopId) + //orderDetail, err := GetTiktokApi(utils.Int64ToStr(shopId), 0, "").GetTiktokOrderDetail(orderId) + //if err != nil { + // return tiktokShop.Err2CallbackResponse(err, "") //} + //vendorStoreID := orderDetail.ShopId + //if vendorStoreID != 0 { + // storeDetail, err := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), utils.Int64ToStr(vendorStoreID), model.VendorIDDD, "") + // if err != nil || storeDetail == nil || storeDetail.Store.ID == 0 { + // // 当前订单所属门店不属于菜市时,将消息推送到果园 + // gyMsg := map[string]interface{}{"tag": msgId, "msg_id": utils.Int64ToStr(time.Now().Unix()) + msgId, "data": msg} + // // 通知到果园 + // gyResult, err := HttpToGuoYuan(gyMsg, "order") + // if err != nil { + // return tiktokShop.Err2CallbackResponse(err, "") + // } + // result, _ := ioutil.ReadAll(gyResult.Body) + // var guoYuan *tiktokShop.CallbackResponse + // if err := json.Unmarshal(result, guoYuan); err != nil { + // return tiktokShop.Err2CallbackResponse(err, "") + // } + // return guoYuan + // } //} jxutils.CallMsgHandler(func() { response = CurPurchaseHandler.onOrderMsg(msgId, orderId, msg) @@ -46,6 +48,7 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes } func HttpToGuoYuan(param map[string]interface{}, requestType string) (*http.Response, error) { + globals.SugarLogger.Debugf("=========param %s", utils.Format4Output(param, false)) paramData, err := json.Marshal(param) if err != nil { return nil, err @@ -58,7 +61,8 @@ func HttpToGuoYuan(param map[string]interface{}, requestType string) (*http.Resp case "order": // 订单相关 url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg" case "token": // 授权相关 - case "wayBill": // 授权相关 + url = "http://callback-jxgy.jxc4.com/tiktokShop/jxcsToGyTiktokToken" + case "wayBill": // 运单消息 } httpReq, err := http.NewRequest(http.MethodPost, url, body) diff --git a/business/partner/purchase/tiktok_store/dy.go b/business/partner/purchase/tiktok_store/dy.go index 4e5544300..355e52627 100644 --- a/business/partner/purchase/tiktok_store/dy.go +++ b/business/partner/purchase/tiktok_store/dy.go @@ -221,19 +221,11 @@ func (p *PurchaseHandler) getUploadImgPoiCode() (poiCode string) { } func getAPI(appOrgCode string, storeID int, vendorStoreID string) (apiObj *tiktok_api.API) { - apiObj = partner.CurAPIManager.GetAPI(model.VendorIDDD, appOrgCode).(*tiktok_api.API) - //if appOrgCode == globals.TiktokShopCode { - // var storeDetail *dao.StoreDetail - // if storeID != 0 { - // storeDetail, _ = dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDDD, appOrgCode) - // } else if vendorStoreID != "" { - // storeDetail, _ = dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDDD, appOrgCode) - // } - // if storeDetail != nil { - // apiObj.SetToken(storeDetail.MtwmToken) - // } - //} - return apiObj + return partner.CurAPIManager.GetAPI(model.VendorIDDD, appOrgCode).(*tiktok_api.API) +} + +func GetTiktokApi(appOrgCode string, storeID int, vendorStoreID string) *tiktok_api.API { + return getAPI(appOrgCode, storeID, vendorStoreID) } func getAPIWithoutToken(appOrgCode string) (apiObj *tiktok_api.API) { diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index 6cafa1bda..d66bbb706 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -703,21 +703,22 @@ func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *mod if err != nil { return err } + api := getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "") if globals.EnableDdStoreWrite { if isAgree { errList := make([]string, 0, 0) // 同意仅退款 - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeOnlyRefundApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeOnlyRefundApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil } - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeToReturnOneApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeToReturnOneApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil } - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeToReturnTwoApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuAgreeToReturnTwoApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil @@ -729,17 +730,17 @@ func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *mod } else { errList := make([]string, 0, 0) // 拒绝退款 - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseOnlyRefundApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseOnlyRefundApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil } - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseToReturnOneApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseToReturnOneApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil } - if err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseToReturnTwoApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { + if err = api.AfterSaleOperate(tiktokShop.AfterSaleEmuRefuseToReturnTwoApply, afsOrder.AfsOrderID, reason, utils.Str2Int64(order.VendorStoreID)); err != nil { errList = append(errList, err.Error()) } else { return nil diff --git a/controllers/bidding.go b/controllers/bidding.go index e2d056e1c..0ab611689 100644 --- a/controllers/bidding.go +++ b/controllers/bidding.go @@ -81,3 +81,17 @@ func (c *BiddingController) GetStoreBindStatus() { return nil, "", nil }) } + +// NeedDeleteGetStoreBindStatus 查询门店是否绑定成功,成功之后创建本地门店 +// 查询门店是否绑定成功,成功之后创建本地门店 +// @Title 查询门店是否绑定成功,成功之后创建本地门店 +// @Description 查询门店是否绑定成功,成功之后创建本地门店 +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /NeedDeleteGetStoreBindStatus [get] +func (c *BiddingController) NeedDeleteGetStoreBindStatus() { + c.callNeedDeleteGetStoreBindStatus(func(params *tBindNeedDeleteGetStoreBindStatusParams) (interface{}, string, error) { + dd := bidding.QueryNeedDeleteSku() + return dd, "", nil + }) +} diff --git a/controllers/tiktok_store.go b/controllers/tiktok_store.go index df46382c2..3ad78c873 100644 --- a/controllers/tiktok_store.go +++ b/controllers/tiktok_store.go @@ -150,9 +150,28 @@ func (c *TiktokShopController) TokenMsg() { return } - // 授权码发生变化,通知到果园 - { + c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess} + c.ServeJSON() +} +func (c *TiktokShopController) JxcsToGyTiktokToken() { + data, err := ioutil.ReadAll(c.Ctx.Request.Body) + if err != nil { + c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} + c.ServeJSON() + return + } + param := &model.VendorOrgCode{} + if err := json.Unmarshal(data, param); err != nil { + c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} + c.ServeJSON() + return + } + + if err := common.AddVendorOrgCode(nil, param); err != nil { + c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail} + c.ServeJSON() + return } c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess} diff --git a/controllers/version_config_controller.go b/controllers/version_config_controller.go index aa80bc61e..ca887b722 100644 --- a/controllers/version_config_controller.go +++ b/controllers/version_config_controller.go @@ -12,8 +12,8 @@ type VersionController struct { // @Title 添加小程序的版本控制 // @Description 添加小程序的版本控制 // @Param token header string true "认证token" -// @Param appId header string true "小程序id" -// @Param version header string true "小程序版本" +// @Param appId query string true "小程序id" +// @Param version query string true "小程序版本" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AddVersionController [post] @@ -27,8 +27,8 @@ func (c *VersionController) AddVersionController() { // @Title 修改小程序的版本控制 // @Description 修改小程序的版本控制 // @Param token header string true "认证token" -// @Param appId header string true "小程序id" -// @Param version header string true "小程序版本" +// @Param appId query string true "小程序id" +// @Param version query string true "小程序版本" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /UpdateVersionController [post] @@ -42,7 +42,7 @@ func (c *VersionController) UpdateVersionController() { // @Title 获取版本控制 // @Description 获取版本控制 // @Param token header string false "认证token" -// @Param appId header string false "小程序id" +// @Param appId query string false "小程序id" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetVersionController [get] diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 90d95cbdf..9758b5f5d 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -4197,6 +4197,14 @@ func init() { MethodParams: param.Make(), Filters: nil, Params: nil}) + web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BiddingController"], + web.ControllerComments{ + Method: "NeedDeleteGetStoreBindStatus", + Router: `/NeedDeleteGetStoreBindStatus`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) // 版本设置 web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:VersionController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:VersionController"],