- create dada store when after jx store created.

This commit is contained in:
gazebo
2019-03-18 16:26:11 +08:00
parent cf2dc1be14
commit 6266315684
2 changed files with 9 additions and 8 deletions

View File

@@ -419,6 +419,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
dao.WrapAddIDCULDEntity(store, userName)
store.ID = existingID
if err = dao.CreateEntity(nil, store); err == nil {
_, err = RefreshMissingDadaStores(ctx, store.ID, false, false)
return store.ID, err
}
return 0, err
@@ -475,9 +476,6 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
} else {
err = ErrCanNotFindVendor
}
if err == nil && vendorID == model.VendorIDJD {
_, err = RefreshMissingDadaStores(ctx, storeID, false, false)
}
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) {
db := dao.GetDB()
storeList, err := dao.GetMissingDadaStores(db, storeID)
storeList, err := dao.GetMissingDadaStores(db, storeID, false)
if err != nil {
return "", err
}

View File

@@ -24,7 +24,7 @@ type StoreDetail struct {
type StoreDetail2 struct {
model.Store
VendorStoreID string `orm:"column(vendor_store_id)`
VendorStoreID string `orm:"column(vendor_store_id)` // 这个在GetMissingDadaStores返回中指的是到家的vendorStoreID
DistrictName 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 := `
SELECT t1.*,
t2.vendor_store_id,
t2.vendor_store_id vendor_store_id,
city.name city_name, district.name district_name
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 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 = ?
@@ -125,6 +125,9 @@ func GetMissingDadaStores(db *DaoDB, storeID int) (storeList []*StoreDetail2, er
utils.DefaultTimeValue,
utils.DefaultTimeValue,
}
if isMustHaveJdStore {
sql += " AND t2.id IS NOT NULL"
}
if storeID != 0 {
sql += " AND t1.id = ?"
sqlParams = append(sqlParams, storeID)