Browse Source

服务商红包

master
黄梓健 5 years ago
parent
commit
34e231ea0c
  1. 9
      controllers/common/im.go
  2. 2
      libs/wechat/wx.go
  3. 8
      libs/wx/wx.go
  4. 15
      log/hdzj.log
  5. 4
      models/customer_goods.go
  6. 2
      models/invitation_letter.go
  7. 14
      models/new_vote_activity_history.go
  8. 4
      models/real_sign_list.go
  9. 8
      models/reward_history.go
  10. 6
      services/pay/transfer.go
  11. 4
      test/order_test.go
  12. 6
      utils/define/define.go

9
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)
}

2
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{

8
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)
}
///

15
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 客户订单异常

4
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)"`
//// 无关变量

2
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:"更新"`

14
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('更新时间')"`
}

4
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"`

8
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
}

6
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 {

4
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)
}

6
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`

Loading…
Cancel
Save