|
@ -7,10 +7,10 @@ import ( |
|
|
activity_service "hudongzhuanjia/services/activity" |
|
|
activity_service "hudongzhuanjia/services/activity" |
|
|
pay_service "hudongzhuanjia/services/pay" |
|
|
pay_service "hudongzhuanjia/services/pay" |
|
|
ws_send_service "hudongzhuanjia/services/ws_send" |
|
|
ws_send_service "hudongzhuanjia/services/ws_send" |
|
|
|
|
|
"hudongzhuanjia/utils" |
|
|
"hudongzhuanjia/utils/code" |
|
|
"hudongzhuanjia/utils/code" |
|
|
"hudongzhuanjia/utils/define" |
|
|
"hudongzhuanjia/utils/define" |
|
|
"math/rand" |
|
|
"math/rand" |
|
|
"strings" |
|
|
|
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -65,7 +65,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { |
|
|
|
|
|
|
|
|
record := new(models.ShakeRedEnvelopeRecord) /// 之后使用, 存入乐观锁
|
|
|
record := new(models.ShakeRedEnvelopeRecord) /// 之后使用, 存入乐观锁
|
|
|
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { // 剔除摇过红包的用户
|
|
|
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT { // 剔除摇过红包的用户
|
|
|
exist, err := record.ExistRecord(activity.RehearsalId, activity.Id, rule.Id, envelope.Id, userId) |
|
|
|
|
|
|
|
|
exist, err = record.ExistRecord(activity.RehearsalId, activity.Id, rule.Id, envelope.Id, userId) |
|
|
t.CheckErr(err) |
|
|
t.CheckErr(err) |
|
|
t.Assert(!exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "您已经摇过红包了,请等待下一轮.") // 不存在继续往下走
|
|
|
t.Assert(!exist, code.MSG_SHAKERB_RECORD_NOT_EXIST, "您已经摇过红包了,请等待下一轮.") // 不存在继续往下走
|
|
|
} |
|
|
} |
|
@ -84,24 +84,18 @@ func (t *ShakeRedEnvelopeCtl) Shake() { |
|
|
t.CheckErr(err) |
|
|
t.CheckErr(err) |
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|
|
|
|
|
|
|
|
record.IsDraw = 0 |
|
|
|
|
|
// 记录红包 ---> 非彩排才能
|
|
|
// 记录红包 ---> 非彩排才能
|
|
|
if activity.RehearsalId == 0 { |
|
|
if activity.RehearsalId == 0 { |
|
|
//res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name),
|
|
|
//res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name),
|
|
|
// "", rule.Model, "摇得越快抢得越多", int(record.Amount*100), 1, 1)
|
|
|
// "", rule.Model, "摇得越快抢得越多", int(record.Amount*100), 1, 1)
|
|
|
|
|
|
|
|
|
ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":") |
|
|
|
|
|
res, err := pay_service.Transfer("欧轩互动-红包活动", ip[0], user.Openid, int(record.Amount*100)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
t.ERROR("您与红包擦肩而过", code.MSG_SHAKERB_NOT_HIT) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
record.TransferType = 1 |
|
|
|
|
|
record.TransferNo = res.PartnerTradeNo |
|
|
|
|
|
record.IsDraw = 1 |
|
|
|
|
|
|
|
|
record.TransferType = 1 // 微信转账
|
|
|
|
|
|
record.PartnerTradeNo = utils.RandomStr(32) |
|
|
|
|
|
// 加入延迟队列
|
|
|
|
|
|
pay_service.PutTransferDelayQueue("欧轩互动-红包活动", record.PartnerTradeNo, user.Openid, int(record.Amount*100), 5, 5*60) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
record.IsDraw = 1 |
|
|
record.UserId = user.Id |
|
|
record.UserId = user.Id |
|
|
record.AreaName = area.Name |
|
|
record.AreaName = area.Name |
|
|
record.Name = activity.Name |
|
|
record.Name = activity.Name |
|
@ -114,14 +108,9 @@ func (t *ShakeRedEnvelopeCtl) Shake() { |
|
|
remaining, err := new(models.ShakeRedEnvelopeRecord).Count(activity.Id, activity.RehearsalId, envelope.Id, rule.Id, -1) |
|
|
remaining, err := new(models.ShakeRedEnvelopeRecord).Count(activity.Id, activity.RehearsalId, envelope.Id, rule.Id, -1) |
|
|
t.CheckErr(err) |
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
|
customer := new(models.Customer) |
|
|
|
|
|
exist, err = models.GetById(customer, customerId) |
|
|
|
|
|
t.CheckErr(err) |
|
|
|
|
|
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|
|
|
|
|
|
|
|
|
|
|
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|
|
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|
|
define.TYPE_H5USER, userId, map[string]interface{}{ |
|
|
define.TYPE_H5USER, userId, map[string]interface{}{ |
|
|
"customer_id": customer.Id, |
|
|
|
|
|
|
|
|
"customer_id": customerId, |
|
|
"user_id": user.Id, |
|
|
"user_id": user.Id, |
|
|
"type": "shake_rb", |
|
|
"type": "shake_rb", |
|
|
"data": map[string]interface{}{ |
|
|
"data": map[string]interface{}{ |
|
@ -135,7 +124,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { |
|
|
|
|
|
|
|
|
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|
|
go ws_send_service.SendShakeRedEnvelope(fmt.Sprintf("%d", activity.Id), |
|
|
define.TYPE_CUSTOMER, customerId, map[string]interface{}{ |
|
|
define.TYPE_CUSTOMER, customerId, map[string]interface{}{ |
|
|
"customer_id": customer.Id, |
|
|
|
|
|
|
|
|
"customer_id": customerId, |
|
|
"user_id": user.Id, |
|
|
"user_id": user.Id, |
|
|
"type": "shake_rb", |
|
|
"type": "shake_rb", |
|
|
"data": map[string]interface{}{ |
|
|
"data": map[string]interface{}{ |
|
|