info.php 16 KB

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