goods.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <?php
  2. $status = Dever::config('base')->status;
  3. return array
  4. (
  5. # 表名
  6. 'name' => 'goods',
  7. # 显示给用户看的名称
  8. 'lang' => '商品列表',
  9. 'order' => 10,
  10. 'menu' => false,
  11. 'ends' => array
  12. (
  13. 'insert' => 'shop/lib/manage.goodsUpdate',
  14. 'update' => 'shop/lib/manage.goodsUpdate',
  15. ),
  16. 'fill' => array
  17. (
  18. # 从哪个表填充
  19. 'goods/info' => array
  20. (
  21. # 条件,另外一个表的字段 => 本表的字段
  22. 'where' => array('id' => 'goods_id'),
  23. # 要填充的数据,另外一个表的字段 => 本表的字段,如果不填写就是所有的
  24. 'update' => array('price_type' => 'price_type', 'status' => 'status'),
  25. # 不需要填充的字段 与update互斥
  26. //'no' => array('id', 'seller_id', 'service_id', 'chose', 'state', 'cdate')
  27. )
  28. ),
  29. # 数据结构
  30. 'struct' => array
  31. (
  32. 'id' => array
  33. (
  34. 'type' => 'int-11',
  35. 'name' => 'ID',
  36. 'default' => '',
  37. 'desc' => '',
  38. 'match' => 'is_numeric',
  39. 'search' => 'order',
  40. 'update' => 'hidden',
  41. //'list' => true,
  42. ),
  43. 'shop_id' => array
  44. (
  45. 'type' => 'int-11',
  46. 'name' => '所属门店',
  47. 'default' => '',
  48. 'desc' => '所属门店',
  49. 'match' => 'is_numeric',
  50. 'update' => 'hidden',
  51. 'search' => 'hidden',
  52. 'value' => Dever::input('search_option_shop_id'),
  53. 'list' => 'Dever::load("shop/info-one#name", {shop_id})',
  54. ),
  55. 'goods_id' => array
  56. (
  57. 'type' => 'int-11',
  58. 'name' => '商品名称',
  59. 'default' => '',
  60. 'desc' => '商品名称',
  61. 'match' => 'is_numeric',
  62. 'update' => 'select',
  63. 'update_search' => 'goods/lib/manage.search',
  64. 'list' => 'Dever::load("goods/info-one#name", {goods_id})',
  65. ),
  66. 'category_id' => array
  67. (
  68. 'type' => 'int-11',
  69. 'name' => '分类id',
  70. 'default' => '',
  71. 'desc' => '分类id',
  72. 'match' => 'is_numeric',
  73. ),
  74. 'price_type' => array
  75. (
  76. 'type' => 'int-11',
  77. 'name' => '价格类型',
  78. 'default' => '1',
  79. 'desc' => '价格类型',
  80. 'match' => 'is_numeric',
  81. ),
  82. 'add_num' => array
  83. (
  84. 'type' => 'float-11,2',
  85. 'name' => '新增库存-输入小于0的数字,则为减少库存',
  86. 'default' => '0',
  87. 'desc' => '新增库存',
  88. 'match' => 'is_numeric',
  89. 'update' => Dever::input('col') ? 'text' : 'hidden',
  90. 'list_name' => '当前库存',
  91. 'list' => 'Dever::load("goods/lib/sku.table", "{goods_id}", "shop", "{shop_id}", false, false)',
  92. ),
  93. 'total_num' => array
  94. (
  95. 'type' => 'float-11,2',
  96. 'name' => '总库存',
  97. 'default' => '0',
  98. 'desc' => '总库存',
  99. 'match' => 'is_numeric',
  100. ),
  101. 'sell_num' => array
  102. (
  103. 'type' => 'float-11,2',
  104. 'name' => '销量',
  105. 'default' => '0',
  106. 'desc' => '请填写销量',
  107. 'match' => 'option',
  108. 'search' => 'order',
  109. //'list' => true,
  110. ),
  111. 'min' => array
  112. (
  113. 'type' => 'float-11,2',
  114. 'name' => '起购数',
  115. 'default' => '1',
  116. 'desc' => '起购数',
  117. 'match' => 'is_string',
  118. 'update' => 'text',
  119. //'list' => true,
  120. ),
  121. 'status' => array
  122. (
  123. 'type' => 'tinyint-1',
  124. 'name' => '状态',
  125. 'default' => '2',
  126. 'desc' => '状态',
  127. 'match' => 'is_numeric',
  128. //'update' => 'select',
  129. 'option' => $status,
  130. 'search' => 'select',
  131. 'list' => true,
  132. //'edit' => true,
  133. ),
  134. 'state' => array
  135. (
  136. 'type' => 'tinyint-1',
  137. 'name' => '状态',
  138. 'default' => '1',
  139. 'desc' => '请选择状态',
  140. 'match' => 'is_numeric',
  141. ),
  142. 'cdate' => array
  143. (
  144. 'type' => 'int-11',
  145. 'name' => '创建时间',
  146. 'match' => array('is_numeric', time()),
  147. 'desc' => '',
  148. # 只有insert时才生效
  149. //'insert' => true,
  150. //'search' => 'date',
  151. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  152. ),
  153. ),
  154. 'alter' => array
  155. (
  156. 2 => array
  157. (
  158. array('update', 'add_num', 'add_num', 'float-11,2 0 新增库存'),
  159. array('update', 'total_num', 'total_num', 'float-11,2 0 总库存'),
  160. array('update', 'sell_num', 'sell_num', 'float-11,2 0 销量'),
  161. array('update', 'min', 'min', 'float-11,2 0 起购数'),
  162. ),
  163. 'version' => 2,
  164. ),
  165. 'manage' => array
  166. (
  167. 'insert' => false,
  168. 'edit' => false,
  169. 'delete' => false,
  170. # 列表里的按钮
  171. 'list_button' => array
  172. (
  173. 'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
  174. ),
  175. ),
  176. 'request' => array
  177. (
  178. # 更新售出量
  179. 'incSell' => array
  180. (
  181. 'type' => 'update',
  182. 'where' => array
  183. (
  184. 'shop_id' => 'yes',
  185. 'goods_id' => 'yes',
  186. ),
  187. 'set' => array
  188. (
  189. 'sell_num' => array('yes', '+='),
  190. ),
  191. ),
  192. # 减少售出量
  193. 'decSell' => array
  194. (
  195. 'type' => 'update',
  196. 'where' => array
  197. (
  198. 'shop_id' => 'yes',
  199. 'goods_id' => 'yes',
  200. ),
  201. 'set' => array
  202. (
  203. 'sell_num' => array('yes', '-='),
  204. ),
  205. ),
  206. # 更新总库存
  207. 'updateTotal' => array
  208. (
  209. 'type' => 'update',
  210. 'where' => array
  211. (
  212. 'id' => 'yes',
  213. ),
  214. 'set' => array
  215. (
  216. 'total_num' => array('yes', '+='),
  217. ),
  218. ),
  219. # 增加总库存
  220. 'incTotal' => array
  221. (
  222. 'type' => 'update',
  223. 'where' => array
  224. (
  225. 'shop_id' => 'yes',
  226. 'goods_id' => 'yes',
  227. ),
  228. 'set' => array
  229. (
  230. 'total_num' => array('yes', '+='),
  231. ),
  232. ),
  233. # 减少总库存
  234. 'decTotal' => array
  235. (
  236. 'type' => 'update',
  237. 'where' => array
  238. (
  239. 'shop_id' => 'yes',
  240. 'goods_id' => 'yes',
  241. ),
  242. 'set' => array
  243. (
  244. 'total_num' => array('yes', '-='),
  245. ),
  246. ),
  247. # 获取单条数据
  248. 'getOne' => array
  249. (
  250. # 匹配的正则或函数 选填项
  251. 'option' => array
  252. (
  253. 'shop_id' => 'yes',
  254. 'goods_id' => 'yes',
  255. 'state' => 1,
  256. ),
  257. 'type' => 'one',
  258. 'col' => '*,total_num-sell_num as num',
  259. ),
  260. # 获取后台列表
  261. 'list' => array
  262. (
  263. # 匹配的正则或函数 选填项
  264. 'option' => array
  265. (
  266. 'status' => 'yes',
  267. 'shop_id' => 'yes',
  268. 'state' => 1,
  269. ),
  270. 'type' => 'all',
  271. 'page' => array(15, 'list'),
  272. 'col' => '*',
  273. ),
  274. # 推荐列表
  275. 'getTop' => array
  276. (
  277. # 匹配的正则或函数 选填项
  278. 'option' => array
  279. (
  280. 'shop_id' => array('yes-t_1.shop_id'),
  281. 'hot' => array('yes-t_2.hot'),
  282. 'top' => array('yes-t_2.top'),
  283. 'status' => array('yes-t_2.status', 1),
  284. 'state' => array('yes-t_2.state', 1),
  285. ),
  286. # 联表
  287. 'join' => array
  288. (
  289. array
  290. (
  291. 'table' => 'goods/info',
  292. 'type' => 'left join',
  293. 'on' => array('goods_id','id'),
  294. 'col' => 'goods_id',
  295. ),
  296. ),
  297. 'type' => 'all',
  298. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  299. 'limit' => '0,6',
  300. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  301. ),
  302. 'getData' => array
  303. (
  304. # 匹配的正则或函数 选填项
  305. 'option' => array
  306. (
  307. 'shop_id' => array('yes-t_1.shop_id'),
  308. 'hot' => array('yes-t_2.hot'),
  309. 'top' => array('yes-t_2.top'),
  310. //'youhui' => array('yes-t_2.youhui'),
  311. 'price_type' => array('yes-t_2.price_type', 'in'),
  312. 'sell_type' => array('yes-t_2.sell_type'),
  313. 'name' => array('yes-t_2.name', 'like'),
  314. 'column' => array('yes-t_2.column_id', 'like'),
  315. 'category' => array('yes-t_2.category', 'like'),
  316. 'top_category_id' => array('yes-t_2.top_category_id'),
  317. 'second_category_id' => array('yes-t_2.second_category_id'),
  318. 'category_id' => array('yes-t_2.category_id'),
  319. 'status' => array('yes-t_2.status', 1),
  320. 'state' => array('yes-t_2.state', 1),
  321. 'state_1' => array('yes-t_1.state', 1),
  322. ),
  323. # 联表
  324. 'join' => array
  325. (
  326. array
  327. (
  328. 'table' => 'goods/info',
  329. 'type' => 'left join',
  330. 'on' => array('goods_id','id'),
  331. 'col' => 'goods_id',
  332. ),
  333. ),
  334. 'type' => 'all',
  335. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  336. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  337. ),
  338. 'getDataPage' => array
  339. (
  340. # 匹配的正则或函数 选填项
  341. 'option' => array
  342. (
  343. 'shop_id' => array('yes-t_1.shop_id'),
  344. 'hot' => array('yes-t_2.hot'),
  345. 'top' => array('yes-t_2.top'),
  346. //'youhui' => array('yes-t_2.youhui'),
  347. 'price_type' => array('yes-t_2.price_type', 'in'),
  348. 'sell_type' => array('yes-t_2.sell_type'),
  349. 'name' => array('yes-t_2.name', 'like'),
  350. 'column' => array('yes-t_2.column_id', 'like'),
  351. 'category' => array('yes-t_2.category', 'like'),
  352. 'top_category_id' => array('yes-t_2.top_category_id'),
  353. 'second_category_id' => array('yes-t_2.second_category_id'),
  354. 'category_id' => array('yes-t_2.category_id'),
  355. 'status' => array('yes-t_2.status', 1),
  356. 'state' => array('yes-t_2.state', 1),
  357. 'state_1' => array('yes-t_1.state', 1),
  358. ),
  359. # 联表
  360. 'join' => array
  361. (
  362. array
  363. (
  364. 'table' => 'goods/info',
  365. 'type' => 'left join',
  366. 'on' => array('goods_id','id'),
  367. 'col' => 'goods_id',
  368. ),
  369. ),
  370. 'type' => 'all',
  371. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  372. 'page' => array(10, 'list'),
  373. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  374. ),
  375. ),
  376. );