diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index dcd9ae516..3c830e043 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -209,6 +209,15 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } } + + // 目前存在当订单为平台自配送时,本地储存新订单的结算信息是包含了配送费的!所以结算信息不对! + // 修改为订单完成时更新订单的结算信息 + settlementAmount, err3 := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).GetOrderSettleAccounts(order) + if err3 == nil && settlementAmount != model.NO { + order.TotalShopMoney = settlementAmount + dao.UpdateEntity(db, order, "TotalShopMoney") + } + //更新订单new_earning_price if order.EarningType == model.EarningTypePoints { waybill, _ := c.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID) @@ -2508,7 +2517,20 @@ func UpdateTiktokShopTotalMoney() { } nextStartIndex = next v.TotalShopMoney = totalShopMoney - if _, err := dao.UpdateEntity(db, v, "TotalShopMoney"); err != nil { + if v.EarningType == model.EarningTypePoints { + waybill, _ := partner.CurOrderManager.LoadWaybill(v.VendorWaybillID, v.WaybillVendorID) + // store, _ := c.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID) + if waybill == nil { + if (v.NewEarningPrice == 0 || v.NewEarningPrice != v.TotalShopMoney*int64(100-v.OrderPayPercentage/2)/int64(100)) && v.OrderPayPercentage <= 50 { + v.NewEarningPrice = v.TotalShopMoney * int64(100-v.OrderPayPercentage/2) / int64(100) + } + } else { + if (v.NewEarningPrice == 0 || v.NewEarningPrice != (v.TotalShopMoney-waybill.DesiredFee)*int64(100-v.OrderPayPercentage/2)/int64(100)) && v.OrderPayPercentage <= 50 { + v.NewEarningPrice = v.TotalShopMoney*int64(100-v.OrderPayPercentage/2)/int64(100) - waybill.DesiredFee + } + } + } + if _, err := dao.UpdateEntity(db, v, "TotalShopMoney", "NewEarningPrice"); err != nil { globals.SugarLogger.Errorf("更新本地订单结算信息错误 : %s", err) continue } diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index dbf11572f..8eaf6bc3e 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -89,6 +89,9 @@ type IPurchasePlatformOrderHandler interface { ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error) //推送订单骑手信息 GetOrderRider(vendorOrgCode, vendorStoreID string, param map[string]interface{}) (err error) + + // 获取各个平台订单的结算信息 + GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) } type IAddWaybillTip interface { diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 5eea2f695..b488a10f4 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -786,3 +786,14 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + orderInfo, err := api.EbaiAPI.OrderGet(order.VendorOrderID) + if err != nil { + return 0, err + } + orderMap := orderInfo["order"].(map[string]interface{}) + + return utils.ForceInterface2Int64(orderMap["shop_fee"]), nil +} diff --git a/business/partner/purchase/elm/order.go b/business/partner/purchase/elm/order.go index becd7c62e..598e3872f 100644 --- a/business/partner/purchase/elm/order.go +++ b/business/partner/purchase/elm/order.go @@ -344,3 +344,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index b53a21d67..bfac7e806 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -660,3 +660,12 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(goods *model.GoodsOrder) (int64, error) { + settlement, err := getAPI(goods.VendorOrgCode).OrderShoudSettlementService2(goods.VendorOrderID) + if err != nil { + return 0, err + } + return settlement.SettlementAmount, nil +} diff --git a/business/partner/purchase/jdshop/order.go b/business/partner/purchase/jdshop/order.go index e424e12ca..cd16bac49 100644 --- a/business/partner/purchase/jdshop/order.go +++ b/business/partner/purchase/jdshop/order.go @@ -328,3 +328,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/jx/order.go b/business/partner/purchase/jx/order.go index 71af88f8e..ec82bfbcd 100644 --- a/business/partner/purchase/jx/order.go +++ b/business/partner/purchase/jx/order.go @@ -155,3 +155,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 9418ab187..21e5bcbd7 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -849,3 +849,20 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + oderDetail, err := getAPI(order.VendorOrgCode, 0, order.VendorStoreID).OrderGetOrderDetail(utils.Str2Int64(order.VendorOrderID), true) + if err != nil { + return 0, err + } + + if poiReceiveDetailStr := utils.Interface2String(oderDetail["poi_receive_detail"]); poiReceiveDetailStr != "" { + var poiReceiveDetail *mtwmapi.PoiReceiveDetailInfo + utils.UnmarshalUseNumber([]byte(poiReceiveDetailStr), &poiReceiveDetail) + if poiReceiveDetail != nil { + return poiReceiveDetail.WmPoiReceiveCent, nil + } + } + return 0, nil +} diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 1b95a38fc..96bf98039 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -2,9 +2,6 @@ package mtwm import ( "encoding/json" - "regexp" - "strings" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" @@ -15,6 +12,8 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" + "regexp" + "strings" ) const ( @@ -163,29 +162,29 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in storeCat.CatSyncStatus |= model.SyncFlagNewMask err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat) } - if err != nil && strings.Contains(err.Error(), "门店内存在重复的分类:") { - globals.SugarLogger.Debugf("==========err %s", err.Error()) - storeCategoryList, err2 := api.RetailCatList(vendorStoreID) - globals.SugarLogger.Debugf("==========err2 %v", err2) - globals.SugarLogger.Debugf("==========err %s", utils.Format4Output(storeCategoryList, false)) - if err2 != nil { - err = err2 - } else { - for _, v := range storeCategoryList { - globals.SugarLogger.Debugf("storeCategoryList==========err %s", err.Error()) - if len(v.Children) > 0 { - for _, c := range v.Children { - if strings.Contains(c.Name, err.Error()) { - api.RetailCatDelete(vendorStoreID, "", c.Name) - } - } - } - if strings.Contains(v.Name, err.Error()) { - api.RetailCatDelete(vendorStoreID, "", v.Name) - } - } - } - } + //if err != nil && strings.Contains(err.Error(), "门店内存在重复的分类:") { + // globals.SugarLogger.Debugf("==========err %s", err.Error()) + // storeCategoryList, err2 := api.RetailCatList(vendorStoreID) + // globals.SugarLogger.Debugf("==========err2 %v", err2) + // globals.SugarLogger.Debugf("==========err %s", utils.Format4Output(storeCategoryList, false)) + // if err2 != nil { + // err = err2 + // } else { + // for _, v := range storeCategoryList { + // globals.SugarLogger.Debugf("storeCategoryList==========err %s", err.Error()) + // if len(v.Children) > 0 { + // for _, c := range v.Children { + // if strings.Contains(c.Name, err.Error()) { + // api.RetailCatDelete(vendorStoreID, "", c.Name) + // } + // } + // } + // if strings.Contains(v.Name, err.Error()) { + // api.RetailCatDelete(vendorStoreID, "", v.Name) + // } + // } + // } + //} } if err == nil { // storeCat.VendorCatID = utils.FilterEmoji(storeCat.Name) diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index 66ec28f1e..c2fee67e7 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -1029,3 +1029,8 @@ func GetOrderTotalShopMoney(appOrgCode string, orderIds string, nextStartIndex s func GetOrderDetail(appOrgCode, vendorOrderID string) (*order_orderDetail_response.ShopOrderDetail, error) { return getAPI(appOrgCode, 0, "").GetTiktokOrderDetail(vendorOrderID) } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/weimob/wsc/order.go b/business/partner/purchase/weimob/wsc/order.go index ff960af92..787c3a925 100644 --- a/business/partner/purchase/weimob/wsc/order.go +++ b/business/partner/purchase/weimob/wsc/order.go @@ -313,3 +313,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/yb/order.go b/business/partner/purchase/yb/order.go index e973e72fa..594f0f808 100644 --- a/business/partner/purchase/yb/order.go +++ b/business/partner/purchase/yb/order.go @@ -106,3 +106,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +}