goods_sku.php 14 KB

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