info.php 15 KB

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