- up
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StoreManager struct {
|
type StoreManager struct {
|
||||||
@@ -20,6 +21,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int, storeStatus int) (err error) {
|
func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int, storeStatus int) (err error) {
|
||||||
|
globals.SugarLogger.Debugf("OnStoreStatusChanged venvendorStoreID:%s, storeStatus:%d", vendorStoreID, storeStatus)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, vendorStoreID, vendorID)
|
storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, vendorStoreID, vendorID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -36,11 +38,11 @@ func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if storeDetail.Status == model.StoreStatusOpened && storeDetail.VendorStatus == model.StoreStatusOpened {
|
if storeDetail.Status == model.StoreStatusOpened {
|
||||||
storeMapKV = map[string]interface{}{
|
storeMapKV = map[string]interface{}{
|
||||||
"Status": storeStatus,
|
"Status": storeStatus,
|
||||||
}
|
}
|
||||||
} else if storeDetail.Status == model.StoreStatusClosed && storeStatus == model.StoreStatusClosed {
|
} else if storeDetail.Status <= storeStatus {
|
||||||
storeMapKV = map[string]interface{}{
|
storeMapKV = map[string]interface{}{
|
||||||
"Status": model.StoreStatusOpened,
|
"Status": model.StoreStatusOpened,
|
||||||
}
|
}
|
||||||
@@ -57,24 +59,34 @@ func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int,
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if storeKV != nil {
|
if storeKV != nil {
|
||||||
|
globals.SugarLogger.Debugf("OnStoreStatusChanged venvendorStoreID:%s, storeKV:%d", vendorStoreID, utils.Format4Output(storeKV, true))
|
||||||
store := &model.Store{}
|
store := &model.Store{}
|
||||||
store.ID = storeDetail.Store.ID
|
store.ID = storeDetail.Store.ID
|
||||||
if _, err = dao.UpdateEntityLogically(db, store, storeKV, model.AdminName, nil); err != nil {
|
if err = utils.CallFuncLogError(func() error {
|
||||||
|
_, err = dao.UpdateEntityLogically(db, store, storeKV, model.AdminName, nil)
|
||||||
|
return err
|
||||||
|
}, "OnStoreStatusChanged Update Store venvendorStoreID:%s", vendorStoreID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if storeMapKV != nil {
|
if storeMapKV != nil {
|
||||||
if _, err = dao.UpdateEntityLogically(db, &model.StoreMap{}, storeMapKV, model.AdminName, map[string]interface{}{
|
globals.SugarLogger.Debugf("OnStoreStatusChanged venvendorStoreID:%s, storeMapKV:%d", vendorStoreID, utils.Format4Output(storeMapKV, true))
|
||||||
model.FieldStoreID: storeDetail.Store.ID,
|
if err = utils.CallFuncLogError(func() error {
|
||||||
model.FieldVendorID: vendorID,
|
_, err = dao.UpdateEntityLogically(db, &model.StoreMap{}, storeMapKV, model.AdminName, map[string]interface{}{
|
||||||
model.FieldDeletedAt: utils.DefaultTimeValue,
|
model.FieldStoreID: storeDetail.Store.ID,
|
||||||
}); err != nil {
|
model.FieldVendorID: vendorID,
|
||||||
|
model.FieldDeletedAt: utils.DefaultTimeValue,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}, "OnStoreStatusChanged Update StoreMap venvendorStoreID:%s", vendorStoreID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if storeStatus != model.StoreStatusOpened {
|
if storeStatus != model.StoreStatusOpened {
|
||||||
// 因为storeStatus != model.StoreStatusOpened不会修改京西门店的状态,所以直接用storeDetail.Status是合适的
|
// 因为storeStatus != model.StoreStatusOpened不会修改京西门店的状态,所以直接用storeDetail.Status是合适的
|
||||||
if err = dao.FormalizeStoreStatus(db, storeDetail.Store.ID, storeDetail.Status); err != nil {
|
if err = utils.CallFuncLogError(func() error {
|
||||||
|
return dao.FormalizeStoreStatus(db, storeDetail.Store.ID, storeDetail.Status)
|
||||||
|
}, "OnStoreStatusChanged FormalizeStoreStatus venvendorStoreID:%s", vendorStoreID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user