|
|
|
|
@@ -59,13 +59,14 @@ type StoreExt struct {
|
|
|
|
|
FloatLng float64 `json:"lng"`
|
|
|
|
|
FloatLat float64 `json:"lat"`
|
|
|
|
|
|
|
|
|
|
ProvinceCode int `json:"provinceCode"`
|
|
|
|
|
ProvinceName string `json:"provinceName"`
|
|
|
|
|
CityName string `json:"cityName"`
|
|
|
|
|
DistrictName string `json:"districtName"`
|
|
|
|
|
StoreMapStr string `json:"-"`
|
|
|
|
|
CourierMapStr string `json:"-"`
|
|
|
|
|
PayeeBankName string `json:"payeeBankName"` // 开户行名称
|
|
|
|
|
ProvinceCode int `json:"provinceCode"`
|
|
|
|
|
ProvinceName string `json:"provinceName"`
|
|
|
|
|
CityName string `json:"cityName"`
|
|
|
|
|
DistrictName string `json:"districtName"`
|
|
|
|
|
StoreMapStr string `json:"-"`
|
|
|
|
|
CourierMapStr string `json:"-"`
|
|
|
|
|
PayeeBankName string `json:"payeeBankName"` // 开户行名称
|
|
|
|
|
LinkStoreCount int `json:"linkStoreCount"`
|
|
|
|
|
// StoreMaps []map[string]interface{} `orm:"-"`
|
|
|
|
|
// CourierMaps []map[string]interface{} `orm:"-"`
|
|
|
|
|
StoreMaps []*model.StoreMap `json:"StoreMaps"`
|
|
|
|
|
@@ -326,8 +327,8 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
|
|
|
|
|
prefix := autils.NewRole("", 0).GetFullName()
|
|
|
|
|
sqlWhereParams = append(sqlWhereParams, keyword+"%", autils.NewStoreBossRole(-1).GetFullName(), prefix, prefix, prefix) // 必须要前缀,不然不能用过些会很慢
|
|
|
|
|
}
|
|
|
|
|
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
|
|
|
|
|
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)
|
|
|
|
|
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.link_store_id = ?"
|
|
|
|
|
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64)
|
|
|
|
|
if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown {
|
|
|
|
|
sqlWhere += `
|
|
|
|
|
OR (SELECT COUNT(*) FROM store_map tsm WHERE t1.id = tsm.store_id AND tsm.deleted_at = ? AND tsm.vendor_store_id = ?) > 0
|
|
|
|
|
@@ -453,7 +454,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|
|
|
|
province.code province_code,
|
|
|
|
|
province.name province_name,
|
|
|
|
|
city.name city_name,
|
|
|
|
|
district.name district_name
|
|
|
|
|
district.name district_name,
|
|
|
|
|
(SELECT COUNT(*) FROM store t11 WHERE t11.link_store_id = t1.id) link_store_count
|
|
|
|
|
` + sql + `
|
|
|
|
|
ORDER BY t1.id DESC
|
|
|
|
|
`
|
|
|
|
|
@@ -776,14 +778,20 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|
|
|
|
handler.UnregisterPrinter(ctx, store.PrinterSN, store.PrinterKey)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if linkStoreID, ok := valid["linkStoreID"].(int); ok {
|
|
|
|
|
if valid["linkStoreID"] != nil {
|
|
|
|
|
linkStoreID := int(utils.Interface2Int64WithDefault(valid["linkStoreID"], 0))
|
|
|
|
|
linkStoreID, err = getRealLinkStoreID(linkStoreID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
if err = checkStoreHaveLinkedStore(storeID, linkStoreID); err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
valid["linkStoreID"] = linkStoreID
|
|
|
|
|
// globals.SugarLogger.Debug(linkStoreID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
|
|
|
|
for _, v := range []string{
|
|
|
|
|
"lng",
|
|
|
|
|
"lat",
|
|
|
|
|
@@ -1003,6 +1011,26 @@ func EnableHaveRestStores(ctx *jxcontext.Context, isAsync, isContinueWhenError b
|
|
|
|
|
return hint, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func checkStoreHaveLinkedStore(storeID, linkStoreID int) (err error) {
|
|
|
|
|
if linkStoreID != 0 {
|
|
|
|
|
if storeID == linkStoreID {
|
|
|
|
|
err = fmt.Errorf("不能自我关联")
|
|
|
|
|
} else {
|
|
|
|
|
storeList, err2 := dao.GetStoreLinkStores(dao.GetDB(), storeID)
|
|
|
|
|
if err = err2; err == nil {
|
|
|
|
|
if len(storeList) > 0 {
|
|
|
|
|
var storeInfo []string
|
|
|
|
|
for _, v := range storeList {
|
|
|
|
|
storeInfo = append(storeInfo, utils.Int2Str(v.ID))
|
|
|
|
|
}
|
|
|
|
|
err = fmt.Errorf("门店%d已经被其它门店(%s)关联,不能再关联至其它门店", storeID, strings.Join(storeInfo, ","))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
|
|
|
|
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
|
|
|
|
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
|
|
|
|
@@ -1022,6 +1050,9 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
if err = checkStoreHaveLinkedStore(storeExt.ID, realLinkStoreID); err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
storeExt.LinkStoreID = realLinkStoreID
|
|
|
|
|
|
|
|
|
|
existingID := store.ID
|
|
|
|
|
|