Set.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <?php
  2. namespace Cash\Lib;
  3. use Dever;
  4. class Set
  5. {
  6. public function getCash($cash)
  7. {
  8. if (!$cash || $cash <= 0) {
  9. return 0;
  10. }
  11. return round($cash, 2);
  12. }
  13. public function info($audit_type, $audit)
  14. {
  15. $config = Dever::db('cash/order')->config;
  16. return $config['config_audit_type'][$audit_type] . $config['config_audit'][$audit];
  17. }
  18. public function statDate($type, $day)
  19. {
  20. if ($type == 1) {
  21. $string = 'Y年m月';
  22. } elseif ($type == 2) {
  23. $string = 'Y年W周';
  24. } else {
  25. $string = 'Y年m月d日';
  26. }
  27. return date($string, $day);
  28. }
  29. public function statYes($info, $type, $source = false)
  30. {
  31. $table = 'cash/' . $type;
  32. if ($type == 'shop_sell') {
  33. $type = 'shop';
  34. }
  35. $info = is_array($info) ? $info : Dever::db($table)->one($info);
  36. $other = Dever::db($type . '/info')->find($info[$type . '_id']);
  37. if (!$other) {
  38. return '';
  39. }
  40. if ($type == 'store') {
  41. return $this->statDate($info['type'], $info['day']) . '与'.$other['name'].'对账单数量是否正确<br />对账数量' . $info['num'] . '个';
  42. }
  43. return $this->statDate($info['type'], $info['day']) . '与'.$other['name'].'对账单款项是否正确<br />对账金额¥' . round($info['cash'],2) . '元';
  44. }
  45. public function statTime($start, $end)
  46. {
  47. return date('Y-m-d', $start) . ' ~ ' . date('Y-m-d', $end);
  48. }
  49. public function orderUpdate_commit($id, $name, $data)
  50. {
  51. Dever::config('base')->hook = true;
  52. $update = array();
  53. $audit = Dever::param('audit', $data);
  54. $info = Dever::db('cash/order')->one($id);
  55. if ($audit > 1 && $info['refund_id'] && $info['refund_id'] > 0) {
  56. Dever::load('shop/lib/refund')->set('buy')->action($info['refund_id'], $audit, false, false);
  57. if ($audit == 2) {
  58. $state = Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time(), 'fdate' => time()));
  59. $order = Dever::db('shop/buy_order')->find(array('id' => $info['source_order_id'], 'clear' => true));
  60. if ($state && $info['jstype'] == 2 && isset($order['status']) && $order['status'] == 8) {
  61. # 如果是退款结算,同时要把主订单也结算
  62. $where = array();
  63. $where['source_order_id'] = $order['id'];
  64. $where['jstype'] = 1;
  65. $where['audit'] = 1;
  66. $info = Dever::db('cash/order')->find($where);
  67. if ($info) {
  68. $set['status'] = 2;
  69. $set['audit'] = 2;
  70. $set['where_id'] = $info['id'];
  71. $set['operdate'] = time();
  72. $set['fdate'] = time();
  73. Dever::db('cash/order')->update($set);
  74. }
  75. }
  76. }
  77. }
  78. }
  79. # 审核对账
  80. public function audit_api()
  81. {
  82. Dever::config('base')->hook = true;
  83. $id = Dever::input('id');
  84. $type = Dever::input('type', 'shop');
  85. $table = 'cash/' . $type;
  86. $data = Dever::db($table)->one($id);
  87. if ($data) {
  88. Dever::db($table)->update(array('where_id' => $id, 'status' => 2));
  89. if ($type == 'shop_sell' && $data['cash'] > 0) {
  90. return 'reload';
  91. $card = Dever::db('cash/order')->getCardAll(array('start'=>$data['start'],'end'=>$data['end'],'pay_type'=>2,'status'=>2,'type'=>1,'type_id'=>$data['shop_id'],'state'=>1));
  92. $shop = Dever::db('shop/info')->find($data['shop_id']);
  93. if ($card && $card['cash'] > 0) {
  94. $cash = sprintf("%01.2f", $card['cash']);
  95. $yue = $shop['price'] + $cash;
  96. $explan = date('Y年m月d日',$data['end']).'礼品卡对账金额';
  97. Dever::load('shop/lib/record')->pingtai($data['shop_id'],$shop['sid'],8,$data['shop_id'],$cash,$yue,$explan);
  98. }
  99. $bao = Dever::db('cash/order')->getCardAll(array('start'=>$data['start'],'end'=>$data['end'],'pay_type'=>3,'status'=>2,'type'=>1,'type_id'=>$data['shop_id'],'state'=>1));
  100. if($bao && $bao['cash']>0){
  101. $shop = Dever::db('shop/info')->find(array('id'=>$shop['id'],'s'=>1));
  102. $cash = sprintf("%01.2f", $bao['cash']);
  103. $yue = $shop['price'] + $cash;
  104. $explan = date('Y年m月d日',$data['end']).'钱包对账金额';
  105. Dever::load('shop/lib/record')->pingtai($data['shop_id'],$shop['sid'],8,$data['shop_id'],$cash,$yue,$explan);
  106. }
  107. }
  108. }
  109. return 'reload';
  110. }
  111. # 批量审核对账
  112. public function auditShopMul($id, $name, $data)
  113. {
  114. Dever::config('base')->hook = true;
  115. $table = 'cash/shop';
  116. if ($id) {
  117. $list = explode(',', $id);
  118. if ($list) {
  119. foreach ($list as $k => $v) {
  120. $data = Dever::db($table)->one($v);
  121. if ($data) {
  122. Dever::db($table)->update(array('where_id' => $v, 'status' => 2));
  123. }
  124. }
  125. }
  126. }
  127. return 'reload';
  128. }
  129. # 审核对账
  130. public function audit_other_api()
  131. {
  132. $id = Dever::input('id');
  133. $type = Dever::input('type', 'shop');
  134. $table = 'cash/' . $type;
  135. $info = Dever::db($table)->one($id);
  136. if ($info) {
  137. Dever::db($table)->update(array('where_id' => $id, $type . '_status' => 2));
  138. }
  139. return 'reload';
  140. }
  141. # 查看对账单详情
  142. public function view_api()
  143. {
  144. $id = Dever::input('id');
  145. if (!$id) {
  146. return false;
  147. }
  148. $show = Dever::input('show', 1);
  149. $type = Dever::input('type', 'shop');
  150. $pay_type = 1;
  151. $table = 'cash/' . $type;
  152. $source_type = $type;
  153. if ($type == 'shop') {
  154. $search_option_type = 1;
  155. $name = '门店';
  156. } if ($type == 'shop_sell') {
  157. $search_option_type = 1;
  158. $pay_type = '2,3';
  159. $name = '门店零售';
  160. $type = 'shop';
  161. } elseif ($type == 'store') {
  162. $search_option_type = 3;
  163. $name = '仓库';
  164. } elseif ($type == 'factory') {
  165. $search_option_type = 2;
  166. $name = '工厂';
  167. }
  168. $config = Dever::db($table)->config;
  169. $info = Dever::db($table)->one($id);
  170. $status = $config['config_status'][$info['status']];
  171. $other_status = $config['config_status'][$info[$type . '_status']];
  172. $other = Dever::db($type . '/info')->find($info[$type . '_id']);
  173. $html = '<div class="layui-col-md12"><div class="layui-card"><div class="layui-card-header">对账单详情</div><div class="layui-card-body">';
  174. $html .= '<table class="layui-table"><tbody>';
  175. $html .= '<tr>
  176. <td width="100">对账'.$name.'</td>
  177. <td>'.$this->table(false, array(array($other['name']))).'</td>
  178. </tr>';
  179. $html .= '<tr>
  180. <td width="80">对账时间</td>
  181. <td>'.$this->table(false, array(array($this->statDate($info['type'], $info['day'])))).'</td>
  182. </tr>';
  183. $html .= '<tr>
  184. <td width="80">对账周期</td>
  185. <td>'.$this->table(false, array(array($this->statTime($info['start'], $info['end'])))).'</td>
  186. </tr>';
  187. if ($type == 'store') {
  188. $html .= '<tr>
  189. <td width="80">商品数量</td>
  190. <td>'.$this->table(false, array(array($info['num']))).'</td>
  191. </tr>';
  192. } else {
  193. $html .= '<tr>
  194. <td width="80">对账金额</td>
  195. <td>'.$this->table(false, array(array('¥' . round($info['cash'], 2)))).'</td>
  196. </tr>';
  197. }
  198. if ($show == 1) {
  199. $manage_config = Dever::db('main/manage_config')->find();
  200. $s = 2;
  201. if ($table == 'cash/shop' && $manage_config['buy_dz'] == 1) {
  202. $s = 1;
  203. }
  204. if ($table == 'cash/shop_sell' && $manage_config['sell_dz'] == 1) {
  205. $s = 1;
  206. }
  207. if ($s == 1) {
  208. $html .= '<tr>
  209. <td width="80">'.$name.'对账状态</td>
  210. <td>'.$this->table(false, array(array($other_status))).'</td>
  211. </tr>';
  212. }
  213. $html .= '<tr>
  214. <td width="100">平台对账状态</td>
  215. <td>'.$this->table(false, array(array($status))).'</td>
  216. </tr>';
  217. } else {
  218. $html .= '<tr>
  219. <td width="80">对账状态</td>
  220. <td>'.$this->table(false, array(array($other_status))).'</td>
  221. </tr>';
  222. }
  223. $button = array();
  224. if ($show == 1) {
  225. if ($info['status'] == 1) {
  226. $url = Dever::url('lib/set.audit&id='.$id.'&type=' . $source_type, 'cash');
  227. $button[] = '<button class="layui-btn layui-btn-primary" onclick="load(\''.$url.'\', \''.$this->statYes($info, $source_type).'\', \'请确认\')">立即确认</button>';
  228. }
  229. $config['phone'] = '联系人:' . $other['truename'] . ',联系电话:' . $other['mobile'];
  230. $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系'.$name.'</button>';
  231. $start = date('Y-m-d H:i:s', $info['start']);
  232. $end = date('Y-m-d H:i:s', $info['end']);
  233. $out = Dever::url('lib/set.excel?id=' . $info['id'] . '&type=' . $source_type, 'cash');
  234. $button[] = '<a class="layui-btn layui-btn-primary" href="'.$out.'">导出对账单</a>';
  235. } elseif ($show == 2) {
  236. if ($info[$type . '_status'] == 1 && $show != 1) {
  237. $url = Dever::url('lib/set.audit_other&id='.$id.'&type=' . $source_type, 'cash');
  238. $button[] = '<button class="layui-btn layui-btn-primary" onclick="load(\''.$url.'\', \''.$this->statYes($info, $source_type).'\', \'请确认\')">立即确认</button>';
  239. }
  240. $config = Dever::load('factory/admin/auth.config');
  241. $config['phone'] = '联系电话:' . $config['dz_phone'];
  242. $button[] = '<button class="layui-btn layui-btn-primary" onclick="showAlert(\''.$config['phone'].'\')">联系对账专员</button>';
  243. $print = Dever::url('admin/stat.print?id=' . $info['id'] . '&type=' . $source_type, $type);
  244. $button[] = '<a class="layui-btn layui-btn-primary" href="'.$print.'" target="_blank">打印对账单</a>';
  245. }
  246. $html .= '<tr>
  247. <td>功能按钮</td>
  248. <td>'.$this->table(false, array($button)).'</td>
  249. </tr>';
  250. $html .= '</tbody></table></div></div>';
  251. $data = $this->getOrderData($type, $info, '', $pay_type);
  252. if ($data) {
  253. $body = array();
  254. $config = Dever::db('cash/order')->config;
  255. foreach ($data as $k => $v) {
  256. $cdate = date('Y-m-d H:i', $v['cdate']);
  257. $fdate = $v['fdate'] ? date('Y-m-d H:i', $v['fdate']) : '';
  258. $operdate = $v['operdate'] ? date('Y-m-d H:i', $v['operdate']) : '';
  259. $noprice = 2;
  260. if ($type == 'factory') {
  261. $set_type = 2;
  262. $cash = '¥' . round($v['p_cash'], 2);
  263. } else {
  264. $cash = '¥' . round($v['cash'], 2);
  265. $set_type = 1;
  266. }
  267. if ($show == 1) {
  268. if ($v['source_type'] == 4) {
  269. $url = Dever::url('project/database/list?project=shop&table=sell_order_goods&order_id='.$v['source_order_id'].'&page_type=1&noprice=' . $noprice . '&type=' . $set_type, 'manage');
  270. } else {
  271. $url = Dever::url('project/database/list?project=shop&table=buy_order_goods&order_id='.$v['source_order_id'].'&page_type=1&noprice=' . $noprice . '&type=' . $set_type, 'manage');
  272. }
  273. $v['source_order_num'] = '<a href="'.$url.'" style="color:blue">'.$v['source_order_num'].'</a>';
  274. $head = array('结算单号', '订货单号', '结算类型', '下单日期', '完成日期', '结算日期', '对账金额');
  275. if ($type == 'store') {
  276. $head[6] = '商品数量';
  277. }
  278. $head[] = '结算状态';
  279. $d = array
  280. (
  281. $v['order_num'],
  282. $v['source_order_num'],
  283. $config['config_jstype'][$v['jstype']],
  284. $cdate,
  285. $fdate,
  286. $operdate,
  287. $cash,
  288. );
  289. if ($type == 'store') {
  290. $d[6] = $v['num'];
  291. }
  292. $d[] = '已入账';
  293. $body[] = $d;
  294. } else {
  295. $head = array('订货单号', '下单日期', '完成日期', '对账金额');
  296. if ($type == 'store') {
  297. $head[3] = '商品数量';
  298. }
  299. $head[] = '状态';
  300. $d = array
  301. (
  302. $v['source_order_num'],
  303. $cdate,
  304. $fdate,
  305. $cash,
  306. );
  307. if ($type == 'store') {
  308. $d[3] = $v['num'];
  309. }
  310. $d[] = '已入账';
  311. $body[] = $d;
  312. }
  313. }
  314. $page = Dever::page("current");
  315. $html .= '<div class="layui-card"><div class="layui-card-header">对账清单</div><div class="layui-card-body" style="max-heights: 500px;overflow: auto;">' . $this->table($head, $body) . $page . '</div></div>';
  316. }
  317. $html .= '</div>';
  318. return '<div class="layui-card-body">' . $html . '</div>';
  319. }
  320. private function table($head, $data)
  321. {
  322. $html = '';
  323. if ($head) {
  324. $html = '<table class="layui-table">';
  325. $html .= '<thead><tr>';
  326. foreach ($head as $k => $v) {
  327. $html .= '<th>'.$v.'</th>';
  328. }
  329. $html .= '</tr></thead>';
  330. $html .= '<tbody>';
  331. foreach ($data as $k => $v) {
  332. $html .= '<tr>';
  333. foreach ($v as $k1 => $v1) {
  334. $html .= '<td>'.$v1.'</td>';
  335. }
  336. $html .= '</tr>';
  337. }
  338. $html .= '</tbody>';
  339. $html .= '</table>';
  340. } else {
  341. foreach ($data as $k => $v) {
  342. $html .= '';
  343. foreach ($v as $k1 => $v1) {
  344. $html .= $v1 . '&nbsp;&nbsp;&nbsp;&nbsp;';
  345. }
  346. $html .= '';
  347. }
  348. }
  349. return $html;
  350. }
  351. # 导出对账单
  352. public function excel_api()
  353. {
  354. $type = Dever::input('type');
  355. $id = Dever::input('id');
  356. $table = 'cash/' . $type;
  357. $pay_type = 1;
  358. if ($type == 'shop_sell') {
  359. $pay_type = '2,3';
  360. $type = 'shop';
  361. }
  362. $config = Dever::db($table)->config;
  363. $info = Dever::db($table)->one($id);
  364. $data = $this->getOrderData($type, $info, 'NoPage', $pay_type);
  365. $stat_type = Dever::db('cash/shop')->config['config_type'];
  366. $other = Dever::db($type . '/info')->find($info[$type . '_id']);
  367. $status = $config['config_status'][$info['status']];
  368. $other_status = $config['config_status'][$info[$type . '_status']];
  369. $info['name'] = Dever::load('cash/lib/set')->statDate($stat_type, $info['day']);
  370. $info['status_name'] = $status;
  371. $file = $other['name'] . '的' . $info['name'] . '对账单';
  372. $header = $body = array();
  373. $header = array
  374. (
  375. 'top' => array
  376. (
  377. $file . ' ' . $info['status_name'] . ' 对账金额¥' . $info['cash']. ' 商品数量¥' . $info['num'],
  378. ),
  379. '结算单号',
  380. '订货单号',
  381. '结算类型',
  382. '下单日期',
  383. '完成日期',
  384. '结算日期',
  385. '对账金额',
  386. '礼品卡卡号',
  387. '礼品卡抵扣金额',
  388. );
  389. if ($type == 'store') {
  390. $head[6] = '商品数量';
  391. }
  392. $head[] = '结算状态';
  393. if ($data) {
  394. $body = array();
  395. foreach ($data as $k => $v) {
  396. $cdate = date('Y-m-d H:i', $v['cdate']);
  397. $fdate = $v['fdate'] ? date('Y-m-d H:i', $v['fdate']) : '';
  398. $operdate = $v['operdate'] ? date('Y-m-d H:i', $v['operdate']) : '';
  399. if ($type == 'factory') {
  400. $cash = '¥' . round($v['p_cash'], 2);
  401. } else {
  402. $cash = '¥' . round($v['cash'], 2);
  403. }
  404. $card_code_card = '';
  405. $card_code_cash = '';
  406. if ($v['pay_type'] == 2) {
  407. $sell_order = Dever::db('shop/sell_order')->find($v['source_order_id']);
  408. if ($sell_order) {
  409. $card_code_card = $sell_order['card_code_card'];
  410. $card_code_cash = $sell_order['card_code_cash'];
  411. }
  412. }
  413. $jstype = Dever::db('cash/order')->config['config_jstype'][$v['jstype']];
  414. $body[$k][0] = $v['order_num'];
  415. $body[$k][1] = $v['source_order_num'];
  416. $body[$k][2] = $jstype;
  417. $body[$k][3] = $cdate;
  418. $body[$k][4] = $operdate;
  419. $body[$k][5] = $fdate;
  420. $body[$k][6] = $cash;
  421. if ($type == 'store') {
  422. $body[$k][6] = $v['num'];
  423. }
  424. $body[$k][7] = $card_code_card;
  425. $body[$k][8] = $card_code_cash;
  426. $body[$k][] = '已入账';
  427. }
  428. }
  429. Dever::excelExport($body, $header, $file);
  430. }
  431. # 打印订单单
  432. public function printer($user)
  433. {
  434. $id = Dever::input('id');
  435. if (!$id) {
  436. return false;
  437. }
  438. $type = Dever::input('type', 'shop');
  439. $table = 'cash/' . $type;
  440. $pay_type = 1;
  441. if ($type == 'shop') {
  442. $name = '门店';
  443. } elseif ($type == 'shop_sell') {
  444. $pay_type = '2,3';
  445. $name = '门店';
  446. $type = 'shop';
  447. } elseif ($type == 'store') {
  448. $name = '仓库';
  449. } elseif ($type == 'factory') {
  450. $name = '工厂';
  451. }
  452. $config = Dever::db($table)->config;
  453. $info = Dever::db($table)->one($id);
  454. $status = $config['config_status'][$info['status']];
  455. $other_status = $config['config_status'][$info[$type . '_status']];
  456. $other = Dever::db($type . '/info')->find($info[$type . '_id']);
  457. $member = Dever::db($type . '/member')->find($user['id']);
  458. $factory_config = Dever::db('main/factory_config')->find();
  459. $main_config = Dever::db('main/config')->find();
  460. $pdf = Dever::load('pdf/lib/base')->init();
  461. $pdf->hr('-', $other['name']);
  462. $pdf->br()->font(20)->center('对账周期:' . $this->statTime($info['start'], $info['end']));
  463. $pdf->font(10);
  464. $pdf->br();
  465. $pdf->br()->left('对账日期:' . $this->statDate($info['type'], $info['day']), 80)->left('制单人:' . $member['name'], 60)->left('制单时间:' . date('Y-m-d H:i'), 40);
  466. $pdf->hr();
  467. $data = $this->getOrderData($type, $info, 'NoPage', $pay_type);
  468. $body = array();
  469. $body_total = array();
  470. $body_total['cash'] = 0;
  471. $body_total['num'] = 0;
  472. if ($data) {
  473. foreach ($data as $k => $v) {
  474. $cdate = date('Y-m-d H:i', $v['cdate']);
  475. $fdate = $v['fdate'] ? date('Y-m-d H:i', $v['fdate']) : '';
  476. $operdate = $v['operdate'] ? date('Y-m-d H:i', $v['operdate']) : '';
  477. $prefix = '¥';
  478. if ($type == 'store') {
  479. $cash = $v['num'];
  480. $prefix = '';
  481. } elseif ($type == 'factory') {
  482. $cash = $v['p_cash'];
  483. } else {
  484. $cash = $v['cash'];
  485. }
  486. $cash = round($cash, 2);
  487. $body[] = array
  488. (
  489. $v['source_order_num'],
  490. $cdate,
  491. $fdate,
  492. $prefix . $cash,
  493. '已入账'
  494. );
  495. $body_total['cash'] += $cash;
  496. $body_total['num'] += 1;
  497. }
  498. }
  499. $head = array(array('订单号', 60), array('下单日期', 43), array('完成日期', 43), array('对账金额', 30), array('状态', 20));
  500. if ($type == 'store') {
  501. $head[3][0] = '对账数量';
  502. }
  503. if ($body) {
  504. $pdf->br();
  505. foreach ($head as $k => $v) {
  506. $pdf->left($v[0], $v[1]);
  507. }
  508. foreach ($body as $k => $v) {
  509. $pdf->br();
  510. foreach ($head as $k1 => $v1) {
  511. $pdf->left($v[$k1], $v1[1]);
  512. }
  513. }
  514. $pdf->br();
  515. if ($type == 'store') {
  516. $pdf->right('共'.$body_total['num'].'个订单,合计对账数量' . $body_total['cash'] . '个');
  517. } else {
  518. $pdf->right('共'.$body_total['num'].'个订单,合计对账金额¥' . $body_total['cash'] . '元');
  519. }
  520. $pdf->hr();
  521. }
  522. $pdf->br(1);
  523. //$pdf->SetY(-100);
  524. $pdf->right('如遇任何问题请致电客服');
  525. $pdf->br();
  526. $pdf->font(20);
  527. $pdf->left($main_config['name'], 160);
  528. $pdf->font(10);
  529. $pdf->right('电话:' . $factory_config['phone'], 30);
  530. $pdf->br();
  531. $pdf->left($main_config['site'], 160);
  532. $pdf->font(10);
  533. $pdf->right($main_config['worktime'], 30);
  534. $pdf->out('对账单');
  535. }
  536. # 获取对账单数据
  537. public function getOrderData($type, $info, $page = 'NoPage', $pay_type = 1)
  538. {
  539. $id = $info[$type . '_id'];;
  540. if ($type == 'shop' || $type == 'shop_sell') {
  541. $where['type'] = 1;
  542. $where['type_id'] = $id;
  543. $where['pay_type'] = $pay_type;
  544. $m = 'getAll';
  545. } elseif ($type == 'factory') {
  546. $where['source_type'] = 3;
  547. $where['source_id'] = $id;
  548. $m = 'getAll';
  549. } else {
  550. $where['type'] = 2;
  551. $where['type_id'] = $id;
  552. $where['source_type'] = 2;
  553. $where['source_id'] = $id;
  554. $m = 'getAllByStore';
  555. }
  556. $m .= $page;
  557. $where['status'] = 2;
  558. $where['start'] = $info['start'];
  559. $where['end'] = $info['end'];
  560. return Dever::db('cash/order')->$m($where);
  561. }
  562. }