刷新京西调价包
This commit is contained in:
@@ -124,7 +124,8 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
|
|||||||
|
|
||||||
func (c *BaseScheduler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
func (c *BaseScheduler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||||
globals.SugarLogger.Infof("SelfDeliverDelivered orderID:%s", order.VendorOrderID)
|
globals.SugarLogger.Infof("SelfDeliverDelivered orderID:%s", order.VendorOrderID)
|
||||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status == model.OrderStatusDelivering {
|
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status >= model.OrderStatusFinishedPickup &&
|
||||||
|
order.Status <= model.OrderStatusDelivering {
|
||||||
if c.IsReallyCallPlatformAPI {
|
if c.IsReallyCallPlatformAPI {
|
||||||
err = utils.CallFuncLogError(func() error {
|
err = utils.CallFuncLogError(func() error {
|
||||||
return partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivered(order, userName)
|
return partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivered(order, userName)
|
||||||
|
|||||||
@@ -407,6 +407,10 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, vendorOr
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
act.VendorMask = model.GetVendorMask(vendorIDs...)
|
act.VendorMask = model.GetVendorMask(vendorIDs...)
|
||||||
|
if act.VendorMask&(^model.GetVendorMask(model.VendorIDJX)) != 0 &&
|
||||||
|
vendorOrgCode == "" {
|
||||||
|
return "", fmt.Errorf("必须指定平台分账号信息")
|
||||||
|
}
|
||||||
setActDefault(act)
|
setActDefault(act)
|
||||||
|
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func GetCategories(ctx *jxcontext.Context, parentID int) (catList []*dao.SkuCate
|
|||||||
ids = append(ids, v.ID)
|
ids = append(ids, v.ID)
|
||||||
}
|
}
|
||||||
thingMapMap, err2 := dao.GetThingMapMap(db, model.ThingTypeCategory, nil, ids)
|
thingMapMap, err2 := dao.GetThingMapMap(db, model.ThingTypeCategory, nil, ids)
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(thingMapMap, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(thingMapMap, false))
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
for _, v := range cats {
|
for _, v := range cats {
|
||||||
catList = append(catList, &dao.SkuCategoryWithVendor{
|
catList = append(catList, &dao.SkuCategoryWithVendor{
|
||||||
|
|||||||
@@ -1037,7 +1037,13 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
|||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
storeMap.StoreID = storeID
|
storeMap.StoreID = storeID
|
||||||
storeMap.VendorID = vendorID
|
storeMap.VendorID = vendorID
|
||||||
|
storeMap.Status = model.StoreStatusOpened
|
||||||
|
storeMap.DeliveryType = model.StoreDeliveryTypeByStore
|
||||||
|
storeMap.SyncStatus = 0
|
||||||
if vendorID != model.VendorIDJX {
|
if vendorID != model.VendorIDJX {
|
||||||
|
if storeMap.VendorOrgCode == "" {
|
||||||
|
return nil, fmt.Errorf("必须指定平台分账号信息")
|
||||||
|
}
|
||||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||||
store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID)
|
store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID)
|
||||||
if err = err2; err == nil || storeMap.IsSync == 0 {
|
if err = err2; err == nil || storeMap.IsSync == 0 {
|
||||||
@@ -1054,8 +1060,8 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
|||||||
} else {
|
} else {
|
||||||
ReCalculateJxPrice(ctx, []int{storeID})
|
ReCalculateJxPrice(ctx, []int{storeID})
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(storeMap, userName)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
dao.WrapAddIDCULDEntity(storeMap, userName)
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
}
|
}
|
||||||
@@ -1103,9 +1109,12 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
|||||||
return 0, fmt.Errorf("非京东平台要求必须自动拣货")
|
return 0, fmt.Errorf("非京东平台要求必须自动拣货")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storeHandler := CurVendorSync.GetStoreHandler(vendorID)
|
var storeHandler partner.IPurchasePlatformHandler
|
||||||
if storeHandler == nil {
|
if vendorID != model.VendorIDJX {
|
||||||
return 0, ErrCanNotFindVendor
|
storeHandler = CurVendorSync.GetStoreHandler(vendorID)
|
||||||
|
if storeHandler == nil {
|
||||||
|
return 0, ErrCanNotFindVendor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -1143,12 +1152,14 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
if vendorID != model.VendorIDJX {
|
||||||
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID)
|
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
||||||
if err = err2; err == nil {
|
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID)
|
||||||
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
if err = err2; err == nil {
|
||||||
|
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
||||||
|
}
|
||||||
|
err = nil // todo 忽略读不到DeliveryType的错误
|
||||||
}
|
}
|
||||||
err = nil // todo 忽略读不到DeliveryType的错误
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -1156,7 +1167,10 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
|||||||
if len(valid) > 0 {
|
if len(valid) > 0 {
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
dao.Rollback(db)
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
if valid["status"] != nil { // 对于store vendor map,只有Status改变才需要同步到厂商
|
if valid["status"] != nil { // 对于store vendor map,只有Status改变才需要同步到厂商
|
||||||
num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{
|
num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{
|
||||||
@@ -1169,23 +1183,32 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
|||||||
model.FieldVendorID: vendorID,
|
model.FieldVendorID: vendorID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err == nil && num > 0 {
|
if err != nil {
|
||||||
if valid["pricePercentage"] != nil || valid["pricePercentagePack"] != nil {
|
dao.Rollback(db)
|
||||||
if vendorID == model.VendorIDJX {
|
return 0, err
|
||||||
|
}
|
||||||
|
if num > 0 {
|
||||||
|
// TODO 重算京西商城价
|
||||||
|
if vendorID != model.VendorIDJX {
|
||||||
|
if valid["pricePercentage"] != nil || valid["pricePercentagePack"] != nil {
|
||||||
|
storeSkuBind := &model.StoreSkuBind{}
|
||||||
|
if num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeSkuBind, nil, userName, map[string]interface{}{
|
||||||
|
model.FieldStoreID: storeID,
|
||||||
|
}, dao.GetSyncStatusStructField(model.VendorNames[vendorID]), model.SyncFlagPriceMask); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if valid["pricePercentage"] != nil || valid["pricePercentagePack"] != nil {
|
||||||
ReCalculateJxPrice(ctx, []int{storeID})
|
ReCalculateJxPrice(ctx, []int{storeID})
|
||||||
}
|
}
|
||||||
storeSkuBind := &model.StoreSkuBind{}
|
|
||||||
if num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeSkuBind, nil, userName, map[string]interface{}{
|
|
||||||
model.FieldStoreID: storeID,
|
|
||||||
}, dao.GetSyncStatusStructField(model.VendorNames[vendorID]), model.SyncFlagPriceMask); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dao.Commit(db)
|
|
||||||
if valid["status"] != nil || valid["freightDeductionPack"] != nil {
|
|
||||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil) {
|
||||||
|
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num, err
|
return num, err
|
||||||
|
|||||||
@@ -266,10 +266,10 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
}
|
}
|
||||||
sql += ")"
|
sql += ")"
|
||||||
}
|
}
|
||||||
if params["jdID"] != nil {
|
// if params["jdID"] != nil {
|
||||||
sql += " AND t1.jd_id = ?"
|
// sql += " AND t1.jd_id = ?"
|
||||||
sqlParams = append(sqlParams, params["jdID"].(int))
|
// sqlParams = append(sqlParams, params["jdID"].(int))
|
||||||
}
|
// }
|
||||||
if params["name"] != nil {
|
if params["name"] != nil {
|
||||||
sql += " AND t1.name LIKE ?"
|
sql += " AND t1.name LIKE ?"
|
||||||
sqlParams = append(sqlParams, "%"+params["name"].(string)+"%")
|
sqlParams = append(sqlParams, "%"+params["name"].(string)+"%")
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func (v *VendorSync) syncCategories(ctx *jxcontext.Context, parentTask tasksch.I
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
||||||
if !model.IsUseThingMap {
|
if !globals.IsUseThingMap {
|
||||||
return v.oldSyncCategory(ctx, db, categoryID, isAsync, userName)
|
return v.oldSyncCategory(ctx, db, categoryID, isAsync, userName)
|
||||||
}
|
}
|
||||||
return SyncCategories(ctx, nil, nil, nil, []int{categoryID}, isAsync)
|
return SyncCategories(ctx, nil, nil, nil, []int{categoryID}, isAsync)
|
||||||
@@ -165,7 +165,7 @@ func (v *VendorSync) oldSyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, cate
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
||||||
if !model.IsUseThingMap {
|
if !globals.IsUseThingMap {
|
||||||
return v.oldSyncReorderCategories(ctx, db, categoryID, isAsync, userName)
|
return v.oldSyncReorderCategories(ctx, db, categoryID, isAsync, userName)
|
||||||
}
|
}
|
||||||
return SyncReorderCategories(ctx, -1, isAsync)
|
return SyncReorderCategories(ctx, -1, isAsync)
|
||||||
@@ -188,7 +188,6 @@ func (v *VendorSync) oldSyncReorderCategories(ctx *jxcontext.Context, db *dao.Da
|
|||||||
|
|
||||||
func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID, storeID int, isAsync bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID, storeID int, isAsync bool, userName string) (hint string, err error) {
|
||||||
globals.SugarLogger.Debugf("SyncStore, storeID:%d", storeID)
|
globals.SugarLogger.Debugf("SyncStore, storeID:%d", storeID)
|
||||||
|
|
||||||
var vendorIDs []int
|
var vendorIDs []int
|
||||||
if vendorID != -1 {
|
if vendorID != -1 {
|
||||||
vendorIDs = []int{
|
vendorIDs = []int{
|
||||||
@@ -198,35 +197,38 @@ func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID,
|
|||||||
hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("同步门店信息:%d", storeID), isAsync, false, vendorIDs, []int{storeID}, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) {
|
hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("同步门店信息:%d", storeID), isAsync, false, vendorIDs, []int{storeID}, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) {
|
||||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||||
handler := v.GetStoreHandler(loopMapInfo.VendorID)
|
handler := v.GetStoreHandler(loopMapInfo.VendorID)
|
||||||
if len(loopMapInfo.StoreMapList) > 1 {
|
if handler != nil {
|
||||||
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), nil, ctx,
|
if len(loopMapInfo.StoreMapList) > 1 {
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), nil, ctx,
|
||||||
var resultList []interface{}
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
var resultList []interface{}
|
||||||
db2 := db
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
if len(loopMapInfo.StoreMapList) > 1 {
|
db2 := db
|
||||||
db2 = dao.GetDB()
|
if len(loopMapInfo.StoreMapList) > 1 {
|
||||||
}
|
db2 = dao.GetDB()
|
||||||
if err = handler.UpdateStore(db2, storeMap.StoreID, userName); err == nil {
|
}
|
||||||
storeMap.SyncStatus = 0
|
if err = handler.UpdateStore(db2, storeMap.StoreID, userName); err == nil {
|
||||||
_, err = dao.UpdateEntity(db2, storeMap, model.FieldSyncStatus)
|
storeMap.SyncStatus = 0
|
||||||
resultList = append(resultList, 1)
|
_, err = dao.UpdateEntity(db2, storeMap, model.FieldSyncStatus)
|
||||||
}
|
resultList = append(resultList, 1)
|
||||||
return resultList, err
|
}
|
||||||
}, loopMapInfo.StoreMapList)
|
return resultList, err
|
||||||
t.AddChild(loopStoreTask).Run()
|
}, loopMapInfo.StoreMapList)
|
||||||
resultList, err = loopStoreTask.GetResult(0)
|
t.AddChild(loopStoreTask).Run()
|
||||||
} else {
|
resultList, err = loopStoreTask.GetResult(0)
|
||||||
storeMap := loopMapInfo.StoreMapList[0]
|
} else {
|
||||||
if err = handler.UpdateStore(db, storeMap.StoreID, userName); err == nil {
|
storeMap := loopMapInfo.StoreMapList[0]
|
||||||
storeMap.SyncStatus = 0
|
if err = handler.UpdateStore(db, storeMap.StoreID, userName); err == nil {
|
||||||
_, err = dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
|
storeMap.SyncStatus = 0
|
||||||
}
|
_, err = dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
|
||||||
if err == nil {
|
}
|
||||||
resultList = []interface{}{1}
|
if err == nil {
|
||||||
|
resultList = []interface{}{1}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
err = partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||||
}
|
}
|
||||||
return resultList, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
return resultList, err
|
||||||
}, true)
|
}, true)
|
||||||
return hint, makeSyncError(err)
|
return hint, makeSyncError(err)
|
||||||
}
|
}
|
||||||
@@ -246,7 +248,7 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
|
||||||
if !model.IsUseThingMap {
|
if !globals.IsUseThingMap {
|
||||||
return v.oldSyncSkus(ctx, db, nameIDs, skuIDs, isAsync, isContinueWhenError, userName)
|
return v.oldSyncSkus(ctx, db, nameIDs, skuIDs, isAsync, isContinueWhenError, userName)
|
||||||
}
|
}
|
||||||
return SyncSkus(ctx, nil, nil, nil, nameIDs, skuIDs, isAsync)
|
return SyncSkus(ctx, nil, nil, nil, nameIDs, skuIDs, isAsync)
|
||||||
@@ -561,6 +563,7 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskN
|
|||||||
if len(loopInfoList) == 1 {
|
if len(loopInfoList) == 1 {
|
||||||
taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID])
|
taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID])
|
||||||
}
|
}
|
||||||
|
// globals.SugarLogger.Debugf("LoopStoresMap2 loopInfoList:%s", utils.Format4Output(loopInfoList, false))
|
||||||
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
||||||
tasksch.HandleTask(task, nil, isManageIt).Run()
|
tasksch.HandleTask(task, nil, isManageIt).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
|
|||||||
@@ -167,9 +167,13 @@ func OnCreateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
|
||||||
errList.AddErr(dao.CreateEntity(db, thingMap))
|
errList.AddErr(dao.CreateEntity(db, thingMap))
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
}
|
}
|
||||||
// return errList.GetErrListAsOne()
|
if globals.IsUseThingMap {
|
||||||
return nil
|
err = errList.GetErrListAsOne()
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
|
func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
|
||||||
@@ -190,12 +194,16 @@ func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
thingMap.LastOperator = ctx.GetUserName()
|
thingMap.LastOperator = ctx.GetUserName()
|
||||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
} else if !dao.IsNoRowsError(err2) {
|
} else if !dao.IsNoRowsError(err2) {
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return errList.GetErrListAsOne()
|
if globals.IsUseThingMap {
|
||||||
return nil
|
err = errList.GetErrListAsOne()
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
|
func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
|
||||||
@@ -221,12 +229,16 @@ func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
thingMap.LastOperator = ctx.GetUserName()
|
thingMap.LastOperator = ctx.GetUserName()
|
||||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
} else if !dao.IsNoRowsError(err2) {
|
} else if !dao.IsNoRowsError(err2) {
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return errList.GetErrListAsOne()
|
if globals.IsUseThingMap {
|
||||||
return nil
|
err = errList.GetErrListAsOne()
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkuCategoryVendor2ThingMap(cat *dao.SkuStoreCatInfo) (thingMap *model.ThingMap) {
|
func SkuCategoryVendor2ThingMap(cat *dao.SkuStoreCatInfo) (thingMap *model.ThingMap) {
|
||||||
@@ -253,6 +265,7 @@ func SkuVendor2ThingMap(sku *dao.StoreSkuSyncInfo) (thingMap *model.ThingMap) {
|
|||||||
SyncStatus: sku.SkuSyncStatus,
|
SyncStatus: sku.SkuSyncStatus,
|
||||||
VendorThingID: sku.VendorSkuID,
|
VendorThingID: sku.VendorSkuID,
|
||||||
}
|
}
|
||||||
|
thingMap.DeletedAt = utils.DefaultTimeValue
|
||||||
thingMap.ID = sku.BindID // 一定要赋值
|
thingMap.ID = sku.BindID // 一定要赋值
|
||||||
return thingMap
|
return thingMap
|
||||||
}
|
}
|
||||||
@@ -282,6 +295,26 @@ func OnThingSync(ctx *jxcontext.Context, db *dao.DaoDB, thingMap *model.ThingMap
|
|||||||
thingMap.UpdatedAt = time.Now()
|
thingMap.UpdatedAt = time.Now()
|
||||||
thingMap.Remark = ""
|
thingMap.Remark = ""
|
||||||
_, err = dao.UpdateEntity(db, thingMap, updateFields...)
|
_, err = dao.UpdateEntity(db, thingMap, updateFields...)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateThingMapEntity(db *dao.DaoDB, thingMap *model.ThingMap) {
|
||||||
|
if thingMap.ThingType == model.ThingTypeCategory {
|
||||||
|
cat := &model.SkuCategory{
|
||||||
|
JdID: utils.Str2Int64WithDefault(thingMap.VendorThingID, 0),
|
||||||
|
JdSyncStatus: thingMap.SyncStatus,
|
||||||
|
}
|
||||||
|
cat.ID = int(thingMap.ThingID)
|
||||||
|
dao.UpdateEntity(db, cat, "JdID", "JdSyncStatus")
|
||||||
|
} else if thingMap.ThingType == model.ThingTypeSku {
|
||||||
|
sku := &model.Sku{
|
||||||
|
JdID: utils.Str2Int64WithDefault(thingMap.VendorThingID, 0),
|
||||||
|
JdSyncStatus: thingMap.SyncStatus,
|
||||||
|
}
|
||||||
|
sku.ID = int(thingMap.ThingID)
|
||||||
|
dao.UpdateEntity(db, sku, "JdID", "JdSyncStatus")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ func GetSkuCategoryWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string,
|
|||||||
t1m.sync_status cat_sync_status,
|
t1m.sync_status cat_sync_status,
|
||||||
|
|
||||||
t1pm.id parent_map_id,
|
t1pm.id parent_map_id,
|
||||||
t1pm.t1p.name parent_cat_name
|
t1p.name parent_cat_name,
|
||||||
t1pm.vendor_thing_id parent_vendor_cat_id,
|
t1pm.vendor_thing_id parent_vendor_cat_id,
|
||||||
t1pm.sync_status parent_cat_sync_status
|
t1pm.sync_status parent_cat_sync_status
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ func GetDirtyStoreCategories(db *DaoDB, vendorID, storeID int, level int) (cats
|
|||||||
// 以store_sku_bind为基础来做同步,正常情况下使用
|
// 以store_sku_bind为基础来做同步,正常情况下使用
|
||||||
// 单多门店模式厂商通用
|
// 单多门店模式厂商通用
|
||||||
func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty bool) (skus []*StoreSkuSyncInfo, err error) {
|
func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty bool) (skus []*StoreSkuSyncInfo, err error) {
|
||||||
if !model.IsUseThingMap {
|
if !globals.IsUseThingMap {
|
||||||
return oldGetStoreSkus2(db, vendorID, storeID, skuIDs, mustDirty)
|
return oldGetStoreSkus2(db, vendorID, storeID, skuIDs, mustDirty)
|
||||||
}
|
}
|
||||||
return newGetStoreSkus2(db, vendorID, storeID, skuIDs, mustDirty)
|
return newGetStoreSkus2(db, vendorID, storeID, skuIDs, mustDirty)
|
||||||
@@ -495,7 +495,7 @@ func GetStoreSkus(db *DaoDB, vendorID, storeID int, skuIDs []int) (skus []*Store
|
|||||||
// 以sku为基础来做全同步,
|
// 以sku为基础来做全同步,
|
||||||
// 多门店模式厂商适用
|
// 多门店模式厂商适用
|
||||||
func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInfo, err error) {
|
func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInfo, err error) {
|
||||||
if !model.IsUseThingMap {
|
if !globals.IsUseThingMap {
|
||||||
return oldGetFullStoreSkus(db, vendorID, storeID)
|
return oldGetFullStoreSkus(db, vendorID, storeID)
|
||||||
}
|
}
|
||||||
return newGetFullStoreSkus(db, vendorID, storeID)
|
return newGetFullStoreSkus(db, vendorID, storeID)
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ const (
|
|||||||
ThingTypeSku = 3
|
ThingTypeSku = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
IsUseThingMap = false
|
|
||||||
)
|
|
||||||
|
|
||||||
type ThingMap struct {
|
type ThingMap struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ zhongwuAppSecret = "29435497822f52f3cf659c65da548a79"
|
|||||||
getWeixinTokenKey = "c928ed0d-87a3-441a-8517-f92f0167296f"
|
getWeixinTokenKey = "c928ed0d-87a3-441a-8517-f92f0167296f"
|
||||||
storeName = "京西菜市"
|
storeName = "京西菜市"
|
||||||
|
|
||||||
|
useThingMap = false
|
||||||
|
|
||||||
[dev]
|
[dev]
|
||||||
jdOrgCode = "320406"
|
jdOrgCode = "320406"
|
||||||
jdToken = "77e703b7-7997-441b-a12a-2e522efb117a"
|
jdToken = "77e703b7-7997-441b-a12a-2e522efb117a"
|
||||||
@@ -292,6 +294,8 @@ enableEbaiStoreWrite = true
|
|||||||
enableMtwmStoreWrite = true
|
enableMtwmStoreWrite = true
|
||||||
enableWscStoreWrite = false
|
enableWscStoreWrite = false
|
||||||
|
|
||||||
|
useThingMap = true
|
||||||
|
|
||||||
[beta]
|
[beta]
|
||||||
enableStoreWrite = false
|
enableStoreWrite = false
|
||||||
enableJdStoreWrite = false
|
enableJdStoreWrite = false
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ var (
|
|||||||
WxpayNotifyURL string
|
WxpayNotifyURL string
|
||||||
|
|
||||||
JdOrgCode string
|
JdOrgCode string
|
||||||
|
|
||||||
|
IsUseThingMap bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -99,6 +101,8 @@ func Init() {
|
|||||||
|
|
||||||
WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "")
|
WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "")
|
||||||
JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "")
|
JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "")
|
||||||
|
|
||||||
|
IsUseThingMap = beego.AppConfig.DefaultBool("useThingMap", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsCallbackAlwaysReturnSuccess() bool {
|
func IsCallbackAlwaysReturnSuccess() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user