删除日志

This commit is contained in:
邹宗楠
2022-10-24 11:22:38 +08:00
parent 5a47102894
commit 5d6a5a3226
139 changed files with 17 additions and 787 deletions

View File

@@ -1111,12 +1111,10 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
sqlParams2 := append([]interface{}{}, sqlParams...)
sqlParams2 = append(sqlParams2, sqlParamsPage)
var storeNameList []*tStoreNameBind
beginTime := time.Now()
if err = dao.GetRowsTx(txDB, &storeNameList, sql2, sqlParams2...); err != nil {
dao.Rollback(db, txDB)
return nil, err
}
globals.SugarLogger.Debugf("GetStoresSkusNew get result1:%v", time.Now().Sub(beginTime))
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
sql += " AND (1 = 0"
for _, v := range storeNameList {
@@ -1154,7 +1152,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
sql += " , t4.unit_price DESC LIMIT 99"
}
var tmpList []*tGetStoresSkusInfo
beginTime := time.Now()
if err = dao.GetRowsTx(txDB, &tmpList, sql, sqlParams...); err != nil {
dao.Rollback(db, txDB)
return nil, err
@@ -1163,7 +1160,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
}
dao.Commit(db, txDB)
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
storeNameMap := make(map[int64]*dao.StoreSkuNameExt)
for _, v := range tmpList {
var storeName *dao.StoreSkuNameExt
@@ -1207,7 +1203,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
}
}
// globals.SugarLogger.Debug(utils.Format4Output(skuNamesInfo, false))
return skuNamesInfo, err
}
@@ -1284,12 +1279,10 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
sqlParams2 := append([]interface{}{}, sqlParams...)
sqlParams2 = append(sqlParams2, sqlParamsPage)
var storeNameList []*tStoreNameBind
beginTime := time.Now()
if err = dao.GetRowsTx(txDB, &storeNameList, sql2, sqlParams2...); err != nil {
dao.Rollback(db, txDB)
return nil, err
}
globals.SugarLogger.Debugf("GetStoresSkusNew get result1:%v", time.Now().Sub(beginTime))
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
sql += " AND (1 = 0"
for _, v := range storeNameList {
@@ -1327,7 +1320,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
sql += " , t4.unit_price DESC LIMIT 99"
}
var tmpList []*tGetStoresSkusInfo
beginTime := time.Now()
if err = dao.GetRowsTx(txDB, &tmpList, sql, sqlParams...); err != nil {
dao.Rollback(db, txDB)
return nil, err
@@ -1336,7 +1328,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
}
dao.Commit(db, txDB)
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
storeNameMap := make(map[int64]*dao.StoreSkuNameExt)
for _, v := range tmpList {
var storeName *dao.StoreSkuNameExt
@@ -1380,7 +1371,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
}
}
// globals.SugarLogger.Debug(utils.Format4Output(skuNamesInfo, false))
return skuNamesInfo, err
}
@@ -1554,8 +1544,6 @@ func GetStoreAbnormalSkuCount(ctx *jxcontext.Context, storeID, syncStatus int, i
}
func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int, fromTime, toTime time.Time, fromCount, toCount int) (saleInfoList []*SkuSaleInfo, err error) {
globals.SugarLogger.Debugf("GetStoresSkusSaleInfo storeIDs:%v, fromTime:%v, toTime:%v, fromCount:%d, toCount:%d", storeIDs, fromTime, toTime, fromCount, toCount)
db := dao.GetDB()
sql := `
SELECT IF(t2.jx_store_id <> 0, jx_store_id, store_id) store_id, t1.sku_id, COUNT(*) times, SUM(count) count
@@ -1588,7 +1576,6 @@ func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int,
`
sqlParams = append(sqlParams, fromCount, toCount)
if err = dao.GetRows(db, &saleInfoList, sql, sqlParams...); err == nil {
// globals.SugarLogger.Debug(utils.Format4Output(saleInfoList, false))
return saleInfoList, nil
}
return nil, err
@@ -1718,7 +1705,6 @@ 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))
if beego.BConfig.RunMode == "jxgy" {
doStoreSkuAuditForGy(ctx, storeIDs, skuBindInfos)
var num int64
@@ -1891,7 +1877,6 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
skuBindInfos = uniqueStoreNameBind(skuBindInfos)
sort.Ints(storeIDs)
// globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
if db == nil {
db = dao.GetDB()
}
@@ -1989,7 +1974,6 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
// globals.SugarLogger.Debug(sql)
if err = dao.GetRows(db, &allBinds, sql, sqlParams...); err == nil {
if len(allBinds) > 0 {
globals.SugarLogger.Debug(utils.Format4Output(allBinds, true))
inSkuBinsMap := make(map[int]*StoreSkuBindSkuInfo, len(inSkuBinds))
for _, v := range inSkuBinds {
inSkuBinsMap[v.SkuID] = v
@@ -2650,7 +2634,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
}
sqlDelete += sqlCatAndSku
sqlDeleteParams = append(sqlDeleteParams, sqlCatAndSkuParams)
// globals.SugarLogger.Debug(sqlDelete)
num2, err2 := dao.ExecuteSQL(db, sqlDelete, sqlDeleteParams)
if err = err2; err != nil {
errList.AddErr(err)
@@ -2658,7 +2641,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
break
}
num += num2
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num1:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
}
isModifyStatus := 1
syncStatus := model.SyncFlagStoreSkuOnlyMask
@@ -2723,9 +2705,7 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
}
sql += sqlCatAndSku
sqlParams = append(sqlParams, sqlCatAndSkuParams)
// globals.SugarLogger.Debug(sql)
num2, err2 := dao.ExecuteSQL(db, sql, sqlParams)
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num2:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
if err = err2; err != nil {
errList.AddErr(err)
dao.Rollback(db, txDB)
@@ -2805,7 +2785,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
dao.Rollback(db, txDB)
break
}
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
dao.Commit(db, txDB)
//同一商品若源门店的规格少于要复制到的门店则在复制的门店里的其他规格的unitprice不会变
@@ -2872,7 +2851,6 @@ func shouldPendingStorePriceChange(ctx *jxcontext.Context, storeID int, skuBindI
}
func filterStorePriceChange(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (filteredStoreIDs []int, filteredSkuBindInfos []*StoreSkuBindInfo, err error) {
globals.SugarLogger.Debug("filterStorePriceChange")
if globals.EnablePendingChange {
db := dao.GetDB()
txDB, _ := dao.Begin(db)
@@ -3115,8 +3093,6 @@ func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyw
sqlPageSize := pageSize
sqlParams = append(sqlParams, sqlPageSize, sqlOffset)
db := dao.GetDB()
// globals.SugarLogger.Debug(sql)
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
var requestList []*StoreOpRequestInfo
txDB, _ := dao.Begin(db)
defer dao.Commit(db, txDB)
@@ -3169,7 +3145,6 @@ func getStoreOpRequestsInfo(reqIDs []int) (infoMap map[int]*StoreOpRequestInfo,
}
func changeStoreOpStatus(ctx *jxcontext.Context, reqIDs []int, status int8, rejectReason string) (err error) {
globals.SugarLogger.Debugf("changeStoreOpStatus, reqIDs:%v", reqIDs)
if globals.EnablePendingChange {
if len(reqIDs) > 0 {
infoMap, err2 := getStoreOpRequestsInfo(reqIDs)
@@ -3189,7 +3164,6 @@ func changeStoreOpStatus(ctx *jxcontext.Context, reqIDs []int, status int8, reje
dao.WrapUpdateULEntity(op, ctx.GetUserName())
op.DeletedAt = time.Now()
op.ID = reqID
// globals.SugarLogger.Debug(utils.Format4Output(op, false))
if _, err = dao.UpdateEntity(db, op, "IntParam0", "Remark", "Status", "DeletedAt", "LastOperator", "UpdatedAt"); err != nil {
return err
}
@@ -3356,7 +3330,6 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
}
func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuIDs []int, isContinueWhenError bool) (skuVendorMap map[int][]*partner.StoreSkuInfo, err error) {
globals.SugarLogger.Debugf("GetVendorStoreSkusInfo, storeID:%d, vendorIDs:%v, skuID:%v", storeID, vendorIDs, skuIDs)
db := dao.GetDB()
var locker sync.RWMutex
skuVendorMap = make(map[int][]*partner.StoreSkuInfo)
@@ -3447,7 +3420,6 @@ func GetVendorStoreSkusToStruct(ctx *jxcontext.Context, storeID, vendorID int) (
if err != nil {
globals.SugarLogger.Debug(err)
} else {
globals.SugarLogger.Debug(len(tmpList))
if len(tmpList) == 0 { //数据库中无匹配项 直接将第三方数据进行导出
goto creatExec
} else { //进行比较
@@ -3539,7 +3511,6 @@ func ComPareLocalWithVendors(localSku []*tGetStoresSkusInfoContainCategoryName,
}
localStoreSkus = append(localStoreSkus, skus)
}
globals.SugarLogger.Debug(localStoreSkus, vendorSkus)
// 由于go语言中无法子定义struct比较规则 因此需要把数据提取出来进行处理
// 进行比较处理 对两个slice 进行遍历 放到map中 以 skuID slice的形式进行存储 如果不存在则直接进行put操作 如果存在则进行比较类别,价格,以及上下架状态
compareMap := make(map[int]*VendorStoreSkus)
@@ -3584,7 +3555,6 @@ func ComPareLocalWithVendors(localSku []*tGetStoresSkusInfoContainCategoryName,
for _, v := range compareMap {
updateStoreSkus = append(updateStoreSkus, v)
}
globals.SugarLogger.Debug(updateStoreSkus)
return updateStoreSkus
}
@@ -5012,7 +4982,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
if user != nil && err == nil {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!门店爆品数量异常!", v)
}
globals.SugarLogger.Debugf("SendSeckillSkusCountMsg: [%v]", v)
}
for k, v := range marketMap {
if operaterMap[k] != "" {
@@ -5022,7 +4991,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
if user != nil && err == nil {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!门店爆品数量异常!", v)
}
globals.SugarLogger.Debugf("SendSeckillSkusCountMsg: [%v]", v)
}
}
return result, err
@@ -5908,7 +5876,6 @@ func GetStoreSkuAudit(ctx *jxcontext.Context, storeIDs, nameIDs, skuIDs, statuss
}
func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (isAudit bool, err error) {
globals.SugarLogger.Debugf("doStoreSkuAudit storeIDs: %v", storeIDs)
time.Sleep(time.Second / 5)
db := dao.GetDB()
for _, storeID := range storeIDs {
@@ -5916,7 +5883,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
//扣点的门店改价不进审核
if len(stores) > 0 {
if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" || stores[0].StoreLevel == "D" {
globals.SugarLogger.Debugf("doStoreSkuAudit return0 storeID : %v", storeID)
return false, err
}
}
@@ -5925,12 +5891,10 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{skuBindInfo.NameID}, model.StoreAuditStatusOnline)
//取消关注,可售排除
if skuBindInfo.IsFocus == -1 || skuBindInfo.IsSale != 0 || skuBindInfo.UnitPrice == 0 {
globals.SugarLogger.Debugf("doStoreSkuAudit return1 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
return false, err
}
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v loginType: %v", storeID, ctx.GetLoginType())
authInfo, err := ctx.GetV2AuthInfo()
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
if len(storeAudits) > 0 {
@@ -5943,7 +5907,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
// }
// }
}
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
return false, err
}
}
@@ -5976,7 +5939,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
storeAudits[0].DeletedAt = time.Now()
dao.UpdateEntity(db, storeAudits[0], "DeletedAt")
}
globals.SugarLogger.Debugf("doStoreSkuAudit cover storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
}
} else {
return false, fmt.Errorf("未查询到该门店商品价storeID: %v, nameID: %v", storeID, skuBindInfo.NameID)
@@ -5992,7 +5954,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
}
func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (isAudit bool, err error) {
globals.SugarLogger.Debugf("doStoreSkuAuditForGy storeIDs: %v", storeIDs)
time.Sleep(time.Second / 5)
db := dao.GetDB()
for _, storeID := range storeIDs {
@@ -6005,16 +5966,13 @@ func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos [
// }
// }
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)
//取消关注,可售排除
if skuBindInfo.IsFocus == -1 || skuBindInfo.IsSale != 0 || skuBindInfo.UnitPrice == 0 {
globals.SugarLogger.Debugf("doStoreSkuAudit return1 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
return false, err
}
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v loginType: %v", storeID, ctx.GetLoginType())
authInfo, err := ctx.GetV2AuthInfo()
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
if len(storeAudits) > 0 {
@@ -6045,7 +6003,6 @@ func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos [
storeAudits[0].DeletedAt = time.Now()
dao.UpdateEntity(db, storeAudits[0], "DeletedAt")
}
globals.SugarLogger.Debugf("doStoreSkuAudit cover storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
} else {
return false, fmt.Errorf("未查询到该门店商品价storeID: %v, nameID: %v", storeID, skuBindInfo.NameID)
}