info.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <?php
  2. # 定义几个常用的选项
  3. $type = array
  4. (
  5. 1 => '未领取',
  6. 2 => '已领取',
  7. 3 => '已使用',
  8. 4 => '已作废',
  9. );
  10. $status = array
  11. (
  12. 1 => '不可用',
  13. 2 => '可用',
  14. );
  15. $product = function()
  16. {
  17. return Dever::load('journal/api.data');
  18. };
  19. $seller = function()
  20. {
  21. return Dever::db('code/seller')->state();
  22. };
  23. # 获取小刊分类权限
  24. $auth = Dever::tops();
  25. $cate = function() use ($auth)
  26. {
  27. $array = array();
  28. if ($auth) {
  29. $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
  30. } else {
  31. $info = Dever::db('journal/cate')->state();
  32. }
  33. if($info)
  34. {
  35. $array += $info;
  36. }
  37. return $array;
  38. };
  39. $name = 'info';
  40. $create = Dever::config('database')->create;
  41. $data = Dever::input('search_linkage_product');
  42. if (isset($data[1])) {
  43. $product_id = $data[1];
  44. } else {
  45. $product_id = Dever::input('set_product_id');
  46. }
  47. if ($product_id && $product_id > 0) {
  48. $name .= '_' . $product_id;
  49. $create = false;
  50. }
  51. return array
  52. (
  53. # 表名
  54. 'name' => $name,
  55. # 显示给用户看的名称
  56. 'lang' => '兑换码列表',
  57. 'menu' => 'stat',
  58. 'order' => 1,
  59. 'create' => $create,
  60. 'auto' => 10000000,
  61. # 数据结构
  62. 'struct' => array
  63. (
  64. 'id' => array
  65. (
  66. 'type' => 'int-11',
  67. 'name' => 'ID',
  68. 'default' => '',
  69. 'desc' => '',
  70. 'match' => 'is_numeric',
  71. 'search' => 'order',
  72. 'order' => 'desc',
  73. //'list' => true,
  74. ),
  75. 'create_uid' => array
  76. (
  77. 'type' => 'int-11',
  78. 'name' => '创建人',
  79. 'default' => '-1',
  80. 'desc' => '创建人',
  81. 'match' => 'is_numeric',
  82. 'search' => array
  83. (
  84. 'api' => 'passport/user-all',
  85. 'col' => 'username',
  86. 'result' => 'id',
  87. ),
  88. //'list' => 'Dever::load("code/lib/manage.showUserInfo", "{uid}", "{ldate}")',
  89. ),
  90. 'product' => array
  91. (
  92. 'name' => '小刊',
  93. 'default' => '',
  94. 'desc' => '小刊',
  95. 'search' => 'linkage',
  96. 'search_col' => 'cate_id,product_id',
  97. 'option' => Dever::url('lib/manage.search_cate_journal', 'journal'),
  98. ),
  99. 'cate_id' => array
  100. (
  101. 'type' => 'int-11',
  102. 'name' => '小刊分类',
  103. 'default' => '1',
  104. 'desc' => '小刊分类',
  105. 'match' => 'is_numeric',
  106. 'update' => 'select',
  107. 'option' => $cate,
  108. //'search' => 'select',
  109. 'list' => true,
  110. ),
  111. 'product_id' => array
  112. (
  113. 'type' => 'int-11',
  114. 'name' => '小刊',
  115. 'default' => '',
  116. 'desc' => '小刊',
  117. 'match' => 'is_numeric',
  118. 'update' => 'select',
  119. 'option' => $product,
  120. //'search' => 'select',
  121. 'list' => '{product_id} > 0 ? Dever::load("journal/info-one#name", {product_id}) : "通用"',
  122. ),
  123. 'code' => array
  124. (
  125. 'type' => 'varchar-32',
  126. 'name' => '兑换码',
  127. 'default' => '',
  128. 'desc' => '兑换码',
  129. 'match' => 'is_string',
  130. 'update' => 'text',
  131. 'search' => 'fulltext',
  132. 'list' => 'Dever::load("code/lib/manage.showCode", "{id}")',
  133. //'list' => true,
  134. ),
  135. 'score' => array
  136. (
  137. 'type' => 'varchar-80',
  138. 'name' => '增加积分数-直接填写积分数,设置之后,积分规则里的设置及小刊兑换码中的设置将失效,当设置为0时,直接使用积分规则中的设置。当设置为-1时,不增加积分数',
  139. 'default' => '',
  140. 'desc' => '增加积分数',
  141. 'match' => 'is_string',
  142. //'update' => 'text',
  143. ),
  144. 'product_num' => array
  145. (
  146. 'type' => 'int-11',
  147. 'name' => '兑换本数',
  148. 'default' => '0',
  149. 'desc' => '兑换本数',
  150. 'match' => 'option',
  151. 'update' => 'text',
  152. 'search' => 'fulltext',
  153. 'list' => true,
  154. ),
  155. 'type' => array
  156. (
  157. 'type' => 'int-11',
  158. 'name' => '使用状态',
  159. 'default' => '1',
  160. 'desc' => '使用状态',
  161. 'match' => 'is_numeric',
  162. 'option' => $type,
  163. 'search' => 'select',
  164. 'update' => 'select',
  165. 'list' => true,
  166. 'mul' => array(1 => '恢复使用', 4 => '已作废'),
  167. ),
  168. 'seller_id' => array
  169. (
  170. 'type' => 'int-11',
  171. 'name' => '销售商',
  172. 'default' => '1',
  173. 'desc' => '销售商',
  174. 'match' => 'is_numeric',
  175. 'update' => 'select',
  176. 'option' => $seller,
  177. 'search' => 'select',
  178. 'list' => true,
  179. ),
  180. 'uid' => array
  181. (
  182. 'type' => 'int-11',
  183. 'name' => '用户信息',
  184. 'default' => '0',
  185. 'desc' => '用户信息',
  186. 'match' => 'is_numeric',
  187. 'list' => 'Dever::load("code/lib/manage.showUserInfo", "{create_uid}", "{uid}", "{ldate}", "{type}")',
  188. ),
  189. 'order_id' => array
  190. (
  191. 'type' => 'varchar-100',
  192. 'name' => '订单表ID',
  193. 'default' => '',
  194. 'desc' => '订单表ID',
  195. 'match' => 'is_string',
  196. 'update' => 'text',
  197. 'search' => 'fulltext',
  198. 'list' => true,
  199. //'list' => '"{order_id}" ? "{order_id}" : "{code}"',
  200. ),
  201. 'state' => array
  202. (
  203. 'type' => 'tinyint-1',
  204. 'name' => '状态',
  205. 'default' => '1',
  206. 'desc' => '请选择状态',
  207. 'match' => 'is_numeric',
  208. ),
  209. 'ldate' => array
  210. (
  211. 'type' => 'int-11',
  212. 'name' => '领取时间',
  213. 'match' => 'option',
  214. 'default' => '',
  215. 'desc' => '',
  216. //'search' => 'date',
  217. ),
  218. 'cdate' => array
  219. (
  220. 'type' => 'int-11',
  221. 'name' => '生成时间',
  222. 'match' => array('is_numeric', time()),
  223. 'desc' => '',
  224. # 只有insert时才生效
  225. 'insert' => true,
  226. 'search' => 'date',
  227. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  228. ),
  229. ),
  230. //'top' => Dever::config('base')->top,
  231. # 增加这个,为了给当前的list增加一个option
  232. 'top_option' => array
  233. (
  234. 'value' => $auth,
  235. 'col' => 'cate_id',
  236. ),
  237. # 更新表结构
  238. 'alter' => array
  239. (
  240. 2 => array
  241. (
  242. array('update', 'product_num', 'product_num', 'varchar-32 0 兑换本数'),
  243. //array('add', 'config', 'config', 'int-11 1 配置'),
  244. ),
  245. 'version' => 2,
  246. ),
  247. # 索引
  248. 'index' => array
  249. (
  250. 4 => array
  251. (
  252. 'order_id' => 'order_id',
  253. ),
  254. # 版本号 更改版本号会更新当前表的索引
  255. 'version' => 4,
  256. ),
  257. 'manage' => array
  258. (
  259. 'excel' => true,
  260. 'delete' => false,
  261. 'edit' => false,
  262. 'insert' => false,
  263. 'mul' => '{type} == 1 || {type} == 4',
  264. # 自定义快捷新增和编辑
  265. 'button' => array
  266. (
  267. '新增兑换码' => array('fast', 1, 'config&where_id=1'),
  268. '销售商列表' => array('list', 'seller&project=code&oper_parent=info&oper_project=code'),
  269. '新增销售商' => array('fast', 1, 'seller'),
  270. ),
  271. 'list_button' => array
  272. (
  273. 'oper' => array('作废', 'code/lib/manage.drop?id={id}&journal_id={product_id}&code={code}', '{type} == 1'),
  274. 'oper2' => array('恢复使用', 'code/lib/manage.recovery?id={id}&journal_id={product_id}&code={code}', '{type} == 4'),
  275. ),
  276. ),
  277. 'request' => array
  278. (
  279. 'getAll' => array
  280. (
  281. # 匹配的正则或函数 选填项
  282. 'option' => array
  283. (
  284. 'cate_id' => 'yes',
  285. 'create_uid' => 'yes',
  286. 'order_id' => 'yes',
  287. 'type' => array('yes', '!='),
  288. 'state' => 1,
  289. ),
  290. 'type' => 'all',
  291. 'order' => array('type' => 'asc', 'id' => 'desc'),
  292. 'page' => array(30, 'list'),
  293. 'col' => '*',
  294. ),
  295. 'getMyAll' => array
  296. (
  297. # 匹配的正则或函数 选填项
  298. 'option' => array
  299. (
  300. 'order_id' => 'yes',
  301. 'create_uid' => 'yes',
  302. 'type' => array('yes', '!='),
  303. 'state' => 1,
  304. ),
  305. 'type' => 'all',
  306. 'order' => array('type' => 'asc', 'id' => 'desc'),
  307. 'page' => array(10, 'list'),
  308. 'col' => 'id,code,type,create_uid',
  309. ),
  310. 'getData' => array
  311. (
  312. # 匹配的正则或函数 选填项
  313. 'option' => array
  314. (
  315. 'order_id' => 'yes',
  316. 'type' => array('yes', '!='),
  317. 'state' => 1,
  318. ),
  319. 'type' => 'all',
  320. 'order' => array('type' => 'asc', 'id' => 'desc'),
  321. 'col' => '*',
  322. ),
  323. )
  324. );