info.php 16 KB

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