2024-09-29 15:43:18 +08:00
|
|
|
|
<?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'];
|
|
|
|
|
}
|
2025-02-15 19:00:17 +08:00
|
|
|
|
$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']);
|
|
|
|
|
|
2024-09-29 15:43:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-15 19:00:17 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-09-29 15:43:18 +08:00
|
|
|
|
}
|