info.php 4.5 KB

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