Browse Source

库存

master
黄梓健 5 years ago
parent
commit
130074390e
  1. 2
      controllers/client/bully_screen.go
  2. 2
      controllers/client/live.go
  3. 2
      controllers/client/reward.go
  4. 2
      log/hdzj.log
  5. 21
      services/pay/handle.go

2
controllers/client/bully_screen.go

@ -51,7 +51,7 @@ func (t *BullyScreenCtl) PaScreen() {
res["out_trade_no"] = ""
if activity.RehearsalId == 0 {
res, err = pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id,
activityId, time.Now().Add(48*time.Hour).Unix())
activityId, time.Now().Add(1*time.Hour).Unix())
t.CheckErr(err)
}

2
controllers/client/live.go

@ -130,7 +130,7 @@ func (t *LiveCtl) SendLiveRedPack() {
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
res, err := pay_service.UnifiedOrder("欧轩互动-直播红包", user.Openid, int64(amount*100),
3, userId, activityId, time.Now().Add(24*time.Hour).Unix())
3, userId, activityId, time.Now().Add(1*time.Hour).Unix())
t.CheckErr(err)
rule := models.LiveRedEnvelopeRule{

2
controllers/client/reward.go

@ -57,7 +57,7 @@ func (t *RewardCtl) Reward() {
res["out_trade_no"] = ""
if activity.RehearsalId == 0 || _type == 1 { // 直播不用彩排
res, err = pay_service.UnifiedOrder("欧轩互动-打赏支付", user.Openid, int64(amount*100), 2,
user.Id, activityId, time.Now().Add(48*time.Hour).Unix())
user.Id, activityId, time.Now().Add(1*time.Hour).Unix())
t.CheckErr(err)
}

2
log/hdzj.log

@ -98,3 +98,5 @@
2020-05-22 15:01:42.724 ERROR logger/logger.go:87 出现错误: xml unmarsal error:EOF
2020-05-22 15:03:20.189 ERROR logger/logger.go:87 出现错误: xml unmarsal error:EOF
2020-05-22 15:06:18.656 ERROR logger/logger.go:87 微信响应次数: 1
2020-05-22 15:08:27.956 ERROR logger/logger.go:87 微信响应次数: 1
2020-05-22 15:08:56.782 ERROR logger/logger.go:87 微信响应次数: 2

21
services/pay/handle.go

@ -13,7 +13,7 @@ import (
)
func init() {
go loopUnifiedOrder()
go loopOrder()
go utils.HandleTicker(1*time.Hour, HandleReward) // 打赏24小时退款
}
@ -23,7 +23,7 @@ func PutOrderDelayQueue(order *models.UserOrder) {
orderDelayQueue <- order
}
func loopUnifiedOrder() {
func loopOrder() {
orders, err := models.GetUserOrdersByStatus(0, 3)
if err != nil {
panic(err)
@ -39,7 +39,7 @@ func loopUnifiedOrder() {
}
// 重启
time.Sleep(5 * time.Second)
loopUnifiedOrder()
loopOrder()
}()
for {
select {
@ -49,11 +49,11 @@ func loopUnifiedOrder() {
}
if order.ExpireAt <= time.Now().Unix() { // 订单超时
if order.Status == 0 {
err = Close(order.OutTradeNo) // 超时关闭订单
if err != nil {
logger.Error("订单关闭出现错误: 错误原因->", err)
}
order.Status = 5
//err = Close(order.OutTradeNo) // 超时关闭订单
//if err != nil {
// logger.Error("订单关闭出现错误: 错误原因->", err)
//}
//order.Status = 5
go HandleFailed(order)
}
continue
@ -249,6 +249,11 @@ func HandleSuccess(order *models.UserOrder) error {
func HandleFailed(order *models.UserOrder) error {
// 退还库存
if order.GoodType == 4 {
err := Close(order.OutTradeNo)
if err != nil {
err = fmt.Errorf("直播订单关闭错误: err-> %v, out_trade_no-> %+v", err, order.OutTradeNo)
return err
}
customerOrder := new(models.CustomerOrder)
exist, err := customerOrder.GetByOutTradeNO(order.OutTradeNo)
if err != nil || !exist {

Loading…
Cancel
Save