Yii::$app->request->post('date_type', ''),//时间类型 'start_date' => Yii::$app->request->post('start_date', ''),//开始时间 'end_date' => Yii::$app->request->post('end_date', ''),//接收时间 'org_id' => Yii::$app->request->post('org_id', ''),//渠道商ID 'settlement_status' => Yii::$app->request->post('settlement_status', 0),//结算状态值 'prod_type' => Yii::$app->request->post('prod_type', 0),//订单产品类型 'more_search' => Yii::$app->request->post('more_search', ''),//更多查询条件 'current_page' => Yii::$app->request->post('current_page', '1'),//当前页 'page_size' => Yii::$app->request->post('page_size', '10'),//每页展示条数 ); return $param; } /** * Des:获取参数 * Name: getParam * @return array * @author 倪宗锋 */ public function getGetParam() { $param = array( 'date_type' => Yii::$app->request->get('date_type', ''),//时间类型 'start_date' => Yii::$app->request->get('start_date', ''),//开始时间 'end_date' => Yii::$app->request->get('end_date', ''),//接收时间 'org_id' => Yii::$app->request->get('org_id', ''),//渠道商ID 'settlement_status' => Yii::$app->request->get('settlement_status', 0),//结算状态值 'prod_type' => Yii::$app->request->get('prod_type', 0),//订单产品类型 'more_search' => Yii::$app->request->get('more_search', ''),//更多查询条件 'current_page' => Yii::$app->request->get('current_page', '1'),//当前页 'page_size' => Yii::$app->request->get('page_size', '10'),//每页展示条数 ); return $param; } public static function to_excel($file_name, $title, $fin_list) { ob_clean(); $fileName = $file_name . '.csv'; $fileName = iconv("utf-8", "gb2312", $fileName); header("Content-type:text/csv"); header("Content-Disposition:attachment;filename=" . $fileName); header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); header('Expires:0'); header('Pragma:public'); $data = ''; foreach ($fin_list as $key => $val) { if ($key == 0) { $data .= implode(',', $title) . "\n"; } $data .= '"' . implode('","', array_values($val)) . "\"\n"; } $data = chr(0xEF) . chr(0xBB) . chr(0xBF) . $data; echo $data; return ''; } /** * Function Description:管理页面查询条件 * Function Name: getWhere * @param $param * @return array * @author 倪宗锋 */ public function getWhere($param) { #region 获取用户信息 //获取cookies $cookies = Yii::$app->request->cookies; //账号权限 $user_id = $cookies->getValue('user_id'); $user_info = BaseUser::find() ->select('main_corp_id') ->where(['id' => $user_id, 'cancel_flag' => 0]) ->asArray() ->one(); $main_corp_id = $user_info['main_corp_id']; if ($main_corp_id == 0) { $main_corp_id = 1; } #endregion /**==========拼接订单的查询条件============**/ //$order_where = " a.main_corp_id={$main_corp_id} and a.CANCEL_FLAG=0 and (a.order_status in(146,147,314) or a.CHANNEL_ORDER_STATUS in (551,554,553)) and a.ORDER_PROD_TYPE not in (81,82,38,369) and a.PARENT_ORDER_ID = 0 ";//获取所有已完成的有效的主订单 //需要新增代售线路成本 $order_where = " a.main_corp_id={$main_corp_id} and a.CANCEL_FLAG=0 and (a.order_status in(146,147,314) ) and ((a.ORDER_PROD_TYPE not in (81,82,38,369)) or (a.ORDER_PROD_TYPE in (81,82,38,369) and a.main_corp_id!=a.source_main_corp_id)) and a.PARENT_ORDER_ID = 0 ";//获取所有已完成的有效的主订单 //结算时间 if ($param['date_type'] == '2' && $param['start_date']) { $order_where .= " and (SELECT if(a.ORDER_PROD_TYPE in (25,26),a.PROD_END_STATION_DATE,MAX(RUN_DATE)) from order_main WHERE a.ORDER_ID = PARENT_ORDER_ID) >= '{$param['start_date']}'";//大于等于起始日期 } if ($param['date_type'] == '2' && $param['end_date']) { $order_where .= " and (SELECT if(a.ORDER_PROD_TYPE in (25,26),a.PROD_END_STATION_DATE,MAX(RUN_DATE)) from order_main WHERE a.ORDER_ID = PARENT_ORDER_ID) < date_add('{$param['end_date']}', INTERVAL 1 day)";//小于日期 } if ($param['date_type'] == '3' && $param['start_date']) { $order_where .= " and (SELECT if(a.ORDER_PROD_TYPE in (25,26),a.PROD_START_STATION_DATE,MAX(RUN_DATE)) from order_main WHERE a.ORDER_ID = PARENT_ORDER_ID) >= '{$param['start_date']}'";//大于等于起始日期 } if ($param['date_type'] == '3' && $param['end_date']) { $order_where .= " and (SELECT if(a.ORDER_PROD_TYPE in (25,26),a.PROD_START_STATION_DATE,MAX(RUN_DATE)) from order_main WHERE a.ORDER_ID = PARENT_ORDER_ID) < date_add('{$param['end_date']}', INTERVAL 1 day)";//小于日期 } //收款状态 if ($param['settlement_status']) { $order_where .= " and IFNULL(b.payment_status,1) = {$param['settlement_status']}"; } //预定时间 if ($param['date_type'] == '1' && $param['start_date']) { $order_where .= " and a.CREATE_TIME >= DATE_FORMAT('{$param['start_date']}' ,'%Y-%m-%d %H:%i:%s')";//大于等于起始日期 } if ($param['date_type'] == '1' && $param['end_date']) { $order_where .= " and a.CREATE_TIME < date_add(DATE_FORMAT('{$param['end_date']}' ,'%Y-%m-%d %H:%i:%s'), INTERVAL 1 day)";//小于结束日期的第二天凌晨 } //渠道商ID if ($param['org_id']) { $order_where .= " and a.PROD_TOP_ORG_ID = '{$param['org_id']}'"; } //订单产品类型 if ($param['prod_type']) { $order_where .= " and a.ORDER_PROD_TYPE in ({$param['prod_type']})"; } //更多查询 if ($param['more_search']) { $order_where .= " and (a.ORDER_ID like '%{$param['more_search']}%' or a.CUSTOMER_MOBILE like '%{$param['more_search']}%' or a.CUSTOMER_NAME like '%{$param['more_search']}%' or a.OUTSIDE_ORDER_NO like '%{$param['more_search']}%' )"; } /**==========拼接巴士bus的查询条件============**/ $bus_where = " a.TOTAL_COST_PRICE > 0 and a.CANCEL_FLAG=0 and d.main_corp_id={$main_corp_id} ";//获取所有巴士 //结算-预定时间 巴士的出发时间即预定时间 if ($param['start_date']) { $bus_where .= " and a.START_TIME >= '{$param['start_date']}'";//大于等于起始日期 } if ($param['end_date']) { $bus_where .= " and a.START_TIME < date_add('{$param['end_date']}', INTERVAL 1 day)";//小于日期 } //收款状态 if ($param['settlement_status']) { $bus_where .= " and IFNULL(b.payment_status,1) = {$param['settlement_status']}"; } //渠道商ID if ($param['org_id']) { $bus_where .= " and a.BUS_ORG_ID = '{$param['org_id']}'"; } //订单产品类型 if (!empty($param['prod_type']) && $param['prod_type'] != '81,82,38,369') {//不是车的则不统计 $bus_where .= " and a.ID = 0 "; } //更多查询 if ($param['more_search']) { $bus_where .= " and (a.id like '%{$param['more_search']}%' or d.LINE_NAME like '%{$param['more_search']}%')"; } return array('order_where' => $order_where, 'bus_where' => $bus_where, 'param' => $param); } /** * Des:获取总记录数 * Name: getTotal * @param $getWhere * @return mixed * @author 倪宗锋 */ public function getTotal($getWhere) { /**==========获取记录数和总金额============**/ $sql_1 = " SELECT SUM(x.cnt) 'cnt',FORMAT(SUM(x.base_price),2) 'total_price',SUM(x.reparations_price) 'reparations_price' FROM ( SELECT COUNT(1) cnt,SUM(a.TOTAL_COST_PRICE) 'base_price', SUM( (SELECT IFNULL(SUM(v.reparations),0) from order_main u JOIN order_finance_reparations v on u.order_id = v.order_id WHERE u.RUN_ID = a.RUN_ID and u.RUN_BUS_ORDER_ID = a.BUS_ORDER_ID ) ) as 'reparations_price' from bus_cost a LEFT JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID WHERE {$getWhere['bus_where']} union ALL SELECT COUNT(1) cnt,SUM(a.BASE_PRICE) 'base_price', IFNULL((SELECT reparations from order_finance_reparations WHERE order_id=a.ORDER_ID),0) 'reparations_price' from order_main a LEFT JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 WHERE {$getWhere['order_where']} ) x "; $getTotal = \Yii::$app->getDb()->createCommand($sql_1)->queryAll(); if (empty($getTotal['0']['cnt'])) { $getTotal[0]['cnt'] = 0; $getTotal[0]['total_price'] = 0; $getTotal[0]['total_commission'] = 0; $getTotal[0]['reparations_price'] = 0; } $data['page']['total_count'] = $getTotal[0]['cnt']; $data['page']['total_page'] = (string)ceil($getTotal[0]['cnt'] / $getWhere['param']['page_size']); $data['sum_info'] = $getTotal[0]; return $data; } /** * Des:获取列表记录 * Name: getList * @param $getWhere * @return array * @author 倪宗锋 */ public function getList($getWhere, $excel_flag = 0) { /**==========获取列表============**/ $offset = ($getWhere['param']['current_page'] - 1) * $getWhere['param']['page_size']; //非0则为导出 if ($excel_flag == 0) { $limit = "LIMIT {$getWhere['param']['page_size']} offset $offset"; } else { $limit = ''; } $sql_2 = " SELECT a.ID 'order_id','-' as 'outside_order_no',a.START_TIME 'create_time', d.LINE_NAME 'parent_prod_name','' as 'order_prod_type', ifnull((SELECT SUPPLIER_NAME FROM base_supplier WHERE a.BUS_ORG_ID = ID),'-') 'supplier_name' , a.TOTAL_COST_PRICE 'base_price', (SELECT IFNULL(SUM(v.reparations),0) from order_main u JOIN order_finance_reparations v on u.order_id = v.order_id WHERE u.RUN_ID = a.RUN_ID and u.RUN_BUS_ORDER_ID = a.BUS_ORDER_ID ) as 'reparations_price', IFNULL(b.payment_status,1) 'status', CASE IFNULL(b.payment_status,1) WHEN 1 THEN '待结算' WHEN 2 THEN '已关账' WHEN 3 THEN '结算中' WHEN 4 THEN '已结算' ELSE '待结算' END AS 'status_des' , a.START_TIME as 'run_date', '巴士' as 'prod_type_des', '-' as 'order_description', '-' as 'prodNum', '-' as 'prodName' from bus_cost a LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID LEFT JOIN order_finance_status b on a.ID = b.order_id and b.type=2 WHERE {$getWhere['bus_where']} union ALL SELECT a.ORDER_ID 'order_id',a.OUTSIDE_ORDER_NO,a.CREATE_TIME 'create_time', (SELECT CONCAT(PARENT_PROD_NAME, '
',PROD_START_STATION_RES_NAME,' - ',PROD_END_STATION_RES_NAME) from order_main WHERE PARENT_ORDER_ID = a.ORDER_ID LIMIT 1) 'parent_prod_name', a.ORDER_PROD_TYPE 'order_prod_type', ifnull((SELECT SUPPLIER_NAME from base_supplier WHERE ID = a.PROD_TOP_ORG_ID),'-') 'supplier_name', a.BASE_PRICE 'base_price', IFNULL((SELECT reparations from order_finance_reparations WHERE order_id=a.ORDER_ID),0) 'reparations_price', IFNULL(b.payment_status,1) 'status', CASE IFNULL(b.payment_status,1) WHEN 1 THEN '待结算' WHEN 2 THEN '已关账' WHEN 3 THEN '结算中' WHEN 4 THEN '已结算' ELSE '待结算' END AS 'status_des' , (SELECT MAX(RUN_DATE) from order_main WHERE a.ORDER_ID = PARENT_ORDER_ID) 'run_date', CASE WHEN a.ORDER_PROD_TYPE in (25,26) THEN '酒店' WHEN a.ORDER_PROD_TYPE in (81,82,38,369) THEN '车票' WHEN a.ORDER_PROD_TYPE in (258,282,311) THEN '门票' else '-' END as 'prod_type_des', a.ORDER_DESCRIPTION 'order_description', '-' as 'prodNum', '-' as 'prodName' from order_main a LEFT JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 WHERE {$getWhere['order_where']} {$limit}; "; $list = \Yii::$app->getDb()->createCommand($sql_2)->queryAll(); /**==========设置返回值============**/ if (empty($list) == false) { foreach ($list as $key => $value) { if (empty($value['order_description'])) { continue; } $list[$key]['prodNum'] = 0; $list[$key]['prodName'] = '-'; $scripTionArr = explode('|', $value['order_description']); foreach ($scripTionArr as $vl) { if (empty($vl)) { continue; } $vls = explode(',', $vl); if (empty($vls['2'])) { $list[$key]['prodNum'] = $vls[0]; } else { $list[$key]['prodNum'] = $vls['2']; $list[$key]['prodName'] = $vls['0']; } } unset($list[$key]['order_description']); } } return $list; } /** * Des:校验是否可以关账 * Name: checkClosesAmount * @param $getWhere * @return bool * @author 倪宗锋 */ public function checkClosesAmount($getWhere) { /**============判断是否可以关账===================**/ $sql_1 = " SELECT SUM(x.cnt) cnt FROM ( SELECT COUNT(1) cnt from bus_cost a LEFT JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID WHERE {$getWhere['bus_where']} and IFNULL(b.payment_status,1) != 1 union ALL SELECT COUNT(1) cnt from order_main a LEFT JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 WHERE {$getWhere['order_where']} and IFNULL(b.payment_status,1) != 1 ) x "; $getTotal = \Yii::$app->getDb()->createCommand($sql_1)->queryOne(); if ($getTotal['cnt'] >= 1) { return false; } return true; } /** * Function Description:关账 * Function Name: closeByOrderId * @param $order_id * * @return bool * @throws Exception * * @author 李健 */ public function closeByOrderId($order_id) { $transaction = \Yii::$app->db->beginTransaction(); try{ //没有在状态表的数据 插入到状态表 $sql = "select order_id from order_finance_status where order_id in (".$order_id.")"; $res = \Yii::$app->getDb()->createCommand($sql)->queryAll(); $str = ''; $arr = explode(',',trim($order_id,',')); foreach ($res as $v){ if(!in_array($v['order_id'],$arr)){ $str .= $v['order_id'].' ,'; } } $str = trim($str,','); if(!empty($str)){ $sql1 = " INSERT into order_finance_status(main_corp_id,order_id,update_time, type) SELECT x.main_corp_id,x.order_id,NOW(),1 from ( SELECT a.ORDER_ID 'order_id',a.main_corp_id 'main_corp_id' from order_main a where a.order_id in (".$str.") )x "; $res1 = \Yii::$app->getDb()->createCommand($sql1)->execute(); if (!$res1) { $transaction->rollBack(); return false; } } /**==========更新已有状态表记录=============**/ $sql2 = "UPDATE order_finance_status SET payment_status = 2 WHERE order_id in (".$order_id.") and payment_status=1"; $res2 = Yii::$app->getDb()->createCommand($sql2)->execute(); if (!$res2) { $transaction->rollBack(); return false; } $transaction->commit(); return true; }catch(Exception $e) { $transaction->rollBack(); return false; } } /** * Des:执行关账操作 * Name: closesAmount * @param $getWhere * @return bool * @author 倪宗锋 */ public function closesAmount($getWhere) { $transaction = \Yii::$app->db->beginTransaction(); try { //没有在状态表的数据 插入到状态表 $sql1 = " INSERT into order_finance_status(main_corp_id,order_id, update_time, type) SELECT {$getWhere["main_corp_id"]},z.* FROM ( SELECT a.ID,NOW(),2 from bus_cost a LEFT JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID WHERE {$getWhere['bus_where']} and b.payment_status is null union ALL SELECT a.ORDER_ID,NOW(),1 from order_main a LEFT JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 WHERE {$getWhere['order_where']} and b.payment_status is null and a.CANCEL_FLAG=0 ) z "; $flag1 = \Yii::$app->getDb()->createCommand($sql1)->execute(); // if (!$flag1) { // $transaction->rollBack(); // return false; // } /**==========更新已有状态表记录=============**/ $sql2 = " update order_main a JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 set b.payment_status = 2 WHERE {$getWhere['order_where']}; "; $sql3 = "update bus_cost a JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID SET b.payment_status = 2 WHERE {$getWhere['bus_where']}; "; $flag2 = \Yii::$app->getDb()->createCommand($sql2)->execute(); $flag3 = \Yii::$app->getDb()->createCommand($sql3)->execute(); if (!$flag3 && !$flag2 && !$flag1) { $transaction->rollBack(); return false; } $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); return false; } return true; } /** * Des:检测是否所有记录都是以关账状态 * Name: checkIsAllCloses * @param $getWhere * @return bool * @author 倪宗锋 */ public function checkIsAllCloses($getWhere) { /**============判断是否可以生成对账单===================**/ $sql_1 = " SELECT SUM(x.cnt) cnt FROM ( SELECT COUNT(1) cnt from bus_cost a LEFT JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID WHERE {$getWhere['bus_where']} and IFNULL(b.payment_status,1) != 2 union ALL SELECT COUNT(1) cnt from order_main a LEFT JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 WHERE {$getWhere['order_where']} and IFNULL(b.payment_status,1) != 2 ) x "; $getTotal = \Yii::$app->getDb()->createCommand($sql_1)->queryOne(); if ($getTotal['cnt'] >= 1) { return false; } return true; } /** * Des:生成对账单 * Name: addBalance * @param $getWhere * @return bool * @author 倪宗锋 */ public function addBalance($getWhere) { $transaction = \Yii::$app->db->beginTransaction(); try { $time = microtime(true) * 10000; $financeBalance = new OrderFinanceBalanceAccount(); $flag = $financeBalance->addBalanceForPayment($getWhere, $time);//插入对账单记录 if (!$flag) { $transaction->rollBack(); return false; } //对账单生成后修改订单对账状态并关联对账单 $financeStatus = new OrderFinanceStatus(); $flag1 = $financeStatus->setStatusForAddBalanceForPayment($getWhere, $time); if (!$flag1) { $transaction->rollBack(); return false; } $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); return false; } return true; } /** * Function Description:生成对账单 * Function Name: addBalanceByOrderId * @param $order_id * @param $start_date * @param $end_date * @param $main_corp_id * * @return bool * @throws Exception * * @author 李健 */ public function addBalanceByOrderId($order_id,$start_date,$end_date,$main_corp_id) { $transaction = \Yii::$app->db->beginTransaction(); try { $time = microtime(true) * 10000; $financeBalance = new OrderFinanceBalanceAccount(); $flag = $financeBalance->addBalanceForPayment2($order_id,$start_date,$end_date,$main_corp_id, $time);//插入对账单记录 if (!$flag) { $transaction->rollBack(); return false; } //对账单生成后修改订单对账状态并关联对账单 $financeStatus = new OrderFinanceStatus(); $flag1 = $financeStatus->setStatusForAddBalanceForPayment2($order_id, $time); if (!$flag1) { $transaction->rollBack(); return false; } $transaction->commit(); return true; } catch (Exception $e) { $transaction->rollBack(); return false; } } /** * Des:取消关账 * Name: cancelCloses * @param $getWhere * @return bool * @author 倪宗锋 */ public function cancelCloses($getWhere) { $sql = " update order_main a JOIN order_finance_status b ON a.ORDER_ID = b.order_id and b.type=1 set b.payment_status = 1 WHERE {$getWhere['order_where']}; "; $sql1 = "update bus_cost a JOIN order_finance_status b on a.ID = b.order_id and b.type=2 LEFT JOIN opera_line d ON a.LINE_ID = d.LINE_ID SET b.payment_status = 1 WHERE {$getWhere['bus_where']}"; $flag = \Yii::$app->getDb()->createCommand($sql)->execute(); $flag1 = \Yii::$app->getDb()->createCommand($sql1)->execute(); if (!$flag && !$flag1) { return false; } return true; } /** * Function Description:取消关账 * Function Name: cancelByOrderId * @param $order_id * * @return bool * @throws Exception * * @author 李健 */ public function cancelByOrderId($order_id) { $sql = "UPDATE order_finance_status SET payment_status = 1 WHERE order_id in (".$order_id.") and payment_status=2"; $res = Yii::$app->getDb()->createCommand($sql)->execute(); if(!$res){ return false; } return true; } /** * Des: 获取对账单列表 * Name: getBalance * @param $param * @return bool * @author 倪宗锋 */ public function getBalance($param) { $where = array(); $where[] = ' type = 1 '; if (!empty($param['org_id'])) { $where[] = " org_id = {$param['org_id']} "; } if (!empty($param['batch_id'])) { $where[] = " batch_id like '%{$param['batch_id']}%' "; } if (!empty($param['status'])) { $where[] = " status = {$param['status']} "; } if (!empty($param['main_corp_id'])) { $where[] = " main_corp_id = {$param['main_corp_id']} "; } $whereStr = ''; if (count($where)) { $whereStr .= implode(' and ', $where); } /**============第一页时返回总记录数和总页数==============**/ $sql_1 = "SELECT count(1) cnt FROM order_finance_balance_account WHERE $whereStr "; $getTotal = Yii::$app->getDb()->createCommand($sql_1)->queryOne(); $data['page']['total_count'] = $getTotal['cnt']; $data['page']['total_page'] = (string)ceil($getTotal['cnt'] / $param['page_size']); /**============获取分页列表数据==============**/ $offset = ($param['current_page'] - 1) * $param['page_size']; $sql_2 = "SELECT id,org_id,org_name,price,commission_price,reparations_price,date,start_date,end_date, account_bank,account_num,account_name,sett_frequency,batch_id,remark, CASE status WHEN 1 THEN '待核对' WHEN 2 THEN '待结算' WHEN 3 THEN '已结算' WHEN 4 THEN '已取消' ELSE 'error' END as 'status_des', status from order_finance_balance_account WHERE $whereStr ORDER BY id DESC LIMIT {$param['page_size']} OFFSET {$offset}"; $list = Yii::$app->getDb()->createCommand($sql_2)->queryAll(); $data['order_list'] = $list; return $data; } /** * Des:校验对账单的状态 * Name: checkBalanceStatus * @param $id * @param $status * @return bool * @author 倪宗锋 */ public function checkBalanceStatus($id, $status) { $sql = "SELECT `status` from order_finance_balance_account WHERE id = $id"; $info = Yii::$app->getDb()->createCommand($sql)->queryOne(); if (empty($info['status']) || !in_array($info['status'], $status)) { return false; } return true; } /** * Des:取消对账单 * Name: cancelBalance * @param $id * @return bool * @author 倪宗锋 */ public function cancelBalance($id) { //更改状态 $sql = " update order_finance_balance_account a join order_finance_status b on a.batch_id=b.payment_batch_id set a.`status` =4,b.payment_status = 2 WHERE a.`status` in(1) and a.id = $id "; $flag = Yii::$app->getDb()->createCommand($sql)->execute(); if (!$flag) { return false; } else { return true; } } /** * Des:修改对账单状态 * Name: confirmedBalance * @param $id * @return bool * @author 倪宗锋 */ public function confirmedBalance($id) { $financeAccount = new OrderFinanceBalanceAccount(); return $financeAccount->editStatus($id); } /** * Des:确认对账 * Name: balancing * @param $id * @return bool * @author 倪宗锋 */ public function balancing($id) { //更改状态 //更改状态 $sql = " update order_finance_balance_account a join order_finance_status b on a.batch_id=b.payment_batch_id set a.`status` =3,b.payment_status =4 WHERE a.`status` in(2) and a.id = $id "; $flag = Yii::$app->getDb()->createCommand($sql)->execute(); if (!$flag) { return false; } else { return true; } } /** * Des:获取对账单详情 * Name: getAccountInfo * @param $id * @return array|bool * @author 倪宗锋 */ public function getAccountInfo($id) { $financeAccount = new OrderFinanceBalanceAccount(); $info = $financeAccount->getInfoById($id);//获取详情 if (empty($info['id'])) { return false; } return $info; } /** * Des:获取导出excel数据 * Name: getListForExcel * @param $info * @return array * @author 倪宗锋 */ public function getListForExcel($info) { $financeAccount = new OrderFinanceBalanceAccount(); $getList = $financeAccount->getExcelForPayment($info); return $getList; } /** * Function Description:获取分页数组 * Function Name: getPage * * @param int $total_row 总条数 * @param int $page_size 每页条数 * @param int $current_page 当前页 * * @return array * * @author 张帅 */ public function getPage($total_row, $page_size, $current_page) { $total_page = ceil($total_row / $page_size); if ($total_page <= 1) { $page_arr = []; return $page_arr; } #region 页首 $page_arr = ['首页', '<上一页', 1]; #endregion #region 页前 if ($current_page <= 5) { for ($i = 2; $i <= $current_page; $i++) { $page_arr[] = $i; } } else { if ($total_page > 6) { $page_arr[] = '...'; } if ($total_page - $current_page <= 2) { for ($i = $total_page - 4; $i <= $current_page; $i++) { $page_arr[] = $i; } } else { $page_arr[] = $current_page - 2; $page_arr[] = $current_page - 1; $page_arr[] = $current_page; } } #endregion #region 页后 if ($total_page - $current_page <= 4) { for ($i = $current_page + 1; $i < $total_page; $i++) { $page_arr[] = $i; } } else { if ($current_page >= 3) { $page_arr[] = $current_page + 1; $page_arr[] = $current_page + 2; if ($total_page > 6) { $page_arr[] = '...'; } } else { for ($i = $current_page + 1; $i <= 5; $i++) { $page_arr[] = $i; } if ($total_page > 6) { $page_arr[] = '...'; } } } #endregion #region 页尾 if ($current_page != $total_page) { $page_arr[] = $total_page; } $page_arr[] = '下一页>'; $page_arr[] = '末页'; #endregion return $page_arr; } /** * Function Description:得到结算状态 * Function Name: getStatus * @param $order_id * * @return array|false * @throws Exception * * @author 李健 */ public function getStatus($order_id) { $order_finance_status = new OrderFinanceStatus(); return $order_finance_status->getStatus($order_id); } /** * Function Description:修改账单备注 * Function Name: changeRemark * @param $account_id * @param $remark * * @return array * * @author 娄梦宁 */ public function changeRemark($account_id,$remark) { if($account_id==0){ return [ 'code'=>1, 'info'=>'参数错误', ]; } $order_finance_balance_account=new OrderFinanceBalanceAccount(); $order_finance_balance_account::updateAll(['remark'=>$remark],['id'=>$account_id]); return [ 'code'=>0, 'info'=>'修改成功' ]; } }