Browse Source

no message

xingzai 1 year ago
parent
commit
25d4ed7885
3 changed files with 18 additions and 16 deletions
  1. 3 0
      controllers/activity.go
  2. 1 1
      controllers/order.go
  3. 14 15
      services/wx_pay.go

+ 3 - 0
controllers/activity.go

@@ -1193,6 +1193,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
+		resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
 	}
 
 	// 判断是否属于研选类型的活动
@@ -1547,6 +1548,7 @@ func (this *ActivityCoAntroller) CheckAsk() {
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
+		resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
 	}
 	// 判断是否属于研选类型的活动
 	if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
@@ -1683,6 +1685,7 @@ func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
+		resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
 	}
 
 	// 判断是否属于研选类型的活动

+ 1 - 1
controllers/order.go

@@ -90,12 +90,12 @@ func (this *OrderController) AddByArticle() {
 	} else {
 		err = order.UpdateCygxOrder(item, oldOrderCode)
 	}
-
 	if err != nil {
 		br.Msg = "创建订单信息失败"
 		br.ErrMsg = "创建订单信息失败,Err:" + err.Error()
 		return
 	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 14 - 15
services/wx_pay.go

@@ -7,6 +7,8 @@ import (
 	"github.com/wechatpay-apiv3/wechatpay-go/core/option"
 	"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
 	payUtils "github.com/wechatpay-apiv3/wechatpay-go/utils"
+	"hongze/hongze_mfyx/models/order"
+	"hongze/hongze_mfyx/utils"
 	"log"
 )
 
@@ -17,9 +19,9 @@ const (
 	MchAPIv3Key                = "W1tbnzQrzQ7yRRNuQCIHjis8dgdasKVX"
 )
 
-func init111w() {
-	ExampleJsapiApiService_Prepay()
-}
+//func init() {
+//	ExampleJsapiApiServicePrepay()
+//}
 
 // 获取加解密处理
 func getWechatClient() (context.Context, *core.Client, error) {
@@ -42,7 +44,7 @@ func getWechatClient() (context.Context, *core.Client, error) {
 	return ctx, client, nil
 }
 
-func ExampleJsapiApiService_Prepay() {
+func ExampleJsapiApiServicePrepay(orderDetail *order.CygxOrder, openid string) {
 	//mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
 	//if err != nil {
 	//	log.Print("load merchant private key error")
@@ -63,26 +65,23 @@ func ExampleJsapiApiService_Prepay() {
 	// 得到prepay_id,以及调起支付所需的参数和签名
 	resp, _, err := svc.PrepayWithRequestPayment(ctx,
 		jsapi.PrepayRequest{
-			Appid:       core.String("wx5e3240ab90c247ac"),
+			Appid:       core.String(utils.WxAppId),
 			Mchid:       core.String(Mchid),
-			Description: core.String("Image形象店-深圳腾大-QQ公仔"),
-			OutTradeNo:  core.String("1217752501201407033233368018"),
-			Attach:      core.String("自定义数据说明"),
+			Description: core.String(orderDetail.SourceTitle),
+			OutTradeNo:  core.String(orderDetail.OrderCode),
+			Attach:      core.String(""),
 			NotifyUrl:   core.String("https://www.weixin.qq.com/wxpay/pay.php"),
 			Amount: &jsapi.Amount{
-				Total: core.Int64(1),
+				Total: core.Int64(int64(orderDetail.OrderMoney * 100)), // 分
 			},
 			Payer: &jsapi.Payer{
-				Openid: core.String("ouw2U62cUWNe97e96AZ5jxeAgrJM"),
+				Openid: core.String(openid),
 			},
 		},
 	)
-	//fmt.Println("result", result.Response)
-	fmt.Println("result", resp.PrepayId)
-	//fmt.Println("result", log.(resp.Appid))
-	//fmt.Println("result", result.Request)
+	fmt.Println("PrepayId", *resp)
 	if err == nil {
-		log.Println(resp)
+		log.Println(*resp.Appid)
 	} else {
 		log.Println(err)
 	}