!!!门店相关的API全部添加vendorOrgCode依赖

This commit is contained in:
gazebo
2019-12-06 17:20:55 +08:00
parent 7fb09f99d1
commit 039f87c8dc
27 changed files with 167 additions and 164 deletions

View File

@@ -26,6 +26,7 @@ const (
type tJdStoreInfo struct {
model.Store
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` //
@@ -37,8 +38,9 @@ type tJdStoreInfo struct {
SyncStatus int
}
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
result, err := getAPI("").GetStoreInfoByStationNo2(vendorStoreID)
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (*dao.StoreDetail, error) {
a := getAPI(vendorOrgCode)
result, err := a.GetStoreInfoByStationNo2(vendorStoreID)
if err == nil {
retVal := &dao.StoreDetail{
Store: model.Store{
@@ -92,7 +94,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string
}
retVal.ID = int(utils.Str2Int64WithDefault(result.OutSystemID, 0))
deliveryRange, err2 := getAPI("").GetDeliveryRangeByStationNo2(vendorStoreID)
deliveryRange, err2 := a.GetDeliveryRangeByStationNo2(vendorStoreID)
if err = err2; err == nil {
retVal.DeliveryRangeType = int8(deliveryRange.DeliveryRangeType)
if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon {
@@ -110,9 +112,11 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
var stores []*tJdStoreInfo
sql := `
SELECT t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator,
t2.sync_status, t2.freight_deduction_pack
SELECT
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
t2.last_operator) real_last_operator,
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code
FROM store t1
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
LEFT JOIN place city ON t1.city_code = city.code
@@ -122,6 +126,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
`
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, utils.DefaultTimeValue, storeID); err == nil {
for _, store := range stores {
a := getAPI(store.VendorOrgCode)
storeParams := &jdapi.OpStoreParams{
StationNo: store.VendorStoreID,
Operator: userName,
@@ -163,7 +168,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
globals.SugarLogger.Debug(utils.Format4Output(storeParams, false))
errList := errlist.New()
if globals.EnableJdStoreWrite {
errList.AddErr(getAPI("").UpdateStoreInfo4Open2(storeParams, modifyCloseStatus))
errList.AddErr(a.UpdateStoreInfo4Open2(storeParams, modifyCloseStatus))
}
if store.FreightDeductionPack != "" {
storeDetail, err2 := dao.GetStoreDetail(db, store.ID, model.VendorIDJD)
@@ -196,7 +201,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
freightParams.IsFullFree = len(freightParams.FreeFreightInfoList) > 0
globals.SugarLogger.Debug(utils.Format4Output(freightParams, false))
if globals.EnableJdStoreWrite {
errList.AddErr(getAPI("").UpdateStoreFreightConfigNew(freightParams))
errList.AddErr(a.UpdateStoreFreightConfigNew(freightParams))
}
}
}
@@ -239,7 +244,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
storeParams.OutSystemID = store.VendorStoreID
}
if globals.EnableJdStoreWrite {
err = getAPI("").UpdateStoreInfo4Open2(storeParams, false)
err = getAPI(store.VendorOrgCode).UpdateStoreInfo4Open2(storeParams, false)
}
return nil, err
}, stores)
@@ -265,8 +270,8 @@ func JdDeliveryType2Jx(deliveryType int) int8 {
return scheduler.StoreDeliveryTypeByPlatform
}
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) {
result, err := getAPI("").GetStoreInfoByStationNo2(vendorStoreID)
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) {
result, err := getAPI(vendorOrgCode).GetStoreInfoByStationNo2(vendorStoreID)
if err == nil {
storeStatus = JdStoreStatus2JxStatus(int(result.Yn), result.CloseStatus)
}
@@ -291,15 +296,15 @@ func (c *PurchaseHandler) OnStoreMsg(msg *jdapi.CallbackOrderMsg) (response *jda
return jdapi.Err2CallbackResponse(err, "")
}
func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) {
_, err = getAPI("").UpdateStoreConfig4Open(vendorStoreID, isSetEnable)
func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) {
_, err = getAPI(vendorOrgCode).UpdateStoreConfig4Open(vendorStoreID, isSetEnable)
return err
}
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) {
_, closeStatus := JxStoreStatus2JdStatus(status)
if globals.EnableJdStoreWrite {
err = getAPI("").UpdateStoreInfo4Open2(&jdapi.OpStoreParams{
err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2(&jdapi.OpStoreParams{
StationNo: vendorStoreID,
Operator: ctx.GetUserName(),
CloseStatus: closeStatus,
@@ -331,20 +336,20 @@ func fillOpTimeParams(params *jdapi.OpStoreParams, opTimeList []int16) {
}
}
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
params := &jdapi.OpStoreParams{
StationNo: vendorStoreID,
Operator: ctx.GetUserName(),
}
fillOpTimeParams(params, opTimeList)
if globals.EnableJdStoreWrite {
err = getAPI("").UpdateStoreInfo4Open2(params, false)
err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2(params, false)
}
return err
}
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) {
vendorStoreIDs, err = getAPI("").GetStationsByVenderId()
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) {
vendorStoreIDs, err = getAPI(vendorOrgCode).GetStationsByVenderId()
return vendorStoreIDs, err
}
@@ -453,9 +458,9 @@ func (c *PurchaseHandler) SyncQualify(ctx *jxcontext.Context, storeDetail *dao.S
return addStoreInfo2Err(err, storeDetail.ID)
}
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) {
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) {
if globals.EnableJdStoreWrite {
err = getAPI("").UpdateStoreInfo4Open2(
err = getAPI(vendorOrgCode).UpdateStoreInfo4Open2(
&jdapi.OpStoreParams{
StationNo: vendorStoreID,
Operator: ctx.GetUserName(),