fix:
This commit is contained in:
parent
564c9a5341
commit
649d240561
|
@ -497,20 +497,20 @@ func RentCardOrderCreate(c *gin.Context) {
|
|||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
//webPay, err := wxpay.WebPay(order.OrderSn, req.Price, user.WxOpenID, "N", wxpay.WxPayRentCard, configInfo.NotifyUrl)
|
||||
//if err != nil {
|
||||
// logger.Error(errors.New("WebPay err"))
|
||||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
|
||||
webPay, err := wxpay.HmJsPayUnifiedOrder(order.OrderSn, req.Price, user.WxOpenID, "N", wxpay.WxPayRentCard, configInfo.NotifyUrl)
|
||||
webPay, err := wxpay.WebPay(order.OrderSn, req.Price, user.WxOpenID, "N", wxpay.WxPayRentCard, configInfo.NotifyUrl)
|
||||
if err != nil {
|
||||
logger.Error(errors.New("WebPay err"))
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
//webPay, err := wxpay.HmJsPayUnifiedOrder(order.OrderSn, req.Price, user.WxOpenID, "N", wxpay.WxPayRentCard, configInfo.NotifyUrl)
|
||||
//if err != nil {
|
||||
// logger.Error(errors.New("WebPay err"))
|
||||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
|
||||
//num, err := model.NewOrderQuerySet(model.DB).IDEq(order.ID).GetUpdater().
|
||||
// SetOutTradeNo(webPay.NonceStr).SetMchid(config.AppConfig.WxMchID).UpdateNum()
|
||||
//if err != nil {
|
||||
|
|
|
@ -326,6 +326,13 @@ func OpenMember(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
//webPay, err := wxpay.HmJsPayUnifiedOrder(orderSn, totalFee, user.WxOpenID, "N", wxpay.WxPayRentCard, configInfo.NotifyUrl)
|
||||
//if err != nil {
|
||||
// logger.Error(errors.New("WebPay err"))
|
||||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
|
||||
RespOK(c, webPay)
|
||||
}
|
||||
|
||||
|
|
|
@ -960,9 +960,9 @@ func newHttpClient(certFile, keyFile string) (*http.Client, error) {
|
|||
type HmPayPublicPara struct {
|
||||
AppId string `json:"app_id"`
|
||||
//SubAppId string `json:"sub_app_id"`
|
||||
Method string `json:"method"`
|
||||
Charset string `json:"charset"`
|
||||
//SignType string `json:"sign_type"`
|
||||
Method string `json:"method"`
|
||||
//Charset string `json:"charset"`
|
||||
SignType string `json:"sign_type"`
|
||||
Sign string `json:"sign"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Nonce string `json:"nonce"`
|
||||
|
@ -972,41 +972,78 @@ type HmPayPublicPara struct {
|
|||
}
|
||||
|
||||
type HmJsPayUnifiedOrderReq struct {
|
||||
CreateIp string `json:"create_ip"`
|
||||
CreateTime string `json:"create_time"`
|
||||
//ExpireTime string `json:"expire_time"`
|
||||
//BankWay string `json:"bank_way"`
|
||||
PayWay string `json:"pay_way"`
|
||||
PayType string `json:"pay_type"`
|
||||
MerAppId string `json:"mer_app_id"`
|
||||
MerBuyerId string `json:"mer_buyer_id"`
|
||||
//BuyerId string `json:"buyer_id"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
//scene_info
|
||||
Body string `json:"body"`
|
||||
StoreId string `json:"store_id"`
|
||||
//TerminalId string `json:"terminal_id"`
|
||||
//OperatorId string `json:"operator_id"`
|
||||
NotifyUrl string `json:"notify_url"`
|
||||
//RedirectUrl string `json:"redirect_url"`
|
||||
//LimitPay string `json:"limit_pay"`
|
||||
//ReqReserved string `json:"req_reserved"`
|
||||
|
||||
//extend_params
|
||||
//discount_info
|
||||
//goods_details
|
||||
//device_info
|
||||
//ext_user_info
|
||||
|
||||
HmPayPublicPara
|
||||
}
|
||||
|
||||
type HmPayBizContent struct {
|
||||
Body string `json:"body"`
|
||||
BuyerId string `json:"buyer_id"`
|
||||
CreateIp string `json:"create_ip"`
|
||||
CreateTime string `json:"create_time"`
|
||||
DiscountInfo struct {
|
||||
DiscountableAmount float64 `json:"discountable_amount"`
|
||||
} `json:"discount_info"`
|
||||
ExpireTime string `json:"expire_time"`
|
||||
ExtendParams struct {
|
||||
AccessPartyCode string `json:"access_party_code"`
|
||||
} `json:"extend_params"`
|
||||
GoodsDetails []HmPayGoodsDetails `json:"goods_details"`
|
||||
LimitPay string `json:"limit_pay"`
|
||||
NotifyUrl string `json:"notify_url"`
|
||||
//OperatorId string `json:"operator_id"`
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
PayType string `json:"pay_type"`
|
||||
PayWay string `json:"pay_way"`
|
||||
StoreId string `json:"store_id"`
|
||||
//TerminalId string `json:"terminal_id"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
}
|
||||
|
||||
type HmPayGoodsDetails struct {
|
||||
Body string `json:"body"`
|
||||
GoodsId string `json:"goods_id"`
|
||||
GoodsName string `json:"goods_name"`
|
||||
Price float64 `json:"price"`
|
||||
Quantity int `json:"quantity"`
|
||||
ShowUrl string `json:"show_url"`
|
||||
}
|
||||
|
||||
type HmPayUnifiedOrderDetail struct {
|
||||
BankOrderNo string `json:"bank_order_no"`
|
||||
BankTrxNo string `json:"bank_trx_no"`
|
||||
BankWay string `json:"bank_way"`
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
PayData string `json:"pay_data"`
|
||||
PlatTrxNo string `json:"plat_trx_no"`
|
||||
PrepayId string `json:"prepay_id"`
|
||||
SubCode string `json:"sub_code"`
|
||||
SubMsg string `json:"sub_msg"`
|
||||
}
|
||||
|
||||
type HmPayUnifiedOrderPayData struct {
|
||||
TimeStamp string `json:"timeStamp"`
|
||||
Package string `json:"package"`
|
||||
PaySign string `json:"paySign"`
|
||||
AppId string `json:"appId"`
|
||||
SignType string `json:"signType"`
|
||||
NonceStr string `json:"nonceStr"`
|
||||
}
|
||||
|
||||
type HmPayUnifiedOrderRsp struct {
|
||||
Code string `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data string `json:"data"`
|
||||
Sign string `json:"sign"`
|
||||
}
|
||||
|
||||
//hm 微信支付
|
||||
func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, profitSharing, attach, notifyUrl string) (*Sextuple, error) {
|
||||
func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, profitSharing, attach, notifyUrl string) (*HmPayUnifiedOrderPayData, error) {
|
||||
now := time.Now().Local()
|
||||
strTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(),
|
||||
now.Minute(), now.Second())
|
||||
expireTime := now.Add(time.Hour * 3)
|
||||
strExpireTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", expireTime.Year(), expireTime.Month(),
|
||||
expireTime.Day(), expireTime.Hour(), expireTime.Minute(), expireTime.Second())
|
||||
nonce := utils.GenRandStr(NonceStringLength)
|
||||
|
||||
if notifyUrl == "" {
|
||||
|
@ -1014,74 +1051,63 @@ func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, profitSharing,
|
|||
return nil, errors.New("NotifyUrl is null")
|
||||
}
|
||||
|
||||
logger.Info("MchId:", config.AppConfig.WxMchID)
|
||||
logger.Info("AppId:", config.AppConfig.WxAppId)
|
||||
logger.Info("MchSecret:", config.AppConfig.WxMchSecret)
|
||||
//logger.Info("MchId:", config.AppConfig.WxMchID)
|
||||
//logger.Info("AppId:", config.AppConfig.WxAppId)
|
||||
//logger.Info("MchSecret:", config.AppConfig.WxMchSecret)
|
||||
|
||||
//unifiedOrderReq := UnifiedOrderReq{
|
||||
// DeviceInfo: "WEB",
|
||||
// NonceStr: nonce,
|
||||
// Sign: "",
|
||||
// SignType: "MD5",
|
||||
// Body: "创建订单",
|
||||
// OutTradeNo: orderId,
|
||||
// FeeType: "CNY",
|
||||
// TotalFee: strconv.Itoa(int(totalFee)),
|
||||
// //SpbillCreateIp: config.AppConfig.IP,
|
||||
// SpbillCreateIp: clientIp,
|
||||
// //NotifyUrl: "https://" + config.AppConfig.Domain + config.AppConfig.WxPayNotifyUrl,
|
||||
// //NotifyUrl: "https://" + domain + wxPayNotifyUrl,
|
||||
// //NotifyUrl: configInfo.NotifyUrl,
|
||||
// NotifyUrl: notifyUrl,
|
||||
//
|
||||
// TradeType: "JSAPI",
|
||||
// MchId: config.AppConfig.WxMchID,
|
||||
// AppId: config.AppConfig.WxAppId,
|
||||
// OpenId: openId,
|
||||
// TimeStart: strTime,
|
||||
// ProfitSharing: profitSharing,
|
||||
// Attach: attach,
|
||||
//}
|
||||
|
||||
unifiedOrderReq := HmJsPayUnifiedOrderReq{
|
||||
CreateIp: clientIp,
|
||||
CreateTime: strTime,
|
||||
//ExpireTime: "",
|
||||
//BankWay: "",
|
||||
PayWay: "WECHAT",
|
||||
PayType: "JSAPI",
|
||||
MerAppId: config.AppConfig.WxAppId,
|
||||
MerBuyerId: openId,
|
||||
//BuyerId: "",
|
||||
TotalAmount: float64(totalFee) / 100,
|
||||
OutOrderNo: orderId,
|
||||
Body: "会员",
|
||||
StoreId: "100001",
|
||||
//TerminalId: "",
|
||||
//OperatorId: "",
|
||||
NotifyUrl: notifyUrl,
|
||||
//RedirectUrl: "",
|
||||
//LimitPay: "",
|
||||
//ReqReserved: "",
|
||||
}
|
||||
unifiedOrderReq := HmJsPayUnifiedOrderReq{}
|
||||
publicPara := HmPayPublicPara{
|
||||
AppId: HmPayMerchantId,
|
||||
//SubAppId: HmWxSubMerchantId,
|
||||
Method: "trade.create",
|
||||
Charset: "UTF-8",
|
||||
//SignType: "",
|
||||
//SubAppId: HmWxSubMerchantId,
|
||||
Method: "trade.create",
|
||||
//Charset: "UTF-8",
|
||||
SignType: "RSA",
|
||||
Sign: "",
|
||||
Timestamp: now.Format(TimeFormat),
|
||||
Nonce: nonce,
|
||||
//Version: "",
|
||||
//Format: "",
|
||||
BizContent: fmt.Sprintf(`{"attach":"%s"}`, attach),
|
||||
//Nonce: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||
//Version: "1.0.0",
|
||||
//Format: "JSON",
|
||||
}
|
||||
|
||||
biz := HmPayBizContent{
|
||||
Body: "会员费",
|
||||
BuyerId: openId,
|
||||
CreateIp: clientIp,
|
||||
CreateTime: strTime,
|
||||
DiscountInfo: struct {
|
||||
DiscountableAmount float64 `json:"discountable_amount"`
|
||||
}{},
|
||||
ExpireTime: strExpireTime,
|
||||
ExtendParams: struct {
|
||||
AccessPartyCode string `json:"access_party_code"`
|
||||
}{},
|
||||
GoodsDetails: []HmPayGoodsDetails{
|
||||
{
|
||||
Body: "会员",
|
||||
GoodsId: "1",
|
||||
GoodsName: "会员服务",
|
||||
Price: 399,
|
||||
Quantity: 1,
|
||||
ShowUrl: "",
|
||||
},
|
||||
},
|
||||
LimitPay: "NO_CREDIT",
|
||||
NotifyUrl: notifyUrl,
|
||||
OutOrderNo: orderId,
|
||||
PayType: "JSAPI",
|
||||
PayWay: "WECHAT",
|
||||
StoreId: "100001",
|
||||
TotalAmount: float64(totalFee) / 100,
|
||||
}
|
||||
unifiedOrderReq.HmPayPublicPara = publicPara
|
||||
|
||||
//fmt.Println("OutTradeNo:", unifiedOrderReq.OutTradeNo)
|
||||
fmt.Println("OutOrderNo:", unifiedOrderReq.OutOrderNo)
|
||||
|
||||
bizString, err := json.Marshal(&biz)
|
||||
if err != nil {
|
||||
logger.Error("marshal biz err:", err)
|
||||
return nil, err
|
||||
}
|
||||
unifiedOrderReq.HmPayPublicPara.BizContent = string(bizString)
|
||||
m, err := struct2Map(unifiedOrderReq)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
|
@ -1096,7 +1122,6 @@ func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, profitSharing,
|
|||
logger.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
//unifiedOrderReq.Sign = strings.ToUpper(sign)
|
||||
unifiedOrderReq.Sign = sign
|
||||
|
||||
//unifiedOrderReqJson, _ := json.Marshal(&unifiedOrderReq)
|
||||
|
@ -1107,59 +1132,26 @@ func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, profitSharing,
|
|||
logger.Errorf("WxUnifiedOrder unified order error %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var sextuple Sextuple
|
||||
sextuple.NonceStr = unifiedOrderResp.NonceStr
|
||||
sextuple.AppId = unifiedOrderResp.AppId
|
||||
sextuple.Timestamp = fmt.Sprintf("%d", now.Unix())
|
||||
sextuple.Package = "prepay_id=" + unifiedOrderResp.PrepayId
|
||||
sextuple.SignType = "MD5"
|
||||
//logger.Debugf("unified order sextuple: %#v", sextuple)
|
||||
|
||||
m, err = struct2Map(sextuple)
|
||||
//fmt.Println("unifiedOrderResp:", unifiedOrderResp.Data)
|
||||
var hmPayDetail HmPayUnifiedOrderDetail
|
||||
err = json.Unmarshal([]byte(unifiedOrderResp.Data), &hmPayDetail)
|
||||
if err != nil {
|
||||
logger.Errorf("struct to map error %#v", err)
|
||||
logger.Errorf("hm pay unified order pay data unmarshal error %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
//fmt.Println("hmPayDetail:", hmPayDetail)
|
||||
|
||||
var hmPayData HmPayUnifiedOrderPayData
|
||||
err = json.Unmarshal([]byte(hmPayDetail.PayData), &hmPayData)
|
||||
if err != nil {
|
||||
logger.Errorf("hm pay unified order pay data unmarshal error %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sextuple.PaySign, err = GenWxPaySign(m, config.AppConfig.WxMchSecret)
|
||||
if err != nil {
|
||||
logger.Errorf("GenWxPaySign gen response sign error: %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &sextuple, nil
|
||||
//fmt.Println("hmPayData:", hmPayData)
|
||||
return &hmPayData, nil
|
||||
}
|
||||
|
||||
//func RsaSign(signContent string, privateKey string, hash crypto.Hash) string {
|
||||
// shaNew := hash.New()
|
||||
// shaNew.Write([]byte(signContent))
|
||||
// hashed := shaNew.Sum(nil)
|
||||
// priKey, err := ParsePrivateKey(privateKey)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
//
|
||||
// signature, err := rsa.SignPKCS1v15(rand.Reader, priKey, hash, hashed)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// return base64.StdEncoding.EncodeToString(signature)
|
||||
|
||||
//digest := sha256.Sum256(data)
|
||||
//
|
||||
//signature, signErr := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, digest[:])
|
||||
//
|
||||
//if signErr != nil {
|
||||
//t.Errorf("Could not sign message:%s", signErr.Error())
|
||||
//}
|
||||
//
|
||||
//// just to check that we can survive to and from b64
|
||||
//b64sig := base64.StdEncoding.EncodeToString(signature)
|
||||
//
|
||||
//decodedSignature, _ := base64.StdEncoding.DecodeString(b64sig)
|
||||
//}
|
||||
|
||||
func GenHmPaySign(m map[string]string) (string, error) {
|
||||
delete(m, "sign")
|
||||
var signData []string
|
||||
|
@ -1167,34 +1159,23 @@ func GenHmPaySign(m map[string]string) (string, error) {
|
|||
if k == "openid" {
|
||||
fmt.Println(k, ":", v)
|
||||
}
|
||||
//fmt.Println("k:", k)
|
||||
//fmt.Println("v:", v)
|
||||
if v != "" && v != "0" {
|
||||
signData = append(signData, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
}
|
||||
signDataJson, _ := json.MarshalIndent(&signData, "", " ")
|
||||
fmt.Println("signDataJson1", string(signDataJson))
|
||||
//signDataJson, _ := json.MarshalIndent(&signData, "", " ")
|
||||
//fmt.Println("signDataJson1", string(signDataJson))
|
||||
|
||||
sort.Strings(signData)
|
||||
|
||||
signDataJson2, _ := json.MarshalIndent(&signData, "", " ")
|
||||
fmt.Println("signDataJson2", string(signDataJson2))
|
||||
//signDataJson2, _ := json.MarshalIndent(&signData, "", " ")
|
||||
//fmt.Println("signDataJson2", string(signDataJson2))
|
||||
|
||||
signStr := strings.Join(signData, "&")
|
||||
//signStr = signStr + "&key=" + payKey
|
||||
logger.Info("签字符串1 :", signStr)
|
||||
//c := md5.New()
|
||||
//_, err := c.Write([]byte(signStr))
|
||||
//if err != nil {
|
||||
// logger.Error(err)
|
||||
// return "", err
|
||||
//}
|
||||
//
|
||||
//signByte := c.Sum(nil)
|
||||
//
|
||||
//return fmt.Sprintf("%x", signByte), nil
|
||||
signature, err := Sha256withRsa(signStr)
|
||||
|
||||
signature, err := Sha1withRsa(signStr)
|
||||
if err != nil {
|
||||
logger.Error("signature err:", err)
|
||||
return "", err
|
||||
|
@ -1202,8 +1183,8 @@ func GenHmPaySign(m map[string]string) (string, error) {
|
|||
return signature, nil
|
||||
}
|
||||
|
||||
func Sha256withRsa(signContent string) (string, error) {
|
||||
hash := crypto.SHA256
|
||||
func Sha1withRsa(signContent string) (string, error) {
|
||||
hash := crypto.SHA1
|
||||
shaNew := hash.New()
|
||||
shaNew.Write([]byte(signContent))
|
||||
hashed := shaNew.Sum(nil)
|
||||
|
@ -1260,7 +1241,7 @@ func FormatPrivateKey(privateKey string) string {
|
|||
return privateKey
|
||||
}
|
||||
|
||||
func VerifySha256Rsa(signContent, signBase string) error {
|
||||
func VerifySha1Rsa(signContent, signBase string) error {
|
||||
fp := "/Users/li/mh/mh_server/pack/configs/hm_pay/public_key.pme"
|
||||
publicKeyString, err := ioutil.ReadFile(fp)
|
||||
if err != nil {
|
||||
|
@ -1279,7 +1260,7 @@ func VerifySha256Rsa(signContent, signBase string) error {
|
|||
fmt.Println("public key nil:")
|
||||
return err
|
||||
}
|
||||
hash := crypto.SHA256
|
||||
hash := crypto.SHA1
|
||||
shaNew := hash.New()
|
||||
shaNew.Write([]byte(signContent))
|
||||
hashed := shaNew.Sum(nil)
|
||||
|
@ -1290,7 +1271,7 @@ func VerifySha256Rsa(signContent, signBase string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = rsa.VerifyPKCS1v15(publicKey.(*rsa.PublicKey), crypto.SHA256, hashed, sign)
|
||||
err = rsa.VerifyPKCS1v15(publicKey.(*rsa.PublicKey), hash, hashed, sign)
|
||||
if err != nil {
|
||||
fmt.Println("verify err:", err)
|
||||
return err
|
||||
|
@ -1300,48 +1281,77 @@ func VerifySha256Rsa(signContent, signBase string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func HmPayUnifiedOrder(r HmJsPayUnifiedOrderReq) (UnifiedOrderResp, error) {
|
||||
var payResp UnifiedOrderResp
|
||||
func HmPayUnifiedOrder(r HmJsPayUnifiedOrderReq) (HmPayUnifiedOrderRsp, error) {
|
||||
var hmPayUnifiedOrderRsp HmPayUnifiedOrderRsp
|
||||
|
||||
data, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return payResp, err
|
||||
return hmPayUnifiedOrderRsp, err
|
||||
}
|
||||
|
||||
fmt.Println("data json:", string(data))
|
||||
client := http.Client{}
|
||||
req, err := http.NewRequest("POST", HmPayUnifiedOrderUrl, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return payResp, err
|
||||
return hmPayUnifiedOrderRsp, err
|
||||
}
|
||||
//req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
//req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return payResp, err
|
||||
return hmPayUnifiedOrderRsp, err
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return payResp, err
|
||||
return hmPayUnifiedOrderRsp, err
|
||||
}
|
||||
fmt.Println("body:", string(body))
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
//err = xml.Unmarshal(body, &payResp)
|
||||
//if err != nil {
|
||||
// logger.Error(err)
|
||||
// return payResp, err
|
||||
//}
|
||||
//
|
||||
//if payResp.ReturnCode != "SUCCESS" {
|
||||
// return payResp, errors.New(payResp.ReturnMsg)
|
||||
//}
|
||||
err = json.Unmarshal(body, &hmPayUnifiedOrderRsp)
|
||||
if err != nil {
|
||||
logger.Error("hmPayUnifiedOrderRsp err:", err)
|
||||
return hmPayUnifiedOrderRsp, err
|
||||
}
|
||||
if hmPayUnifiedOrderRsp.Code != "200" {
|
||||
return hmPayUnifiedOrderRsp, errors.New(hmPayUnifiedOrderRsp.Msg)
|
||||
}
|
||||
|
||||
return payResp, nil
|
||||
return hmPayUnifiedOrderRsp, nil
|
||||
}
|
||||
|
||||
//func RsaSign(signContent string, privateKey string, hash crypto.Hash) string {
|
||||
// shaNew := hash.New()
|
||||
// shaNew.Write([]byte(signContent))
|
||||
// hashed := shaNew.Sum(nil)
|
||||
// priKey, err := ParsePrivateKey(privateKey)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
//
|
||||
// signature, err := rsa.SignPKCS1v15(rand.Reader, priKey, hash, hashed)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// return base64.StdEncoding.EncodeToString(signature)
|
||||
//
|
||||
// digest := sha256.Sum256(data)
|
||||
//
|
||||
// signature, signErr := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, digest[:])
|
||||
//
|
||||
// if signErr != nil {
|
||||
// t.Errorf("Could not sign message:%s", signErr.Error())
|
||||
// }
|
||||
//
|
||||
// // just to check that we can survive to and from b64
|
||||
// b64sig := base64.StdEncoding.EncodeToString(signature)
|
||||
//
|
||||
// decodedSignature, _ := base64.StdEncoding.DecodeString(b64sig)
|
||||
//}
|
||||
|
|
|
@ -2096,17 +2096,17 @@ func TestPasKey(t *testing.T) {
|
|||
fmt.Println("key:", encodeToString)
|
||||
}
|
||||
|
||||
func TestSha256withRsa(t *testing.T) {
|
||||
func TestSha1withRsa(t *testing.T) {
|
||||
d := `{"hm":10}`
|
||||
|
||||
withRsa, err := wxpay.Sha256withRsa(d)
|
||||
withRsa, err := wxpay.Sha1withRsa(d)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
}
|
||||
|
||||
fmt.Println("sign:", withRsa)
|
||||
|
||||
err = wxpay.VerifySha256Rsa(d, withRsa)
|
||||
err = wxpay.VerifySha1Rsa(d, withRsa)
|
||||
if err != nil {
|
||||
logger.Error("verify rsa err:", err)
|
||||
}
|
||||
|
@ -2121,3 +2121,15 @@ func TestHmJsPayUnifiedOrder(t *testing.T) {
|
|||
|
||||
fmt.Println("order:", order)
|
||||
}
|
||||
|
||||
func TestUnicode(t *testing.T) {
|
||||
str := `{"msg":"\u8be5\u5355\u53f7\u6682\u65e0\u7269\u6d41\u8fdb\u5c55\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\uff0c\u6216\u68c0\u67e5\u516c\u53f8\u548c\u5355\u53f7\u662f\u5426\u6709\u8bef\u3002","status":"-3","error_code":"13","data":{"info":{"status":"0","msg":"\u8be5\u5355\u53f7\u6682\u65e0\u7269\u6d41\u8fdb\u5c55\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\uff0c\u6216\u68c0\u67e5\u516c\u53f8\u548c\u5355\u53f7\u662f\u5426\u6709\u8bef\u3002","_source_com":""},"com":"zhongtong","company":{"url":"http:\/\/www.zto.com\/?from=openv","fullname":"\u4e2d\u901a\u5feb\u9012","shortname":"\u4e2d\u901a","icon":{"id":"29","smallurl":"https:\/\/ss0.baidu.com\/6ONWsjip0QIZ8tyhnq\/it\/u=3682653099,2524883494&fm=58","smallpos":"0,496","middleurl":"https:\/\/ss2.baidu.com\/6ONYsjip0QIZ8tyhnq\/it\/u=1078213688,3146076104&fm=58","middlepos":"0,324","normal":"https:\/\/ss0.baidu.com\/6ONWsjip0QIZ8tyhnq\/it\/u=1022514261,1855787563&fm=58"},"website":{"title":"www.zto.com","url":"http:\/\/www.zto.com"},"tel":"95311","auxiliary":[{"title":"\u7f51\u70b9\u67e5\u8be2","url":"http:\/\/www.zto.com\/GuestService\/SiteQuery"},{"title":"\u7f51\u4e0a\u5bc4\u4ef6","url":"http:\/\/my.zto.com\/order"},{"title":"\u4ef7\u683c\u67e5\u8be2","url":"http:\/\/www.zto.com\/GuestService\/PriceQuery"},{"title":"\u4e2d\u901a\u4f18\u9009","url":"http:\/\/www.ztbest.com"}]},"source":{"logo":"https:\/\/ss2.baidu.com\/6ONYsjip0QIZ8tyhnq\/it\/u=1429564979,1787167512&fm=58","title":"\u6570\u636e\u6765\u81ea\u5feb\u9012100","url":"http:\/\/www.kuaidi100.com\/?from=baidu_ala","name":"\u5feb\u9012100","showName":"\u5feb\u9012100"}}}`
|
||||
data := make(map[string]interface{})
|
||||
json.Unmarshal([]byte(str), &data)
|
||||
newStr, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("===", string(newStr))
|
||||
|
||||
}
|
||||
|
|
|
@ -542,6 +542,7 @@ type UserInviteListReq struct {
|
|||
PageSize int `json:"page_size"`
|
||||
Uid uint32 `json:"uid"`
|
||||
MemberType int `json:"member_type"` // 0-全部 1-普通用户 2-会员
|
||||
SpendType uint32 `json:"spend_type"` // 2-开通会员 3-续费
|
||||
StartTime string `json:"start_time"` // 开始时间
|
||||
EndTime string `json:"end_time"` // 结束时间
|
||||
}
|
||||
|
@ -583,13 +584,19 @@ func (m *UserInviteListReq) InviteUserList() (*UserInviteListResp, error) {
|
|||
//qs = qs.SpendTypeEq(2)
|
||||
//qs = qs.SpendTypeNotIn([]uint32{3, 4}...)
|
||||
if user.CooperativeBusinessId == 1 {
|
||||
qs = qs.SpendTypeIn([]uint32{2, 3}...)
|
||||
if m.SpendType != 0 {
|
||||
qs = qs.SpendTypeEq(m.SpendType)
|
||||
} else {
|
||||
qs = qs.SpendTypeIn([]uint32{2, 3}...)
|
||||
}
|
||||
} else {
|
||||
qs = qs.SpendTypeNotIn([]uint32{3, 4}...)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if m.MemberType == 0 && m.SpendType != 0 {
|
||||
qs = qs.SpendTypeEq(m.SpendType)
|
||||
}
|
||||
if m.StartTime != "" {
|
||||
parse, err := time.Parse(DateTimeFormat, m.StartTime)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user