reply.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. package model
  2. import (
  3. "encoding/csv"
  4. "fmt"
  5. "time"
  6. dtmdl "go-common/app/interface/main/mcn/model/datamodel"
  7. xtime "go-common/library/time"
  8. )
  9. // Permits .
  10. type Permits struct {
  11. BasePermission uint8 `form:"base_permission" json:"base_permission" validate:"min=0,max=1"` // 基础权限
  12. DataPermission uint8 `form:"data_permission" json:"data_permission" validate:"min=0,max=1"` // 数据权限
  13. RecPermission uint8 `form:"rec_permission" json:"rec_permission" validate:"min=0,max=1"` // 推荐权限
  14. DepartPermission uint8 `form:"depart_permission" json:"depart_permission" validate:"min=0,max=1"` // 起飞权限
  15. }
  16. // SetAttrPermitVal set struct from permission
  17. func (p *Permits) SetAttrPermitVal(val uint32) {
  18. p.BasePermission = AttrVal(val, uint(AttrBasePermitBit))
  19. p.DataPermission = AttrVal(val, uint(AttrDataPermitBit))
  20. p.RecPermission = AttrVal(val, uint(AttrRecPermitBit))
  21. p.DepartPermission = AttrVal(val, uint(AttrDepartPermitBit))
  22. }
  23. // GetAttrPermitVal .
  24. func (p *Permits) GetAttrPermitVal() (permission uint32) {
  25. permission = AttrSet(permission, p.BasePermission, uint(AttrBasePermitBit))
  26. permission = AttrSet(permission, p.DataPermission, uint(AttrDataPermitBit))
  27. permission = AttrSet(permission, p.RecPermission, uint(AttrRecPermitBit))
  28. permission = AttrSet(permission, p.DepartPermission, uint(AttrDepartPermitBit))
  29. return
  30. }
  31. // AttrSet set Permission.
  32. func AttrSet(dest uint32, bitValue uint8, bit uint) (res uint32) {
  33. res = dest&(^(1 << bit)) | (uint32(bitValue) << bit)
  34. return
  35. }
  36. // AttrVal get Permission.
  37. func AttrVal(v uint32, bit uint) uint8 {
  38. return uint8((v >> bit) & 1)
  39. }
  40. // MCNSignInfoReply .
  41. type MCNSignInfoReply struct {
  42. SignID int64 `json:"sign_id"`
  43. McnMid int64 `json:"mcn_mid"`
  44. McnName string `json:"mcn_name"`
  45. CompanyName string `json:"company_name"`
  46. CompanyLicenseID string `json:"company_license_id"`
  47. CompanyLicenseLink string `json:"company_license_link"`
  48. ContractLink string `json:"contract_link"`
  49. ContactName string `json:"contact_name"`
  50. ContactTitle string `json:"contact_title"`
  51. ContactPhone string `json:"contact_phone"`
  52. ContactIdcard string `json:"contact_idcard"`
  53. BeginDate xtime.Time `json:"begin_date"`
  54. EndDate xtime.Time `json:"end_date"`
  55. State MCNSignState `json:"state"`
  56. RejectTime xtime.Time `json:"reject_time"`
  57. RejectReason string `json:"reject_reason"`
  58. Ctime xtime.Time `json:"ctime"`
  59. Mtime xtime.Time `json:"mtime"`
  60. SignPayInfo []*SignPayInfoReply `json:"sign_pay_info"`
  61. Permission uint32 `json:"permission"`
  62. Permits *Permits `json:"permits"` // 权限集合
  63. }
  64. // AttrPermitVal get Permission all.
  65. func (n *MCNSignInfoReply) AttrPermitVal() {
  66. n.Permits = &Permits{}
  67. n.Permits.SetAttrPermitVal(n.Permission)
  68. }
  69. // MCNSignListReply .
  70. type MCNSignListReply struct {
  71. List []*MCNSignInfoReply `json:"result"`
  72. PageResult
  73. }
  74. // SignPayInfoReply .
  75. type SignPayInfoReply struct {
  76. SignPayID int64 `json:"sign_pay_id,omitempty"`
  77. McnMid int64 `json:"mcn_mid"`
  78. SignID int64 `json:"sign_id,omitempty"`
  79. State MCNPayState `json:"state"`
  80. DueDate xtime.Time `json:"due_date"`
  81. PayValue int64 `json:"pay_value"` // thousand bit
  82. }
  83. // MCNUPInfoReply .
  84. type MCNUPInfoReply struct {
  85. SignUpID int64 `json:"sign_up_id"`
  86. SignID int64 `json:"sign_id"`
  87. McnMid int64 `json:"mcn_mid"`
  88. UpMid int64 `json:"up_mid"`
  89. BeginDate xtime.Time `json:"begin_date"`
  90. EndDate xtime.Time `json:"end_date"`
  91. ContractLink string `json:"contract_link"`
  92. UpAuthLink string `json:"up_auth_link"`
  93. RejectTime xtime.Time `json:"reject_time"`
  94. RejectReason string `json:"reject_reason"`
  95. State MCNUPState `json:"state"`
  96. StateChangeTime xtime.Time `json:"state_change_time"`
  97. Ctime xtime.Time `json:"ctime"`
  98. Mtime xtime.Time `json:"mtime"`
  99. UpName string `json:"up_name"`
  100. McnName string `json:"mcn_name"`
  101. ActiveTid int16 `json:"active_tid"`
  102. TpName string `json:"type_name"`
  103. FansCount int64 `json:"fans_count"`
  104. FansCountActive int64 `json:"fans_count_active"`
  105. FansIncreaseAccumulate int64 `json:"fans_increase_accumulate"`
  106. ArchiveCount int64 `json:"archive_count"`
  107. PlayCount int64 `json:"play_count"`
  108. UPType int8 `json:"up_type"`
  109. SiteLink string `json:"site_link"`
  110. ConfirmTime xtime.Time `json:"confirm_time"`
  111. PubPrice int64 `json:"publication_price"`
  112. Permission uint32 `json:"permission"`
  113. Permits *Permits `json:"permits"` // 权限集合
  114. }
  115. // AttrPermitVal get Permission all.
  116. func (n *MCNUPInfoReply) AttrPermitVal() {
  117. n.Permits = &Permits{}
  118. n.Permits.SetAttrPermitVal(n.Permission)
  119. }
  120. // MCNUPReviewListReply .
  121. type MCNUPReviewListReply struct {
  122. List []*MCNUPInfoReply `json:"result"`
  123. PageResult
  124. }
  125. // UpBaseInfo .
  126. type UpBaseInfo struct {
  127. Mid int64 `json:"mid"`
  128. FansCount int64 `json:"fans_count"`
  129. ActiveTid int16 `json:"active_tid"`
  130. ArticleCountAccumulate int64 `json:"article_count_accumulate"`
  131. }
  132. // UpPlayInfo .
  133. type UpPlayInfo struct {
  134. Mid int64 `json:"mid"`
  135. ArticleCount int64 `json:"article_count"`
  136. PlayCountAccumulate int64 `json:"play_count_accumulate"`
  137. PlayCountAverage int64 `json:"play_count_average"`
  138. }
  139. // MCNListReply struct .
  140. type MCNListReply struct {
  141. List []*MCNListOne `json:"result"`
  142. PageResult
  143. }
  144. // MCNListOne struct .
  145. type MCNListOne struct {
  146. ID int64 `json:"id"`
  147. MCNMID int64 `json:"mcn_mid"`
  148. MCNName string `json:"mcn_name"`
  149. UPCount int64 `json:"up_count"`
  150. FansCountAccumulate int64 `json:"fans_count_accumulate"`
  151. FansCountOnlineAccumulate int64 `json:"fans_count_online_accumulate"`
  152. FansCountRealAccumulate int64 `json:"fans_count_real_accumulate"`
  153. FansCountCheatAccumulate int64 `json:"fans_count_cheat_accumulate"`
  154. GenerateDate xtime.Time `json:"generate_date"`
  155. BeginDate xtime.Time `json:"begin_date"`
  156. EndDate xtime.Time `json:"end_date"`
  157. State MCNSignState `json:"state"`
  158. PayInfos []*SignPayInfoReply `json:"pay_infos"`
  159. Permission uint32 `json:"permission"`
  160. Permits *Permits `json:"permits"` // 权限集合
  161. }
  162. // AttrPermitVal get Permission all.
  163. func (n *MCNListOne) AttrPermitVal() {
  164. n.Permits = &Permits{}
  165. n.Permits.SetAttrPermitVal(n.Permission)
  166. }
  167. // MCNInfoReply struct .
  168. type MCNInfoReply struct {
  169. MCNSign
  170. UPCount int64 `json:"up_count"`
  171. ArchiveCountAccumulate int64 `json:"archive_count_accumulate"`
  172. PlayCountAccumulate int64 `json:"play_count_accumulate"`
  173. FansCountAccumulate int64 `json:"fans_count_accumulate"`
  174. FansCountOnline int64 `json:"fans_count_online"`
  175. FansCountReal int64 `json:"fans_count_real"`
  176. FansCountCheat int64 `json:"fans_count_cheat"`
  177. FansCountRealAccumulate int64 `json:"fans_count_real_accumulate"`
  178. FansCountOnlineAccumulate int64 `json:"fans_count_online_accumulate"`
  179. }
  180. // MCNUPListReply struct .
  181. type MCNUPListReply struct {
  182. List []*MCNUPInfoReply `json:"result"`
  183. PageResult
  184. }
  185. // MCNCheatReply struct .
  186. type MCNCheatReply struct {
  187. SignID int64 `json:"sign_id"`
  188. MCNMID int64 `json:"mcn_mid"`
  189. MCNName string `json:"mcn_name"`
  190. UpMID int64 `json:"up_mid"`
  191. UpName string `json:"up_name"`
  192. FansCountCheatAccumulate int64 `json:"fans_count_cheat_accumulate"`
  193. FansCountCheatIncreaseDay int64 `json:"fans_count_cheat_increase_day"`
  194. FansCountReal int64 `json:"fans_count_real"`
  195. FansCountCheatCleanedAccumulate int64 `json:"fans_count_cheat_cleaned_accumulate"`
  196. }
  197. // MCNCheatListReply struct.
  198. type MCNCheatListReply struct {
  199. List []*MCNCheatReply `json:"result"`
  200. PageResult
  201. }
  202. // MCNCheatUPReply struct .
  203. type MCNCheatUPReply struct {
  204. GenerateDate xtime.Time `json:"generate_date"`
  205. FansCountCheatIncreaseDay int64 `json:"fans_count_cheat_increase_day"`
  206. MCNMID int64 `json:"mcn_mid"`
  207. MCNName string `json:"mcn_name"`
  208. SignID int64 `json:"sign_id"`
  209. FansCountCheatAccumulate int64 `json:"fans_count_cheat_accumulate"`
  210. FansCountCheatCleanedAccumulate int64 `json:"fans_count_cheat_cleaned_accumulate"`
  211. FansCountReal int64 `json:"fans_count_real"`
  212. }
  213. // MCNCheatUPListReply struct .
  214. type MCNCheatUPListReply struct {
  215. List []*MCNCheatUPReply `json:"result"`
  216. PageResult
  217. }
  218. // MCNImportUPInfoReply struct .
  219. type MCNImportUPInfoReply struct {
  220. ID int64 `json:"id"`
  221. MCNMID int64 `json:"mcn_mid"`
  222. SignID int64 `json:"sign_id"`
  223. UpMID int64 `json:"up_mid"`
  224. UpName string `json:"up_name"`
  225. StandardFansDate int64 `json:"standard_fans_date"`
  226. StandardArchiveCount int64 `json:"standard_archive_count"`
  227. StandardFansCount int64 `json:"standard_fans_count"`
  228. IsReward int8 `json:"is_reward"`
  229. JoinTime int32 `json:"join_time"`
  230. }
  231. // MCNIncreaseReply struct .
  232. type MCNIncreaseReply struct {
  233. ID int64 `json:"id"`
  234. SignID int64 `json:"sign_id"`
  235. DataType int8 `json:"data_type"`
  236. ActiveTID int64 `json:"active_tid"`
  237. GenerateDate xtime.Time `json:"generate_date"`
  238. UPCount int64 `json:"up_count"`
  239. FansCountOnlineAccumulate int64 `json:"fans_count_online_accumulate"`
  240. FansCountRealAccumulate int64 `json:"fans_count_real_accumulate"`
  241. FansCountCheatAccumulate int64 `json:"fans_count_cheat_accumulate"`
  242. FansCountIncreaseDay int64 `json:"fans_count_increase_day"`
  243. ArchiveCountAccumulate int64 `json:"archive_count_accumulate"`
  244. ArchiveCountDay int64 `json:"archive_count_day"`
  245. PlayCountAccumulate int64 `json:"play_count_accumulate"`
  246. PlayCountIncreaseDay int64 `json:"play_count_increase_day"`
  247. FansCountAccumulate int64 `json:"fans_count_accumulate"`
  248. }
  249. // MCNIncreaseListReply struct .
  250. type MCNIncreaseListReply struct {
  251. List []*MCNIncreaseReply `json:"result"`
  252. PageResult
  253. }
  254. //GetFileName get file name
  255. func (q *MCNListReply) GetFileName() string {
  256. return fmt.Sprintf("%s_%s.csv", "MCN列表", time.Now().Format(dateTimeFmt))
  257. }
  258. //ToCsv to buffer
  259. func (q *MCNListReply) ToCsv(writer *csv.Writer) {
  260. var title = []string{
  261. "ID",
  262. "MCN_ID",
  263. "MCN_昵称",
  264. "签约UP主数",
  265. "累计粉丝数",
  266. "累计线上涨粉数",
  267. "累计实际粉丝数",
  268. "累计作弊粉丝数",
  269. "签约周期",
  270. "付款周期",
  271. "账号状态",
  272. }
  273. writer.Write(title)
  274. if q == nil {
  275. return
  276. }
  277. for _, v := range q.List {
  278. var record []string
  279. var payString string
  280. if len(v.PayInfos) > 0 {
  281. for _, pv := range v.PayInfos {
  282. payString += fmt.Sprintf("%s-%d-%s ", pv.DueDate.Time().Format(TimeFormatDay), pv.PayValue/1000, pv.State.String())
  283. }
  284. }
  285. record = append(record,
  286. intFormat(v.ID),
  287. intFormat(v.MCNMID),
  288. v.MCNName,
  289. intFormat(v.UPCount),
  290. intFormat(v.FansCountAccumulate),
  291. intFormat(v.FansCountOnlineAccumulate),
  292. intFormat(v.FansCountRealAccumulate),
  293. intFormat(v.FansCountCheatAccumulate),
  294. fmt.Sprintf("%s-%s", v.BeginDate.Time().Format(TimeFormatDay), v.EndDate.Time().Format(TimeFormatDay)),
  295. payString,
  296. v.State.String(),
  297. )
  298. writer.Write(record)
  299. }
  300. }
  301. //GetFileName get file name
  302. func (q *MCNUPListReply) GetFileName() string {
  303. return fmt.Sprintf("%s_%s.csv", "MCN UP主列表", time.Now().Format(dateTimeFmt))
  304. }
  305. //ToCsv to buffer
  306. func (q *MCNUPListReply) ToCsv(writer *csv.Writer) {
  307. var title = []string{
  308. "ID",
  309. "UP主UID",
  310. "UP主昵称",
  311. "粉丝总量",
  312. "活跃粉丝量",
  313. "粉数增长量",
  314. "稿件量",
  315. "播放量",
  316. "分区",
  317. "账号状态",
  318. "签约周期",
  319. }
  320. writer.Write(title)
  321. if q == nil {
  322. return
  323. }
  324. for _, v := range q.List {
  325. var record []string
  326. record = append(record,
  327. intFormat(v.SignUpID),
  328. intFormat(v.UpMid),
  329. v.UpName,
  330. intFormat(v.FansCount),
  331. intFormat(v.FansCountActive),
  332. intFormat(v.FansIncreaseAccumulate),
  333. intFormat(v.ArchiveCount),
  334. intFormat(v.PlayCount),
  335. v.TpName,
  336. v.State.String(),
  337. fmt.Sprintf("%s-%s", v.BeginDate.Time().Format(TimeFormatDay), v.EndDate.Time().Format(TimeFormatDay)),
  338. )
  339. writer.Write(record)
  340. }
  341. }
  342. // McnUpRecommendPool .
  343. type McnUpRecommendPool struct {
  344. ID int64 `json:"id"`
  345. UpMid int64 `json:"up_mid"`
  346. UpName string `json:"up_name"`
  347. FansCount int64 `json:"fans_count"`
  348. FansCountIncreaseMonth int64 `json:"fans_count_increase_month"`
  349. ArchiveCount int64 `json:"archive_count"`
  350. PlayCountAccumulate int64 `json:"play_count_accumulate"`
  351. PlayCountAverage int64 `json:"play_count_average"`
  352. ActiveTid int16 `json:"active_tid"`
  353. TpName string `json:"type_name"`
  354. LastArchiveTime xtime.Time `json:"last_archive_time"`
  355. State MCNUPRecommendState `json:"state"`
  356. Source MCNUPRecommendSource `json:"source"`
  357. GenerateTime xtime.Time `json:"generate_time"`
  358. Ctime xtime.Time `json:"ctime"`
  359. Mtime xtime.Time `json:"mtime"`
  360. }
  361. // McnUpRecommendListReply struct .
  362. type McnUpRecommendListReply struct {
  363. List []*McnUpRecommendPool `json:"result"`
  364. PageResult
  365. }
  366. //GetFileName get file name
  367. func (list *McnUpRecommendListReply) GetFileName() string {
  368. return fmt.Sprintf("%s_%s.csv", "MCN推荐池列表", time.Now().Format(dateTimeFmt))
  369. }
  370. //ToCsv to buffer
  371. func (list *McnUpRecommendListReply) ToCsv(writer *csv.Writer) {
  372. var title = []string{
  373. "UP主UID",
  374. "up主昵称",
  375. "粉丝量",
  376. "本月粉丝增长量",
  377. "累积播放量",
  378. "稿均播放量",
  379. "分区",
  380. "最近投稿时间",
  381. "来源",
  382. "推荐池状态",
  383. "数据更新时间",
  384. }
  385. writer.Write(title)
  386. if list == nil {
  387. return
  388. }
  389. for _, v := range list.List {
  390. var record []string
  391. record = append(record,
  392. intFormat(v.UpMid),
  393. v.UpName,
  394. intFormat(v.FansCount),
  395. intFormat(v.FansCountIncreaseMonth),
  396. intFormat(v.PlayCountAccumulate),
  397. intFormat(v.PlayCountAverage),
  398. v.TpName,
  399. v.LastArchiveTime.Time().Format(TimeFormatSec),
  400. v.Source.String(),
  401. v.State.String(),
  402. v.GenerateTime.Time().Format(TimeFormatSec),
  403. )
  404. writer.Write(record)
  405. }
  406. }
  407. // McnGetRankUpFansReply reply
  408. type McnGetRankUpFansReply struct {
  409. Result []*RankArchiveLikeInfo `json:"result"` // 按顺序进行排名
  410. TypeList []*TidnameInfo `json:"type_list"`
  411. }
  412. // GetFileName get file name
  413. func (list *McnGetRankUpFansReply) GetFileName() string {
  414. return fmt.Sprintf("%s_%s.csv", "top稿件列表", time.Now().Format(dateTimeFmt))
  415. }
  416. // ToCsv to buffer
  417. func (list *McnGetRankUpFansReply) ToCsv(writer *csv.Writer) {
  418. var title = []string{
  419. "稿件ID",
  420. "稿件标题",
  421. "UP主UID",
  422. "UP主昵称",
  423. "新增点赞数",
  424. "累积点赞数",
  425. "新增播放数",
  426. "累积播放数",
  427. "分区",
  428. "上传日期",
  429. }
  430. writer.Write(title)
  431. if list == nil {
  432. return
  433. }
  434. for _, v := range list.Result {
  435. var record []string
  436. record = append(record,
  437. intFormat(v.ArchiveID),
  438. v.ArchiveTitle,
  439. intFormat(v.Author.Mid),
  440. v.Author.Name,
  441. intFormat(v.LikesIncrease),
  442. intFormat(v.LikesAccumulate),
  443. intFormat(v.PlayIncrease),
  444. intFormat(v.PlayAccumulate),
  445. v.TidName,
  446. v.Ctime.Time().Format(TimeFormatSec),
  447. )
  448. writer.Write(record)
  449. }
  450. }
  451. // McnGetMcnFansReply reply 粉丝分析.
  452. type McnGetMcnFansReply struct {
  453. FansOverview *dtmdl.DmConMcnFansD `json:"fans_overview"` // 粉丝概况
  454. FansSex *dtmdl.DmConMcnFansSexW `json:"fans_sex"` // 粉丝性别
  455. FansAge *dtmdl.DmConMcnFansAgeW `json:"fans_age"` // 粉丝年龄
  456. FansPlayWay *dtmdl.DmConMcnFansPlayWayW `json:"fans_play_way"` // 粉丝观看途径
  457. FansArea []*dtmdl.DmConMcnFansAreaW `json:"fans_area"` // 粉丝地区分布
  458. FansType []*dtmdl.DmConMcnFansTypeW `json:"fans_type"` // 粉丝倾向分布
  459. FansTag []*dtmdl.DmConMcnFansTagW `json:"fans_tag"` // 粉丝标签地图分布
  460. }
  461. // McnUpPermissionApply .
  462. type McnUpPermissionApply struct {
  463. ID int64 `json:"id"`
  464. McnMid int64 `json:"mcn_mid"`
  465. UpMid int64 `json:"up_mid"`
  466. McnName string `json:"mcn_name"`
  467. UpName string `json:"up_name"`
  468. SignID int64 `json:"sign_id"`
  469. FansCount int64 `json:"fans_count"`
  470. UpAuthLink string `json:"up_auth_link"`
  471. ActiveTID int16 `json:"active_tid"`
  472. TypeName string `json:"type_name"`
  473. RejectReason string `json:"reject_reason"`
  474. RejectTime xtime.Time `json:"reject_time"`
  475. State MCNUPPermissionState `json:"state"`
  476. Ctime xtime.Time `json:"ctime"`
  477. Mtime xtime.Time `json:"mtime"`
  478. AdminID int64 `json:"admin_id"`
  479. AdminName string `json:"admin_name"`
  480. OldPermits *Permits `json:"old_permits"`
  481. NewPermits *Permits `json:"new_permits"`
  482. NewPermission uint32 `json:"-"`
  483. OldPermission uint32 `json:"-"`
  484. }
  485. // AttrPermitVal get Permission all.
  486. func (n *McnUpPermissionApply) AttrPermitVal() {
  487. n.OldPermits, n.NewPermits = &Permits{}, &Permits{}
  488. n.OldPermits.SetAttrPermitVal(n.OldPermission)
  489. n.NewPermits.SetAttrPermitVal(n.NewPermission)
  490. }
  491. // McnUpPermitApplyListReply struct .
  492. type McnUpPermitApplyListReply struct {
  493. List []*McnUpPermissionApply `json:"result"`
  494. PageResult
  495. }