shenjiachi 1ヶ月前
コミット
9ab64d6a0d
4個のファイルの変更185行の追加2行の削除
  1. +49
    -0
      app/md/im/md_send_red_package_ord.go
  2. +1
    -1
      app/svc/im/svc_customer_service.go
  3. +1
    -1
      app/svc/im/svc_emoticon.go
  4. +134
    -0
      app/svc/im/svc_send_red_package_ord.go

+ 49
- 0
app/md/im/md_send_red_package_ord.go ファイルの表示

@@ -0,0 +1,49 @@
package md

type PageSendRedPackageOrdReq struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
State int `json:"state"` //状态
Uid int `json:"uid"`
RedPacketType int `json:"red_packet_type"` //红包类型
StartTimeStart string `json:"start_time_start" example:"发送时间-起始"`
StartTimeEnd string `json:"start_time_end" example:"发送时间-截止"`
InviteCode string `json:"invite_code" example:"邀请码"` //邀请码
Phone string `json:"phone" example:"手机号"` //手机号
Nickname string `json:"nickname" example:"昵称"` //昵称
OrdNo string `json:"ord_no" example:"订单号"` //订单号
}

type PageSendRedPackageOrdResp struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
Total int64 `json:"total"`
List []struct {
Id int64 `json:"id"` //记录id
Uid int64 `json:"uid"`
Phone string `json:"ord_no" example:"订单号"`
Nickname string `json:"nickname" example:"昵称"`
AvatarUrl string `json:"avatar_url" example:"头像"`
InviteCode string `json:"invite_code" example:"邀请码"`
State int `json:"state"` // 红包状态(0:未领取 1:领取中 2:领取完 3:已过期)
Amount string `json:"amount"` // 金额
RedPacketBalanceAmount string `json:"red_packet_balance_amount" example:"红包剩余金额"` // 红包剩余金额
RedPacketType int `json:"red_packet_type" example:"红包类型"` // 红包类型
RedPacketNums string `json:"red_packet_nums" example:"红包剩余个数"` // 红包剩余个数
WaitDrawUserIds string `json:"wait_draw_user_ids" example:"待领取用户id"` // 待领取用户id
ReceivedUserIds string `json:"received_user_ids" example:"领取用户id"` // 领取用户id
ReceivedTimes string `json:"received_times" example:"已领取时间"` // 已领取时间
ReceivedUserAmount string `json:"received_user_amount" example:"已领取用户金额"` // 已领取用户金额
CreateTime string `json:"create_time" example:"创建时间"` // 创建时间
UpdateTime string `json:"update_time" example:"更新时间"` // 更新时间
} `json:"list"`
}

type RedPackageRecordsDetailResp struct {
Uid int64 `json:"uid"`
InviteCode string `json:"invite_code" example:"邀请码"`
Nickname string `json:"nickname" example:"昵称"`
AvatarUrl string `json:"avatar_url" example:"头像"`
Amount string `json:"amount"` // 金额
ReceivedTimes string `json:"received_times" example:"领取时间"` // 领取时间
}

+ 1
- 1
app/svc/im/svc_customer_service.go ファイルの表示

@@ -17,7 +17,7 @@ func PageCustomerService(req md.PageCustomerServiceReq) (err error, resp md.Page
sess.And("memo = ?", req.State)
}
var mm []*model.CustomerService
resp.Total, err = sess.Limit(req.PageSize, (req.Page-1)*req.PageSize).Asc("a.id").FindAndCount(&mm)
resp.Total, err = sess.Limit(req.PageSize, (req.Page-1)*req.PageSize).Asc("id").FindAndCount(&mm)
if err != nil {
return
}


+ 1
- 1
app/svc/im/svc_emoticon.go ファイルの表示

@@ -17,7 +17,7 @@ func PageEmoticon(req md.PageEmoticonReq) (err error, resp md.PageEmoticonResp)
sess.And("memo = ?", req.State)
}
var mm []*model.Emoticon
resp.Total, err = sess.Limit(req.PageSize, (req.Page-1)*req.PageSize).Asc("a.id").FindAndCount(&mm)
resp.Total, err = sess.Limit(req.PageSize, (req.Page-1)*req.PageSize).Desc("id").FindAndCount(&mm)
if err != nil {
return
}


+ 134
- 0
app/svc/im/svc_send_red_package_ord.go ファイルの表示

@@ -0,0 +1,134 @@
package svc

import (
"applet/app/db"
md "applet/app/md/im"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"errors"
"fmt"
"strings"
)

type PageSendRedPackageOrdJoinUser struct {
model.ImSendRedPackageOrd `xorm:"extends"`
model.User `xorm:"extends"`
}

