goods_sku.php 12 KB

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