info.php 17 KB

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