diff --git a/config.json b/config.json index 1e77734..eba0c8a 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "port": "20181", - "host": "192.168.1.103", + "host": "127.0.0.1", "cross_domain": "*", "post_max_memory": 1024000, "api_router": "/PcClient/*", diff --git a/controllers/client/live.go b/controllers/client/live.go index dbdde91..2d07f8f 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -127,7 +127,7 @@ func (t *LiveCtl) SendLiveRedPack() { t.CheckErr(err) } - rule := models.LiveRedEnvelopeRule{} + rule := new(models.LiveRedEnvelopeRule) rule.OutTradeNo = res["out_trade_no"].(string) // 彩排为空 rule.ActivityId = activityId rule.RehearsalId = activity.RehearsalId @@ -144,7 +144,7 @@ func (t *LiveCtl) SendLiveRedPack() { } rule.UpdatedAt = time.Now() rule.CreatedAt = time.Now() - _, err = rule.Add() + _, err = models.Add(rule) t.CheckErr(err) if activity.RehearsalId != 0 { // 彩排不过钱 @@ -171,7 +171,7 @@ func (t *LiveCtl) SendLiveRedPack() { record.Amount = utils.Float64CusDecimal(float64(v)/float64(100), 2) record.CreatedAt = time.Now() record.UpdatedAt = time.Now() - _, err = record.Add() + _, err = models.Add(record) t.CheckErr(err) } diff --git a/services/red_envelope/red_envelop.go b/services/red_envelope/red_envelop.go index 80661bf..281c0fa 100644 --- a/services/red_envelope/red_envelop.go +++ b/services/red_envelope/red_envelop.go @@ -45,14 +45,14 @@ func GetCurrentRB(aid, uid, rid int64) (map[string]interface{}, error) { } const ( - MinRedPackAmount = 1 - MaxRedPackAmount = 499 + MinRedPackAmount = 30 // 分钱 + MaxRedPackAmount = 49900 // 4990 ) func GenRedPack(amount, num int) []int { r := rand.New(rand.NewSource(time.Now().UnixNano())) sumMoney := 0 - redPacks := make([]int, num) + redPacks := make([]int, 0) for i := 0; i < num; i++ { money := r.Int()*2*(amount-sumMoney)/num - i if money <= MinRedPackAmount {