diff --git a/business/model/user_vendor_order.go b/business/model/user_vendor_order.go index ccd8b93d4..f762e4316 100644 --- a/business/model/user_vendor_order.go +++ b/business/model/user_vendor_order.go @@ -1,7 +1,5 @@ package model -import "git.rosy.net.cn/jx-callback/business/model/dao" - type UserVendorOrder struct { ModelIDCUL UserId string `orm:"size(128);column(user_id);index" json:"userID"` // 用户ID @@ -22,6 +20,7 @@ type UserVendorOrder struct { Type int `orm:"size(8);column(type)" json:"type"` // 快递公司 PromiseTimeType int `orm:"size(8);column(promise_Time_type)" json:"promiseTimeType"` // 快递时效产品 DeliveryType int `orm:"size(8);column(delivery_type)" json:"deliveryType"` // 产品类型 + ReallyChannelFee float64 `orm:"column(really_channel_fee)" json:"reallyChannelFee"` // 真实价格 ChannelFee float64 `orm:"column(channel_fee)" json:"channelFee"` // 渠道价 ServiceCharge float64 `orm:"column(service_charge)" json:"serviceCharge"` // 服务费 GuarantFee float64 `orm:"column(guarant_fee)" json:"guarantFee"` // 保价费用 @@ -30,20 +29,22 @@ type UserVendorOrder struct { Increment float64 `orm:"column(increment)" json:"increment"` // 增值(物流) ChannelType int `orm:"size(8);column(channel_type)" json:"channelType"` // 渠道类型(1-快递,2-物流,3-国际物流,4-整车) OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(1-待支付,2-支付失败,3-支付成功,4-取件,5-配送,6-,4-取消) - Img string `orm:"text;column(img)" json:"img"` // 包裹图片 + Img string `orm:"column(img)" json:"img"` // 包裹图片 + IsForward int `orm:"column(is_forward)" json:"isForward"` // 1否,2是 } func (*UserVendorOrder) TableUnique() [][]string { return [][]string{ - []string{"LocalWayBill", "DeletedAt"}, - []string{"OtherWayBill", "DeletedAt"}, - []string{"CreatedAt", "DeletedAt"}, + []string{"LocalWayBill"}, + []string{"OtherWayBill"}, } } -func (u *UserVendorOrder) CreateVendorOrder() error { - return dao.CreateEntity(dao.GetDB(), u) -} +//func (*UserVendorOrder) TableIndex()[][]string { +// return [][]string{ +// []string{""}, +// } +//} // MakeOrderParamReq 下订单请求参数 type MakeOrderParamReq struct { @@ -62,14 +63,14 @@ type MakeOrderParamReq struct { ReceiveName string `json:"receiveName"` // 收件人姓名 ReceivePhone string `json:"receivePhone"` // 收件人手机号 Remark string `json:"remark"` // 运单备注 - SenderAddressID int64 `json:"senderAddressId"` // 寄件人地址Id + SenderAddressId int64 `json:"senderAddressId"` // 寄件人地址Id SenderAddress string `json:"senderAddress"` // 寄件人地址 SenderName string `json:"senderName"` // 寄件人姓名 SenderPhone string `json:"senderPhone"` // 寄件人手机号 ThirdPlatform int `json:"thirdPlatform"` // 第三方平台-京东商家下单传3 Type int `json:"type"` // 快递公司 ChannelType int `json:"channelType"` // 渠道类型(1-快递,2-物流,3-国际物流,4-整车) - Img string `json:"img"` // 包裹图片 + Images string `json:"images"` // 包裹图片 // 快递费 ChannelFee float64 `json:"channel_fee"` // 渠道价 Bulk float64 `json:"bulk"` // 体积抛比系数 diff --git a/business/q_bida/q_bida_server.go b/business/q_bida/q_bida_server.go index 88a8a631f..9ec253c69 100644 --- a/business/q_bida/q_bida_server.go +++ b/business/q_bida/q_bida_server.go @@ -59,6 +59,7 @@ func QueryExpressPrice(param *bida.GetExpressPriceReq) (map[string]*bida.GetExpr // CreateWayOrder 创建快递订单 func CreateWayOrder(ctx *jxcontext.Context, param *model.MakeOrderParamReq, userId string) error { // 检查价格 + reallyCannelleFee := param.ChannelFee if err := checkWayFeeIsTrue(param); err != nil { return err } @@ -86,9 +87,10 @@ func CreateWayOrder(ctx *jxcontext.Context, param *model.MakeOrderParamReq, user PackageNum: param.PackageNum, ReceiveAddressID: param.ReceiveAddressId, Remark: param.Remark, - SenderAddressID: param.SenderAddressID, + SenderAddressID: param.SenderAddressId, ThirdPlatform: param.ThirdPlatform, Type: param.Type, + ReallyChannelFee: reallyCannelleFee, ChannelFee: param.ChannelFee, ServiceCharge: param.ServiceCharge, GuarantFee: param.GuarantFee, @@ -97,8 +99,41 @@ func CreateWayOrder(ctx *jxcontext.Context, param *model.MakeOrderParamReq, user Increment: param.Increment, ChannelType: param.ChannelType, OrderStatus: model.YES, // 创建 - Img: param.Img, + Img: param.Images, + IsForward: model.YES, } dao.WrapAddIDCULEntity(vendorOrder, ctx.GetUserName()) - return vendorOrder.CreateVendorOrder() + return dao.CreateEntity(dao.GetDB(), vendorOrder) +} + +// CancelWayOrder 取消运单 todo +func CancelWayOrder(param *bida.CancelOrderReq) error { + if err := api.QBiDaAPI.CancelOrder(param); err != nil { + return err + } + + // 发起退款 + // 修改本地订单状态 + return nil +} + +// QueryOrderDetail 获取订单详细信息 +func QueryOrderDetail(typeCode int, orderNo string) (*bida.OrderDetail, error) { + detail, err := api.QBiDaAPI.GetOrderDetail(&bida.GetOrderDetailReq{ + Type: typeCode, + OrderNo: orderNo, + }) + if err != nil { + return nil, err + } + + // 本地查询获取真是支付快递费用 + sql := `SELECT * FROM user_vendor_order a WHERE a.other_way_bill = ? and a.type = ? ` + data := &model.UserVendorOrder{} + param := []interface{}{orderNo, typeCode} + if err := dao.GetRow(dao.GetDB(), data, sql, param); err != nil { + return nil, err + } + + detail.ExpressFee = data.ChannelFee } diff --git a/conf/app.conf b/conf/app.conf index 8bc95e264..a5a899882 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -88,6 +88,10 @@ addEvent = true dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" +#QBIDA 账号 +QBiDaAccess = "18048531223" +QBiDaPassword = "18080188338" + [beta] enableStoreWrite = true enableJdStoreWrite = false diff --git a/controllers/q_bida.go b/controllers/q_bida.go index 916292dea..0b4e283ab 100644 --- a/controllers/q_bida.go +++ b/controllers/q_bida.go @@ -2,6 +2,7 @@ package controllers import ( bida "git.rosy.net.cn/baseapi/platformapi/q_bida" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" bidaServer "git.rosy.net.cn/jx-callback/business/q_bida" "github.com/astaxie/beego/server/web" @@ -11,16 +12,16 @@ type QBiDaExpressController struct { web.Controller } -// QueryExpressPrice 查询物业费 +// QueryExpressPrice 查询物流费 // @Title Q必达 // @Description 查询快递费 -// @Param token header string false "管理员token" -// @Param promiseTimeType formData int true "快递时效产品" -// @Param deliveryType formData int true "产品类型" -// @Param goodsValue formData float64 true "保价金额" +// @Param token header string true "管理员token" +// @Param promiseTimeType formData int false "快递时效产品" +// @Param deliveryType formData int false "产品类型" +// @Param goodsValue formData float64 false "保价金额" // @Param receiveAddress formData string true "收件人地址" // @Param sendAddress formData string true "寄件人地址" -// @Param type formData int true "快递公司" +// @Param type formData int false "快递公司" // @Param weight formData int true "重量kg" // @Param length formData int true "所有包裹累计长" // @Param width formData int true "所有包裹累计宽" @@ -49,21 +50,19 @@ func (c *QBiDaExpressController) QueryExpressPrice() { }) } -// 下单 - // CreateWayOrder 下单 // @Title Q必达 // @Description 下单 -// @Param token header string false "管理员token" +// @Param token header string true "管理员token" // @Param promiseTimeType formData int true "快递时效产品" // @Param deliveryType formData int true "产品类型" // @Param goods formData string true "商品名称" -// @Param guaranteeValueAmount formData float64 true "保价金额" +// @Param guaranteeValueAmount formData float64 false "保价金额" // @Param weight formData int true "重量kg" -// @Param length formData int true "所有包裹累计长" -// @Param width formData int true "所有包裹累计宽" -// @Param height formData int true "所有包裹累计高" -// @Param orderSendTime formData string true "预约时间" +// @Param length formData int false "所有包裹累计长" +// @Param width formData int false "所有包裹累计宽" +// @Param height formData int false "所有包裹累计高" +// @Param orderSendTime formData string false "预约时间" // @Param packageNum formData int true "包裹数量" // @Param receiveAddress formData string true "收件人地址" // @Param receiveName formData string true "收件人姓名" @@ -74,6 +73,16 @@ func (c *QBiDaExpressController) QueryExpressPrice() { // @Param senderPhone formData string true "寄件人手机号" // @Param thirdPlatform formData int true "第三方平台" // @Param type formData int true "快递公司" +// @Param receiveAddressId formData int64 true "收件人地址Id" +// @Param senderAddressId formData int64 true "寄件人地址Id" +// @Param channelType formData int true "渠道类型(1-快递,2-物流,3-国际物流,4-整车)" +// @Param images formData string false "物品图片多个用逗号隔开" +// @Param channelFee formData float64 true "渠道价" +// @Param bulk formData int false "泡比" +// @Param serviceCharge formData float64 false "服务费" +// @Param guarantFee formData float64 false "保价" +// @Param originalFee formData float64 false "原价" +// @Param increment formData float64 false "物流" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CreateWayOrder [post] @@ -99,18 +108,46 @@ func (c *QBiDaExpressController) CreateWayOrder() { SenderPhone: params.SenderPhone, ThirdPlatform: params.ThirdPlatform, Type: params.Type, - ReceiveAddressId: 0, - SenderAddressID: 0, - ChannelType: 0, - Img: "", - ChannelFee: 0, - Bulk: 0, - ServiceCharge: 0, - GuarantFee: 0, - OriginalFee: 0, - Increment: 0, + ReceiveAddressId: int64(params.ReceiveAddressId), + SenderAddressId: int64(params.SenderAddressId), + ChannelType: params.ChannelType, + Images: params.Images, + ChannelFee: params.ChannelFee, + Bulk: utils.Int2Float64(params.Bulk), + ServiceCharge: params.ServiceCharge, + GuarantFee: params.GuarantFee, + OriginalFee: params.OriginalFee, + Increment: params.Increment, + } + + if err := bidaServer.CreateWayOrder(params.Ctx, param, params.Ctx.GetUserID()); err != nil { + return nil, "", err + } + return nil, "", nil + }) +} + +// CancelWayVendorOrder 取消运单 +// @Title Q必达 +// @Description 取消运单 +// @Param token header string true "管理员token" +// @Param genre formData int true "1取消2关闭" +// @Param orderNo formData string true "订单编号" +// @Param type formData int true "快递公司" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /CancelWayVendorOrder [post] +func (c *QBiDaExpressController) CancelWayVendorOrder() { + c.callCancelWayVendorOrder(func(params *tExpressCancelWayVendorOrderParams) (interface{}, string, error) { + cancel := &bida.CancelOrderReq{ + Genre: params.Genre, + OrderNo: params.OrderNo, + Type: params.Type, + } + + if err := bidaServer.CancelWayOrder(cancel); err != nil { + return nil, "", err } - bidaServer.CreateWayOrder(c.Ctx, params) return nil, "", nil }) } diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index c61ebbd90..1cc98a0d8 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1015,7 +1015,7 @@ 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", @@ -1024,4 +1024,13 @@ func init() { MethodParams: param.Make(), 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: "CreateWayOrder", + Router: "/CreateWayOrder", + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) }