You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
7.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package otosaas
import "git.oa00.com/go/otosaas/request"
type order struct {
}
const (
orderFreight = "/mall/v1/order/orderFreight" // 计算运费
orderSubmit = "/mall/v1/order/submitOrder" // 生成订单
orderConfirm = "/mall/v1/order/confirm" // 确认下单
orderDetail = "/mall/v1/order/queryPartnerOrderDetails" // 订单详情
orderLogistics = "/mall/v1/order/queryPartnerOrderLogistics" // 订单物流查询
orderReceipt = "/mall/v1/order/confirmReceipt" // 确认收货
)
type SkuFreightItem struct {
CommodityCode string `json:"commodityCode"` // 商品编号
CommoditySpecCode string `json:"commoditySpecCode"` // 规格编号
CommodityNum uint `json:"commodityNum"` // 商品数量
}
type respFreightAmount struct {
FreightAmount float64 `json:"freightAmount"`
}
// Freight @Title 运费获取
func (o *order) Freight(skus []SkuFreightItem) (freightAmount float64, err error) {
amount := respFreightAmount{}
err = request.Exec(orderFreight, map[string]interface{}{
"commodityList": skus,
}, &amount)
return amount.FreightAmount, err
}
type OrderSubmit struct {
UserId string `json:"userId"` // 固定传
UserPhone string `json:"userPhone"` // 固定传
TotalPrice float64 `json:"totalPrice"` // 订单总金额
ReceiverName string `json:"receiverName"` // 收件人
ReceiverPhone string `json:"receiverPhone"` // 收件人手机号
ReceiverProvince string `json:"receiverProvince"` // 省
ReceiverCity string `json:"receiverCity"` // 市
ReceiverRegion string `json:"receiverRegion"` // 区
ReceiverStreetName string `json:"receiverStreetName"` // 街道
ReceiverDetailAddress string `json:"receiverDetailAddress"` // 详细地址
CommodityList []OrderSkuItem `json:"commodityList"` // 商品信息
Remark string `json:"remark"` // 备注
FreightAmount float64 `json:"freightAmount"` // 运费
CustomerOrderId string `json:"customerOrderId"` // 订单号
CreateTime int64 `json:"createTime"` // 创建时间
}
type OrderSkuItem struct {
CommodityCode string `json:"commodityCode"` // 商品编号
CommoditySpecCode string `json:"commoditySpecCode"` // 规格编号
CommodityNum uint `json:"commodityNum"` // 商品数量
CommoditySpecPrice float64 `json:"commoditySpecPrice"` // 购买数量
ShopCode string `json:"shopCode"` // 店铺编码
}
type respOrderSubmit struct {
OrderId string `json:"orderId"`
}
// Submit @Title 生成订单
func (o *order) Submit(data OrderSubmit) (orderId string, err error) {
submit := respOrderSubmit{}
err = request.Exec(orderSubmit, data, &submit)
return submit.OrderId, err
}
type respOrderConfirm struct {
OrderId string `json:"orderId"` // 订单id
Status int `json:"status"` // 订单状态0->待付款1->待发货2->待收货;4 ->已完成 ; 5->已取消6->已关闭
}
// Confirm @Title 确认下单
func (o *order) Confirm(orderId, userId string) (confirm respOrderConfirm, err error) {
err = request.Exec(orderConfirm, map[string]interface{}{
"orderId": orderId,
"userId": userId,
}, &confirm)
return confirm, err
}
type OrderDetail struct {
PaymentSerial string `json:"paymentSerial"` // 支付流水号 无用
Item []struct {
RealAmount string `json:"realAmount"` // 子订单实付金额
CommoditySpecCode string `json:"commoditySpecCode"` // 商品规格编号
CommodityPic string `json:"commodityPic"` // 商品图片
FreightAmount string `json:"freightAmount"` // 子订单运费
CommodityNum string `json:"commodityNum"` // 商品数量
CommodityCode string `json:"commodityCode"` // 商品编码
CommoditySpecialPrice string `json:"commoditySpecialPrice"` // 商品价格
CommodityAttr string `json:"commodityAttr"` // 子订单商品属性
ItemOrderId string `json:"itemOrderId"` // 子订单号
CommodityName string `json:"commodityName"` // 商品名称
Status string `json:"status"` // 子订单状态0->待付款1->待发货2->已发货3->已收货 ;4 ->已完成 ; 5->已取消6->已关闭
} `json:"item"`
FreightAmount string `json:"freightAmount"` // 运费
OrderId string `json:"orderId"` // 订单id
ReceiverName string `json:"receiverName"` // 收货人姓名
CustomerOrderId string `json:"customerOrderId"` // 客户订单编号
ReceiverProvince string `json:"receiverProvince"` // 省份
ReceiverDetailAddress string `json:"receiverDetailAddress"` // 详细地址
ReceiverCity string `json:"receiverCity"` // 城市名称
ReceiverStreetName string `json:"receiverStreetName"` // 街道名称
PayAmount string `json:"payAmount"` // 支付金额
ReceiverPhone string `json:"receiverPhone"` // 收货人手机号
ReceiverRegion string `json:"receiverRegion"` // 地区名称
CreateTime string `json:"createTime"` // 下单时间
Status string `json:"status"` // 订单状态0->待付款1->待发货2->待收货;4 ->已完成 ; 5->已取消6->已关闭
}
// Detail @Title 订单详情
func (o *order) Detail(orderId, userId string) (result OrderDetail, err error) {
err = request.Exec(orderDetail, map[string]interface{}{
"orderId": orderId,
"userId": userId,
}, &result)
return result, err
}
type OrderLogistics struct {
ReceiverStreetName string `json:"receiverStreetName"` // 街道名称
ReceiverPhone string `json:"receiverPhone"` // 收件人手机号
ReceiverRegion string `json:"receiverRegion"` // 地区
ReceiverName string `json:"receiverName"` // 收件人
OrderExpressList []struct {
ExpressName string `json:"expressName"` // 物流名称
Commodity []struct {
CommoditySpecCode string `json:"commoditySpecCode"` // 商品规格编号
Num int `json:"num"` // 商品数量
CommodityCode string `json:"commodityCode"` // 商品编号
CommodityAttr string `json:"commodityAttr"` // 商品属性
ItemOrderId string `json:"itemOrderId"` // 商品子订单号
CommodityName string `json:"commodityName"` // 商品名称
} `json:"commodity"`
DeliveryTime string `json:"deliveryTime"` // 发货时间 Y-m-d H:i:s
ExpressSn string `json:"expressSn"` // 物流编码
} `json:"orderExpressList"`
ReceiverProvince string `json:"receiverProvince"` // 省份
ReceiverDetailAddress string `json:"receiverDetailAddress"` // 详细地址
ReceiverCity string `json:"receiverCity"` // 城市
}
// Logistics @Title 订单物流信息
func (o *order) Logistics(orderId, userId string) (result OrderLogistics, err error) {
err = request.Exec(orderLogistics, map[string]interface{}{
"orderId": orderId,
"userId": userId,
}, &result)
return result, err
}
// Receipt @Title 确认收货 itemOrderId不填整单确认。
func (o *order) Receipt(orderId, userId, itemOrderId string) error {
return request.Exec(orderReceipt, map[string]interface{}{
"orderId": orderId,
"userId": userId,
"itemOrderId": itemOrderId,
}, nil)
}