func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md.PageSendRedPackageOrdResp) {
sess := db.DbIm.Table("im_send_red_package_ord").Where("1=1")
if req.Phone != "" {
sess.And("user.phone LIKE ?", "%"+req.Phone+"%")
}
if req.Nickname != "" {
sess.And("user.nickname LIKE ?", "%"+req.Nickname+"%")
}
if req.OrdNo != "" {
sess.And("im_send_red_package_ord.ord_no LIKE ?", "%"+req.OrdNo+"%")
}
if req.State != 0 {
sess.And("im_send_red_package_ord.state = ?", req.State)
}
if req.Uid != 0 {
sess.And("im_send_red_package_ord.uid = ?", req.Uid)
}
if req.RedPacketType != 0 {
sess.And("im_send_red_package_ord.red_packet_type = ?", req.RedPacketType)
}
if req.StartTimeStart != "" {
sess.And("im_send_red_package_ord.create_time >= ?", req.StartTimeStart)
}
if req.StartTimeEnd != "" {
sess.And("im_send_red_package_ord.create_time <= ?", req.StartTimeEnd)
}
if req.InviteCode != "" {
sess.And("user.invite_code = ?", req.InviteCode)
}
sess.Join("LEFT", "user", "im_send_red_package_ord.uid = user.id")

var mm []*PageSendRedPackageOrdJoinUser
resp.Total, err = sess.Limit(req.PageSize, (req.Page-1)*req.PageSize).Desc("im_send_red_package_ord.create_time").FindAndCount(&mm)
sql, _ := sess.LastSQL()
fmt.Println("PageSendRedPackageOrd___SQL:::", sql)
if err != nil {
return
}
resp.Page = req.Page
resp.PageSize = req.PageSize
for _, v := range mm {
resp.List = append(resp.List, struct {
Id int64 `json:"id"` //记录id
Uid int64 `json:"uid"`
Phone string `json:"ord_no" example:"订单号"`
Nickname string `json:"nickname" example:"昵称"`
AvatarUrl string `json:"avatar_url" example:"头像"`
InviteCode string `json:"invite_code" example:"邀请码"`
State int `json:"state"` // 红包状态(0:未领取 1:领取中 2:领取完 3:已过期)
Amount string `json:"amount"` // 金额
RedPacketBalanceAmount string `json:"red_packet_balance_amount" example:"红包剩余金额"` // 红包剩余金额
RedPacketType int `json:"red_packet_type" example:"红包类型"` // 红包类型
RedPacketNums string `json:"red_packet_nums" example:"红包剩余个数"` // 红包剩余个数
WaitDrawUserIds string `json:"wait_draw_user_ids" example:"待领取用户id"` // 待领取用户id
ReceivedUserIds string `json:"received_user_ids" example:"领取用户id"` // 领取用户id
ReceivedTimes string `json:"received_times" example:"已领取时间"` // 已领取时间
ReceivedUserAmount string `json:"received_user_amount" example:"已领取用户金额"` // 已领取用户金额
CreateTime string `json:"create_time" example:"创建时间"` // 创建时间
UpdateTime string `json:"update_time" example:"更新时间"` // 更新时间
}{
Id: v.ImSendRedPackageOrd.Id,
Uid: int64(v.ImSendRedPackageOrd.Uid),
Phone: v.User.Phone,
InviteCode: v.User.SystemInviteCode,
Nickname: v.User.Nickname,
AvatarUrl: v.User.Avatar,
State: v.ImSendRedPackageOrd.State,
Amount: v.ImSendRedPackageOrd.Amount,
RedPacketType: v.ImSendRedPackageOrd.RedPacketType,
WaitDrawUserIds: v.ImSendRedPackageOrd.WaitDrawUserIds,
ReceivedUserIds: v.ImSendRedPackageOrd.ReceivedUserIds,
ReceivedUserAmount: v.ImSendRedPackageOrd.ReceivedUserAmount,
CreateTime: v.ImSendRedPackageOrd.CreateTime,
UpdateTime: v.ImSendRedPackageOrd.UpdateTime,
})
}
return
}

func RedPackageRecordsDetail(redPackageId string) (err error, resp []md.RedPackageRecordsDetailResp) {
var imSendRedPackageOrd model.ImSendRedPackageOrd
has, err := db.Db.Where("`id`=?", redPackageId).Get(&imSendRedPackageOrd)
if err != nil {
return
}
if !has {
err = errors.New("红包记录不存在!")
return
}

if imSendRedPackageOrd.ReceivedUserIds != "" {
uids := strings.Split(imSendRedPackageOrd.ReceivedUserIds, ",")
receivedTimes := strings.Split(imSendRedPackageOrd.ReceivedTimes, ",")
receivedUserAmount := strings.Split(imSendRedPackageOrd.ReceivedUserAmount, ",")
var users []*model.User
err = db.Db.In("id", uids).Find(&users)
if err != nil {
return
}
var usersMap = map[string]model.User{}
for _, v := range users {
usersMap[utils.Int64ToStr(v.Id)] = *v
}
for i, v := range uids {
resp = append(resp, md.RedPackageRecordsDetailResp{
Uid: utils.StrToInt64(v),
InviteCode: usersMap[v].SystemInviteCode,
Nickname: usersMap[v].Nickname,
AvatarUrl: usersMap[v].Avatar,
Amount: receivedUserAmount[i],
ReceivedTimes: receivedTimes[i],
})
}
}

return
}

読み込み中…
キャンセル
保存