Merge remote-tracking branch 'origin/jdshop' into qidongsheng
This commit is contained in:
@@ -3,11 +3,12 @@ package cms
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
@@ -714,18 +715,19 @@ func buildSetFinishHook(task tasksch.ITask, ctx *jxcontext.Context) {
|
|||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("同步错误发送钉钉消息失败, authinfo [%v] , [%v]", *authInfo, err)
|
globals.SugarLogger.Debugf("同步错误发送钉钉消息失败, authinfo [%v] , [%v]", *authInfo, err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(task.GetFailedList()) > 1 {
|
|
||||||
if time.Now().Hour() >= 20 || time.Now().Hour() < 7 {
|
|
||||||
downloadURL, _, _ := WirteToExcelBySyncFailed(task)
|
|
||||||
user, err := dao.GetUserByID(dao.GetDB(), "mobile", "18160030913")
|
|
||||||
noticeMsg += fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL)
|
|
||||||
if user != nil && err == nil {
|
|
||||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "同步错误返回", noticeMsg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// if len(task.GetFailedList()) > 1 {
|
||||||
|
// if time.Now().Hour() >= 20 || time.Now().Hour() < 7 {
|
||||||
|
// downloadURL, _, _ := WirteToExcelBySyncFailed(task)
|
||||||
|
// user, err := dao.GetUserByID(dao.GetDB(), "mobile", "18160030913")
|
||||||
|
// noticeMsg += fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL)
|
||||||
|
// if user != nil && err == nil {
|
||||||
|
// ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "同步错误返回", noticeMsg)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1102,9 +1104,9 @@ func (v *VendorSync) SyncJdsStoresSkus(ctx *jxcontext.Context, storeIDs []int, i
|
|||||||
if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||||
for _, storeMap := range loopMapInfo.StoreMapList {
|
for _, storeMap := range loopMapInfo.StoreMapList {
|
||||||
if storeMap.Status > model.StoreStatusDisabled && storeMap.StoreID != model.JdShopMainStoreID && storeMap.SyncRule != 0 {
|
if storeMap.Status > model.StoreStatusDisabled && storeMap.StoreID != model.JdShopMainStoreID && storeMap.SyncRule != 0 {
|
||||||
err = syncJdsStoresSkus(ctx, db, nil, storeMap, isAsync, isContinueWhenError)
|
err = syncJdsStoresSkus(ctx, db, t, storeMap, isAsync, isContinueWhenError)
|
||||||
}
|
}
|
||||||
err = syncJdsStoreStock(ctx, db, storeSkus, storeMap)
|
err = syncJdsStoreStock(ctx, db, t, storeSkus, storeMap, isAsync, isContinueWhenError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||||
@@ -1112,31 +1114,46 @@ func (v *VendorSync) SyncJdsStoresSkus(ctx *jxcontext.Context, storeIDs []int, i
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, storeSkus []*model.StoreSkuBind, storeMap *model.StoreMap) (err error) {
|
func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.ITask, storeSkus []*model.StoreSkuBind, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (err error) {
|
||||||
for _, storeSku := range storeSkus {
|
// for _, storeSku := range storeSkus {
|
||||||
stock := 0
|
// stock := 0
|
||||||
if storeSku.Status == model.StoreSkuBindStatusNormal {
|
// if storeSku.Status == model.StoreSkuBindStatusNormal {
|
||||||
stock = 9999
|
// stock = 9999
|
||||||
}
|
// }
|
||||||
storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
// storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
||||||
if storeSku.JdsID != 0 {
|
// if storeSku.JdsID != 0 {
|
||||||
if len(storeSku2) > 0 {
|
// if len(storeSku2) > 0 {
|
||||||
if storeSku.Status != storeSku2[0].Status && storeMap.VendorStoreID != "" {
|
// if storeSku.Status != storeSku2[0].Status && storeMap.VendorStoreID != "" {
|
||||||
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID))
|
// err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
// err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
storeSku := batchItemList[0].(*model.StoreSkuBind)
|
||||||
|
stock := 0
|
||||||
|
if storeSku.Status == model.StoreSkuBindStatusNormal {
|
||||||
|
stock = 9999
|
||||||
}
|
}
|
||||||
}
|
storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID})
|
||||||
|
if storeSku.JdsID != 0 {
|
||||||
|
if len(storeSku2) > 0 {
|
||||||
|
if storeSku.Status != storeSku2[0].Status && storeMap.VendorStoreID != "" {
|
||||||
|
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeSkus)
|
||||||
|
tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
|
if !isAsync {
|
||||||
|
_, err = task.GetResult(0)
|
||||||
}
|
}
|
||||||
// task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
|
||||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
||||||
// storeSku := batchItemList[0].(*model.StoreSkuBind)
|
|
||||||
|
|
||||||
// return retVal, err
|
|
||||||
// }, storeSkus)
|
|
||||||
// tasksch.HandleTask(task, nil, true).Run()
|
|
||||||
// _, err = task.GetResult(0)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ func NotifyOrderChanged(order *model.GoodsOrder) (err error) {
|
|||||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
},
|
},
|
||||||
"keyword3": map[string]interface{}{
|
"keyword3": map[string]interface{}{
|
||||||
"value": order.ConsigneeAddress + "," + order.ConsigneeName + "," + order.ConsigneeMobile,
|
"value": order.ConsigneeAddress + "," + order.ConsigneeName + "," + order.ConsigneeMobile + "," + order.BuyerComment,
|
||||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
},
|
},
|
||||||
"keyword4": map[string]interface{}{
|
"keyword4": map[string]interface{}{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
|||||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
||||||
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
||||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||||
batchSize = 1
|
batchSize = 2
|
||||||
case partner.FuncGetStoreSkusFullInfo:
|
case partner.FuncGetStoreSkusFullInfo:
|
||||||
batchSize = 1
|
batchSize = 1
|
||||||
case partner.FuncCreateActs, partner.FuncCancelActs:
|
case partner.FuncCreateActs, partner.FuncCancelActs:
|
||||||
|
|||||||
Reference in New Issue
Block a user