31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package dao
|
|
|
|
import (
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
)
|
|
|
|
type StoreDetail struct {
|
|
model.Store
|
|
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
|
VendorStatus int `json:"vendor_status"` // 取值同Store.Status
|
|
DeliveryFee int `json:"deliveryFee"`
|
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
|
model.Place // district info
|
|
}
|
|
|
|
func GetStoreDetail(db *DaoDB, storeID, vendorID int) (storeDetail *StoreDetail, err error) {
|
|
sql := `
|
|
SELECT t2.status vendor_status, t2.vendor_store_id, t2.sync_status, district.*, t1.*
|
|
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
|
|
WHERE t1.id = ? AND t1.deleted_at = ?
|
|
`
|
|
storeDetail = &StoreDetail{}
|
|
if err = GetRow(db, storeDetail, sql, vendorID, utils.DefaultTimeValue, storeID, utils.DefaultTimeValue); err == nil {
|
|
return storeDetail, nil
|
|
}
|
|
return nil, err
|
|
}
|