level_log.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. $level = function()
  3. {
  4. $array = array();
  5. $info = Dever::db('score/level')->state();
  6. if($info)
  7. {
  8. $array += $info;
  9. }
  10. return $array;
  11. };
  12. $type_id = function()
  13. {
  14. $array = array();
  15. $info = Dever::db('score/level_type')->state();
  16. if($info)
  17. {
  18. $array += $info;
  19. }
  20. return $array;
  21. };
  22. $status = array
  23. (
  24. 1 => '收入',
  25. 2 => '支出',
  26. );
  27. # 手动升级时,如果需要用户手动来触发升级则需要本表
  28. return array
  29. (
  30. # 表名
  31. 'name' => 'level_log',
  32. # 显示给用户看的名称
  33. 'lang' => '用户等级请求日志',
  34. 'order' => 10,
  35. 'menu' => false,
  36. # 数据结构
  37. 'struct' => array
  38. (
  39. 'id' => array
  40. (
  41. 'type' => 'int-11',
  42. 'name' => 'ID',
  43. 'default' => '',
  44. 'desc' => '',
  45. 'match' => 'is_numeric',
  46. ),
  47. 'uid' => array
  48. (
  49. 'type' => 'int-11',
  50. 'name' => '用户名',
  51. 'default' => '0',
  52. 'desc' => '请选择用户',
  53. 'match' => 'is_numeric',
  54. //'update' => 'select',
  55. //'search' => 'select',
  56. 'search' => array
  57. (
  58. 'api' => 'passport/user-all',
  59. 'col' => 'username',
  60. 'result' => 'id',
  61. ),
  62. 'list' => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
  63. ),
  64. 'level_type_id' => array
  65. (
  66. 'type' => 'int-11',
  67. 'name' => '等级类别',
  68. 'default' => '1',
  69. 'desc' => '等级类别',
  70. 'match' => 'is_numeric',
  71. 'update' => 'select',
  72. 'option' => $type_id,
  73. 'search' => 'select',
  74. 'list' => true,
  75. ),
  76. 'level_id' => array
  77. (
  78. 'type' => 'int-11',
  79. 'name' => '等级名称',
  80. 'default' => '1',
  81. 'desc' => '等级名称',
  82. 'match' => 'is_numeric',
  83. 'update' => 'select',
  84. 'option' => $level,
  85. 'search' => 'select',
  86. 'list' => true,
  87. 'edit' => true,
  88. ),
  89. 'status' => array
  90. (
  91. 'type' => 'tinyint-1',
  92. 'name' => '收入支出状态',
  93. 'default' => '1',
  94. 'desc' => '收入支出状态',
  95. 'match' => 'is_numeric',
  96. 'update' => 'select',
  97. 'option' => $status,
  98. //'search' => 'select',
  99. 'list' => true,
  100. //'edit' => true,
  101. ),
  102. 'num' => array
  103. (
  104. 'type' => 'varchar-80',
  105. 'name' => '增加积分数-如果为负数,则是减少积分',
  106. 'default' => '',
  107. 'desc' => '增加积分数',
  108. 'match' => 'option',
  109. 'update' => 'textarea',
  110. 'list' => true,
  111. ),
  112. 'total' => array
  113. (
  114. 'type' => 'varchar-80',
  115. 'name' => '总积分数',
  116. 'default' => '',
  117. 'desc' => '总积分数',
  118. 'match' => 'option',
  119. 'update' => 'textarea',
  120. 'list' => true,
  121. ),
  122. 'desc' => array
  123. (
  124. 'type' => 'varchar-300',
  125. 'name' => '描述',
  126. 'default' => '',
  127. 'desc' => '描述',
  128. 'match' => 'option',
  129. 'update' => 'textarea',
  130. ),
  131. 'state' => array
  132. (
  133. 'type' => 'tinyint-1',
  134. 'name' => '状态',
  135. 'default' => '1',
  136. 'desc' => '请选择状态',
  137. 'match' => 'is_numeric',
  138. ),
  139. 'cdate' => array
  140. (
  141. 'type' => 'int-11',
  142. 'name' => '录入时间',
  143. 'match' => array('is_numeric', time()),
  144. 'desc' => '',
  145. # 只有insert时才生效
  146. 'insert' => true,
  147. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  148. ),
  149. ),
  150. 'manage' => array
  151. (
  152. 'delete' => false,
  153. 'edit' => false,
  154. 'insert' => false,
  155. # 列表
  156. 'list_button' => array
  157. (
  158. //'list' => array('行为日志', '"action_log&search_option_action_id={action_id}&search_option_uid={uid}&oper_parent=user_log"'),
  159. ),
  160. ),
  161. # request 请求接口定义
  162. 'request' => array
  163. (
  164. 'getNew' => array
  165. (
  166. # 匹配的正则或函数 选填项
  167. 'option' => array
  168. (
  169. 'config_id' => 'yes',
  170. 'action_id' => 'yes',
  171. 'uid' => 'yes',
  172. 'status' => 'yes',
  173. 'state' => 1,
  174. ),
  175. 'type' => 'one',
  176. 'order' => array('cdate' => 'desc'),
  177. 'col' => '*',
  178. ),
  179. 'getNewTotal' => array
  180. (
  181. # 匹配的正则或函数 选填项
  182. 'option' => array
  183. (
  184. 'config_id' => 'yes',
  185. 'action_id' => 'yes',
  186. 'uid' => 'yes',
  187. 'status' => 'yes',
  188. 'state' => 1,
  189. 'start' => array('yes-cdate', '>='),
  190. 'end' => array('yes-cdate', '<='),
  191. ),
  192. 'type' => 'count',
  193. 'order' => array('cdate' => 'desc'),
  194. 'col' => 'count(1) as total',
  195. ),
  196. )
  197. );