1
This commit is contained in:
@@ -305,7 +305,7 @@ func (c *PurchaseHandler) onOrderMsg(orderStatus, orderId string, orderCallback
|
|||||||
msg := orderCallback.(*tao_vegetable.CallbackOrder)
|
msg := orderCallback.(*tao_vegetable.CallbackOrder)
|
||||||
if orderStatus == tao_vegetable.OrderStatusOnSaleCancel {
|
if orderStatus == tao_vegetable.OrderStatusOnSaleCancel {
|
||||||
onSale := orderCallback.(*tao_vegetable.OnSaleCancel)
|
onSale := orderCallback.(*tao_vegetable.OnSaleCancel)
|
||||||
msg.PublicModel = onSale.PublicModel
|
//msg.PublicModel = onSale.PublicModel
|
||||||
msg.MerchantCode = onSale.MerchantCode
|
msg.MerchantCode = onSale.MerchantCode
|
||||||
msg.StoreId = onSale.StoreId
|
msg.StoreId = onSale.StoreId
|
||||||
msg.BizOrderId = onSale.BizOrderId
|
msg.BizOrderId = onSale.BizOrderId
|
||||||
@@ -386,7 +386,8 @@ func (c *PurchaseHandler) callbackOrderMsg2Status(msg *tao_vegetable.CallbackOrd
|
|||||||
RefVendorOrderID: orderId,
|
RefVendorOrderID: orderId,
|
||||||
RefVendorID: model.VendorIDTaoVegetable,
|
RefVendorID: model.VendorIDTaoVegetable,
|
||||||
VendorStatus: msg.OrderStatus,
|
VendorStatus: msg.OrderStatus,
|
||||||
StatusTime: utils.Str2TimeWithDefault(msg.Timestamp, time.Now()),
|
//StatusTime: utils.Str2TimeWithDefault(msg.Timestamp, time.Now()),
|
||||||
|
StatusTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
switch msg.OrderStatus {
|
switch msg.OrderStatus {
|
||||||
@@ -420,18 +421,18 @@ func (c *PurchaseHandler) callbackOrderMsg2Status(msg *tao_vegetable.CallbackOrd
|
|||||||
|
|
||||||
func (c *PurchaseHandler) postFakeMsg(vendorOrderID, cmd, vendorStatus string) {
|
func (c *PurchaseHandler) postFakeMsg(vendorOrderID, cmd, vendorStatus string) {
|
||||||
msg := &tao_vegetable.CallbackOrder{
|
msg := &tao_vegetable.CallbackOrder{
|
||||||
PublicModel: tao_vegetable.PublicModel{
|
//PublicModel: tao_vegetable.PublicModel{
|
||||||
Method: "",
|
// Method: "",
|
||||||
AppKey: "",
|
// AppKey: "",
|
||||||
Session: "",
|
// Session: "",
|
||||||
Timestamp: utils.Time2Str(time.Now()),
|
// Timestamp: utils.Time2Str(time.Now()),
|
||||||
V: "",
|
// V: "",
|
||||||
SignMethod: "",
|
// SignMethod: "",
|
||||||
Sign: "",
|
// Sign: "",
|
||||||
Format: "",
|
// Format: "",
|
||||||
Simplify: false,
|
// Simplify: false,
|
||||||
CustomerId: false,
|
// CustomerId: false,
|
||||||
},
|
//},
|
||||||
MerchantCode: "",
|
MerchantCode: "",
|
||||||
StoreId: "",
|
StoreId: "",
|
||||||
BizOrderId: utils.Str2Int64(vendorOrderID),
|
BizOrderId: utils.Str2Int64(vendorOrderID),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -12,6 +14,9 @@ import (
|
|||||||
"github.com/astaxie/beego/server/web"
|
"github.com/astaxie/beego/server/web"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaoBaoVegetableController struct {
|
type TaoBaoVegetableController struct {
|
||||||
@@ -69,13 +74,36 @@ func (c *TaoBaoVegetableController) GetCode() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Sign(param url.Values, data, secret string) string {
|
||||||
|
var publicParam = make([]string, 0, 0)
|
||||||
|
for k, v := range param {
|
||||||
|
if k == "sign" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
publicParam = append(publicParam, fmt.Sprintf("%s%s", k, v[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(publicParam)
|
||||||
|
cc := secret + strings.Join(publicParam, "") + strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "") + secret
|
||||||
|
return fmt.Sprintf("%X", md5.Sum([]byte(cc)))
|
||||||
|
}
|
||||||
|
|
||||||
// OrderStatus 订单状态变化 [post]
|
// OrderStatus 订单状态变化 [post]
|
||||||
func (c *TaoBaoVegetableController) OrderStatus() {
|
func (c *TaoBaoVegetableController) OrderStatus() {
|
||||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
urlParam := c.Ctx.Request.URL.RawQuery
|
||||||
c.ServeJSON()
|
values, err := url.ParseQuery(urlParam)
|
||||||
return
|
|
||||||
|
|
||||||
order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
||||||
|
sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret())
|
||||||
|
if sign != values.Get("sign") { // 49C8CEEDC523CA387A677D08C8861ABC
|
||||||
|
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false))
|
globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Debugf("订单状态变化:%s", err.Error())
|
globals.SugarLogger.Debugf("订单状态变化:%s", err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user