From 34e231ea0cbbc4754c2eea3723fdb0c1481d6869 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Tue, 2 Jun 2020 10:55:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=95=86=E7=BA=A2=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/common/im.go | 9 +++++++++ libs/wechat/wx.go | 2 +- libs/wx/wx.go | 8 ++++---- log/hdzj.log | 15 +++++++++++++++ models/customer_goods.go | 4 ++-- models/invitation_letter.go | 2 +- models/new_vote_activity_history.go | 14 +++++++------- models/real_sign_list.go | 4 ++-- models/reward_history.go | 8 ++++---- services/pay/transfer.go | 6 ++++-- test/order_test.go | 4 +++- utils/define/define.go | 6 +++--- 12 files changed, 55 insertions(+), 27 deletions(-) diff --git a/controllers/common/im.go b/controllers/common/im.go index 7ef5626..bc7ec9d 100644 --- a/controllers/common/im.go +++ b/controllers/common/im.go @@ -2,8 +2,17 @@ package common import ( "hudongzhuanjia/controllers" + pay_service "hudongzhuanjia/services/pay" ) type ImTestCtl struct { controllers.BaseCtl } + +func (t *ImTestCtl) SendRB() { + scene := t.MustGetInt("scene") + res, err := pay_service.SendRedPack("欧轩测试", "o9XM41l_c27wRuc33hutRVwsQO4U", + "恭喜发财", "抢红包活动", "越抢越多", 100, 1, scene) + t.CheckErr(err) + t.JSON(res) +} diff --git a/libs/wechat/wx.go b/libs/wechat/wx.go index e5f24a1..3f50f2f 100644 --- a/libs/wechat/wx.go +++ b/libs/wechat/wx.go @@ -6,7 +6,7 @@ import ( "hudongzhuanjia/utils/define" ) -var Endpoint = mpoauth2.NewEndpoint(define.SubAppId, define.Secret) +var Endpoint = mpoauth2.NewEndpoint(define.WxAppId, define.Secret) func GetToken(code string) (*oauth2.Token, error) { client := oauth2.Client{ diff --git a/libs/wx/wx.go b/libs/wx/wx.go index 925f453..bbf790e 100644 --- a/libs/wx/wx.go +++ b/libs/wx/wx.go @@ -10,15 +10,15 @@ import ( func GetCodeUrl() string { uid := helper.CreateUUID() - return fmt.Sprintf(CodeUrl, define.SubAppId, url.PathEscape(RedirectUri), uid) + return fmt.Sprintf(CodeUrl, define.WxAppId, url.PathEscape(RedirectUri), uid) } func GetAccessTokenUrl(code string) string { - return fmt.Sprintf(AccessTokenUrl, define.SubAppId, define.Secret, code) + return fmt.Sprintf(AccessTokenUrl, define.WxAppId, define.Secret, code) } func GetRefreshTokenUrl(refreshToken string) string { - return fmt.Sprintf(RefreshTokenUrl, define.SubAppId, refreshToken) + return fmt.Sprintf(RefreshTokenUrl, define.WxAppId, refreshToken) } func GetAuthUrl(accessToken string, openid string) string { @@ -34,7 +34,7 @@ func GetTicketUrl(ticketToken string) string { } func GetTicketTokenUrl() string { - return fmt.Sprintf(TicketTokenUrl, define.SubAppId, define.Secret) + return fmt.Sprintf(TicketTokenUrl, define.WxAppId, define.Secret) } /// diff --git a/log/hdzj.log b/log/hdzj.log index 781917d..9e57413 100644 --- a/log/hdzj.log +++ b/log/hdzj.log @@ -353,3 +353,18 @@ 2020-06-01 16:26:43.296 ERROR logger/logger.go:87 客户订单异常 2020-06-01 16:26:43.296 ERROR logger/logger.go:87 客户订单异常 2020-06-01 16:26:43.296 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.639 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.639 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.676 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.676 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.676 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.676 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.679 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.683 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.683 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.687 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.687 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.687 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.688 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.688 ERROR logger/logger.go:87 客户订单异常 +2020-06-01 16:29:50.688 ERROR logger/logger.go:87 客户订单异常 diff --git a/models/customer_goods.go b/models/customer_goods.go index 6deca25..5512164 100644 --- a/models/customer_goods.go +++ b/models/customer_goods.go @@ -11,7 +11,7 @@ type CustomerGoods struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` IsDelete bool `json:"is_delete" xorm:"not null default 0 comment('是否删除') TINYINT(1)"` CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"` - UpdatedAt time.Time `json:"updated_at" xorm:"not null default 'CURRENT_TIMESTAMP' updated comment('更新时间') TIMESTAMP"` + UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"` ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"` @@ -20,7 +20,7 @@ type CustomerGoods struct { FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"` Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"` Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"` - Price float64 `json:"price" xorm:"not null default '' comment('商品单价') DECIMAL(18)"` + Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价')"` Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"` //// 无关变量 diff --git a/models/invitation_letter.go b/models/invitation_letter.go index e9075f7..e459bcb 100644 --- a/models/invitation_letter.go +++ b/models/invitation_letter.go @@ -14,7 +14,7 @@ type InvitationLetter struct { ActivityId int64 `json:"activity_id" xorm:"not null default(0) comment('主活动id') INT(11)"` InvitationId int64 `json:"invitation_id" xorm:"not null default(0) comment('邀请函id') INT(11)"` RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id') INT(11)"` - ExtraData string `json:"extra_data" xorm:"not null default(0) comment('邀请函信息') LONGTEXT"` + ExtraData string `json:"extra_data" xorm:"comment('邀请函信息') TEXT"` IsDelete bool `json:"is_delete" xorm:"default(0)" description:"删除"` CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建"` UpdatedAt time.Time `json:"updated_at" xorm:"updated" description:"更新"` diff --git a/models/new_vote_activity_history.go b/models/new_vote_activity_history.go index 20683b1..0c4e9d1 100644 --- a/models/new_vote_activity_history.go +++ b/models/new_vote_activity_history.go @@ -8,13 +8,13 @@ import ( const VoteActivityHistoryTableName = TableNamePrefix + "new_vote_activity_history" type NewVoteActivityHistory struct { - Id int64 `json:"id" xorm:"pk autoincr"` - VoteActivityId int64 `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id')"` - VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default('') comment('投票活动对象')"` - RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式')"` - UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人')"` - IsDelete bool `json:"-" xorm:"default(0) comment('删除')"` - CreatedAt time.Time `json:"-" xorm:"created comment('创建时间')"` + Id int64 `json:"id" xorm:"pk autoincr INT(11)"` + VoteActivityId int64 `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id') INT(11)"` + VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default(0) comment('投票活动对象') INT(11)"` + RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"` + UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人') INT(11)"` + IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"` + CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间')"` UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间')"` } diff --git a/models/real_sign_list.go b/models/real_sign_list.go index 5934c7b..e370ce7 100644 --- a/models/real_sign_list.go +++ b/models/real_sign_list.go @@ -11,8 +11,8 @@ const RealSignListTN = TableNamePrefix + "real_sign_list" type RealSignList struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"` - CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') TIMESTAMP"` - UpdatedAt time.Time `json:"updated_at" xorm:"not null default 'CURRENT_TIMESTAMP' updated comment('更新时间') TIMESTAMP"` + CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"` + UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"` ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"` JsonList string `json:"json_list" xorm:"not null comment('名单记录') TEXT"` diff --git a/models/reward_history.go b/models/reward_history.go index e86ea0a..be58638 100644 --- a/models/reward_history.go +++ b/models/reward_history.go @@ -11,9 +11,9 @@ const ReWardHistoryTableName = TableNamePrefix + "reward_history" //打赏历史 type RewardHistory struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` - IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除')"` - CreatedAt time.Time `json:"create_at" xorm:"not null created comment('创建时间') TIMESTAMP"` - UpdatedAt time.Time `json:"update_at" xorm:"not null default(CURRENT_TIMESTAMP) updated comment('更新时间') TIMESTAMP"` + IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"` + CreatedAt time.Time `json:"create_at" xorm:"created comment('创建时间') TIMESTAMP"` + UpdatedAt time.Time `json:"update_at" xorm:"updated comment('更新时间') TIMESTAMP"` OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('微信订单号') VARCHAR(128)"` CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"` @@ -64,7 +64,7 @@ func GetRewardHistoryByIds(ids interface{}) ([]*RewardHistory, error) { func GetExpireRewardHistory() ([]*RewardHistory, error) { result := make([]*RewardHistory, 0) - err := core.GetXormAuto().Where("is_delete=0 and status=0 and expire_time<=", time.Now().Unix()).Find(&result) + err := core.GetXormAuto().Where("is_delete=0 and status=0 and expire_time<=?", time.Now().Unix()).Find(&result) return result, err } diff --git a/services/pay/transfer.go b/services/pay/transfer.go index f424f37..fca16d7 100644 --- a/services/pay/transfer.go +++ b/services/pay/transfer.go @@ -279,8 +279,10 @@ func SendRedPack(sendName, openId, wishing, actName, remark string, totalAmount, nonceStr := utils.RandomStr(32) body := make(map[string]string, 0) - body["wxappid"] = client.AppId() body["mch_id"] = client.MchId() + body["sub_mch_id"] = client.SubMchId() + body["wxappid"] = client.AppId() + body["msgappid"] = define.WxAppId body["nonce_str"] = nonceStr body["mch_billno"] = mchBillNo body["send_name"] = sendName @@ -291,7 +293,7 @@ func SendRedPack(sendName, openId, wishing, actName, remark string, totalAmount, body["client_ip"] = define.ClientIp body["act_name"] = actName body["remark"] = remark - body["scene_id"] = fmt.Sprintf("PRODUCT_%d", scene) + //body["scene_id"] = fmt.Sprintf("PRODUCT_%d", scene) m, err := mmpaymkttransfers.SendRedPack(client, body) if err != nil { diff --git a/test/order_test.go b/test/order_test.go index f55e5e7..882317a 100644 --- a/test/order_test.go +++ b/test/order_test.go @@ -25,5 +25,7 @@ func TestRefund(t *testing.T) { } func TestApi(t *testing.T) { - + res, err := pay_service.SendRedPack("欧轩测试", "o9XM41l_c27wRuc33hutRVwsQO4U", + "恭喜发财", "抢红包活动", "越抢越多", 1, 1, 1) + fmt.Println(res, err) } diff --git a/utils/define/define.go b/utils/define/define.go index a025c86..f9ea525 100644 --- a/utils/define/define.go +++ b/utils/define/define.go @@ -91,8 +91,8 @@ var DefaultOrderNo = 10000000000 const ( // 欧轩互动 -> 普通商户 //ApiKey = `2c82c64ceec6ba89ffc9f593c671a12f` - SubAppId = `wx7b0bcf476552c5e9` - Secret = `f6aabdd40ea25272f4442603a7dc8028` + WxAppId = `wx7b0bcf476552c5e9` + Secret = `f6aabdd40ea25272f4442603a7dc8028` //AppId = `wx7b0bcf476552c5e9` //MchId = `1394404502` //SubMchId = `` @@ -100,7 +100,7 @@ const ( // 欧轩 -> 服务商 ApiKey = `6e281c8b5430c674034594cab789334F` AppId = `wx662a1633304bfd42` - //SubAppId = `wx662a1633304bfd42` + //WxAppId = `wx662a1633304bfd42` //Secret = `7e4ecfe06ad1e075c210059d5b0162a3` MchId = `1441266702` //SubMchId = `1394404502`