info.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. $status = Dever::config('base')->status;
  3. $price_type = array
  4. (
  5. 1 => '普通商品',
  6. 2 => '多价商品',
  7. 3 => '套餐商品',
  8. 4 => '组合商品',
  9. );
  10. $mode = array
  11. (
  12. 1 => '自提',
  13. 2 => '外送',
  14. 3 => '以上全支持',
  15. );
  16. $yes = array
  17. (
  18. 1 => '是',
  19. 2 => '否',
  20. );
  21. $column = function()
  22. {
  23. $array = array();
  24. $info = Dever::load('goods/column-state');
  25. if($info)
  26. {
  27. $array += $info;
  28. }
  29. return $array;
  30. };
  31. $tag = function()
  32. {
  33. $array = array();
  34. $info = Dever::load('goods/tag-state');
  35. if($info)
  36. {
  37. $array += $info;
  38. }
  39. return $array;
  40. };
  41. $config = array
  42. (
  43. # 表名
  44. 'name' => 'info',
  45. # 显示给用户看的名称
  46. 'lang' => '商品列表',
  47. 'order' => 200,
  48. 'auto' => 10000000,
  49. 'end' => array
  50. (
  51. 'insert' => 'goods/lib/manage.infoUpdate',
  52. 'update' => 'goods/lib/manage.infoUpdate',
  53. ),
  54. # 同步更新另外一个或多个表的数据,将数据同步到关联表中
  55. 'sync' => array
  56. (
  57. 'goods/info_category' => array
  58. (
  59. # 更新另外一个表的字段 => 本表的字段
  60. 'where' => array('info_id', 'id'),
  61. # 要更新的数据
  62. 'update' => array('category_id' => 'category'),
  63. # 同步更新的类型,delete为先删再插入,update为直接更新
  64. 'type' => 'delete',
  65. ),
  66. 'goods/info_column' => array
  67. (
  68. # 更新另外一个表的字段 => 本表的字段
  69. 'where' => array('info_id', 'id'),
  70. # 要更新的数据
  71. 'update' => array('column_id' => 'column_id'),
  72. # 同步更新的类型,delete为先删再插入,update为直接更新
  73. 'type' => 'delete',
  74. ),
  75. 'goods/info_tag' => array
  76. (
  77. # 更新另外一个表的字段 => 本表的字段
  78. 'where' => array('info_id', 'id'),
  79. # 要更新的数据
  80. 'update' => array('tag_id' => 'tag_id'),
  81. # 同步更新的类型,delete为先删再插入,update为直接更新
  82. 'type' => 'delete',
  83. )
  84. ),
  85. # 数据结构 不同的字段放这里
  86. 'struct' => array
  87. (
  88. 'id' => array
  89. (
  90. 'type' => 'int-11',
  91. 'name' => 'ID',
  92. 'default' => '',
  93. 'desc' => '',
  94. 'match' => 'is_numeric',
  95. //'list' => true,
  96. ),
  97. 'name' => array
  98. (
  99. 'type' => 'varchar-800',
  100. 'name' => '商品名称',
  101. 'default' => '',
  102. 'desc' => '商品名称',
  103. 'match' => 'is_string',
  104. 'update' => 'textarea',
  105. 'search' => 'fulltext',
  106. 'list' => true,
  107. 'edit' => true,
  108. ),
  109. 'column_id' => array
  110. (
  111. 'type' => 'varchar-8000',
  112. 'name' => '栏目',
  113. 'default' => '',
  114. 'desc' => '所属项目',
  115. 'match' => 'is_string',
  116. 'update' => 'checkbox',
  117. 'option' => $column,
  118. //'list' => true,
  119. ),
  120. 'category' => array
  121. (
  122. 'type' => 'varchar-500',
  123. 'name' => '分类',
  124. 'default' => '',
  125. 'desc' => '分类',
  126. 'match' => 'is_string',
  127. 'search' => 'linkage',
  128. 'update' => 'linkage',
  129. 'option' => Dever::url('api.get', 'category'),
  130. //'list' => 'Dever::load("category/api.string", "{category}")',
  131. ),
  132. # 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
  133. 'top_category_id' => array
  134. (
  135. 'type' => 'int-11',
  136. 'name' => '顶级分类ID-顶级分类,用于分类查询',
  137. 'default' => '-1',
  138. 'desc' => '顶级分类ID',
  139. 'match' => 'is_numeric',
  140. ),
  141. 'second_category_id' => array
  142. (
  143. 'type' => 'int-11',
  144. 'name' => '二级分类ID-二级分类,用于分类查询',
  145. 'default' => '-1',
  146. 'desc' => '二级分类ID',
  147. 'match' => 'is_numeric',
  148. ),
  149. 'category_id' => array
  150. (
  151. 'type' => 'int-11',
  152. 'name' => '子分类ID-最后一个级别的分类,用于分类查询',
  153. 'default' => '-1',
  154. 'desc' => '子分类ID',
  155. 'match' => 'is_numeric',
  156. ),
  157. 'tag_id' => array
  158. (
  159. 'type' => 'varchar-800',
  160. 'name' => '标签',
  161. 'default' => '',
  162. 'desc' => '标签',
  163. 'match' => 'is_string',
  164. 'update' => 'checkbox',
  165. 'option' => $tag,
  166. //'list' => true,
  167. ),
  168. 'area' => array
  169. (
  170. 'type' => 'int-11',
  171. 'name' => '所在地区',
  172. 'default' => '',
  173. 'desc' => '所在地区',
  174. 'match' => 'is_string',
  175. //'search' => 'linkage',
  176. //'update' => 'linkage',
  177. //'option' => Dever::url('api.get?level_total=1', 'area'),
  178. //'list' => 'Dever::load("area/api.string", "{goods_area}")',
  179. ),
  180. 'mode' => array
  181. (
  182. 'type' => 'int-11',
  183. 'name' => '取货形式',
  184. 'default' => '1',
  185. 'desc' => '取货形式',
  186. 'match' => 'is_numeric',
  187. //'update' => 'radio',
  188. 'option' => $mode,
  189. ),
  190. 'price_type' => array
  191. (
  192. 'type' => 'int-11',
  193. 'name' => '商品类型-套餐商品由多个普通商品组成,可以单独定义库存,组合商品也由多个普通商品组成的,但库存无法自定义',
  194. 'default' => '1',
  195. 'desc' => '价格类型',
  196. 'match' => 'is_numeric',
  197. 'update' => 'radio',
  198. 'option' => $price_type,
  199. 'control' => 'price_type',
  200. ),
  201. 'sku_id' => array
  202. (
  203. 'type' => 'int-11',
  204. 'name' => 'sku_id',
  205. 'default' => '-1',
  206. 'desc' => 'sku_id',
  207. 'match' => 'is_numeric',
  208. ),
  209. 'price' => array
  210. (
  211. 'type' => 'decimal-10,2',
  212. 'name' => '销售价',
  213. 'default' => '',
  214. 'desc' => '销售价',
  215. 'match' => 'option',
  216. //'update' => 'text',
  217. 'show' => 'price_type=1',
  218. ),
  219. 's_price' => array
  220. (
  221. 'type' => 'decimal-10,2',
  222. 'name' => '市场价',
  223. 'default' => '',
  224. 'desc' => '市场价',
  225. 'match' => 'option',
  226. //'update' => 'text',
  227. 'show' => 'price_type=1',
  228. ),
  229. 'f_price' => array
  230. (
  231. 'type' => 'decimal-10,2',
  232. 'name' => '采购价',
  233. 'default' => '',
  234. 'desc' => '采购价',
  235. 'match' => 'option',
  236. //'update' => 'text',
  237. 'show' => 'price_type=1',
  238. ),
  239. 'goods' => array
  240. (
  241. 'type' => 'text-1000',
  242. 'name' => '套餐商品配置-套餐和组合商品只可以选择普通商品',
  243. 'default' => '',
  244. 'desc' => '套餐商品配置',
  245. 'match' => 'is_string',
  246. 'show' => 'price_type=3,4',
  247. 'update' => array
  248. (
  249. array
  250. (
  251. 'col' => 'goods_id',
  252. 'name' => '选择商品',
  253. 'default' => '',
  254. 'desc' => '选择商品',
  255. 'match' => 'option',
  256. 'update' => 'select',
  257. 'update_search' => 'goods/lib/manage.search?price_type=1',
  258. ),
  259. array
  260. (
  261. 'col' => 'num',
  262. 'name' => '数量',
  263. 'default' => '1',
  264. 'desc' => '数量',
  265. 'match' => 'is_string',
  266. 'update' => 'text',
  267. ),
  268. ),
  269. ),
  270. 'cover' => array
  271. (
  272. 'type' => 'varchar-150',
  273. 'name' => '封面图-图片尺寸300*300px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
  274. 'default' => '',
  275. 'desc' => '封面图',
  276. 'match' => 'option',
  277. 'update' => 'image',
  278. 'key' => '1',
  279. 'place' => '300*300',
  280. 'list_name' => '商品详情',
  281. 'list' => 'Dever::load("goods/lib/manage.info", "{id}")',
  282. ),
  283. 'video' => array
  284. (
  285. 'type' => 'varchar-800',
  286. 'name' => '视频-视频格式mp4,上传大小不能超过4G',
  287. 'default' => '',
  288. 'desc' => '视频',
  289. 'match' => 'option',
  290. 'update' => 'video',
  291. 'key' => '3',
  292. 'place' => '150',
  293. 'upload' => 'yun',
  294. 'large' => true,
  295. //'cover' => 'pic',//封面图字段名
  296. ),
  297. 'pic' => array
  298. (
  299. 'type' => 'text-255',
  300. 'name' => '多张图片-图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,用户上传图片之后会自动进行居中裁剪',
  301. 'default' => '',
  302. 'desc' => '多张图片',
  303. 'match' => 'option',
  304. 'update' => 'images',
  305. 'key' => '1',
  306. 'place' => '750*422',
  307. ),
  308. 'hot' => array
  309. (
  310. 'type' => 'int-11',
  311. 'name' => '是否热门商品',
  312. 'default' => '2',
  313. 'desc' => '是否热门商品',
  314. 'match' => 'is_numeric',
  315. //'update' => 'radio',
  316. 'option' => $yes,
  317. //'list' => true,
  318. //'edit' => true,
  319. ),
  320. 'top' => array
  321. (
  322. 'type' => 'int-11',
  323. 'name' => '是否推荐商品',
  324. 'default' => '2',
  325. 'desc' => '是否推荐商品',
  326. 'match' => 'is_numeric',
  327. //'update' => 'radio',
  328. 'option' => $yes,
  329. //'list' => true,
  330. //'edit' => true,
  331. ),
  332. 'youhui' => array
  333. (
  334. 'type' => 'int-11',
  335. 'name' => '是否每日优惠',
  336. 'default' => '2',
  337. 'desc' => '是否每日优惠',
  338. 'match' => 'is_numeric',
  339. //'update' => 'radio',
  340. 'option' => $yes,
  341. //'list' => true,
  342. //'edit' => true,
  343. ),
  344. 'content' => array
  345. (
  346. 'type' => 'text-800',
  347. 'name' => '内容介绍',
  348. 'default' => '',
  349. 'desc' => '内容介绍',
  350. 'match' => 'is_string',
  351. 'update' => 'editor',
  352. 'key' => '1',
  353. ),
  354. 'status' => array
  355. (
  356. 'type' => 'tinyint-1',
  357. 'name' => '状态',
  358. 'default' => '2',
  359. 'desc' => '状态',
  360. 'match' => 'is_numeric',
  361. //'update' => 'select',
  362. 'option' => $status,
  363. 'search' => 'select',
  364. 'list' => true,
  365. 'edit' => true,
  366. ),
  367. 'reorder' => array
  368. (
  369. 'type' => 'int-11',
  370. 'name' => '排序-数值越大越靠前,相当于置顶',
  371. 'default' => '1',
  372. 'desc' => '请输入排序',
  373. 'match' => 'option',
  374. //'update' => 'text',
  375. 'search' => 'order',
  376. 'list' => true,
  377. 'order' => 'desc',
  378. 'edit' => true,
  379. ),
  380. 'state' => array
  381. (
  382. 'type' => 'tinyint-1',
  383. 'name' => '数据状态',
  384. 'default' => '1',
  385. 'desc' => '请选择状态',
  386. 'match' => 'is_numeric',
  387. ),
  388. 'udate' => array
  389. (
  390. 'type' => 'int-11',
  391. 'name' => '更新时间',
  392. 'match' => array('is_numeric', time()),
  393. 'desc' => '',
  394. ),
  395. 'cdate' => array
  396. (
  397. 'type' => 'int-11',
  398. 'name' => '发布时间',
  399. 'match' => array('is_numeric', time()),
  400. 'desc' => '',
  401. # 只有insert时才生效
  402. 'insert' => true,
  403. 'search' => 'date',
  404. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  405. ),
  406. ),
  407. # 索引
  408. 'index' => array
  409. (
  410. 1 => array
  411. (
  412. 'search' => 'category,top_category_id,second_category_id,category_id,mode,area',
  413. ),
  414. # 版本号 更改版本号会更新当前表的索引
  415. 'version' => 1,
  416. ),
  417. # 管理功能
  418. 'manage' => array
  419. (
  420. // 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
  421. 'res' => array
  422. (
  423. //'css' => 'demo',
  424. ),
  425. //'insert' => false,
  426. //'delete' => false,
  427. //'mul' => true,
  428. # 自定义快捷新增和编辑
  429. 'button' => array
  430. (
  431. //'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'),
  432. ),
  433. # 列表里的按钮
  434. 'list_button' => array
  435. (
  436. 'update' => array('编辑', 'info'),
  437. 'fast' => array('属性设置', '"info_attr&project=goods&search_option_info_id={id}&search_option_category={category}&oper_parent=info&oper_project=goods&oper_save_jump=info&where_id={id}"', '{price_type} == 2'),
  438. 'fast_list' => array('价格设置', '"info_sku&project=goods&goods_id={id}&page_type=1"', '{price_type} > 0'),
  439. 'br1' => array('<br />'),
  440. 'delete' => '删除',
  441. ),
  442. ),
  443. # request 请求接口定义
  444. 'request' => array
  445. (
  446. 'getAllByName' => array
  447. (
  448. # 匹配的正则或函数 选填项
  449. 'option' => array
  450. (
  451. 'id' => array('yes', 'in'),
  452. 'name' => array('yes', 'like'),
  453. 'state' => 1,
  454. ),
  455. 'type' => 'all',
  456. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  457. 'col' => '*,name as value,name as label|id',
  458. ),
  459. # 后台搜索用到
  460. 'search' => array
  461. (
  462. # 匹配的正则或函数 选填项
  463. 'option' => array
  464. (
  465. 'ids' => array('yes-id', 'in'),
  466. 'name' => array('yes', 'like'),
  467. 'price_type' => 'yes',
  468. 'id' => 'yes',
  469. 'state' => 1,
  470. ),
  471. 'type' => 'all',
  472. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  473. 'limit' => '0,10',
  474. 'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
  475. ),
  476. # 推荐列表
  477. 'getTop' => array
  478. (
  479. # 匹配的正则或函数 选填项
  480. 'option' => array
  481. (
  482. 'hot' => 'yes',
  483. 'top' => 'yes',
  484. 'youhui' => 'yes',
  485. 'status' => 1,
  486. 'state' => 1,
  487. ),
  488. 'type' => 'all',
  489. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  490. 'limit' => '0,6',
  491. 'col' => '*,id as goods_id',
  492. ),
  493. # 列表
  494. 'getAll' => array
  495. (
  496. # 匹配的正则或函数 选填项
  497. 'option' => array
  498. (
  499. 'audit' => 2,
  500. 'category' => array('yes', 'like'),
  501. 'top_category_id' => 'yes',
  502. 'second_category_id' => 'yes',
  503. 'category_id' => 'yes',
  504. //'status' => 1,
  505. 'state' => 1,
  506. ),
  507. 'type' => 'all',
  508. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  509. 'limit' => '0,10',
  510. //'page' => array(10, 'list'),
  511. 'col' => '*',
  512. ),
  513. # 分页
  514. 'getPageAll' => array
  515. (
  516. # 匹配的正则或函数 选填项
  517. 'option' => array
  518. (
  519. 'shop_id' => 'yes',
  520. 'brand_id' => 'yes',
  521. 'name' => array('yes', 'like'),
  522. 'column_id' => array('yes', 'like'),
  523. 'category' => array('yes', 'like'),
  524. 'top_category_id' => 'yes',
  525. 'second_category_id' => 'yes',
  526. 'category_id' => 'yes',
  527. //'status' => 1,
  528. 'state' => 1,
  529. ),
  530. 'type' => 'all',
  531. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  532. 'page' => array(10, 'list'),
  533. 'col' => '*',
  534. ),
  535. # 更新售出量
  536. 'updateSell' => array
  537. (
  538. 'type' => 'update',
  539. 'where' => array
  540. (
  541. 'id' => 'yes',
  542. ),
  543. 'set' => array
  544. (
  545. 'sell_num' => array('yes', '+='),
  546. ),
  547. ),
  548. ),
  549. );
  550. return $config;