sfps
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"
|
||||
@@ -281,7 +282,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
if result, err = api.DadaAPI.QueryDeliverFee(billParams); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(result.Fee)
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(result.DeliverFee) // jxutils.StandardPrice2Int(result.Fee)
|
||||
deliveryFeeInfo.RefDeliveryFee = deliveryFeeInfo.DeliveryFee
|
||||
}
|
||||
return deliveryFeeInfo, err
|
||||
@@ -357,6 +358,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
}
|
||||
// 重新发送订单
|
||||
result, err = api.DadaAPI.ReaddOrder(billParams)
|
||||
globals.SugarLogger.Debugf("重新发送订单多次发单======== := %s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -366,6 +368,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
if result, err = api.DadaAPI.QueryDeliverFee(billParams); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("查询达达订单费用(第一次发单)======== := %s", utils.Format4Output(result, false))
|
||||
// 阀值警报
|
||||
if err = delivery.CallCreateWaybillPolicy(jxutils.StandardPrice2Int(result.Fee), maxDeliveryFee, order, model.VendorIDDada); err != nil {
|
||||
return nil, err
|
||||
@@ -374,6 +377,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
if err = api.DadaAPI.AddOrderAfterQuery(result.DeliveryNo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("重新发送订单======== := %s", utils.Format4Output(result, false))
|
||||
}
|
||||
if result == nil {
|
||||
return nil, errors.New("达达配送,平台调用错误,无订单数据返回")
|
||||
@@ -383,8 +387,8 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: order.VendorID,
|
||||
WaybillVendorID: model.VendorIDDada,
|
||||
DesiredFee: jxutils.StandardPrice2Int(result.Fee),
|
||||
ActualFee: jxutils.StandardPrice2Int(result.Fee),
|
||||
DesiredFee: jxutils.StandardPrice2Int(result.DeliverFee),
|
||||
ActualFee: jxutils.StandardPrice2Int(result.DeliverFee),
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
return bill, err
|
||||
@@ -540,3 +544,41 @@ 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
|
||||
}
|
||||
|
||||
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
|
||||
// 达达存在多个订单的运单违约金额统计在一起的情况
|
||||
if dadaOrder.FetchTime != "" {
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDDada)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bill.DesiredFee, nil
|
||||
}
|
||||
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -69,10 +69,14 @@ func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int,
|
||||
}
|
||||
parameter.PartnerOrderCode = bill.VendorOrderID
|
||||
if err = api.FnAPI.CancelOrder(parameter); err != nil {
|
||||
globals.SugarLogger.Debugf("============err := %v ", err)
|
||||
if strings.Contains(err.Error(), "运单暂未生成") {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bill.Status = model.WaybillStatusCanceled
|
||||
bill.Remark = cancelReason
|
||||
@@ -114,6 +118,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
|
||||
@@ -145,13 +150,15 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
}
|
||||
|
||||
// 查询订单获取配送费
|
||||
desireFee, actualFee := GetDesiredFee(order.VendorOrderID)
|
||||
bill = &model.Waybill{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: order.VendorID,
|
||||
VendorWaybillID: fnOrderId,
|
||||
VendorWaybillID2: order.VendorOrderID,
|
||||
WaybillVendorID: model.VendorIDFengNiao,
|
||||
DesiredFee: GetDesiredFee(order.VendorOrderID),
|
||||
DesiredFee: desireFee,
|
||||
ActualFee: actualFee,
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
return bill, err
|
||||
@@ -192,17 +199,28 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
preCreateOrder.GoodsItemList = goodsList
|
||||
|
||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||
deliveryFeeInfo.RefDeliveryFee, deliveryFeeInfo.RefAddFee, err = api.FnAPI.PreCreateByShopFn(preCreateOrder)
|
||||
deliveryFeeInfo.RefDeliveryFee, deliveryFeeInfo.RefAddFee, err = api.FnAPI.PreCreateByShopFn(preCreateOrder) //
|
||||
deliveryFeeInfo.DeliveryFee = deliveryFeeInfo.RefDeliveryFee
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
|
||||
// 订单状态
|
||||
func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackResponse) {
|
||||
func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortStatus) (resp *fnpsapi.CallbackResponse) {
|
||||
cc := &fnpsapi.OrderCallbackParam{}
|
||||
if err := utils.Map2StructByJson(msg.Param, cc, true); err != nil {
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
var good *model.GoodsOrder
|
||||
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
||||
sqlParams := []interface{}{cc.PartnerOrderCode}
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
if good == nil || good.VendorOrderID == "" {
|
||||
_, err := fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(resultParam), "order")
|
||||
if err != nil {
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
return fnpsapi.Err2CallbackResponse(nil, "")
|
||||
}
|
||||
|
||||
order := &model.Waybill{
|
||||
VendorWaybillID: utils.Int64ToStr(cc.OrderId),
|
||||
@@ -218,24 +236,19 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackRespon
|
||||
order.StatusTime = time.Now()
|
||||
}
|
||||
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode)
|
||||
|
||||
var good *model.GoodsOrder
|
||||
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
||||
sqlParams := []interface{}{cc.PartnerOrderCode}
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
order.OrderVendorID = good.VendorID
|
||||
|
||||
orderStatus := utils.Str2Int64(order.VendorStatus)
|
||||
switch orderStatus {
|
||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusNew //5 带调度
|
||||
case fnpsapi.OrderStatusAssigned: //20分配骑手
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusCourierAssigned //12
|
||||
order.Remark = order.CourierName + "," + order.CourierMobile
|
||||
case fnpsapi.OrderStatusArrived: // 80 到店
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusCourierArrived
|
||||
case fnpsapi.OrderStatusDelivering: // 2 配送中
|
||||
order.Status = model.WaybillStatusDelivering
|
||||
@@ -319,11 +332,11 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (re
|
||||
}
|
||||
|
||||
// 查询订单配送费
|
||||
func GetDesiredFee(vendorOrderID string) (desiredFee int64) {
|
||||
func GetDesiredFee(vendorOrderID string) (desiredFee, acuteFee int64) {
|
||||
if result, err := api.FnAPI.QueryOrder(vendorOrderID); err == nil {
|
||||
return result.OrderActualAmountCent
|
||||
return result.OrderTotalAmountCent + int64(utils.WayBillDeliveryMarkUp), result.OrderActualAmountCent
|
||||
}
|
||||
return desiredFee
|
||||
return desiredFee, acuteFee
|
||||
}
|
||||
|
||||
// 获取骑手信息
|
||||
@@ -380,3 +393,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.OrderTotalAmountCent, 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
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -92,6 +93,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
|
||||
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
|
||||
}
|
||||
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
|
||||
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
|
||||
order.Status = model.WaybillStatusNew
|
||||
case mtpsapi.OrderStatusAccepted: // 已接单
|
||||
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
|
||||
@@ -99,6 +101,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
|
||||
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
|
||||
}
|
||||
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
|
||||
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
|
||||
order.Status = model.WaybillStatusCourierAssigned
|
||||
order.Remark = order.CourierName + "," + order.CourierMobile
|
||||
case mtpsapi.OrderStatusPickedUp: // 已取货
|
||||
@@ -483,3 +486,36 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
statusList, err := orderman.FixedOrderManager.GetWayBillStatusList(orderId, deliverId, model.VendorIDMTPS)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 已经分配骑手,且超过十五分钟,不扣款
|
||||
if len(statusList) != model.NO {
|
||||
for i := len(statusList) - 1; i >= 0; i-- {
|
||||
switch statusList[i].VendorStatus {
|
||||
case utils.Int2Str(mtpsapi.OrderStatusWaitingForSchedule): // 待调度
|
||||
return 0, nil
|
||||
case utils.Int2Str(mtpsapi.OrderStatusCanceled): // 取消不管
|
||||
continue
|
||||
case utils.Int2Str(mtpsapi.OrderStatusDeliverred): // 送达
|
||||
continue
|
||||
case utils.Int2Str(mtpsapi.OrderStatusAccepted): // 接单
|
||||
// 接单取消扣凉快
|
||||
return 200, nil
|
||||
case utils.Int2Str(mtpsapi.OrderStatusPickedUp): // 取货
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDMTPS)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bill.DesiredFee, nil
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package delivery
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
@@ -100,7 +101,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
|
||||
@@ -207,6 +208,8 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
continue
|
||||
case model.VendorIDDD: // 抖店小时达
|
||||
continue
|
||||
case model.VendorIDJX: // 京西平台
|
||||
continue
|
||||
default:
|
||||
globals.SugarLogger.Errorf("Order source error, non system order: %s", v.VendorOrderID)
|
||||
continue
|
||||
@@ -277,6 +280,14 @@ func UpdateOrder2Complete() {
|
||||
}
|
||||
|
||||
func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
order, _ := partner.CurOrderManager.LoadOrder(fakeWayBill.VendorOrderID, fakeWayBill.OrderVendorID)
|
||||
storeId := 0
|
||||
if order.StoreID != 0 {
|
||||
storeId = order.StoreID
|
||||
} else {
|
||||
storeId = order.JxStoreID
|
||||
}
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeId, order.VendorID, order.VendorOrgCode)
|
||||
switch fakeWayBill.Status {
|
||||
case 5: // 呼叫骑手
|
||||
riderInfo.LogisticsContext = "呼叫骑手,新建运单"
|
||||
@@ -290,8 +301,10 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusCourierAssigned)
|
||||
case 12: // 骑手接单
|
||||
riderInfo.LogisticsContext = model.RiderWaitGetGoods
|
||||
riderInfo.LogisticsStatus = 12
|
||||
riderInfo.LogisticsStatus = 10
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsORDERRECEIVED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusCourierArrived
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusCourierArrived)
|
||||
@@ -299,6 +312,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderToStore
|
||||
riderInfo.LogisticsStatus = 15
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsRIDERARRIVED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusDelivering
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusDelivering)
|
||||
@@ -306,6 +321,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderGetOrderDelivering
|
||||
riderInfo.LogisticsStatus = 20
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsRIDERPICKUP
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusDelivered
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusDelivered)
|
||||
@@ -313,6 +330,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderGetOrderDelivered
|
||||
riderInfo.LogisticsStatus = 40
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsDELIVERED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusFailed
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusFailed)
|
||||
@@ -322,7 +341,7 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateFakeWayBillToTiktok 轮询更新假订单到抖音
|
||||
// UpdateFakeWayBillToTiktok 轮询更新假订单到抖音(抖音/美团/饿百)
|
||||
func UpdateFakeWayBillToTiktok() {
|
||||
scheduleTimer, _ := rand.Int(rand.Reader, big.NewInt(1000))
|
||||
randTimeSchedule := scheduleTimer.Int64()
|
||||
@@ -354,6 +373,7 @@ func UpdateFakeWayBillToTiktok() {
|
||||
LogisticsStatus: fakeWayBill[i].Status,
|
||||
}
|
||||
|
||||
// 设置骑手和下一状态时间
|
||||
makeRiderInfo(fakeWayBill[i], riderInfo)
|
||||
|
||||
if riderInfo.LogisticsContext != model.RiderGetOrderDeliverFailed && riderInfo.LogisticsContext != model.RiderGetOrderDeliverOther && riderInfo.LogisticsContext != model.RiderWaitRider {
|
||||
@@ -398,7 +418,7 @@ func UpdateFakeWayBillToTiktok() {
|
||||
globals.SugarLogger.Debugf("UPDATA goods_order Err :%s", err.Error())
|
||||
}
|
||||
// 饿百订单推送订单送达
|
||||
if fakeWayBill[i].OrderVendorID == model.VendorIDEBAI {
|
||||
if fakeWayBill[i].OrderVendorID == model.VendorIDEBAI || fakeWayBill[i].OrderVendorID == model.VendorIDMTWM {
|
||||
if err := handler.Swtich2SelfDelivered(order, "JingXiAdmin"); err != nil {
|
||||
globals.SugarLogger.Errorf("Swtich2SelfDelivered err := %v", err)
|
||||
}
|
||||
|
||||
@@ -198,8 +198,22 @@ func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonC
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取取消运单违约金
|
||||
func (d DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
waybill, err := dao.GetWaybills(dao.GetDB(), orderId, []int64{model.VendorIDSFPS})
|
||||
if len(waybill) == 0 || err != nil {
|
||||
return 0, err
|
||||
}
|
||||
deductionFee, err := api.SfPsAPI.PreCancelOrder(waybill[0].VendorWaybillID)
|
||||
if deductionFee == 0 || err != nil {
|
||||
return 0, err
|
||||
}
|
||||
money = jxutils.StandardPrice2Int(deductionFee)
|
||||
return money, nil
|
||||
}
|
||||
|
||||
func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||
order, err := dao.GetWaybills(dao.GetDB(), orderId)
|
||||
order, err := dao.GetWaybills(dao.GetDB(), orderId, []int64{model.VendorIDSFPS})
|
||||
if len(order) == 0 || err != nil {
|
||||
return nil, errors.New("顺丰 订单id无效,请检查")
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
||||
VendorWaybillID: orderCode,
|
||||
VendorWaybillID2: originID,
|
||||
WaybillVendorID: model.VendorIDUUPT,
|
||||
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.NeedPayMoney)),
|
||||
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.TotalMoney)),
|
||||
}
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
@@ -192,7 +192,8 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
|
||||
return nil, err
|
||||
} else {
|
||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney))
|
||||
// deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney)) 优惠后金额
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.TotalMoney)) // 原始金额
|
||||
}
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
@@ -240,6 +241,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, "")
|
||||
@@ -304,28 +309,39 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
param.OrderVendorID = good.VendorID
|
||||
//查询运单价格
|
||||
if uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode); err != nil {
|
||||
uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode)
|
||||
if err != nil {
|
||||
reallyPrice = 0
|
||||
} else {
|
||||
reallyPrice = int64((utils.Str2Float64(uuPrice.OrderPrice) - utils.Str2Float64(uuPrice.PriceOff)) * 100)
|
||||
reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100)
|
||||
}
|
||||
actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp)
|
||||
switch req.State {
|
||||
case uuptapi.StateConfirmSuccess:
|
||||
param.Status = model.WaybillStatusNew //5 待调度
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateRMGrabsOrder:
|
||||
param.Status = model.WaybillStatusCourierAssigned
|
||||
param.Remark = req.DriverName + "," + req.DriverMobile
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateArrivedStore:
|
||||
param.Status = model.WaybillStatusCourierArrived
|
||||
param.DesiredFee = reallyPrice
|
||||
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination:
|
||||
param.Status = model.WaybillStatusDelivering
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StatePickUp:
|
||||
param.Status = model.WaybillStatusUuPickUp
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateArrivedDestination:
|
||||
param.Status = model.WaybillStatusUuArrivedDestination
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateReceiverGetGoods:
|
||||
param.Status = model.WaybillStatusDelivered
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateOrderCancel:
|
||||
param.Status = model.WaybillStatusCanceled
|
||||
default:
|
||||
@@ -355,9 +371,12 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
||||
case uuptapi.StateArrivedStore: //骑手到店
|
||||
result.LogisticsStatus = model.WaybillStatusCourierArrived
|
||||
result.LogisticsContext = model.RiderToStore
|
||||
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination: //已取件
|
||||
result.LogisticsStatus = model.WaybillStatusDelivering
|
||||
case uuptapi.StatePickUp: //已取件
|
||||
result.LogisticsStatus = model.WaybillStatusUuPickUp
|
||||
result.LogisticsContext = model.RiderPickUp
|
||||
case uuptapi.StateArrivedDestination: //到达取件人地址处
|
||||
result.LogisticsStatus = model.WaybillStatusUuArrivedDestination
|
||||
result.LogisticsContext = model.RiderArrivedDestination
|
||||
case uuptapi.StateReceiverGetGoods: //取件人收货
|
||||
result.LogisticsStatus = model.WaybillStatusDelivered
|
||||
result.LogisticsContext = model.RiderGetOrderDelivered
|
||||
|
||||
@@ -18,10 +18,10 @@ const (
|
||||
type WaybillFeeInfo struct {
|
||||
ErrCode int `json:"errCode"`
|
||||
ErrStr string `json:"errStr"`
|
||||
RefDeliveryFee int64 `json:"refDeliveryFee"` // 无用,待删除
|
||||
RefAddFee int64 `json:"refAddFee"` // 无用,待删除
|
||||
DeliveryFee int64 `json:"deliveryFee"`
|
||||
TimeoutSecond int `json:"timeoutSecond"` // 系统会自动发运单的倒计时
|
||||
RefDeliveryFee int64 `json:"refDeliveryFee"` // 优惠后
|
||||
RefAddFee int64 `json:"refAddFee"` // 原始配送费
|
||||
DeliveryFee int64 `json:"deliveryFee"` // 优惠后
|
||||
TimeoutSecond int `json:"timeoutSecond"` // 系统会自动发运单的倒计时
|
||||
Waybill *model.Waybill `json:"waybill"`
|
||||
}
|
||||
|
||||
@@ -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,13 @@ const (
|
||||
StoreAcctTypeIncomeCancelReal = 19 //运单取消,回退的真实运费
|
||||
|
||||
//账户支出类型
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeExpendCreateWaybillDeductFee = 23 //运单取消的违约金
|
||||
StoreAcctTypeExpendTextMessageNotify = 24 //短信通知扣费
|
||||
StoreAcctTypeExpendVoiceMessageNotify = 26 //电话通知扣费
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,8 +41,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)
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
@@ -114,7 +112,7 @@ func WriteMessage() {
|
||||
clientInfo := <-ToClientChan
|
||||
//广播发送通知所有京西客户端
|
||||
i++
|
||||
fmt.Printf("WriteMessage clientInfo=%s i=%d\n", utils.Format4Output(clientInfo, false), i)
|
||||
//fmt.Printf("WriteMessage clientInfo=%s i=%d\n", utils.Format4Output(clientInfo, false), i)
|
||||
if Manager.AllClient() != nil {
|
||||
for _, conn := range Manager.AllClient() {
|
||||
if conn.ClientType == ClientTypeJx { //只发送给京西
|
||||
|
||||
@@ -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,24 +40,29 @@ 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",
|
||||
GoodsId: "",
|
||||
GoodsDetailUrl: "",
|
||||
MultiCopiesGoodsInfo: "",
|
||||
CancelOrder: 0,
|
||||
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: "",
|
||||
//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)
|
||||
globals.SugarLogger.Debugf("=======err : %v", err)
|
||||
if err == nil {
|
||||
orderPay = &model.OrderPay{
|
||||
PayOrderID: order.VendorOrderID, // 抖音订单id
|
||||
|
||||
@@ -324,7 +324,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
//if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID {
|
||||
// subAppID = model.JXC4AppId // 京西商城
|
||||
//}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -351,7 +351,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
ActualPayPrice: priceDefendOrders[0].ActualPayPrice,
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
return orderPay, err
|
||||
}
|
||||
|
||||
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
|
||||
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
order *model.GoodsOrder
|
||||
@@ -383,7 +383,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(discountCard.Price),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -416,13 +416,13 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(storeOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌账户充值
|
||||
brandOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
@@ -431,7 +431,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(brandOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -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,42 @@ 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, storeOrder.StoreID, storeOrder.ActualPayPrice, partner.StoreAcctTypeIncomePay, storeOrder.VendorOrderID, "", 0)
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌充值入账
|
||||
brandOrder := &model.StoreAcctOrder{
|
||||
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 {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandOrder.BrandID, brandOrder.ActualPayPrice, model.BrandBillTypeIncome, model.BrandBillFeeTypeCharge, orderPay.VendorOrderID, "")
|
||||
if _, err = dao.UpdateEntity(db, brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
store, _ := dao.GetStoreDetail(db, brandOrder.StoreID, 0, "")
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.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 +1823,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 +1939,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 +1977,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
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
|
||||
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
|
||||
// if order.FromStoreID != 0 {
|
||||
// result, _ := orderman.GetMatterStoreOrderCount(nil, order.FromStoreID)
|
||||
// if !result.Flag {
|
||||
@@ -45,6 +45,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
if code != "" {
|
||||
appAuth := strings.Split(code, "_")
|
||||
sessionInfo, err := weixin.GetAPI(appAuth[0]).SNSCode2Session(appAuth[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
param.Acct = sessionInfo.OpenID
|
||||
}
|
||||
}
|
||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
@@ -64,6 +72,8 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||
} else {
|
||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||
globals.SugarLogger.Debugf("===============result: %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("===============result: %s", utils.Format4Output(err, false))
|
||||
if err == nil {
|
||||
var result2 tonglianpayapi.PayInfo
|
||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||
|
||||
Reference in New Issue
Block a user