55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package q_bida
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
bida "git.rosy.net.cn/baseapi/platformapi/q_bida"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/globals/api"
|
|
"math/rand"
|
|
)
|
|
|
|
// 检查快递费是否正确
|
|
func checkWayFeeIsTrue(param *model.MakeOrderParamReq) error {
|
|
// 检查运费提交是否准确
|
|
orderWayFee, err := QueryExpressPrice(&bida.GetExpressPriceReq{
|
|
PromiseTimeType: param.PromiseTimeType,
|
|
DeliveryType: param.DeliveryType,
|
|
GoodsValue: param.GuaranteeValueAmount,
|
|
ReceiveAddress: param.ReceiveAddress,
|
|
SendAddress: param.SenderAddress,
|
|
Type: param.Type,
|
|
Weight: param.Weight,
|
|
Length: param.Length,
|
|
Height: param.Height,
|
|
Width: param.Width,
|
|
SendPhone: param.SenderPhone,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(orderWayFee[fmt.Sprintf("%d", param.Type)].Data.TypeName, orderWayFee[fmt.Sprintf("%d", param.Type)].Data.Type, orderWayFee[fmt.Sprintf("%d", param.Type)].Data.ChannelFee)
|
|
if fee, ok := orderWayFee[fmt.Sprintf("%d", param.Type)]; !ok || fee.Code != 0 || fee.Data.ChannelFee != param.ChannelFee {
|
|
return errors.New("价格核算错误,价格不匹配")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// 创建QBiDa订单
|
|
func createOtherOrder(param *bida.MakeOrderReq) (string, error) {
|
|
// 创建三方订单
|
|
return api.QBiDaAPI.CreateOrder(param)
|
|
}
|
|
|
|
// RandomString 生成随机字符串
|
|
func RandomString(n int) string {
|
|
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
|
|
b := make([]rune, n)
|
|
for i := range b {
|
|
b[i] = letters[rand.Intn(len(letters))]
|
|
}
|
|
|
|
return string(b)
|
|
}
|