This commit is contained in:
suyl
2021-10-13 13:48:02 +08:00
parent ae1f5c7b0a
commit 0327702065
2 changed files with 22 additions and 5 deletions

View File

@@ -1983,6 +1983,25 @@ func GetNewVendorPopActs(ctx *jxcontext.Context) (err error) {
return err
}
func checkActStoreSkuExist(db *dao.DaoDB, storeID, skuID, vendorID int, beginAt, endAt time.Time) bool {
var (
act = &model.Act{}
)
//如果开始时间和结束时间重合,就默认是从京西上建的活动,需要过滤掉
sql := `
SELECT b.*
FROM act_store_sku a
JOIN act b ON a.act_id = b.id
JOIN act_map c ON c.act_id = b.id
WHERE a.store_id = ? AND a.sku_id = ? AND b.begin_at = ? AND b.end_at = ? AND c.vendor_id = ?
`
sqlParams := []interface{}{storeID, skuID, vendorID, beginAt, endAt}
if err := dao.GetRow(db, &act, sql, sqlParams); err == nil && act != nil {
return true
}
return false
}
func RrefreshMtwmVendorAct(ctx *jxcontext.Context) (err error) {
var (
db = dao.GetDB()
@@ -2003,8 +2022,7 @@ func RrefreshMtwmVendorAct(ctx *jxcontext.Context) (err error) {
if actList, _ := mtapi.RetailDiscountList(storeMap.VendorStoreID, k); len(actList) > 0 {
for _, act := range actList {
if act.Status > 0 {
if actSkus, _ := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{model.VendorIDMTWM}, model.ActTypeAll, []int{storeMap.StoreID},
[]int{utils.Str2Int(act.AppFoodCode)}, utils.Timestamp2Time(act.StartTime), utils.Timestamp2Time(act.EndTime)); len(actSkus) == 0 {
if checkActStoreSkuExist(db, storeMap.StoreID, utils.Str2Int(act.AppFoodCode), model.VendorIDMTWM, utils.Timestamp2Time(act.StartTime), utils.Timestamp2Time(act.EndTime)) {
actVendor := &model.ActMtwmVendor{
StoreID: storeMap.StoreID,
SkuID: utils.Str2Int(act.AppFoodCode),
@@ -2090,8 +2108,7 @@ func RrefreshEbaiVendorAct(ctx *jxcontext.Context) (err error) {
`
sqlParams := []interface{}{storeMap.StoreID, sku.Skuid}
if err = dao.GetRow(db, &storeSkuBind, sql, sqlParams); err == nil && storeSkuBind != nil {
if actSkus, _ := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{model.VendorIDMTWM}, model.ActTypeAll, []int{storeMap.StoreID},
[]int{storeSkuBind.SkuID}, utils.Timestamp2Time(result.Starttime), utils.Timestamp2Time(result.Endtime)); len(actSkus) == 0 {
if checkActStoreSkuExist(db, storeMap.StoreID, storeSkuBind.SkuID, model.VendorIDEBAI, utils.Timestamp2Time(result.Starttime), utils.Timestamp2Time(result.Endtime)) {
actVendorSku.SkuID = storeSkuBind.SkuID
actVendorSku.OriginPrice = jxutils.IntPrice2Standard(int64(storeSkuBind.Price))
}

View File

@@ -1973,7 +1973,7 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
// }
// }
//}
//act.RrefreshMtwmVendorAct(jxcontext.AdminCtx)
act.RrefreshMtwmVendorAct(jxcontext.AdminCtx)
act.RrefreshEbaiVendorAct(jxcontext.AdminCtx)
//var (
// db = dao.GetDB()