Bill.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Db;
  5. use think\facade\Lang;
  6. use app\common\model\Storemoneylog;
  7. /**
  8. *
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * 控制器
  13. */
  14. class Bill extends AdminControl
  15. {
  16. const EXPORT_SIZE = 1000;
  17. public function initialize()
  18. {
  19. parent::initialize();
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/bill.lang.php');
  21. }
  22. /**
  23. * 所有月份销量账单
  24. *
  25. */
  26. public function index()
  27. {
  28. //检查是否需要生成上月及更早结算单的程序不再执行,执行量较大,放到任务计划中触发
  29. $condition = array();
  30. $query_year = input('get.query_year');
  31. if (preg_match('/^\d{4}$/', $query_year, $match)) {
  32. $condition[] = array('os_month', 'like', $query_year . '%');
  33. }
  34. $bill_model = model('bill');
  35. $bill_list = $bill_model->getOrderstatisList($condition, '*', 12, 'os_month desc');
  36. View::assign('bill_list', $bill_list);
  37. View::assign('show_page', $bill_model->page_info->render());
  38. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  39. $this->setAdminCurItem('index');
  40. return View::fetch('index');
  41. }
  42. /**
  43. * 某月所有店铺销量账单
  44. *
  45. */
  46. public function show_statis()
  47. {
  48. $bill_model = model('bill');
  49. $condition = array();
  50. $bill_state = input('get.bill_state');
  51. if (is_numeric($bill_state)) {
  52. $condition[] = array('ob_state', '=', intval($bill_state));
  53. }
  54. $query_store = input('get.query_store');
  55. if (preg_match('/^\d{1,8}$/', $query_store)) {
  56. $condition[] = array('ob_store_id', '=', $query_store);
  57. } elseif ($query_store != '') {
  58. $condition[] = array('ob_store_name', '=', $query_store);
  59. }
  60. $os_month = input('get.os_month');
  61. if ($os_month) {
  62. $condition[] = array('ob_startdate', '>=', strtotime($os_month . '01 0:0:0'));
  63. $condition[] = array('ob_enddate', '<', strtotime($os_month . '01 23:59:59 +1 month -1 day'));
  64. }
  65. $bill_list = $bill_model->getOrderbillList($condition, '*', 30, 'ob_no desc');
  66. View::assign('bill_list', $bill_list);
  67. View::assign('show_page', $bill_model->page_info->render());
  68. $this->setAdminCurItem('show_statis');
  69. return View::fetch('show_statis');
  70. }
  71. /**
  72. * 某店铺某月订单列表
  73. *
  74. */
  75. public function show_bill()
  76. {
  77. $ob_no = input('param.ob_no');
  78. if (!$ob_no) {
  79. $this->error(lang('param_error'));
  80. }
  81. $bill_model = model('bill');
  82. $bill_info = $bill_model->getOrderbillInfo(array('ob_no' => $ob_no));
  83. if (!$bill_info) {
  84. $this->error(lang('param_error'));
  85. }
  86. $order_condition = array();
  87. $order_condition[] = array('ob_no', '=', $ob_no);
  88. $order_condition[] = array('order_state', '=', ORDER_STATE_SUCCESS);
  89. $order_condition[] = array('store_id', '=', $bill_info['ob_store_id']);
  90. $query_start_date = input('get.query_start_date');
  91. $query_end_date = input('get.query_end_date');
  92. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $query_start_date);
  93. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $query_end_date);
  94. $start_unixtime = $if_start_date ? strtotime($query_start_date) : null;
  95. $end_unixtime = $if_end_date ? strtotime($query_end_date) : null;
  96. $end_unixtime = $if_end_date ? $end_unixtime + 86400 - 1 : null;
  97. if ($if_start_date || $if_end_date) {
  98. if ($if_start_date) {
  99. $order_condition[] = array('finnshed_time', '>=', $start_unixtime);
  100. }
  101. if ($if_end_date) {
  102. $order_condition[] = array('finnshed_time', '<=', $end_unixtime);
  103. }
  104. }
  105. $query_type = input('param.query_type');
  106. if ($query_type == 'cost') {
  107. //店铺费用
  108. $storecost_model = model('storecost');
  109. $cost_condition = array();
  110. $cost_condition[] = array('storecost_store_id', '=', $bill_info['ob_store_id']);
  111. $cost_condition[] = array('storecost_time', 'between', [$bill_info['ob_startdate'], $bill_info['ob_enddate']]);
  112. $store_cost_list = $storecost_model->getStorecostList($cost_condition, 20);
  113. //取得店铺名字
  114. $store_info = model('store')->getStoreInfoByID($bill_info['ob_store_id']);
  115. View::assign('cost_list', $store_cost_list);
  116. View::assign('store_info', $store_info);
  117. View::assign('show_page', $storecost_model->page_info->render());
  118. $sub_tpl_name = 'show_cost_list';
  119. } elseif ($query_type == 'vrorder') {
  120. //店铺费用
  121. $vrorder_model = model('vrorder');
  122. $order_list = $vrorder_model->getVrorderList($order_condition, 20, '(ROUND(order_amount*commis_rate/100,2)) AS commis_amount,(ROUND(refund_amount*commis_rate/100,2)) AS return_commis_amount,order_amount,refund_amount,order_sn,buyer_name,add_time,finnshed_time,order_id');
  123. foreach ($order_list as $key => $val) {
  124. if (!$val['order_id']) {
  125. $order_list = array();
  126. break;
  127. }
  128. //分销佣金
  129. $inviter_info = Db::name('orderinviter')->where(array('orderinviter_order_id' => $key, 'orderinviter_valid' => 1, 'orderinviter_order_type' => 1))->field('SUM(orderinviter_money) AS ob_inviter_totals')->find();
  130. $order_list[$key]['inviter_amount'] = ds_price_format($inviter_info['ob_inviter_totals']);
  131. }
  132. View::assign('order_list', $order_list);
  133. View::assign('show_page', $vrorder_model->page_info->render());
  134. $sub_tpl_name = 'show_vrorder_list';
  135. } else {
  136. //订单列表
  137. $order_model = model('order');
  138. $order_list = $order_model->getOrderList($order_condition, 20);
  139. //然后取订单商品佣金
  140. $order_id_array = array();
  141. if (is_array($order_list)) {
  142. foreach ($order_list as $order_info) {
  143. $order_id_array[] = $order_info['order_id'];
  144. }
  145. }
  146. $order_goods_condition = array();
  147. $order_goods_condition[] = array('order_id', 'in', $order_id_array);
  148. $field = 'SUM(ROUND(goods_pay_price*commis_rate/100,2)) as commis_amount,order_id';
  149. $commis_list = $order_model->getOrdergoodsList($order_goods_condition, $field, 0, null, '', 'order_id', 'order_id');
  150. foreach ($commis_list as $key => $val) {
  151. $return_commis_amount = 0;
  152. $refund_info = Db::name('refundreturn')->alias('refundreturn')->join('ordergoods ordergoods', 'refundreturn.order_goods_id = ordergoods.rec_id')->where(array(array('refundreturn.order_id', '=', $key), array('refundreturn.refund_state', '=', 3), array('refundreturn.order_goods_id', '>', 0)))->field('SUM(ROUND(refundreturn.refund_amount*ordergoods.commis_rate/100,2)) AS ob_commis_return_totals')->find();
  153. $return_commis_amount = $refund_info['ob_commis_return_totals'];
  154. $commis_list[$key]['return_commis_amount'] = $return_commis_amount;
  155. //分销佣金
  156. $inviter_info = Db::name('orderinviter')->where(array('orderinviter_order_id' => $key, 'orderinviter_valid' => 1, 'orderinviter_order_type' => 0))->field('SUM(orderinviter_money) AS ob_inviter_totals')->find();
  157. $commis_list[$key]['inviter_amount'] = $inviter_info['ob_inviter_totals'];
  158. //平台代金券
  159. $mallvoucher_info = Db::name('ordercommon')->where(array('order_id' => $key))->field('mallvoucher_price')->find();
  160. $commis_list[$key]['mall_voucher_totals'] = number_format($mallvoucher_info['mallvoucher_price'], 2);
  161. }
  162. View::assign('commis_list', $commis_list);
  163. View::assign('order_list', $order_list);
  164. View::assign('show_page', $order_model->page_info->render());
  165. $sub_tpl_name = 'show_order_list';
  166. }
  167. View::assign('bill_info', $bill_info);
  168. return View::fetch($sub_tpl_name);
  169. }
  170. public function bill_check()
  171. {
  172. $ob_no = input('param.ob_no');
  173. if (!$ob_no) {
  174. $this->error(lang('param_error'));
  175. }
  176. $bill_model = model('bill');
  177. $condition = array();
  178. $condition[] = array('ob_no', '=', $ob_no);
  179. $condition[] = array('ob_state', '=', BILL_STATE_STORE_COFIRM);
  180. $bill_info = $bill_model->getOrderbillInfo($condition);
  181. if (!$bill_info) {
  182. $this->error(lang('bill_is_not_exist'));
  183. }
  184. if (request()->isPost()) {
  185. Db::startTrans();
  186. try {
  187. if ($bill_info['ob_result_totals'] != 0) {
  188. $storemoneylog_model = model('storemoneylog');
  189. $data = array(
  190. 'store_id' => $bill_info['ob_store_id'],
  191. 'storemoneylog_type' => Storemoneylog::TYPE_BILL,
  192. 'storemoneylog_state' => Storemoneylog::STATE_VALID,
  193. 'storemoneylog_add_time' => TIMESTAMP,
  194. 'store_avaliable_money' => $bill_info['ob_result_totals'], //如果是欠账则从店铺余额里扣除,否则增加
  195. 'storemoneylog_desc' => $ob_no . lang('bill_phase_numbers') . lang('bill_state_success'),
  196. );
  197. $storemoneylog_model->changeStoremoney($data);
  198. }
  199. $update = $bill_model->editOrderbill(array('ob_state' => BILL_STATE_SUCCESS, 'ob_admin_content' => input('post.ob_admin_content')), $condition);
  200. if (!$update) {
  201. throw new \think\Exception(lang('bill_audit_fail'), 10006);
  202. }
  203. } catch (\Exception $e) {
  204. Db::rollback();
  205. $this->log(lang('bill_audit_bill') . $ob_no, 0);
  206. $this->error($e->getMessage());
  207. }
  208. Db::commit();
  209. $this->log(lang('bill_audit_bill') . $ob_no, 1);
  210. $this->success(lang('bill_audit_succ'), (string)url('Bill/show_bill', ['ob_no' => $ob_no]));
  211. } else {
  212. return View::fetch('bill_check');
  213. }
  214. }
  215. /**
  216. * 账单付款
  217. *
  218. */
  219. public function bill_pay()
  220. {
  221. $ob_no = input('param.ob_no');
  222. if (!preg_match('/^20\d{5,12}$/', $ob_no)) {
  223. $this->error(lang('param_error'));
  224. }
  225. $bill_model = model('bill');
  226. $condition = array();
  227. $condition[] = array('ob_no', '=', $ob_no);
  228. $condition[] = array('ob_state', '=', BILL_STATE_SYSTEM_CHECK);
  229. $bill_info = $bill_model->getOrderbillInfo($condition);
  230. if (!$bill_info) {
  231. $this->error(lang('param_error'));
  232. }
  233. if (request()->isPost()) {
  234. if (!preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.pay_date'))) {
  235. $this->error(lang('param_error'));
  236. }
  237. $input = array();
  238. $input['ob_pay_content'] = input('pay_content');
  239. $input['ob_paydate'] = strtotime(input('param.pay_date'));
  240. $input['ob_state'] = BILL_STATE_SUCCESS;
  241. $update = $bill_model->editOrderbill($input, $condition);
  242. if ($update) {
  243. $storecost_model = model('storecost');
  244. $cost_condition = array();
  245. $cost_condition[] = array('storecost_store_id', '=', $bill_info['ob_store_id']);
  246. $cost_condition[] = array('storecost_state', '=', 0);
  247. $cost_condition[] = array('storecost_time', 'between', "{$bill_info['ob_startdate']},{$bill_info['ob_enddate']}");
  248. $storecost_model->editStorecost(array('storecost_state' => 1), $cost_condition);
  249. // 发送店铺消息
  250. $param = array();
  251. $param['code'] = 'store_bill_gathering';
  252. $param['store_id'] = $bill_info['ob_store_id'];
  253. $param['ali_param'] = array(
  254. 'bill_no' => $bill_info['ob_no']
  255. );
  256. $param['ten_param'] = array(
  257. $bill_info['ob_no']
  258. );
  259. $param['param'] = $param['ali_param'];
  260. //微信模板消息
  261. $param['weixin_param'] = array(
  262. 'url' => config('ds_config.h5_store_site_url') . '/pages/seller/bill/BillList',
  263. 'data' => array(
  264. "keyword1" => array(
  265. "value" => date('Y-m-d', $bill_info['ob_startdate']) . '~' . date('Y-m-d', $bill_info['ob_enddate']),
  266. "color" => "#333"
  267. ),
  268. "keyword2" => array(
  269. "value" => date('Y-m-d', $bill_info['ob_createdate']),
  270. "color" => "#333"
  271. ),
  272. "keyword3" => array(
  273. "value" => $bill_info['ob_result_totals'],
  274. "color" => "#333"
  275. )
  276. ),
  277. );
  278. model('cron')->addCron(array('cron_exetime' => TIMESTAMP, 'cron_type' => 'sendStoremsg', 'cron_value' => serialize($param)));
  279. $this->log(lang('bill_payment_audit_fail') . $ob_no, 1);
  280. $this->success(lang('ds_common_save_succ'), 'bill/show_statis?os_month=' . $bill_info['os_month']);
  281. } else {
  282. $this->log(lang('bill_payment_audit_fail') . $ob_no, 1);
  283. $this->error(lang('ds_common_save_fail'));
  284. }
  285. } else {
  286. $this->setAdminCurItem('bill_pay');
  287. return View::fetch('bill_pay');
  288. }
  289. }
  290. /**
  291. * 打印结算单
  292. *
  293. */
  294. public function bill_print()
  295. {
  296. $ob_no = input('param.ob_no');
  297. if (!$ob_no) {
  298. $this->error(lang('param_error'));
  299. }
  300. $bill_model = model('bill');
  301. $condition = array();
  302. $condition[] = array('ob_no', '=', $ob_no);
  303. $condition[] = array('ob_state', '=', BILL_STATE_SUCCESS);
  304. $bill_info = $bill_model->getOrderbillInfo($condition);
  305. if (!$bill_info) {
  306. $this->error(lang('param_error'));
  307. }
  308. View::assign('bill_info', $bill_info);
  309. return View::fetch('bill_print');
  310. }
  311. /**
  312. * 导出 结算管理
  313. *
  314. */
  315. public function export_js_step1()
  316. {
  317. $bill_model = model('bill');
  318. $condition = array();
  319. $query_year = input('get.query_year');
  320. if (preg_match('/^\d{4}$/', $query_year, $match)) {
  321. $condition[] = array('os_month', 'like', $query_year . '%');
  322. }
  323. if (!is_numeric(input('param.page'))) {
  324. $count = $bill_model->getOrderstatisCount($condition);
  325. $export_list = array();
  326. if ($count > self::EXPORT_SIZE) { //显示下载链接
  327. $page = ceil($count / self::EXPORT_SIZE);
  328. for ($i = 1; $i <= $page; $i++) {
  329. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  330. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  331. $export_list[$i] = $limit1 . ' ~ ' . $limit2;
  332. }
  333. View::assign('export_list', $export_list);
  334. return View::fetch('/public/excel');
  335. } else { //如果数量小,直接下载
  336. $data = $bill_model->getOrderstatisList($condition, '*', '', '', self::EXPORT_SIZE);
  337. $this->createJsExcel($data);
  338. }
  339. } else { //下载
  340. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  341. $limit2 = self::EXPORT_SIZE;
  342. $data = $bill_model->getOrderstatisList($condition, '*', $limit2);
  343. $this->createJsExcel($data);
  344. }
  345. }
  346. /**
  347. * 结算管理 生成excel
  348. *
  349. * @param array $data
  350. */
  351. private function createJsExcel($data = array())
  352. {
  353. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/export.lang.php');
  354. $excel_obj = new \excel\Excel();
  355. $excel_data = array();
  356. //设置样式
  357. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  358. //header
  359. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_number_bill'));
  360. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_price_from'));
  361. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_total_transport'));
  362. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_commis_totals'));
  363. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_order_returntotals'));
  364. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_commis_returntotals'));
  365. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_store_costtotals'));
  366. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_ob_inviter_totals'));
  367. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_result_totals'));
  368. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_createdate'));
  369. //data
  370. foreach ((array) $data as $k => $v) {
  371. $tmp = array();
  372. $tmp[] = array('data' => substr($v['os_month'], 0, 4) . '-' . substr($v['os_month'], 4));
  373. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_order_totals']));
  374. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_shipping_totals']));
  375. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_commis_totals']));
  376. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_order_returntotals']));
  377. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_commis_returntotals']));
  378. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_store_costtotals']));
  379. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_inviter_totals']));
  380. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_result_totals']));
  381. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['os_createdate']));
  382. $excel_data[] = $tmp;
  383. }
  384. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  385. $excel_obj->addArray($excel_data);
  386. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_js_list'), CHARSET));
  387. $excel_obj->generateXML($excel_obj->charset(lang('exp_js_list'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  388. }
  389. /**
  390. * 商家账单列表 管理
  391. *
  392. */
  393. public function export_zd_step1()
  394. {
  395. $bill_model = model('bill');
  396. $condition = array();
  397. $bill_state = input('get.bill_state');
  398. if (is_numeric($bill_state)) {
  399. $condition[] = array('ob_state', '=', intval($bill_state));
  400. }
  401. $query_store = input('get.query_store');
  402. if (preg_match('/^\d{1,8}$/', $query_store)) {
  403. $condition[] = array('ob_store_id', '=', $query_store);
  404. } elseif ($query_store != '') {
  405. $condition[] = array('ob_store_name', '=', $query_store);
  406. }
  407. $os_month = input('get.os_month');
  408. if ($os_month) {
  409. $condition[] = array('ob_startdate', '>=', strtotime($os_month . '01 0:0:0'));
  410. $condition[] = array('ob_enddate', '<', strtotime($os_month . '01 23:59:59 +1 month -1 day'));
  411. }
  412. if (!is_numeric(input('param.page'))) {
  413. $count = $bill_model->getOrderbillCount($condition);
  414. $export_list = array();
  415. if ($count > self::EXPORT_SIZE) { //显示下载链接
  416. $page = ceil($count / self::EXPORT_SIZE);
  417. for ($i = 1; $i <= $page; $i++) {
  418. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  419. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  420. $export_list[$i] = $limit1 . ' ~ ' . $limit2;
  421. }
  422. View::assign('export_list', $export_list);
  423. return View::fetch('/public/excel');
  424. } else { //如果数量小,直接下载
  425. $data = $bill_model->getOrderbillList($condition, '*', '', '', self::EXPORT_SIZE);
  426. $this->createZdExcel($data);
  427. }
  428. } else { //下载
  429. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  430. $limit2 = self::EXPORT_SIZE;
  431. $data = $bill_model->getOrderbillList($condition, '*', $limit2);
  432. $this->createZdExcel($data);
  433. }
  434. }
  435. /**
  436. * 商家账单列表 生成excel
  437. *
  438. * @param array $data
  439. */
  440. private function createZdExcel($data = array())
  441. {
  442. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/export.lang.php');
  443. $excel_obj = new \excel\Excel();
  444. $excel_data = array();
  445. //设置样式
  446. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  447. //header
  448. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_no'));
  449. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_os_startdate'));
  450. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_os_enddate'));
  451. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_order_price_from'));
  452. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_order_total_transport'));
  453. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_print_commision'));
  454. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_order_return_totals'));
  455. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_os_commis_returntotals'));
  456. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_ob_inviter_totals'));
  457. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_vr_order_totals'));
  458. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_vr_order_return_totals'));
  459. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_vr_commis_totals'));
  460. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_vr_commis_return_totals'));
  461. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_ob_vr_inviter_totals'));
  462. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_os_store_costtotals'));
  463. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_os_result_totals'));
  464. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_out_date'));
  465. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_zd_bill_state'));
  466. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('ds_store_name'));
  467. //data
  468. foreach ((array) $data as $k => $v) {
  469. $tmp = array();
  470. $tmp[] = array('data' => $v['ob_no']);
  471. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['ob_startdate']));
  472. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['ob_enddate']));
  473. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_order_totals']));
  474. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_shipping_totals']));
  475. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_commis_totals']));
  476. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_order_return_totals']));
  477. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_commis_return_totals']));
  478. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_inviter_totals']));
  479. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_vr_order_totals']));
  480. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_vr_order_return_totals']));
  481. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_vr_commis_totals']));
  482. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_vr_commis_return_totals']));
  483. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_vr_inviter_totals']));
  484. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_store_cost_totals']));
  485. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['ob_result_totals']));
  486. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['ob_createdate']));
  487. $tmp[] = array('data' => get_bill_state($v['ob_state']));
  488. $tmp[] = array('data' => $v['ob_store_name']);
  489. $excel_data[] = $tmp;
  490. }
  491. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  492. $excel_obj->addArray($excel_data);
  493. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_zd_list'), CHARSET));
  494. $excel_obj->generateXML($excel_obj->charset(lang('exp_zd_list'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  495. }
  496. /**
  497. * 获取卖家栏目列表,针对控制器下的栏目
  498. */
  499. protected function getAdminItemList()
  500. {
  501. $menu_array = array(
  502. array(
  503. 'name' => 'index',
  504. 'text' => lang('ds_bill'),
  505. 'url' => (string)url('Bill/index')
  506. ),
  507. );
  508. $title = !empty(input('param.os_month')) ? input('param.os_month') . lang('bill_period') : '';
  509. $menu_array[] = array(
  510. 'name' => 'show_statis',
  511. 'text' => $title . lang('bill_billing_list'),
  512. 'url' => !empty($title) ? (string)url('Bill/show_statis', ['os_month' => input('param.os_month')]) : (string)url('Bill/show_statis'),
  513. );
  514. return $menu_array;
  515. }
  516. }