Bill.php 26 KB

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