goods.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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' => 'store/lib/manage.goodsUpdate',
  14. 'update' => 'store/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. 'store_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_store_id'),
  53. 'list' => 'Dever::load("store/info-find#name", {store_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-find#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}", "store", "{store_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. 'status' => array
  112. (
  113. 'type' => 'tinyint-1',
  114. 'name' => '状态',
  115. 'default' => '2',
  116. 'desc' => '状态',
  117. 'match' => 'is_numeric',
  118. //'update' => 'select',
  119. 'option' => $status,
  120. 'search' => 'select',
  121. 'list' => true,
  122. //'edit' => true,
  123. ),
  124. 'state' => array
  125. (
  126. 'type' => 'tinyint-1',
  127. 'name' => '状态',
  128. 'default' => '1',
  129. 'desc' => '请选择状态',
  130. 'match' => 'is_numeric',
  131. ),
  132. 'cdate' => array
  133. (
  134. 'type' => 'int-11',
  135. 'name' => '创建时间',
  136. 'match' => array('is_numeric', time()),
  137. 'desc' => '',
  138. # 只有insert时才生效
  139. //'insert' => true,
  140. 'search' => 'date',
  141. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  142. ),
  143. ),
  144. 'alter' => array
  145. (
  146. 2 => array
  147. (
  148. array('update', 'add_num', 'add_num', 'float-11,2 0 新增库存'),
  149. array('update', 'total_num', 'total_num', 'float-11,2 0 总库存'),
  150. array('update', 'sell_num', 'sell_num', 'float-11,2 0 销量'),
  151. ),
  152. 'version' => 2,
  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=store&other_id={store_id}&page_type=1"'),
  163. ),
  164. ),
  165. 'request' => array
  166. (
  167. # 更新售出量
  168. 'incSell' => array
  169. (
  170. 'type' => 'update',
  171. 'where' => array
  172. (
  173. 'store_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. 'store_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. 'store_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. 'store_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. 'store_id' => 'yes',
  243. 'goods_id' => 'yes',
  244. 'state' => 1,
  245. ),
  246. 'type' => 'one',
  247. 'col' => '*,total_num-sell_num as num',
  248. ),
  249. 'getData' => array
  250. (
  251. # 匹配的正则或函数 选填项
  252. 'option' => array
  253. (
  254. 'top' => array('yes-t_2.top'),
  255. 'youhui' => array('yes-t_2.youhui'),
  256. 'category' => array('yes-t_2.category', 'like'),
  257. 'top_category_id' => array('yes-t_2.top_category_id'),
  258. 'second_category_id' => array('yes-t_2.second_category_id'),
  259. 'category_id' => array('yes-t_2.category_id'),
  260. 'status' => array('yes-t_2.status', 1),
  261. 'state' => array('yes-t_2.state', 1),
  262. ),
  263. # 联表
  264. 'join' => array
  265. (
  266. array
  267. (
  268. 'table' => 'goods/info',
  269. 'type' => 'left join',
  270. 'on' => array('goods_id','id'),
  271. 'col' => 'goods_id',
  272. ),
  273. ),
  274. 'type' => 'all',
  275. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  276. 'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
  277. ),
  278. ),
  279. );