修改门店发单和品牌发单是扣费问题
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -540,3 +541,35 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取达达平台扣除配送费
|
||||
// 待接单,待取货(小于一分钟,大于十五分钟)不扣钱
|
||||
// 待取货1-15分钟内取消扣两元
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
dadaOrder, err := api.DadaAPI.QueryOrderInfo(orderId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 未接单不扣款
|
||||
if dadaOrder.AcceptTime == "" {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// 有了接单时间,订单变成了待取货
|
||||
if dadaOrder.AcceptTime != "" && dadaOrder.FetchTime == "" {
|
||||
nowTime := time.Now().Unix()
|
||||
fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
|
||||
timeDiffer := nowTime - fetchTime
|
||||
if timeDiffer > 15*60 || timeDiffer < 60 {
|
||||
return 0, nil
|
||||
}
|
||||
return 200, nil
|
||||
}
|
||||
|
||||
if dadaOrder.FetchTime != "" {
|
||||
return jxutils.StandardPrice2Int(dadaOrder.ActualFee), nil
|
||||
}
|
||||
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
ReceiverPrimaryPhone: order.ConsigneeMobile,
|
||||
OutShopCode: utils.Int2Str(order.JxStoreID),
|
||||
ChainStoreId: "",
|
||||
SerialNumber: fmt.Sprintf("%s #%d", model.VendorChineseNames[order.VendorID], order.OrderSeq),
|
||||
}
|
||||
// 重量超标减少配送费
|
||||
weight := 4.9500
|
||||
@@ -380,3 +381,36 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取运单取消违约金
|
||||
// 蜂鸟:骑手接单后-取餐之前,每单扣除2元,超过20分钟不扣款
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
// 获取订单状态
|
||||
order, err := api.FnAPI.QueryOrder(orderId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 已经分配骑手,且超过十五分钟,不扣款
|
||||
if len(order.EventLogDetails) != model.NO {
|
||||
for i := len(order.EventLogDetails) - 1; i >= 0; i-- {
|
||||
switch order.EventLogDetails[i].OrderStatus {
|
||||
case fnpsapi.OrderStatusDelivered, fnpsapi.OrderStatusArrived, fnpsapi.OrderStatusDelivering: // 送达,到店,配送中 取消订单全额扣款
|
||||
return order.OrderActualAmountCent, nil
|
||||
case fnpsapi.OrderStatusAcceptCacle, fnpsapi.OrderStatusException: // 取消和异常状态,跳过查看上一状态
|
||||
continue
|
||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 生成运单和系统接单取消不扣除费用
|
||||
return 0, nil
|
||||
case fnpsapi.OrderStatusAssigned:
|
||||
if time.Now().UnixNano()/1e6-order.EventLogDetails[i].OccurTime > fnpsapi.WayBillPressureOrderTime {
|
||||
return 0, nil
|
||||
} else {
|
||||
return 200, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -107,3 +107,6 @@ func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, reson
|
||||
func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -483,3 +483,6 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
|
||||
return result, nil
|
||||
}
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
}
|
||||
|
||||
if orderId == "" { // 订单id为空是,是定时轮询操作,不做此状态
|
||||
waybillList, _ := dao.GetWaybills(dao.GetDB(), v.VendorOrderID)
|
||||
waybillList, _ := dao.GetWaybills(dao.GetDB(), v.VendorOrderID, nil)
|
||||
if len(waybillList) > 0 && waybillList[0].Status > model.WaybillStatusEndBegin {
|
||||
globals.SugarLogger.Debugf("订单物流状态结束,不在推送订单状态:orderID[%s],wayBillId[%s]", v.VendorOrderID, waybillList[0].VendorWaybillID)
|
||||
continue
|
||||
|
||||
@@ -240,6 +240,10 @@ func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeison
|
||||
return param, nil
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
return api.UuAPI.GetOrderLiquidatedDamages(deliverId, orderId)
|
||||
}
|
||||
|
||||
//辅助函数
|
||||
func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceResp, err error) {
|
||||
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||
|
||||
@@ -40,8 +40,16 @@ type IDeliveryPlatformHandler interface {
|
||||
GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *WaybillFeeInfo, err error)
|
||||
//投诉骑手
|
||||
ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error)
|
||||
// 获取骑手信息
|
||||
// GetRiderInfo 获取骑手信息
|
||||
GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error)
|
||||
// 三方配送时,呼叫骑手在取消.可能存在违约赔付!获取每单的违约金额!
|
||||
// 蜂鸟:骑手接单后-取餐之前,每单扣除2元,超过20分钟不扣款
|
||||
// 达达:骑手接单后-到店之前,接单1-15分钟内,扣款2元,超过不扣款
|
||||
// uu :接单后超过一定时间取消会产生违约金,取消后扣除费用退回剩余订单金额
|
||||
// 美团配送: 暂无
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取配送单的违约金:京西订单id:orderId,配送方id:deliverId
|
||||
GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error)
|
||||
}
|
||||
|
||||
type IDeliveryUpdateStoreHandler interface {
|
||||
|
||||
@@ -13,10 +13,11 @@ const (
|
||||
StoreAcctTypeIncomeCancelReal = 19 //运单取消,回退的真实运费
|
||||
|
||||
//账户支出类型
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeExpendCreateWaybillDeductFee = 23 //运单取消的违约金
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,8 +39,8 @@ type IStoreAcctManager interface {
|
||||
//InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
//更新门店账户
|
||||
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
|
||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillID string, expendID int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendOrderID string, expendID int) (err error)
|
||||
CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
|
||||
GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/kuaishou_mini"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -39,22 +40,27 @@ func pay4OrderByKs(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
||||
}
|
||||
|
||||
param := &kuaishou_mini.PreCreateOrderReq{
|
||||
OutOrderNo: utils.Int64ToStr(GenPayOrderID(order)),
|
||||
OpenId: authBindList[0].AuthID,
|
||||
TotalAmount: order.ActualPayPrice,
|
||||
Subject: "蔬菜水果日用品",
|
||||
Detail: getOrderBriefKs(order),
|
||||
TypeDetail: 1832, // 蔬菜:费率2%,水果:1833%2
|
||||
ExpireTime: 60 * 10,
|
||||
Sign: "",
|
||||
Attach: "",
|
||||
NotifyUrl: "http://callback.jxc4.com/kuaishou/KuaiShouCallback",
|
||||
OutOrderNo: utils.Int64ToStr(GenPayOrderID(order)),
|
||||
OpenId: authBindList[0].AuthID,
|
||||
TotalAmount: order.ActualPayPrice,
|
||||
Subject: "蔬菜水果日用品",
|
||||
Detail: getOrderBriefKs(order),
|
||||
TypeDetail: 1832, // 蔬菜:费率2%,水果:1833%2
|
||||
ExpireTime: 60 * 10,
|
||||
Sign: "",
|
||||
Attach: "",
|
||||
//NotifyUrl: "https://callback.jxc4.com/kuaishou/kuaiShouCallback",
|
||||
GoodsId: "",
|
||||
GoodsDetailUrl: "",
|
||||
MultiCopiesGoodsInfo: "",
|
||||
CancelOrder: 0,
|
||||
}
|
||||
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
param.NotifyUrl = "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
} else {
|
||||
param.NotifyUrl = "https://callback.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
}
|
||||
// 预下单
|
||||
prePayInfo, err := api.KuaiShouApi.PreCreateOrder(param)
|
||||
if err == nil {
|
||||
|
||||
@@ -406,7 +406,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
dao.UpdateEntity(db, userMemberOrigin, "EndAt")
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay:
|
||||
case model.PayTypeTL_StoreAcctPay: // 门店账户充值
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
@@ -421,7 +421,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌账户充值
|
||||
brandOrder := &model.BrandOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
@@ -546,9 +546,11 @@ func GetAvailableDeliverTime(ctx *jxcontext.Context, storeID int) (deliverTimerL
|
||||
|
||||
func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
// 查询订单是购物订单还是充值订单
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderPay.VendorOrderID, orderPay.VendorID)
|
||||
if err == nil {
|
||||
db := dao.GetDB()
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
if count, err2 := dao.GetJxOrderCount(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorOrderID, order.OrderCreatedAt); err2 == nil {
|
||||
order.OrderSeq = count + 1
|
||||
@@ -584,44 +586,41 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
} else {
|
||||
switch orderPay.PayType {
|
||||
case model.PayTypeTL_DiscountCard:
|
||||
userMembers, _ := dao.GetUserMember(dao.GetDB(), "", orderPay.VendorOrderID, "", model.VendorIDJX, model.MemberTypeDiscountCard, model.NO)
|
||||
userMembers, _ := dao.GetUserMember(db, "", orderPay.VendorOrderID, "", model.VendorIDJX, model.MemberTypeDiscountCard, model.NO)
|
||||
if len(userMembers) > 0 {
|
||||
userMembers[0].IsPay = model.YES
|
||||
dao.UpdateEntity(dao.GetDB(), userMembers[0], "IsPay")
|
||||
dao.UpdateEntity(db, userMembers[0], "IsPay")
|
||||
err = nil
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay: //门店账户充值完成后直接入账
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
if err = dao.GetEntity(db, storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
storeOrder.OrderFinishedAt = time.Now()
|
||||
storeOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), storeOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
// 获取门店的品牌ID
|
||||
storeBrandId, err := GetStoreAcctOrderByVendorId(orderPay.VendorOrderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeBrandId, storeOrder.ActualPayPrice, model.BrandBillFeeTypeSys, model.BrandBillFeeTypeSys, "", "")
|
||||
_, err = dao.UpdateEntity(db, storeOrder, "OrderFinishedAt", "Status")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), storeOrder.ActualPayPrice, partner.StoreAcctTypeIncomePay, order.VendorOrderID, order.VendorWaybillID, 0)
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌充值入账
|
||||
brandOrder := &model.BrandOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
if err = dao.GetEntity(db, brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
brandOrder.OrderFinishedAt = time.Now()
|
||||
brandOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
if _, err = dao.UpdateEntity(db, brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandOrder.BrandID, brandOrder.ActualPayPrice, model.BrandBillTypeIncome, model.BrandBillFeeTypeCharge, orderPay.VendorOrderID, "")
|
||||
}
|
||||
}
|
||||
default:
|
||||
priceDefendOrders, _ := dao.GetPriceDefendOrder(dao.GetDB(), orderPay.VendorOrderID, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, -1, 0, "", utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
priceDefendOrders, _ := dao.GetPriceDefendOrder(db, orderPay.VendorOrderID, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, -1, 0, "", utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
if len(priceDefendOrders) > 0 {
|
||||
priceDefendOrders[0].IsPay = model.YES
|
||||
dao.UpdateEntity(dao.GetDB(), priceDefendOrders[0], "IsPay")
|
||||
dao.UpdateEntity(db, priceDefendOrders[0], "IsPay")
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
@@ -1823,7 +1822,7 @@ func RefreshAllMatterOrderStatus(ctx *jxcontext.Context) (err error) {
|
||||
}()
|
||||
vv.Status = model.OrderStatusFinished
|
||||
dao.UpdateEntity(db, vv, "Status")
|
||||
waybills, err := dao.GetWaybills(db, vv.VendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, vv.VendorOrderID, nil)
|
||||
if err == nil && len(waybills) > 0 {
|
||||
waybills[0].Status = model.WaybillStatusDelivered
|
||||
dao.UpdateEntity(db, waybills[0], "Status")
|
||||
@@ -1939,7 +1938,7 @@ func updateMatterOrderStatus(db *dao.DaoDB, order *model.GoodsOrder, queryOrderS
|
||||
}()
|
||||
order.Status = model.OrderStatusFinished
|
||||
dao.UpdateEntity(db, order, "Status")
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if err == nil && len(waybills) > 0 {
|
||||
waybills[0].Status = model.WaybillStatusDelivered
|
||||
dao.UpdateEntity(db, waybills[0], "Status")
|
||||
@@ -1977,7 +1976,7 @@ func updateJdWayBillInfo(db *dao.DaoDB, order *model.GoodsOrder, getTrackMessage
|
||||
break
|
||||
}
|
||||
}
|
||||
waybills, err = dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, err = dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if len(waybills) > 0 {
|
||||
waybills[0].VendorWaybillID = waybillCode
|
||||
waybills[0].CourierName = cName
|
||||
|
||||
Reference in New Issue
Block a user