- create dada store when after jx store created.
This commit is contained in:
@@ -419,6 +419,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
|||||||
dao.WrapAddIDCULDEntity(store, userName)
|
dao.WrapAddIDCULDEntity(store, userName)
|
||||||
store.ID = existingID
|
store.ID = existingID
|
||||||
if err = dao.CreateEntity(nil, store); err == nil {
|
if err = dao.CreateEntity(nil, store); err == nil {
|
||||||
|
_, err = RefreshMissingDadaStores(ctx, store.ID, false, false)
|
||||||
return store.ID, err
|
return store.ID, err
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -475,9 +476,6 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
|||||||
} else {
|
} else {
|
||||||
err = ErrCanNotFindVendor
|
err = ErrCanNotFindVendor
|
||||||
}
|
}
|
||||||
if err == nil && vendorID == model.VendorIDJD {
|
|
||||||
_, err = RefreshMissingDadaStores(ctx, storeID, false, false)
|
|
||||||
}
|
|
||||||
return outStoreMap, err
|
return outStoreMap, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,7 +746,7 @@ func UpdateStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendo
|
|||||||
|
|
||||||
func RefreshMissingDadaStores(ctx *jxcontext.Context, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshMissingDadaStores(ctx *jxcontext.Context, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeList, err := dao.GetMissingDadaStores(db, storeID)
|
storeList, err := dao.GetMissingDadaStores(db, storeID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type StoreDetail struct {
|
|||||||
|
|
||||||
type StoreDetail2 struct {
|
type StoreDetail2 struct {
|
||||||
model.Store
|
model.Store
|
||||||
VendorStoreID string `orm:"column(vendor_store_id)`
|
VendorStoreID string `orm:"column(vendor_store_id)` // 这个在GetMissingDadaStores返回中指的是到家的vendorStoreID
|
||||||
DistrictName string
|
DistrictName string
|
||||||
CityName string
|
CityName string
|
||||||
}
|
}
|
||||||
@@ -106,13 +106,13 @@ func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (sto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 这个返回的地点信息是城市
|
// 这个返回的地点信息是城市
|
||||||
func GetMissingDadaStores(db *DaoDB, storeID int) (storeList []*StoreDetail2, err error) {
|
func GetMissingDadaStores(db *DaoDB, storeID int, isMustHaveJdStore bool) (storeList []*StoreDetail2, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*,
|
SELECT t1.*,
|
||||||
t2.vendor_store_id,
|
t2.vendor_store_id vendor_store_id,
|
||||||
city.name city_name, district.name district_name
|
city.name city_name, district.name district_name
|
||||||
FROM store t1
|
FROM store t1
|
||||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
LEFT JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||||
JOIN place city ON city.code = t1.city_code
|
JOIN place city ON city.code = t1.city_code
|
||||||
JOIN place district ON district.code = t1.district_code
|
JOIN place district ON district.code = t1.district_code
|
||||||
LEFT JOIN store_courier_map t3 ON t3.store_id = t1.id AND t3.vendor_id = ? AND t3.deleted_at = ?
|
LEFT JOIN store_courier_map t3 ON t3.store_id = t1.id AND t3.vendor_id = ? AND t3.deleted_at = ?
|
||||||
@@ -125,6 +125,9 @@ func GetMissingDadaStores(db *DaoDB, storeID int) (storeList []*StoreDetail2, er
|
|||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
}
|
}
|
||||||
|
if isMustHaveJdStore {
|
||||||
|
sql += " AND t2.id IS NOT NULL"
|
||||||
|
}
|
||||||
if storeID != 0 {
|
if storeID != 0 {
|
||||||
sql += " AND t1.id = ?"
|
sql += " AND t1.id = ?"
|
||||||
sqlParams = append(sqlParams, storeID)
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
|||||||
Reference in New Issue
Block a user