goods_sku.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <?php
  2. $type = Dever::input('search_option_store_id');
  3. $status = Dever::config('base')->status;
  4. $button = array
  5. (
  6. '新增仓库商品' => array('location', Dever::url('lib/set.home?id=' . Dever::input('search_option_store_id'), 'store')),
  7. '导出调整明细' => array('excel', 'shop/excel.goods_log'),
  8. );
  9. $list_button = array
  10. (
  11. 'list' => array('查看详情', '"goods_log&search_option_sid={id}&search_option_store_id={store_id}&oper_table=goods_sku&top_table=info"'),
  12. 'fast_list' => array('库存设置', '"info_sku&project=goods&goods_id={goods_id}&other=store&other_id={store_id}&page_type=1"'),
  13. );
  14. if (!$type) {
  15. unset($button['新增仓库商品']);
  16. unset($button['导出调整明细']);
  17. unset($list_button['fast_list']);
  18. $list_button['list'] = array('查看详情', '"goods_log&search_option_sid={id}&search_option_store_id={store_id}&oper_table=goods_sku"');
  19. }
  20. $config = array
  21. (
  22. # 表名
  23. 'name' => 'goods_sku',
  24. # 显示给用户看的名称
  25. 'lang' => '商品库存设置',
  26. 'order' => 200,
  27. 'menu' => false,
  28. 'end' => array
  29. (
  30. 'insert' => 'store/lib/manage.skuUpdate',
  31. 'update' => 'store/lib/manage.skuUpdate',
  32. ),
  33. 'fill' => array
  34. (
  35. # 从哪个表填充
  36. 'goods/info' => array
  37. (
  38. # 条件,另外一个表的字段 => 本表的字段
  39. 'where' => array('id' => 'goods_id'),
  40. # 要填充的数据,另外一个表的字段 => 本表的字段,如果不填写就是所有的
  41. 'update' => array('status' => 'status'),
  42. # 不需要填充的字段 与update互斥
  43. //'no' => array('id', 'seller_id', 'service_id', 'chose', 'state', 'cdate')
  44. )
  45. ),
  46. # 数据结构 不同的字段放这里
  47. 'struct' => array
  48. (
  49. 'id' => array
  50. (
  51. 'type' => 'int-11',
  52. 'name' => 'ID',
  53. 'default' => '',
  54. 'desc' => '',
  55. 'match' => 'is_numeric',
  56. //'list' => true,
  57. ),
  58. 'store_id' => array
  59. (
  60. 'type' => 'int-11',
  61. 'name' => '仓库名称',
  62. 'default' => '',
  63. 'desc' => '仓库名称',
  64. 'match' => 'is_numeric',
  65. 'list' => 'Dever::load("store/info-find#name", {store_id})',
  66. 'search' => !$type ? array
  67. (
  68. 'api' => 'store/info-like',
  69. 'col' => 'name',
  70. 'result' => 'id',
  71. 'search' => 'store_id',//本表的字段,默认为当前的字段
  72. ) : 'hidden',
  73. //'search' => 'hidden',
  74. 'list_order' => 1,
  75. ),
  76. 'goods-info_sku-code'=> array
  77. (
  78. 'name' => '商品编码',
  79. 'default' => '',
  80. 'desc' => '商品编码',
  81. 'match' => 'option',
  82. # 读取另外表的关联方式
  83. 'sync' => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
  84. 'search' => array
  85. (
  86. 'api' => 'goods/info_sku-like',
  87. 'col' => 'code',
  88. 'result' => 'id',
  89. 'search' => 'sku_id',//本表的字段,默认为当前的字段
  90. ),
  91. 'list' => true,
  92. 'list_order' => 2,
  93. ),
  94. 'goods-info_sku-f_price'=> array
  95. (
  96. 'name' => '门店进货单价',
  97. 'default' => '',
  98. 'desc' => '门店进货单价',
  99. 'match' => 'option',
  100. # 读取另外表的关联方式
  101. 'sync' => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
  102. 'list' => $type != 1 ? true : false,
  103. 'list_order' => 7,
  104. ),
  105. 'goods_id' => array
  106. (
  107. 'type' => 'int-11',
  108. 'name' => '商品名称',
  109. 'default' => '',
  110. 'desc' => '商品名称',
  111. 'match' => 'is_numeric',
  112. 'search' => array
  113. (
  114. 'api' => 'goods/info-like',
  115. 'col' => 'name',
  116. 'result' => 'id',
  117. ),
  118. 'list' => 'Dever::load("goods/info-find#name", {goods_id})',
  119. 'list_order' => 5,
  120. ),
  121. 'sku_id' => array
  122. (
  123. 'type' => 'int-11',
  124. 'name' => '规格型号',
  125. 'default' => '-1',
  126. 'desc' => '规格型号',
  127. 'match' => 'is_numeric',
  128. 'list' => 'Dever::load("shop/lib/manage.getSku", {goods_id}, {sku_id})',
  129. 'list_order' => 6,
  130. ),
  131. 'add_num' => array
  132. (
  133. 'type' => 'float-11,2',
  134. 'name' => '新增库存-输入小于0的数字,则为减少库存',
  135. 'default' => '0',
  136. 'desc' => '新增库存',
  137. 'match' => 'is_numeric',
  138. 'list_name' => '当前库存',
  139. 'list' => '{total_num} - {sell_num}',
  140. 'list_order' => 8,
  141. ),
  142. 'total_num' => array
  143. (
  144. 'type' => 'float-11,2',
  145. 'name' => '总库存',
  146. 'default' => '0',
  147. 'desc' => '总库存',
  148. 'match' => 'is_numeric',
  149. 'list' => true,
  150. 'list_order' => 10,
  151. ),
  152. 'sell_num' => array
  153. (
  154. 'type' => 'float-11,2',
  155. 'name' => '销量',
  156. 'default' => '0',
  157. 'desc' => '请填写销量',
  158. 'match' => 'option',
  159. //'search' => 'order',
  160. 'list_name' => '占用库存',
  161. 'list' => true,
  162. 'list_order' => 9,
  163. ),
  164. 'reorder' => array
  165. (
  166. 'type' => 'int-11',
  167. 'name' => '排序-数值越大越靠前,相当于置顶',
  168. 'default' => '1',
  169. 'desc' => '请输入排序',
  170. 'match' => 'option',
  171. //'update' => 'text',
  172. //'search' => 'order',
  173. //'list' => true,
  174. 'order' => 'desc',
  175. //'edit' => true,
  176. 'list_name' => '在途库存',
  177. 'list' => 'Dever::load("shop/lib/manage.getGoodsTotal", 2, {store_id}, {goods_id}, {sku_id})',
  178. 'list_order' => 9,
  179. ),
  180. 'operdate' => array
  181. (
  182. 'type' => 'int-11',
  183. 'name' => '最近调整时间',
  184. 'default' => '',
  185. 'match' => 'is_numeric',
  186. 'desc' => '',
  187. 'search' => 'sday',
  188. 'list' => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : date("Y-m-d H:i", {cdate})',
  189. 'list_order' => 13,
  190. ),
  191. 'status' => array
  192. (
  193. 'type' => 'tinyint-1',
  194. 'name' => '商品状态',
  195. 'default' => '2',
  196. 'desc' => '状态',
  197. 'match' => 'is_numeric',
  198. //'update' => 'select',
  199. 'option' => $status,
  200. 'search' => 'select',
  201. 'list' => true,
  202. 'list_order' => 11,
  203. //'edit' => true,
  204. ),
  205. 'state' => array
  206. (
  207. 'type' => 'tinyint-1',
  208. 'name' => '数据状态',
  209. 'default' => '1',
  210. 'desc' => '请选择状态',
  211. 'match' => 'is_numeric',
  212. ),
  213. 'cdate' => array
  214. (
  215. 'type' => 'int-11',
  216. 'name' => '创建时间',
  217. 'match' => array('is_numeric', time()),
  218. 'desc' => '',
  219. # 只有insert时才生效
  220. 'insert' => true,
  221. //'search' => 'sday',
  222. 'list' => $type == 1 ? 'date("Y-m-d H:i", {cdate})' : false,
  223. 'list_order' => 12,
  224. ),
  225. ),
  226. 'alter' => array
  227. (
  228. 2 => array
  229. (
  230. array('update', 'add_num', 'add_num', 'float-11,2 0 新增库存'),
  231. array('update', 'total_num', 'total_num', 'float-11,2 0 总库存'),
  232. array('update', 'sell_num', 'sell_num', 'float-11,2 0 销量'),
  233. ),
  234. 'version' => 2,
  235. ),
  236. 'manage' => array
  237. (
  238. 'insert' => false,
  239. 'edit' => false,
  240. 'delete' => false,
  241. 'num' => false,
  242. 'excel' => true,
  243. 'page_list_table' => 'sku',
  244. # 自定义快捷新增和编辑
  245. 'button' => $button,
  246. 'list_button' => $list_button,
  247. ),
  248. # request 请求接口定义
  249. 'request' => array
  250. (
  251. 'getDataPage' => array
  252. (
  253. # 匹配的正则或函数 选填项
  254. 'option' => array
  255. (
  256. 'store_id' => array('yes-t_1.store_id'),
  257. 'name' => array('yes-t_2.name', 'like'),
  258. 'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
  259. 'column' => array('yes-t_2.column_id', 'like'),
  260. 'category' => array('yes-t_2.category', 'like'),
  261. 'top_category_id' => array('yes-t_2.top_category_id'),
  262. 'second_category_id' => array('yes-t_2.second_category_id'),
  263. 'category_id' => array('yes-t_2.category_id'),
  264. 'status' => array('yes-t_2.status', 1),
  265. 'state' => array('yes-t_2.state', 1),
  266. 'state_1' => array('yes-t_1.state', 1),
  267. ),
  268. # 联表
  269. 'join' => array
  270. (
  271. array
  272. (
  273. 'table' => 'goods/info',
  274. 'type' => 'left join',
  275. 'on' => array('goods_id','id'),
  276. 'col' => 'goods_id',
  277. ),
  278. ),
  279. 'type' => 'all',
  280. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  281. 'page' => array(30, 'list'),
  282. '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',
  283. ),
  284. # 列表
  285. 'getData' => array
  286. (
  287. # 匹配的正则或函数 选填项
  288. 'option' => array
  289. (
  290. 'store_id' => 'yes',
  291. 'sku_id' => 'yes',
  292. 'goods_id' => 'yes',
  293. 'state' => 1,
  294. ),
  295. 'type' => 'all',
  296. 'order' => array('id' => 'desc'),
  297. 'col' => '*,total_num-sell_num as total|sku_id',
  298. ),
  299. # 获取单条数据
  300. 'getOne' => array
  301. (
  302. # 匹配的正则或函数 选填项
  303. 'option' => array
  304. (
  305. 'store_id' => 'yes',
  306. 'sku_id' => 'yes',
  307. 'goods_id' => 'yes',
  308. 'state' => 1,
  309. ),
  310. 'type' => 'one',
  311. 'col' => '*,total_num-sell_num as total',
  312. ),
  313. # 更新售出量
  314. 'incSell' => array
  315. (
  316. 'type' => 'update',
  317. 'where' => array
  318. (
  319. 'store_id' => 'yes',
  320. 'goods_id' => 'yes',
  321. 'sku_id' => 'yes',
  322. ),
  323. 'set' => array
  324. (
  325. 'sell_num' => array('yes', '+='),
  326. ),
  327. ),
  328. # 减少售出量
  329. 'decSell' => array
  330. (
  331. 'type' => 'update',
  332. 'where' => array
  333. (
  334. 'store_id' => 'yes',
  335. 'goods_id' => 'yes',
  336. 'sku_id' => 'yes',
  337. ),
  338. 'set' => array
  339. (
  340. 'sell_num' => array('yes', '-='),
  341. ),
  342. ),
  343. # 更新总库存
  344. 'updateTotal' => array
  345. (
  346. 'type' => 'update',
  347. 'where' => array
  348. (
  349. 'id' => 'yes',
  350. ),
  351. 'set' => array
  352. (
  353. 'total_num' => array('yes', '+='),
  354. ),
  355. ),
  356. # 增加总库存
  357. 'incTotal' => array
  358. (
  359. 'type' => 'update',
  360. 'where' => array
  361. (
  362. 'store_id' => 'yes',
  363. 'goods_id' => 'yes',
  364. 'sku_id' => 'yes',
  365. ),
  366. 'set' => array
  367. (
  368. 'total_num' => array('yes', '+='),
  369. ),
  370. ),
  371. # 减少总库存
  372. 'decTotal' => array
  373. (
  374. 'type' => 'update',
  375. 'where' => array
  376. (
  377. 'store_id' => 'yes',
  378. 'goods_id' => 'yes',
  379. 'sku_id' => 'yes',
  380. ),
  381. 'set' => array
  382. (
  383. 'total_num' => array('yes', '-='),
  384. ),
  385. ),
  386. 'getDataByDate' => array
  387. (
  388. # 匹配的正则或函数 选填项
  389. 'option' => array
  390. (
  391. 'store_id' => 'yes',
  392. 'status' => 'yes',
  393. 'start' => array('yes-cdate', '>='),
  394. 'end' => array('yes-cdate', '<='),
  395. 'sku_id' => array('yes', 'in'),
  396. 'goods_id' => array('yes', 'in'),
  397. 'state' => 1,
  398. ),
  399. 'type' => 'all',
  400. 'order' => array('id' => 'desc'),
  401. 'col' => '*',
  402. ),
  403. ),
  404. );
  405. return $config;