goods_sku.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <?php
  2. $config = array
  3. (
  4. # 表名
  5. 'name' => 'goods_sku',
  6. # 显示给用户看的名称
  7. 'lang' => '商品价格设置',
  8. 'order' => 200,
  9. 'menu' => false,
  10. /*
  11. 'end' => array
  12. (
  13. 'insert' => 'scm_role/lib/seller.skuUpdate',
  14. 'update' => 'scm_role/lib/seller.skuUpdate',
  15. ),
  16. */
  17. # 数据结构 不同的字段放这里
  18. 'struct' => array
  19. (
  20. 'id' => array
  21. (
  22. 'type' => 'int-11',
  23. 'name' => 'ID',
  24. 'default' => '',
  25. 'desc' => '',
  26. 'match' => 'is_numeric',
  27. //'list' => true,
  28. ),
  29. 'supplier_id' => array
  30. (
  31. 'type' => 'int-11',
  32. 'name' => '所属供应商',
  33. 'default' => '',
  34. 'desc' => '所属供应商',
  35. 'match' => 'is_numeric',
  36. 'update' => 'hidden',
  37. 'search' => 'hidden',
  38. 'value' => Dever::input('search_option_supplier_id'),
  39. 'list' => 'Dever::load("scm_supplier/info-one#name", {supplier_id})',
  40. ),
  41. 'goods-info_sku-code'=> array
  42. (
  43. 'name' => '商品编码',
  44. 'default' => '',
  45. 'desc' => '商品编码',
  46. 'match' => 'option',
  47. # 读取另外表的关联方式
  48. 'sync' => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
  49. 'list' => true,
  50. 'list_order' => 4,
  51. ),
  52. 'goods_id' => array
  53. (
  54. 'type' => 'int-11',
  55. 'name' => '商品名称',
  56. 'default' => '',
  57. 'desc' => '商品名称',
  58. 'match' => 'is_numeric',
  59. 'update' => 'select',
  60. 'update_search' => 'scm_product/lib/manage.search',
  61. 'list' => 'Dever::load("scm_product/info-one#name", {goods_id})',
  62. ),
  63. 'sku_id' => array
  64. (
  65. 'type' => 'int-11',
  66. 'name' => '规格型号',
  67. 'default' => '-1',
  68. 'desc' => '规格型号',
  69. 'match' => 'is_numeric',
  70. ),
  71. 'cost_price' => array
  72. (
  73. 'type' => 'varchar-100',
  74. 'name' => '成本价',
  75. 'default' => '',
  76. 'desc' => '成本价',
  77. 'match' => 'option',
  78. 'update' => 'text',
  79. //'list' => true,
  80. ),
  81. 'in_num' => array
  82. (
  83. 'type' => 'decimal-11,2',
  84. 'name' => '入库库存',
  85. 'default' => '0',
  86. 'desc' => '入库库存',
  87. 'match' => 'is_numeric',
  88. ),
  89. 'out_num' => array
  90. (
  91. 'type' => 'decimal-11,2',
  92. 'name' => '出库库存',
  93. 'default' => '0',
  94. 'desc' => '出库库存',
  95. 'match' => 'option',
  96. ),
  97. 'state' => array
  98. (
  99. 'type' => 'tinyint-1',
  100. 'name' => '数据状态',
  101. 'default' => '1',
  102. 'desc' => '请选择状态',
  103. 'match' => 'is_numeric',
  104. ),
  105. 'cdate' => array
  106. (
  107. 'type' => 'int-11',
  108. 'name' => '发布时间',
  109. 'match' => array('is_numeric', time()),
  110. 'desc' => '',
  111. # 只有insert时才生效
  112. 'insert' => true,
  113. //'search' => 'date',
  114. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  115. ),
  116. ),
  117. 'manage' => array
  118. (
  119. 'insert' => false,
  120. 'edit' => false,
  121. 'delete' => false,
  122. //'excel' => array(array('导出门店库存', '门店库存', '')),
  123. 'page_list_table' => 'sku',
  124. ),
  125. # request 请求接口定义
  126. 'request' => array
  127. (
  128. # 后台搜索用到,也可以不加,自动生成
  129. 'search' => array
  130. (
  131. # 匹配的正则或函数 选填项
  132. 'option' => array
  133. (
  134. 'name' => array('yes-t_2.name', 'like'),
  135. 'supplier_id' => array('yes-t_1.supplier_id'),
  136. 'status' => 'yes-t_2.status-1',
  137. 'state' => 'yes-t_2.state-1',
  138. 'state_1' => 'yes-t_1.state-1',
  139. ),
  140. # 联表
  141. 'join' => array
  142. (
  143. array
  144. (
  145. 'table' => 'scm_product/info',
  146. 'type' => 'left join',
  147. 'on' => array('goods_id','id'),
  148. 'col' => 'goods_id',
  149. ),
  150. ),
  151. 'type' => 'all',
  152. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  153. 'col' => '*,t_2.*,t_2.id as value, "" as selected, "" as disabled',
  154. ),
  155. 'getDataPage' => array
  156. (
  157. # 匹配的正则或函数 选填项
  158. 'option' => array
  159. (
  160. 'supplier_id' => array('yes-t_1.supplier_id'),
  161. 'name' => array('yes-t_2.name', 'like'),
  162. 'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
  163. 'category' => array('yes-t_2.category', 'like'),
  164. 'top_category_id' => array('yes-t_2.top_category_id'),
  165. 'second_category_id' => array('yes-t_2.second_category_id'),
  166. 'category_id' => array('yes-t_2.category_id'),
  167. 'status' => array('yes-t_2.status', 1),
  168. 'state' => array('yes-t_2.state', 1),
  169. 'state_1' => array('yes-t_1.state', 1),
  170. ),
  171. # 联表
  172. 'join' => array
  173. (
  174. array
  175. (
  176. 'table' => 'scm_product/info',
  177. 'type' => 'left join',
  178. 'on' => array('goods_id','id'),
  179. 'col' => 'goods_id',
  180. ),
  181. ),
  182. 'type' => 'all',
  183. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  184. 'page' => array(30, 'list'),
  185. 'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
  186. ),
  187. 'getData' => array
  188. (
  189. # 匹配的正则或函数 选填项
  190. 'option' => array
  191. (
  192. 'supplier_id' => array('yes-t_1.supplier_id'),
  193. 'name' => array('yes-t_2.name', 'like'),
  194. 'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
  195. 'category' => array('yes-t_2.category', 'like'),
  196. 'top_category_id' => array('yes-t_2.top_category_id'),
  197. 'second_category_id' => array('yes-t_2.second_category_id'),
  198. 'category_id' => array('yes-t_2.category_id'),
  199. 'status' => array('yes-t_2.status', 1),
  200. 'state' => array('yes-t_2.state', 1),
  201. 'state_1' => array('yes-t_1.state', 1),
  202. ),
  203. # 联表
  204. 'join' => array
  205. (
  206. array
  207. (
  208. 'table' => 'scm_product/info',
  209. 'type' => 'left join',
  210. 'on' => array('goods_id','id'),
  211. 'col' => 'goods_id',
  212. ),
  213. ),
  214. 'type' => 'all',
  215. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  216. 'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.in_num-t_1.out_num as total,t_1.out_num',
  217. ),
  218. # 列表
  219. 'getList' => array
  220. (
  221. # 匹配的正则或函数 选填项
  222. 'option' => array
  223. (
  224. 'supplier_id' => 'yes',
  225. 'goods_id' => 'yes',
  226. 'sku_id' => 'yes',
  227. 'state' => 1,
  228. ),
  229. 'type' => 'all',
  230. 'order' => array('id' => 'desc'),
  231. 'col' => '*,in_num-out_num as total|sku_id',
  232. ),
  233. # 获取单条数据
  234. 'getOne' => array
  235. (
  236. # 匹配的正则或函数 选填项
  237. 'option' => array
  238. (
  239. 'supplier_id' => 'yes',
  240. 'goods_id' => 'yes',
  241. 'sku_id' => 'yes',
  242. 'state' => 1,
  243. ),
  244. 'type' => 'one',
  245. 'col' => '*,in_num-out_num as total',
  246. ),
  247. # 更新售出量
  248. 'incSell' => array
  249. (
  250. 'type' => 'update',
  251. 'where' => array
  252. (
  253. 'supplier_id' => 'yes',
  254. 'goods_id' => 'yes',
  255. 'sku_id' => 'yes',
  256. ),
  257. 'set' => array
  258. (
  259. 'out_num' => array('yes', '+='),
  260. ),
  261. ),
  262. # 减少售出量
  263. 'decSell' => array
  264. (
  265. 'type' => 'update',
  266. 'where' => array
  267. (
  268. 'supplier_id' => 'yes',
  269. 'goods_id' => 'yes',
  270. 'sku_id' => 'yes',
  271. ),
  272. 'set' => array
  273. (
  274. 'out_num' => array('yes', '-='),
  275. ),
  276. ),
  277. # 更新总库存
  278. 'updateTotal' => array
  279. (
  280. 'type' => 'update',
  281. 'where' => array
  282. (
  283. 'id' => 'yes',
  284. ),
  285. 'set' => array
  286. (
  287. 'in_num' => array('yes', '+='),
  288. ),
  289. ),
  290. # 增加总库存
  291. 'incTotal' => array
  292. (
  293. 'type' => 'update',
  294. 'where' => array
  295. (
  296. 'supplier_id' => 'yes',
  297. 'goods_id' => 'yes',
  298. 'sku_id' => 'yes',
  299. ),
  300. 'set' => array
  301. (
  302. 'in_num' => array('yes', '+='),
  303. ),
  304. ),
  305. # 减少总库存
  306. 'decTotal' => array
  307. (
  308. 'type' => 'update',
  309. 'where' => array
  310. (
  311. 'supplier_id' => 'yes',
  312. 'goods_id' => 'yes',
  313. 'sku_id' => 'yes',
  314. ),
  315. 'set' => array
  316. (
  317. 'in_num' => array('yes', '-='),
  318. ),
  319. ),
  320. ),
  321. );
  322. return $config;