266 lines
11 KiB
Go
266 lines
11 KiB
Go
package controllers
|
||
|
||
import (
|
||
"fmt"
|
||
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"
|
||
)
|
||
|
||
type QBiDaExpressController struct {
|
||
web.Controller
|
||
}
|
||
|
||
// QueryExpressPrice 查询物流费
|
||
// @Title Q必达
|
||
// @Description 查询快递费
|
||
// @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 false "快递公司"
|
||
// @Param weight formData int true "重量kg"
|
||
// @Param length formData int false "所有包裹累计长"
|
||
// @Param width formData int false "所有包裹累计宽"
|
||
// @Param height formData int false "所有包裹累计高"
|
||
// @Param sendPhone formData string true "寄件人手机号"
|
||
// @Param channelType formData int true "渠道类型(1-快递,2-物流,3-国际物流,4-整车)"
|
||
// @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,
|
||
ChannelType: params.ChannelType,
|
||
}
|
||
result, err := bidaServer.QueryExpressPrice(param)
|
||
for _, v := range result {
|
||
fmt.Println(v.Data.TypeName, v.Data.Type, v.Data.ChannelFee)
|
||
}
|
||
return result, "", err
|
||
})
|
||
}
|
||
|
||
// CreateWayOrder 下单
|
||
// @Title Q必达
|
||
// @Description 下单
|
||
// @Param token header string true "管理员token"
|
||
// @Param promiseTimeType formData int false "快递时效产品"
|
||
// @Param deliveryType formData int false "产品类型"
|
||
// @Param goods formData string true "商品名称"
|
||
// @Param guaranteeValueAmount formData float64 false "保价金额"
|
||
// @Param weight formData int true "重量kg"
|
||
// @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 "收件人姓名"
|
||
// @Param receivePhone formData string true "收件人手机号"
|
||
// @Param remark formData string false "运单备注"
|
||
// @Param senderAddress formData string true "寄件人地址"
|
||
// @Param senderName formData string true "寄件人姓名"
|
||
// @Param senderPhone formData string true "寄件人手机号"
|
||
// @Param thirdPlatform formData int false "第三方平台"
|
||
// @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]
|
||
func (c *QBiDaExpressController) CreateWayOrder() {
|
||
c.callCreateWayOrder(func(params *tExpressCreateWayOrderParams) (interface{}, string, error) {
|
||
param := &model.MakeOrderParamReq{
|
||
PromiseTimeType: params.PromiseTimeType,
|
||
DeliveryType: params.DeliveryType,
|
||
Goods: params.Goods,
|
||
GuaranteeValueAmount: params.GuaranteeValueAmount,
|
||
Weight: params.Weight,
|
||
Length: params.Length,
|
||
Height: params.Height,
|
||
Width: params.Width,
|
||
OrderSendTime: params.OrderSendTime,
|
||
PackageNum: params.PackageNum,
|
||
ReceiveAddress: params.ReceiveAddress,
|
||
ReceiveName: params.ReceiveName,
|
||
ReceivePhone: params.ReceivePhone,
|
||
Remark: params.Remark,
|
||
SenderAddress: params.SenderAddress,
|
||
SenderName: params.SenderName,
|
||
SenderPhone: params.SenderPhone,
|
||
ThirdPlatform: params.ThirdPlatform,
|
||
Type: params.Type,
|
||
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,
|
||
}
|
||
|
||
order, err := bidaServer.CreateWayOrder(params.Ctx, param, params.Ctx.GetUserID())
|
||
if err != nil {
|
||
return nil, "", err
|
||
}
|
||
return order, "", 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(params.Ctx, params.Ctx.GetUserID(), cancel); err != nil {
|
||
return nil, "", err
|
||
}
|
||
return nil, "", nil
|
||
})
|
||
}
|
||
|
||
// QueryUserOrderList 获取用户订单列表QueryUserOrderList
|
||
// @Title Q必达
|
||
// @Description 获取用户订单列表
|
||
// @Param token header string true "管理员token"
|
||
// @Param expressType formData int false "就是type快递公司"
|
||
// @Param orderStatus formData int false "订单状态"
|
||
// @Param orderNo formData string false "订单号码"
|
||
// @Param pageNum formData int true "页码"
|
||
// @Param pageSize formData int true "页数"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /QueryUserOrderList [post]
|
||
func (c *QBiDaExpressController) QueryUserOrderList() {
|
||
c.callQueryUserOrderList(func(params *tExpressQueryUserOrderListParams) (interface{}, string, error) {
|
||
result, count, err := bidaServer.QueryUserOrderList(params.Ctx.GetUserID(), params.ExpressType, params.OrderStatus, params.PageNum, params.PageSize, params.OrderNo)
|
||
if err != nil {
|
||
return nil, "", err
|
||
}
|
||
|
||
return map[string]interface{}{"result": result, "count": count}, "", err
|
||
})
|
||
}
|
||
|
||
// GetOrderDetail 查询订单详情
|
||
// @Title Q必达
|
||
// @Description 获取订单详情
|
||
// @Param token header string true "管理员token"
|
||
// @Param expressType formData int true "就是type快递公司"
|
||
// @Param orderNo formData string true "订单Id,三方Id"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetOrderDetail [post]
|
||
func (c *QBiDaExpressController) GetOrderDetail() {
|
||
c.callGetOrderDetail(func(params *tExpressGetOrderDetailParams) (interface{}, string, error) {
|
||
result, err := bidaServer.QueryOrderDetail(params.ExpressType, params.OrderNo)
|
||
if err != nil {
|
||
return nil, "", err
|
||
}
|
||
return result, "", nil
|
||
})
|
||
}
|
||
|
||
// GetOrderList 管理系统获取订单详情
|
||
// @Title Q必达
|
||
// @Description 管理系统获取订单详情
|
||
// @Param token header string true "管理员token"
|
||
// @Param expressType formData int false "就是type快递公司"
|
||
// @Param orderNo formData string false "订单Id,三方Id"
|
||
// @Param orderStatus formData int false "订单状态"
|
||
// @Param pageNum formData int true "页码"
|
||
// @Param pageSize formData int true "页数"
|
||
// @Param startTime formData string true "开始时间"
|
||
// @Param endTime formData string true "结束时间"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetOrderList [post]
|
||
func (c *QBiDaExpressController) GetOrderList() {
|
||
c.callGetOrderList(func(params *tExpressGetOrderListParams) (interface{}, string, error) {
|
||
listParam := &model.OrderListReq{
|
||
ExpressType: params.ExpressType,
|
||
OrderNo: params.OrderNo,
|
||
OrderStatus: params.OrderStatus,
|
||
PageNum: params.PageNum,
|
||
PageSize: params.PageSize,
|
||
StartTime: utils.Str2Time(params.StartTime),
|
||
EndTime: utils.Str2Time(params.EndTime),
|
||
}
|
||
result, count, err := bidaServer.ManagerGetOrderList(listParam)
|
||
data := make(map[string]interface{}, 2)
|
||
data["result"] = result
|
||
data["count"] = count
|
||
return data, "", err
|
||
})
|
||
}
|
||
|
||
// DeleteOrder 删除订单
|
||
// @Title Q必达
|
||
// @Description 删除未支付订单,已支付订单一个星期后才能删除
|
||
// @Param token header string true "管理员token"
|
||
// @Param localOrderId formData string true "本地订单"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteOrder [post]
|
||
func (c *QBiDaExpressController) DeleteOrder() {
|
||
c.callDeleteOrder(func(params *tExpressDeleteOrderParams) (interface{}, string, error) {
|
||
count, err := bidaServer.DeleteOrderByLocalId(params.Ctx.GetUserID(), params.LocalOrderId)
|
||
return count, "", err
|
||
})
|
||
}
|
||
|
||
// TryAgainOrderByOldOrder 用户再来一单
|
||
// @Title Q必达
|
||
// @Description 再来一单
|
||
// @Param token header string true "用户token"
|
||
// @Param oldNo formData string true "旧的订单Id"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /TryAgainOrderByOldOrder [post]
|
||
func (c *QBiDaExpressController) TryAgainOrderByOldOrder() {
|
||
c.callTryAgainOrderByOldOrder(func(params *tExpressTryAgainOrderByOldOrderParams) (interface{}, string, error) {
|
||
newOrder, err := bidaServer.TryAgainOrder(params.Ctx, params.OldNo)
|
||
return newOrder, "", err
|
||
})
|
||
}
|