info.php 17 KB

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