You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
875 B
37 lines
875 B
package union
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
"recook/internal/dbc"
|
|
"recook/internal/v2/lib/unionpay"
|
|
"recook/internal/v2/model/recook/after"
|
|
manage "recook/internal/v2/model/recook/order"
|
|
"strconv"
|
|
)
|
|
|
|
// @Style 退款
|
|
func Refund(asGoods *after.RecookAfterSalesGoodsModel) error {
|
|
var o manage.RecookOrderInfoModel
|
|
if err := dbc.DB.First(&o, asGoods.OrderId).Error; err != nil {
|
|
return errors.New("订单错误")
|
|
}
|
|
var refundID uint64
|
|
if o.PayType == 1 {
|
|
refundID = uint64(o.VirtualID)
|
|
} else {
|
|
refundID = uint64(o.Id)
|
|
}
|
|
query, err := unionpay.UnionPay.Query(strconv.FormatUint(refundID, 10))
|
|
if err != nil {
|
|
log.Println(err, "========")
|
|
return err
|
|
}
|
|
tradeNo := asGoods.TradeNo + "T" + strconv.Itoa(int(asGoods.Id))
|
|
_, err = unionpay.UnionPay.Refund(tradeNo, query["queryId"], asGoods.RefundAmount)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
return err
|
|
}
|