goods_sku.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. 'price_id' => array
  132. (
  133. 'type' => 'int-11',
  134. 'name' => '价格模板',
  135. 'default' => '0',
  136. 'desc' => '价格模板',
  137. 'match' => 'option',
  138. ),
  139. 'add_num' => array
  140. (
  141. 'type' => 'float-11,2',
  142. 'name' => '新增库存-输入小于0的数字,则为减少库存',
  143. 'default' => '0',
  144. 'desc' => '新增库存',
  145. 'match' => 'is_numeric',
  146. 'list_name' => '当前库存',
  147. 'list' => '{total_num} - {sell_num}',
  148. 'list_order' => 8,
  149. ),
  150. 'total_num' => array
  151. (
  152. 'type' => 'float-11,2',
  153. 'name' => '总库存',
  154. 'default' => '0',
  155. 'desc' => '总库存',
  156. 'match' => 'is_numeric',
  157. 'list' => true,
  158. 'list_order' => 10,
  159. ),
  160. 'sell_num' => array
  161. (
  162. 'type' => 'float-11,2',
  163. 'name' => '销量',
  164. 'default' => '0',
  165. 'desc' => '请填写销量',
  166. 'match' => 'option',
  167. //'search' => 'order',
  168. 'list_name' => '占用库存',
  169. 'list' => true,
  170. 'list_order' => 9,
  171. ),
  172. 'reorder' => array
  173. (
  174. 'type' => 'int-11',
  175. 'name' => '排序-数值越大越靠前,相当于置顶',
  176. 'default' => '1',
  177. 'desc' => '请输入排序',
  178. 'match' => 'option',
  179. //'update' => 'text',
  180. //'search' => 'order',
  181. //'list' => true,
  182. 'order' => 'desc',
  183. //'edit' => true,
  184. 'list_name' => '在途库存',
  185. 'list' => 'Dever::load("shop/lib/manage.getGoodsTotal", 2, {store_id}, {goods_id}, {sku_id})',
  186. 'list_order' => 9,
  187. ),
  188. 'operdate' => array
  189. (
  190. 'type' => 'int-11',
  191. 'name' => '最近调整时间',
  192. 'default' => '',
  193. 'match' => 'is_numeric',
  194. 'desc' => '',
  195. 'search' => 'sday',
  196. 'list' => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : date("Y-m-d H:i", {cdate})',
  197. 'list_order' => 13,
  198. ),
  199. 'status' => array
  200. (
  201. 'type' => 'tinyint-1',
  202. 'name' => '商品状态',
  203. 'default' => '2',
  204. 'desc' => '状态',
  205. 'match' => 'is_numeric',
  206. //'update' => 'select',
  207. 'option' => $status,
  208. 'search' => 'select',
  209. 'list' => true,
  210. 'list_order' => 11,
  211. //'edit' => true,
  212. ),
  213. 'state' => array
  214. (
  215. 'type' => 'tinyint-1',
  216. 'name' => '数据状态',
  217. 'default' => '1',
  218. 'desc' => '请选择状态',
  219. 'match' => 'is_numeric',
  220. ),
  221. 'cdate' => array
  222. (
  223. 'type' => 'int-11',
  224. 'name' => '创建时间',
  225. 'match' => array('is_numeric', time()),
  226. 'desc' => '',
  227. # 只有insert时才生效
  228. 'insert' => true,
  229. //'search' => 'sday',
  230. 'list' => $type == 1 ? 'date("Y-m-d H:i", {cdate})' : false,
  231. 'list_order' => 12,
  232. ),
  233. ),
  234. 'alter' => array
  235. (
  236. 2 => array
  237. (
  238. array('update', 'add_num', 'add_num', 'float-11,2 0 新增库存'),
  239. array('update', 'total_num', 'total_num', 'float-11,2 0 总库存'),
  240. array('update', 'sell_num', 'sell_num', 'float-11,2 0 销量'),
  241. ),
  242. 'version' => 2,
  243. ),
  244. 'manage' => array
  245. (
  246. 'insert' => false,
  247. 'edit' => false,
  248. 'delete' => false,
  249. 'num' => false,
  250. 'excel' => true,
  251. 'page_list_table' => 'sku',
  252. # 自定义快捷新增和编辑
  253. 'button' => $button,
  254. 'list_button' => $list_button,
  255. ),
  256. # request 请求接口定义
  257. 'request' => array
  258. (
  259. 'getDataPage' => array
  260. (
  261. # 匹配的正则或函数 选填项
  262. 'option' => array
  263. (
  264. 'store_id' => array('yes-t_1.store_id'),
  265. 'name' => array('yes-t_2.name', 'like'),
  266. 'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
  267. 'column' => array('yes-t_2.column_id', 'like'),
  268. 'category' => array('yes-t_2.category', 'like'),
  269. 'top_category_id' => array('yes-t_2.top_category_id'),
  270. 'second_category_id' => array('yes-t_2.second_category_id'),
  271. 'category_id' => array('yes-t_2.category_id'),
  272. 'status' => array('yes-t_2.status', 1),
  273. 'state' => array('yes-t_2.state', 1),
  274. 'state_1' => array('yes-t_1.state', 1),
  275. ),
  276. # 联表
  277. 'join' => array
  278. (
  279. array
  280. (
  281. 'table' => 'goods/info',
  282. 'type' => 'left join',
  283. 'on' => array('goods_id','id'),
  284. 'col' => 'goods_id',
  285. ),
  286. ),
  287. 'type' => 'all',
  288. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  289. 'page' => array(30, 'list'),
  290. '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',
  291. ),
  292. # 列表
  293. 'getData' => array
  294. (
  295. # 匹配的正则或函数 选填项
  296. 'option' => array
  297. (
  298. 'store_id' => 'yes',
  299. 'sku_id' => 'yes',
  300. 'goods_id' => 'yes',
  301. 'state' => 1,
  302. ),
  303. 'type' => 'all',
  304. 'order' => array('id' => 'desc'),
  305. 'col' => '*,total_num-sell_num as total|sku_id',
  306. ),
  307. # 获取单条数据
  308. 'getOne' => array
  309. (
  310. # 匹配的正则或函数 选填项
  311. 'option' => array
  312. (
  313. 'store_id' => 'yes',
  314. 'sku_id' => 'yes',
  315. 'goods_id' => 'yes',
  316. 'state' => 1,
  317. ),
  318. 'type' => 'one',
  319. 'col' => '*,total_num-sell_num as total',
  320. ),
  321. # 更新售出量
  322. 'incSell' => array
  323. (
  324. 'type' => 'update',
  325. 'where' => array
  326. (
  327. 'store_id' => 'yes',
  328. 'goods_id' => 'yes',
  329. 'sku_id' => 'yes',
  330. ),
  331. 'set' => array
  332. (
  333. 'sell_num' => array('yes', '+='),
  334. ),
  335. ),
  336. # 减少售出量
  337. 'decSell' => array
  338. (
  339. 'type' => 'update',
  340. 'where' => array
  341. (
  342. 'store_id' => 'yes',
  343. 'goods_id' => 'yes',
  344. 'sku_id' => 'yes',
  345. ),
  346. 'set' => array
  347. (
  348. 'sell_num' => array('yes', '-='),
  349. ),
  350. ),
  351. # 更新总库存
  352. 'updateTotal' => array
  353. (
  354. 'type' => 'update',
  355. 'where' => array
  356. (
  357. 'id' => 'yes',
  358. ),
  359. 'set' => array
  360. (
  361. 'total_num' => array('yes', '+='),
  362. ),
  363. ),
  364. # 增加总库存
  365. 'incTotal' => array
  366. (
  367. 'type' => 'update',
  368. 'where' => array
  369. (
  370. 'store_id' => 'yes',
  371. 'goods_id' => 'yes',
  372. 'sku_id' => 'yes',
  373. ),
  374. 'set' => array
  375. (
  376. 'total_num' => array('yes', '+='),
  377. ),
  378. ),
  379. # 减少总库存
  380. 'decTotal' => array
  381. (
  382. 'type' => 'update',
  383. 'where' => array
  384. (
  385. 'store_id' => 'yes',
  386. 'goods_id' => 'yes',
  387. 'sku_id' => 'yes',
  388. ),
  389. 'set' => array
  390. (
  391. 'total_num' => array('yes', '-='),
  392. ),
  393. ),
  394. 'getDataByDate' => array
  395. (
  396. # 匹配的正则或函数 选填项
  397. 'option' => array
  398. (
  399. 'store_id' => 'yes',
  400. 'status' => 'yes',
  401. 'start' => array('yes-cdate', '>='),
  402. 'end' => array('yes-cdate', '<='),
  403. 'sku_id' => array('yes', 'in'),
  404. 'goods_id' => array('yes', 'in'),
  405. 'state' => 1,
  406. ),
  407. 'type' => 'all',
  408. 'order' => array('id' => 'desc'),
  409. 'col' => '*',
  410. ),
  411. ),
  412. );
  413. return $config;