goods_sku.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?php
  2. $config = array
  3. (
  4. # 表名
  5. 'name' => 'goods_sku',
  6. # 显示给用户看的名称
  7. 'lang' => '商品价格设置',
  8. 'order' => 200,
  9. 'menu' => false,
  10. 'end' => array
  11. (
  12. 'insert' => 'shop/lib/manage.skuUpdate',
  13. 'update' => 'shop/lib/manage.skuUpdate',
  14. ),
  15. # 数据结构 不同的字段放这里
  16. 'struct' => array
  17. (
  18. 'id' => array
  19. (
  20. 'type' => 'int-11',
  21. 'name' => 'ID',
  22. 'default' => '',
  23. 'desc' => '',
  24. 'match' => 'is_numeric',
  25. //'list' => true,
  26. ),
  27. 'shop_id' => array
  28. (
  29. 'type' => 'int-11',
  30. 'name' => '所属门店',
  31. 'default' => '',
  32. 'desc' => '所属门店',
  33. 'match' => 'is_numeric',
  34. //'list' => 'Dever::load("shop/info-find#name", {shop_id})',
  35. ),
  36. 'goods_id' => array
  37. (
  38. 'type' => 'int-11',
  39. 'name' => '商品名称',
  40. 'default' => '',
  41. 'desc' => '商品名称',
  42. 'match' => 'is_numeric',
  43. //'list' => 'Dever::load("goods/info-find#name", {goods_id})',
  44. ),
  45. 'sku_id' => array
  46. (
  47. 'type' => 'int-11',
  48. 'name' => 'sku_id',
  49. 'default' => '-1',
  50. 'desc' => 'sku_id',
  51. 'match' => 'is_numeric',
  52. ),
  53. 'add_num' => array
  54. (
  55. 'type' => 'int-11',
  56. 'name' => '新增库存-输入小于0的数字,则为减少库存',
  57. 'default' => '0',
  58. 'desc' => '新增库存',
  59. 'match' => 'is_numeric',
  60. ),
  61. 'total_num' => array
  62. (
  63. 'type' => 'int-11',
  64. 'name' => '总库存',
  65. 'default' => '0',
  66. 'desc' => '总库存',
  67. 'match' => 'is_numeric',
  68. ),
  69. 'sell_num' => array
  70. (
  71. 'type' => 'int-11',
  72. 'name' => '销量',
  73. 'default' => '0',
  74. 'desc' => '请填写销量',
  75. 'match' => 'option',
  76. 'search' => 'order',
  77. //'list' => true,
  78. ),
  79. 'reorder' => array
  80. (
  81. 'type' => 'int-11',
  82. 'name' => '排序-数值越大越靠前,相当于置顶',
  83. 'default' => '1',
  84. 'desc' => '请输入排序',
  85. 'match' => 'option',
  86. //'update' => 'text',
  87. 'search' => 'order',
  88. 'list' => true,
  89. 'order' => 'desc',
  90. 'edit' => true,
  91. ),
  92. 'state' => array
  93. (
  94. 'type' => 'tinyint-1',
  95. 'name' => '数据状态',
  96. 'default' => '1',
  97. 'desc' => '请选择状态',
  98. 'match' => 'is_numeric',
  99. ),
  100. 'cdate' => array
  101. (
  102. 'type' => 'int-11',
  103. 'name' => '发布时间',
  104. 'match' => array('is_numeric', time()),
  105. 'desc' => '',
  106. # 只有insert时才生效
  107. 'insert' => true,
  108. //'search' => 'date',
  109. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  110. ),
  111. ),
  112. 'manage' => array
  113. (
  114. 'insert' => false,
  115. 'edit' => false,
  116. 'delete' => false,
  117. 'num' => false,
  118. 'page_list_table' => 'sku',
  119. # 自定义快捷新增和编辑
  120. 'button' => array
  121. (
  122. //'自定义属性' => array('fast', 1, 'config&where_id=1'),
  123. ),
  124. ),
  125. # request 请求接口定义
  126. 'request' => array
  127. (
  128. 'getDataPage' => array
  129. (
  130. # 匹配的正则或函数 选填项
  131. 'option' => array
  132. (
  133. 'shop_id' => array('yes-t_1.shop_id'),
  134. 'name' => array('yes-t_2.name', 'like'),
  135. 'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
  136. 'column' => array('yes-t_2.column_id', 'like'),
  137. 'category' => array('yes-t_2.category', 'like'),
  138. 'top_category_id' => array('yes-t_2.top_category_id'),
  139. 'second_category_id' => array('yes-t_2.second_category_id'),
  140. 'category_id' => array('yes-t_2.category_id'),
  141. 'status' => array('yes-t_2.status', 1),
  142. 'state' => array('yes-t_2.state', 1),
  143. 'state_1' => array('yes-t_1.state', 1),
  144. ),
  145. # 联表
  146. 'join' => array
  147. (
  148. array
  149. (
  150. 'table' => 'goods/info',
  151. 'type' => 'left join',
  152. 'on' => array('goods_id','id'),
  153. 'col' => 'goods_id',
  154. ),
  155. ),
  156. 'type' => 'all',
  157. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  158. 'page' => array(30, 'list'),
  159. 'col' => '*,t_2.name,t_2.cover,t_2.id as id,t_1.total_num-t_1.sell_num as total,t_1.sell_num',
  160. ),
  161. # 列表
  162. 'getData' => array
  163. (
  164. # 匹配的正则或函数 选填项
  165. 'option' => array
  166. (
  167. 'shop_id' => 'yes',
  168. 'goods_id' => 'yes',
  169. 'sku_id' => 'yes',
  170. 'state' => 1,
  171. ),
  172. 'type' => 'all',
  173. 'order' => array('id' => 'desc'),
  174. 'col' => '*,total_num-sell_num as total|sku_id',
  175. ),
  176. # 获取单条数据
  177. 'getOne' => array
  178. (
  179. # 匹配的正则或函数 选填项
  180. 'option' => array
  181. (
  182. 'shop_id' => 'yes',
  183. 'goods_id' => 'yes',
  184. 'sku_id' => 'yes',
  185. 'state' => 1,
  186. ),
  187. 'type' => 'one',
  188. 'col' => '*,total_num-sell_num as total',
  189. ),
  190. # 更新售出量
  191. 'incSell' => array
  192. (
  193. 'type' => 'update',
  194. 'where' => array
  195. (
  196. 'shop_id' => 'yes',
  197. 'goods_id' => 'yes',
  198. 'sku_id' => 'yes',
  199. ),
  200. 'set' => array
  201. (
  202. 'sell_num' => array('yes', '+='),
  203. ),
  204. ),
  205. # 减少售出量
  206. 'decSell' => array
  207. (
  208. 'type' => 'update',
  209. 'where' => array
  210. (
  211. 'shop_id' => 'yes',
  212. 'goods_id' => 'yes',
  213. 'sku_id' => 'yes',
  214. ),
  215. 'set' => array
  216. (
  217. 'sell_num' => array('yes', '-='),
  218. ),
  219. ),
  220. # 更新总库存
  221. 'updateTotal' => array
  222. (
  223. 'type' => 'update',
  224. 'where' => array
  225. (
  226. 'id' => 'yes',
  227. ),
  228. 'set' => array
  229. (
  230. 'total_num' => array('yes', '+='),
  231. ),
  232. ),
  233. # 增加总库存
  234. 'incTotal' => array
  235. (
  236. 'type' => 'update',
  237. 'where' => array
  238. (
  239. 'shop_id' => 'yes',
  240. 'goods_id' => 'yes',
  241. 'sku_id' => 'yes',
  242. ),
  243. 'set' => array
  244. (
  245. 'total_num' => array('yes', '+='),
  246. ),
  247. ),
  248. # 减少总库存
  249. 'decTotal' => array
  250. (
  251. 'type' => 'update',
  252. 'where' => array
  253. (
  254. 'shop_id' => 'yes',
  255. 'goods_id' => 'yes',
  256. 'sku_id' => 'yes',
  257. ),
  258. 'set' => array
  259. (
  260. 'total_num' => array('yes', '-='),
  261. ),
  262. ),
  263. ),
  264. );
  265. return $config;