修改蜂鸟配送
This commit is contained in:
@@ -1,32 +1,72 @@
|
||||
package fn
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||
err = api.FnAPI.CreateStore(&fnpsapi.CreateStoreParam{
|
||||
ChainStoreCode: utils.Int2Str(storeDetail.ID),
|
||||
ChainStoreName: globals.StoreName + "-" + storeDetail.Name,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
Address: storeDetail.Address,
|
||||
PositionSource: 3,
|
||||
Longitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)),
|
||||
Latitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)),
|
||||
})
|
||||
if err == nil {
|
||||
vendorStoreID = utils.Int2Str(storeDetail.ID)
|
||||
var (
|
||||
auditStatusMap = map[int]int{
|
||||
// 创建
|
||||
fnpsapi.ShopCreateStatusAuditRejected: model.StoreAuditStatusCreated,
|
||||
fnpsapi.ShopCreateStatusAuditPassed: model.StoreAuditStatusRejected,
|
||||
fnpsapi.ShopCreateStatusAuditCreated: model.StoreAuditStatusCreated,
|
||||
fnpsapi.ShopCreateStatusAuditOnline: model.StoreAuditStatusOnline,
|
||||
fnpsapi.ShopCreateStatusAuditUpdateRejected: model.StoreAuditStatusOnline,
|
||||
|
||||
// 修改
|
||||
fnpsapi.ShopUpdateStatusAuditRejected: model.StoreAuditStatusCreated,
|
||||
}
|
||||
return vendorStoreID, status, err
|
||||
)
|
||||
|
||||
func getAuditStatus(vendorAuditStatus int) int {
|
||||
if auditStatus, ok := auditStatusMap[vendorAuditStatus]; ok {
|
||||
return auditStatus
|
||||
}
|
||||
return model.StoreAuditStatusCreated
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||
// 获取品牌名称
|
||||
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
|
||||
createStore := &fnpsapi.CreateStoreBaseInfo{
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
Address: storeDetail.Address,
|
||||
Longitude: utils.Int2Float64(storeDetail.Lng) / 1000000,
|
||||
Latitude: utils.Int2Float64(storeDetail.Lat) / 1000000,
|
||||
PositionSource: 3,
|
||||
OutShopCode: utils.Int2Str(storeDetail.ID),
|
||||
CategoryID: "51",
|
||||
OwnerName: storeDetail.IDName,
|
||||
OwnerIDNum: storeDetail.IDCode,
|
||||
HandheldLicencePicHash: "暂不需要(手持身份证、营业执照图片)",
|
||||
OwnerIDPicFrontHash: "暂不需要(省份证正)",
|
||||
OwnerIDPicBackHash: "暂不需要(身份证反)",
|
||||
CreditCode: storeDetail.LicenceCode,
|
||||
BusinessLicencePicHash: storeDetail.Licence,
|
||||
}
|
||||
if len(brandInfo) >= 0 {
|
||||
createStore.HeadShopName = brandInfo[0].Name + "-" + storeDetail.Name
|
||||
} else {
|
||||
createStore.HeadShopName = storeDetail.Name
|
||||
}
|
||||
|
||||
fnShopId, err := api.FnAPI.CreateStore(createStore)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
|
||||
return fnShopId, status, err
|
||||
}
|
||||
|
||||
func shopStatus2JX(status int) (jxStatus int) {
|
||||
@@ -65,20 +105,68 @@ func (c *DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) {
|
||||
params := &fnpsapi.CreateStoreParam{
|
||||
ChainStoreCode: utils.Int2Str(storeDetail.ID),
|
||||
// ChainStoreName: globals.StoreName + "-" + storeDetail.Name,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
Address: storeDetail.Address,
|
||||
PositionSource: 3,
|
||||
Longitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)),
|
||||
Latitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)),
|
||||
// 获取品牌名称
|
||||
brandInfo, err := dao.GetBrands(dao.GetDB(), "", storeDetail.BrandID, "", false, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !strings.Contains(storeDetail.Name, globals.StoreName+"-") {
|
||||
params.ChainStoreName = globals.StoreName + "-" + storeDetail.Name
|
||||
|
||||
updateStore := &fnpsapi.UpdateStoreParam{
|
||||
ChainStoreID: "",
|
||||
HeadShopName: brandInfo[0].Name + "-" + storeDetail.Name,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
Address: storeDetail.Address,
|
||||
Longitude: utils.Int2Float64(storeDetail.Lng) / 1000000,
|
||||
Latitude: utils.Int2Float64(storeDetail.Lat) / 1000000,
|
||||
PositionSource: 3,
|
||||
OutShopCode: utils.Int2Str(storeDetail.ID),
|
||||
CategoryID: "51",
|
||||
OwnerName: storeDetail.IDName,
|
||||
OwnerIDNum: storeDetail.IDCode,
|
||||
HandheldLicencePicHash: "暂不需要(手持身份证、营业执照图片)",
|
||||
OwnerIDPicFrontHash: "暂不需要(省份证正)",
|
||||
OwnerIDPicBackHash: "暂不需要(身份证反)",
|
||||
CreditCode: storeDetail.LicenceCode,
|
||||
BusinessLicencePicHash: storeDetail.Licence,
|
||||
}
|
||||
if len(brandInfo) >= 0 {
|
||||
updateStore.HeadShopName = brandInfo[0].Name + "-" + storeDetail.Name
|
||||
} else {
|
||||
params.ChainStoreName = storeDetail.Name
|
||||
updateStore.HeadShopName = storeDetail.Name
|
||||
}
|
||||
err = api.FnAPI.UpdateStore(params)
|
||||
return err
|
||||
|
||||
return api.FnAPI.UpdateStore(updateStore)
|
||||
}
|
||||
|
||||
// 蜂鸟门店状态改变
|
||||
func OnStoreStatus(msg map[string]interface{}) (retVal *fnpsapi.CallbackResponse) {
|
||||
return curDeliveryHandler.OnStoreStatus(msg)
|
||||
}
|
||||
|
||||
// 修改本地门店审核状态
|
||||
func (c *DeliveryHandler) OnStoreStatus(msg map[string]interface{}) (retVal *fnpsapi.CallbackResponse) {
|
||||
var status int = 0
|
||||
if storeStatus, ok := msg["status"]; ok && storeStatus != 0 {
|
||||
status = int(utils.ForceInterface2Int64(storeStatus))
|
||||
} else {
|
||||
status = int(utils.ForceInterface2Int64(msg["modify_status"]))
|
||||
}
|
||||
err := partner.CurStoreManager.OnCourierStoreStatusChanged(
|
||||
jxcontext.AdminCtx,
|
||||
utils.Interface2String(msg["out_shop_code"]),
|
||||
model.VendorIDFengNiao,
|
||||
getAuditStatus(status),
|
||||
utils.Interface2String(msg["remark"]),
|
||||
)
|
||||
retVal = fnpsapi.Err2CallbackResponse(err, "mtps OnStoreStatus")
|
||||
return retVal
|
||||
}
|
||||
|
||||
type ChainstoreParam struct {
|
||||
MerchantId string `json:"merchant_id"` // 商户id
|
||||
ChainStoreId string `json:"chain_store_id"` // 蜂鸟门店id
|
||||
OutShopCode string `json:"out_shop_code"` // 外部门店编码
|
||||
Status string `json:"status"` // 门店认证状态
|
||||
ModifyStatus string `json:"modify_status"` // 门店修改状态
|
||||
Remark string `json:"remark "` // 门店认证、修改等驳回时返回原因
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user