info.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?php
  2. $config = function()
  3. {
  4. $array = array();
  5. $info = Dever::db('account/config')->state();
  6. if($info)
  7. {
  8. $array += $info;
  9. }
  10. return $array;
  11. };
  12. $project = function()
  13. {
  14. $array = array();
  15. $data = Dever::load('account/config_project-state');
  16. if($data)
  17. {
  18. $array += $data;
  19. }
  20. return $array;
  21. };
  22. $user = '用户ID';
  23. $search = 'hidden';
  24. $config_key = Dever::input('config_key');
  25. if ($config_key) {
  26. $info = Dever::db('account/config')->find(array('key' => $config_key));
  27. if ($info) {
  28. Dever::setInput('search_option_config_id', $info['id']);
  29. }
  30. }
  31. $uid = Dever::input('search_option_uid');
  32. $config_id = Dever::input('search_option_config_id');
  33. if ($config_id && $uid) {
  34. $search_config = Dever::load('account/lib/info')->getSearch($config_id);
  35. if ($search_config) {
  36. $search = $search_config;
  37. $user = '用户名称';
  38. }
  39. }
  40. $account_log = 'info_log&project=account&search_option_info_id={id}&search_option_uid={uid}&search_option_config_id={config_id}&oper_parent=info&oper_project=account';
  41. $oper_table = Dever::input('oper_table');
  42. if ($oper_table) {
  43. $account_log .= '&top_table=' . $oper_table . '&top_project=' . Dever::input('oper_project');
  44. }
  45. return array
  46. (
  47. # 表名
  48. 'name' => 'info',
  49. # 显示给用户看的名称
  50. 'lang' => '用户账户列表',
  51. 'order' => 100,
  52. 'menu' => false,
  53. # 数据结构
  54. 'struct' => array
  55. (
  56. 'id' => array
  57. (
  58. 'type' => 'int-11',
  59. 'name' => 'ID',
  60. 'default' => '',
  61. 'desc' => '',
  62. 'match' => 'is_numeric',
  63. //'list' => true,
  64. ),
  65. 'uid' => array
  66. (
  67. 'type' => 'int-11',
  68. 'name' => $user,
  69. 'default' => '0',
  70. 'desc' => '用户名称',
  71. 'match' => 'is_numeric',
  72. 'search' => $search,
  73. 'value' => $uid,
  74. 'list_name' => '用户名称',
  75. 'list' => 'Dever::load("account/lib/info.getName", {uid}, {config_id})',
  76. ),
  77. 'config_id' => array
  78. (
  79. 'type' => 'int-11',
  80. 'name' => '账户名称',
  81. 'default' => '1',
  82. 'desc' => '账户名称',
  83. 'match' => 'is_numeric',
  84. 'update' => 'select',
  85. 'option' => $config,
  86. 'search' => 'select',
  87. 'list' => true,
  88. ),
  89. 'project_id' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '所属项目',
  93. 'default' => '1',
  94. 'desc' => '所属项目',
  95. 'match' => 'is_numeric',
  96. 'update' => 'radio',
  97. 'option' => $project,
  98. 'list' => true,
  99. ),
  100. 'cash' => array
  101. (
  102. 'type' => 'decimal-11,2',
  103. 'name' => '可用金额',
  104. 'default' => '0',
  105. 'desc' => '可用金额',
  106. 'match' => 'option',
  107. 'update' => 'text',
  108. 'list' => true,
  109. ),
  110. 'z_cash' => array
  111. (
  112. 'type' => 'decimal-11,2',
  113. 'name' => '总获取金额',
  114. 'default' => '0',
  115. 'desc' => '总获取金额',
  116. 'match' => 'option',
  117. 'update' => 'text',
  118. 'list' => true,
  119. ),
  120. 't_cash' => array
  121. (
  122. 'type' => 'decimal-11,2',
  123. 'name' => '总消耗金额',
  124. 'default' => '0',
  125. 'desc' => '总消耗金额',
  126. 'match' => 'option',
  127. 'update' => 'text',
  128. 'list' => true,
  129. ),
  130. 'state' => array
  131. (
  132. 'type' => 'tinyint-1',
  133. 'name' => '状态',
  134. 'default' => '1',
  135. 'desc' => '请选择状态',
  136. 'match' => 'is_numeric',
  137. ),
  138. 'cdate' => array
  139. (
  140. 'type' => 'int-11',
  141. 'name' => '录入时间',
  142. 'match' => array('is_numeric', time()),
  143. 'desc' => '',
  144. # 只有insert时才生效
  145. 'insert' => true,
  146. ),
  147. ),
  148. # 索引
  149. 'index' => array
  150. (
  151. 1 => array
  152. (
  153. 'search' => 'uid,config_id,project_id',
  154. ),
  155. # 版本号 更改版本号会更新当前表的索引
  156. 'version' => 1,
  157. ),
  158. 'manage' => array
  159. (
  160. 'delete' => false,
  161. 'edit' => false,
  162. 'insert' => false,
  163. # 列表
  164. 'list_button' => array
  165. (
  166. 'fast_add' => array('账户操作', 'push&project=account&search_option_config_id={config_id}&search_option_uid={uid}'),
  167. 'list' => array('账户流水', $account_log),
  168. ),
  169. ),
  170. # request 请求接口定义
  171. 'request' => array
  172. (
  173. # 更新
  174. 'inc' => array
  175. (
  176. 'type' => 'update',
  177. 'where' => array
  178. (
  179. 'id' => 'yes',
  180. ),
  181. 'set' => array
  182. (
  183. 'cash' => array('yes', '+='),
  184. 'col' => array('yes-z_cash', '+='),
  185. ),
  186. ),
  187. # 更新
  188. 'dec' => array
  189. (
  190. 'type' => 'update',
  191. 'where' => array
  192. (
  193. 'id' => 'yes',
  194. ),
  195. 'set' => array
  196. (
  197. 'cash' => array('yes', '+='),
  198. 'col' => array('yes-t_cash', '+='),
  199. ),
  200. ),
  201. )
  202. );