requestargs.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. package signmodel
  2. import (
  3. "fmt"
  4. "net/url"
  5. "strings"
  6. "time"
  7. "go-common/app/admin/main/up/conf"
  8. "go-common/app/admin/main/up/dao"
  9. xtime "go-common/library/time"
  10. )
  11. // const .
  12. const (
  13. SignUpList = 0
  14. SignUpDetail = 1
  15. )
  16. // -------------------------------------------------
  17. // CommonResponse result
  18. type CommonResponse struct {
  19. }
  20. // CommonArg arg
  21. type CommonArg struct {
  22. }
  23. // SignUpBaseInfo struct
  24. type SignUpBaseInfo struct {
  25. ID int64 `json:"id"`
  26. Name string `json:"name"`
  27. Sex int8 `json:"sex"`
  28. Mid int64 `json:"mid"`
  29. BeginDate xtime.Time `json:"begin_date"`
  30. EndDate xtime.Time `json:"end_date"`
  31. State int8 `json:"state"`
  32. Country string `json:"country"`
  33. Province string `json:"province"`
  34. City string `json:"city"`
  35. Note string `json:"note"`
  36. TypeName string `json:"type_name"`
  37. ActiveTid int16 `json:"active_tid"`
  38. AdminID int `json:"admin_id"`
  39. AdminName string `json:"admin_name"`
  40. CreateTime xtime.Time `json:"create_time"`
  41. Organization int8 `json:"organization"`
  42. SignType int8 `json:"sign_type"`
  43. Age int8 `json:"age"`
  44. Residence string `json:"residence"`
  45. IDCard string `json:"id_card"`
  46. Phone string `json:"phone"`
  47. QQ int64 `json:"qq"`
  48. Wechat string `json:"wechat"`
  49. IsEconomic int8 `json:"is_economic"`
  50. EconomicCompany string `json:"economic_company"`
  51. EconomicBegin xtime.Time `json:"economic_begin"`
  52. EconomicEnd xtime.Time `json:"economic_end"`
  53. ViolationTimes int `json:"violation_times"`
  54. LeaveTimes int `json:"leave_times"`
  55. }
  56. // CopyTo copy
  57. func (s *SignUpBaseInfo) CopyTo(dbstruct *SignUp) {
  58. dbstruct.ID = s.ID
  59. dbstruct.Mid = s.Mid
  60. dbstruct.Sex = s.Sex
  61. dbstruct.BeginDate = s.BeginDate
  62. dbstruct.EndDate = s.EndDate
  63. dbstruct.Country = s.Country
  64. dbstruct.Province = s.Province
  65. dbstruct.City = s.City
  66. dbstruct.Note = s.Note
  67. dbstruct.AdminID = s.AdminID
  68. dbstruct.AdminName = s.AdminName
  69. dbstruct.Organization = s.Organization
  70. dbstruct.SignType = s.SignType
  71. dbstruct.Age = s.Age
  72. dbstruct.Residence = s.Residence
  73. dbstruct.IDCard = s.IDCard
  74. dbstruct.Phone = s.Phone
  75. dbstruct.QQ = s.QQ
  76. dbstruct.Wechat = s.Wechat
  77. dbstruct.IsEconomic = s.IsEconomic
  78. if s.IsEconomic == ContainEconomic {
  79. dbstruct.EconomicCompany = s.EconomicCompany
  80. dbstruct.EconomicBegin = s.EconomicBegin
  81. dbstruct.EconomicEnd = s.EconomicEnd
  82. }
  83. }
  84. // CopyFrom copy
  85. func (s *SignUpBaseInfo) CopyFrom(dbstruct *SignUp) {
  86. s.ID = dbstruct.ID
  87. s.Mid = dbstruct.Mid
  88. s.Sex = dbstruct.Sex
  89. s.BeginDate = dbstruct.BeginDate
  90. s.EndDate = dbstruct.EndDate
  91. s.Country = dbstruct.Country
  92. s.Province = dbstruct.Province
  93. s.City = dbstruct.City
  94. s.Note = dbstruct.Note
  95. s.AdminID = dbstruct.AdminID
  96. s.AdminName = dbstruct.AdminName
  97. s.Organization = dbstruct.Organization
  98. s.SignType = dbstruct.SignType
  99. s.Age = dbstruct.Age
  100. s.Residence = dbstruct.Residence
  101. s.IDCard = dbstruct.IDCard
  102. s.Phone = dbstruct.Phone
  103. s.QQ = dbstruct.QQ
  104. s.Wechat = dbstruct.Wechat
  105. s.IsEconomic = dbstruct.IsEconomic
  106. if dbstruct.IsEconomic == ContainEconomic {
  107. s.EconomicCompany = dbstruct.EconomicCompany
  108. s.EconomicBegin = dbstruct.EconomicBegin
  109. s.EconomicEnd = dbstruct.EconomicEnd
  110. }
  111. s.State = dbstruct.State
  112. s.ActiveTid = dbstruct.ActiveTid
  113. s.LeaveTimes = dbstruct.LeaveTimes
  114. s.ViolationTimes = dbstruct.ViolationTimes
  115. s.CreateTime = dbstruct.Ctime
  116. }
  117. // CopyFrom .
  118. func (t *SignTaskHistoryArg) CopyFrom(st *SignTaskHistory, absenceCounter int) {
  119. var taskBegin, taskEnd time.Time
  120. taskBegin, taskEnd = GetTaskDuration(st.GenerateDate.Time(), st.TaskType)
  121. t.TaskBegin = xtime.Time(taskBegin.Unix())
  122. t.TaskEnd = xtime.Time(taskEnd.Unix())
  123. t.TaskType = st.TaskType
  124. t.TaskState = int8(st.State)
  125. t.TaskCounter = st.TaskCounter
  126. t.TaskCondition = st.TaskCondition
  127. t.AbsenceCounter = absenceCounter
  128. t.IsBusinessArchive = st.AttrVal(AttrBitIsBusinessArchive)
  129. }
  130. // SignUpArg struct
  131. type SignUpArg struct {
  132. SignUpBaseInfo
  133. PayInfo []*SignPayInfoArg `json:"pay_info"`
  134. TaskInfo []*SignTaskInfoArg `json:"task_info"`
  135. ContractInfo []*SignContractInfoArg `json:"contract_info"`
  136. }
  137. // SignUpsArg struct
  138. type SignUpsArg struct {
  139. SignUpBaseInfo
  140. TaskHistoryInfo []*SignTaskHistoryArg `json:"task_history_info"`
  141. PayInfo []*SignPayInfoArg `json:"pay_info"`
  142. ContractInfo []*SignContractInfoArg `json:"contract_info"`
  143. }
  144. // SignQueryResult result
  145. type SignQueryResult struct {
  146. SignBaseInfo *SignUpBaseInfo `json:"sign_base_info"`
  147. Result []*SignUpsArg `json:"result"`
  148. TotalCount int `json:"total_count"`
  149. Page int `json:"page"`
  150. Size int `json:"size"`
  151. }
  152. // SignTaskHistoryArg struct
  153. type SignTaskHistoryArg struct {
  154. TaskBegin xtime.Time `json:"task_begin"`
  155. TaskEnd xtime.Time `json:"task_end"`
  156. TaskType int8 `json:"task_type"`
  157. TaskState int8 `json:"task_state"`
  158. TaskCounter int `json:"task_counter"`
  159. TaskCondition int `json:"task_condition"`
  160. AbsenceCounter int `json:"absence_counter"`
  161. IsBusinessArchive int64 `json:"is_business_archive"`
  162. }
  163. // ViolationArg struct
  164. type ViolationArg struct {
  165. ID int64 `json:"id"`
  166. SignID int64 `json:"sign_id"`
  167. Mid int64 `json:"mid"`
  168. ViolationReason string `json:"violation_reason"`
  169. AdminID int64 `json:"admin_id"`
  170. AdminName string `json:"admin_name"`
  171. OpTime xtime.Time `json:"op_time"`
  172. State int8 `json:"state"`
  173. }
  174. // ViolationResult result
  175. type ViolationResult struct {
  176. Result []*ViolationArg `json:"result"`
  177. TotalCount int `json:"total_count"`
  178. Page int `json:"page"`
  179. Size int `json:"size"`
  180. }
  181. // CopyTo violationArg.
  182. func (a *ViolationArg) CopyTo(v *SignViolationHistory) {
  183. v.SignID = a.SignID
  184. v.Mid = a.Mid
  185. v.AdminID = a.AdminID
  186. v.AdminName = a.AdminName
  187. v.ViolationReason = a.ViolationReason
  188. }
  189. // CopyFrom violationArg.
  190. func (a *ViolationArg) CopyFrom(v *SignViolationHistory) {
  191. a.ID = v.ID
  192. a.SignID = v.SignID
  193. a.Mid = v.Mid
  194. a.AdminID = v.AdminID
  195. a.AdminName = v.AdminName
  196. a.ViolationReason = v.ViolationReason
  197. a.OpTime = v.Mtime
  198. a.State = v.State
  199. }
  200. // AbsenceArg struct
  201. type AbsenceArg struct {
  202. ID int64 `json:"id"`
  203. SignID int64 `json:"sign_id"`
  204. Mid int64 `json:"mid"`
  205. AbsenceCount int `json:"absence_count"`
  206. Reason string `json:"reason"`
  207. AdminID int64 `json:"admin_id"`
  208. AdminName string `json:"admin_name"`
  209. OpTime xtime.Time `json:"op_time"`
  210. TaskBegin xtime.Time `json:"task_begin"`
  211. TaskEnd xtime.Time `json:"task_end"`
  212. State int8 `json:"state"`
  213. }
  214. // CopyTo AbsenceArg.
  215. func (a *AbsenceArg) CopyTo(v *SignTaskAbsence) {
  216. v.SignID = a.SignID
  217. v.Mid = a.Mid
  218. v.AdminID = a.AdminID
  219. v.AdminName = a.AdminName
  220. v.AbsenceCount = a.AbsenceCount
  221. v.Reason = a.Reason
  222. }
  223. // CopyFrom AbsenceArg.
  224. func (a *AbsenceArg) CopyFrom(v *SignTaskAbsence) {
  225. a.ID = v.ID
  226. a.SignID = v.SignID
  227. a.Mid = v.Mid
  228. a.AdminID = v.AdminID
  229. a.AdminName = v.AdminName
  230. a.AbsenceCount = v.AbsenceCount
  231. a.Reason = v.Reason
  232. a.State = v.State
  233. a.OpTime = v.Mtime
  234. }
  235. // AbsenceResult result
  236. type AbsenceResult struct {
  237. Result []*AbsenceArg `json:"result"`
  238. TotalCount int `json:"total_count"`
  239. Page int `json:"page"`
  240. Size int `json:"size"`
  241. }
  242. // PageArg .
  243. type PageArg struct {
  244. SignID int64 `form:"sign_id"`
  245. Page int `form:"page"`
  246. Size int `form:"size"`
  247. }
  248. // IDArg .
  249. type IDArg struct {
  250. ID int64 `json:"id"`
  251. SignID int64 `json:"sign_id"`
  252. AdminID int64
  253. AdminName string
  254. }
  255. // PowerCheckArg .
  256. type PowerCheckArg struct {
  257. TIDs []int16 `form:"tids,split"`
  258. Mid int64 `form:"mid"`
  259. }
  260. // PowerCheckReply .
  261. type PowerCheckReply struct {
  262. IsPower bool `json:"is_power"`
  263. IsSign bool `json:"is_sign"`
  264. }
  265. // SignPayInfoArg =============
  266. type SignPayInfoArg struct {
  267. ID int64 `json:"id"`
  268. SignID int64 `json:"sign_id"`
  269. Mid int64 `json:"mid"`
  270. DueDate xtime.Time `json:"due_date"`
  271. PayValue int64 `json:"pay_value"`
  272. Note string `json:"note"`
  273. State int8 `json:"state"`
  274. InTax int8 `json:"in_tax"`
  275. }
  276. // CopyTo copy
  277. func (s *SignPayInfoArg) CopyTo(dbstruct *SignPay) {
  278. dbstruct.ID = s.ID
  279. dbstruct.SignID = s.SignID
  280. dbstruct.Mid = s.Mid
  281. dbstruct.DueDate = s.DueDate
  282. dbstruct.PayValue = s.PayValue
  283. dbstruct.Note = s.Note
  284. dbstruct.InTax = s.InTax
  285. }
  286. // CopyFrom copy
  287. func (s *SignPayInfoArg) CopyFrom(dbstruct *SignPay) {
  288. s.ID = dbstruct.ID
  289. s.SignID = dbstruct.SignID
  290. s.Mid = dbstruct.Mid
  291. s.DueDate = dbstruct.DueDate
  292. s.PayValue = dbstruct.PayValue
  293. s.Note = dbstruct.Note
  294. s.State = dbstruct.State
  295. s.InTax = dbstruct.InTax
  296. }
  297. // SignTaskInfoArg =============
  298. type SignTaskInfoArg struct {
  299. ID int64 `json:"id"`
  300. SignID int64 `json:"sign_id"`
  301. Mid int64 `json:"mid"`
  302. TaskType int8 `json:"task_type"`
  303. TaskCondition int `json:"task_condition"`
  304. TaskCounter int `json:"task_counter"`
  305. TaskState int8 `json:"task_state"`
  306. IsBusinessArchive int64 `json:"is_business_archive"`
  307. }
  308. // CopyTo copy
  309. func (s *SignTaskInfoArg) CopyTo(dbstruct *SignTask) {
  310. dbstruct.ID = s.ID
  311. dbstruct.SignID = s.SignID
  312. dbstruct.Mid = s.Mid
  313. dbstruct.TaskType = s.TaskType
  314. dbstruct.TaskCondition = s.TaskCondition
  315. dbstruct.AttrSet(s.IsBusinessArchive, AttrBitIsBusinessArchive)
  316. dbstruct.TaskData = ""
  317. }
  318. // CopyFrom copy
  319. func (s *SignTaskInfoArg) CopyFrom(dbstruct *SignTask) {
  320. s.ID = dbstruct.ID
  321. s.SignID = dbstruct.SignID
  322. s.Mid = dbstruct.Mid
  323. s.TaskType = dbstruct.TaskType
  324. s.TaskCondition = dbstruct.TaskCondition
  325. s.TaskCounter = dbstruct.TaskCounter
  326. s.IsBusinessArchive = dbstruct.AttrVal(AttrBitIsBusinessArchive)
  327. if s.TaskCounter >= s.TaskCondition {
  328. s.TaskState = 1
  329. }
  330. }
  331. // SignContractInfoArg =============
  332. type SignContractInfoArg struct {
  333. ID int64 `json:"id"`
  334. SignID int64 `json:"sign_id"`
  335. Mid int64 `json:"mid"`
  336. Filename string `json:"filename"`
  337. Filelink string `json:"filelink"`
  338. }
  339. // CopyTo copy
  340. func (s *SignContractInfoArg) CopyTo(dbstruct *SignContract) {
  341. dbstruct.ID = s.ID
  342. dbstruct.SignID = s.SignID
  343. dbstruct.Mid = s.Mid
  344. dbstruct.Filelink = BuildOrcBfsURL(s.Filelink)
  345. dbstruct.Filename = s.Filename
  346. }
  347. // CopyFrom copy
  348. func (s *SignContractInfoArg) CopyFrom(dbstruct *SignContract) {
  349. s.ID = dbstruct.ID
  350. s.SignID = dbstruct.SignID
  351. s.Mid = dbstruct.Mid
  352. s.Filelink = BuildDownloadURL(dbstruct.Filename, dbstruct.Filelink)
  353. s.Filename = dbstruct.Filename
  354. }
  355. // SignQueryArg =============
  356. type SignQueryArg struct {
  357. Tids []int64 `form:"tids,split"` // 权限tid
  358. Mid int64 `form:"mid"`
  359. DueSign int8 `form:"due_sign"` // 签约即将过期
  360. DuePay int8 `form:"due_pay"` // 支付周期即将过期
  361. ExpireSign int8 `form:"expire_sign"` // 签约已过期
  362. Sex int8 `form:"sex" default:"-1"`
  363. Country []string `form:"country,split"`
  364. ActiveTID int16 `form:"active_tid"`
  365. SignType int8 `form:"sign_type"`
  366. TaskState int8 `form:"task_state"`
  367. SignBegin xtime.Time `form:"sign_begin"`
  368. SignEnd xtime.Time `form:"sign_end"`
  369. IsDetail int8 `form:"is_detail"` // 是否详情
  370. Page int `form:"page"`
  371. Size int `form:"size"`
  372. }
  373. // SignIDArg .
  374. type SignIDArg struct {
  375. ID int64 `form:"id" validate:"required"`
  376. }
  377. // SignPayCompleteArg ==============
  378. type SignPayCompleteArg struct {
  379. IDs []int64 `json:"ids"`
  380. }
  381. // SignPayCompleteResult result
  382. type SignPayCompleteResult struct {
  383. }
  384. // SignCheckTaskArg ==============
  385. type SignCheckTaskArg struct {
  386. Date string `form:"date"`
  387. }
  388. // SignCheckExsitArg ==============
  389. type SignCheckExsitArg struct {
  390. Mid int64 `form:"mid"`
  391. }
  392. // SignCheckExsitResult result
  393. type SignCheckExsitResult struct {
  394. Exist bool `json:"exist"`
  395. }
  396. // SignOpSearchArg .
  397. type SignOpSearchArg struct {
  398. Mid int64 `form:"mid"`
  399. OpID int64 `form:"oper_id"` // 操作人
  400. SignID int64 `form:"sign_id"`
  401. Tp int8 `form:"type" default:"2"` // 操作类型 1:新增 2:修改
  402. Order string `form:"order" default:"ctime"`
  403. Sort string `form:"sort" default:"desc"`
  404. PN int `form:"page" default:"1"`
  405. PS int `form:"size" default:"50"`
  406. }
  407. // BaseAuditReply .
  408. type BaseAuditReply struct {
  409. CTime string `json:"ctime"`
  410. IntOne int64 `json:"int_0"`
  411. OID int64 `json:"oid"`
  412. Tp int8 `json:"type"`
  413. UID int64 `json:"uid"`
  414. UName string `json:"uname"`
  415. ExtraData string `json:"extra_data"`
  416. }
  417. // BaseAuditListReply .
  418. type BaseAuditListReply struct {
  419. Order string `json:"order"`
  420. Sort string `json:"sort"`
  421. Pager *pager `json:"page"`
  422. Result []*BaseAuditReply `json:"result"`
  423. }
  424. type pager struct {
  425. Page int `json:"num"`
  426. Size int `json:"size"`
  427. TotalCount int `json:"total"`
  428. }
  429. // SignAuditReply .
  430. type SignAuditReply struct {
  431. CTime xtime.Time `json:"ctime"`
  432. SignID int64 `json:"sign_id"`
  433. Mid int64 `json:"mid"`
  434. Tp int8 `json:"type"`
  435. OperID int64 `json:"oper_id"`
  436. OperName string `json:"oper_name"`
  437. Content *SignContentReply `json:"content"`
  438. }
  439. // SignAuditListReply .
  440. type SignAuditListReply struct {
  441. Order string `json:"order"`
  442. Sort string `json:"sort"`
  443. Page int `json:"page"`
  444. Size int `json:"size"`
  445. TotalCount int `json:"total_count"`
  446. Result []*SignAuditReply `json:"result"`
  447. }
  448. // SignContentReply .
  449. type SignContentReply struct {
  450. New *SignUpArg `json:"new"`
  451. Old *SignUpArg `json:"old"`
  452. ChangeType []int8 `json:"change_type"`
  453. }
  454. // SignCountrysReply .
  455. type SignCountrysReply struct {
  456. List []string `json:"list"`
  457. }
  458. // SignTidsReply .
  459. type SignTidsReply struct {
  460. List map[int64]string `json:"list"`
  461. }
  462. // BuildOrcBfsURL orc bfs url.
  463. func BuildOrcBfsURL(raw string) string {
  464. if raw == "" {
  465. return ""
  466. }
  467. ori, err := url.Parse(raw)
  468. if err != nil {
  469. return raw
  470. }
  471. values := ori.Query()
  472. values.Del("token")
  473. ori.RawQuery = values.Encode()
  474. return ori.String()
  475. }
  476. // BuildDownloadURL .
  477. func BuildDownloadURL(fileName string, bfsurl string) (finalurl string) {
  478. var bfsConf = conf.Conf.BfsConf
  479. var index = strings.LastIndex(bfsurl, "/")
  480. if index >= 0 && index+1 < len(bfsurl) {
  481. fileName = bfsurl[index+1:]
  482. }
  483. finalurl = fmt.Sprintf("%s?token=%s", bfsurl, url.QueryEscape(dao.Authorize(bfsConf.Key, bfsConf.Secret, "GET", bfsConf.Bucket, fileName, time.Now().Unix())))
  484. return
  485. }