info.php 20 KB

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