info.php 8.4 KB

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