diff --git a/app/services/OrderService.go b/app/services/OrderService.go index f0ccd1d..db4b600 100644 --- a/app/services/OrderService.go +++ b/app/services/OrderService.go @@ -164,7 +164,7 @@ func OrderRefundService(userId int, orderId int) (code int) { if err != nil || !has { return errorcode.NotFound } - if order.State >= common.ORDER_STATUS_PAY { + if order.State != common.ORDER_STATUS_PAY { return errorcode.OrderNOTAuthREFUND } code, response := YouChuOrderRefund(order) @@ -215,6 +215,8 @@ func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderN utils.Log(nil, "notify err", err, YouChuOrderNotifyRequest.ReqTraceId, YouChuOrderNotifyRequest.OrderNo) return front.YouChuOrderNotifyResponse{RespCode: "000003", RespMsg: "订单不存在"} } + + ordersmodel.GetInstance().GetDb().Where("id = ?", order.Id).Update(ordersmodel.Orders{ExchangeTime: time.Now()}) var productDetail productsmodel.Products has, err = productsmodel.GetInstance().GetDb().Where("id = ?", orderDetail.ProductId).Get(&productDetail) if err != nil || !has { @@ -237,6 +239,7 @@ func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderN utils.Log(nil, "notify err", err) return front.YouChuOrderNotifyResponse{RespCode: "000004", RespMsg: "库存不足"} } + client := market.NewMarketClient(config.GetConf().OpenApiMarketConfig) send, err := client.MarketSend(orderDetail.OrderNo, strconv.Itoa(orderDetail.VoucherId), "", "2") utils.Log(nil, "OrderNotify-MarketSend", send, err) diff --git a/app/third/youchu/youchu_api.go b/app/third/youchu/youchu_api.go index 1edcd12..34118ea 100644 --- a/app/third/youchu/youchu_api.go +++ b/app/third/youchu/youchu_api.go @@ -2,6 +2,7 @@ package youchu import ( "encoding/json" + "fmt" "qteam/app/constants/errorcode" "qteam/app/http/entities/front" "qteam/app/models/ordersmodel" @@ -122,7 +123,7 @@ func (this *YouChuClient) OrderRefund(order ordersmodel.Orders) (code int, respo }, Body: front.RefundRequestBody{ BusiMainId: BusiMainId, - ReqTransTime: order.CreateTime.Format("2006-01-02 15:04:05"), + ReqTransTime: order.CreateTime.Format("20060102150405"), Data: front.RefundRequestData{ TxnCode: "1003", SourceId: "16", @@ -145,6 +146,7 @@ func (this *YouChuClient) OrderRefund(order ordersmodel.Orders) (code int, respo post, err := this.doPost(url, request.Body.BusiMainId, "b2c.gatewaypay.orderRefund", bytes) utils.Log(nil, "b2c.orderRefund", post) if err != nil { + fmt.Println(err) return errorcode.YouChuOrderRefundFail, response } responseData := DecryptResponse(string(post), false)