user_log.php 4.7 KB

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