- sync.
This commit is contained in:
@@ -25,8 +25,8 @@ type StoresInfo struct {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrMissingInput = errors.New("没有有效的输入参数")
|
||||
ErrCanNotVendor = errors.New("vendorID参数不合法")
|
||||
ErrMissingInput = errors.New("没有有效的输入参数")
|
||||
ErrCanNotFindVendor = errors.New("vendorID参数不合法")
|
||||
)
|
||||
|
||||
func GetPlaces(parentCode int, vendorID int, includeDisabled bool) ([]*model.Place, error) {
|
||||
@@ -97,7 +97,7 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
|
||||
|
||||
if params["storeID"] != nil {
|
||||
sqlWhere += " AND t1.id = ?"
|
||||
sqlParams = append(sqlParams, params["id"].(int))
|
||||
sqlParams = append(sqlParams, params["storeID"].(int))
|
||||
}
|
||||
if params["name"] != nil {
|
||||
sqlWhere += " AND t1.name LIKE ?"
|
||||
@@ -195,8 +195,7 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
|
||||
}
|
||||
|
||||
func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
||||
handler := GetPurchaseHandler(vendorID)
|
||||
if handler != nil {
|
||||
if handler := GetPurchaseHandler(vendorID); handler != nil {
|
||||
result, err2 := handler.ReadStore(vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
retVal = &StoreExt{
|
||||
@@ -213,7 +212,7 @@ func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err e
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return nil, ErrCanNotVendor
|
||||
return nil, ErrCanNotFindVendor
|
||||
}
|
||||
|
||||
func UpdateStore(storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
@@ -254,18 +253,22 @@ func GetStoreVendorMaps(db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*
|
||||
}
|
||||
|
||||
func AddStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, storeMap *model.StoreMap, userName string) (outStoreMap *model.StoreMap, err error) {
|
||||
store, err := GetPurchaseHandler(storeMap.VendorID).ReadStore(storeMap.VendorStoreID)
|
||||
if err == nil {
|
||||
dao.WrapAddIDCULEntity(storeMap, userName)
|
||||
storeMap.StoreID = storeID
|
||||
storeMap.VendorID = vendorID
|
||||
storeMap.DeliveryType = store.DeliveryType
|
||||
storeMap.Status = store.Status
|
||||
storeMap.SyncStatus = model.SyncFlagModifiedMask // 新增绑定门店是修改的概念
|
||||
if err = dao.CreateEntity(db, storeMap); err == nil {
|
||||
outStoreMap = storeMap
|
||||
err = CurVendorSync.SyncStore(db, storeMap.VendorID, store, true, userName)
|
||||
if handler := GetPurchaseHandler(storeMap.VendorID); handler != nil {
|
||||
store, err := handler.ReadStore(storeMap.VendorStoreID)
|
||||
if err == nil {
|
||||
dao.WrapAddIDCULEntity(storeMap, userName)
|
||||
storeMap.StoreID = storeID
|
||||
storeMap.VendorID = vendorID
|
||||
storeMap.DeliveryType = store.DeliveryType
|
||||
storeMap.Status = store.Status
|
||||
storeMap.SyncStatus = model.SyncFlagModifiedMask // 新增绑定门店是修改的概念
|
||||
if err = dao.CreateEntity(db, storeMap); err == nil {
|
||||
outStoreMap = storeMap
|
||||
err = CurVendorSync.SyncStore(db, storeMap.VendorID, store, true, userName)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = ErrCanNotFindVendor
|
||||
}
|
||||
return outStoreMap, err
|
||||
}
|
||||
@@ -283,9 +286,13 @@ func UpdateStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, payload map[stri
|
||||
db = dao.GetDB()
|
||||
}
|
||||
if vendorStoreID := utils.Interface2String(payload["vendorStoreID"]); vendorStoreID != "" {
|
||||
jdStore, err2 := GetPurchaseHandler(vendorID).ReadStore(vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
payload["deliveryType"] = jdStore.DeliveryType
|
||||
if handler := GetPurchaseHandler(vendorID); handler != nil {
|
||||
jdStore, err2 := handler.ReadStore(vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
payload["deliveryType"] = jdStore.DeliveryType
|
||||
}
|
||||
} else {
|
||||
err = ErrCanNotFindVendor
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user