Bill.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. $mallvoucher_info=Db::name('ordercommon')->where(array('order_id' => $key))->field('mallvoucher_price')->find();
  165. $commis_list[$key]['mall_voucher_totals']=number_format($mallvoucher_info['mallvoucher_price'], 2);
  166. }
  167. View::assign('commis_list', $commis_list);
  168. View::assign('order_list', $order_list);
  169. View::assign('show_page', $order_model->page_info->render());
  170. $sub_tpl_name = 'show_order_list';
  171. }
  172. View::assign('bill_info', $bill_info);
  173. return View::fetch($sub_tpl_name);
  174. }
  175. public function bill_check() {
  176. $ob_no = input('param.ob_no');
  177. if (!$ob_no) {
  178. $this->error(lang('param_error'));
  179. }
  180. $bill_model = model('bill');
  181. $condition = array();
  182. $condition[] = array('ob_no','=',$ob_no);
  183. $condition[] = array('ob_state','=',BILL_STATE_STORE_COFIRM);
  184. $bill_info = $bill_model->getOrderbillInfo($condition);
  185. if (!$bill_info) {
  186. $this->error(lang('bill_is_not_exist'));
  187. }
  188. if (request()->isPost()) {
  189. Db::startTrans();
  190. try {
  191. if($bill_info['ob_result_totals']!=0){
  192. $storemoneylog_model=model('storemoneylog');
  193. $data=array(
  194. 'store_id'=>$bill_info['ob_store_id'],
  195. 'storemoneylog_type'=>Storemoneylog::TYPE_BILL,
  196. 'storemoneylog_state'=>Storemoneylog::STATE_VALID,
  197. 'storemoneylog_add_time'=>TIMESTAMP,
  198. 'store_avaliable_money'=>$bill_info['ob_result_totals'],//如果是欠账则从店铺余额里扣除,否则增加
  199. 'storemoneylog_desc'=>$ob_no.lang('bill_phase_numbers').lang('bill_state_success'),
  200. );
  201. $storemoneylog_model->changeStoremoney($data);
  202. }
  203. $update = $bill_model->editOrderbill(array('ob_state' => BILL_STATE_SUCCESS,'ob_admin_content'=>input('post.ob_admin_content')), $condition);
  204. if (!$update) {
  205. throw new \think\Exception(lang('bill_audit_fail'), 10006);
  206. }
  207. } catch (\Exception $e) {
  208. Db::rollback();
  209. $this->log(lang('bill_audit_bill') . $ob_no, 0);
  210. $this->error($e->getMessage());
  211. }
  212. Db::commit();
  213. $this->log(lang('bill_audit_bill') . $ob_no, 1);
  214. $this->success(lang('bill_audit_succ'),(string)url('Bill/show_bill',['ob_no'=>$ob_no]));
  215. } else {
  216. return View::fetch('bill_check');
  217. }
  218. }
  219. /**
  220. * 账单付款
  221. *
  222. */
  223. public function bill_pay()
  224. {
  225. $ob_no = input('param.ob_no');
  226. if (!preg_match('/^20\d{5,12}$/', $ob_no)) {
  227. $this->error(lang('param_error'));
  228. }
  229. $bill_model = model('bill');
  230. $condition = array();
  231. $condition[] = array('ob_no','=',$ob_no);
  232. $condition[] = array('ob_state','=',BILL_STATE_SYSTEM_CHECK);
  233. $bill_info = $bill_model->getOrderbillInfo($condition);
  234. if (!$bill_info) {
  235. $this->error(lang('param_error'));
  236. }
  237. if (request()->isPost()) {
  238. if (!preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.pay_date'))) {
  239. $this->error(lang('param_error'));
  240. }
  241. $input = array();
  242. $input['ob_pay_content'] = input('pay_content');
  243. $input['ob_paydate'] = strtotime(input('param.pay_date'));
  244. $input['ob_state'] = BILL_STATE_SUCCESS;
  245. $update = $bill_model->editOrderbill($input, $condition);
  246. if ($update) {
  247. $storecost_model = model('storecost');
  248. $cost_condition = array();
  249. $cost_condition[] = array('storecost_store_id','=',$bill_info['ob_store_id']);
  250. $cost_condition[] = array('storecost_state','=',0);
  251. $cost_condition[] = array('storecost_time','between', "{$bill_info['ob_startdate']},{$bill_info['ob_enddate']}");
  252. $storecost_model->editStorecost(array('storecost_state' => 1), $cost_condition);
  253. // 发送店铺消息
  254. $param = array();
  255. $param['code'] = 'store_bill_gathering';
  256. $param['store_id'] = $bill_info['ob_store_id'];
  257. $param['ali_param'] = array(
  258. 'bill_no' => $bill_info['ob_no']
  259. );
  260. $param['ten_param'] = array(
  261. $bill_info['ob_no']
  262. );
  263. $param['param'] = $param['ali_param'];
  264. //微信模板消息
  265. $param['weixin_param'] = array(
  266. 'url' => config('ds_config.h5_store_site_url').'/pages/seller/bill/BillList',
  267. 'data'=>array(
  268. "keyword1" => array(
  269. "value" => date('Y-m-d', $bill_info['ob_startdate']).'~'.date('Y-m-d', $bill_info['ob_enddate']),
  270. "color" => "#333"
  271. ),
  272. "keyword2" => array(
  273. "value" => date('Y-m-d', $bill_info['ob_createdate']),
  274. "color" => "#333"
  275. ),
  276. "keyword3" => array(
  277. "value" => $bill_info['ob_result_totals'],
  278. "color" => "#333"
  279. )
  280. ),
  281. );
  282. model('cron')->addCron(array('cron_exetime'=>TIMESTAMP,'cron_type'=>'sendStoremsg','cron_value'=>serialize($param)));
  283. $this->log(lang('bill_payment_audit_fail') . $ob_no, 1);
  284. $this->success(lang('ds_common_save_succ'), 'bill/show_statis?os_month=' . $bill_info['os_month']);
  285. } else {
  286. $this->log(lang('bill_payment_audit_fail') . $ob_no, 1);
  287. $this->error(lang('ds_common_save_fail'));
  288. }
  289. } else {
  290. $this->setAdminCurItem('bill_pay');
  291. return View::fetch('bill_pay');
  292. }
  293. }
  294. /**
  295. * 打印结算单
  296. *
  297. */
  298. public function bill_print()
  299. {
  300. $ob_no = input('param.ob_no');
  301. if (!$ob_no) {
  302. $this->error(lang('param_error'));
  303. }
  304. $bill_model = model('bill');
  305. $condition = array();
  306. $condition[] = array('ob_no','=',$ob_no);
  307. $condition[] = array('ob_state','=',BILL_STATE_SUCCESS);
  308. $bill_info = $bill_model->getOrderbillInfo($condition);
  309. if (!$bill_info) {
  310. $this->error(lang('param_error'));
  311. }
  312. View::assign('bill_info', $bill_info);
  313. return View::fetch('bill_print');
  314. }
  315. /**
  316. * 导出 结算管理
  317. *
  318. */
  319. public function export_js_step1() {
  320. $bill_model = model('bill');
  321. $condition = array();
  322. $query_year = input('get.query_year');
  323. if (preg_match('/^\d{4}$/', $query_year, $match)) {
  324. $condition[]=array('os_month','like',$query_year.'%');
  325. }
  326. if (!is_numeric(input('param.page'))) {
  327. $count = $bill_model->getOrderstatisCount($condition);
  328. $export_list = array();
  329. if ($count > self::EXPORT_SIZE) { //显示下载链接
  330. $page = ceil($count / self::EXPORT_SIZE);
  331. for ($i = 1; $i <= $page; $i++) {
  332. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  333. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  334. $export_list[$i] = $limit1 . ' ~ ' . $limit2;
  335. }
  336. View::assign('export_list', $export_list);
  337. return View::fetch('/public/excel');
  338. } else { //如果数量小,直接下载
  339. $data = $bill_model->getOrderstatisList($condition, '*', '', '', self::EXPORT_SIZE);
  340. $this->createJsExcel($data);
  341. }
  342. } else { //下载
  343. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  344. $limit2 = self::EXPORT_SIZE;
  345. $data = $bill_model->getOrderstatisList($condition, '*', $limit2);
  346. $this->createJsExcel($data);
  347. }
  348. }
  349. /**
  350. * 结算管理 生成excel
  351. *
  352. * @param array $data
  353. */
  354. private function createJsExcel($data = array()) {
  355. Lang::load(base_path() .'admin/lang/'.config('lang.default_lang').'/export.lang.php');
  356. $excel_obj = new \excel\Excel();
  357. $excel_data = array();
  358. //设置样式
  359. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  360. //header
  361. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_number_bill'));
  362. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_price_from'));
  363. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_order_total_transport'));
  364. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_commis_totals'));
  365. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_order_returntotals'));
  366. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_commis_returntotals'));
  367. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_store_costtotals'));
  368. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_ob_inviter_totals'));
  369. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_result_totals'));
  370. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_js_os_createdate'));
  371. //data
  372. foreach ((array) $data as $k => $v) {
  373. $tmp = array();
  374. $tmp[] = array('data' => substr($v['os_month'],0,4).'-'.substr($v['os_month'],4));
  375. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_order_totals']));
  376. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_shipping_totals']));
  377. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_commis_totals']));
  378. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_order_returntotals']));
  379. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_commis_returntotals']));
  380. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_store_costtotals']));
  381. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_inviter_totals']));
  382. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['os_result_totals']));
  383. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['os_createdate']));
  384. $excel_data[] = $tmp;
  385. }
  386. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  387. $excel_obj->addArray($excel_data);
  388. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_js_list'), CHARSET));
  389. $excel_obj->generateXML($excel_obj->charset(lang('exp_js_list'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  390. }
  391. /**
  392. * 商家账单列表 管理
  393. *
  394. */
  395. public function export_zd_step1() {
  396. $bill_model = model('bill');
  397. $condition = array();
  398. $bill_state = input('get.bill_state');
  399. if (is_numeric($bill_state)) {
  400. $condition[] = array('ob_state','=',intval($bill_state));
  401. }
  402. $query_store = input('get.query_store');
  403. if (preg_match('/^\d{1,8}$/', $query_store)) {
  404. $condition[] = array('ob_store_id','=',$query_store);
  405. } elseif ($query_store != '') {
  406. $condition[] = array('ob_store_name','=',$query_store);
  407. }
  408. $os_month = input('get.os_month');
  409. if($os_month){
  410. $condition[]=array('ob_startdate','>=',strtotime($os_month.'01 0:0:0'));
  411. $condition[]=array('ob_enddate','<',strtotime($os_month.'01 23:59:59 +1 month -1 day'));
  412. }
  413. if (!is_numeric(input('param.page'))) {
  414. $count = $bill_model->getOrderbillCount($condition);
  415. $export_list = array();
  416. if ($count > self::EXPORT_SIZE) { //显示下载链接
  417. $page = ceil($count / self::EXPORT_SIZE);
  418. for ($i = 1; $i <= $page; $i++) {
  419. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  420. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  421. $export_list[$i] = $limit1 . ' ~ ' . $limit2;
  422. }
  423. View::assign('export_list', $export_list);
  424. return View::fetch('/public/excel');
  425. } else { //如果数量小,直接下载
  426. $data = $bill_model->getOrderbillList($condition, '*', '', '', self::EXPORT_SIZE);
  427. $this->createZdExcel($data);
  428. }
  429. } else { //下载
  430. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  431. $limit2 = self::EXPORT_SIZE;
  432. $data = $bill_model->getOrderbillList($condition, '*', $limit2);
  433. $this->createZdExcel($data);
  434. }
  435. }
  436. /**
  437. * 商家账单列表 生成excel
  438. *
  439. * @param array $data
  440. */
  441. private function createZdExcel($data = array()) {
  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. }
  517. ?>