unionorder
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtunionapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func OnCallback(call *mtunionapi.CallBackResult) (err error) {
|
||||
if call.Status == mtunionapi.MtUnionOrderStatusFinished {
|
||||
if order, err := api.MtUnionAPI.Rtnotify(call.Orderid, call.Type); order != nil && err == nil {
|
||||
unionOrder := &partner.UnionOrderInfo{
|
||||
SID: order.Order.Sid,
|
||||
Profit: jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit)),
|
||||
VendorID: model.VendorIDMTWM,
|
||||
}
|
||||
cms.UnionOrderCallBack(unionOrder)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1,11 +1,25 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtunionapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
orderStatusMap = map[int]int{
|
||||
mtunionapi.MtUnionOrderStatusPay: model.UnionOrderStatusPay,
|
||||
mtunionapi.MtUnionOrderStatusFinished: model.UnionOrderStatusFinish,
|
||||
mtunionapi.MtUnionOrderStatusCanceled: model.UnionOrderStatusFail,
|
||||
}
|
||||
)
|
||||
|
||||
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string, resourceType int, goodsID string) (link string, err error) {
|
||||
@@ -60,3 +74,55 @@ func (s *UnionHandler) GetUnionMatterDetail(ctx *jxcontext.Context, goodsID stri
|
||||
func (s *UnionHandler) GetUnionMatterListRcmmd(ctx *jxcontext.Context, goodsID string, rcmmdType, offset, pageSize int) (result *partner.MatterList, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func OnCallback(call *mtunionapi.CallBackResult) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if order, err := api.MtUnionAPI.Rtnotify(call.Orderid, call.Type); order != nil && err == nil {
|
||||
unionOrders, err := dao.GetUnionOrdersByIDs(db, []string{order.Order.Orderid}, model.VendorIDPDD)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
orderStatus := &model.UnionOrderStatus{
|
||||
VendorOrderID: order.Order.Orderid,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Status: mtunionOrderStatus2Jx(order.Order.Status),
|
||||
VendorStatus: utils.Int2Str(order.Order.Status),
|
||||
OrderStatusAt: time.Unix(utils.Str2Int64(order.Order.Modtime), 0),
|
||||
}
|
||||
if len(order.Refund) > 0 {
|
||||
orderStatus.Comment = "售后完成"
|
||||
}
|
||||
//change
|
||||
jxutils.CallMsgHandler(func() {
|
||||
if len(unionOrders) > 0 {
|
||||
if unionOrders[0].Status != orderStatus.Status {
|
||||
cms.ChangeUnionOrder(unionOrders[0], orderStatus)
|
||||
}
|
||||
} else {
|
||||
//new
|
||||
unionOrder := &model.UnionOrder{
|
||||
VendorOrderID: order.Order.Orderid,
|
||||
VendorID: model.VendorIDMTWM,
|
||||
Status: mtunionOrderStatus2Jx(order.Order.Status),
|
||||
PID: order.Order.Sid,
|
||||
PayPrice: int(jxutils.StandardPrice2Int(utils.Str2Float64(order.Order.Direct))),
|
||||
PromotionAmount: int(jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit))),
|
||||
GoodsName: order.Order.Smstitle,
|
||||
GoodsID: order.Order.Dealid,
|
||||
OrderCreateAt: time.Unix(utils.Str2Int64(order.Order.Paytime), 0),
|
||||
OrderPayAt: time.Unix(utils.Str2Int64(order.Order.Paytime), 0),
|
||||
OrderReceiveAt: time.Unix(utils.Str2Int64(order.Order.Modtime), 0),
|
||||
OrderSettleAt: time.Unix(utils.Str2Int64(order.Coupon[0].Usetime), 0),
|
||||
}
|
||||
cms.NewUnionOrder(unionOrder, orderStatus)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(order.Order.Orderid, model.VendorIDMTWM))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func mtunionOrderStatus2Jx(status int) (jxstatus int) {
|
||||
return orderStatusMap[status]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user