goods.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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' => 'int-11',
  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' => 'int-11',
  96. 'name' => '总库存',
  97. 'default' => '0',
  98. 'desc' => '总库存',
  99. 'match' => 'is_numeric',
  100. ),
  101. 'sell_num' => array
  102. (
  103. 'type' => 'int-11',
  104. 'name' => '销量',
  105. 'default' => '0',
  106. 'desc' => '请填写销量',
  107. 'match' => 'option',
  108. 'search' => 'order',
  109. //'list' => true,
  110. ),
  111. 'min' => array
  112. (
  113. 'type' => 'int-11',
  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. 'manage' => array
  155. (
  156. 'insert' => false,
  157. 'edit' => false,
  158. 'delete' => false,
  159. # 列表里的按钮
  160. 'list_button' => array
  161. (
  162. 'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=shop&other_id={shop_id}&page_type=1"', '{price_type} <= 3'),
  163. ),
  164. ),
  165. 'request' => array
  166. (
  167. # 更新售出量
  168. 'incSell' => array
  169. (
  170. 'type' => 'update',
  171. 'where' => array
  172. (
  173. 'shop_id' => 'yes',
  174. 'goods_id' => 'yes',
  175. ),
  176. 'set' => array
  177. (
  178. 'sell_num' => array('yes', '+='),
  179. ),
  180. ),
  181. # 减少售出量
  182. 'decSell' => array
  183. (
  184. 'type' => 'update',
  185. 'where' => array
  186. (
  187. 'shop_id' => 'yes',
  188. 'goods_id' => 'yes',
  189. ),
  190. 'set' => array
  191. (
  192. 'sell_num' => array('yes', '-='),
  193. ),
  194. ),
  195. # 更新总库存
  196. 'updateTotal' => array
  197. (
  198. 'type' => 'update',
  199. 'where' => array
  200. (
  201. 'id' => 'yes',
  202. ),
  203. 'set' => array
  204. (
  205. 'total_num' => array('yes', '+='),
  206. ),
  207. ),
  208. # 增加总库存
  209. 'incTotal' => array
  210. (
  211. 'type' => 'update',
  212. 'where' => array
  213. (
  214. 'shop_id' => 'yes',
  215. 'goods_id' => 'yes',
  216. ),
  217. 'set' => array
  218. (
  219. 'total_num' => array('yes', '+='),
  220. ),
  221. ),
  222. # 减少总库存
  223. 'decTotal' => array
  224. (
  225. 'type' => 'update',
  226. 'where' => array
  227. (
  228. 'shop_id' => 'yes',
  229. 'goods_id' => 'yes',
  230. ),
  231. 'set' => array
  232. (
  233. 'total_num' => array('yes', '-='),
  234. ),
  235. ),
  236. # 获取单条数据
  237. 'getOne' => array
  238. (
  239. # 匹配的正则或函数 选填项
  240. 'option' => array
  241. (
  242. 'shop_id' => 'yes',
  243. 'goods_id' => 'yes',
  244. 'state' => 1,
  245. ),
  246. 'type' => 'one',
  247. 'col' => '*,total_num-sell_num as num',
  248. ),
  249. # 获取后台列表
  250. 'list' => array
  251. (
  252. # 匹配的正则或函数 选填项
  253. 'option' => array
  254. (
  255. 'status' => 'yes',
  256. 'shop_id' => 'yes',
  257. 'state' => 1,
  258. ),
  259. 'type' => 'all',
  260. 'page' => array(15, 'list'),
  261. 'col' => '*',
  262. ),
  263. # 推荐列表
  264. 'getTop' => array
  265. (
  266. # 匹配的正则或函数 选填项
  267. 'option' => array
  268. (
  269. 'shop_id' => array('yes-t_1.shop_id'),
  270. 'hot' => array('yes-t_2.hot'),
  271. 'top' => array('yes-t_2.top'),
  272. 'status' => array('yes-t_2.status', 1),
  273. 'state' => array('yes-t_2.state', 1),
  274. ),
  275. # 联表
  276. 'join' => array
  277. (
  278. array
  279. (
  280. 'table' => 'goods/info',
  281. 'type' => 'left join',
  282. 'on' => array('goods_id','id'),
  283. 'col' => 'goods_id',
  284. ),
  285. ),
  286. 'type' => 'all',
  287. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  288. 'limit' => '0,6',
  289. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  290. ),
  291. 'getData' => array
  292. (
  293. # 匹配的正则或函数 选填项
  294. 'option' => array
  295. (
  296. 'shop_id' => array('yes-t_1.shop_id'),
  297. 'hot' => array('yes-t_2.hot'),
  298. 'top' => array('yes-t_2.top'),
  299. //'youhui' => array('yes-t_2.youhui'),
  300. 'price_type' => array('yes-t_2.price_type', 'in'),
  301. 'sell_type' => array('yes-t_2.sell_type'),
  302. 'name' => array('yes-t_2.name', 'like'),
  303. 'column' => array('yes-t_2.column_id', 'like'),
  304. 'category' => array('yes-t_2.category', 'like'),
  305. 'top_category_id' => array('yes-t_2.top_category_id'),
  306. 'second_category_id' => array('yes-t_2.second_category_id'),
  307. 'category_id' => array('yes-t_2.category_id'),
  308. 'status' => array('yes-t_2.status', 1),
  309. 'state' => array('yes-t_2.state', 1),
  310. 'state_1' => array('yes-t_1.state', 1),
  311. ),
  312. # 联表
  313. 'join' => array
  314. (
  315. array
  316. (
  317. 'table' => 'goods/info',
  318. 'type' => 'left join',
  319. 'on' => array('goods_id','id'),
  320. 'col' => 'goods_id',
  321. ),
  322. ),
  323. 'type' => 'all',
  324. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  325. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  326. ),
  327. 'getDataPage' => array
  328. (
  329. # 匹配的正则或函数 选填项
  330. 'option' => array
  331. (
  332. 'shop_id' => array('yes-t_1.shop_id'),
  333. 'hot' => array('yes-t_2.hot'),
  334. 'top' => array('yes-t_2.top'),
  335. //'youhui' => array('yes-t_2.youhui'),
  336. 'price_type' => array('yes-t_2.price_type', 'in'),
  337. 'sell_type' => array('yes-t_2.sell_type'),
  338. 'name' => array('yes-t_2.name', 'like'),
  339. 'column' => array('yes-t_2.column_id', 'like'),
  340. 'category' => array('yes-t_2.category', 'like'),
  341. 'top_category_id' => array('yes-t_2.top_category_id'),
  342. 'second_category_id' => array('yes-t_2.second_category_id'),
  343. 'category_id' => array('yes-t_2.category_id'),
  344. 'status' => array('yes-t_2.status', 1),
  345. 'state' => array('yes-t_2.state', 1),
  346. 'state_1' => array('yes-t_1.state', 1),
  347. ),
  348. # 联表
  349. 'join' => array
  350. (
  351. array
  352. (
  353. 'table' => 'goods/info',
  354. 'type' => 'left join',
  355. 'on' => array('goods_id','id'),
  356. 'col' => 'goods_id',
  357. ),
  358. ),
  359. 'type' => 'all',
  360. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  361. 'page' => array(10, 'list'),
  362. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  363. ),
  364. ),
  365. );