1
This commit is contained in:
@@ -5,23 +5,19 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jcqapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -308,12 +304,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
if order.OrderType == model.OrderTypeAddressErr {
|
||||
buildOrderTo102919(order)
|
||||
}
|
||||
// billParams, _ := GetDaDaBillParams(db, order)
|
||||
// if result, err := api.DadaAPI.QueryDeliverFee(billParams); err == nil {
|
||||
// if result.Fee > 10 {
|
||||
// buildOrderTo102919(order)
|
||||
// }
|
||||
// }
|
||||
|
||||
if store != nil {
|
||||
distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
if distance > 4 {
|
||||
@@ -328,12 +319,6 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
}
|
||||
|
||||
func buildOrderTo102919(order *model.GoodsOrder) {
|
||||
// if order.VendorOrgCode == "1" {
|
||||
// order.StoreID = 102919
|
||||
// order.JxStoreID = 102919
|
||||
// order.StoreName = "商城模板(成都发货)"
|
||||
// order.VendorStoreID = model.JdShopMainVendorStoreID
|
||||
// } else {
|
||||
order.StoreID = model.JdShopMainStoreID
|
||||
order.JxStoreID = model.JdShopMainStoreID
|
||||
order.StoreName = "商城模板店2"
|
||||
@@ -403,81 +388,82 @@ func getAllRealOrderID(orderID string) (orders []*model.GoodsOrder) {
|
||||
return orders
|
||||
}
|
||||
|
||||
func GetDaDaBillParams(db *dao.DaoDB, order *model.GoodsOrder) (billParams *dadaapi.OperateOrderParams, err error) {
|
||||
billParams = &dadaapi.OperateOrderParams{
|
||||
OriginID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
|
||||
CargoPrice: jxutils.IntPrice2Standard(limitOrderPrice(order.ActualPayPrice)),
|
||||
IsPrepay: 0,
|
||||
ReceiverName: utils.FilterMb4(order.ConsigneeName),
|
||||
ReceiverAddress: utils.FilterMb4(order.ConsigneeAddress),
|
||||
ReceiverPhone: order.ConsigneeMobile,
|
||||
}
|
||||
if billParams.ShopNo, err = getDadaShopID(order, db); err == nil {
|
||||
if billParams.CityCode, err = getDataCityCodeFromOrder(order, db); err == nil {
|
||||
// storeTel := ""
|
||||
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// if storeDeatail.Tel2 != "" {
|
||||
// storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// }
|
||||
billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成定单!"))
|
||||
billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||
billParams.CargoNum = order.GoodsCount
|
||||
}
|
||||
}
|
||||
return billParams, err
|
||||
}
|
||||
|
||||
func limitOrderPrice(price int64) int64 {
|
||||
var maxOrderPrice int64 = 6399
|
||||
if price > maxOrderPrice {
|
||||
return maxOrderPrice
|
||||
}
|
||||
return price
|
||||
}
|
||||
|
||||
func limitOrderWeight(weight int) int {
|
||||
maxOrderWeight := 5000 // 5公斤
|
||||
if weight > maxOrderWeight {
|
||||
return maxOrderWeight
|
||||
}
|
||||
return weight
|
||||
}
|
||||
|
||||
func getDadaShopID(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
saleStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
storeCourierList, err2 := dao.GetOpenedStoreCouriersByStoreID(db, saleStoreID, model.VendorIDDada)
|
||||
if err = err2; err != nil && !dao.IsNoRowsError(err) {
|
||||
return "", err
|
||||
}
|
||||
if len(storeCourierList) == 0 {
|
||||
return "", partner.ErrStoreHaveNoCourier
|
||||
}
|
||||
retVal = storeCourierList[0].VendorStoreID
|
||||
if beego.BConfig.RunMode == "dev" {
|
||||
retVal = "test_0001"
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
func getDataCityCodeFromOrder(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
jxStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
sql := `
|
||||
SELECT t2.tel_code
|
||||
FROM store t1
|
||||
JOIN place t2 on t1.city_code = t2.code
|
||||
WHERE t1.id = ?
|
||||
`
|
||||
codeInfo := &struct {
|
||||
TelCode string
|
||||
}{}
|
||||
if err = dao.GetRow(db, codeInfo, sql, jxStoreID); err != nil {
|
||||
if err == nil {
|
||||
err = errors.New("不能找到美团配送站点配置")
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return codeInfo.TelCode, nil
|
||||
}
|
||||
//
|
||||
//func GetDaDaBillParams(db *dao.DaoDB, order *model.GoodsOrder) (billParams *dadaapi.OperateOrderParams, err error) {
|
||||
// billParams = &dadaapi.OperateOrderParams{
|
||||
// OriginID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
|
||||
// CargoPrice: jxutils.IntPrice2Standard(limitOrderPrice(order.ActualPayPrice)),
|
||||
// IsPrepay: 0,
|
||||
// ReceiverName: utils.FilterMb4(order.ConsigneeName),
|
||||
// ReceiverAddress: utils.FilterMb4(order.ConsigneeAddress),
|
||||
// ReceiverPhone: order.ConsigneeMobile,
|
||||
// }
|
||||
// if billParams.ShopNo, err = getDadaShopID(order, db); err == nil {
|
||||
// if billParams.CityCode, err = getDataCityCodeFromOrder(order, db); err == nil {
|
||||
// // storeTel := ""
|
||||
// // storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// // storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// // if storeDeatail.Tel2 != "" {
|
||||
// // storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// // }
|
||||
// billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
// billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成定单!"))
|
||||
// billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
// billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||
// billParams.CargoNum = order.GoodsCount
|
||||
// }
|
||||
// }
|
||||
// return billParams, err
|
||||
//}
|
||||
//
|
||||
//func limitOrderPrice(price int64) int64 {
|
||||
// var maxOrderPrice int64 = 6399
|
||||
// if price > maxOrderPrice {
|
||||
// return maxOrderPrice
|
||||
// }
|
||||
// return price
|
||||
//}
|
||||
//
|
||||
//func limitOrderWeight(weight int) int {
|
||||
// maxOrderWeight := 5000 // 5公斤
|
||||
// if weight > maxOrderWeight {
|
||||
// return maxOrderWeight
|
||||
// }
|
||||
// return weight
|
||||
//}
|
||||
//
|
||||
//func getDadaShopID(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
// saleStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeCourierList, err2 := dao.GetOpenedStoreCouriersByStoreID(db, saleStoreID, model.VendorIDDada)
|
||||
// if err = err2; err != nil && !dao.IsNoRowsError(err) {
|
||||
// return "", err
|
||||
// }
|
||||
// if len(storeCourierList) == 0 {
|
||||
// return "", partner.ErrStoreHaveNoCourier
|
||||
// }
|
||||
// retVal = storeCourierList[0].VendorStoreID
|
||||
// if beego.BConfig.RunMode == "dev" {
|
||||
// retVal = "test_0001"
|
||||
// }
|
||||
// return retVal, nil
|
||||
//}
|
||||
//
|
||||
//func getDataCityCodeFromOrder(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
// jxStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// sql := `
|
||||
// SELECT t2.tel_code
|
||||
// FROM store t1
|
||||
// JOIN place t2 on t1.city_code = t2.code
|
||||
// WHERE t1.id = ?
|
||||
// `
|
||||
// codeInfo := &struct {
|
||||
// TelCode string
|
||||
// }{}
|
||||
// if err = dao.GetRow(db, codeInfo, sql, jxStoreID); err != nil {
|
||||
// if err == nil {
|
||||
// err = errors.New("不能找到美团配送站点配置")
|
||||
// }
|
||||
// return "", err
|
||||
// }
|
||||
// return codeInfo.TelCode, nil
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user