diff --git a/business/q_bida/q_bida_server.go b/business/q_bida/q_bida_server.go new file mode 100644 index 000000000..0121d4a72 --- /dev/null +++ b/business/q_bida/q_bida_server.go @@ -0,0 +1,27 @@ +package q_bida + +import ( + "errors" + bida "git.rosy.net.cn/baseapi/platformapi/q_bida" + "git.rosy.net.cn/jx-callback/globals/api" +) + +func QueryExpressPrice(param *bida.GetExpressPriceReq) ([]*bida.GetExpressPriceData, error) { + if param.Weight <= 0 { + return nil, errors.New("物品重量必须大于0") + } + fee, err := api.QBiDaAPI.GetExpressPrice(param) + if err != nil { + return nil, err + } + + // 渠道费每公斤加价两毛 + for _, v := range fee { + if v.ChannelFee != 0 { + addFee := v.ChannelFee + int64(param.Width*2) + v.ChannelFee = addFee + } + } + + return fee, nil +} diff --git a/conf/app.conf b/conf/app.conf index 67e4e9350..8bc95e264 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -167,6 +167,10 @@ yinbaoAppID = "18C0E0867E467DBC26EFF5E957B02EC4" aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54" +#QBIDA 账号 +QBiDaAccess = "18048531223" +QBiDaPassword = "18080188338" + [rsm] EnableDocs = true @@ -271,6 +275,10 @@ tbUnionAppSecret = "2c2bce02eab860d486f68aa59a0127d9" pddAppKey = "f9d95aaf5856485eabf39588f69a86de" pddAppSecret = "fa40c1fe356eebc1376ace1d2380ed44e553c602" +#QBIDA 账号 +QBiDaAccess = "18048531223" +QBiDaPassword = "18080188338" + [print] httpport = 8088 EnableDocs = false @@ -283,4 +291,7 @@ enableEbaiStoreWrite = true enableMtwmStoreWrite = true enableWscStoreWrite = true enableYbStoreWrite = true -enableJdShopWrite = true \ No newline at end of file +enableJdShopWrite = true +#QBIDA 账号 +QBiDaAccess = "18048531223" +QBiDaPassword = "18080188338" \ No newline at end of file diff --git a/controllers/q_bida.go b/controllers/q_bida.go new file mode 100644 index 000000000..5a87bf7be --- /dev/null +++ b/controllers/q_bida.go @@ -0,0 +1,51 @@ +package controllers + +import ( + bida "git.rosy.net.cn/baseapi/platformapi/q_bida" + bidaServer "git.rosy.net.cn/jx-callback/business/q_bida" + "github.com/astaxie/beego/server/web" +) + +type QBiDaExpressController struct { + web.Controller +} + +// QueryExpressPrice 查询物业费 +// @Title Q必达 +// @Description 查询快递费 +// @Param token header string false "管理员token" +// @Param promiseTimeType formData int true "快递时效产品" +// @Param deliveryType formData int true "产品类型" +// @Param goodsValue formData int true "保价金额" +// @Param receiveAddress formData string true "收件人地址" +// @Param sendAddress formData string true "寄件人地址" +// @Param type formData int true "快递公司" +// @Param weight formData int true "重量kg" +// @Param length formData int true "所有包裹累计长" +// @Param width formData int true "所有包裹累计宽" +// @Param height formData int true "所有包裹累计高" +// @Param sendPhone formData string true "寄件人手机号" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /QueryExpressPrice [post] +func (c *QBiDaExpressController) QueryExpressPrice() { + c.callQueryExpressPrice(func(params *tExpressQueryExpressPriceParams) (interface{}, string, error) { + param := &bida.GetExpressPriceReq{ + PromiseTimeType: params.PromiseTimeType, + DeliveryType: params.DeliveryType, + GoodsValue: params.GoodsValue, + ReceiveAddress: params.ReceiveAddress, + SendAddress: params.SendAddress, + Type: params.Type, + Weight: params.Weight, + Length: params.Length, + Height: params.Height, + Width: params.Width, + SendPhone: params.SendPhone, + } + result, err := bidaServer.QueryExpressPrice(param) + return result, "", err + }) +} + +// 添加收货地址 diff --git a/globals/api/api.go b/globals/api/api.go index 8eae97e40..42229bfb7 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -3,6 +3,7 @@ package api import ( "git.rosy.net.cn/baseapi/platformapi/jdunionapi" "git.rosy.net.cn/baseapi/platformapi/pddapi" + "git.rosy.net.cn/baseapi/platformapi/q_bida" "git.rosy.net.cn/baseapi/platformapi/tbunionapi" "io/ioutil" @@ -84,6 +85,9 @@ var ( Cacher cache.ICacher SMSClient *aliyunsmsclient.SmsClient + + // QBiDaApi + QBiDaAPI *q_bida.Api ) func init() { @@ -161,4 +165,7 @@ func Init() { PushAPI = unipushapi.New(beego.AppConfig.DefaultString("pushAppID", ""), beego.AppConfig.DefaultString("pushAppKey", ""), beego.AppConfig.DefaultString("pushAppSecret", ""), beego.AppConfig.DefaultString("pushMasterSecret", "")) MtMemberAPI = mtmemberapi.New() SMSClient = aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/") + + // 初始化QBIDA + QBiDaAPI = q_bida.NewQBiDa(beego.AppConfig.DefaultString("QBiDaAccess", ""), beego.AppConfig.DefaultString("QBiDaPassword", "")) } diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 51f66981a..c61ebbd90 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1015,4 +1015,13 @@ func init() { Filters: nil, Params: nil}) + // 快递运单 + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:QBiDaExpressController"], + beego.ControllerComments{ + Method: "QueryExpressPrice", + Router: "/QueryExpressPrice", + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) } diff --git a/routers/router.go b/routers/router.go index bf9abca53..b48013e3a 100644 --- a/routers/router.go +++ b/routers/router.go @@ -61,6 +61,12 @@ func init() { &controllers.UnionController{}, ), ), + // QBiDa + web.NSNamespace("/express", + web.NSInclude( + &controllers.QBiDaExpressController{}, + ), + ), ) web.AddNamespace(ns) web.AutoRouter(&controllers.WXPayController{})