Browse Source

no message

xingzai 1 năm trước cách đây
mục cha
commit
e1c2ed42b4
8 tập tin đã thay đổi với 100 bổ sung138 xóa
  1. 2 1
      .gitignore
  2. 1 0
      controllers/activity.go
  3. 1 0
      go.mod
  4. 10 0
      go.sum
  5. 1 0
      models/activity_signup.go
  6. 1 1
      services/activity.go
  7. 0 136
      services/resource_data.go
  8. 84 0
      services/wx_pay.go

+ 2 - 1
.gitignore

@@ -8,4 +8,5 @@
 /riot-index
 /hongze_mfyx
 /static
-/README.md
+/README.md
+/utils/cret/

+ 1 - 0
controllers/activity.go

@@ -910,6 +910,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
+		resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
 	}
 
 	// 判断是否属于研选类型的活动

+ 1 - 0
go.mod

@@ -17,6 +17,7 @@ require (
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/satori/go.uuid v1.2.0 // indirect
 	github.com/tealeg/xlsx v1.0.5
+	github.com/wechatpay-apiv3/wechatpay-go v0.2.18 // indirect
 	golang.org/x/sys v0.6.0 // indirect
 	golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
 	gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df

+ 10 - 0
go.sum

@@ -9,6 +9,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
 github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
 github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
+github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=
 github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ -390,6 +391,8 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
 github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@@ -397,6 +400,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
@@ -405,6 +411,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
 github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
 github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+github.com/wechatpay-apiv3/wechatpay-go v0.2.18 h1:vj5tvSmnEIz3ZsnFNNUzg+3Z46xgNMJbrO4aD4wP15w=
+github.com/wechatpay-apiv3/wechatpay-go v0.2.18/go.mod h1:A254AUBVB6R+EqQFo3yTgeh7HtyqRRtN2w9hQSOrd4Q=
 github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
 github.com/ylywyn/jpush-api-go-client v0.0.0-20190906031852-8c4466c6e369/go.mod h1:Nv7wKD2/bCdKUFNKcJRa99a+1+aSLlCRJFriFYdjz/I=
@@ -646,6 +654,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

+ 1 - 0
models/activity_signup.go

@@ -45,6 +45,7 @@ type SignupStatus struct {
 	ActivityTypeName  string `description:"活动类型名称"`
 	ActivityTime      string `description:"活动时间"`
 	ActivityType      int    `description:"活动线上线下类型 1线上,0 线下"`
+	IsShowWxPay       bool   `description:"是否展示微信支付"`
 }
 
 // 我的日程

+ 1 - 1
services/activity.go

@@ -1329,7 +1329,7 @@ func GetYanxuanActivityIds(user *models.WxUserItem) (activityIds []int) {
 	}()
 	var condition string
 	var pars []interface{}
-	condition = `  AND  chart_permission_id  = 31  AND yidong_activity_id = '' AND art.publish_status = 1  `
+	condition = `  AND  chart_permission_id  = 31  AND art.publish_status = 1  `
 	//pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN)
 	if user.CompanyId > 1 {
 		conditionActivity, e := ActivityConditioninitSql(user, condition, 0)

+ 0 - 136
services/resource_data.go

@@ -100,82 +100,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	//处理晨会精华
-	if len(meetingreviewchaptIds) > 0 {
-		//pars = make([]interface{}, 0)
-		//condition = ` AND c.id IN (` + utils.GetOrmInReplace(len(meetingreviewchaptIds)) + `)`
-		//pars = append(pars, meetingreviewchaptIds)
-
-		listrMeet, e := GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
-		if e != nil {
-			err = errors.New("GetCygxMorningMeetingReviewChapterListByIds, Err: " + e.Error())
-			return
-		}
-
-		for _, v := range listrMeet {
-			v.Content = AnnotationHtml(v.Content)
-			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
-			mapItems[fmt.Sprint("meetingreviewchapt", v.Id)].Meetingreviewchapt = v
-		}
-	}
-
-	//处理上周纪要汇总
-	if len(minutessummaryIds) > 0 {
-		pars = make([]interface{}, 0)
-		condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(minutessummaryIds)) + `)`
-		pars = append(pars, minutessummaryIds)
-
-		listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_minutes_summary", pars, 0, len(minutessummaryIds))
-		if e != nil {
-			err = errors.New("GetResourceDataList, Err: " + e.Error())
-			return
-		}
-		mapPv := GetCygxReportHistoryRecordListMap(minutessummaryIds, "szjyhz")
-		for _, v := range listresearchsummary {
-			v.Pv = mapPv[v.ArticleId]
-			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
-			mapItems[fmt.Sprint("minutessummary", v.ArticleId)].Minutessummary = v
-		}
-	}
-
-	//处理本周纪要汇总
-	if len(researchsummaryIds) > 0 {
-		pars = make([]interface{}, 0)
-		condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(researchsummaryIds)) + `)`
-		pars = append(pars, researchsummaryIds)
-
-		listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_research_summary", pars, 0, len(researchsummaryIds))
-		if e != nil {
-			err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
-			return
-		}
-		mapPv := GetCygxReportHistoryRecordListMap(researchsummaryIds, "bzyjhz")
-		for _, v := range listresearchsummary {
-			v.Pv = mapPv[v.ArticleId]
-			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
-			mapItems[fmt.Sprint("researchsummary", v.ArticleId)].Researchsummary = v
-		}
-	}
-
-	//处理产品内测
-	if len(productinteriorIds) > 0 {
-		pars = make([]interface{}, 0)
-		condition = `  AND art.status = 1 AND art.product_interior_id  IN (` + utils.GetOrmInReplace(len(productinteriorIds)) + `)`
-		pars = append(pars, productinteriorIds)
-		listProductInterior, e := models.GetCygxProductInteriorList(condition, pars, 0, len(productinteriorIds))
-		if e != nil {
-			err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
-			return
-		}
-		ProductInteriorHistoryMap := GetCygxProductInteriorHistoryListPvMap(productinteriorIds)
-		for _, v := range listProductInterior {
-			v.Body = ProductInteriorHtml(v.Body)
-			v.Pv = ProductInteriorHistoryMap[v.ProductInteriorId]
-			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
-			mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
-		}
-	}
-
 	detail, e := models.GetConfigByCode("city_img_url")
 	if e != nil {
 		err = errors.New("GetResourceDataList, Err: " + e.Error())
@@ -255,45 +179,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	//处理专项调研
-	if len(activityspecialIds) > 0 {
-		pars = make([]interface{}, 0)
-		condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
-		pars = append(pars, activityspecialIds)
-		activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
-		if e != nil {
-			err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
-			return
-		}
-
-		for _, v := range activitySpeciallist {
-			if mapChart[v.ChartPermissionName] != "" {
-				imgUrlResp = mapChart[v.ChartPermissionName]
-			}
-
-			if v.Days == 0 {
-				v.TripStatus = 1
-				v.TripImgLink = v.TripImgLink
-			} else {
-				v.TripStatus = 2
-				v.TripImgLink = v.TripImgLinkFix
-				v.ActivityTimeText = v.ActivityTimeTextByDay
-			}
-			resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
-			resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
-			if resultTimeStart.After(time.Now()) {
-				v.ActiveState = 1
-			} else if time.Now().After(resultTimeEnd) {
-				v.ActiveState = 3
-			} else {
-				v.ActiveState = 2
-			}
-			v.ImgUrl = imgUrlResp
-			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Activityspecial = v
-
-		}
-	}
-
 	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
 
 		audioIdstr := strings.Join(activityvoiceIds, ",")
@@ -383,27 +268,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	//处理报告精选
-	lenreportselectionIds := len(reportselectionIds)
-	if lenreportselectionIds > 0 {
-		pars = make([]interface{}, 0)
-		condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenreportselectionIds) + `)`
-		pars = append(pars, reportselectionIds)
-		listreportselection, e := models.GetReportSelectionList(condition, pars, 0, lenreportselectionIds)
-		if e != nil {
-			err = errors.New("GetReportSelectionList, Err: " + e.Error())
-			return
-		}
-		mapPv := GetCygxReportHistoryRecordListMap(reportselectionIds, "bgjx")
-		for _, v := range listreportselection {
-			v.Title += "(第" + v.Periods + "期)"
-			v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
-			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
-			v.Pv = mapPv[v.ArticleId]
-			mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
-		}
-	}
-
 	//处理研选专栏
 	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
 	if lenyanxuanSpecialIds > 0 {

+ 84 - 0
services/wx_pay.go

@@ -0,0 +1,84 @@
+package services
+
+import (
+	"context"
+	"fmt"
+	"github.com/wechatpay-apiv3/wechatpay-go/core"
+	"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"
+	"log"
+)
+
+const (
+	MchPKFileName              = "./utils/cret/apiclient_key.pem"
+	Mchid                      = "1624495680"
+	MchCertificateSerialNumber = "5ED2719CFAE5205763034AD80BF4B8A33533C418"
+	MchAPIv3Key                = "W1tbnzQrzQ7yRRNuQCIHjis8dgdasKVX"
+)
+
+func initUU() {
+	ExampleJsapiApiService_Prepay()
+}
+
+// 获取加解密处理
+func getWechatClient() (context.Context, *core.Client, error) {
+	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
+	mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
+	if err != nil {
+		log.Print("load merchant private key error")
+		return nil, nil, err
+	}
+	fmt.Println("mchPrivateKey", mchPrivateKey)
+	ctx := context.Background()
+	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
+	opts := []core.ClientOption{
+		option.WithWechatPayAutoAuthCipher(Mchid, MchCertificateSerialNumber, mchPrivateKey, MchAPIv3Key),
+	}
+	client, err := core.NewClient(ctx, opts...)
+	if err != nil {
+		log.Printf("new wechat pay client err:%s", err)
+		return nil, nil, err
+	}
+	return ctx, client, nil
+}
+
+func ExampleJsapiApiService_Prepay() {
+	mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
+	if err != nil {
+		log.Print("load merchant private key error")
+		return
+	}
+	ctx := context.Background()
+	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
+	opts := []core.ClientOption{
+		option.WithWechatPayAutoAuthCipher(Mchid, MchCertificateSerialNumber, mchPrivateKey, MchAPIv3Key),
+	}
+	client, err := core.NewClient(ctx, opts...)
+
+	svc := jsapi.JsapiApiService{Client: client}
+	// 得到prepay_id,以及调起支付所需的参数和签名
+	resp, result, err := svc.PrepayWithRequestPayment(ctx,
+		jsapi.PrepayRequest{
+			Appid:       core.String("wx5e3240ab90c247ac"),
+			Mchid:       core.String(Mchid),
+			Description: core.String("Image形象店-深圳腾大-QQ公仔"),
+			OutTradeNo:  core.String("1217752501201407033233368018"),
+			Attach:      core.String("自定义数据说明"),
+			NotifyUrl:   core.String("https://www.weixin.qq.com/wxpay/pay.php"),
+			Amount: &jsapi.Amount{
+				Total: core.Int64(1),
+			},
+			Payer: &jsapi.Payer{
+				Openid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
+			},
+		},
+	)
+	fmt.Println("result", result.Response)
+	fmt.Println("result", result.Request)
+	if err == nil {
+		log.Println(resp)
+	} else {
+		log.Println(err)
+	}
+}