+ 添加GoodsOrder.TotalShopMoney表示应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除)
This commit is contained in:
@@ -20,6 +20,7 @@ type GoodsOrder struct {
|
||||
VendorPrice int64 `json:"vendorPrice"` // 平台价
|
||||
SalePrice int64 `json:"salePrice"` // 售卖价
|
||||
ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付
|
||||
TotalShopMoney int64 `json:"shopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除)
|
||||
Weight int `json:"weight"` // 单位为克
|
||||
ConsigneeName string `orm:"size(32)" json:"consigneeName"`
|
||||
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
||||
|
||||
@@ -127,7 +127,7 @@ func (p *PurchaseHandler) partRefund2OrderDetailSkuList(orderID string, orderDet
|
||||
// Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / number, // 退单这里的total_weight有BUG,这里的total_weight还是没有退单时的值
|
||||
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
||||
}
|
||||
sku.SalePrice, sku.StoreSubName = getSkuSalePrice(product)
|
||||
sku.SalePrice, _, sku.StoreSubName = getSkuSalePrice(product)
|
||||
if sku.Weight == 0 {
|
||||
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
StatusTime: getTimeFromInterface(orderMap["create_time"]),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
ActualPayPrice: utils.MustInterface2Int64(orderMap["user_fee"]),
|
||||
Skus: []*model.OrderSku{},
|
||||
TotalShopMoney: utils.MustInterface2Int64(orderMap["shop_fee"]),
|
||||
}
|
||||
if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) {
|
||||
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 饿百要求在5分钟内拣货,不然订单会被取消
|
||||
@@ -213,7 +213,9 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
Weight: int(utils.Interface2Int64WithDefault(product["total_weight"], 0)) / productAmount,
|
||||
VendorPrice: utils.MustInterface2Int64(product["product_price"]),
|
||||
}
|
||||
sku.SalePrice, sku.StoreSubName = getSkuSalePrice(product)
|
||||
var baiduRate int64
|
||||
sku.SalePrice, baiduRate, sku.StoreSubName = getSkuSalePrice(product)
|
||||
order.TotalShopMoney += baiduRate
|
||||
if sku.Weight == 0 {
|
||||
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) // 订单信息里没有重量,只有名字里尝试找
|
||||
}
|
||||
@@ -226,15 +228,15 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
return order
|
||||
}
|
||||
|
||||
func getSkuSalePrice(product map[string]interface{}) (salePrice int64, vendorActType string) {
|
||||
func getSkuSalePrice(product map[string]interface{}) (salePrice, baiduRate int64, vendorActType string) {
|
||||
var product2 *ebaiapi.OrderProductInfo
|
||||
if err := utils.Map2StructByJson(product, &product2, true); err != nil {
|
||||
return utils.MustInterface2Int64(product["product_price"]), ""
|
||||
return utils.MustInterface2Int64(product["product_price"]), 0, ""
|
||||
}
|
||||
return getSkuSalePrice2(product2)
|
||||
}
|
||||
|
||||
func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int64, vendorActType string) {
|
||||
func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice, baiduRate int64, vendorActType string) {
|
||||
salePrice = int64(product.ProductPrice)
|
||||
if product.ProductSubsidy != nil {
|
||||
for _, v := range product.ProductSubsidy.DiscountDetail {
|
||||
@@ -246,9 +248,10 @@ func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice int64, vendo
|
||||
salePrice -= int64(math.Round(float64(v.BaiduRate+v.ShopRate) / float64(skuCount))) // 饿百同一SKU的优惠与非优惠没有拆开,平均摊销处理
|
||||
vendorActType = v.Type
|
||||
}
|
||||
baiduRate += int64(v.BaiduRate)
|
||||
}
|
||||
}
|
||||
return salePrice, vendorActType
|
||||
return salePrice, baiduRate, vendorActType
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -77,18 +79,46 @@ func (c *PurchaseHandler) onOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi
|
||||
|
||||
func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, orderMap map[string]interface{}, err error) {
|
||||
globals.SugarLogger.Debugf("jd getOrder orderID:%s", orderID)
|
||||
if orderMap, err = api.JdAPI.QuerySingleOrder(orderID); err == nil {
|
||||
globals.SugarLogger.Debugf("jd getOrder2 orderID:%s", orderID)
|
||||
order = c.Map2Order(orderMap)
|
||||
if jxutils.IsMobileFake(order.ConsigneeMobile) {
|
||||
if realMobile, err := api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误
|
||||
globals.SugarLogger.Debugf("jd getOrder3 orderID:%s", orderID)
|
||||
order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
|
||||
} else {
|
||||
// globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2)
|
||||
var (
|
||||
realMobile string
|
||||
orderSettlement *jdapi.OrderSettlementInfo
|
||||
)
|
||||
task := tasksch.NewParallelTask("jd getOrder", tasksch.NewParallelConfig().SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
taskIndex := batchItemList[0].(int)
|
||||
switch taskIndex {
|
||||
case 0:
|
||||
orderMap, err = api.JdAPI.QuerySingleOrder(orderID)
|
||||
case 1:
|
||||
realMobile, err = api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID)
|
||||
case 2:
|
||||
orderSettlement, err = api.JdAPI.OrderShoudSettlementService2(orderID)
|
||||
}
|
||||
return nil, err
|
||||
}, []int{0, 1, 2})
|
||||
task.Run()
|
||||
task.GetResult(0)
|
||||
if orderMap != nil {
|
||||
order = c.Map2Order(orderMap)
|
||||
if orderSettlement != nil {
|
||||
order.TotalShopMoney = orderSettlement.SettlementAmount + orderSettlement.PlatOrderGoodsDiscountMoney
|
||||
}
|
||||
if realMobile != "" {
|
||||
order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
|
||||
}
|
||||
}
|
||||
// if orderMap, err = api.JdAPI.QuerySingleOrder(orderID); err == nil {
|
||||
// globals.SugarLogger.Debugf("jd getOrder2 orderID:%s", orderID)
|
||||
// order = c.Map2Order(orderMap)
|
||||
// if jxutils.IsMobileFake(order.ConsigneeMobile) {
|
||||
// if realMobile, err := api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误
|
||||
// globals.SugarLogger.Debugf("jd getOrder3 orderID:%s", orderID)
|
||||
// order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
|
||||
// } else {
|
||||
// // globals.SugarLogger.Warnf("jd GetOrder orderID:%s, GetRealMobile4Order failed with error:%v", orderID, err2)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return order, orderMap, err
|
||||
}
|
||||
|
||||
@@ -125,7 +155,6 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
StatusTime: utils.Str2Time(result[statusTimeField].(string)),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
ActualPayPrice: utils.MustInterface2Int64(result["orderBuyerPayableMoney"]),
|
||||
Skus: []*model.OrderSku{},
|
||||
}
|
||||
order.Status = c.GetStatusFromVendorStatus(order.VendorStatus)
|
||||
businessTage := utils.Interface2String(result["businessTag"])
|
||||
|
||||
@@ -118,7 +118,6 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
StatusTime: getTimeFromTimestamp(utils.MustInterface2Int64(result["ctime"])),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
ActualPayPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(result["total"])),
|
||||
Skus: []*model.OrderSku{},
|
||||
}
|
||||
if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) {
|
||||
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
@@ -202,6 +201,17 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if poiReceiveDetailStr := utils.Interface2String(result["poi_receive_detail"]); poiReceiveDetailStr != "" {
|
||||
var poiReceiveDetail *mtwmapi.PoiReceiveDetailInfo
|
||||
utils.UnmarshalUseNumber([]byte(poiReceiveDetailStr), &poiReceiveDetail)
|
||||
if poiReceiveDetail != nil {
|
||||
order.TotalShopMoney = poiReceiveDetail.WmPoiReceiveCent
|
||||
for _, v := range poiReceiveDetail.ActOrderChargeByMt {
|
||||
order.TotalShopMoney += v.MoneyCent
|
||||
}
|
||||
}
|
||||
}
|
||||
// if product["isGift"].(bool) {
|
||||
// sku.SkuType = 1
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user