- RefreshMissingDadaStores
- auto acreate dada store when link jd store
This commit is contained in:
@@ -22,12 +22,19 @@ type StoreDetail struct {
|
||||
model.Place // district info
|
||||
}
|
||||
|
||||
type StoreDetail2 struct {
|
||||
model.Store
|
||||
VendorStoreID string `orm:"column(vendor_store_id)`
|
||||
DistrictName string
|
||||
CityName string
|
||||
}
|
||||
|
||||
func GetStoreDetail(db *DaoDB, storeID, vendorID int) (storeDetail *StoreDetail, err error) {
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||
district.*
|
||||
district.code, district.name, district.parent_code, district.level, district.tel_code, district.jd_code, district.ebai_code, district.enabled, district.mtps_price
|
||||
FROM store t1
|
||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||
LEFT JOIN place district ON t1.district_code = district.code
|
||||
@@ -40,7 +47,7 @@ func GetStoreDetail(db *DaoDB, storeID, vendorID int) (storeDetail *StoreDetail,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (storeList []*StoreDetail, err error) {
|
||||
func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (storeList []*StoreDetail2, err error) {
|
||||
sqlList := []string{
|
||||
`
|
||||
SELECT t1.*, t5.vendor_store_id
|
||||
@@ -50,8 +57,8 @@ func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (sto
|
||||
WHERE t1.status = ?
|
||||
`,
|
||||
`
|
||||
SELECT t1.*
|
||||
FROM store t1, t5.vendor_store_id
|
||||
SELECT t1.*, t5.vendor_store_id
|
||||
FROM store t1
|
||||
JOIN place t2 ON t2.code = t1.city_code
|
||||
JOIN place t3 ON t3.code = t2.parent_code AND t3.name = ?
|
||||
LEFT JOIN store_map t5 ON t1.id = t5.store_id AND t5.vendor_id = ? AND t5.deleted_at = ?
|
||||
@@ -94,3 +101,34 @@ func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (sto
|
||||
// 正常是不应该达到这里的
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
// 这个返回的地点信息是城市
|
||||
func GetMissingDadaStores(db *DaoDB, storeID int) (storeList []*StoreDetail2, err error) {
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.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 = ?
|
||||
JOIN place city ON city.code = t1.city_code
|
||||
JOIN place district ON district.code = t1.district_code
|
||||
LEFT JOIN store_map t3 ON t3.store_id = t1.id AND t3.vendor_id = ? AND t3.deleted_at = ?
|
||||
WHERE t1.deleted_at = ? AND t1.status <> ? AND t3.id IS NULL
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.VendorIDJD,
|
||||
utils.DefaultTimeValue,
|
||||
model.VendorIDDada,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
model.StoreStatusDisabled,
|
||||
}
|
||||
if storeID != 0 {
|
||||
sql += " AND t1.id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
}
|
||||
if err = GetRows(db, &storeList, sql, sqlParams...); err == nil {
|
||||
return storeList, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user