buy_order.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <?php
  2. $status = array
  3. (
  4. 1 => '待支付',
  5. 2 => '待审核',
  6. 3 => '待发货',
  7. 4 => '待收货确认',
  8. 5 => '已完成',
  9. 6 => '已完成(有退款)',
  10. 7 => '已取消',
  11. 8 => '已退款',
  12. 11 => '已过期',
  13. );
  14. $audit = array
  15. (
  16. //1 => '待审核',
  17. 2 => '审核通过',
  18. 3 => '审核未通过',
  19. );
  20. $refund_status = array
  21. (
  22. 1 => '未申请',
  23. 2 => '已申请',
  24. );
  25. $parent_type = array
  26. (
  27. 1 => '直接下单',
  28. 2 => '平台店订单',
  29. 3 => '代理商订单',
  30. );
  31. $type = Dever::config('base')->source;
  32. unset($type[3]);
  33. $shop = function()
  34. {
  35. $array = array();
  36. $info = Dever::db('shop/info')->select();
  37. if($info)
  38. {
  39. $array += $info;
  40. }
  41. return $array;
  42. };
  43. $store = function()
  44. {
  45. $array = array();
  46. $info = Dever::db('store/info')->select();
  47. if($info)
  48. {
  49. $array += $info;
  50. }
  51. return $array;
  52. };
  53. $search_option_type = Dever::input('search_option_type', 1);
  54. if ($search_option_type == 1) {
  55. $search_name = '门店名称';
  56. $search_option = $shop;
  57. $search_url = 'shop/lib/manage.search';
  58. $search_table = 'shop';
  59. $search = $search_table . '/info-like';
  60. $excel = array
  61. (
  62. array('导出订单', '门店采购订单', ''),
  63. array('导出订单明细', '门店采购订单明细', 'shop/excel.buy_order'),
  64. );
  65. $source_name = '供货商';
  66. $source_order = 4;
  67. } elseif ($search_option_type == 2) {
  68. $search_name = '仓库名称';
  69. $search_option = $store;
  70. $search_url = 'store/lib/manage.search';
  71. $search_table = 'store';
  72. $search = $search_table . '/info-like';
  73. $excel = array
  74. (
  75. array('导出订单', '仓库入库订单', ''),
  76. array('导出订单明细', '仓库入库订单明细', 'shop/excel.store_buy_order'),
  77. );
  78. $source_name = '发货工厂';
  79. $source_order = 4;
  80. }
  81. $search_option_source_type = Dever::input('search_option_source_type');
  82. if ($search_option_source_type == 2) {
  83. $source_name = '仓库名称';
  84. $source_order = -1;
  85. $excel = array
  86. (
  87. array('导出订单', '仓库发货订单', ''),
  88. array('导出订单明细', '仓库发货订单明细', 'shop/excel.store_buy_order_fa'),
  89. );
  90. } elseif ($search_option_source_type == 3) {
  91. $search_option_type = 3;
  92. $search_name = '收件人名称';
  93. $search_table = 'store';
  94. $search = $search_table . '/info-like';
  95. $source_name = '工厂名称';
  96. $source_order = -1;
  97. $excel = array
  98. (
  99. array('导出订单', '工厂发货订单', ''),
  100. array('导出订单明细', '工厂发货订单明细', 'shop/excel.factory_buy_order_fa'),
  101. );
  102. }
  103. return array
  104. (
  105. # 表名
  106. 'name' => 'buy_order',
  107. # 显示给用户看的名称
  108. 'lang' => '采购订单',
  109. 'order' => 99,
  110. 'status' => $status,
  111. 'refund_status' => $refund_status,
  112. 'end' => array
  113. (
  114. 'insert' => 'shop/lib/manage.buyOrderUpdate',
  115. 'update' => 'shop/lib/manage.buyOrderUpdate',
  116. ),
  117. # 数据结构
  118. 'struct' => array
  119. (
  120. 'id' => array
  121. (
  122. 'type' => 'int-11',
  123. 'name' => 'ID',
  124. 'default' => '',
  125. 'desc' => '',
  126. 'match' => 'is_numeric',
  127. 'search' => 'order',
  128. //'list' => true,
  129. ),
  130. 'type' => array
  131. (
  132. 'type' => 'int-11',
  133. 'name' => '收件人类型',
  134. 'default' => '',
  135. 'desc' => '收件人类型',
  136. 'match' => 'is_numeric',
  137. 'search' => $search_option_source_type == 3 ? 'select' : 'hidden',
  138. 'option' => $type,
  139. 'list' => $search_option_source_type == 3 ? true : false,
  140. 'list_order' => 3,
  141. ),
  142. 'type_id' => array
  143. (
  144. 'type' => 'int-11',
  145. 'name' => $search_name,
  146. 'default' => '',
  147. 'desc' => '拥有人',
  148. 'match' => 'is_numeric',
  149. //'search' => $search_option_type == 3 ? '' : 'select',
  150. 'search' => $search_option_type == 3 ? '' : array
  151. (
  152. 'api' => $search,
  153. 'col' => 'name',
  154. 'result' => 'id',
  155. ),
  156. //'option' => $search_option,
  157. //'update_search' => $search_url,
  158. 'list' => 'Dever::load("shop/lib/manage.buyInfo", "{type}", "{type_id}")',
  159. 'list_order' => 2,
  160. ),
  161. 'shop-info-sid'=> array
  162. (
  163. 'name' => '门店编号',
  164. 'default' => '',
  165. 'desc' => '门店编号',
  166. 'match' => 'option',
  167. # 读取另外表的关联方式
  168. 'sync' => array('type_id', 'id'),
  169. 'list' => $search_option_type == 1 ? true : false,
  170. 'list_order' => 1,
  171. ),
  172. 'shop-info-type'=> array
  173. (
  174. 'name' => '门店类型',
  175. 'default' => '',
  176. 'desc' => '门店类型',
  177. 'match' => 'option',
  178. # 读取另外表的关联方式
  179. 'sync' => array('type_id', 'id'),
  180. 'list' => $search_option_type == 1 ? 'Dever::load("shop/lib/manage.shopInfoType", {shop-info-type})' : false,
  181. 'list_order' => 3,
  182. ),
  183. 'area' => array
  184. (
  185. 'type' => 'varchar-500',
  186. 'name' => '所在街道',
  187. 'default' => '',
  188. 'desc' => '所在街道',
  189. 'match' => 'option',
  190. 'search' => $search_option_type == 1 ? 'linkage' : false,
  191. 'update' => 'linkage',
  192. 'option' => Dever::url('lib/area.get', $search_table),
  193. //'list' => 'Dever::load("area/api.string", "{area}")',
  194. ),
  195. 'source_type' => array
  196. (
  197. 'type' => 'int-11',
  198. 'name' => '供货商类型',
  199. 'default' => '',
  200. 'desc' => '供货商类型',
  201. 'match' => 'is_numeric',
  202. 'search' => 'hidden',
  203. 'value' => $search_option_source_type,
  204. ),
  205. 'source_id' => array
  206. (
  207. 'type' => 'int-11',
  208. 'name' => $source_name,
  209. 'default' => '',
  210. 'desc' => '供货商',
  211. 'match' => 'is_numeric',
  212. 'search' => $search_option_source_type == 2 ? array
  213. (
  214. 'api' => 'store/info-like',
  215. 'col' => 'name',
  216. 'result' => 'id',
  217. ) : array
  218. (
  219. 'api' => 'factory/info-like',
  220. 'col' => 'name',
  221. 'result' => 'id',
  222. ),
  223. 'list' => 'Dever::load("shop/lib/manage.buyInfo", "{source_type}", "{source_id}")',
  224. 'list_order' => $source_order,
  225. ),
  226. 'name' => array
  227. (
  228. 'type' => 'varchar-800',
  229. 'name' => '订单名称',
  230. 'default' => '',
  231. 'desc' => '订单名称',
  232. 'match' => 'is_string',
  233. 'update' => 'text',
  234. ),
  235. 'parent_type' => array
  236. (
  237. 'type' => 'int-11',
  238. 'name' => '原订单类型',
  239. 'default' => '1',
  240. 'desc' => '原订单类型',
  241. 'match' => 'is_numeric',
  242. 'option' => $parent_type,
  243. ),
  244. 'parent_order_id' => array
  245. (
  246. 'type' => 'int-11',
  247. 'name' => '原订单id',
  248. 'default' => '',
  249. 'desc' => '原订单id',
  250. 'match' => 'is_numeric',
  251. ),
  252. 'order_num' => array
  253. (
  254. 'type' => 'varchar-100',
  255. 'name' => '订货单号',
  256. 'default' => '',
  257. 'desc' => '订货单号',
  258. 'match' => 'is_string',
  259. 'update' => 'text',
  260. 'search' => 'fulltext',
  261. 'list' => true,
  262. 'list_order' => 5,
  263. ),
  264. 'price' => array
  265. (
  266. 'type' => 'varchar-50',
  267. 'name' => '购买价格-采购价',
  268. 'default' => '0',
  269. 'desc' => '购买价格',
  270. 'match' => 'option',
  271. 'update' => 'text',
  272. 'list' => $search_option_type == 1 ? true : false,
  273. 'list_name' => '订货单总金额',
  274. 'list_order' => 7,
  275. ),
  276. 'p_price' => array
  277. (
  278. 'type' => 'varchar-50',
  279. 'name' => '购买价格-出厂价,给厂家看的',
  280. 'default' => '0',
  281. 'desc' => '购买价格',
  282. 'match' => 'option',
  283. 'update' => 'text',
  284. 'list' => $search_option_source_type == 3 ? true : false,
  285. 'list_name' => '订货单总金额',
  286. 'list_order' => 7,
  287. ),
  288. 'num' => array
  289. (
  290. 'type' => 'int-11',
  291. 'name' => '购买数量',
  292. 'default' => '',
  293. 'desc' => '购买数量',
  294. 'match' => 'is_numeric',
  295. 'search' => 'select',
  296. 'list' => true,
  297. 'list_name' => '订货总数量',
  298. 'list_order' => 6,
  299. ),
  300. 'refund_cash' => array
  301. (
  302. 'type' => 'varchar-50',
  303. 'name' => '退款合计金额-采购价格',
  304. 'default' => '0',
  305. 'desc' => '退款合计金额',
  306. 'match' => 'option',
  307. 'update' => 'text',
  308. 'list' => ($search_option_type == 1 || $search_option_source_type == 3) ? true : false,
  309. 'list_name' => '退款金额',
  310. 'list_order' => 11,
  311. ),
  312. 'refund_p_cash' => array
  313. (
  314. 'type' => 'varchar-50',
  315. 'name' => '退款合计金额-出厂价格',
  316. 'default' => '0',
  317. 'desc' => '退款合计金额',
  318. 'match' => 'option',
  319. 'update' => 'text',
  320. 'list' => ($search_option_type == 2 || $search_option_source_type == 2 || $search_option_source_type == 3) ? 'Dever::load("shop/lib/manage.buyInfoRefundNum", "{id}")' : false,
  321. 'list_name' => '已退商品数量',
  322. 'list_order' => 11,
  323. ),
  324. 'refund_status' => array
  325. (
  326. 'type' => 'tinyint-1',
  327. 'name' => '退款状态',
  328. 'default' => '1',
  329. 'desc' => '退款状态',
  330. 'match' => 'is_numeric',
  331. 'option' => $refund_status,
  332. //'search' => 'select',
  333. 'list' => $search_option_type == 1 ? 'Dever::load("shop/lib/manage.buyInfoRefundStatus", "{id}")' : false,
  334. 'list_name' => '退款状态',
  335. 'list_order' => 10,
  336. ),
  337. 'info' => array
  338. (
  339. 'type' => 'varchar-300',
  340. 'name' => '订单备注',
  341. 'default' => '',
  342. 'desc' => '订单备注',
  343. 'match' => 'option',
  344. 'update' => 'textarea',
  345. ),
  346. 'status' => array
  347. (
  348. 'type' => 'tinyint-1',
  349. 'name' => '状态',
  350. 'default' => '1',
  351. 'desc' => '状态',
  352. 'match' => 'is_numeric',
  353. 'option' => $status,
  354. 'search' => 'select',
  355. 'list' => 'Dever::load("mshop/lib/buy.orderStatus", "{id}")',
  356. 'list_name' => '订货单状态',
  357. 'list_order' => 9,
  358. ),
  359. 'audit' => array
  360. (
  361. 'type' => 'tinyint-1',
  362. 'name' => '审核状态',
  363. 'default' => '2',
  364. 'desc' => '审核状态',
  365. 'match' => 'is_numeric',
  366. 'option' => $audit,
  367. //'search' => 'select',
  368. 'update' => 'radio',
  369. ),
  370. 'audit_desc' => array
  371. (
  372. 'type' => 'varchar-500',
  373. 'name' => '未通过原因',
  374. 'default' => '',
  375. 'desc' => '未通过原因',
  376. 'match' => 'option',
  377. 'update' => 'textarea',
  378. ),
  379. 'state' => array
  380. (
  381. 'type' => 'tinyint-1',
  382. 'name' => '状态',
  383. 'default' => '1',
  384. 'desc' => '请选择状态',
  385. 'match' => 'is_numeric',
  386. ),
  387. 'fdate' => array
  388. (
  389. 'type' => 'int-11',
  390. 'name' => '完成时间',
  391. 'default' => '',
  392. 'match' => 'is_numeric',
  393. 'desc' => '',
  394. ),
  395. 'operdate' => array
  396. (
  397. 'type' => 'int-11',
  398. 'name' => '审核时间',
  399. 'default' => '',
  400. 'match' => 'is_numeric',
  401. 'desc' => '',
  402. ),
  403. 'shop-buy_order_ps-cdate'=> array
  404. (
  405. 'name' => '发货日期',
  406. 'default' => '',
  407. 'desc' => '发货日期',
  408. 'match' => 'option',
  409. # 读取另外表的关联方式
  410. 'sync' => array('id', 'order_id'),
  411. 'list' => ($search_option_type == 2 || $search_option_source_type == 2 || $search_option_source_type == 3) ? '"{shop-buy_order_ps-cdate}" ? date("Y-m-d H:i", {shop-buy_order_ps-cdate}) : "-"' : false,
  412. 'list_order' => 9,
  413. ),
  414. 'shop-buy_order_ps-ydate'=> array
  415. (
  416. 'name' => '收货日期',
  417. 'default' => '',
  418. 'desc' => '收货日期',
  419. 'match' => 'option',
  420. # 读取另外表的关联方式
  421. 'sync' => array('id', 'order_id'),
  422. 'list' => $search_option_type == 2 ? '"{shop-buy_order_ps-ydate}" ? date("Y-m-d H:i", {shop-buy_order_ps-ydate}) : "-"': false,
  423. 'list_order' => 9,
  424. ),
  425. 'cdate' => array
  426. (
  427. 'type' => 'int-11',
  428. 'name' => '下单时间',
  429. 'match' => array('is_numeric', time()),
  430. 'desc' => '',
  431. # 只有insert时才生效
  432. 'insert' => true,
  433. 'search' => 'sdate',
  434. 'list' => 'date("Y-m-d H:i", {cdate})',
  435. 'list_name' => '订货日期',
  436. 'list_order' => 8,
  437. //'list' => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
  438. ),
  439. ),
  440. 'manage' => array
  441. (
  442. 'delete' => false,
  443. 'edit' => false,
  444. 'insert' => false,
  445. 'excel' => $excel,
  446. 'button' => array
  447. (
  448. //'导出订单' => array('location', 'user/lib/manage.out'),
  449. ),
  450. 'list_button' => array(
  451. //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2'),
  452. //'delete' => array('删除', '', '{status} == 1'),
  453. 'list' => array('查看详情', '"buy_order_goods&project=shop&order_id={id}&page_type=1&types='.$search_option_type.'"'),
  454. //'oper' => array('审核', '"mshop/lib/manage.audit?order_id={id}"', '{status} == 2'),
  455. 'fast' => array('审核', '"buy_order&where_id={id}&col=audit,audit_desc&oper_save_jump=buy_order&oper_table=buy_order&oper_parent=buy_order"', '{status} == 2'),
  456. //'oper1' => array('发货', '"mshop/lib/manage.send?order_id={id}"', '{status} == 3'),
  457. //'fast1' => array('发货', '"buy_order_ps&where_id={id}&search_option_order_id={id}&oper_save_jump=buy_order&oper_table=buy_order&oper_parent=buy_order"', '{status} == 3'),
  458. ),
  459. ),
  460. 'alter' => array
  461. (
  462. 2 => array
  463. (
  464. array('update', 'parent_order_id', 'parent_order_id', 'int-11 0 原订单id'),
  465. ),
  466. 'version' => 2,
  467. ),
  468. 'request' => array
  469. (
  470. 'getAll' => array
  471. (
  472. # 匹配的正则或函数 选填项
  473. 'option' => array
  474. (
  475. 'name' => array('yes', 'like'),
  476. 'order_num' => array('yes', 'like'),
  477. 'type' => 'yes',
  478. 'type_id' => 'yes',
  479. 'source_type' => 'yes',
  480. 'source_id' => 'yes',
  481. 'start' => array('yes-cdate', '>='),
  482. 'end' => array('yes-cdate', '<='),
  483. 'start_o' => array('yes-operdate', '>='),
  484. 'end_o' => array('yes-operdate', '<='),
  485. 'start_f' => array('yes-fdate', '>='),
  486. 'end_f' => array('yes-fdate', '<='),
  487. 'status' => array('yes', 'in'),
  488. 'refund_status' => 'yes',
  489. 'state' => 1,
  490. ),
  491. 'type' => 'all',
  492. 'order' => array('cdate' => 'desc'),
  493. 'page' => array(20, 'list'),
  494. 'col' => '*',
  495. ),
  496. 'getData' => array
  497. (
  498. # 匹配的正则或函数 选填项
  499. 'option' => array
  500. (
  501. 'name' => array('yes', 'like'),
  502. 'order_num' => array('yes', 'like'),
  503. 'type' => 'yes',
  504. 'type_id' => 'yes',
  505. 'source_type' => 'yes',
  506. 'source_id' => 'yes',
  507. 'start' => array('yes-cdate', '>='),
  508. 'end' => array('yes-cdate', '<='),
  509. 'start_o' => array('yes-operdate', '>='),
  510. 'end_o' => array('yes-operdate', '<='),
  511. 'start_f' => array('yes-fdate', '>='),
  512. 'end_f' => array('yes-fdate', '<='),
  513. 'status' => array('yes', 'in'),
  514. 'refund_status' => 'yes',
  515. 'state' => 1,
  516. ),
  517. 'type' => 'all',
  518. 'order' => array('cdate' => 'desc'),
  519. 'col' => '*',
  520. ),
  521. # 获取订单数量
  522. 'getOrderNum' => array
  523. (
  524. # 匹配的正则或函数 选填项
  525. 'option' => array
  526. (
  527. 'start' => array('yes-cdate', '>='),
  528. 'end' => array('yes-cdate', '<='),
  529. 'start_o' => array('yes-operdate', '>='),
  530. 'end_o' => array('yes-operdate', '<='),
  531. 'type' => 'yes',
  532. 'type_id' => 'yes',
  533. 'source_type' => 'yes',
  534. 'source_id' => 'yes',
  535. 'status' => array('yes', 'in'),
  536. 'state' => 1,
  537. ),
  538. 'type' => 'count',
  539. 'col' => '*',
  540. ),
  541. # 获取总金额
  542. 'getCashNum' => array
  543. (
  544. # 匹配的正则或函数 选填项
  545. 'option' => array
  546. (
  547. 'start' => array('yes-cdate', '>='),
  548. 'end' => array('yes-cdate', '<='),
  549. 'start_o' => array('yes-operdate', '>='),
  550. 'end_o' => array('yes-operdate', '<='),
  551. 'type' => 'yes',
  552. 'type_id' => 'yes',
  553. 'source_type' => 'yes',
  554. 'source_id' => 'yes',
  555. 'status' => array('yes', 'in'),
  556. 'state' => 1,
  557. ),
  558. 'type' => 'one',
  559. 'col' => 'sum(price-refund_cash) as total',
  560. ),
  561. # 获取总金额
  562. 'getPCashNum' => array
  563. (
  564. # 匹配的正则或函数 选填项
  565. 'option' => array
  566. (
  567. 'start' => array('yes-cdate', '>='),
  568. 'end' => array('yes-cdate', '<='),
  569. 'start_o' => array('yes-operdate', '>='),
  570. 'end_o' => array('yes-operdate', '<='),
  571. 'type' => 'yes',
  572. 'type_id' => 'yes',
  573. 'source_type' => 'yes',
  574. 'source_id' => 'yes',
  575. 'status' => array('yes', 'in'),
  576. 'state' => 1,
  577. ),
  578. 'type' => 'one',
  579. 'col' => 'sum(p_price-refund_p_cash) as total',
  580. ),
  581. # 获取商品数量
  582. 'getGoodsNum' => array
  583. (
  584. # 匹配的正则或函数 选填项
  585. 'option' => array
  586. (
  587. 'start' => array('yes-cdate', '>='),
  588. 'end' => array('yes-cdate', '<='),
  589. 'start_o' => array('yes-operdate', '>='),
  590. 'end_o' => array('yes-operdate', '<='),
  591. 'type' => 'yes',
  592. 'type_id' => 'yes',
  593. 'source_type' => 'yes',
  594. 'source_id' => 'yes',
  595. 'status' => array('yes', 'in'),
  596. 'state' => 1,
  597. ),
  598. 'type' => 'one',
  599. 'col' => 'sum(num) as total',
  600. ),
  601. # 获取提交订单超过12个小时
  602. 'getDataByTime' => array
  603. (
  604. # 匹配的正则或函数 选填项
  605. 'option' => array
  606. (
  607. 'cdate' => array('yes', '<='),
  608. 'status' => 'yes',
  609. 'notice' => 'yes',
  610. 'state' => 1,
  611. ),
  612. 'type' => 'all',
  613. 'order' => array('cdate' => 'desc'),
  614. 'col' => '*',
  615. ),
  616. # 获取商品数量
  617. 'getGoodsTotal' => array
  618. (
  619. # 匹配的正则或函数 选填项
  620. 'option' => array
  621. (
  622. 'type' => 'yes',
  623. 'type_id' => 'yes',
  624. 'status' => array('yes', 'in'),
  625. 'state' => 1,
  626. ),
  627. 'type' => 'one',
  628. 'col' => 'sum(num) as total',
  629. ),
  630. 'getDataToId' => array
  631. (
  632. # 匹配的正则或函数 选填项
  633. 'option' => array
  634. (
  635. 'type' => 'yes',
  636. 'type_id' => 'yes',
  637. 'source_type' => 'yes',
  638. 'source_id' => 'yes',
  639. 'parent_type' => 'yes',
  640. 'parent_order_id' => 'yes',
  641. 'status' => array('yes', 'in'),
  642. 'state' => 1,
  643. ),
  644. 'type' => 'all',
  645. 'order' => array('cdate' => 'desc'),
  646. 'col' => '*|id',
  647. ),
  648. ),
  649. );