Bill.php 27 KB

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