Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -239,8 +239,9 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
||||
}
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sqlWhere += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.last_operator LIKE ? OR city.name LIKE ? OR t1.address LIKE ? OR t1.printer_sn LIKE ?"
|
||||
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||
sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.market_man_phone LIKE ?
|
||||
OR t1.last_operator LIKE ? OR city.name LIKE ? OR t1.address LIKE ? OR t1.printer_sn LIKE ?`
|
||||
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||
|
||||
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
|
||||
if jxutils.IsLegalMobileNumber(keywordInt64) {
|
||||
@@ -1391,10 +1392,12 @@ func updateVendorStoreStatusBySnapshot(db *dao.DaoDB, curSnapshotList []*model.V
|
||||
}
|
||||
}()
|
||||
for _, v := range storeMapList {
|
||||
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil && v.Status != snapshot.Status {
|
||||
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil &&
|
||||
(v.Status != snapshot.Status || v.DeliveryType != snapshot.DeliveryType) {
|
||||
v.Status = snapshot.Status
|
||||
v.DeliveryType = snapshot.DeliveryType
|
||||
if _, err = dao.UpdateEntity(db, v, model.FieldStatus, "DeliveryType"); err != nil {
|
||||
v.LastOperator = model.AdminName
|
||||
if _, err = dao.UpdateEntity(db, v, model.FieldLastOperator, model.FieldUpdatedAt, model.FieldStatus, "DeliveryType"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1649,6 +1652,7 @@ func sendStoreStatusInfo2Mobile(mobile, title, txtAlarm string) {
|
||||
|
||||
func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync bool) (err error) {
|
||||
curSnapshotAt := getCurrentSnapshotAt(time.Now())
|
||||
prevSnapshotAt := getCurrentSnapshotAt(curSnapshotAt.Add(-1 * time.Second))
|
||||
db := dao.GetDB()
|
||||
var curSnapshotList, prevSnapshotList []*model.VendorStoreSnapshot
|
||||
task := tasksch.NewSeqTask("SaveAndSendAlarmVendorSnapshot", ctx,
|
||||
@@ -1664,7 +1668,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
||||
case 1:
|
||||
err = SaveStoresVendorSnapshot(db, curSnapshotAt, curSnapshotList)
|
||||
case 2:
|
||||
prevSnapshotList, err = dao.GetVendorStoreSnapshot(db, curSnapshotAt)
|
||||
prevSnapshotList, err = dao.GetVendorStoreSnapshot(db, prevSnapshotAt)
|
||||
case 3:
|
||||
err = SendAlarmVendorSnapshot(ctx, task, prevSnapshotList, curSnapshotList)
|
||||
}
|
||||
|
||||
@@ -1280,7 +1280,7 @@ func getSkuSaleStatus(inSkuBind *StoreSkuBindSkuInfo, skuBindInfo *StoreSkuBindI
|
||||
}
|
||||
|
||||
// todo 应该用updateStoresSkusWithoutSync实现
|
||||
func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string) (needSyncSkus []int, err error) {
|
||||
func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, userName string) (needSyncSkus []int, err error) {
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
needSyncIDMap := make(map[int]int)
|
||||
@@ -1310,14 +1310,19 @@ func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBind
|
||||
} else {
|
||||
skuBind.Status = model.StoreSkuBindStatusDontSale
|
||||
}
|
||||
if num, err = dao.UpdateEntityLogically(db, skuBind, map[string]interface{}{
|
||||
kvs := map[string]interface{}{
|
||||
model.FieldStatus: skuBind.Status,
|
||||
model.FieldJdSyncStatus: skuBind.JdSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldEbaiSyncStatus: skuBind.EbaiSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldMtwmSyncStatus: skuBind.MtwmSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldElmSyncStatus: skuBind.ElmSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldWscSyncStatus: skuBind.WscSyncStatus | model.SyncFlagSaleMask,
|
||||
}, userName, nil); err != nil {
|
||||
}
|
||||
// if utils.IsTimeZero(autoSaleTime) || skuBind.Status == model.SkuStatusNormal {
|
||||
// autoSaleTime = utils.DefaultTimeValue
|
||||
// }
|
||||
// kvs["AutoSaleAt"] = autoSaleTime
|
||||
if num, err = dao.UpdateEntityLogically(db, skuBind, kvs, userName, nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return nil, err
|
||||
}
|
||||
@@ -1342,13 +1347,13 @@ func uniqueStoreSkuBind(skuBindSkuInfos []*StoreSkuBindSkuInfo) (outSkuBindSkuIn
|
||||
return outSkuBindSkuInfos
|
||||
}
|
||||
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
storeIDs = uniqueStoreIDs(storeIDs)
|
||||
skuBindSkuInfos = uniqueStoreSkuBind(skuBindSkuInfos)
|
||||
|
||||
var num int64
|
||||
for _, storeID := range storeIDs {
|
||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, userName)
|
||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, autoSaleTime, userName)
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -2171,3 +2176,37 @@ func GetMissingStoreSkuFromOrder(ctx *jxcontext.Context, fromTime time.Time) (mi
|
||||
}
|
||||
return missingList, err
|
||||
}
|
||||
|
||||
func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||
// db := dao.GetDB()
|
||||
// storeSkuList, err := dao.GetAutoSaleStoreSku(db, storeIDs)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// storeSkuMap := make(map[int][]*model.StoreSkuBind)
|
||||
// for _, v := range storeSkuList {
|
||||
// storeSkuMap[v.StoreID] = append(storeSkuMap[v.StoreID], v)
|
||||
// }
|
||||
// now := time.Now()
|
||||
// for storeID, storeSkuList := range storeSkuMap {
|
||||
// var skuIDs []int
|
||||
// for _, storeSku := range storeSkuList {
|
||||
// if now.Sub(storeSku.AutoSaleAt) > 0 {
|
||||
// storeSku.AutoSaleAt = utils.DefaultTimeValue
|
||||
// if storeSku.Status != model.SkuStatusNormal {
|
||||
// storeSku.Status = model.SkuStatusNormal
|
||||
// skuIDs = append(skuIDs, storeSku.SkuID)
|
||||
// }
|
||||
// if _, err = dao.UpdateEntity(db, storeSku, "AutoSaleAt", model.FieldStatus); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if len(skuIDs) > 0 {
|
||||
// if _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -27,3 +27,9 @@ func TestSendAlarmVendorSnapshot(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateVendorStoreStatusBySnapshot(t *testing.T) {
|
||||
db := dao.GetDB()
|
||||
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-30 08:00:00"))
|
||||
updateVendorStoreStatusBySnapshot(db, curSnapshotList)
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ var (
|
||||
updateActStatusTimeList = []string{
|
||||
"00:01:00",
|
||||
}
|
||||
|
||||
autoEnableStoreSkuTimeList = []string{
|
||||
"7:00:00",
|
||||
"14:00:00",
|
||||
"22:00:00",
|
||||
}
|
||||
)
|
||||
|
||||
func Init() {
|
||||
@@ -70,6 +76,10 @@ func Init() {
|
||||
ScheduleTimerFunc(func() {
|
||||
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
||||
}, updateActStatusTimeList)
|
||||
|
||||
// ScheduleTimerFunc(func() {
|
||||
// cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil)
|
||||
// }, autoEnableStoreSkuTimeList)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user