From aa3bfcd4c2a436a3fb986b14fa30a8d90e397545 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 20 Sep 2019 09:11:41 +0800 Subject: [PATCH 1/5] =?UTF-8?q?-=20BatchUpdateEntityByKV=E4=B8=ADpanic?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=89=93=E5=8D=B0=E8=B0=83=E8=AF=95=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 27 ++++++++++++++++---------- business/model/dao/dao_bz.go | 20 +++++++++++++++++-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 71f8e725c..80715e406 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -28,13 +28,10 @@ var ( func CreateStoreCategoryByStoreSku(ctx *jxcontext.Context, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs []int) (err error) { globals.SugarLogger.Debugf("CreateStoreCategoryByStoreSku vendorID:%d, storeID:%d", vendorID, storeID) db := dao.GetDB() - dao.Begin(db) defer func() { - if r := recover(); r != nil || err != nil { + if r := recover(); r != nil { dao.Rollback(db) - if r != nil { - panic(r) - } + panic(r) } }() for i := 0; i < 2; i++ { @@ -42,15 +39,19 @@ func CreateStoreCategoryByStoreSku(ctx *jxcontext.Context, vendorID, storeID int if err = err2; err != nil { return err } - for _, v := range localCats { - if v.MapID == 0 { - if err = dao.AddStoreCategoryMap(db, storeID, v.ID, vendorID, "", model.SyncFlagNewMask, ctx.GetUserName()); err != nil { - return err + if len(localCats) > 0 { + dao.Begin(db) + for _, v := range localCats { + if v.MapID == 0 { + if err = dao.AddStoreCategoryMap(db, storeID, v.ID, vendorID, "", model.SyncFlagNewMask, ctx.GetUserName()); err != nil { + dao.Rollback(db) + return err + } } } + dao.Commit(db) } } - dao.Commit(db) return err } @@ -257,6 +258,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyncInfo, syncStatus int8) (num int64, err error) { if len(storeSkuList) > 0 { + // defer func() { + // if r := recover(); r != nil { + // globals.SugarLogger.Debugf("updateStoreSku panic, vendorID:%d, len:%d, storeID0:%d, skuID0:%d, syncStatus:%d", vendorID, len(storeSkuList), storeSkuList[0].StoreID, storeSkuList[0].SkuID, syncStatus) + // panic(r) + // } + // }() updateItemList := make([]*dao.KVUpdateItem, len(storeSkuList)) for k, v := range storeSkuList { updateItemList[k] = sku2Update(vendorID, v, syncStatus) diff --git a/business/model/dao/dao_bz.go b/business/model/dao/dao_bz.go index 70838b7c5..649ea5eb0 100644 --- a/business/model/dao/dao_bz.go +++ b/business/model/dao/dao_bz.go @@ -73,8 +73,24 @@ func BatchUpdateEntityByKV(db *DaoDB, items []*KVUpdateItem) (num int64, err err // } // } // }() - for _, v := range items { - num2, err2 := UpdateEntityByKV(db, v.Item, v.KVs, nil) + + var item *KVUpdateItem + defer func() { + if r := recover(); r != nil { + if item != nil { + var bindID int64 + value := refutil.CheckAndGetStructValue(item.Item).FieldByName(model.FieldID) + if value.IsValid() { + bindID = value.Int() + } + globals.SugarLogger.Debugf("BatchUpdateEntityByKV panic, bindID:%d, KVs:%s", bindID, utils.Format4Output(item.KVs, true)) + } + panic(r) + } + }() + + for _, item = range items { + num2, err2 := UpdateEntityByKV(db, item.Item, item.KVs, nil) if err = err2; err != nil { return 0, err } From 2409b4f323c14dbea9e61feff17bea0e1b5f4a55 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 20 Sep 2019 10:30:45 +0800 Subject: [PATCH 2/5] =?UTF-8?q?-=20=E6=AF=8F=E6=99=9A8=E7=82=B9=E5=86=8D?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=B8=80=E6=AC=A1=E5=B9=B3=E5=8F=B0=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 1 + business/model/dao/food_recipe_test.go | 2 +- business/model/dao/store_test.go | 8 ++++++++ business/userstore/food_recipe.go | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 81bb6f7b4..d028028f3 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -103,6 +103,7 @@ var ( "10:00:00", "11:00:00", "15:00:00", + "20:00:00", } ) diff --git a/business/model/dao/food_recipe_test.go b/business/model/dao/food_recipe_test.go index 689ee2439..471c44e8a 100644 --- a/business/model/dao/food_recipe_test.go +++ b/business/model/dao/food_recipe_test.go @@ -6,7 +6,7 @@ import ( func TestQueryRecipes(t *testing.T) { db := GetDB() - recipeList, err := QueryFoodRecipes(db, "", -1, "", "") + recipeList, _, err := QueryFoodRecipes(db, "", 0, "", "", 0, 0) if err != nil { t.Fatal(err) } diff --git a/business/model/dao/store_test.go b/business/model/dao/store_test.go index d0455d9e6..6905a1c0f 100644 --- a/business/model/dao/store_test.go +++ b/business/model/dao/store_test.go @@ -38,3 +38,11 @@ func TestGetStoreList4Role(t *testing.T) { t.Fatal(err) } } + +func TestGetStoresMapList(t *testing.T) { + storeList, err := GetStoresMapList(GetDB(), nil, nil, model.StoreStatusClosed, model.StoreIsSyncYes, "") + t.Log(utils.Format4Output(storeList, false)) + if err != nil { + t.Fatal(err) + } +} diff --git a/business/userstore/food_recipe.go b/business/userstore/food_recipe.go index 6b585a4df..9fd93acf8 100644 --- a/business/userstore/food_recipe.go +++ b/business/userstore/food_recipe.go @@ -74,6 +74,7 @@ func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID RecipeID: recipeID, Index: int8(k + 1), Name: v.Name, + Img: v.Img, } dao.WrapAddIDCULDEntity(step, ctx.GetUserName()) if err = dao.CreateEntity(db, step); err != nil { From 479fb6e1d93ea91e029d9e0498bd1674e92c8530 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 20 Sep 2019 10:41:30 +0800 Subject: [PATCH 3/5] - up --- business/userstore/food_recipe.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/business/userstore/food_recipe.go b/business/userstore/food_recipe.go index 9fd93acf8..1f7218922 100644 --- a/business/userstore/food_recipe.go +++ b/business/userstore/food_recipe.go @@ -71,10 +71,11 @@ func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID for k, v := range stepList { step := &model.FoodRecipeStep{ - RecipeID: recipeID, - Index: int8(k + 1), - Name: v.Name, - Img: v.Img, + RecipeID: recipeID, + Index: int8(k + 1), + Name: v.Name, + Img: v.Img, + Description: v.Description, } dao.WrapAddIDCULDEntity(step, ctx.GetUserName()) if err = dao.CreateEntity(db, step); err != nil { From af931ce49610c74f54b7364730f35cf0b6268b44 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 20 Sep 2019 10:53:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?-=20ebai=E7=9A=84shop=5Ffee=E7=94=A8ForceIn?= =?UTF-8?q?terface2Int64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/ebai/order.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 5bb422226..d7c4257d8 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -188,8 +188,8 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo StatusTime: getTimeFromInterface(orderMap["create_time"]), OrderCreatedAt: getTimeFromInterface(orderMap["create_time"]), OriginalData: string(utils.MustMarshal(result)), - ActualPayPrice: utils.MustInterface2Int64(orderMap["user_fee"]), - TotalShopMoney: utils.MustInterface2Int64(orderMap["shop_fee"]), + ActualPayPrice: utils.ForceInterface2Int64(orderMap["user_fee"]), + TotalShopMoney: utils.ForceInterface2Int64(orderMap["shop_fee"]), } if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) { order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 饿百要求在5分钟内拣货,不然订单会被取消 From a5b8513eb5dfb653ae4c9f148d9a8a203fe8566d Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 20 Sep 2019 11:22:46 +0800 Subject: [PATCH 5/5] =?UTF-8?q?-=20=E9=A5=BF=E7=99=BE=E5=AF=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=B9=9F=E8=AE=BE=E7=BD=AEdeliveryType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/ebai/financial.go | 2 +- business/partner/purchase/ebai/order.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/ebai/financial.go b/business/partner/purchase/ebai/financial.go index 66c13c6d6..f7109eb7f 100644 --- a/business/partner/purchase/ebai/financial.go +++ b/business/partner/purchase/ebai/financial.go @@ -195,7 +195,7 @@ func (p *PurchaseHandler) OrderDetail2Financial(result map[string]interface{}) ( orderFinancial.ReceivableFreight = utils.MustInterface2Int64(order1["send_fee"]) orderFinancial.DownFlag = int8(utils.MustInterface2Int64(order1["down_flag"])) - if int(getInt64FromInterface(order1["delivery_party"])) == ebaiapi.SendImmediatelySelf { + if int(getInt64FromInterface(order1["delivery_party"])) == ebaiapi.DeliveryPartyFengElmSelf { orderFinancial.SelfDeliveryDiscountMoney = orderFinancial.ReceivableFreight orderFinancial.DistanceFreightMoney = 0 // 通过本地数据库去取是否转美团/达达,并计算运费 diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index d7c4257d8..44e8a2590 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -56,8 +56,19 @@ var ( ebaiapi.OrderSkuDiscountTypeZhe: 1, ebaiapi.OrderSkuDiscountTypeReduce: 1, } + deliveryTypeMap = map[int]string{ + ebaiapi.DeliveryPartyFengElmSelf: model.OrderDeliveryTypeStoreSelf, + } ) +func mapDeliveryType(ebaiDeliveryParty int) (deliveryType string) { + deliveryType = deliveryTypeMap[ebaiDeliveryParty] + if deliveryType == "" { + deliveryType = model.OrderDeliveryTypePlatform + } + return deliveryType +} + func (p *PurchaseHandler) getStatusFromVendorStatus(vendorStatus string) int { if status, ok := VendorStatus2StatusMap[vendorStatus]; ok { return status @@ -190,6 +201,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo OriginalData: string(utils.MustMarshal(result)), ActualPayPrice: utils.ForceInterface2Int64(orderMap["user_fee"]), TotalShopMoney: utils.ForceInterface2Int64(orderMap["shop_fee"]), + DeliveryType: mapDeliveryType(int(utils.ForceInterface2Int64(orderMap["delivery_party"]))), } if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) { order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 饿百要求在5分钟内拣货,不然订单会被取消