1
This commit is contained in:
@@ -32,7 +32,7 @@ type UserVendorOrder struct {
|
||||
Bulk float64 `orm:"column(bulk)" json:"bulk"` // 体积抛比系数
|
||||
Increment float64 `orm:"column(increment)" json:"increment"` // 增值(物流)
|
||||
ChannelType int `orm:"size(8);column(channel_type)" json:"channelType"` // 渠道类型(1-快递,2-物流,3-国际物流,4-整车)
|
||||
OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(2-待支付,3-支付失败,4-支付成功,10预下单11待取件12运输中15已签收16取消订单17终止揽收)
|
||||
OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(2-待支付,3-支付失败,4-支付成功,10预下单11待取件12运输中15已签收16取消订单17终止揽收,150取消)
|
||||
Img string `orm:"column(img)" json:"img"` // 包裹图片
|
||||
IsForward int `orm:"column(is_forward)" json:"isForward"` // 1否,2是 转寄单
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd
|
||||
// 支付方式为余额支付,则需要修改order/userVendorOrder,修改订单状态,给用户账户价钱,生成一个价钱数据
|
||||
} else if orderWay.PayMethod == 2 { // 微信支付
|
||||
// 微信支付原路退款,发起退款申请
|
||||
_, err := RefundOrderByTL(ctx, orderWay, order.OtherWayBill, int(order.ChannelFee*100), "申请退款")
|
||||
_, err := RefundOrderByTL(ctx, orderWay, order, order.OtherWayBill, int(order.ChannelFee*100), "申请退款")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -378,14 +378,14 @@ func CreateOrder2QBiDa(order *model.UserVendorOrder) error {
|
||||
order.OtherWayBill = otherId
|
||||
order.OrderStatus = model.OrderStatusWaitPickup
|
||||
order.UpdatedAt = time.Now()
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), order); err != nil {
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), &order, "OtherWayBill", "OrderStatus", "UpdatedAt"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RefundOrderByTL 发起取消订单
|
||||
func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.Order, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||
func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.Order, order *model.UserVendorOrder, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
|
||||
result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
|
||||
Trxamt: refundFee,
|
||||
Reqsn: utils.GetUUID(),
|
||||
@@ -410,10 +410,25 @@ func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.Order, refundID str
|
||||
orderPayRefund.Status = model.RefundStatusFailed
|
||||
}
|
||||
orderPayRefund.OriginalData = utils.Format4Output(result, true)
|
||||
dao.CreateEntity(db, orderPayRefund)
|
||||
|
||||
//orderPay.Status = model.OrderStatusCancel
|
||||
//dao.UpdateEntity(db, orderPay)
|
||||
tx, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
|
||||
if err := dao.CreateEntityTx(tx, orderPayRefund); err != nil {
|
||||
dao.Rollback(db, tx)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
order.OrderStatus = model.OrderStatusCancel
|
||||
if _, err := dao.UpdateEntityTx(tx, order); err != nil {
|
||||
dao.Rollback(db, tx)
|
||||
return nil, err
|
||||
}
|
||||
dao.Commit(db, tx)
|
||||
|
||||
}
|
||||
return orderPayRefund, err
|
||||
|
||||
Reference in New Issue
Block a user