674 行
23 KiB
PHP
可执行文件
674 行
23 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
|
||
use Common\Model\ImageGalleryModel;
|
||
use Common\Model\PayOrderModel;
|
||
use Common\Model\RetailFranchiseeBillModel;
|
||
use Common\Model\RetailFranchiseeModel;
|
||
use Common\Model\StoreModel;
|
||
use Think\Controller;
|
||
|
||
//[1.9.2]
|
||
|
||
/**
|
||
* 加盟店结算管理
|
||
* Class FranchiseDealController
|
||
* @package Retail\Controller
|
||
*/
|
||
class FranchiseDealController extends BaseController
|
||
{
|
||
/**
|
||
* 加盟店结算管理
|
||
*/
|
||
public function index()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 商户结算账户设置
|
||
*/
|
||
public function accountSetting()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 门店收入管理
|
||
*/
|
||
public function indexMoney()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 申请平账
|
||
*/
|
||
public function reconciliation()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 提现详情、平账详情、提现审核、平账审核
|
||
*/
|
||
public function operatingReceipt()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 商户打款提交页面
|
||
*/
|
||
public function makeMoney()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 营业收款页面详情
|
||
*/
|
||
public function order()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
*列表数据(门店商户端通用)
|
||
*/
|
||
public function getList()
|
||
{
|
||
$user_type = I('post.user_type'); //请求数据类型 1商户 2门店
|
||
if (!in_array($user_type, array('1', '2'))) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '访问有误';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
// 页码限制
|
||
$page = I('post.page') ? I('post.page') : 1;
|
||
$limit = I('post.limit') ? I('post.limit') : 10;
|
||
|
||
if ($user_type == 1) {
|
||
// 门店搜索
|
||
$store_id = I('post.store_id');
|
||
if (!empty($store_id)) {
|
||
$map['store_id'] = $store_id;
|
||
}
|
||
} else {
|
||
$map['store_id'] = $this->store_id;
|
||
}
|
||
|
||
// 结算周期
|
||
$type = I('post.type');
|
||
if (!empty($type)) {
|
||
$map['type'] = $type;
|
||
}
|
||
// 结算方式
|
||
$data_type = I('post.data_type');
|
||
if (!empty($data_type)) {
|
||
$map['data_type'] = $data_type;
|
||
}
|
||
// 审核状态
|
||
$status = I('post.status');
|
||
if (!empty($status)) {
|
||
$map['status'] = $status;
|
||
}
|
||
// 申请时间
|
||
$start_time = I('post.start_time');
|
||
$end_time = I('post.end_time');
|
||
if (!empty($start_time) && !empty($end_time)) {
|
||
$start_time = strtotime($start_time);
|
||
$end_time = strtotime($end_time);
|
||
$map['add_time'] = array('between', array($start_time, $end_time));
|
||
}
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$FranchiseeBillModel = new RetailFranchiseeBillModel();
|
||
$order = $FranchiseeBillModel->getSelect($map, '*', 'id desc', "{$page},{$limit}");
|
||
$count = $FranchiseeBillModel->getCount($map);
|
||
if ($order) {
|
||
$status_list = array(
|
||
'1' => '待提现',
|
||
'2' => '提现待审核',
|
||
'3' => '提现驳回',
|
||
'4' => '待打款',
|
||
'5' => '已打款',
|
||
'6' => '平账待审核',
|
||
'7' => '平账驳回',
|
||
'8' => '已平账',
|
||
'9' => '待平账',
|
||
'10' => '无需操作',
|
||
);
|
||
$ImageGalleryModel = new ImageGalleryModel();
|
||
$StoreModel = new StoreModel();
|
||
$storeArr = array();
|
||
foreach ($order as &$val) {
|
||
if (empty($storeArr[$val['store_id']])) {
|
||
$storeArr[$val['store_id']] = $StoreModel->getFindField(array('id' => $val['store_id']), 'storetag');
|
||
}
|
||
$val['store_name'] = $storeArr[$val['store_id']];
|
||
$val['status_remark'] = $status_list[$val['status']];
|
||
if (!empty($val['apply_time'])) {
|
||
$val['apply_time'] = date('Y.m.d H:i:s', $val['apply_time']);
|
||
} else {
|
||
$val['apply_time'] = '--';
|
||
}
|
||
if (!empty($val['reject_time'])) {
|
||
$val['reject_time'] = date('Y.m.d H:i:s', $val['reject_time']);
|
||
}
|
||
$val['add_time'] = date('Y.m.d H:i:s', $val['add_time']);
|
||
$val['type_remark'] = $val['data_type'] == 1 ? '提现' : '平账';
|
||
if ($val['reject_img_id']) {
|
||
$val['reject_img'] = $ImageGalleryModel->getImagePath($val['reject_img_id']);
|
||
}
|
||
}
|
||
$result['status'] = 1;
|
||
$result['msg'] = '查询成功';
|
||
$result['data'] = $order;
|
||
} else {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '暂无数据';
|
||
$result['data'] = array();
|
||
}
|
||
$result['pages'] = array(
|
||
'total_num' => $count,
|
||
'page' => $page,
|
||
'limit' => $limit,
|
||
);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 获取统计数据
|
||
*/
|
||
public function getSumTotal()
|
||
{
|
||
$user_type = I('post.user_type'); //1商户 2门店
|
||
if ($user_type == 2 && empty($this->store_id)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '操作有误';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
if ($user_type == 2) {
|
||
$map['store_id'] = $this->store_id;
|
||
}
|
||
|
||
$FranchiseeBillModel = new RetailFranchiseeBillModel();
|
||
// 总提现金额
|
||
$map['status'] = 5;
|
||
$total['total_money'] = $FranchiseeBillModel->getSum($map, 'money');
|
||
// 总平账金额
|
||
$map['status'] = 8;
|
||
$total['total_flat_money'] = $FranchiseeBillModel->getSum($map, 'money');
|
||
// 待提现金额
|
||
$map['status'] = $user_type == 1 ? 2 : array('in', '1,2,3');
|
||
$total['stay_money'] = $FranchiseeBillModel->getSum($map, 'money');
|
||
// 待平账金额
|
||
$map['status'] = $user_type == 1 ? 6 : array('in', '6,7,9');
|
||
$total['stay_flat_money'] = $FranchiseeBillModel->getSum($map, 'money');
|
||
if ($user_type == 2) {
|
||
// 总收入
|
||
$total['store_total_money'] = $FranchiseeBillModel->getSum(array('store_id' => $this->store_id), 'money');
|
||
}
|
||
$result['status'] = 1;
|
||
$result['msg'] = '查询成功';
|
||
$result['total'] = $total;
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 商户结算账号设置
|
||
*/
|
||
public function accountSet()
|
||
{
|
||
$map['account_type'] = 2;
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$isset = I('post.isset');
|
||
$franchisee = D('RetailFranchisee')->getFind($map);
|
||
if ($isset) {
|
||
if ($franchisee) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '账号信息';
|
||
$result['list'] = $franchisee;
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '无账号信息';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$adds['merchant_id'] = $this->merchant_id;
|
||
$adds['clearing_form'] = I('post.clearing_form');
|
||
$adds['account_number'] = I('post.account_number');
|
||
if ($adds['clearing_form'] == 1) {
|
||
$adds['opening_bank'] = I('post.opening_bank');
|
||
}
|
||
$adds['name'] = I('post.name');
|
||
$adds['add_time'] = time();
|
||
$adds['account_type'] = 2;
|
||
if (!empty($adds['clearing_form']) && !empty($adds['account_number']) && !empty($adds['name'])) {
|
||
$RetailFranchisee = D('RetailFranchisee');
|
||
if ($franchisee) {
|
||
// 修改操作
|
||
$map['id'] = $franchisee['id'];
|
||
$res = $RetailFranchisee->updateOrder($map, $adds);
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '修改成功';
|
||
}
|
||
} else {
|
||
// 新增操作
|
||
$RetailF = $RetailFranchisee->addOrder($adds);
|
||
if ($RetailF) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '添加成功';
|
||
}
|
||
}
|
||
$this->ajaxReturn($result);
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '缺失参数';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 导出账单(商户门店通用)
|
||
*/
|
||
public function accountCSV()
|
||
{
|
||
$data = I('get.');
|
||
$StoreModel = new StoreModel();
|
||
$Franchise_model = new RetailFranchiseeBillModel();
|
||
if (!in_array($data['user_type'], array('1', '2'))) {
|
||
$result = array('status' => 0, 'msg' => '访问有误');
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$data['store_id'] = $this->store_id;
|
||
$data['merchant_id'] = $this->merchant_id;
|
||
$where_data = $Franchise_model->getMap($data);
|
||
if ($where_data['status'] != 1) {
|
||
$result = array('status' => 0, 'msg' => '条件有误');
|
||
$this->ajaxReturn($result);
|
||
}
|
||
// 获取列表
|
||
$result = $Franchise_model->getSelect($where_data['data']['where'], $where_data['data']['field']);
|
||
$status_list = array(
|
||
'1' => '待提现',
|
||
'2' => '提现待审核',
|
||
'3' => '提现驳回',
|
||
'4' => '待打款',
|
||
'5' => '已打款',
|
||
'6' => '平账待审核',
|
||
'7' => '平账驳回',
|
||
'8' => '已平账',
|
||
'9' => '待平账',
|
||
'10' => '无需操作',
|
||
);
|
||
$storeArr = [];
|
||
$storeList = [];
|
||
foreach ($result as $key => &$val) {
|
||
$val['index'] = $key + 1;
|
||
$val['status'] = $status_list[$val['status']];
|
||
if (!empty($val['apply_time'])) {
|
||
$val['apply_time'] = date('Y.m.d H:i:s', $val['apply_time']);
|
||
}
|
||
$val['add_time'] = date('Y.m.d H:i:s', $val['add_time']);
|
||
$val['data_type'] = $val['data_type'] == 1 ? '提现' : '平账';
|
||
if (in_array($val['store_id'], $storeArr)) {
|
||
$val['store_name'] = $storeList[$val['store_id']]['store_name'];
|
||
} else {
|
||
$val['store_name'] = $StoreModel->getFindField(array('id' => $val['store_id']), 'storetag');
|
||
$storeArr[] = $val['store_id'];
|
||
$storeList[$val['store_id']]['store_name'] = $val['store_name'];
|
||
}
|
||
}
|
||
if ($data['user_type'] == 2) {
|
||
//门店
|
||
$head_arr = array(
|
||
array('index', '序号'),
|
||
array('store_name', '结算门店'),
|
||
array('periods', '结算周期'),
|
||
array('franchisee_time', '结算日期'),
|
||
array('add_time', '账单生成时间'),
|
||
array('apply_time', '申请时间'),
|
||
array('data_type', '结算方式'),
|
||
array('money', '结算金额'),
|
||
array('status', '审核状态')
|
||
);
|
||
} else {
|
||
$head_arr = array(
|
||
array('index', '序号'),
|
||
array('store_name', '门店'),
|
||
array('periods', '结算周期'),
|
||
array('franchisee_time', '结算日期'),
|
||
array('apply_time', '申请日期'),
|
||
array('add_time', '账单生成时间'),
|
||
array('data_type', '结算方式'),
|
||
array('money', '结算金额'),
|
||
array('status', '审核状态')
|
||
);
|
||
}
|
||
switch ($data['user_type']) {
|
||
case 1:
|
||
$file_name = "加盟店结算明细";
|
||
break;
|
||
case 2:
|
||
$file_name = "收入明细";
|
||
break;
|
||
}
|
||
$str = "导出时间:" . date("Y-m-d H:i:s", time());
|
||
$this->getExcel($file_name, $head_arr, $result, $str);
|
||
}
|
||
|
||
/**
|
||
* 导出(公共方法)
|
||
*/
|
||
private function getExcel($expTitle, $expCellName, $expTableData, $str = "")
|
||
{
|
||
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle); //文件名称
|
||
$fileName = $expTitle . date('_YmdHis'); //or $xlsTitle 文件名称可根据自己情况设定
|
||
$cellNum = count($expCellName);
|
||
$dataNum = count($expTableData);
|
||
$common = $str;
|
||
vendor("PHPExcel.PHPExcel");
|
||
ob_clean();
|
||
$objPHPExcel = new \PHPExcel();
|
||
$cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ');
|
||
$objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1'); //合并单元格
|
||
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $common);
|
||
for ($i = 0; $i < $cellNum; $i++) {
|
||
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]);
|
||
}
|
||
for ($i = 0; $i < $dataNum; $i++) {
|
||
for ($j = 0; $j < $cellNum; $j++) {
|
||
$objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), ' ' . $expTableData[$i][$expCellName[$j][0]]);
|
||
}
|
||
}
|
||
foreach ($cellName as $value) {
|
||
$objPHPExcel->getActiveSheet()->getColumnDimension($value)->setWidth(20);
|
||
}
|
||
header('pragma:public');
|
||
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"');
|
||
header("Content-Disposition:attachment;filename=$fileName.xls"); //attachment新窗口打印inline本窗口打印
|
||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||
$objWriter->save('php://output');
|
||
exit();
|
||
}
|
||
|
||
/**
|
||
* 状态更新
|
||
*/
|
||
public function status()
|
||
{
|
||
$id = I('post.id');
|
||
$status = I('post.status');
|
||
$reject_reason = I('post.reject_reason');
|
||
if (($status == 3 || $status == 7)) {
|
||
if (empty($reject_reason)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请填写驳回原因';
|
||
$this->ajaxReturn($result);
|
||
} else {
|
||
$data['reject_reason'] = $reject_reason;
|
||
}
|
||
}
|
||
//审核状态:1待提现 2提现待审核 3提现驳回 4提现通过待打款 5已打款 6平账待审核 7平账驳回 8已平账 9待平账 10无需操作
|
||
if (empty($id) || empty($status) || !in_array($status, array('2', '3', '4', '7', '8'))) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '缺失参数';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
if ($status == 3 || $status == 7) {
|
||
$data['reject_time'] = time();
|
||
} else if ($status == 2) {
|
||
$data['apply_time'] = time();
|
||
}
|
||
$map['id'] = $id;
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$data['status'] = $status;
|
||
$FranchiseeBillModel = new RetailFranchiseeBillModel();
|
||
$res = $FranchiseeBillModel->updateOrder($map, $data);
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '操作成功';
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '操作失败';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 确认打款
|
||
*/
|
||
public function toMakeMoney()
|
||
{
|
||
$id = I('post.id');
|
||
$data = I('post.');
|
||
$FranchiseeBillModel = new RetailFranchiseeBillModel();
|
||
$map = array(
|
||
'id' => $id,
|
||
'merchant_id' => $this->merchant_id,
|
||
'status' => 4,
|
||
);
|
||
$order = $FranchiseeBillModel->getFind($map);
|
||
if (empty($order)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '操作有误';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$data['time'] = time();
|
||
$save = array(
|
||
'status' => 5,
|
||
'settlement_json' => json_encode($data),
|
||
);
|
||
$res = $FranchiseeBillModel->updateOrder($map, $save);
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '操作成功';
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '操作失败';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 商户平账收款账号信息
|
||
*/
|
||
public function applyFlat()
|
||
{
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$map['account_type'] = 2;
|
||
$FranchiseeModel = new RetailFranchiseeModel();
|
||
$res = $FranchiseeModel->getOrderFind($map, 'clearing_form,account_number,opening_bank,name');
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '查询成功';
|
||
$result['data'] = $res;
|
||
$result['m'] = M()->_sql();
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '商户暂未设置收款账号信息';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 提交平账
|
||
*/
|
||
public function flatFile()
|
||
{
|
||
$id = I('post.id');
|
||
if ($_FILES['image']['error'] == 0) {
|
||
$item = array(
|
||
'add_time' => time(),
|
||
'from_type_id' => 51,
|
||
'localUrl' => 'Store/Settlement',
|
||
'user_type' => 4,
|
||
'merchant_id' => $this->merchant_id,
|
||
'store_id' => $this->store_id,
|
||
);
|
||
$uploads = uploadFiles($item); //上传图片
|
||
if (empty($uploads['image'])) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '图片上传失败';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$data = array(
|
||
'reject_img_id' => $uploads['image']['id'], //平账图片
|
||
'status' => 6,
|
||
'apply_time' => time(),
|
||
);
|
||
$FranchiseeBillModel = new RetailFranchiseeBillModel();
|
||
$map = array(
|
||
'id' => $id,
|
||
);
|
||
$res = $FranchiseeBillModel->updateOrder($map, $data);
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '操作成功';
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '系统发生错误';
|
||
}
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '请上传凭证';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 门店收款账号信息
|
||
*/
|
||
public function getPayInfo()
|
||
{
|
||
$store_id = I('post.store_id');
|
||
$map['store_id'] = $store_id;
|
||
$map['account_type'] = 1;
|
||
$FranchiseeModel = new RetailFranchiseeModel();
|
||
$res = $FranchiseeModel->getFind($map, 'clearing_form,account_number,opening_bank,name');
|
||
if ($res) {
|
||
$result['status'] = 1;
|
||
$result['msg'] = '查询成功';
|
||
$result['data'] = $res;
|
||
} else {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '无信息';
|
||
}
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 营业收款详细列表
|
||
*/
|
||
public function getOrderList()
|
||
{
|
||
$franchisee_time = I('post.franchisee_time');
|
||
$store_id = I('post.store_id');
|
||
$type = I('post.type'); //1付款 2退款
|
||
$pay_type = I('post.pay_type'); //支付类型 1微信 2支付宝 3现金 4小程序微信 5其他支付方式 6会员余额
|
||
$scene_type = I('post.scene_type'); //1营业 2快捷收款 3充值
|
||
$page = I('post.page') ? I('post.page') : 1;
|
||
$limit = I('post.limit') ? I('post.limit') : 10;
|
||
if (!$franchisee_time || !$store_id) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '缺失参数';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$start_end = explode('-', $franchisee_time);
|
||
$start_time = strtotime(str_replace('.', '-', $start_end[0]));
|
||
$end_time = strtotime(str_replace('.', '-', $start_end[1]));
|
||
$map = array(
|
||
'store_id' => $store_id,
|
||
'add_time' => array('between', array($start_time, $end_time)),
|
||
'order_state' => array('in', 'SUCCESS,REFUND'),
|
||
'order_type' => array('in', '1,2,6,7'), //1购买商品 2会员充值 4购买礼品卡5.购买付费会员 6小助手快捷收银 7.购买次卡
|
||
'pay_type' => array('in', '1,2,3,4,5,6'),
|
||
);
|
||
//场景 1营业 2快捷收款 3充值 4次卡
|
||
switch ($scene_type) {
|
||
case '1':
|
||
$map['bill_id'] = array('gt', 0);
|
||
if ($type == 2) {
|
||
$map['order_type'] = 1;
|
||
$map['scene_type'] = 2;
|
||
$map['order_state'] = 'REFUND';
|
||
} else if ($type == 1) {
|
||
$map['order_type'] = 1;
|
||
}
|
||
break;
|
||
case '2':
|
||
$map['order_type'] = 6;
|
||
break;
|
||
case '3':
|
||
$map['order_type'] = array('in', '2,3');
|
||
$map['bill_id'] = 0;
|
||
break;
|
||
case '4':
|
||
$map['order_type'] = 7;
|
||
break;
|
||
}
|
||
|
||
if ($scene_type) {
|
||
if ($type == 2) {
|
||
//退款订单
|
||
$map['scene_type'] = 2;
|
||
$map['order_state'] = 'REFUND';
|
||
} else if ($type == 1) {
|
||
//支付
|
||
$map['scene_type'] = 1;
|
||
$map['order_state'] = 'SUCCESS';
|
||
}
|
||
}
|
||
if (in_array($pay_type, array('1', '2', '3', '4', '5', '6'))) {
|
||
$map['pay_type'] = $pay_type;
|
||
}
|
||
|
||
$PayOrderModel = new PayOrderModel();
|
||
$fields = array(
|
||
'id',
|
||
'out_trade_no',
|
||
'trade_no',
|
||
'add_time',
|
||
'pay_type',
|
||
'mer_id',
|
||
'trade_amount',
|
||
'order_state',
|
||
);
|
||
$list = $PayOrderModel->getSelect($map, $fields, 'id desc', $page . ',' . $limit);
|
||
$count = $PayOrderModel->getCount($map);
|
||
$payTypeArr = array(
|
||
'1' => '微信',
|
||
'2' => '支付宝',
|
||
'3' => '现金',
|
||
'4' => '小程序微信',
|
||
'5' => '其他支付方式',
|
||
'6' => '会员余额',
|
||
);
|
||
foreach ($list as &$val) {
|
||
if ($val['order_state'] == 'SUCCESS') {
|
||
$val['order_state'] = '支付';
|
||
} elseif ($val['order_state'] == 'REFUND') {
|
||
$val['order_state'] = '退款';
|
||
}
|
||
$val['add_time'] = date('Y.m.d H:i:s', $val['add_time']);
|
||
$val['pay_type'] = $payTypeArr[$val['pay_type']];
|
||
}
|
||
$result = array(
|
||
'status' => 1,
|
||
'msg' => $list ? '查询成功' : '暂无数据',
|
||
'data' => $list ? $list : array(),
|
||
'pages' => array(
|
||
'total_num' => $count,
|
||
'page' => $page,
|
||
'limit' => $limit,
|
||
),
|
||
);
|
||
|
||
$this->ajaxReturn($result);
|
||
}
|
||
}
|