model.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. package model
  2. import (
  3. "go-common/library/time"
  4. )
  5. //allowance origin
  6. const (
  7. AllowanceNone = iota
  8. AllowanceSystemAdmin
  9. AllowanceBusinessReceive
  10. )
  11. // blance change type
  12. const (
  13. VipSalary int64 = iota + 1
  14. SystemAdminSalary
  15. Consume
  16. ConsumeFaildBack
  17. )
  18. // coupon type
  19. const (
  20. CouponVideo = iota + 1
  21. CouponCartoon
  22. CouponAllowance
  23. CouponAllowanceCode
  24. )
  25. // coupon state.
  26. const (
  27. NotUsed = iota
  28. InUse
  29. Used
  30. Expire
  31. Block
  32. )
  33. // allowance explain
  34. const (
  35. NoLimitExplain = "不限定"
  36. ScopeFmt = "仅限%s端使用"
  37. )
  38. // batch state
  39. const (
  40. BatchStateNormal int8 = iota
  41. BatchStateBlock
  42. )
  43. // batch origin
  44. const (
  45. AdminSalaryOrigin int64 = iota + 1
  46. )
  47. // allowance change type
  48. const (
  49. AllowanceSalary int8 = iota + 1
  50. AllowanceConsume
  51. AllowanceCancel
  52. AllowanceConsumeSuccess
  53. AllowanceConsumeFaild
  54. AllowanceBlock
  55. AllowanceUnBlock
  56. )
  57. // coupon_batch_info表 product_limit_renewal字段.
  58. const (
  59. ProdLimRenewalAll int8 = iota
  60. ProdLimRenewalAuto
  61. ProdLimRenewalNotAuto
  62. )
  63. // coupon_batch_info表 product_limit_renewal字段.
  64. const (
  65. None int8 = 0
  66. ProdLimMonth1 = 1
  67. ProdLimMonth3 = 3
  68. ProdLimMonth12 = 12
  69. )
  70. // ProdLimit .
  71. var (
  72. ProdLimMonthMap = map[int8]string{None: "", ProdLimMonth1: "1月", ProdLimMonth3: "3月", ProdLimMonth12: "12月"}
  73. ProdLimRenewalMap = map[int8]string{ProdLimRenewalAll: "", ProdLimRenewalAuto: "自动续期", ProdLimRenewalNotAuto: "非自动续期"}
  74. )
  75. // PageInfo common page info.
  76. type PageInfo struct {
  77. Count int `json:"count"`
  78. CurrentPage int `json:"currentPage,omitempty"`
  79. Item interface{} `json:"item"`
  80. }
  81. // CouponBatchInfo info.
  82. type CouponBatchInfo struct {
  83. ID int64 `json:"id"`
  84. AppID int64 `json:"app_id"`
  85. Name string `json:"name"`
  86. BatchToken string `json:"batch_token"`
  87. MaxCount int64 `json:"max_count"`
  88. CurrentCount int64 `json:"current_count"`
  89. StartTime int64 `json:"start_time"`
  90. ExpireTime int64 `json:"expire_time"`
  91. ExpireDay int64 `json:"expire_day"`
  92. Ver int64 `json:"ver"`
  93. Ctime time.Time `json:"ctime"`
  94. Mtime time.Time `json:"mtime"`
  95. Operator string `json:"operator"`
  96. LimitCount int64 `json:"limit_count"`
  97. FullAmount float64 `json:"full_amount"`
  98. Amount float64 `json:"amount"`
  99. State int8 `json:"state"`
  100. CouponType int8 `json:"coupon_type"`
  101. PlatformLimit string `json:"platform_limit"`
  102. ProdLimMonth int8 `json:"product_limit_month"`
  103. ProdLimRenewal int8 `json:"product_limit_Renewal"`
  104. }
  105. // ArgBatchInfo arg.
  106. type ArgBatchInfo struct {
  107. AppID int64 `form:"app_id" validate:"required,min=1,gte=1"`
  108. Name string `form:"name" validate:"required"`
  109. MaxCount int64 `form:"max_count" validate:"required,min=1,gte=1"`
  110. LimitCount int64 `form:"limit_count"`
  111. StartTime int64 `form:"start_time" validate:"required,min=1,gte=1"`
  112. ExpireTime int64 `form:"end_time" validate:"required,min=1,gte=1"`
  113. }
  114. // ArgAllowanceBatchInfo allowance arg.
  115. type ArgAllowanceBatchInfo struct {
  116. AppID int64 `form:"app_id" validate:"required,min=1,gte=1"`
  117. Name string `form:"name" validate:"required"`
  118. MaxCount int64 `form:"max_count"`
  119. LimitCount int64 `form:"limit_count"`
  120. StartTime int64 `form:"start_time"`
  121. ExpireTime int64 `form:"end_time"`
  122. ExpireDay int64 `form:"expire_day" default:"-1"`
  123. Amount float64 `form:"amount" validate:"required,min=1,gte=1"`
  124. FullAmount float64 `form:"full_amount" validate:"required,min=1,gte=1"`
  125. PlatformLimit []int64 `form:"platform_limit,split"`
  126. ProdLimMonth int8 `form:"product_limit_month"`
  127. ProdLimRenewal int8 `form:"product_limit_Renewal" validate:"gte=0,lte=2"`
  128. }
  129. // ArgAllowanceBatchInfoModify allowance modify arg.
  130. type ArgAllowanceBatchInfoModify struct {
  131. ID int64 `form:"id" validate:"required,min=1,gte=1"`
  132. AppID int64 `form:"app_id" validate:"required,min=1,gte=1"`
  133. Name string `form:"name" validate:"required"`
  134. MaxCount int64 `form:"max_count" `
  135. LimitCount int64 `form:"limit_count"`
  136. PlatformLimit []int64 `form:"platform_limit,split"`
  137. ProdLimMonth int8 `form:"product_limit_month" validate:"gte=0"`
  138. ProdLimRenewal int8 `form:"product_limit_Renewal" validate:"gte=0,lte=2"`
  139. }
  140. // ArgAllowance arg.
  141. type ArgAllowance struct {
  142. ID int64 `form:"id" validate:"required,min=1,gte=1"`
  143. }
  144. // ArgAllowanceInfo arg.
  145. type ArgAllowanceInfo struct {
  146. BatchToken string `form:"batch_token" validate:"required"`
  147. }
  148. // ArgAllowanceSalary allowance salary arg.
  149. type ArgAllowanceSalary struct {
  150. Mids []int64 `form:"mids,split"`
  151. BatchToken string `form:"batch_token" validate:"required"`
  152. MsgType string `form:"msg_type" default:"vip"`
  153. }
  154. // ArgAllowanceState arg.
  155. type ArgAllowanceState struct {
  156. Mid int64 `form:"mid" validate:"required,min=1,gte=1"`
  157. CouponToken string `form:"coupon_token" validate:"required"`
  158. }
  159. // ArgBatchList arg.
  160. type ArgBatchList struct {
  161. AppID int64 `form:"app_id"`
  162. Type int8 `form:"type" default:"3"`
  163. }
  164. // ArgSalaryCoupon salary coupon.
  165. type ArgSalaryCoupon struct {
  166. Mid int64 `form:"mid" validate:"required,min=1,gte=1"`
  167. CouponType int64 `form:"coupon_type" validate:"required,min=1,gte=1"`
  168. Count int `form:"count" validate:"required,min=1,gte=1"`
  169. BranchToken string `form:"branch_token" validate:"required"`
  170. }
  171. // ArgUploadFile upload file arg.
  172. type ArgUploadFile struct {
  173. FileURL string `form:"url" validate:"required"`
  174. }
  175. // CouponBatchResp resp.
  176. type CouponBatchResp struct {
  177. ID int64 `json:"id"`
  178. AppID int64 `json:"app_id"`
  179. AppName string `json:"app_name"`
  180. Name string `json:"name"`
  181. BatchToken string `json:"batch_token"`
  182. MaxCount int64 `json:"max_count"`
  183. CurrentCount int64 `json:"current_count"`
  184. StartTime int64 `json:"start_time"`
  185. ExpireTime int64 `json:"expire_time"`
  186. ExpireDay int64 `json:"expire_day"`
  187. Operator string `json:"operator"`
  188. LimitCount int64 `json:"limit_count"`
  189. ProductLimitExplain string `json:"product_limit_explain"`
  190. PlatfromLimit []int64 `json:"platform_limit"`
  191. UseLimitExplain string `json:"use_limit_explain"`
  192. State int8 `json:"state"`
  193. Amount float64 `json:"amount"`
  194. FullAmount float64 `json:"full_amount"`
  195. ProdLimMonth int8 `json:"product_limit_month"`
  196. ProdLimRenewal int8 `json:"product_limit_Renewal"`
  197. }
  198. // AppInfo app info.
  199. type AppInfo struct {
  200. ID int64 `json:"id"`
  201. Name string `json:"name"`
  202. Appkey string `json:"appkey"`
  203. NotifyURL string `json:"notify_url"`
  204. Ctime time.Time `json:"ctime"`
  205. Mtime time.Time `json:"mtime"`
  206. }
  207. // CouponResp def.
  208. type CouponResp struct {
  209. Token string `json:"token"`
  210. Mid int64 `json:"mid"`
  211. GrantTime int64 `json:"grant_time"`
  212. UseTime int64 `json:"use_time"`
  213. State int8 `json:"state"`
  214. Remark int8 `json:"remark"`
  215. }
  216. // CouponAllowanceInfo coupon allowance info.
  217. type CouponAllowanceInfo struct {
  218. ID int64 `json:"id"`
  219. CouponToken string `json:"coupon_token"`
  220. Mid int64 `json:"mid"`
  221. State int32 `json:"state"`
  222. StartTime int64 `json:"start_time"`
  223. ExpireTime int64 `json:"expire_time"`
  224. Origin int64 `json:"origin"`
  225. OrderNO string `json:"order_no"`
  226. Ver int64 `json:"ver"`
  227. Remark string `json:"remark"`
  228. CTime time.Time `json:"ctime"`
  229. MTime time.Time `json:"mtime"`
  230. BatchToken string `json:"batch_token"`
  231. Amount float64 `json:"amount"`
  232. FullAmount float64 `json:"full_amount"`
  233. AppID int64 `json:"app_id"`
  234. }
  235. // CouponAllowanceChangeLog coupon allowance change log.
  236. type CouponAllowanceChangeLog struct {
  237. ID int64 `json:"-"`
  238. CouponToken string `json:"coupon_token"`
  239. OrderNO string `json:"order_no"`
  240. Mid int64 `json:"mid"`
  241. State int8 `json:"state"`
  242. ChangeType int8 `json:"change_type"`
  243. Ctime time.Time `json:"ctime"`
  244. Mtime time.Time `json:"mtime"`
  245. }
  246. // ProdLimExplainFmt .
  247. func (c *CouponBatchResp) ProdLimExplainFmt(prodLimMonth, prodLimRenewal int8) {
  248. if prodLimMonth == None && prodLimRenewal == None {
  249. c.ProductLimitExplain = NoLimitExplain
  250. }
  251. pstr := ""
  252. if limm, ok := ProdLimMonthMap[prodLimMonth]; ok {
  253. pstr += limm
  254. }
  255. if limr, ok := ProdLimRenewalMap[prodLimRenewal]; ok {
  256. pstr += "、" + limr
  257. }
  258. c.ProductLimitExplain = pstr
  259. }
  260. //Sizer .
  261. type Sizer interface {
  262. Size() int64
  263. }
  264. //ArgCouponViewBatch .
  265. type ArgCouponViewBatch struct {
  266. ID int64 `form:"id"`
  267. Name string `form:"name" validate:"required"`
  268. AppID int64 `form:"app_id" validate:"required,min=1"`
  269. MaxCount int64 `form:"max_count" default:"-1"`
  270. CurrentCount int64 `form:"current_count"`
  271. LimitCount int64 `form:"limit_count" default:"-1"`
  272. StartTime int64 `form:"start_time" validate:"required,min=1"`
  273. ExpireTime int64 `form:"end_time" validate:"required,min=1"`
  274. Operator string `form:"operator"`
  275. Ver int64
  276. BatchToken string
  277. CouponType int8
  278. }
  279. //ArgSearchCouponView .
  280. type ArgSearchCouponView struct {
  281. PN int `form:"pn" default:"1"`
  282. PS int `form:"ps" default:"20"`
  283. Mid int64 `form:"mid" validate:"required"`
  284. CouponToken string `form:"coupon_token"`
  285. AppID int64 `form:"app_id"`
  286. BatchToken string `form:"batch_token"`
  287. BatchTokens []string
  288. }
  289. //CouponInfo .
  290. type CouponInfo struct {
  291. CouponToken string `json:"coupon_token"`
  292. Mid int64 `json:"mid"`
  293. State int8 `json:"state"`
  294. StartTime int64 `json:"start_time"`
  295. ExpireTime int64 `json:"expire_time"`
  296. Origin int8 `json:"origin"`
  297. CouponType int8 `json:"coupon_type"`
  298. OrderNo string `json:"order_no"`
  299. OID int32 `json:"oid"`
  300. Remark string `json:"remark"`
  301. UseVer int64 `json:"use_ver"`
  302. Ctime time.Time `json:"ctime"`
  303. Mtime time.Time `json:"mtime"`
  304. BatchToken string `json:"batch_token"`
  305. Title string `json:"title"`
  306. BatchName string `json:"batch_name"`
  307. }
  308. //PGCInfoResq .
  309. type PGCInfoResq struct {
  310. Title string `json:"title"`
  311. }
  312. //CouponChangeLog .
  313. type CouponChangeLog struct {
  314. CouponToken string `json:"coupon_token"`
  315. Mid int64 `json:"mid"`
  316. State int8 `json:"state"`
  317. }
  318. // ArgBatchSalaryCoupon batch salary coupon.
  319. type ArgBatchSalaryCoupon struct {
  320. FileURL string `form:"file_url" validate:"required"`
  321. Count int64 `form:"count" validate:"required,min=1,gte=1"`
  322. BranchToken string `form:"branch_token" validate:"required"`
  323. SliceSize int `form:"slice_size" default:"100" validate:"min=100,max=10000"`
  324. }
  325. // ArgCouponCode coupon code.
  326. type ArgCouponCode struct {
  327. ID int64 `form:"id"`
  328. BatchToken string `form:"batch_token"`
  329. State int32 `form:"state"`
  330. Code string `form:"code"`
  331. Mid int64 `form:"mid"`
  332. CouponType int32 `form:"coupon_type"`
  333. CouponToken string `form:"coupon_token"`
  334. Pn int `form:"pn"`
  335. Ps int `form:"ps"`
  336. }
  337. // CouponCode coupon code.
  338. type CouponCode struct {
  339. ID int64 `json:"id"`
  340. BatchToken string `json:"batch_token"`
  341. State int32 `json:"state"`
  342. Code string `json:"code"`
  343. Mid int64 `json:"mid"`
  344. CouponType int32 `json:"coupon_type"`
  345. CouponToken string `json:"coupon_token"`
  346. Ver int64 `json:"ver"`
  347. Ctime time.Time `json:"ctime"`
  348. Mtime time.Time `json:"mtime"`
  349. }
  350. // CodePage code page.
  351. type CodePage struct {
  352. Count int64 `json:"count"`
  353. CodeList []*CouponCode `json:"code_list"`
  354. }
  355. // coupon code state.
  356. const (
  357. CodeStateNotUse = iota + 1
  358. CodeStateUsed
  359. CodeStateBlock
  360. CodeStateExpire
  361. )
  362. // batch code max count.
  363. const (
  364. BatchCodeMaxCount = 50000
  365. BatchAddCodeSlice = 100
  366. )
  367. // code batch state.
  368. const (
  369. CodeBatchUsable = iota
  370. CodeBatchBlock
  371. CodeBatchExpire
  372. )