633 行
24 KiB
PHP
可执行文件
633 行
24 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
|
||
//[1.9.20]
|
||
|
||
use Common\Business\Plug;
|
||
use Common\Business\Store;
|
||
use Common\Model\RetailBillOrderModel;
|
||
use Common\Model\RetailVipModel;
|
||
use Common\Model\RetailPayOrderModel;
|
||
use Common\Model\RetailStoreModel;
|
||
use Common\Model\StoreModel;
|
||
use Common\Order\PayOrder;
|
||
use Common\User\Cashier;
|
||
use Common\User\Manager;
|
||
use Common\User\Vip;
|
||
|
||
/**
|
||
* 支付流水
|
||
* Class PayFlowController
|
||
* @package Retail\Controller
|
||
*/
|
||
class PayFlowController extends BaseController
|
||
{
|
||
/**
|
||
* 加载页面(商户)
|
||
*/
|
||
public function mIndex()
|
||
{
|
||
// 节点
|
||
$arr = array(
|
||
'exportMPayFlow' => '/index.php/Retail/PayFlow/exportMPayFlow',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取列表(商户)
|
||
* @param $seek array 搜索条件
|
||
* @param $page string 分页
|
||
* @param $limit string 数量
|
||
* @return $res array
|
||
*/
|
||
public function getMPayFlowList()
|
||
{
|
||
try {
|
||
// 判断登录
|
||
if (!$this->merchant_id) {
|
||
$res = array('status' => 0, 'msg' => '登录超时,请重新登录');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
// 接受数据
|
||
$seek_data = I('post.seek_data');
|
||
$page = I('post.page') ? intval(I('post.page')) : 1;
|
||
$limit = I('post.limit') ? intval(I('post.limit')) : 10;
|
||
// 获取列表
|
||
$result = $this->publicMCondition($seek_data, $page . ',' . $limit);
|
||
if ($result['status'] == 0) {
|
||
$this->ajaxReturn($result);
|
||
}
|
||
// 统计数据
|
||
$result2 = $this->publicStatisticalAmount($result['map']);
|
||
$result2['pay_flow_list'] = $result['pay_flow_list'];
|
||
$result2['count'] = $result['count'];
|
||
$this->ajaxReturn($result2);
|
||
} catch (\Exception $e) {
|
||
// 异常操作,抛出错误
|
||
$res = array('status' => 0, 'msg' => '操作异常,请刷新重试');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 商户支付流水公共条件(搜索)
|
||
* @param $seek array 搜索条件
|
||
* @param $page string 分页
|
||
* @return $res array
|
||
*/
|
||
private function publicMCondition($seek_data, $page)
|
||
{
|
||
// 判断时间段搜索
|
||
if (!empty($seek_data['time_slot'])) {
|
||
$start_time = strtotime($seek_data['time_slot'][0]);
|
||
$end_time = strtotime($seek_data['time_slot'][1]);
|
||
} else {
|
||
$start_time = strtotime(date('Y-m-01 00:00:00', time()));
|
||
$end_time = time();
|
||
}
|
||
// 判断门店搜索
|
||
if ($seek_data['store_id']) {
|
||
$map['store_id'] = $seek_data['store_id'];
|
||
if ($seek_data['cashier_id']) {
|
||
$map['cashier_id'] = $seek_data['cashier_id'];
|
||
}
|
||
}
|
||
// 判断支付方式搜素
|
||
if ($seek_data['pay_type']) {
|
||
$map['pay_type'] = $seek_data['pay_type'];
|
||
}
|
||
$map['add_time'] = array('between', array($start_time, $end_time));
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$map['order_state'] = array('in', array('SUCCESS', 'REFUND'));
|
||
// 判断类型搜索
|
||
if ($seek_data['order_type']) {
|
||
$map['order_type'] = $seek_data['order_type'];
|
||
}
|
||
// 判断类型搜索
|
||
if ($seek_data['scene_type']) {
|
||
$map['scene_type'] = $seek_data['scene_type'];
|
||
}
|
||
//订单号
|
||
$BillModel = new RetailBillOrderModel();
|
||
if (!empty($seek_data['order_number'])) {
|
||
if ($seek_data['order_no_type'] == 2) {
|
||
$bill_id = $BillModel->getFindField(['order_no' => strval($seek_data['order_number'])], 'id');
|
||
if (empty($bill_id)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
$map['bill_id'] = $bill_id;
|
||
} else {
|
||
$map['trade_no|out_trade_no'] = strval($seek_data['order_number']);
|
||
}
|
||
}
|
||
if (!empty($seek_data['vip_phone'])) {
|
||
$VipModel = new RetailVipModel();
|
||
$vid = $VipModel->getFindField(['merchantid' => $this->merchant_id, 'mobile_phone|card_key' => strval($seek_data['vip_phone'])], 'id');
|
||
if (empty($vid)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
} else {
|
||
$map['vid'] = $vid;
|
||
}
|
||
}
|
||
|
||
/* 德育币会员搜索 */
|
||
if ($seek_data['mec_vip_key']) {
|
||
$bill_id = $BillModel->getFindField(['third_vip_code|third_vip_name' => strval($seek_data['mec_vip_key'])], 'id');
|
||
if (empty($bill_id)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
$map['bill_id'] = $bill_id;
|
||
}
|
||
/* 德育币村镇ID搜索 */
|
||
if ($seek_data['mec_villages_id']) {
|
||
$StoreModel = new RetailStoreModel();
|
||
$storeIds = $StoreModel->getFindField(['third_code' => strval($seek_data['mec_villages_id'])]);
|
||
if (empty($storeIds)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
}
|
||
// 查询
|
||
$res = $this->publicGetPayFlowData($map, $page);
|
||
$res['map'] = $map;
|
||
return $res;
|
||
}
|
||
|
||
/**
|
||
* 统计
|
||
* @param $map
|
||
* @return array
|
||
*/
|
||
private function publicStatisticalAmount($map)
|
||
{
|
||
$RPOModel = new RetailPayOrderModel(); // 流水模型(pay_order)
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 总额
|
||
$map[$RPOModel::ORDER_STATE] = "SUCCESS";
|
||
$map[$RPOModel::ORDER_TYPE] = array('in', array(1, 2, 4, 5, 6, 7, 8, 9));
|
||
$total_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 购买商品
|
||
$map[$RPOModel::ORDER_TYPE] = 1;
|
||
$goods_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 会员充值
|
||
$map[$RPOModel::ORDER_TYPE] = 2;
|
||
$recharge_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 购买礼品卡
|
||
$map[$RPOModel::ORDER_TYPE] = 4;
|
||
$gift_card_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 购买plus会员
|
||
$map[$RPOModel::ORDER_TYPE] = 5;
|
||
$plus_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 快捷收银
|
||
$map[$RPOModel::ORDER_TYPE] = 6;
|
||
$quick_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 购买次卡
|
||
$map[$RPOModel::ORDER_TYPE] = 7;
|
||
$card_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
// 积分商城
|
||
$map[$RPOModel::ORDER_TYPE] = 8;
|
||
$score_mall_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE]);
|
||
//代金券
|
||
$pay_coupon_fee = 0;
|
||
if ($map['scene_type'] == 1 || empty($map['scene_type'])) {
|
||
$pay_coupon_fee = $RPOModel->getSum($map, 'pay_coupon_fee'); //代金券使用总额
|
||
unset($map['scene_type']);
|
||
}
|
||
// 退款
|
||
$map[$RPOModel::ORDER_STATE] = "REFUND";
|
||
$map['scene_type'] = 2;
|
||
$refund_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_STATE], $map['scene_type']);
|
||
// 净收入
|
||
$map[$RPOModel::ORDER_STATE] = "SUCCESS";
|
||
$map[$RPOModel::ORDER_TYPE] = array('in', array(1, 2, 4, 5, 6, 7, 8));
|
||
$map[$RPOModel::PAY_TYPE] = array('in', array(1, 2, 3, 4, 5, 8));
|
||
$net_income_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE], $map[$RPOModel::PAY_TYPE]);
|
||
// 余额付款
|
||
$map[$RPOModel::ORDER_TYPE] = array('in', array(1, 2, 4, 5, 6, 7, 8));
|
||
$map[$RPOModel::PAY_TYPE] = 6;
|
||
$balance_money = $RPOModel->getSum($map, $RPOModel::TRADE_AMOUNT);
|
||
unset($map[$RPOModel::ORDER_TYPE], $map[$RPOModel::PAY_TYPE]);
|
||
//代金券退款金额
|
||
$refund_pay_coupon_fee = 0;
|
||
if ($map['scene_type'] == 2 || empty($map['scene_type'])) {
|
||
$refund_pay_coupon_fee = $RPOModel->getSum($map, 'refund_coupon_fee'); //代金券退款总额
|
||
unset($map['scene_type']);
|
||
}
|
||
|
||
|
||
// 定义数组
|
||
$pay_flow_total = array(
|
||
'total_money' => $total_money ? strval($total_money) : '0',
|
||
'goods_money' => $goods_money ? strval($goods_money) : '0',
|
||
'recharge_money' => $recharge_money ? strval($recharge_money) : '0',
|
||
'gift_card_money' => $gift_card_money ? strval($gift_card_money) : '0',
|
||
'plus_money' => $plus_money ? strval($plus_money) : '0',
|
||
'refund_money' => $refund_money ? strval($refund_money) : '0',
|
||
'quick_money' => $quick_money ? round($quick_money, 2) : "0",
|
||
'card_money' => $card_money ? round($card_money, 2) : "0",
|
||
'net_income_money' => $net_income_money ? strval($net_income_money) : "0",
|
||
'balance_money' => $balance_money ? strval($balance_money) : "0",
|
||
'score_mall_money' => $score_mall_money ? strval($score_mall_money) : "0",
|
||
'pay_coupon_fee' => $pay_coupon_fee ? strval($pay_coupon_fee) : "0",
|
||
'refund_pay_coupon_fee' => $refund_pay_coupon_fee ? strval($refund_pay_coupon_fee) : "0",
|
||
);
|
||
// 返回值
|
||
$res = array(
|
||
'status' => 1,
|
||
'pay_flow_total' => $pay_flow_total,
|
||
);
|
||
return $res;
|
||
}
|
||
|
||
/**
|
||
* 商户导出支付流水
|
||
*/
|
||
public function exportMPayFlow()
|
||
{
|
||
// 判断登录
|
||
if (!$this->merchant_id) {
|
||
return false;
|
||
}
|
||
// 接受数据
|
||
$seek_data = json_decode($_GET['seek_data'], true);
|
||
// 获取列表
|
||
$result = $this->publicMCondition($seek_data, '');
|
||
$file_name = "支付流水";
|
||
$str = $file_name . "导出时间:" . date('Y-m-d H:i:s', time());
|
||
$Plug = new Plug();
|
||
$plug_result = $Plug->merPlugState([
|
||
'merchant_id' => $this->merchant_id,
|
||
'identification_arr' => ['moraleducationcoin']
|
||
]);
|
||
$head_arr = [
|
||
['index', '序号'],
|
||
['out_trade_no', '内部流水号订单号'],
|
||
['trade_no', '外部流水号订单号'],
|
||
['store_name', '消费门店'],
|
||
['scene_type', '订单类型'],
|
||
['order_type', '消费类型'],
|
||
['m_pay_type', '支付模式'],
|
||
['pay_type', '支付方式'],
|
||
['trade_amount', '支付金额'],
|
||
['pay_coupon_fee', '代金券金额'],
|
||
['trade_date', '支付时间'],
|
||
['refund_money', '已退金额'],
|
||
['vip_name', '会员'],
|
||
['cashier_name', '收银员'],
|
||
];
|
||
if ($plug_result['moraleducationcoin']){
|
||
$head_arr[] = ['third_vip_code', '德育币会员ID'];
|
||
$head_arr[] = ['villageId', '村镇ID'];
|
||
}
|
||
getExcel($file_name, $head_arr, $result['pay_flow_list'], $str);
|
||
}
|
||
|
||
/**
|
||
* 加载页面(门店)
|
||
*/
|
||
public function sIndex()
|
||
{
|
||
// 节点
|
||
$arr = array(
|
||
'exportSPayFlow' => '/index.php/Retail/PayFlow/exportSPayFlow',
|
||
);
|
||
$authArr = checkFunction($arr);
|
||
$this->assign('authArr', $authArr);
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取列表(门店)
|
||
* @param $seek array 搜索条件
|
||
* @param $page string 分页
|
||
* @param $limit string 数量
|
||
* @return $res array
|
||
*/
|
||
public function getSPayFlowList()
|
||
{
|
||
try {
|
||
// 判断登录
|
||
if (!$this->merchant_id || !$this->store_id) {
|
||
$res = array('status' => 0, 'msg' => '登录超时,请重新登录');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
// 接受数据
|
||
$seek_data = I('post.seek_data');
|
||
$page = I('post.page') ? intval(I('post.page')) : 1;
|
||
$limit = I('post.limit') ? intval(I('post.limit')) : 10;
|
||
// 获取列表
|
||
$result = $this->publicSCondition($seek_data, $page . ',' . $limit);
|
||
// 判断
|
||
if ($result['status'] == 0) {
|
||
$this->ajaxReturn($result);
|
||
}
|
||
// 统计数据
|
||
$result2 = $this->publicStatisticalAmount($result['map']);
|
||
$result2['pay_flow_list'] = $result['pay_flow_list'];
|
||
$result2['count'] = $result['count'];
|
||
$this->ajaxReturn($result2);
|
||
} catch (\Exception $e) {
|
||
// 异常操作,抛出错误
|
||
$res = array('status' => 0, 'msg' => '操作异常,请刷新重试');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 门店支付流水公共条件(搜索)
|
||
* @param $seek array 搜索条件
|
||
* @param $page string 分页
|
||
* @return $res array
|
||
*/
|
||
private function publicSCondition($seek_data, $page)
|
||
{
|
||
// 判断时间段搜索
|
||
if (!empty($seek_data['time_slot'])) {
|
||
$start_time = strtotime($seek_data['time_slot'][0]);
|
||
$end_time = strtotime($seek_data['time_slot'][1]);
|
||
} else {
|
||
$start_time = strtotime(date('Y-m-01 00:00:00', time()));
|
||
$end_time = time();
|
||
}
|
||
// 判断支付方式搜素
|
||
if ($seek_data['pay_type']) {
|
||
$map['pay_type'] = $seek_data['pay_type'];
|
||
}
|
||
if ($seek_data['cashier_id']) {
|
||
$map['cashier_id'] = $seek_data['cashier_id'];
|
||
}
|
||
$map['trade_date'] = array('between', array($start_time, $end_time));
|
||
$map['merchant_id'] = $this->merchant_id;
|
||
$map['store_id'] = $this->store_id;
|
||
$map['order_state'] = array('in', array('SUCCESS', 'REFUND'));
|
||
|
||
// 判断类型搜索
|
||
if ($seek_data['order_type']) {
|
||
$map['order_type'] = $seek_data['order_type'];
|
||
}
|
||
// 判断类型搜索
|
||
if ($seek_data['scene_type']) {
|
||
$map['scene_type'] = $seek_data['scene_type'];
|
||
}
|
||
// 判断类型搜索
|
||
$BillModel = new RetailBillOrderModel();
|
||
if ($seek_data['order_number']) {
|
||
if ($seek_data['order_no_type'] == 2) {
|
||
$bill_id = $BillModel->getFindField(['order_no' => strval($seek_data['order_number'])], 'id');
|
||
if (empty($bill_id)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
$map['bill_id'] = $bill_id;
|
||
} else {
|
||
$map['trade_no|out_trade_no'] = strval($seek_data['order_number']);
|
||
}
|
||
}
|
||
if (!empty($seek_data['vip_phone'])) {
|
||
$VipModel = new RetailVipModel();
|
||
$vid = $VipModel->getFindField(['merchantid' => $this->merchant_id, 'mobile_phone|card_key' => strval($seek_data['vip_phone'])], 'id');
|
||
if (empty($vid)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
} else {
|
||
$map['vid'] = $vid;
|
||
}
|
||
}
|
||
|
||
/* 德育币会员搜索 */
|
||
if ($seek_data['mec_vip_key']) {
|
||
$bill_id = $BillModel->getFindField(['third_vip_code|third_vip_name' => strval($seek_data['mec_vip_key'])], 'id');
|
||
if (empty($bill_id)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
$map['bill_id'] = $bill_id;
|
||
}
|
||
/* 德育币村镇ID搜索 */
|
||
if ($seek_data['mec_villages_id']) {
|
||
$StoreModel = new RetailStoreModel();
|
||
$storeIds = $StoreModel->getFindField(['third_code' => strval($seek_data['mec_villages_id'])]);
|
||
if (empty($storeIds)) {
|
||
return ['status' => 1, 'pay_flow_list' => [], 'count' => 0, 'map' => $map];
|
||
}
|
||
}
|
||
// 查询
|
||
$res = $this->publicGetPayFlowData($map, $page);
|
||
$res['map'] = $map;
|
||
return $res;
|
||
}
|
||
|
||
/**
|
||
* 获取支付流水(公共方法)
|
||
* @param $map array 查询条件
|
||
* @param $page string 分页
|
||
* @return array
|
||
*/
|
||
private function publicGetPayFlowData($map, $page)
|
||
{
|
||
// 查询支付流水
|
||
$RPOModel = new RetailPayOrderModel(); // 流水模型(pay_order)
|
||
$pay_flow_list = $RPOModel->getSelect($map, '*', $RPOModel::ID . ' desc', $page);
|
||
if (empty($pay_flow_list)) {
|
||
$res = array('status' => 0, 'msg' => '暂无支付流水');
|
||
return $res;
|
||
}
|
||
// 获取总数
|
||
$count = $RPOModel->getCount($map);
|
||
// 处理数据
|
||
$PayOrder = new PayOrder();//支付订单处理
|
||
$Store = new Store();
|
||
$Cashier = new Cashier();
|
||
$Manager = new Manager();
|
||
$Vip = new Vip();
|
||
$Plug = new Plug();
|
||
$plug_result = $Plug->merPlugState([
|
||
'merchant_id' => $this->merchant_id,
|
||
'identification_arr' => ['moraleducationcoin']
|
||
]);
|
||
$BillOrderModel = new RetailBillOrderModel();
|
||
$StoreModel = new RetailStoreModel();
|
||
$villageIds = [];
|
||
foreach ($pay_flow_list as $key => &$val) {
|
||
$val['index'] = $key + 1;
|
||
if ($val['scene_type'] == 1) {
|
||
$val['pay_coupon_fee'] = floatval($val['pay_coupon_fee']);
|
||
} else if ($val['scene_type'] == 2) {
|
||
$val['pay_coupon_fee'] = floatval($val['refund_coupon_fee']);
|
||
}
|
||
$val['trade_date'] = date('Y-m-d H:i:s', $val['trade_date']);
|
||
$val['order_type'] = $PayOrder->getOrderType($val['order_type']);
|
||
$val['scene_type'] = $PayOrder->getSceneType($val['scene_type']);
|
||
$val['pay_type'] = $PayOrder->getPayType($val['pay_type'], $val['other_pay_id']);
|
||
$val['m_pay_type'] = $PayOrder->getMerPayType($val['m_pay_type']);
|
||
$val['store_name'] = $Store->getStoreName($val['store_id'], $store_list);
|
||
// 判断是否有收银员
|
||
if (!empty($val['cashier_id'])) {
|
||
$val['cashier_name'] = $Cashier->getCashierName($val['cashier_id'], $cashier_list);// 查询收银员
|
||
} else if (!empty($val['shopowner_id'])) {
|
||
$val['cashier_name'] = $Manager->getManagerName($val['shopowner_id'], $manager_list);//查店长
|
||
}
|
||
// 判断是否是会员
|
||
if ($val['vid']) {
|
||
// 查询会员
|
||
$val['vip_name'] = $Vip->getVipName($val['vid'], $vip_list);
|
||
} else if (!empty($val['bill_id']) && $plug_result['moraleducationcoin']) {
|
||
$vip = $BillOrderModel->getFind(['id' => $val['bill_id']], 'third_vip_code,third_vip_name');
|
||
$val['vip_name'] = $vip['third_vip_name'];
|
||
$val['third_vip_code'] = $vip['third_vip_code'];
|
||
if (!$villageIds[$val['store_id']]) {
|
||
$villageIds[$val['store_id']] = $StoreModel->getFindField(['id' => $val['store_id']], 'third_code');
|
||
}
|
||
$val['villageId'] = $villageIds[$val['store_id']];
|
||
}
|
||
}
|
||
// 返回值
|
||
$res = array(
|
||
'status' => 1,
|
||
'pay_flow_list' => $pay_flow_list,
|
||
'count' => intval($count)
|
||
);
|
||
return $res;
|
||
}
|
||
|
||
/**
|
||
* 商户导出支付流水
|
||
*/
|
||
public function exportSPayFlow()
|
||
{
|
||
// 判断登录
|
||
if (!$this->merchant_id || !$this->store_id) {
|
||
return false;
|
||
}
|
||
// 接受数据
|
||
$seek_data = json_decode($_GET['seek_data'], true);
|
||
// 获取列表
|
||
$result = $this->publicSCondition($seek_data, '');
|
||
$file_name = "支付流水";
|
||
$str = $file_name . "导出时间:" . date('Y-m-d H:i:s', time());
|
||
$Plug = new Plug();
|
||
$plug_result = $Plug->merPlugState([
|
||
'merchant_id' => $this->merchant_id,
|
||
'identification_arr' => ['moraleducationcoin']
|
||
]);
|
||
$head_arr = [
|
||
['index', '序号'],
|
||
['out_trade_no', '内部流水号订单号'],
|
||
['trade_no', '外部流水号订单号'],
|
||
['scene_type', '订单类型'],
|
||
['order_type', '消费类型'],
|
||
['m_pay_type', '支付模式'],
|
||
['pay_type', '支付方式'],
|
||
['trade_amount', '支付金额'],
|
||
['pay_coupon_fee', '代金券金额'],
|
||
['trade_date', '支付时间'],
|
||
['refund_money', '已退金额'],
|
||
['vip_name', '会员'],
|
||
['cashier_name', '收银员'],
|
||
];
|
||
if ($plug_result['moraleducationcoin']){
|
||
$head_arr[] = ['third_vip_code', '德育币会员ID'];
|
||
$head_arr[] = ['villageId', '村镇ID'];
|
||
}
|
||
getExcel($file_name, $head_arr, $result['pay_flow_list'], $str);
|
||
}
|
||
|
||
/**
|
||
* 异常订单
|
||
*/
|
||
public function abnormal_order()
|
||
{
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 获取待支付订单列表
|
||
*/
|
||
public function getWaitPayFlowList()
|
||
{
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$order_no = I('post.order_no');
|
||
$date = I('post.date');
|
||
$map = array(
|
||
'order_type' => array('in', '1,2,4,5,6,7'),
|
||
'pay_type' => array('in', '1,2,4'),
|
||
'order_state' => ['in', 'WAIT_BUYER_PAY,REVOKED'],
|
||
'merchant_id' => $this->merchant_id,
|
||
);
|
||
if ($date) {
|
||
$map['add_time'] = array('between', array(strtotime($date[0]), strtotime($date[1])));
|
||
}
|
||
if ($order_no) {
|
||
$map['out_trade_no'] = strval($order_no);
|
||
}
|
||
$PayOrderModel = new RetailPayOrderModel();
|
||
$field = array(
|
||
'id',
|
||
'out_trade_no',
|
||
'order_state',
|
||
'scene_type',
|
||
'order_type',
|
||
'pay_type',
|
||
'trade_amount',
|
||
'm_pay_type',
|
||
'store_id',
|
||
'add_time',
|
||
);
|
||
$list = $PayOrderModel->getSelect($map, $field, 'id desc', "{$page},{$limit}");
|
||
$PayOrder = new PayOrder();
|
||
$Store = new Store();
|
||
foreach ($list as &$val) {
|
||
$val['store_name'] = $Store->getStoreName($val['store_id'], $store_list);
|
||
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
|
||
$val['order_type'] = $PayOrder->getOrderType($val['order_type']);
|
||
$val['scene_type'] = $PayOrder->getSceneType($val['scene_type']);
|
||
$val['pay_type'] = $PayOrder->getPayType($val['pay_type']);
|
||
$val['m_pay_type'] = $PayOrder->getMerPayType($val['m_pay_type']);
|
||
}
|
||
if ($list) {
|
||
$count = $PayOrderModel->getCount($map);
|
||
}
|
||
$result['status'] = 1;
|
||
$result['msg'] = $list ? '获取成功' : '暂无数据';
|
||
$result['data'] = $list ? $list : array();
|
||
$result['count'] = $count ? $count : 0;
|
||
$this->ajaxReturn($result);
|
||
}
|
||
|
||
/**
|
||
* 处理异常订单
|
||
*/
|
||
public function handleWaitPayOrder()
|
||
{
|
||
$id = I('post.id');
|
||
$map = array(
|
||
'order_type' => array('in', '1,2,4,5,6,7'),//1购买商品 2会员充值 4购买礼品卡 5.购买付费会员 6小助手快捷收银 7.购买次卡
|
||
'pay_type' => array('in', '1,2,4'),//1微信 2支付宝 4小程序微信
|
||
'order_state' => ['in', 'WAIT_BUYER_PAY,REVOKED'],
|
||
'merchant_id' => $this->merchant_id,
|
||
'id' => $id,
|
||
);
|
||
$PayOrderModel = new RetailPayOrderModel();
|
||
$order = $PayOrderModel->getFind($map);
|
||
if (empty($map)) {
|
||
$result['status'] = 0;
|
||
$result['msg'] = '操作有误';
|
||
$this->ajaxReturn($result);
|
||
}
|
||
$PayOrderApi = new PayOrder();
|
||
$result = $PayOrderApi->handleWaitPayOrder($order);
|
||
$this->ajaxReturn($result);
|
||
}
|
||
}
|