info.php 18 KB

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