goods_sku.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. 'supplier_id' => array('yes-t_1.supplier_id'),
  135. 'status' => 'yes-t_2.status-1',
  136. 'state' => 'yes-t_2.state-1',
  137. 'state_1' => 'yes-t_1.state-1',
  138. ),
  139. # 联表
  140. 'join' => array
  141. (
  142. array
  143. (
  144. 'table' => 'scm_product/info',
  145. 'type' => 'left join',
  146. 'on' => array('goods_id','id'),
  147. 'col' => 'goods_id',
  148. ),
  149. ),
  150. 'type' => 'all',
  151. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
  152. 'col' => '*,t_2.*,t_2.id as value, "" as selected, "" as disabled',
  153. ),
  154. 'getDataPage' => array
  155. (
  156. # 匹配的正则或函数 选填项
  157. 'option' => array
  158. (
  159. 'supplier_id' => array('yes-t_1.supplier_id'),
  160. 'name' => array('yes-t_2.name', 'like'),
  161. 'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
  162. 'category' => array('yes-t_2.category', 'like'),
  163. 'top_category_id' => array('yes-t_2.top_category_id'),
  164. 'second_category_id' => array('yes-t_2.second_category_id'),
  165. 'category_id' => array('yes-t_2.category_id'),
  166. 'status' => array('yes-t_2.status', 1),
  167. 'state' => array('yes-t_2.state', 1),
  168. 'state_1' => array('yes-t_1.state', 1),
  169. ),
  170. # 联表
  171. 'join' => array
  172. (
  173. array
  174. (
  175. 'table' => 'scm_product/info',
  176. 'type' => 'left join',
  177. 'on' => array('goods_id','id'),
  178. 'col' => 'goods_id',
  179. ),
  180. ),
  181. 'type' => 'all',
  182. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  183. 'page' => array(30, 'list'),
  184. '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',
  185. ),
  186. 'getData' => array
  187. (
  188. # 匹配的正则或函数 选填项
  189. 'option' => array
  190. (
  191. 'supplier_id' => array('yes-t_1.supplier_id'),
  192. 'name' => array('yes-t_2.name', 'like'),
  193. 'total' => array('yes|t_1.in_num-t_1.out_num', '<'),
  194. 'category' => array('yes-t_2.category', 'like'),
  195. 'top_category_id' => array('yes-t_2.top_category_id'),
  196. 'second_category_id' => array('yes-t_2.second_category_id'),
  197. 'category_id' => array('yes-t_2.category_id'),
  198. 'status' => array('yes-t_2.status', 1),
  199. 'state' => array('yes-t_2.state', 1),
  200. 'state_1' => array('yes-t_1.state', 1),
  201. ),
  202. # 联表
  203. 'join' => array
  204. (
  205. array
  206. (
  207. 'table' => 'scm_product/info',
  208. 'type' => 'left join',
  209. 'on' => array('goods_id','id'),
  210. 'col' => 'goods_id',
  211. ),
  212. ),
  213. 'type' => 'all',
  214. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  215. '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',
  216. ),
  217. # 列表
  218. 'getList' => array
  219. (
  220. # 匹配的正则或函数 选填项
  221. 'option' => array
  222. (
  223. 'supplier_id' => 'yes',
  224. 'goods_id' => 'yes',
  225. 'sku_id' => 'yes',
  226. 'state' => 1,
  227. ),
  228. 'type' => 'all',
  229. 'order' => array('id' => 'desc'),
  230. 'col' => '*,in_num-out_num as total|sku_id',
  231. ),
  232. # 获取单条数据
  233. 'getOne' => array
  234. (
  235. # 匹配的正则或函数 选填项
  236. 'option' => array
  237. (
  238. 'supplier_id' => 'yes',
  239. 'goods_id' => 'yes',
  240. 'sku_id' => 'yes',
  241. 'state' => 1,
  242. ),
  243. 'type' => 'one',
  244. 'col' => '*,in_num-out_num as total',
  245. ),
  246. # 更新售出量
  247. 'incSell' => array
  248. (
  249. 'type' => 'update',
  250. 'where' => array
  251. (
  252. 'supplier_id' => 'yes',
  253. 'goods_id' => 'yes',
  254. 'sku_id' => 'yes',
  255. ),
  256. 'set' => array
  257. (
  258. 'out_num' => array('yes', '+='),
  259. ),
  260. ),
  261. # 减少售出量
  262. 'decSell' => array
  263. (
  264. 'type' => 'update',
  265. 'where' => array
  266. (
  267. 'supplier_id' => 'yes',
  268. 'goods_id' => 'yes',
  269. 'sku_id' => 'yes',
  270. ),
  271. 'set' => array
  272. (
  273. 'out_num' => array('yes', '-='),
  274. ),
  275. ),
  276. # 更新总库存
  277. 'updateTotal' => array
  278. (
  279. 'type' => 'update',
  280. 'where' => array
  281. (
  282. 'id' => 'yes',
  283. ),
  284. 'set' => array
  285. (
  286. 'in_num' => array('yes', '+='),
  287. ),
  288. ),
  289. # 增加总库存
  290. 'incTotal' => array
  291. (
  292. 'type' => 'update',
  293. 'where' => array
  294. (
  295. 'supplier_id' => 'yes',
  296. 'goods_id' => 'yes',
  297. 'sku_id' => 'yes',
  298. ),
  299. 'set' => array
  300. (
  301. 'in_num' => array('yes', '+='),
  302. ),
  303. ),
  304. # 减少总库存
  305. 'decTotal' => array
  306. (
  307. 'type' => 'update',
  308. 'where' => array
  309. (
  310. 'supplier_id' => 'yes',
  311. 'goods_id' => 'yes',
  312. 'sku_id' => 'yes',
  313. ),
  314. 'set' => array
  315. (
  316. 'in_num' => array('yes', '-='),
  317. ),
  318. ),
  319. ),
  320. );
  321. return $config;