黄梓健
5 years ago
21 changed files with 310 additions and 323 deletions
-
4controllers/client/bully_screen.go
-
46controllers/client/live.go
-
4controllers/client/reward.go
-
28controllers/pc/shake_red_envelope.go
-
37models/bully_screen_history.go
-
2models/customer_goods.go
-
7models/customer_order.go
-
1models/init_models.go
-
60models/live_config.go
-
13models/live_red_envelope_rule.go
-
53models/live_red_pack.go
-
13models/real_sign_list.go
-
42models/reward_history.go
-
9models/shake_red_envelope_record.go
-
11models/shake_red_envelope_rule.go
-
6models/user_order.go
-
4services/im/im.go
-
40services/pay/handle.go
-
155services/pay/order.go
-
12services/pay/pay_test.go
@ -1,53 +0,0 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"time" |
|||
) |
|||
|
|||
const LiveRedPackTN = TableNamePrefix + "live_red_pack" |
|||
|
|||
type LiveRedPack struct { |
|||
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` |
|||
IsDelete bool `json:"-" xorm:"not null default 0 comment('是否删除') TINYINT(1)"` |
|||
CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` |
|||
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` |
|||
|
|||
LiveRedPackInfoId int64 `json:"live_red_pack_info_id" xorm:"not null default 0 comment('红包信息id') INT(11)"` |
|||
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` |
|||
Receiver int64 `json:"receiver" xorm:"not null default 0 comment('[0未领取/非0领取用户id]') INT(11)"` |
|||
OpenId string `json:"open_id" xorm:"not null default '' comment('用户openid') VARCHAR(128)"` |
|||
Amount int `json:"amount" xorm:"not null default 0 comment('红包金额, 分') INT(18)"` |
|||
TransferType int `json:"transfer_type" xorm:"not null default 0 comment('转账方式[0微信红包1微信零钱]') TINYINT(1)"` |
|||
PartnerTradeNo string `json:"partner_trade_no" xorm:"not null default '' comment('转账单号') VARCHAR(128) "` |
|||
Status int `json:"status" xorm:"not null default 0 comment('0 未被领取 1 已被领取 2 已发送 3 出现错误') TINYINT(1)"` |
|||
Version int `json:"version" xorm:"not null version comment('乐观锁') INT(11)"` |
|||
} |
|||
|
|||
func (t LiveRedPack) TableName() string { |
|||
return LiveRedPackTN |
|||
} |
|||
|
|||
func (t *LiveRedPack) Add() (int64, error) { |
|||
return core.GetXormAuto().InsertOne(t) |
|||
} |
|||
|
|||
func (t *LiveRedPack) GetByInfoId(infoId int64) (bool, error) { |
|||
return core.GetXormAuto().Where("live_red_package_info_id=? and is_delete=0", infoId).Get(t) |
|||
} |
|||
|
|||
func (t *LiveRedPack) UpdateStatusById(id interface{}, status int) (int64, error) { |
|||
t.Status = status |
|||
return core.GetXormAuto().Where("id=?", id). |
|||
Cols("receiver, open_id, transfer_type, transfer_no, status").Update(t) |
|||
} |
|||
|
|||
func GetRedPacksByStatus(status interface{}) ([]*LiveRedPack, error) { |
|||
redPacks := make([]*LiveRedPack, 0) |
|||
err := core.GetXormAuto().Where("is_delete=0 and status=?", status).Find(&redPacks) |
|||
return redPacks, err |
|||
} |
|||
|
|||
func (t *LiveRedPack) GetByTransferNo(transferNo string) (bool, error) { |
|||
return core.GetXormAuto().Where("is_delete=0 and transfer_no=?", transferNo).Get(t) |
|||
} |
@ -0,0 +1,40 @@ |
|||
package pay_service |
|||
|
|||
import ( |
|||
"errors" |
|||
"hudongzhuanjia/libs/im" |
|||
"hudongzhuanjia/models" |
|||
im_service "hudongzhuanjia/services/im" |
|||
"time" |
|||
) |
|||
|
|||
//处理支付成功之后的回调问题
|
|||
|
|||
// 直播红包
|
|||
func Handle(order *models.UserOrder) error { |
|||
if order == nil { |
|||
return errors.New("订单信息不存在") |
|||
} |
|||
if order.GoodType == 3 { // 直播红包
|
|||
info := new(models.LiveRedEnvelopeRule) |
|||
exist, err := info.GetByOutTradeNo(order.OutTradeNo) |
|||
if err != nil || !exist { |
|||
return errors.New("直播红包信息异常") |
|||
} |
|||
|
|||
return im_service.SendNoticeByActivityId(order.ActivityId, im.NoticeLiveRedPackStart, |
|||
map[string]interface{}{ |
|||
"live_red_envelope_rule_id": info.Id, |
|||
"timestamp": time.Now().Unix(), |
|||
}) |
|||
} else if order.GoodType == 2 { // 打赏
|
|||
history := new(models.RewardHistory) |
|||
_, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0) |
|||
return err |
|||
} else if order.GoodType == 1 { // 霸屏
|
|||
history := new(models.BullyScreenHistory) |
|||
_, err := history.UpdateStatusByOutTradeNo(order.OutTradeNo, 0) |
|||
return err |
|||
} |
|||
return nil |
|||
} |
@ -1,12 +0,0 @@ |
|||
package pay_service |
|||
|
|||
import ( |
|||
"fmt" |
|||
"testing" |
|||
) |
|||
|
|||
func TestTransfer(t *testing.T) { |
|||
res, err := Transfer("欧轩互动-转账测试", "127.0.0.1", "o9XM41s_NN8Y0QK6_MbM-aYMV3TE", 1) |
|||
fmt.Println(err) |
|||
fmt.Printf("%+v\n", res) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue