解决冲突
This commit is contained in:
@@ -13,6 +13,8 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
@@ -843,8 +845,7 @@ func UpdateStoreSkus(ctx *jxcontext.Context, causeFlag, storeID int, skuBindInfo
|
||||
|
||||
func UpdateStoresSkus(ctx *jxcontext.Context, causeFlag int, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isScale, isRefreshHigh, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("UpdateStoresSkus:%s, storeIDs:%v, skuBindInfos:%s", ctx.GetTrackInfo(), storeIDs, utils.Format4Output(skuBindInfos, true))
|
||||
flag, err := doStoreSkuAudit(ctx, storeIDs, skuBindInfos)
|
||||
if !flag {
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
skuIDs, err := updateStoresSkusWithoutSync(ctx, db, storeIDs, skuBindInfos, isScale, isRefreshHigh)
|
||||
@@ -859,6 +860,24 @@ func UpdateStoresSkus(ctx *jxcontext.Context, causeFlag int, storeIDs []int, sku
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
}
|
||||
} else {
|
||||
flag, _ := doStoreSkuAudit(ctx, storeIDs, skuBindInfos)
|
||||
if !flag {
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
skuIDs, err := updateStoresSkusWithoutSync(ctx, db, storeIDs, skuBindInfos, isScale, isRefreshHigh)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, causeFlag, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
}
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
@@ -1107,7 +1126,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
skuBind.Status = tmpStatus
|
||||
}
|
||||
if globals.IsAddEvent {
|
||||
err = AddEventDetail(db, ctx, model.OperateAdd, v.RealSkuID, model.ThingTypeSku, storeID, "", "")
|
||||
err = AddEventDetail(db, ctx, model.OperateAdd, v.RealSkuID, model.ThingTypeSku, storeID, "", utils.Int2Str(skuBind.UnitPrice))
|
||||
}
|
||||
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
||||
dao.WrapAddIDCULDEntity(skuBind, userName)
|
||||
@@ -2351,7 +2370,7 @@ func ReCalculateJxPrice(db *dao.DaoDB, ctx *jxcontext.Context, storeIDs []int) (
|
||||
if storeSkuList, err := dao.GetStoresSkusInfo(db, []int{storeID}, nil); err == nil {
|
||||
for _, skuBind := range storeSkuList {
|
||||
skuBind.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), skuBind.Price)
|
||||
dao.UpdateEntity(db, skuBind)
|
||||
dao.UpdateEntity(db, skuBind, "JxPrice")
|
||||
}
|
||||
} else {
|
||||
return nil, err
|
||||
@@ -4504,6 +4523,14 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
time.Sleep(time.Second / 5)
|
||||
db := dao.GetDB()
|
||||
for _, storeID := range storeIDs {
|
||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
||||
//扣点的门店改价不进审核
|
||||
if len(stores) > 0 {
|
||||
if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return0 storeID : %v", storeID)
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
for _, skuBindInfo := range skuBindInfos {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit storeID: %v , nameID: %v", storeID, skuBindInfo.NameID)
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{skuBindInfo.NameID}, model.StoreAuditStatusOnline)
|
||||
@@ -4584,7 +4611,7 @@ func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSku
|
||||
if status == model.StoreAuditStatusOnline {
|
||||
return "", fmt.Errorf("审核标志不正确!")
|
||||
}
|
||||
task := tasksch.NewParallelTask("StoreSkuPriceAudit", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
task := tasksch.NewParallelTask("StoreSkuPriceAudit", tasksch.NewParallelConfig().SetParallelCount(5).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeAudit := batchItemList[0].(*model.StoreSkuAudit)
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeAudit.StoreID}, []int{storeAudit.NameID}, model.StoreAuditStatusOnline)
|
||||
@@ -4594,10 +4621,10 @@ func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSku
|
||||
if len(storeAudits) > 1 {
|
||||
return retVal, fmt.Errorf("查询到该门店该商品的待审核信息大于1条!storeID: %v, nameID: %v", storeAudit.StoreID, storeAudit.NameID)
|
||||
}
|
||||
flag := false
|
||||
// flag := false
|
||||
//审核通过
|
||||
if status == model.StoreAuditStatusCreated {
|
||||
flag = true
|
||||
// flag = true
|
||||
storeAudits[0].UserID = ctx.GetUserID()
|
||||
storeAudits[0].Status = model.StoreAuditStatusCreated
|
||||
storeAudits[0].Remark = storeAudit.Remark
|
||||
@@ -4640,19 +4667,20 @@ func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSku
|
||||
} else {
|
||||
return retVal, fmt.Errorf("审核标志不正确!")
|
||||
}
|
||||
//TODO 暂时先不推消息了
|
||||
if err == nil {
|
||||
if globals.IsProductEnv() {
|
||||
skuAndNames, err := dao.GetSkus(db, nil, []int{storeAudit.NameID}, nil, nil, nil)
|
||||
if len(skuAndNames) > 0 && err == nil {
|
||||
price := 0
|
||||
if storeAudit.AuditPrice != 0 {
|
||||
price = storeAudit.AuditPrice
|
||||
} else {
|
||||
price = storeAudits[0].UnitPrice
|
||||
}
|
||||
weixinmsg.NotifyStoreOpRequestStatus(flag, storeAudit.StoreID, storeAudit.NameID, jxutils.ComposeSpuName(skuAndNames[0].Prefix, skuAndNames[0].Name, 0), storeAudits[0].OriginUnitPrice, price, storeAudit.Remark)
|
||||
}
|
||||
}
|
||||
// if globals.IsProductEnv() {
|
||||
// skuAndNames, err := dao.GetSkus(db, nil, []int{storeAudit.NameID}, nil, nil, nil)
|
||||
// if len(skuAndNames) > 0 && err == nil {
|
||||
// price := 0
|
||||
// if storeAudit.AuditPrice != 0 {
|
||||
// price = storeAudit.AuditPrice
|
||||
// } else {
|
||||
// price = storeAudits[0].UnitPrice
|
||||
// }
|
||||
// weixinmsg.NotifyStoreOpRequestStatus(flag, storeAudit.StoreID, storeAudit.NameID, jxutils.ComposeSpuName(skuAndNames[0].Prefix, skuAndNames[0].Name, 0), storeAudits[0].OriginUnitPrice, price, storeAudit.Remark)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return retVal, err
|
||||
}, storeSkuAudits)
|
||||
|
||||
Reference in New Issue
Block a user