
- 添加 endsWithDoubleZero 函数,用于处理数值字符串末尾的两个零 - 修改 Core.php 中的 queue 方法,增加对卡库提单的特殊处理逻辑 -调整 Feedov.php 中的订单查询和充值逻辑,提高系统稳定性 - 优化数据库配置,连接测试数据库以确保数据安全
184 lines
5.6 KiB
PHP
184 lines
5.6 KiB
PHP
<?php
|
||
|
||
// +----------------------------------------------------------------------
|
||
// | ThinkAdmin
|
||
// +----------------------------------------------------------------------
|
||
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||
// +----------------------------------------------------------------------
|
||
// | 官方网站: https://thinkadmin.top
|
||
// +----------------------------------------------------------------------
|
||
// | 开源协议 ( https://mit-license.org )
|
||
// +----------------------------------------------------------------------
|
||
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\merchant\controller;
|
||
|
||
use think\admin\Controller;
|
||
use app\merchant\service\MerchantLogService;
|
||
use app\merchant\service\MerchantService;
|
||
use app\merchant\service\OrderService;
|
||
use app\channel\service\ChannelService;
|
||
use app\channel\service\ProductService;
|
||
use app\merchant\service\MerchantLogHistoryService;
|
||
/**
|
||
* 商户资金管理
|
||
* Class Merchant
|
||
* @package app\merchant\controller
|
||
*/
|
||
class Account extends Controller
|
||
{
|
||
|
||
/**
|
||
* 绑定数据表
|
||
* @var string
|
||
*/
|
||
public $table = 'MerchantAccountLog';
|
||
|
||
/**
|
||
* 充值信息列表
|
||
* @auth true
|
||
* @menu true
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function index()
|
||
{
|
||
$id = input('id');
|
||
$this->info = MerchantService::instance()->getInfo($id);
|
||
$this->title = '【' . $this->info['name'] . '】交易明细列表';
|
||
$data_type = input('data_type', 1);
|
||
if ($data_type == 2) {
|
||
$this->table = 'MerchantAccountLogHistory';
|
||
}
|
||
$this->data_type = $data_type;
|
||
$query = $this->_query($this->table);
|
||
$query->where(array('is_yue' => 1));
|
||
$query->equal('mid,type,oper,account_type')->like('order_id')->dateBetween('create_at,order_date');
|
||
$query->where(['mid' => $id]);
|
||
// 列表排序并显示
|
||
if (input('output') === 'json') {
|
||
$result = $query->order('id desc')->page(true, false);
|
||
$this->success('获取数据列表成功', $result);
|
||
} else {
|
||
$query->order('id desc')->page();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 表单数据处理
|
||
* @param array $data
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
protected function _form_filter(&$data)
|
||
{
|
||
|
||
}
|
||
|
||
/**
|
||
* 列表数据处理
|
||
* @param array $data
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
protected function _index_page_filter(array &$data)
|
||
{
|
||
$merchant = MerchantService::instance();
|
||
$this->type = $this->type();
|
||
$this->account_type = $this->account_type();
|
||
foreach ($data as $k => $v) {
|
||
$data[$k]['merchant'] = $this->info;
|
||
|
||
$data[$k]['oper_name'] = $this->type($v['type']);
|
||
|
||
if ($v['account_type'] == 2) {
|
||
$data[$k]['account_name'] = '授信账户';
|
||
} else {
|
||
$data[$k]['account_name'] = '余额账户';
|
||
}
|
||
|
||
|
||
|
||
if ($data[$k]['num'] > 0) {
|
||
if ($v['oper'] == 1) {
|
||
$data[$k]['snum'] = '+' . $data[$k]['num'];
|
||
} else {
|
||
$data[$k]['snum'] = '-' . $data[$k]['num'];
|
||
}
|
||
} else {
|
||
$data[$k]['snum'] = $data[$k]['num'];
|
||
}
|
||
$data[$k]['snum'] = $this->endsWithDoubleZero($data[$k]['snum']);
|
||
$data[$k]['qian_yue'] = $this->endsWithDoubleZero($data[$k]['qian_yue']);
|
||
$data[$k]['yue'] = $this->endsWithDoubleZero($data[$k]['yue']);
|
||
$data[$k]['product_cash'] = $this->endsWithDoubleZero($data[$k]['product_cash']);
|
||
$data[$k]['profit'] = $this->endsWithDoubleZero($data[$k]['profit']);
|
||
|
||
}
|
||
|
||
if ($this->data_type == 2) {
|
||
$this->total = MerchantLogHistoryService::instance()->total($this->info['id'], $this->info);
|
||
} else {
|
||
$this->total = MerchantLogService::instance()->total($this->info['id'], $this->info);
|
||
}
|
||
}
|
||
|
||
protected function type($type = false)
|
||
{
|
||
$config = array
|
||
(
|
||
'' => '全部',
|
||
1 => '充值',
|
||
2 => '扣减',
|
||
3 => '下单成功扣减',
|
||
4 => '下单失败返还',
|
||
5 => '满额返点',
|
||
6 => '授信',
|
||
);
|
||
|
||
if (!$type) {
|
||
return $config;
|
||
} else {
|
||
return $config[$type];
|
||
}
|
||
}
|
||
|
||
protected function account_type($type = false)
|
||
{
|
||
$config = array
|
||
(
|
||
'' => '全部',
|
||
2 => '授信账户',
|
||
1 => '余额账户',
|
||
);
|
||
|
||
if (!$type) {
|
||
return $config;
|
||
} else {
|
||
return $config[$type];
|
||
}
|
||
}
|
||
|
||
public function endsWithDoubleZero($string) {
|
||
// 获取字符串的长度
|
||
$length = strlen($string);
|
||
|
||
// 检查字符串长度是否至少为4,并且最后两位是否为 '00'
|
||
if ($length >= 4 && str_ends_with($string, '00')) {
|
||
// 截去最后两位
|
||
if(str_ends_with($string, '.00')){
|
||
return $string;
|
||
}
|
||
return substr($string, 0, $length - 2);
|
||
}
|
||
|
||
// 如果最后两位不是 '00',返回原字符串
|
||
return $string;
|
||
}
|
||
}
|