🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
导入代码 ~~~ /* * 物业费导入 */ public function sanqi(){ set_time_limit(0);// $list = import_excel('excel/3.xls'); unset($list[1]); $successNum = 0; foreach ($list as $key => $val) { // print_r($val); exit; $data = []; $data['item_id'] = $this->item_id; $data['order_id'] = $val[0]; //订单 $data['user_name'] = $val[1]; //姓名 $data['room'] = $val[2]; //房号 $data['building_area'] = $val[3]; //面积 $data['start_time'] = $val[4]; //起止日期 $data['end_time'] = $val[5]; //起止日期 $data['total'] = $val[6]; //合计 $data['remark'] = $val[7]; //用户类型 $data['category'] = 1; Db::name('temp_managefee')->insertGetId($data); $successNum++; } return '成功导入'.$successNum.'条数据'; } ~~~ ~~~ // 美丽三期 public function jianmian(){ set_time_limit(0);// $list = import_excel('excel/3-.xls'); unset($list[1]); $successNum = 0; foreach ($list as $key => $val) { // print_r($val); exit; $data = []; $data['item_id'] = $this->item_id; $data['order_id'] = $val[0]; //订单 $data['user_name'] = $val[1]; //姓名 $data['room'] = $val[2]; //房号 $data['building_area'] = $val[3]; //面积 $data['start_time'] = $val[4]; //起止日期 $data['end_time'] = $val[5]; //起止日期 $data['jianmian'] = $val[6]; //合计 $data['remark'] = '减免'.$val[7]; //用户类型 $data['category'] = 0; //减免 Db::name('temp_managefee')->insertGetId($data); $successNum++; } echo '成功导入'.$successNum.'条数据'; exit; } ~~~ ~~~ public function duijie(){ set_time_limit(0);// $item_id = $this->item_id; $map = []; $worksheet = Db::name('temp_managefee')->where( $map )->order('id ASC')->select(); // Db::name('worksheet')->where( 'item_id','<>','' )->update(['item_id'=>3]); // print_r($worksheet); exit; // return json($worksheet); $successNum = 0; foreach ($worksheet as $key => $val) { $room = explode('-', $val['room']); $building_name = $room[0].'栋'.$room[1].'单元'; $room_number = $room[2]; //重置临时表 $data = []; $data['item_id'] = $item_id; $data['building_name'] = $building_name; $data['room_number'] = $room_number; $data['unit_price'] = 1.5; $data['unit'] = $room[1]; $data['months'] = get_month_num($val['start_time'],$val['end_time']); // 替换房号 把3A替换成4 // $room_number = preg_replace('/3A/i','4',$room_number); $data['building_id'] = Db::name('building')-> where( ['item_id'=>$item_id,'building_name'=>$data['building_name']] )->value('id'); $data['room_id'] = Db::name('room')-> where( ['item_id'=>$item_id,'building_name'=>$data['building_name'],'number'=>$data['room_number']] )->value('id'); if( empty($data['building_id']) || empty($data['room_id'])){ echo '对接失败,编号:'.$val['id'].',房号:'.$building_name.'-'.$room_number.'<br>'; continue; } Db::name('temp_managefee')->where( 'id',$val['id'] )->update($data); $successNum++; } return '对接成功'.$successNum.'条数据'; } ~~~ ~~~ /* * 物业费 入库 * 美丽四期 * 第四步 */ public function siqi_ruku(){ set_time_limit(0);// $item_id = $this->item_id; $map = []; $worksheet = Db::name('temp_managefee')->where( $map )->order('id ASC')->select(); // Db::name('worksheet')->where( 'item_id','<>','' )->update(['item_id'=>3]); $successNum = 0; $errorNum = 0; $nowTime = time(); foreach ($worksheet as $key => $val) { // 入库 $insert = []; $insert['item_id'] = $val['item_id']; $insert['building_id'] = $val['building_id']; $insert['room_id'] = $val['room_id']; $insert['room_number'] = $val['room_number']; // $insert['order_id'] = $val['order_id']; $insert['user_name'] = $val['user_name']; $insert['start_time'] = $val['start_time']; $insert['end_time'] = $val['end_time']; $insert['unit_price'] = $val['unit_price']; // $insert['building_area'] = $val['building_area']; // $insert['decorate'] = '否'; $insert['payable'] = $val['payable']; $insert['remark'] = $val['remark']; $insert['cost_type'] = 'managefee'; $insert['cost_explain'] = '物业费'; $insert['purpose'] = '否'; //空置 $insert['status'] = 1; //已付款 $insert['payment'] = '现金'; //默认现金全付款 $insert['pay_way'] = '导入'; $insert['admin_id'] = $this->admin_id; $insert['admin_name'] = $this->admin_name; $insert['pay_time'] = strtotime($val['start_time']); //时间戳 $insert['update_time'] = strtotime('2018-05-22'); //时间戳 $insert['create_time'] = strtotime('2018-05-22'); //时间戳 $insert['import_time'] = $nowTime; //时间戳 $insert['payable'] = get_cost_for_date($val['start_time'],$val['end_time'],$val['building_area'],$val['unit_price']); //时间戳 if($val['category']==1){ $insert['total'] = $val['total']; $insert['collected'] = $val['total']; $insert['uncollected'] = 0; $insert['months'] = $val['months']; $insert['deposit'] = 0; //押金转物业费 $insert['derate_num'] = 0; }else{ $insert['derate_num'] = $val['months']; //减免月数 $insert['derate_price'] = $val['jianmian']; //减免金额 $insert['months'] = 0; $insert['total'] = 0; $insert['collected'] = 0; $insert['uncollected'] = 0; } $id = Db::name('fee_manage')->insertGetId($insert); if($id){ $order_id = get_order_id_for_tableid($id); Db::name('fee_manage')->where( 'id',$id )->update(['order_id'=>$order_id]); $successNum++; }else{ } } $str = ''; $str .= '导入前:'.Db::name('fee_manage')->count().'条数据'; $str .= '<br>'; $str .= '成功导入'.$successNum.'条数据'; $str .= '<br>'; sleep(1); return $str .= '导入后:'.Db::name('fee_manage')->count().'条数据'; } ~~~