user_log.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. 'rebate_uid' => array
  64. (
  65. 'type' => 'int-11',
  66. 'name' => '下级用户',
  67. 'default' => '0',
  68. 'desc' => '下级用户',
  69. 'match' => 'is_numeric',
  70. 'list' => '{rebate_uid} > 0 ? Dever::load("passport/user-one#username", {rebate_uid}) : "无"',
  71. ),
  72. 'config_id' => array
  73. (
  74. 'type' => 'int-11',
  75. 'name' => '积分名称',
  76. 'default' => '1',
  77. 'desc' => '积分名称',
  78. 'match' => 'is_numeric',
  79. 'update' => 'select',
  80. 'option' => $config,
  81. 'search' => 'select',
  82. 'list' => true,
  83. ),
  84. 'action_id' => array
  85. (
  86. 'type' => 'int-11',
  87. 'name' => '所属行为',
  88. 'default' => '1',
  89. 'desc' => '所属行为',
  90. 'match' => 'is_numeric',
  91. 'update' => 'select',
  92. 'option' => $action,
  93. 'search' => 'select',
  94. 'list' => true,
  95. ),
  96. 'action_log_id' => array
  97. (
  98. 'type' => 'int-11',
  99. 'name' => '所属行为日志',
  100. 'default' => '1',
  101. 'desc' => '所属行为日志',
  102. 'match' => 'is_numeric',
  103. 'update' => 'text',
  104. 'list' => true,
  105. ),
  106. 'status' => array
  107. (
  108. 'type' => 'tinyint-1',
  109. 'name' => '收入支出状态',
  110. 'default' => '1',
  111. 'desc' => '收入支出状态',
  112. 'match' => 'is_numeric',
  113. 'update' => 'select',
  114. 'option' => $status,
  115. //'search' => 'select',
  116. 'list' => true,
  117. //'edit' => true,
  118. ),
  119. 'num' => array
  120. (
  121. 'type' => 'varchar-80',
  122. 'name' => '增加积分数-如果为负数,则是减少积分',
  123. 'default' => '',
  124. 'desc' => '增加积分数',
  125. 'match' => 'option',
  126. 'update' => 'textarea',
  127. 'list' => true,
  128. ),
  129. 'total' => array
  130. (
  131. 'type' => 'varchar-80',
  132. 'name' => '总积分数',
  133. 'default' => '',
  134. 'desc' => '总积分数',
  135. 'match' => 'option',
  136. 'update' => 'textarea',
  137. 'list' => true,
  138. ),
  139. 'desc' => array
  140. (
  141. 'type' => 'varchar-300',
  142. 'name' => '描述',
  143. 'default' => '',
  144. 'desc' => '描述',
  145. 'match' => 'option',
  146. 'update' => 'textarea',
  147. ),
  148. 'state' => array
  149. (
  150. 'type' => 'tinyint-1',
  151. 'name' => '状态',
  152. 'default' => '1',
  153. 'desc' => '请选择状态',
  154. 'match' => 'is_numeric',
  155. ),
  156. 'cdate' => array
  157. (
  158. 'type' => 'int-11',
  159. 'name' => '录入时间',
  160. 'match' => array('is_numeric', time()),
  161. 'desc' => '',
  162. # 只有insert时才生效
  163. 'insert' => true,
  164. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  165. ),
  166. ),
  167. # 索引
  168. 'index' => array
  169. (
  170. 1 => array
  171. (
  172. 'search' => 'uid,config_id,action_id,action_log_id',
  173. ),
  174. # 版本号 更改版本号会更新当前表的索引
  175. 'version' => 1,
  176. ),
  177. 'manage' => array
  178. (
  179. 'delete' => false,
  180. 'edit' => false,
  181. 'insert' => false,
  182. # 列表
  183. 'list_button' => array
  184. (
  185. //'list' => array('行为日志', '"action_log&search_option_action_id={action_id}&search_option_uid={uid}&oper_parent=user_log"'),
  186. ),
  187. ),
  188. # request 请求接口定义
  189. 'request' => array
  190. (
  191. 'getNew' => array
  192. (
  193. # 匹配的正则或函数 选填项
  194. 'option' => array
  195. (
  196. 'config_id' => 'yes',
  197. 'action_id' => 'yes',
  198. 'uid' => 'yes',
  199. 'status' => 'yes',
  200. 'state' => 1,
  201. ),
  202. 'type' => 'one',
  203. 'order' => array('cdate' => 'desc'),
  204. 'col' => '*',
  205. ),
  206. 'getList' => array
  207. (
  208. # 匹配的正则或函数 选填项
  209. 'option' => array
  210. (
  211. 'config_id' => 'yes',
  212. 'action_id' => 'yes',
  213. 'uid' => 'yes',
  214. 'status' => 'yes',
  215. 'state' => 1,
  216. ),
  217. 'type' => 'all',
  218. 'order' => array('cdate' => 'desc'),
  219. 'page' => array(5, 'list'),
  220. 'col' => '*',
  221. ),
  222. 'getNewTotal' => array
  223. (
  224. # 匹配的正则或函数 选填项
  225. 'option' => array
  226. (
  227. 'config_id' => 'yes',
  228. 'action_id' => 'yes',
  229. 'uid' => 'yes',
  230. 'status' => 'yes',
  231. 'state' => 1,
  232. 'start' => array('yes-cdate', '>='),
  233. 'end' => array('yes-cdate', '<='),
  234. ),
  235. 'type' => 'count',
  236. 'order' => array('cdate' => 'desc'),
  237. 'col' => 'count(1) as total',
  238. ),
  239. )
  240. );