*/ class VerifyBillController extends Controller { /** * VerifyBillController constructor. */ public function __construct() { parent::__construct(); if(ACTION_NAME == "show" && isset($_REQUEST['from']) && $_REQUEST['from']=="pc"){ //不验证 }else{ if (empty(session('cp_user_auth'))) { redirect('admin.php?s=public/cp_login.html'); } } } /** * */ public function index(){ $m_title = '对账单管理'; $list_data = DM('statement')->order('create_time desc')->select(); foreach ($list_data as $key => $value) { $list_data[$key]['statement_type_str'] = $value['statement_type'] ? '工会对账单' : 'cp对账单'; } $this->assign('list_data', $list_data); $this->assign('meta_title', $m_title); $this->display(); } public function show() { $id = I('id'); $data = DM('statement')->where(['id' => $id])->find(); $data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方 $data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方 $data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录 //收款方 $data['receive_company'] = $data['pay_type'] ? $data['first_party_info']['partner'] : $data['second_party_info']['partner']; // dd($data); $all_sum_money = array_sum(array_column($data['statement_info'], 'sum_money'));//合计平台总额 $all_pay_amount = array_sum(array_column($data['statement_info'], 'pay_amount'));//合计结算金额 $big_all_sum_money = convertAmountToCn($all_sum_money);//大写 $this->assign('big_all_sum_money', $big_all_sum_money); $this->assign('all_sum_money', $all_sum_money); $this->assign('all_pay_amount', $all_pay_amount); $this->assign('data', $data); $this->assign('from', I('from')); if ($data['statement_type'] == 1) {//下游 $template = 'company_show'; } else { $template = 'partner_show';//上游 } $this->display($template); } public function confirm() { $id = I('id'); $res = DM('statement')->where(['id' => $id])->save(['is_confirm' => 1]); if ($res) { $this->success("操作成功", U('index')); } else { $this->error('操作失败'); } } /** *导出excell * @param int id */ public function export() { $id = I('id'); $data = DM('statement')->where(['id' => $id])->find(); $data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方 $data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方 $data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录 //收款方 // dd($data); $all_sum_money = array_sum(array_column($data['statement_info'], 'sum_money'));//合计平台总额 $all_pay_amount = array_sum(array_column($data['statement_info'], 'pay_amount'));//合计结算金额 $big_all_sum_money = convertAmountToCn($all_sum_money);//大写 $data['receive_company'] = $data['pay_type'] ? $data['first_party_info'] : $data['second_party_info']; $data['pay_company'] = $data['pay_type'] ? $data['second_party_info'] : $data['first_party_info']; dd($data['statement_info']); if ($data['statement_type'] == 1) {//下游 excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); } else {//上游 excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); } } }