goods_sku.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <?php
  2. $type = Dever::input('search_type');
  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 != 1) {
  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 != 1 ? 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' => 'int-11',
  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' => 'int-11',
  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' => 'int-11',
  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. 'manage' => array
  227. (
  228. 'insert' => false,
  229. 'edit' => false,
  230. 'delete' => false,
  231. 'num' => false,
  232. 'excel' => true,
  233. 'page_list_table' => 'sku',
  234. # 自定义快捷新增和编辑
  235. 'button' => $button,
  236. 'list_button' => $list_button,
  237. ),
  238. # request 请求接口定义
  239. 'request' => array
  240. (
  241. 'getDataPage' => array
  242. (
  243. # 匹配的正则或函数 选填项
  244. 'option' => array
  245. (
  246. 'store_id' => array('yes-t_1.store_id'),
  247. 'name' => array('yes-t_2.name', 'like'),
  248. 'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
  249. 'column' => array('yes-t_2.column_id', 'like'),
  250. 'category' => array('yes-t_2.category', 'like'),
  251. 'top_category_id' => array('yes-t_2.top_category_id'),
  252. 'second_category_id' => array('yes-t_2.second_category_id'),
  253. 'category_id' => array('yes-t_2.category_id'),
  254. 'status' => array('yes-t_2.status', 1),
  255. 'state' => array('yes-t_2.state', 1),
  256. 'state_1' => array('yes-t_1.state', 1),
  257. ),
  258. # 联表
  259. 'join' => array
  260. (
  261. array
  262. (
  263. 'table' => 'goods/info',
  264. 'type' => 'left join',
  265. 'on' => array('goods_id','id'),
  266. 'col' => 'goods_id',
  267. ),
  268. ),
  269. 'type' => 'all',
  270. 'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
  271. 'page' => array(30, 'list'),
  272. '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',
  273. ),
  274. # 列表
  275. 'getData' => array
  276. (
  277. # 匹配的正则或函数 选填项
  278. 'option' => array
  279. (
  280. 'store_id' => 'yes',
  281. 'sku_id' => 'yes',
  282. 'goods_id' => 'yes',
  283. 'state' => 1,
  284. ),
  285. 'type' => 'all',
  286. 'order' => array('id' => 'desc'),
  287. 'col' => '*,total_num-sell_num as total|sku_id',
  288. ),
  289. # 获取单条数据
  290. 'getOne' => array
  291. (
  292. # 匹配的正则或函数 选填项
  293. 'option' => array
  294. (
  295. 'store_id' => 'yes',
  296. 'sku_id' => 'yes',
  297. 'goods_id' => 'yes',
  298. 'state' => 1,
  299. ),
  300. 'type' => 'one',
  301. 'col' => '*,total_num-sell_num as total',
  302. ),
  303. # 更新售出量
  304. 'incSell' => array
  305. (
  306. 'type' => 'update',
  307. 'where' => array
  308. (
  309. 'store_id' => 'yes',
  310. 'goods_id' => 'yes',
  311. 'sku_id' => 'yes',
  312. ),
  313. 'set' => array
  314. (
  315. 'sell_num' => array('yes', '+='),
  316. ),
  317. ),
  318. # 减少售出量
  319. 'decSell' => array
  320. (
  321. 'type' => 'update',
  322. 'where' => array
  323. (
  324. 'store_id' => 'yes',
  325. 'goods_id' => 'yes',
  326. 'sku_id' => 'yes',
  327. ),
  328. 'set' => array
  329. (
  330. 'sell_num' => array('yes', '-='),
  331. ),
  332. ),
  333. # 更新总库存
  334. 'updateTotal' => array
  335. (
  336. 'type' => 'update',
  337. 'where' => array
  338. (
  339. 'id' => 'yes',
  340. ),
  341. 'set' => array
  342. (
  343. 'total_num' => array('yes', '+='),
  344. ),
  345. ),
  346. # 增加总库存
  347. 'incTotal' => array
  348. (
  349. 'type' => 'update',
  350. 'where' => array
  351. (
  352. 'store_id' => 'yes',
  353. 'goods_id' => 'yes',
  354. 'sku_id' => 'yes',
  355. ),
  356. 'set' => array
  357. (
  358. 'total_num' => array('yes', '+='),
  359. ),
  360. ),
  361. # 减少总库存
  362. 'decTotal' => array
  363. (
  364. 'type' => 'update',
  365. 'where' => array
  366. (
  367. 'store_id' => 'yes',
  368. 'goods_id' => 'yes',
  369. 'sku_id' => 'yes',
  370. ),
  371. 'set' => array
  372. (
  373. 'total_num' => array('yes', '-='),
  374. ),
  375. ),
  376. 'getDataByDate' => array
  377. (
  378. # 匹配的正则或函数 选填项
  379. 'option' => array
  380. (
  381. 'store_id' => 'yes',
  382. 'status' => 'yes',
  383. 'start' => array('yes-cdate', '>='),
  384. 'end' => array('yes-cdate', '<='),
  385. 'sku_id' => array('yes', 'in'),
  386. 'goods_id' => array('yes', 'in'),
  387. 'state' => 1,
  388. ),
  389. 'type' => 'all',
  390. 'order' => array('id' => 'desc'),
  391. 'col' => '*',
  392. ),
  393. ),
  394. );
  395. return $config;