黄梓健
5 years ago
18 changed files with 457 additions and 419 deletions
-
2controllers/client/activity.go
-
14controllers/client/bully_screen.go
-
102controllers/client/live.go
-
22controllers/client/reward.go
-
38controllers/pc/bully_screen.go
-
21controllers/pc/reward.go
-
27models/bully_screen_history.go
-
13models/live_red_pack.go
-
21models/live_red_pack_info.go
-
13models/reward_history.go
-
62models/user_order.go
-
7models/user_refund.go
-
4services/bully_reward/current.go
-
36services/bully_reward/dao.go
-
21services/bully_screen/dao.go
-
287services/pay/order.go
-
150services/pay/refund.go
@ -0,0 +1,36 @@ |
|||
package bully_reward_service |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/models" |
|||
) |
|||
|
|||
type BullyListResult struct { |
|||
Id int `json:"id"` |
|||
Content string `json:"content"` |
|||
Status int `json:"status"` |
|||
Second int `json:"second"` |
|||
} |
|||
|
|||
func GetBullyList(userId, bullyId int64) ([]*BullyListResult, error) { |
|||
list := make([]*BullyListResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.BullyScreenHistory)).Select("id, content, status, second"). |
|||
Where("is_delete=0 and user_id=? and bully_screen_server_id=? and status<> -1", userId, bullyId). |
|||
OrderBy("created_at desc").Find(&list) |
|||
return list, err |
|||
} |
|||
|
|||
type RewardListResult struct { |
|||
Id int64 `json:"id"` |
|||
Content string `json:"content"` |
|||
Amount float64 `json:"amount"` |
|||
Status int `json:"status"` |
|||
} |
|||
|
|||
func GetRewardList(userId, rewardId int64) ([]*RewardListResult, error) { |
|||
list := make([]*RewardListResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.RewardHistory)).Select("id, content, amount, status"). |
|||
Where("is_delete=0 and user_id=? and reward_server_id=? and status <> -1", userId, rewardId). |
|||
Desc("created_at").Find(&list) |
|||
return list, err |
|||
} |
@ -1,21 +0,0 @@ |
|||
package bully_screen_service |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/models" |
|||
) |
|||
|
|||
type ReviewListResult struct { |
|||
Id int `json:"id"` |
|||
Content string `json:"content"` |
|||
Status int `json:"status"` |
|||
Second int `json:"second"` |
|||
} |
|||
|
|||
func GetReviewList(uid, bssid int64) ([]*ReviewListResult, error) { |
|||
list := make([]*ReviewListResult, 0) |
|||
err := core.GetXormAuto().Table(new(models.BullyScreenHistory)).Select("id, content, status, second"). |
|||
Where("is_delete=0 and user_id=? and bully_screen_server_id=? and status<> -1", uid, bssid). |
|||
OrderBy("created_at desc").Find(&list) |
|||
return list, err |
|||
} |
@ -1,122 +1,32 @@ |
|||
package pay_service |
|||
|
|||
import ( |
|||
"errors" |
|||
core2 "github.com/chanxuehong/wechat/mch/core" |
|||
"github.com/chanxuehong/wechat/mch/pay" |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/utils" |
|||
"time" |
|||
) |
|||
|
|||
const CALLBACK_REFUND_URL = "https://api.ouxuanhudong.com/PcClient/common/WeChatOauthCtl/callbackRefund" |
|||
|
|||
func Refund(reason, outTradeNo, openId string, goodType, totalFee, refundFee int, userId, activityId int64) (*pay.RefundResponse, error) { |
|||
client, err := Client() |
|||
|
|||
outRefundNo := utils.RandomStr(64) |
|||
nonceStr := utils.RandomStr(32) |
|||
res, err := pay.Refund2(client, &pay.RefundRequest{ |
|||
TransactionId: "", |
|||
OutTradeNo: outTradeNo, |
|||
OutRefundNo: outRefundNo, |
|||
TotalFee: int64(totalFee), |
|||
RefundFee: int64(refundFee), |
|||
NonceStr: nonceStr, |
|||
SignType: core2.SignType_MD5, |
|||
RefundFeeType: "CNY", |
|||
RefundDesc: reason, |
|||
}) |
|||
//
|
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
refund := new(models.UserRefund) |
|||
refund.OutTradeNo = outTradeNo |
|||
refund.Status = 0 |
|||
refund.TotalFee = totalFee |
|||
refund.GoodType = goodType |
|||
refund.RefundDesc = reason |
|||
refund.FeeType = "CNY" |
|||
refund.OpenId = openId |
|||
refund.UserId = userId |
|||
refund.ActivityId = activityId |
|||
refund.IsDelete = false |
|||
refund.CreatedAt = time.Now() |
|||
refund.UpdatedAt = time.Now() |
|||
_, err = refund.AddUserRefund() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
return res, err |
|||
} |
|||
|
|||
func QueryRefund(outTradeNo string) (*pay.RefundQueryResponse, error) { |
|||
refund := new(models.UserRefund) |
|||
exist, err := refund.GetByOutTradeNo(outTradeNo) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
if !exist { |
|||
return nil, errors.New("不存在改笔退款") |
|||
} |
|||
|
|||
client, err := Client() |
|||
res, err := pay.RefundQuery2(client, &pay.RefundQueryRequest{ |
|||
OutTradeNo: outTradeNo, |
|||
NonceStr: utils.RandomStr(32), |
|||
SignType: core2.SignType_MD5, |
|||
}) |
|||
//请求申请退款
|
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
refund.RefundAccount = res.RefundList[0].RefundAccount |
|||
refund.RefundRecvAccount = res.RefundList[0].RefundRecvAccout |
|||
refund.RefundStatus = res.RefundList[0].RefundStatus |
|||
refund.Status = 1 |
|||
refund.SuccessTime = res.RefundList[0].RefundSuccessTime |
|||
refund.WxRefundId = res.RefundList[0].RefundId |
|||
refund.TransactionId = res.TransactionId |
|||
_, err = refund.QueryUpdate() |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
return res, nil |
|||
} |
|||
|
|||
func BatchQueryRefundByUserId(userId int64) error { |
|||
refunds := make([]*models.UserRefund, 0) |
|||
if err := core.GetXormAuto().Where("status = 0 and user_id=?", userId).Find(&refunds); err != nil { |
|||
return err |
|||
} |
|||
if err := batchQueryRefund(refunds); err != nil { |
|||
return err |
|||
} |
|||
return nil |
|||
} |
|||
func BatchQueryRefundByActivityId(activityId int64) error { |
|||
refunds := make([]*models.UserRefund, 0) |
|||
if err := core.GetXormAuto().Where("status = 0 and user_id=?", activityId).Find(&refunds); err != nil { |
|||
return err |
|||
} |
|||
if err := batchQueryRefund(refunds); err != nil { |
|||
return err |
|||
} |
|||
return nil |
|||
} |
|||
|
|||
func batchQueryRefund(refunds []*models.UserRefund) error { |
|||
for _, refund := range refunds { |
|||
_, err := QueryRefund(refund.OutTradeNo) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
} |
|||
return nil |
|||
} |
|||
//func BatchQueryRefundByUserId(userId int64) error {
|
|||
// refunds := make([]*models.UserRefund, 0)
|
|||
// if err := core.GetXormAuto().Where("status = 0 and user_id=?", userId).Find(&refunds); err != nil {
|
|||
// return err
|
|||
// }
|
|||
// if err := batchQueryRefund(refunds); err != nil {
|
|||
// return err
|
|||
// }
|
|||
// return nil
|
|||
//}
|
|||
//func BatchQueryRefundByActivityId(activityId int64) error {
|
|||
// refunds := make([]*models.UserRefund, 0)
|
|||
// if err := core.GetXormAuto().Where("status = 0 and user_id=?", activityId).Find(&refunds); err != nil {
|
|||
// return err
|
|||
// }
|
|||
// if err := batchQueryRefund(refunds); err != nil {
|
|||
// return err
|
|||
// }
|
|||
// return nil
|
|||
//}
|
|||
//
|
|||
//func batchQueryRefund(refunds []*models.UserRefund) error {
|
|||
// for _, refund := range refunds {
|
|||
// _, err := QueryRefund(refund.OutTradeNo)
|
|||
// if err != nil {
|
|||
// return err
|
|||
// }
|
|||
// }
|
|||
// return nil
|
|||
//}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue