goods.php 10 KB

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