Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"requestargs.go",
"sign_up.go",
],
importpath = "go-common/app/admin/main/up/model/signmodel",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/up/conf:go_default_library",
"//app/admin/main/up/dao:go_default_library",
"//app/admin/main/up/util/now:go_default_library",
"//library/log:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,87 @@
CREATE TABLE `sign_task_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '任务ID',
`mid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`sign_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
`task_template_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'sign_task模板表中的任务ID',
`task_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型 0累积 1日 2周 3月 4季度',
`task_counter` int(11) NOT NULL DEFAULT '0' COMMENT '任务计数器',
`task_condition` int(11) NOT NULL DEFAULT '0' COMMENT '任务条件',
`attribute` bigint(20) NOT NULL DEFAULT '0' COMMENT '属性位',
`task_data` varchar(1024) NOT NULL DEFAULT '' COMMENT '任务存储相关数据',
`state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态1、未完成2、完成 100、删除',
`generate_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '任务开始时间',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_task_template_id_generate_date` (`task_template_id`,`generate_date`),
KEY `ix_mid` (`mid`),
KEY `ix_sign_id` (`sign_id`),
KEY `ix_generate_date` (`generate_date`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务历史数据表';
CREATE TABLE `sign_task_absence` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`sign_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
`mid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`task_history_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'sign_task_history表中ID',
`absence_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '请假数量',
`reason` varchar(255) NOT NULL DEFAULT '' COMMENT '请假理由',
`state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
`admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '管理员id',
`admin_name` varchar(32) NOT NULL DEFAULT '' COMMENT '管理员name',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
KEY `ix_mid` (`mid`),
KEY `ix_sign_id` (`sign_id`),
KEY `ix_task_history_id` (`task_history_id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务请假表';
CREATE TABLE `sign_violation_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`sign_id` int(11) NOT NULL DEFAULT '0' COMMENT '签约id',
`mid` bigint(20) NOT NULL DEFAULT '0' COMMENT '违约人',
`admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '操作人id',
`admin_name` varchar(32) NOT NULL DEFAULT '' COMMENT '操作人名字',
`violation_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '违约原因',
`state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '违约状态 1:违约 100:删除',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
KEY `ix_sign_id` (`sign_id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '违约历史表';
#新增字段
alter table sign_task add column attribute bigint(20) not null default '0' comment '属性位';
alter table sign_task add column finish_note varchar(255) NOT NULL DEFAULT '' COMMENT '任务完成方式';
alter table sign_pay add column `in_tax` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否含税:1 不含税 2含税';
alter table sign_up add column `organization` tinyint(4) NOT NULL DEFAULT '1' COMMENT '组织属性: 1个人 2公司';
alter table sign_up add column `sign_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '签约类型: 0 其他 、1独家、2首发、3独家系列、4独家双微除外、5独家微博除外';
alter table sign_up add column `age` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '年龄';
alter table sign_up add column `residence` varchar(255) NOT NULL DEFAULT '' COMMENT '居住地';
alter table sign_up add column `id_card` varchar(20) NOT NULL DEFAULT '' COMMENT '身份证';
alter table sign_up add column `phone` varchar(16) NOT NULL DEFAULT '' COMMENT '联系方式';
alter table sign_up add column `qq` bigint(20) unsigned NOT NULL COMMENT 'qq号';
alter table sign_up add column `wechat` varchar(16) NOT NULL DEFAULT '' COMMENT '微信号';
alter table sign_up add column `is_economic` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是非签署经济约 1否 2是';
alter table sign_up add column `economic_company` varchar(16) NOT NULL DEFAULT '' COMMENT '签约的经济公司';
alter table sign_up add column `task_state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '任务完成度: 1 未完成 2 已完成';
alter table sign_up add column `wechat` varchar(16) NOT NULL DEFAULT '' COMMENT '微信号';
alter table sign_up add column `leave_times` int(11) NOT NULL COMMENT '请假次数';
alter table sign_up add column `violation_times` int(11) NOT NULL COMMENT '违约次数';
alter table sign_up add column `active_tid` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT 'up所属主分区';
#新增索引
ALTER TABLE sign_up ADD INDEX ix_active_tid(`active_tid`);
ALTER TABLE sign_up ADD INDEX ix_sex(`sex`);
ALTER TABLE sign_up ADD INDEX ix_country(`country`);
ALTER TABLE sign_up ADD INDEX ix_task_state(`task_state`);
ALTER TABLE sign_up ADD INDEX ix_sign_type(`sign_type`);
alter table sign_up add `economic_begin` date NOT NULL DEFAULT '0000-00-00' COMMENT '经济约的签约开始时间';
alter table sign_up add `economic_end` date NOT NULL DEFAULT '0000-00-00' COMMENT '经济约的签约结束时间';

View File

@ -0,0 +1,538 @@
package signmodel
import (
"fmt"
"net/url"
"strings"
"time"
"go-common/app/admin/main/up/conf"
"go-common/app/admin/main/up/dao"
xtime "go-common/library/time"
)
// const .
const (
SignUpList = 0
SignUpDetail = 1
)
// -------------------------------------------------
// CommonResponse result
type CommonResponse struct {
}
// CommonArg arg
type CommonArg struct {
}
// SignUpBaseInfo struct
type SignUpBaseInfo struct {
ID int64 `json:"id"`
Name string `json:"name"`
Sex int8 `json:"sex"`
Mid int64 `json:"mid"`
BeginDate xtime.Time `json:"begin_date"`
EndDate xtime.Time `json:"end_date"`
State int8 `json:"state"`
Country string `json:"country"`
Province string `json:"province"`
City string `json:"city"`
Note string `json:"note"`
TypeName string `json:"type_name"`
ActiveTid int16 `json:"active_tid"`
AdminID int `json:"admin_id"`
AdminName string `json:"admin_name"`
CreateTime xtime.Time `json:"create_time"`
Organization int8 `json:"organization"`
SignType int8 `json:"sign_type"`
Age int8 `json:"age"`
Residence string `json:"residence"`
IDCard string `json:"id_card"`
Phone string `json:"phone"`
QQ int64 `json:"qq"`
Wechat string `json:"wechat"`
IsEconomic int8 `json:"is_economic"`
EconomicCompany string `json:"economic_company"`
EconomicBegin xtime.Time `json:"economic_begin"`
EconomicEnd xtime.Time `json:"economic_end"`
ViolationTimes int `json:"violation_times"`
LeaveTimes int `json:"leave_times"`
}
// CopyTo copy
func (s *SignUpBaseInfo) CopyTo(dbstruct *SignUp) {
dbstruct.ID = s.ID
dbstruct.Mid = s.Mid
dbstruct.Sex = s.Sex
dbstruct.BeginDate = s.BeginDate
dbstruct.EndDate = s.EndDate
dbstruct.Country = s.Country
dbstruct.Province = s.Province
dbstruct.City = s.City
dbstruct.Note = s.Note
dbstruct.AdminID = s.AdminID
dbstruct.AdminName = s.AdminName
dbstruct.Organization = s.Organization
dbstruct.SignType = s.SignType
dbstruct.Age = s.Age
dbstruct.Residence = s.Residence
dbstruct.IDCard = s.IDCard
dbstruct.Phone = s.Phone
dbstruct.QQ = s.QQ
dbstruct.Wechat = s.Wechat
dbstruct.IsEconomic = s.IsEconomic
if s.IsEconomic == ContainEconomic {
dbstruct.EconomicCompany = s.EconomicCompany
dbstruct.EconomicBegin = s.EconomicBegin
dbstruct.EconomicEnd = s.EconomicEnd
}
}
// CopyFrom copy
func (s *SignUpBaseInfo) CopyFrom(dbstruct *SignUp) {
s.ID = dbstruct.ID
s.Mid = dbstruct.Mid
s.Sex = dbstruct.Sex
s.BeginDate = dbstruct.BeginDate
s.EndDate = dbstruct.EndDate
s.Country = dbstruct.Country
s.Province = dbstruct.Province
s.City = dbstruct.City
s.Note = dbstruct.Note
s.AdminID = dbstruct.AdminID
s.AdminName = dbstruct.AdminName
s.Organization = dbstruct.Organization
s.SignType = dbstruct.SignType
s.Age = dbstruct.Age
s.Residence = dbstruct.Residence
s.IDCard = dbstruct.IDCard
s.Phone = dbstruct.Phone
s.QQ = dbstruct.QQ
s.Wechat = dbstruct.Wechat
s.IsEconomic = dbstruct.IsEconomic
if dbstruct.IsEconomic == ContainEconomic {
s.EconomicCompany = dbstruct.EconomicCompany
s.EconomicBegin = dbstruct.EconomicBegin
s.EconomicEnd = dbstruct.EconomicEnd
}
s.State = dbstruct.State
s.ActiveTid = dbstruct.ActiveTid
s.LeaveTimes = dbstruct.LeaveTimes
s.ViolationTimes = dbstruct.ViolationTimes
s.CreateTime = dbstruct.Ctime
}
// CopyFrom .
func (t *SignTaskHistoryArg) CopyFrom(st *SignTaskHistory, absenceCounter int) {
var taskBegin, taskEnd time.Time
taskBegin, taskEnd = GetTaskDuration(st.GenerateDate.Time(), st.TaskType)
t.TaskBegin = xtime.Time(taskBegin.Unix())
t.TaskEnd = xtime.Time(taskEnd.Unix())
t.TaskType = st.TaskType
t.TaskState = int8(st.State)
t.TaskCounter = st.TaskCounter
t.TaskCondition = st.TaskCondition
t.AbsenceCounter = absenceCounter
t.IsBusinessArchive = st.AttrVal(AttrBitIsBusinessArchive)
}
// SignUpArg struct
type SignUpArg struct {
SignUpBaseInfo
PayInfo []*SignPayInfoArg `json:"pay_info"`
TaskInfo []*SignTaskInfoArg `json:"task_info"`
ContractInfo []*SignContractInfoArg `json:"contract_info"`
}
// SignUpsArg struct
type SignUpsArg struct {
SignUpBaseInfo
TaskHistoryInfo []*SignTaskHistoryArg `json:"task_history_info"`
PayInfo []*SignPayInfoArg `json:"pay_info"`
ContractInfo []*SignContractInfoArg `json:"contract_info"`
}
// SignQueryResult result
type SignQueryResult struct {
SignBaseInfo *SignUpBaseInfo `json:"sign_base_info"`
Result []*SignUpsArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// SignTaskHistoryArg struct
type SignTaskHistoryArg struct {
TaskBegin xtime.Time `json:"task_begin"`
TaskEnd xtime.Time `json:"task_end"`
TaskType int8 `json:"task_type"`
TaskState int8 `json:"task_state"`
TaskCounter int `json:"task_counter"`
TaskCondition int `json:"task_condition"`
AbsenceCounter int `json:"absence_counter"`
IsBusinessArchive int64 `json:"is_business_archive"`
}
// ViolationArg struct
type ViolationArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
ViolationReason string `json:"violation_reason"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
OpTime xtime.Time `json:"op_time"`
State int8 `json:"state"`
}
// ViolationResult result
type ViolationResult struct {
Result []*ViolationArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// CopyTo violationArg.
func (a *ViolationArg) CopyTo(v *SignViolationHistory) {
v.SignID = a.SignID
v.Mid = a.Mid
v.AdminID = a.AdminID
v.AdminName = a.AdminName
v.ViolationReason = a.ViolationReason
}
// CopyFrom violationArg.
func (a *ViolationArg) CopyFrom(v *SignViolationHistory) {
a.ID = v.ID
a.SignID = v.SignID
a.Mid = v.Mid
a.AdminID = v.AdminID
a.AdminName = v.AdminName
a.ViolationReason = v.ViolationReason
a.OpTime = v.Mtime
a.State = v.State
}
// AbsenceArg struct
type AbsenceArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
AbsenceCount int `json:"absence_count"`
Reason string `json:"reason"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
OpTime xtime.Time `json:"op_time"`
TaskBegin xtime.Time `json:"task_begin"`
TaskEnd xtime.Time `json:"task_end"`
State int8 `json:"state"`
}
// CopyTo AbsenceArg.
func (a *AbsenceArg) CopyTo(v *SignTaskAbsence) {
v.SignID = a.SignID
v.Mid = a.Mid
v.AdminID = a.AdminID
v.AdminName = a.AdminName
v.AbsenceCount = a.AbsenceCount
v.Reason = a.Reason
}
// CopyFrom AbsenceArg.
func (a *AbsenceArg) CopyFrom(v *SignTaskAbsence) {
a.ID = v.ID
a.SignID = v.SignID
a.Mid = v.Mid
a.AdminID = v.AdminID
a.AdminName = v.AdminName
a.AbsenceCount = v.AbsenceCount
a.Reason = v.Reason
a.State = v.State
a.OpTime = v.Mtime
}
// AbsenceResult result
type AbsenceResult struct {
Result []*AbsenceArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// PageArg .
type PageArg struct {
SignID int64 `form:"sign_id"`
Page int `form:"page"`
Size int `form:"size"`
}
// IDArg .
type IDArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
AdminID int64
AdminName string
}
// PowerCheckArg .
type PowerCheckArg struct {
TIDs []int16 `form:"tids,split"`
Mid int64 `form:"mid"`
}
// PowerCheckReply .
type PowerCheckReply struct {
IsPower bool `json:"is_power"`
IsSign bool `json:"is_sign"`
}
// SignPayInfoArg =============
type SignPayInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
DueDate xtime.Time `json:"due_date"`
PayValue int64 `json:"pay_value"`
Note string `json:"note"`
State int8 `json:"state"`
InTax int8 `json:"in_tax"`
}
// CopyTo copy
func (s *SignPayInfoArg) CopyTo(dbstruct *SignPay) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.DueDate = s.DueDate
dbstruct.PayValue = s.PayValue
dbstruct.Note = s.Note
dbstruct.InTax = s.InTax
}
// CopyFrom copy
func (s *SignPayInfoArg) CopyFrom(dbstruct *SignPay) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.DueDate = dbstruct.DueDate
s.PayValue = dbstruct.PayValue
s.Note = dbstruct.Note
s.State = dbstruct.State
s.InTax = dbstruct.InTax
}
// SignTaskInfoArg =============
type SignTaskInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
TaskType int8 `json:"task_type"`
TaskCondition int `json:"task_condition"`
TaskCounter int `json:"task_counter"`
TaskState int8 `json:"task_state"`
IsBusinessArchive int64 `json:"is_business_archive"`
}
// CopyTo copy
func (s *SignTaskInfoArg) CopyTo(dbstruct *SignTask) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.TaskType = s.TaskType
dbstruct.TaskCondition = s.TaskCondition
dbstruct.AttrSet(s.IsBusinessArchive, AttrBitIsBusinessArchive)
dbstruct.TaskData = ""
}
// CopyFrom copy
func (s *SignTaskInfoArg) CopyFrom(dbstruct *SignTask) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.TaskType = dbstruct.TaskType
s.TaskCondition = dbstruct.TaskCondition
s.TaskCounter = dbstruct.TaskCounter
s.IsBusinessArchive = dbstruct.AttrVal(AttrBitIsBusinessArchive)
if s.TaskCounter >= s.TaskCondition {
s.TaskState = 1
}
}
// SignContractInfoArg =============
type SignContractInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
Filename string `json:"filename"`
Filelink string `json:"filelink"`
}
// CopyTo copy
func (s *SignContractInfoArg) CopyTo(dbstruct *SignContract) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.Filelink = BuildOrcBfsURL(s.Filelink)
dbstruct.Filename = s.Filename
}
// CopyFrom copy
func (s *SignContractInfoArg) CopyFrom(dbstruct *SignContract) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.Filelink = BuildDownloadURL(dbstruct.Filename, dbstruct.Filelink)
s.Filename = dbstruct.Filename
}
// SignQueryArg =============
type SignQueryArg struct {
Tids []int64 `form:"tids,split"` // 权限tid
Mid int64 `form:"mid"`
DueSign int8 `form:"due_sign"` // 签约即将过期
DuePay int8 `form:"due_pay"` // 支付周期即将过期
ExpireSign int8 `form:"expire_sign"` // 签约已过期
Sex int8 `form:"sex" default:"-1"`
Country []string `form:"country,split"`
ActiveTID int16 `form:"active_tid"`
SignType int8 `form:"sign_type"`
TaskState int8 `form:"task_state"`
SignBegin xtime.Time `form:"sign_begin"`
SignEnd xtime.Time `form:"sign_end"`
IsDetail int8 `form:"is_detail"` // 是否详情
Page int `form:"page"`
Size int `form:"size"`
}
// SignIDArg .
type SignIDArg struct {
ID int64 `form:"id" validate:"required"`
}
// SignPayCompleteArg ==============
type SignPayCompleteArg struct {
IDs []int64 `json:"ids"`
}
// SignPayCompleteResult result
type SignPayCompleteResult struct {
}
// SignCheckTaskArg ==============
type SignCheckTaskArg struct {
Date string `form:"date"`
}
// SignCheckExsitArg ==============
type SignCheckExsitArg struct {
Mid int64 `form:"mid"`
}
// SignCheckExsitResult result
type SignCheckExsitResult struct {
Exist bool `json:"exist"`
}
// SignOpSearchArg .
type SignOpSearchArg struct {
Mid int64 `form:"mid"`
OpID int64 `form:"oper_id"` // 操作人
SignID int64 `form:"sign_id"`
Tp int8 `form:"type" default:"2"` // 操作类型 1:新增 2:修改
Order string `form:"order" default:"ctime"`
Sort string `form:"sort" default:"desc"`
PN int `form:"page" default:"1"`
PS int `form:"size" default:"50"`
}
// BaseAuditReply .
type BaseAuditReply struct {
CTime string `json:"ctime"`
IntOne int64 `json:"int_0"`
OID int64 `json:"oid"`
Tp int8 `json:"type"`
UID int64 `json:"uid"`
UName string `json:"uname"`
ExtraData string `json:"extra_data"`
}
// BaseAuditListReply .
type BaseAuditListReply struct {
Order string `json:"order"`
Sort string `json:"sort"`
Pager *pager `json:"page"`
Result []*BaseAuditReply `json:"result"`
}
type pager struct {
Page int `json:"num"`
Size int `json:"size"`
TotalCount int `json:"total"`
}
// SignAuditReply .
type SignAuditReply struct {
CTime xtime.Time `json:"ctime"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
Tp int8 `json:"type"`
OperID int64 `json:"oper_id"`
OperName string `json:"oper_name"`
Content *SignContentReply `json:"content"`
}
// SignAuditListReply .
type SignAuditListReply struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page int `json:"page"`
Size int `json:"size"`
TotalCount int `json:"total_count"`
Result []*SignAuditReply `json:"result"`
}
// SignContentReply .
type SignContentReply struct {
New *SignUpArg `json:"new"`
Old *SignUpArg `json:"old"`
ChangeType []int8 `json:"change_type"`
}
// SignCountrysReply .
type SignCountrysReply struct {
List []string `json:"list"`
}
// SignTidsReply .
type SignTidsReply struct {
List map[int64]string `json:"list"`
}
// BuildOrcBfsURL orc bfs url.
func BuildOrcBfsURL(raw string) string {
if raw == "" {
return ""
}
ori, err := url.Parse(raw)
if err != nil {
return raw
}
values := ori.Query()
values.Del("token")
ori.RawQuery = values.Encode()
return ori.String()
}
// BuildDownloadURL .
func BuildDownloadURL(fileName string, bfsurl string) (finalurl string) {
var bfsConf = conf.Conf.BfsConf
var index = strings.LastIndex(bfsurl, "/")
if index >= 0 && index+1 < len(bfsurl) {
fileName = bfsurl[index+1:]
}
finalurl = fmt.Sprintf("%s?token=%s", bfsurl, url.QueryEscape(dao.Authorize(bfsConf.Key, bfsConf.Secret, "GET", bfsConf.Bucket, fileName, time.Now().Unix())))
return
}

View File

@ -0,0 +1,441 @@
package signmodel
import (
"strings"
"time"
"go-common/app/admin/main/up/util/now"
"go-common/library/log"
xtime "go-common/library/time"
)
const (
// TableSignPay table name
TableSignPay = "sign_pay"
// TableSignUp table name
TableSignUp = "sign_up"
// TableSignTask table name
TableSignTask = "sign_task"
// TableSignContract table name
TableSignContract = "sign_contract"
// TableSignTaskAbsence table name
TableSignTaskAbsence = "sign_task_absence"
// TableSignTaskHistory table name
TableSignTaskHistory = "sign_task_history"
// TableSignViolationHistory table name
TableSignViolationHistory = "sign_violation_history"
)
const (
// DateDefualtFromDB .
DateDefualtFromDB = -28800
// DateDefualt .
DateDefualt = "0000-00-00"
)
const (
//TaskTypeAccumulate 0
TaskTypeAccumulate = 0
//TaskTypeDay 1
TaskTypeDay = 1
//TaskTypeWeek 2
TaskTypeWeek = 2
//TaskTypeMonth 3
TaskTypeMonth = 3
//TaskTypeQuarter 4 季度
TaskTypeQuarter = 4
)
const (
//TaskStateRunning 0
TaskStateRunning = 0
//TaskStateExpire 1
TaskStateExpire = 1
//TaskStateFinish 2
TaskStateFinish = 2
)
// const .
const (
SignUpMidAdd = 1
SignUpMidUpdate = 2
)
// const 。
const (
NotContainEconomic = 1
ContainEconomic = 2
)
const (
// SignUpLogBizID 签约up信息修改日志
SignUpLogBizID int = 261
)
const (
//SignTaskStateInit init
SignTaskStateInit = 0
//SignTaskStateRunning task running
SignTaskStateRunning = 1
//SignTaskStateFinish finish
SignTaskStateFinish = 2
//SignTaskStateDelete delete
SignTaskStateDelete = 100
)
// const 变更类型.
const (
// 年龄
ChangeSexHistory = iota + 1
// 用户id
ChangeMidHistory
// 签约周期
ChangeSignDateHistory
// 地区
ChangeAreaHistory
// 组织
ChangeOrganizationHistory
// 签约类型
ChangeSignTypeHistory
// 年龄
ChangeAgeHistory
// 居住地
ChangeResidenceHistory
// 身份证
ChangeIDCardHistory
// 联系方式
ChangePhoneHistory
// QQ
ChangeQQHistory
// 微信
ChangeWechatHistory
// 经济公司
ChangeEconomicHistory
// 签约付款周期
ChangeSignPayHistory
// 签约任务
ChangeSignTaskHistory
// 签约合同
ChangeSignContractHistory
// 签约备注
ChangeSignNoteHistory
)
const (
//EmailStateNotSend 0
EmailStateNotSend = 0
//EmailStateSendSucc 1
EmailStateSendSucc = 1
)
const (
// AttrYes on
AttrYes = int64(1)
// AttrNo off
AttrNo = int64(0)
// AttrBitIsBusinessArchive bit
AttrBitIsBusinessArchive = uint(0)
)
// SignUpOnlyID struct
type SignUpOnlyID struct {
ID uint32
}
// SignUpOnlySignID struct
type SignUpOnlySignID struct {
SignID uint32
}
// SignUp struct
type SignUp struct {
ID int64
Sex int8
Mid int64
BeginDate xtime.Time
EndDate xtime.Time
State int8
Country string
Province string
City string
Note string
AdminID int
AdminName string
EmailState int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
Organization int8
SignType int8
Age int8
Residence string
IDCard string `gorm:"column:id_card"`
Phone string
QQ int64 `gorm:"column:qq"`
Wechat string `gorm:"column:wechat"`
IsEconomic int8
EconomicCompany string
EconomicBegin xtime.Time
EconomicEnd xtime.Time
TaskState int8
LeaveTimes int
ViolationTimes int
ActiveTid int16
}
// Diff .
func (su *SignUp) Diff(oriSu *SignUp, fields map[int8]struct{}) {
if oriSu.Sex != su.Sex {
fields[ChangeSexHistory] = struct{}{}
}
if oriSu.Mid != su.Mid {
fields[ChangeMidHistory] = struct{}{}
}
if oriSu.BeginDate != su.BeginDate || oriSu.EndDate != su.EndDate {
fields[ChangeSignDateHistory] = struct{}{}
}
if !strings.EqualFold(oriSu.Country, su.Country) || !strings.EqualFold(oriSu.Province, su.Province) || !strings.EqualFold(oriSu.City, su.City) {
fields[ChangeAreaHistory] = struct{}{}
}
if oriSu.Organization != su.Organization {
fields[ChangeOrganizationHistory] = struct{}{}
}
if oriSu.SignType != su.SignType {
fields[ChangeSignTypeHistory] = struct{}{}
}
if oriSu.Age != su.Age {
fields[ChangeAgeHistory] = struct{}{}
}
if oriSu.Residence != su.Residence {
fields[ChangeResidenceHistory] = struct{}{}
}
if oriSu.IDCard != su.IDCard {
fields[ChangeIDCardHistory] = struct{}{}
}
if oriSu.Phone != su.Phone {
fields[ChangePhoneHistory] = struct{}{}
}
if oriSu.QQ != su.QQ {
fields[ChangeQQHistory] = struct{}{}
}
if oriSu.Wechat != su.Wechat {
fields[ChangeWechatHistory] = struct{}{}
}
if oriSu.EconomicBegin == DateDefualtFromDB {
oriSu.EconomicBegin = 0
}
if oriSu.EconomicEnd == DateDefualtFromDB {
oriSu.EconomicEnd = 0
}
if oriSu.IsEconomic != su.IsEconomic || !strings.EqualFold(oriSu.EconomicCompany, su.EconomicCompany) ||
oriSu.EconomicBegin != su.EconomicBegin || oriSu.EconomicEnd != su.EconomicEnd {
fields[ChangeEconomicHistory] = struct{}{}
}
if !strings.EqualFold(oriSu.Note, su.Note) {
fields[ChangeSignNoteHistory] = struct{}{}
}
su.State = oriSu.State
su.EmailState = oriSu.EmailState
su.TaskState = oriSu.TaskState
su.LeaveTimes = oriSu.LeaveTimes
su.ViolationTimes = oriSu.ViolationTimes
su.ActiveTid = oriSu.ActiveTid
su.Ctime = oriSu.Ctime
}
// SignPay struct
type SignPay struct {
ID int64
Mid int64
SignID int64
DueDate xtime.Time
PayValue int64
State int8
Note string
EmailState int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
InTax int8
}
// Diff .
func (sp *SignPay) Diff(mOriSp map[int64]*SignPay, fields map[int8]struct{}) {
var (
ok bool
oriSp *SignPay
)
if oriSp, ok = mOriSp[sp.ID]; !ok {
fields[ChangeSignPayHistory] = struct{}{}
return
}
if sp.DueDate != oriSp.DueDate || sp.PayValue != oriSp.PayValue || sp.InTax != oriSp.InTax {
fields[ChangeSignPayHistory] = struct{}{}
}
sp.Mid = oriSp.Mid
sp.SignID = oriSp.SignID
sp.State = oriSp.State
sp.Note = oriSp.Note
sp.EmailState = oriSp.EmailState
sp.Ctime = oriSp.Ctime
}
// SignTask struct
type SignTask struct {
ID int64 `gorm:"column:id"`
Mid int64 `gorm:"column:mid"`
SignID int64 `gorm:"column:sign_id"`
TaskType int8 `gorm:"column:task_type"`
TaskCounter int `gorm:"column:task_counter"`
TaskCondition int `gorm:"column:task_condition"`
TaskData string `gorm:"column:task_data"`
State int8 `gorm:"column:state"`
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
Attribute int64 `gorm:"column:attribute"`
FinishNote string `gorm:"column:finish_note"`
}
// Diff .
func (st *SignTask) Diff(mOriSt map[int64]*SignTask, fields map[int8]struct{}) {
var (
ok bool
oriSt *SignTask
)
if oriSt, ok = mOriSt[st.ID]; !ok {
fields[ChangeSignTaskHistory] = struct{}{}
return
}
if st.TaskType != oriSt.TaskType || st.TaskCondition != oriSt.TaskCondition ||
st.AttrVal(AttrBitIsBusinessArchive) != oriSt.AttrVal(AttrBitIsBusinessArchive) {
fields[ChangeSignTaskHistory] = struct{}{}
}
st.Mid = oriSt.Mid
st.SignID = oriSt.SignID
st.TaskCounter = oriSt.TaskCounter
st.TaskData = oriSt.TaskData
st.State = oriSt.State
st.Ctime = oriSt.Ctime
}
// AttrVal get attribute value.
func (st *SignTask) AttrVal(bit uint) int64 {
return (st.Attribute >> bit) & int64(1)
}
// AttrSet set attribute value.
func (st *SignTask) AttrSet(v int64, bit uint) {
st.Attribute = st.Attribute&(^(1 << bit)) | (v << bit)
}
// SignTaskHistory .
type SignTaskHistory struct {
ID int64 `gorm:"column:id"`
Mid int64 `gorm:"column:mid"`
SignID int64 `gorm:"column:sign_id"`
TaskTemplateID int `gorm:"column:task_template_id"`
TaskType int8 `gorm:"column:task_type"`
TaskCounter int `gorm:"column:task_counter"`
TaskCondition int `gorm:"column:task_condition"`
TaskData string `gorm:"column:task_data"`
Attribute int64 `gorm:"column:attribute"`
State int `gorm:"column:state"`
GenerateDate xtime.Time `gorm:"column:generate_date"`
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// AttrVal get attribute value.
func (sth *SignTaskHistory) AttrVal(bit uint) int64 {
return (sth.Attribute >> bit) & int64(1)
}
// AttrSet set attribute value.
func (sth *SignTaskHistory) AttrSet(v int64, bit uint) {
sth.Attribute = sth.Attribute&(^(1 << bit)) | (v << bit)
}
//SignContract struct
type SignContract struct {
ID int64 `gorm:"column:id"`
Mid int64
SignID int64
Filename string
Filelink string
State int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// Diff .
func (sc *SignContract) Diff(mOriSc map[int64]*SignContract, fields map[int8]struct{}) {
var (
ok bool
oriSc *SignContract
)
if oriSc, ok = mOriSc[sc.ID]; !ok {
log.Error("OriSc(%d) no exsits", sc.ID)
fields[ChangeSignContractHistory] = struct{}{}
return
}
if !strings.EqualFold(sc.Filelink, oriSc.Filelink) {
log.Error("file(%s)----orc_file(%s) no exsits", sc.Filelink, oriSc.Filelink)
fields[ChangeSignContractHistory] = struct{}{}
}
if !strings.EqualFold(sc.Filename, oriSc.Filename) {
log.Error("filename(%s)----orc_filename(%s) no exsits", sc.Filename, oriSc.Filename)
fields[ChangeSignContractHistory] = struct{}{}
}
sc.Mid = oriSc.Mid
sc.SignID = oriSc.SignID
sc.State = oriSc.State
sc.Ctime = oriSc.Ctime
}
// SignTaskAbsence struct
type SignTaskAbsence struct {
ID int64 `gorm:"column:id"`
SignID int64
Mid int64
TaskHistoryID int64
AbsenceCount int
Reason string
State int8
AdminID int64
AdminName string
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// SignViolationHistory struct
type SignViolationHistory struct {
ID int64 `gorm:"column:id"`
SignID int64
Mid int64
AdminID int64
AdminName string
ViolationReason string
State int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// GetTaskDuration this will return task duration, [startDate, endDate)
func GetTaskDuration(date time.Time, taskType int8) (startDate, endDate time.Time) {
var ndate = now.New(date)
now.WeekStartDay = time.Monday
switch taskType {
case TaskTypeDay:
var begin = ndate.BeginningOfDay()
return begin, begin.AddDate(0, 0, 1)
case TaskTypeWeek:
var begin = ndate.BeginningOfWeek()
return begin, begin.AddDate(0, 0, 7)
case TaskTypeMonth:
var begin = ndate.BeginningOfMonth()
return begin, begin.AddDate(0, 1, 0)
case TaskTypeQuarter:
var begin = ndate.BeginningOfQuarter()
return begin, begin.AddDate(0, 3, 0)
}
return
}

View File

@ -0,0 +1,84 @@
# (fat 1, uat 1, prod 0)
CREATE TABLE `sign_up` (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '签约ID',
sex tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别,性别 0:保密 1:男 2:女',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
begin_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约开始时间',
end_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约结束时间',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
country varchar(16) NOT NULL DEFAULT '' COMMENT '国家',
province varchar(16) NOT NULL DEFAULT '' COMMENT '',
city varchar(16) NOT NULL DEFAULT '' COMMENT '',
note varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
ctime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
mtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (id),
KEY ix_mid (mid),
KEY ix_begin_date (begin_date),
KEY ix_end_date (end_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='签约表';
-- 付款表
CREATE TABLE sign_pay (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
due_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约结束时间',
pay_value BIGINT(20) NOT NULL DEFAULT '0' COMMENT '金额',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0未支付1已支付100删除',
note varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
ctime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
mtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (id),
KEY ix_signid (sign_id),
KEY ix_mid (mid),
KEY ix_date (due_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款表';
CREATE TABLE sign_task (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '任务ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
task_type tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型',
task_counter int(11) NOT NULL DEFAULT '0' COMMENT '任务计数器',
task_condition int(11) NOT NULL DEFAULT '0' COMMENT '任务条件',
task_data varchar(1024) NOT NULL DEFAULT '' COMMENT '任务存储相关数据', -- 任务数据比如用来存已经投过的稿件id
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常1过期100删除',
generate_date date NOT NULL DEFAULT '0000-00-00' COMMENT '任务生成时间',
ctime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
mtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (id),
KEY ix_mid (mid),
KEY ix_signid (sign_id),
KEY ix_date (generate_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务表';
-- 合同表
CREATE TABLE sign_contract (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '合同ID',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
filename varchar(255) NOT NULL DEFAULT '' COMMENT '合同名',
filelink varchar(255) NOT NULL DEFAULT '' COMMENT '文件链接地址',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
ctime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
mtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (id),
KEY ix_mid (mid),
KEY ix_signid (sign_id),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同表';
# (fat 1, uat 1, prod 1)
alter table sign_up add column admin_id int(11) not null default 0 comment '管理员id';
alter table sign_up add column admin_name varchar(32) not null default '' comment '管理员name';
# (fat 1, uat 1, prod 1) --2018.06.26
alter table sign_up add column email_state tinyint(4) not null default 0 comment '邮件发送情况0未发送1已发送过提醒邮件';
alter table sign_pay add column email_state tinyint(4) not null default 0 comment '邮件发送情况0未发送1已发送过提醒邮件';