info.php 7.9 KB

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