You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
400
hyhproject/admin/model/EctTarget.php
Executable file
400
hyhproject/admin/model/EctTarget.php
Executable file
@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
namespace wstmart\admin\model;
|
||||
|
||||
use think\Db;
|
||||
|
||||
use think\Loader;
|
||||
|
||||
/**
|
||||
|
||||
* ============================================================================
|
||||
|
||||
* 提现分类业务处理
|
||||
|
||||
*/
|
||||
|
||||
class EctTarget extends Base{
|
||||
|
||||
/**
|
||||
|
||||
* 分页
|
||||
|
||||
*/
|
||||
|
||||
public function pageQuery(){
|
||||
|
||||
$startDate = input('startDate');
|
||||
|
||||
$endDate = input('endDate');
|
||||
|
||||
$ectNo = input('ectNo');
|
||||
|
||||
$loginName = input('loginName');
|
||||
|
||||
$where = [];
|
||||
|
||||
if($ectNo!='')$where['ectNum'] = ['like','%'.$ectNo.'%'];
|
||||
|
||||
if($loginName!='')$where['b.loginName'] = ['like','%'.$loginName.'%'];
|
||||
|
||||
if($startDate && $endDate){
|
||||
|
||||
$where['a.createTime'] =['between',[strtotime($startDate.' 00:00:00'),strtotime($endDate.' 23:59:59')]];
|
||||
|
||||
}elseif($startDate){
|
||||
|
||||
$where['a.createTime'] = [">=",strtotime($startDate)];
|
||||
|
||||
}elseif($endDate){
|
||||
|
||||
$where['a.createTime'] = ["<=",strtotime($endDate)];
|
||||
|
||||
}
|
||||
|
||||
//mark by cheng 只显示超过一天的提现数据
|
||||
|
||||
$page = Db::name('user_ect_cash_log')->alias('a')
|
||||
|
||||
->join('users b','b.userId=a.userId','left')
|
||||
|
||||
->where($where)
|
||||
|
||||
->order('a.status asc,a.id desc')
|
||||
|
||||
->field('a.transactionId,fromAccount,toAccount,dataRemarks,a.createTime,ectNum,b.loginName,a.userId,a.status,a.id')
|
||||
|
||||
->paginate(input('limit/d'))->toArray();
|
||||
|
||||
if($loginName!=''){
|
||||
|
||||
foreach ($page['Rows'] as $key => $value) {
|
||||
|
||||
$page['Rows'][$key]['sumEct']=db('user_ect_cash_log')->where(['userId'=>$value['userId'],'status'=>1])->sum('ectNum');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
//根据ID获取提现详情
|
||||
|
||||
public function toHandle(){
|
||||
|
||||
$id=input('id');
|
||||
|
||||
$result=Db::name('user_ect_cash_log')->alias('a')
|
||||
|
||||
->join('users b','b.userId=a.userId','left')
|
||||
|
||||
->where('id',$id)
|
||||
|
||||
->order('a.createTime desc')
|
||||
|
||||
->field('a.transactionId,fromAccount,toAccount,dataRemarks,a.createTime,ectNum,b.loginName,a.userId,a.status,a.id')
|
||||
|
||||
->find();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
//对审核结果进行操作
|
||||
|
||||
public function ectTarget(){
|
||||
|
||||
$id=input('id');
|
||||
|
||||
$status=input('status');
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
try{
|
||||
|
||||
$result = db('user_ect_cash_log')->where('id',$id)->update(['status'=>$status]);
|
||||
|
||||
if(false !== $result){
|
||||
|
||||
Db::commit();
|
||||
|
||||
//标记删除购物车
|
||||
|
||||
return WSTReturn("修改成功", 1);
|
||||
|
||||
}
|
||||
|
||||
}catch (\Exception $e) {
|
||||
|
||||
Db::rollback();errLog($e);
|
||||
|
||||
}
|
||||
|
||||
return WSTReturn('修改失败',-1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 获取提现详情
|
||||
|
||||
*/
|
||||
|
||||
public function getById(){
|
||||
|
||||
$id = (int)input('id');
|
||||
|
||||
$rs = $this->get($id);
|
||||
|
||||
$user = [];
|
||||
|
||||
if($rs['targetType']==1){
|
||||
|
||||
$user = Db::name('shops')->alias('s')
|
||||
|
||||
->join('__USERS__ u','u.userId=s.userId')
|
||||
|
||||
->where('shopId',$rs['targetId'])
|
||||
|
||||
->field('s.shopId,u.loginName,s.shopName as userName')
|
||||
|
||||
->find();
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$user = Db::name('users')->where('userId',$rs['targetId'])->field('userId,loginName,userName')->find();
|
||||
|
||||
}
|
||||
|
||||
$rs['userName'] = $user['userName'];
|
||||
|
||||
$rs['loginName'] = $user['loginName'];
|
||||
|
||||
return $rs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 导出提现申请
|
||||
|
||||
*/
|
||||
|
||||
public function toExport(){
|
||||
|
||||
$name='ECT提现管理表';
|
||||
|
||||
$startDate = input('startDate');
|
||||
|
||||
$endDate = input('endDate');
|
||||
|
||||
$ectNo = input('ectNo');
|
||||
|
||||
$loginName = input('loginName');
|
||||
|
||||
$where = [];
|
||||
|
||||
if($ectNo!='')$where['ectNum'] = ['like','%'.$ectNo.'%'];
|
||||
|
||||
if($loginName!='')$where['b.loginName'] = ['like','%'.$loginName.'%'];
|
||||
|
||||
if($startDate && $endDate){
|
||||
|
||||
$where['a.createTime'] =['between',[strtotime($startDate.' 00:00:00'),strtotime($endDate.' 23:59:59')]];
|
||||
|
||||
}elseif($startDate){
|
||||
|
||||
$where['a.createTime'] = [">=",strtotime($startDate)];
|
||||
|
||||
}elseif($endDate){
|
||||
|
||||
$where['a.createTime'] = ["<=",strtotime($endDate)];
|
||||
|
||||
}
|
||||
|
||||
//mark by cheng 只显示超过一天的提现数据
|
||||
|
||||
$page = Db::name('user_ect_cash_log')->alias('a')
|
||||
|
||||
->join('users b','b.userId=a.userId','left')
|
||||
|
||||
->where($where)
|
||||
|
||||
->order('a.createTime desc')
|
||||
|
||||
->field('a.transactionId,fromAccount,toAccount,dataRemarks,a.createTime,from_unixtime(a.createTime) dateTime, ectNum,b.loginName,a.status')
|
||||
|
||||
->select();
|
||||
|
||||
|
||||
|
||||
Loader::import('phpexcel.PHPExcel.IOFactory');
|
||||
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
|
||||
// 设置excel文档的属性
|
||||
|
||||
$objPHPExcel->getProperties()->setCreator("WSTMart")//创建人
|
||||
|
||||
->setLastModifiedBy("WSTMart")//最后修改人
|
||||
|
||||
->setTitle($name)//标题
|
||||
|
||||
->setSubject($name)//题目
|
||||
|
||||
->setDescription($name)//描述
|
||||
|
||||
->setKeywords("提现")//关键字
|
||||
|
||||
->setCategory("Test result file");//种类
|
||||
|
||||
|
||||
|
||||
// 开始操作excel表
|
||||
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// 设置工作薄名称
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setTitle(iconv('gbk', 'utf-8', 'Sheet'));
|
||||
|
||||
// 设置默认字体和大小
|
||||
|
||||
$objPHPExcel->getDefaultStyle()->getFont()->setName(iconv('gbk', 'utf-8', ''));
|
||||
|
||||
$objPHPExcel->getDefaultStyle()->getFont()->setSize(11);
|
||||
|
||||
$styleArray = array(
|
||||
|
||||
'font' => array(
|
||||
|
||||
'bold' => true,
|
||||
|
||||
'color'=>array(
|
||||
|
||||
'argb' => 'ffffffff',
|
||||
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
'borders' => array (
|
||||
|
||||
'outline' => array (
|
||||
|
||||
'style' => \PHPExcel_Style_Border::BORDER_THIN, //设置border样式
|
||||
|
||||
'color' => array ('argb' => 'FF000000'), //设置border颜色
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
//设置宽
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(12);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(30);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(12);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getFill()->getStartColor()->setARGB('333399');
|
||||
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'ECT交易ID')
|
||||
|
||||
->setCellValue('B1', '会员名称')
|
||||
|
||||
->setCellValue('C1', 'ECT发送方')
|
||||
|
||||
->setCellValue('D1', 'ECT接收方')
|
||||
|
||||
->setCellValue('E1', '备注')
|
||||
|
||||
->setCellValue('F1', 'ECT提现数量')
|
||||
|
||||
->setCellValue('G1', '创建时间')
|
||||
|
||||
->setCellValue('H1', '状态(0.未审核1.同意2.拒绝)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
|
||||
|
||||
|
||||
|
||||
for ($row = 0; $row < count($page); $row++){
|
||||
|
||||
$i = $row+2;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A'.$i, $page[$row]['transactionId'])
|
||||
|
||||
->setCellValue('B'.$i, $page[$row]['loginName'])
|
||||
|
||||
->setCellValue('C'.$i, $page[$row]['fromAccount'])
|
||||
|
||||
->setCellValue('D'.$i, $page[$row]['toAccount'])
|
||||
|
||||
->setCellValue('E'.$i, $page[$row]['dataRemarks'])
|
||||
|
||||
->setCellValue('F'.$i, $page[$row]['ectNum'])
|
||||
|
||||
->setCellValue('G'.$i, $page[$row]['dateTime'])
|
||||
|
||||
->setCellValue('H'.$i, $page[$row]['status']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//输出EXCEL格式
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
|
||||
// 从浏览器直接输出$filename
|
||||
|
||||
header('Content-Type:application/csv;charset=UTF-8');
|
||||
|
||||
header("Pragma: public");
|
||||
|
||||
header("Expires: 0");
|
||||
|
||||
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
|
||||
|
||||
header("Content-Type:application/force-download");
|
||||
|
||||
header("Content-Type:application/vnd.ms-excel;");
|
||||
|
||||
header("Content-Type:application/octet-stream");
|
||||
|
||||
header("Content-Type:application/download");
|
||||
|
||||
header('Content-Disposition: attachment;filename="'.$name.'.xls"');
|
||||
|
||||
header("Content-Transfer-Encoding:binary");
|
||||
|
||||
$objWriter->save('php://output');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user