@@ -0,0 +1,7 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type SuperCloudIssuanceBasicDao interface { | |||
GetSuperCloudIssuanceBasic() (m *models.SuperCloudIssuanceBasic, err error) | |||
} |
@@ -1,5 +1,7 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type SuperCloudIssuancePackageOrdDao interface { | |||
//TODO:: You can add specific method definitions here | |||
GetCloudIssuancePackageOrd(ordNo string) (m *models.SuperCloudIssuancePackageOrd, err error) | |||
} |
@@ -1,5 +1,7 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type SuperCloudIssuanceRobotPackageDao interface { | |||
//TODO:: You can add specific method definitions here | |||
FindSuperCloudIssuanceRobotPackage(params map[string]interface{}) (m []*models.SuperCloudIssuanceRobotPackage, err error) | |||
} |
@@ -0,0 +1,10 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type SuperCloudIssuanceUserFreeRobotRecordsDao interface { | |||
GetCloudIssuanceUserFreeRobotRecord() (m *models.SuperCloudIssuanceUserFreeRobotRecords, err error) | |||
GetCloudIssuanceUserFreeRobotRecordByRobotId(robotId int) (m *models.SuperCloudIssuanceUserFreeRobotRecords, err error) | |||
InsertCloudIssuanceUserFreeRobotRecord(m *models.SuperCloudIssuanceUserFreeRobotRecords) (id int, err error) | |||
SaveCloudIssuanceUserFreeRobotRecord(id interface{}, m *models.SuperCloudIssuanceUserFreeRobotRecords, forceColums ...string) (affected int64, err error) | |||
} |
@@ -1,5 +1,33 @@ | |||
package dao | |||
package dao | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
"time" | |||
) | |||
type SuperCloudIssuanceUserRobotBindGroupDao interface { | |||
//TODO:: You can add specific method definitions here | |||
GetSuperCloudIssuanceUserRobotBindGroup(id int) (m *models.SuperCloudIssuanceUserRobotBindGroup, err error) | |||
GetSuperCloudIssuanceUserRobotBindGroupByChatRoomId(chatRoomId string) (m *models.SuperCloudIssuanceUserRobotBindGroup, err error) | |||
InsertSuperCloudIssuanceUserRobotBindGroup(m *models.SuperCloudIssuanceUserRobotBindGroup) (id int, err error) | |||
SaveSuperCloudIssuanceUserRobotBindGroup(id interface{}, m *models.SuperCloudIssuanceUserRobotBindGroup, forceColums ...string) (affected int64, err error) | |||
DeleteSuperCloudIssuanceUserRobotBindGroup(id interface{}) (affected int64, err error) | |||
FindSuperCloudIssuanceUserRobotBindGroup() (resp []*FindCloudIssuanceUserRobotBindGroupResponse, total int64, err error) | |||
FindSuperCloudIssuanceUserRobotBindGroupByCategory(categoryId int) (m []*models.SuperCloudIssuanceUserRobotBindGroup, err error) | |||
} | |||
type FindCloudIssuanceUserRobotBindGroupResponse struct { | |||
Id int `json:"id" ` | |||
Uid int `json:"uid"` | |||
Name string `json:"name"` | |||
RobotId int `json:"robot_id"` | |||
ChatRoomId string `json:"chat_room_id"` | |||
ChatRoomOwner string `json:"chat_room_owner"` | |||
MemberCount int `json:"member_count"` | |||
BigHeadImgUrl string `json:"big_head_img_url"` | |||
SmallHeadImgUrl string `json:"small_head_img_url"` | |||
GoodsCategoryId int `json:"goods_category_id"` | |||
State int `json:"state"` | |||
GoodsCategoryName string `json:"goods_category_name"` | |||
CreateAt time.Time `json:"create_at"` | |||
UpdateAt time.Time `json:"update_at"` | |||
} |
@@ -1,5 +1,10 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type SuperCloudIssuanceUserRobotDao interface { | |||
//TODO:: You can add specific method definitions here | |||
GetSuperCloudIssuanceUserRobot() (m *models.SuperCloudIssuanceUserRobot, err error) | |||
SaveSuperCloudIssuanceUserRobot(id interface{}, m *models.SuperCloudIssuanceUserRobot, forceColums ...string) (affected int64, err error) | |||
GetCloudIssuanceUserFreeRobot() (m *models.SuperCloudIssuanceUserRobot, err error) | |||
InsertCloudIssuanceUserRobot(m *models.SuperCloudIssuanceUserRobot) (id int, err error) | |||
} |
@@ -0,0 +1,28 @@ | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
func NewSuperCloudIssuanceBasicDb(engine *xorm.Engine) dao.SuperCloudIssuanceBasicDao { | |||
return &SuperCloudIssuanceBasicDb{Db: engine} | |||
} | |||
type SuperCloudIssuanceBasicDb struct { | |||
Db *xorm.Engine | |||
} | |||
func (s SuperCloudIssuanceBasicDb) GetSuperCloudIssuanceBasic() (m *models.SuperCloudIssuanceBasic, err error) { | |||
m = new(models.SuperCloudIssuanceBasic) | |||
has, err := s.Db.Where("id >= 1").Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} |
@@ -2,13 +2,44 @@ package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"fmt" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
func NewSuperCloudIssuanceRobotPackageDb(engine *xorm.Engine) dao.SuperCloudIssuanceRobotPackageDao { | |||
return &SuperCloudIssuanceRobotPackageDb{Db: engine} | |||
} | |||
type SuperCloudIssuanceRobotPackageDb struct { | |||
Db *xorm.Engine | |||
} | |||
func NewSuperCloudIssuanceRobotPackageDb(engine *xorm.Engine) dao.SuperCloudIssuanceRobotPackageDao { | |||
return &SuperCloudIssuanceRobotPackageDb{Db: engine} | |||
func (s SuperCloudIssuanceRobotPackageDb) FindSuperCloudIssuanceRobotPackage(params map[string]interface{}) (m []*models.SuperCloudIssuanceRobotPackage, err error) { | |||
if params["key"] == nil { | |||
//查询全部数据 | |||
err := s.Db.OrderBy("sort DESC").Find(&m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
return m, nil | |||
} else { | |||
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { | |||
//指定In查询 | |||
if err := s.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil { | |||
return nil, zhios_order_relate_logx.Warn(err) | |||
} | |||
return m, nil | |||
} else { | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
err := s.Db.Where(query, params["value"]).Find(&m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
return m, nil | |||
} | |||
} | |||
} |
@@ -0,0 +1,59 @@ | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
func NewSuperCloudIssuanceUserFreeRobotRecordsDb(engine *xorm.Engine, uid int) dao.SuperCloudIssuanceUserFreeRobotRecordsDao { | |||
return &SuperCloudIssuanceUserFreeRobotRecordsDb{Db: engine, Uid: uid} | |||
} | |||
type SuperCloudIssuanceUserFreeRobotRecordsDb struct { | |||
Db *xorm.Engine `json:"model"` | |||
Uid int `json:"uid"` | |||
} | |||
func (s SuperCloudIssuanceUserFreeRobotRecordsDb) GetCloudIssuanceUserFreeRobotRecord() (m *models.SuperCloudIssuanceUserFreeRobotRecords, err error) { | |||
m = new(models.SuperCloudIssuanceUserFreeRobotRecords) | |||
has, err := s.Db.Where("uid = ?", s.Uid).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (s SuperCloudIssuanceUserFreeRobotRecordsDb) GetCloudIssuanceUserFreeRobotRecordByRobotId(robotId int) (m *models.SuperCloudIssuanceUserFreeRobotRecords, err error) { | |||
m = new(models.SuperCloudIssuanceUserFreeRobotRecords) | |||
has, err := s.Db.Where("robot_id = ?", robotId).And("uid = ?", s.Uid).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (s SuperCloudIssuanceUserFreeRobotRecordsDb) InsertCloudIssuanceUserFreeRobotRecord(m *models.SuperCloudIssuanceUserFreeRobotRecords) (id int, err error) { | |||
_, err = s.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
id = m.Id | |||
return id, nil | |||
} | |||
func (s SuperCloudIssuanceUserFreeRobotRecordsDb) SaveCloudIssuanceUserFreeRobotRecord(id interface{}, m *models.SuperCloudIssuanceUserFreeRobotRecords, forceColums ...string) (affected int64, err error) { | |||
if forceColums != nil { | |||
affected, err = s.Db.Where("id=?", id).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = s.Db.Where("id=?", id).Update(m) | |||
} | |||
return | |||
} |
@@ -1,14 +1,88 @@ | |||
package implement | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
func NewSuperCloudIssuanceUserRobotBindGroupDb(engine *xorm.Engine, uid int) dao.SuperCloudIssuanceUserRobotBindGroupDao { | |||
return &SuperCloudIssuanceUserRobotBindGroupDb{ | |||
Db: engine, | |||
Uid: uid, | |||
} | |||
} | |||
type SuperCloudIssuanceUserRobotBindGroupDb struct { | |||
Db *xorm.Engine | |||
Db *xorm.Engine `json:"model"` | |||
Uid int `json:"uid"` | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) GetSuperCloudIssuanceUserRobotBindGroup(id int) (m *models.SuperCloudIssuanceUserRobotBindGroup, err error) { | |||
m = new(models.SuperCloudIssuanceUserRobotBindGroup) | |||
has, err := s.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) GetSuperCloudIssuanceUserRobotBindGroupByChatRoomId(chatRoomId string) (m *models.SuperCloudIssuanceUserRobotBindGroup, err error) { | |||
m = new(models.SuperCloudIssuanceUserRobotBindGroup) | |||
has, err := s.Db.Where("chat_room_id =?", chatRoomId).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) InsertSuperCloudIssuanceUserRobotBindGroup(m *models.SuperCloudIssuanceUserRobotBindGroup) (id int, err error) { | |||
_, err = s.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
id = m.Id | |||
return id, nil | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) SaveSuperCloudIssuanceUserRobotBindGroup(id interface{}, m *models.SuperCloudIssuanceUserRobotBindGroup, forceColums ...string) (affected int64, err error) { | |||
if forceColums != nil { | |||
affected, err = s.Db.Where("id=?", id).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = s.Db.Where("id=?", id).Update(m) | |||
} | |||
return | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) DeleteSuperCloudIssuanceUserRobotBindGroup(id interface{}) (affected int64, err error) { | |||
_, err = s.Db.Where("id=?", id).Delete(models.SuperCloudIssuanceUserRobotBindGroup{}) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return 1, nil | |||
} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) FindSuperCloudIssuanceUserRobotBindGroup() (resp []*dao.FindCloudIssuanceUserRobotBindGroupResponse, total int64, err error) { | |||
total, err = s.Db.Table("super_cloud_issuance_user_robot_bind_group"). | |||
Join("LEFT", "super_cloud_issuance_goods_category", "super_cloud_issuance_user_robot_bind_group.goods_category_id = super_cloud_issuance_goods_category.id"). | |||
Where("super_cloud_issuance_user_robot_bind_group.uid = ?", s.Uid). | |||
OrderBy("super_cloud_issuance_user_robot_bind_group.id DESC"). | |||
Cols("super_cloud_issuance_user_robot_bind_group.*, super_cloud_issuance_goods_category.name as goods_category_name"). | |||
FindAndCount(&resp) | |||
return | |||
} | |||
func NewSuperCloudIssuanceUserRobotBindGroupDb(engine *xorm.Engine) dao.SuperCloudIssuanceUserRobotBindGroupDao { | |||
return &SuperCloudIssuanceUserRobotBindGroupDb{Db: engine} | |||
func (s SuperCloudIssuanceUserRobotBindGroupDb) FindSuperCloudIssuanceUserRobotBindGroupByCategory(categoryId int) (m []*models.SuperCloudIssuanceUserRobotBindGroup, err error) { | |||
err = s.Db.Where("uid =? AND goods_category_id =? AND state =1", s.Uid, categoryId).OrderBy("id ASC").Find(&m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
return m, nil | |||
} |
@@ -2,13 +2,83 @@ package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/super_cloud_issuance/enum" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"strconv" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
func NewSuperCloudIssuanceUserRobotDb(engine *xorm.Engine, uid int, masterId string) dao.SuperCloudIssuanceUserRobotDao { | |||
return &SuperCloudIssuanceUserRobotDb{ | |||
Db: engine, | |||
Uid: uid, | |||
MasterId: masterId, | |||
} | |||
} | |||
type SuperCloudIssuanceUserRobotDb struct { | |||
Db *xorm.Engine | |||
Db *xorm.Engine `json:"model"` | |||
Uid int `json:"uid"` | |||
MasterId string `json:"master_id"` | |||
} | |||
func (superCloudIssuanceUserRobotDb *SuperCloudIssuanceUserRobotDb) InsertCloudIssuanceUserRobot(m *models.SuperCloudIssuanceUserRobot) (id int, err error) { | |||
_, err = cloudIssuanceUserRobotDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
id = m.Id | |||
//顺便新增一份数据到总后台的 `cloud_issuance_robot_records` 表 | |||
db.CloudIssuanceRobotRecordsInsert(&model2.CloudIssuanceRobotRecords{ | |||
MasterId: cloudIssuanceUserRobotDb.MasterId, | |||
RobotId: strconv.Itoa(m.RobotId), | |||
Uid: cloudIssuanceUserRobotDb.Uid, | |||
}) | |||
return id, nil | |||
} | |||
func (superCloudIssuanceUserRobotDb *SuperCloudIssuanceUserRobotDb) GetCloudIssuanceUserFreeRobot() (m *models.SuperCloudIssuanceUserRobot, err error) { | |||
//TODO::先将所有已过期的状态改变 | |||
timeStamp := time.Now().Unix() | |||
sql := "update cloud_issuance_user_robot set is_enabled = ? where end_time <= ? and robot_kind =?" | |||
_, err = superCloudIssuanceUserRobotDb.Db.Exec(sql, 3, timeStamp, enum.ShareRobot) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
m = new(models.SuperCloudIssuanceUserRobot) | |||
has, err := superCloudIssuanceUserRobotDb.Db.Where("uid = -1"). | |||
And("robot_kind =?", enum.ShareRobot). | |||
And("is_enabled = 0").Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (superCloudIssuanceUserRobotDb *SuperCloudIssuanceUserRobotDb) GetSuperCloudIssuanceUserRobot() (m *models.SuperCloudIssuanceUserRobot, err error) { | |||
m = new(models.SuperCloudIssuanceUserRobot) | |||
has, err := superCloudIssuanceUserRobotDb.Db.Where("uid = ?", superCloudIssuanceUserRobotDb.Uid). | |||
And("is_enabled = 0").Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func NewSuperCloudIssuanceUserRobotDb(engine *xorm.Engine) dao.SuperCloudIssuanceUserRobotDao { | |||
return &SuperCloudIssuanceUserRobotDb{Db: engine} | |||
func (superCloudIssuanceUserRobotDb *SuperCloudIssuanceUserRobotDb) SaveSuperCloudIssuanceUserRobot(id interface{}, m *models.SuperCloudIssuanceUserRobot, forceColums ...string) (affected int64, err error) { | |||
if forceColums != nil { | |||
affected, err = superCloudIssuanceUserRobotDb.Db.Where("id=?", id).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = superCloudIssuanceUserRobotDb.Db.Where("id=?", id).Update(m) | |||
} | |||
return | |||
} |
@@ -3,7 +3,8 @@ package models | |||
type SuperCloudIssuanceBasic struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
IsOpenFreeAccess int `json:"is_open_free_access" xorm:"not null default 0 comment('是否开启-免费使用权限') TINYINT(3)"` | |||
FreeAccess string `json:"free_access" xorm:"not null comment('免费使用权限') TEXT"` | |||
FreeAccess int `json:"free_access" xorm:"not null comment('免费使用天数') TINYINT(3)"` | |||
MaxActivityGroupNums int `json:"max_activity_group_nums" xorm:"not null comment('最大激活群数量') TINYINT(3)"` | |||
UseAccess int `json:"use_access" xorm:"not null default 0 comment('使用权限(会员等级)') TINYINT(3)"` | |||
TimeIntervalIssuanceOnCircleOfFriends int `json:"time_interval_issuance_on_circle_of_friends" xorm:"not null default 10 comment('朋友圈发单时间间隔(分钟)') TINYINT(3)"` | |||
TimeIntervalIssuanceOnGroups int `json:"time_interval_issuance_on_groups" xorm:"not null default 10 comment('群发单时间间隔(分钟)') TINYINT(3)"` | |||
@@ -0,0 +1,11 @@ | |||
package models | |||
type SuperCloudIssuanceUserFreeRobotRecords struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('uid') INT(11)"` | |||
RobotId int `json:"robot_id" xorm:"not null default 0 comment('机器人id') INT(11)"` | |||
EndTime string `json:"end_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('过期时间') DATETIME"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1 正在使用 2已过期)') TINYINT(1)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
} |
@@ -0,0 +1,49 @@ | |||
package enum | |||
type CloudIssuanceUserRobotKind int | |||
const ( | |||
ExclusiveRobot = 1 | |||
ShareRobot = 2 | |||
) | |||
func (gt CloudIssuanceUserRobotKind) String() string { | |||
switch gt { | |||
case ExclusiveRobot: | |||
return "独享机器人" | |||
case ShareRobot: | |||
return "共享机器人" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type CloudIssuanceUserRobotType int | |||
const ( | |||
IssuingRobot = 1 | |||
ForwardRobot = 2 | |||
RebateRobot = 3 | |||
AllAroundRobot = 4 | |||
SmallRobot = 5 | |||
SendToMomentsRobot = 6 | |||
) | |||
func (gt CloudIssuanceUserRobotType) String() string { | |||
switch gt { | |||
case IssuingRobot: | |||
return "发单机器人" | |||
case ForwardRobot: | |||
return "转发机器人" | |||
case RebateRobot: | |||
return "返利机器人" | |||
case AllAroundRobot: | |||
return "全能机器人" | |||
case SmallRobot: | |||
return "小型机器人" | |||
case SendToMomentsRobot: | |||
return "发圈机器人" | |||
default: | |||
return "未知" | |||
} | |||
} |