This commit is contained in:
devil_gong 2019-05-08 18:19:23 +08:00
parent ef9567d974
commit 7821caa9cc
24 changed files with 1375 additions and 310 deletions

View File

@ -146,7 +146,8 @@ class Safety extends Common
{ {
$params = array( $params = array(
'width' => 100, 'width' => 100,
'height' => 32, 'height' => 28,
'use_point_back' => false,
'key_prefix' => 'safety', 'key_prefix' => 'safety',
); );
$verify = new \base\Verify($params); $verify = new \base\Verify($params);

View File

@ -0,0 +1,99 @@
{{include file="public/header" /}}
<!-- header top nav -->
{{include file="public/header_top_nav" /}}
<!-- search -->
{{include file="public/nav_search" /}}
<!-- header nav -->
{{include file="public/header_nav" /}}
<!-- goods category -->
{{include file="public/goods_category" /}}
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
{{include file="public/user_menu" /}}
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body">
<!-- user menu start -->
{{include file="../../../plugins/view/wallet/public/nav" /}}
<!-- user menu end -->
<!-- tips start -->
<div class="am-alert am-alert-success wallet-cash-auth-tips" data-am-alert>
<p class="title">操作提示</p>
<ul>
<li>1. 请选择 "绑定邮箱" 或 "绑定手机" 方式其一作为安全校验码的获取方式并正确输入。</li>
<li>2. 如果您的邮箱已失效,可以 <a href="{{:MyUrl('index/safety/index')}}">绑定手机</a> 后通过接收手机短信完成验证。</li>
<li>3. 如果您的手机已失效,可以 <a href="{{:MyUrl('index/safety/index')}}">绑定邮箱</a> 后通过接收邮件完成验证。</li>
<li>4. 请正确输入下方图形验证码,如看不清可点击图片进行更换,输入完成后进行下一步操作。</li>
<li>5. 收到安全验证码后,请在{{:Myc('common_verify_expire_time', 600, true)/60}}分钟内完成验证。</li>
</ul>
</div>
<!-- tips end -->
<!-- form start -->
<form class="am-form form-validation" method="post" action="{{:PluginsHomeUrl('wallet', 'cash', 'verifycheck')}}" request-type="ajax-url" request-value="{{:PluginsHomeUrl('wallet', 'cash', 'createinfo')}}">
<div class="am-form-group">
<label>选择身份认证方式<span class="am-form-group-label-tips-must">必选</span></label>
<select name="account_type" class="chosen-select" data-placeholder="请选择..." data-validation-message="请选择身份认证方式" required>
{{if !empty($check_account_list)}}
{{foreach $check_account_list as $v}}
{{if !empty($user[$v['field']])}}
<option value="{{$v.value}}">{{$v.name}}[ {{$user[$v['field']]}} ]</option>
{{/if}}
{{/foreach}}
{{/if}}
</select>
</div>
<div class="am-form-group">
<label>请输入安全验证码<span class="am-form-group-label-tips-must">必填</span></label>
<div class="am-input-group am-input-group-sm">
<input type="number" name="verify" class="am-radius" placeholder="验证码" minlength="6" maxlength="6" data-validation-message="验证码格式 6 位数字" required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius btn-loading-example verify-submit" type="button" data-am-loading="{spinner:'circle-o-notch', loadingText:'发送中...'}" data-url="{{:PluginsHomeUrl('wallet', 'cash', 'verifysend')}}" data-verify="{{:MyC('home_img_verify_state')}}" data-text="获取安全验证码" data-send-text="还有 {time} 秒" data-time="{{:MyC('common_verify_time_interval', 30, true)}}">获取安全验证码</button>
</span>
</div>
</div>
<div class="am-form-group am-form-group-refreshing">
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">确认,进入下一步</button>
</div>
</form>
<!-- form end -->
<!-- verify win start -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="verify-win">
<div class="am-modal-dialog am-radius">
<div class="am-modal-hd">
<a href="javascript:;" class="am-close am-close-spin" data-am-modal-close>&times;</a>
</div>
<div class="am-modal-bd">
<div class="base">
<input type="text" placeholder="图形验证码" maxlength="6" id="verify-img-value" data-validation-message="请输入有效的图形验证码" class="am-form-field am-radius" />
<div class="am-fl">
<img src="{{:PluginsHomeUrl('wallet', 'cash', 'verifyentry')}}" class="am-radius c-p" id="verify-img" onClick="this.src=this.src+'#'+Math.random();" />
<a href="javascript:;" class="verify-tips" onClick="document.getElementById('verify-img').src='{{:PluginsHomeUrl('wallet', 'cash', 'verifyentry')}}#'+Math.random();">看不清换一张</a>
</div>
</div>
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-sm block btn-loading-example verify-submit-win" data-am-loading="{spinner:'circle-o-notch', loadingText:'发送中...'}" data-win="1">确认</button>
</div>
</div>
</div>
<!-- verify win end -->
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -0,0 +1,80 @@
{{include file="public/header" /}}
<!-- header top nav -->
{{include file="public/header_top_nav" /}}
<!-- search -->
{{include file="public/nav_search" /}}
<!-- header nav -->
{{include file="public/header_nav" /}}
<!-- goods category -->
{{include file="public/goods_category" /}}
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
{{include file="public/user_menu" /}}
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body">
<!-- user menu start -->
{{include file="../../../plugins/view/wallet/public/nav" /}}
<!-- user menu end -->
<!-- form start -->
<form class="am-form form-validation create-info" method="post" action="{{:PluginsHomeUrl('wallet', 'cash', 'create')}}" request-type="ajax-url" request-value="{{:PluginsHomeUrl('wallet', 'cash', 'index')}}">
<div class="am-form-group">
<label>提现金额<span class="am-form-group-label-tips-must">必填</span></label>
<div class="am-input-group am-input-group-sm">
<input type="number" autocomplete="off" name="money" step="0.01" min="0.00" max="{{$user_wallet.normal_money}}" class="am-radius" placeholder="提现金额" data-validation-message="请输入提现金额" required />
<span class="am-input-group-btn">
<button type="button" class="am-btn am-btn-default am-radius"></button>
</span>
</div>
<div class="am-alert" data-am-alert>
当前可用金额 <span class="cash-normal-mony">{{$user_wallet.normal_money}}</span>
</div>
</div>
<div class="am-form-group">
<label>收款银行<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_name" placeholder="收款银行" minlength="1" maxlength="60" data-validation-message="收款银行格式 1~60 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert>
强烈建议优先填写国有4大银行(中国银行、中国建设银行、中国工商银行和中国农业银行) 请填写详细的开户银行分行名称,虚拟账户如支付宝、财付通、微信 直接填写 支付宝 即可。
</div>
</div>
<div class="am-form-group">
<label>收款账号<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_accounts" placeholder="收款账号" minlength="1" maxlength="60" data-validation-message="收款账号格式 1~60 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert>
银行账号或虚拟账号(支付宝、财付通等账号)
</div>
</div>
<div class="am-form-group">
<label>开户人姓名<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="bank_username" placeholder="开户人姓名" minlength="1" maxlength="30" data-validation-message="开户人姓名格式 1~30 个字符之间" class="am-radius" required />
<div class="am-alert" data-am-alert>
收款账号的开户人姓名
</div>
</div>
<div class="am-form-group am-form-group-refreshing">
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">确认提现</button>
</div>
</form>
<!-- form end -->
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -45,11 +45,11 @@
<tr> <tr>
<td> <td>
<span>状态:</span> <span>状态:</span>
<select name="type" class="chosen-select" data-placeholder="操作类型..."> <select name="status" class="chosen-select" data-placeholder="提现状态...">
<option value="-1">操作类型...</option> <option value="-1">提现状态...</option>
{{if !empty($common_integral_log_type_list)}} {{if !empty($cash_status_list)}}
{{foreach $common_integral_log_type_list as $v}} {{foreach $cash_status_list as $v}}
<option value="{{$v.id}}" {{if isset($params['type']) and $params['type'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option> <option value="{{$v.value}}" {{if isset($params['status']) and $params['status'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}} {{/foreach}}
{{/if}} {{/if}}
</select> </select>
@ -68,22 +68,32 @@
<table class="am-table am-table-striped"> <table class="am-table am-table-striped">
<thead> <thead>
<tr> <tr>
<th>操作类型</th> <th>提现单号</th>
<th>提现金额(元)</th>
<th class="am-hide-sm-only">打款金额(元)</th>
<th>状态</th>
<th class="am-hide-sm-only">收款银行</th>
<th>收款账号</th>
<th class="am-hide-sm-only">开户人姓名</th>
<th class="am-hide-sm-only">描述</th> <th class="am-hide-sm-only">描述</th>
<th>原始积分</th> <th class="am-hide-sm-only">打款时间</th>
<th>最新积分</th> <th class="am-hide-sm-only">创建时间</th>
<th class="am-hide-sm-only">时间</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{if !empty($data_list)}} {{if !empty($data_list)}}
{{foreach $data_list as $v}} {{foreach $data_list as $v}}
<tr> <tr>
<td>{{$v.type_name}}</td> <td>{{$v.cash_no}}</td>
<td class="am-hide-sm-only">{{$v.msg}}</td> <td class="money-bold">{{$v.money}}</td>
<td>{{$v.original_integral}}</td> <td class="am-hide-sm-only money-bold money">{{if $v['pay_money'] gt 0}}{{$v.pay_money}}{{/if}}</td>
<td>{{$v.new_integral}}</td> <td>{{$v.status_text}}</td>
<td class="am-hide-sm-only">{{$v.add_time_time}}</td> <td class="am-hide-sm-only">{{$v.bank_name}}</td>
<td>{{$v.bank_accounts}}</td>
<td class="am-hide-sm-only">{{$v.bank_username}}</td>
<td class="am-hide-sm-only operation-msg">{{$v.msg}}</td>
<td class="am-hide-sm-only">{{$v.pay_time_text}}</td>
<td class="am-hide-sm-only">{{$v.add_time_text}}</td>
</tr> </tr>
{{/foreach}} {{/foreach}}
{{/if}} {{/if}}

View File

@ -15,7 +15,7 @@
<button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-icon-shield" data-am-modal="{target: '#plugins-recharge-pay-modal', width: 260, height: 130}"> 充值</button> <button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-icon-shield" data-am-modal="{target: '#plugins-recharge-pay-modal', width: 260, height: 130}"> 充值</button>
{{/if}} {{/if}}
{{if in_array($plugins_control, ['wallet', 'cash'])}} {{if in_array($plugins_control, ['wallet', 'cash'])}}
<a class="am-btn am-btn-success am-topbar-btn am-btn-sm am-icon-money"> 提现</a> <a href="{{:PluginsHomeUrl('wallet', 'cash', 'authinfo')}}" class="am-btn am-btn-success am-topbar-btn am-btn-sm am-icon-money"> 提现</a>
{{/if}} {{/if}}
</div> </div>
</ul> </ul>

View File

@ -44,7 +44,7 @@
<tr> <tr>
<th>充值单号</th> <th>充值单号</th>
<th>充值金额(元)</th> <th>充值金额(元)</th>
<th>支付金额(元)</th> <th class="am-hide-sm-only">支付金额(元)</th>
<th>状态</th> <th>状态</th>
<th class="am-hide-sm-only">支付方式</th> <th class="am-hide-sm-only">支付方式</th>
<th class="am-hide-sm-only">支付时间</th> <th class="am-hide-sm-only">支付时间</th>
@ -58,7 +58,7 @@
<tr id="data-list-{{$v.id}}"> <tr id="data-list-{{$v.id}}">
<td>{{$v.recharge_no}}</td> <td>{{$v.recharge_no}}</td>
<td class="money-bold">{{$v.money}}</td> <td class="money-bold">{{$v.money}}</td>
<td class="money">{{if $v['pay_money'] gt 0}}+{{$v.pay_money}}{{/if}}</td> <td class="am-hide-sm-only money-bold money">{{if $v['pay_money'] gt 0}}{{$v.pay_money}}{{/if}}</td>
<td>{{$v.status_text}}</td> <td>{{$v.status_text}}</td>
<td class="am-hide-sm-only">{{$v.payment_name}}</td> <td class="am-hide-sm-only">{{$v.payment_name}}</td>
<td class="am-hide-sm-only">{{$v.pay_time_text}}</td> <td class="am-hide-sm-only">{{$v.pay_time_text}}</td>

View File

@ -11,8 +11,8 @@
namespace app\plugins\wallet; namespace app\plugins\wallet;
use app\plugins\wallet\Common; use app\plugins\wallet\Common;
use app\plugins\wallet\BusinessService; use app\plugins\wallet\service\CashService;
use app\service\PluginsService; use app\plugins\wallet\service\BaseService;
/** /**
* 钱包 - 余额提现 * 钱包 - 余额提现
@ -47,15 +47,167 @@ class Cash extends Common
public function index($params = []) public function index($params = [])
{ {
// 参数 // 参数
$params = input();
$params['user'] = $this->user; $params['user'] = $this->user;
$this->assign('data_list', []); // 分页
$number = MyC('admin_page_number', 10, true);
// 条件
$where = BaseService::CashWhere($params);
// 获取总数
$total = BaseService::CashTotal($where);
// 分页
$page_params = array(
'number' => $number,
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'url' => PluginsHomeUrl('wallet', 'cash', 'index'),
);
$page = new \base\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
// 获取列表
$data_params = array(
'm' => $page->GetPageStarNumber(),
'n' => $number,
'where' => $where,
);
$data = BaseService::CashList($data_params);
$this->assign('data_list', $data['data']);
// 静态数据
$this->assign('cash_status_list', CashService::$cash_status_list);
// 参数 // 参数
$this->assign('params', $params); $this->assign('params', $params);
return $this->fetch('../../../plugins/view/wallet/cash/index'); return $this->fetch('../../../plugins/view/wallet/cash/index');
} }
/**
* 余额提现 - 安全验证
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-03-15T23:51:50+0800
* @param [array] $params [输入参数]
*/
public function authinfo($params = [])
{
// 手机号/邮箱
$check_account_list = [
['field' => 'mobile_security', 'value' => 'mobile', 'name' => '手机'],
['field' => 'email_security', 'value' => 'email','name' => '邮箱'],
];
$this->assign('check_account_list', $check_account_list);
// 参数
$this->assign('params', $params);
return $this->fetch('../../../plugins/view/wallet/cash/authinfo');
}
/**
* 余额提现 - 提现信息填写页面
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-03-15T23:51:50+0800
* @param [array] $params [输入参数]
*/
public function createinfo($params = [])
{
// 参数
$this->assign('params', $params);
return $this->fetch('../../../plugins/view/wallet/cash/createinfo');
}
/**
* 验证码显示
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $params [输入参数]
*/
public function verifyentry($params = [])
{
$params = array(
'width' => 100,
'height' => 28,
'use_point_back' => false,
'key_prefix' => 'wallet_cash',
);
$verify = new \base\Verify($params);
$verify->Entry();
}
/**
* 验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $params [输入参数]
*/
public function verifysend($params = [])
{
// 是否ajax请求
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 开始处理
$params['user'] = $this->user;
return CashService::VerifySend($params);
}
/**
* 验证码校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $params [输入参数]
*/
public function verifycheck($params = [])
{
// 是否ajax请求
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 开始处理
$params['user'] = $this->user;
return CashService::VerifyCheck($params);
}
/**
* 提现创建
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $params [输入参数]
*/
public function create($params = [])
{
// 是否ajax请求
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 开始处理
$params['user'] = $this->user;
return CashService::Create($params);
}
} }
?> ?>

View File

@ -59,17 +59,8 @@ class Common extends Controller
// 用户钱包 // 用户钱包
$user_wallet = WalletService::UserWallet($this->user['id']); $user_wallet = WalletService::UserWallet($this->user['id']);
// 用户钱包状态 // 用户钱包错误信息
$wallet_error = ''; $wallet_error = ($user_wallet['code'] == 0) ? '' : $user_wallet['msg'];
if(isset($user_wallet['code']) and $user_wallet['code'] == 0)
{
if(!isset($user_wallet['data']['status']) || $user_wallet['data']['status'] != 0)
{
$wallet_error = array_key_exists($user_wallet['data']['status'], WalletService::$wallet_status_list) ? '用户钱包[ '.WalletService::$wallet_status_list[$user_wallet['data']['status']]['name'].' ]' : '用户钱包状态异常错误';
}
} else {
$wallet_error = isset($user_wallet['msg']) ? $user_wallet['msg'] : '用户钱包异常错误';
}
$this->assign('wallet_error', $wallet_error); $this->assign('wallet_error', $wallet_error);
// 所有ajax请求校验用户钱包状态 // 所有ajax请求校验用户钱包状态

View File

@ -13,6 +13,7 @@ namespace app\plugins\wallet;
use app\plugins\wallet\Common; use app\plugins\wallet\Common;
use app\plugins\wallet\service\BaseService; use app\plugins\wallet\service\BaseService;
use app\plugins\wallet\service\PayService; use app\plugins\wallet\service\PayService;
use app\plugins\wallet\service\RechargeService;
/** /**
* 钱包 - 充值 * 钱包 - 充值
@ -102,7 +103,7 @@ class Recharge extends Common
// 用户 // 用户
$params['user'] = $this->user; $params['user'] = $this->user;
$params['user_wallet'] = $this->user_wallet; $params['user_wallet'] = $this->user_wallet;
return BaseService::RechargeCreate($params); return RechargeService::RechargeCreate($params);
} }
/** /**
@ -196,7 +197,7 @@ class Recharge extends Common
// 开始处理 // 开始处理
$params['user'] = $this->user; $params['user'] = $this->user;
return BaseService::RechargeDelete($params); return RechargeService::RechargeDelete($params);
} }
} }
?> ?>

View File

@ -12,7 +12,7 @@ namespace app\plugins\wallet;
use think\Controller; use think\Controller;
use app\plugins\wallet\service\WalletService; use app\plugins\wallet\service\WalletService;
use app\service\PluginsService; use app\plugins\wallet\service\BaseService;
/** /**
* 钱包插件 - 钱包管理 * 钱包插件 - 钱包管理
@ -37,10 +37,10 @@ class Walletadmin extends Controller
$number = MyC('admin_page_number', 10, true); $number = MyC('admin_page_number', 10, true);
// 条件 // 条件
$where = WalletService::WalletWhere($params); $where = BaseService::WalletWhere($params);
// 获取总数 // 获取总数
$total = WalletService::WalletTotal($where); $total = BaseService::WalletTotal($where);
// 分页 // 分页
$page_params = array( $page_params = array(
@ -61,7 +61,7 @@ class Walletadmin extends Controller
'n' => $number, 'n' => $number,
'where' => $where, 'where' => $where,
); );
$data = WalletService::WalletList($data_params); $data = BaseService::WalletList($data_params);
$this->assign('data_list', $data['data']); $this->assign('data_list', $data['data']);
} else { } else {
$this->assign('data_list', []); $this->assign('data_list', []);
@ -94,7 +94,7 @@ class Walletadmin extends Controller
'n' => 1, 'n' => 1,
'where' => ['id'=>intval($params['id'])], 'where' => ['id'=>intval($params['id'])],
); );
$ret = WalletService::WalletList($data_params); $ret = BaseService::WalletList($data_params);
if(!empty($ret['data'][0])) if(!empty($ret['data'][0]))
{ {
$data = $ret['data'][0]; $data = $ret['data'][0];

View File

@ -49,4 +49,27 @@ CREATE TABLE `s_plugins_wallet_log` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `wallet_id` (`wallet_id`), KEY `wallet_id` (`wallet_id`),
KEY `user_id` (`user_id`) KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包日志 - 应用' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包日志 - 应用';
# 钱包提现
CREATE TABLE `s_plugins_wallet_cash` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`wallet_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '钱包id',
`cash_no` char(60) NOT NULL DEFAULT '' COMMENT '提现单号',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态0未打款, 1已打款, 2打款失败',
`money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '提现金额',
`pay_money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '打款金额',
`bank_name` char(60) NOT NULL DEFAULT '' COMMENT '收款银行',
`bank_accounts` char(60) NOT NULL DEFAULT '' COMMENT '收款账号',
`bank_username` char(60) NOT NULL DEFAULT '' COMMENT '开户人姓名',
`msg` char(200) NOT NULL DEFAULT '' COMMENT '描述(用户可见)',
`pay_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '打款时间',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`upd_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `cash_no` (`cash_no`),
KEY `status` (`status`),
KEY `user_id` (`user_id`),
KEY `wallet_id` (`wallet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='钱包提现 - 应用';

View File

@ -11,11 +11,11 @@
namespace app\plugins\wallet\service; namespace app\plugins\wallet\service;
use think\Db; use think\Db;
use app\service\PluginsService;
use app\service\ResourcesService; use app\service\ResourcesService;
use app\service\PaymentService;
use app\plugins\wallet\service\WalletService; use app\plugins\wallet\service\WalletService;
use app\plugins\wallet\service\PayService; use app\plugins\wallet\service\PayService;
use app\plugins\wallet\service\CashService;
use app\plugins\wallet\service\RechargeService;
/** /**
* 基础服务层 * 基础服务层
@ -26,6 +26,131 @@ use app\plugins\wallet\service\PayService;
*/ */
class BaseService class BaseService
{ {
/**
* 钱包列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-30T00:13:14+0800
* @param [array] $params [输入参数]
*/
public static function WalletList($params = [])
{
$where = empty($params['where']) ? [] : $params['where'];
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
$field = empty($params['field']) ? '*' : $params['field'];
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
// 获取数据列表
$data = Db::name('PluginsWallet')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$wallet_status_list = WalletService::$wallet_status_list;
foreach($data as &$v)
{
// 用户信息
$v['user'] = self::GetUserInfo($v['user_id']);
// 状态
$v['status_text'] = (isset($v['status']) && isset($wallet_status_list[$v['status']])) ? $wallet_status_list[$v['status']]['name'] : '未知';
// 创建时间
$v['add_time_text'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
* 获取用户信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-05
* @desc description
* @param [int] $user_id [用户id]
*/
private static function GetUserInfo($user_id)
{
$user = Db::name('User')->field('username,nickname,mobile,email,avatar')->find($user_id);
if(!empty($user))
{
$user['user_name_view'] = $user['username'];
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['nickname'];
}
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['mobile'];
}
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['email'];
}
// 头像
if(!empty($user['avatar']))
{
$user['avatar'] = ResourcesService::AttachmentPathViewHandle($user['avatar']);
} else {
$user['avatar'] = config('shopxo.attachment_host').'/static/index/'.strtolower(config('DEFAULT_THEME', 'default')).'/images/default-user-avatar.jpg';
}
}
return $user;
}
/**
* 钱包总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
public static function WalletTotal($where = [])
{
return (int) Db::name('PluginsWallet')->where($where)->count();
}
/**
* 钱包条件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function WalletWhere($params = [])
{
$where = [];
// 用户
if(!empty($params['keywords']))
{
$user_ids = Db::name('User')->where('username|nickname|mobile|email', '=', $params['keywords'])->column('id');
if(!empty($user_ids))
{
$where[] = ['user_id', 'in', $user_ids];
} else {
// 无数据条件,避免用户搜索条件没有数据造成的错觉
$where[] = ['id', '=', 0];
}
}
// 状态
if(isset($params['status']) && $params['status'] > -1)
{
$where[] = ['status', '=', $params['status']];
}
return $where;
}
/** /**
* 充值列表 * 充值列表
* @author Devil * @author Devil
@ -61,13 +186,13 @@ class BaseService
} }
// 支付状态 // 支付状态
$v['status_text'] = isset($v['status']) ? PayService::$recharge_status_list[$v['status']]['name'] : ''; $v['status_text'] = isset($v['status']) ? RechargeService::$recharge_status_list[$v['status']]['name'] : '';
// 支付时间 // 支付时间
$v['pay_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']); $v['pay_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']);
// 创建时间 // 创建时间
$v['add_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']); $v['add_time_text'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
} }
} }
return DataReturn('处理成功', 0, $data); return DataReturn('处理成功', 0, $data);
@ -115,113 +240,6 @@ class BaseService
return $where; return $where;
} }
/**
* 充值订单创建
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function RechargeCreate($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user_wallet',
'error_msg' => '用户钱包有误',
],
[
'checked_type' => 'fun',
'key_name' => 'money',
'checked_data' => 'CheckPrice',
'error_msg' => '请输入有效的充值金额',
],
[
'checked_type' => 'min',
'key_name' => 'money',
'checked_data' => 0.01,
'error_msg' => '请输入大于0的充值金额',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 添加
$data = [
'recharge_no' => date('YmdHis').GetNumberCode(6),
'wallet_id' => $params['user_wallet']['id'],
'user_id' => $params['user']['id'],
'money' => PriceNumberFormat($params['money']),
'status' => 0,
'add_time' => time(),
];
$recharge_id = Db::name('PluginsWalletRecharge')->insertGetId($data);
if($recharge_id > 0)
{
return DataReturn('添加成功',0, [
'recharge_id' => $recharge_id,
'recharge_no' => $data['recharge_no'],
'money' => $data['money'],
]);
}
return DataReturn('添加失败', -100);
}
/**
* 充值纪录删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-14
* @desc description
* @param [array] $params [输入参数]
*/
public static function RechargeDelete($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '删除数据id有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 删除
$where = [
'id' => intval($params['id']),
'user_id' => $params['user']['id']
];
if(Db::name('PluginsWalletRecharge')->where($where)->delete())
{
return DataReturn('删除成功', 0);
}
return DataReturn('删除失败或资源不存在', -100);
}
/** /**
* 钱包明细列表 * 钱包明细列表
* @author Devil * @author Devil
@ -320,5 +338,103 @@ class BaseService
return $where; return $where;
} }
/**
* 提现列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-30T00:13:14+0800
* @param [array] $params [输入参数]
*/
public static function CashList($params = [])
{
$where = empty($params['where']) ? [] : $params['where'];
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
$field = empty($params['field']) ? '*' : $params['field'];
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
// 获取数据列表
$data = Db::name('PluginsWalletCash')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$common_gender_list = lang('common_gender_list');
foreach($data as &$v)
{
// 用户信息
if(!empty($v['user_id']))
{
$user = Db::name('User')->where(['id'=>$v['user_id']])->field('username,nickname,mobile,gender,avatar')->find();
$v['username'] = empty($user['username']) ? '' : $user['username'];
$v['nickname'] = empty($user['nickname']) ? '' : $user['nickname'];
$v['mobile'] = empty($user['mobile']) ? '' : $user['mobile'];
$v['avatar'] = empty($user['avatar']) ? '' : $user['avatar'];
$v['gender_text'] = isset($user['gender']) ? $common_gender_list[$user['gender']]['name'] : '';
}
// 提现状态
$v['status_text'] = isset($v['status']) ? CashService::$cash_status_list[$v['status']]['name'] : '';
// 备注
$v['msg'] = empty($v['msg']) ? '' : str_replace("\n", '<br />', $v['msg']);
// 打款时间
$v['pay_time_text'] = empty($v['pay_time']) ? '' : date('Y-m-d H:i:s', $v['pay_time']);
// 创建时间
$v['add_time_text'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
* 提现列表总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
public static function CashTotal($where = [])
{
return (int) Db::name('PluginsWalletCash')->where($where)->count();
}
/**
* 提现列表条件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function CashWhere($params = [])
{
$where = [];
// 用户id
if(!empty($params['user']))
{
$where[] = ['user_id', '=', $params['user']['id']];
}
// 关键字
if(!empty($params['keywords']))
{
$where[] = ['cash_no', '=', $params['keywords']];
}
// 状态
if(isset($params['status']) && $params['status'] > -1)
{
$where[] = ['status', '=', $params['status']];
}
return $where;
}
} }
?> ?>

View File

@ -0,0 +1,347 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\wallet\service;
use think\Db;
use app\service\MessageService;
use app\plugins\wallet\service\WalletService;
/**
* 提现服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class CashService
{
// 提现状态
public static $cash_status_list = [
0 => ['value' => 0, 'name' => '未打款', 'checked' => true],
1 => ['value' => 1, 'name' => '已打款'],
2 => ['value' => 2, 'name' => '打款失败'],
];
/**
* 验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-05T19:17:10+0800
* @param [array] $params [输入参数]
*/
public static function VerifySend($params = [])
{
// 数据验证
$p = [
[
'checked_type' => 'empty',
'key_name' => 'account_type',
'error_msg' => '身份认证方式有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 账户
if(empty($params['user'][$params['account_type']]))
{
return DataReturn('当前验证类型账号未绑定', -1);
}
// 验证码基础参数
$img_verify_params = array(
'key_prefix' => 'wallet_cash',
'expire_time' => MyC('common_verify_expire_time'),
'time_interval' => MyC('common_verify_time_interval'),
);
// 是否开启图片验证码
$verify = self::IsImaVerify($params, $img_verify_params);
if($verify['code'] != 0)
{
return $verify;
}
// 当前验证账户
$accounts = $params['user'][$params['account_type']];
// 发送验证码
$verify_params = array(
'key_prefix' => md5('wallet_cash_'.$accounts),
'expire_time' => MyC('common_verify_expire_time'),
'time_interval' => MyC('common_verify_time_interval'),
);
$code = GetNumberCode(6);
if($params['account_type'] == 'mobile')
{
$obj = new \base\Sms($verify_params);
$status = $obj->SendCode($accounts, $code, MyC('home_sms_user_mobile_binding'));
} else {
$obj = new \base\Email($verify_params);
$email_params = array(
'email' => $accounts,
'content' => MyC('home_email_user_email_binding'),
'title' => MyC('home_site_name').' - 账户安全认证',
'code' => $code,
);
$status = $obj->SendHtml($email_params);
}
// 状态
if($status)
{
// 清除验证码
if(isset($verify['data']) && is_object($verify['data']))
{
$verify['data']->Remove();
}
return DataReturn('发送成功', 0);
}
return DataReturn('发送失败'.'['.$obj->error.']', -100);
}
/**
* 是否开启图片验证码校验
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-22T15:48:31+0800
* @param [array] $params [输入参数]
* @param [array] $verify_params [配置参数]
* @return [object] [图片验证码类对象]
*/
private static function IsImaVerify($params, $verify_params)
{
if(MyC('home_img_verify_state') == 1)
{
if(empty($params['verify']))
{
return DataReturn('参数错误', -10);
}
$verify = new \base\Verify($verify_params);
if(!$verify->CheckExpire())
{
return DataReturn('验证码已过期', -11);
}
if(!$verify->CheckCorrect($params['verify']))
{
return DataReturn('验证码错误', -12);
}
return DataReturn('操作成功', 0, $verify);
}
return DataReturn('操作成功', 0);
}
/**
* 验证码校验
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-28T15:57:19+0800
* @param [array] $params [输入参数]
*/
public static function VerifyCheck($params = [])
{
// 数据验证
$p = [
[
'checked_type' => 'empty',
'key_name' => 'account_type',
'error_msg' => '身份认证方式有误',
],
[
'checked_type' => 'empty',
'key_name' => 'verify',
'error_msg' => '验证码不能为空',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 账户
if(empty($params['user'][$params['account_type']]))
{
return DataReturn('当前验证类型账号未绑定', -1);
}
// 当前验证账户
$accounts = $params['user'][$params['account_type']];
// 验证码校验
$verify_params = array(
'key_prefix' => md5('wallet_cash_'.$accounts),
'expire_time' => MyC('common_verify_expire_time')
);
if($params['account_type'] == 'mobile')
{
$obj = new \base\Sms($verify_params);
} else {
$obj = new \base\Email($verify_params);
}
// 是否已过期
if(!$obj->CheckExpire())
{
return DataReturn('验证码已过期', -10);
}
// 是否正确
if($obj->CheckCorrect($params['verify']))
{
// 校验成功标记
session('wallet_cash_'.$params['account_type'], true);
// 清除验证码
$obj->Remove();
return DataReturn('验证正确', 0);
}
return DataReturn('验证码错误', -11);
}
/**
* 提现创建
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $params [输入参数]
*/
public static function Create($params = [])
{
// 数据验证
$p = [
[
'checked_type' => 'empty',
'key_name' => 'money',
'error_msg' => '提现金额不能为空',
],
[
'checked_type' => 'length',
'key_name' => 'bank_name',
'checked_data' => '1,60',
'error_msg' => '收款银行格式 1~60 个字符之间',
],
[
'checked_type' => 'length',
'key_name' => 'bank_accounts',
'checked_data' => '1,60',
'error_msg' => '收款账号格式 1~60 个字符之间',
],
[
'checked_type' => 'length',
'key_name' => 'bank_username',
'checked_data' => '1,30',
'error_msg' => '开户人姓名格式 1~30 个字符之间',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 用户钱包
$user_wallet = WalletService::UserWallet($params['user']['id']);
if($user_wallet['code'] != 0)
{
return $user_wallet;
}
// 提现金额
$money = PriceNumberFormat($params['money']);
if($money > $user_wallet['data']['normal_money'])
{
return DataReturn('提现金额不能大于有效金额', -1);
}
// 开始处理
Db::startTrans();
// 添加提现数据
$data = [
'cash_no' => date('YmdHis').GetNumberCode(6),
'user_id' => $user_wallet['data']['user_id'],
'wallet_id' => $user_wallet['data']['id'],
'status' => 0,
'money' => $money,
'bank_name' => $params['bank_name'],
'bank_accounts' => $params['bank_accounts'],
'bank_username' => $params['bank_username'],
'add_time' => time(),
];
$cash_id = Db::name('PluginsWalletCash')->insertGetId($data);
if($cash_id <= 0)
{
Db::rollback();
return DataReturn('提现操作失败', -100);
}
// 钱包更新
$wallet_data = [
'normal_money' => PriceNumberFormat($user_wallet['data']['normal_money']-$money),
'upd_time' => time(),
];
if(!Db::name('PluginsWallet')->where(['id'=>$user_wallet['data']['id']])->update($wallet_data))
{
Db::rollback();
return DataReturn('钱包操作失败', -100);
}
// 日志
$log_data = [
'user_id' => $user_wallet['data']['user_id'],
'wallet_id' => $user_wallet['data']['id'],
'business_type' => 2,
'operation_type' => 0,
'money_type' => 0,
'operation_money' => $money,
'original_money' => $user_wallet['data']['normal_money'],
'latest_money' => $wallet_data['normal_money'],
];
$log_data['msg'] = '用户提现申请[ 减少有效金额'.$log_data['operation_money'].'元 ]';
if(!WalletService::WalletLogInsert($log_data))
{
Db::rollback();
return DataReturn('日志添加失败', -101);
}
// 消息通知
MessageService::MessageAdd($user_wallet['data']['user_id'], '账户余额变动', $log_data['msg'], 0, $cash_id);
// 提交事务
Db::commit();
return DataReturn('操作成功', 0);
}
}
?>

View File

@ -16,6 +16,7 @@ use app\service\PayLogService;
use app\service\MessageService; use app\service\MessageService;
use app\service\PluginsService; use app\service\PluginsService;
use app\plugins\wallet\service\WalletService; use app\plugins\wallet\service\WalletService;
use app\plugins\wallet\service\RechargeService;
/** /**
* 支付服务层 * 支付服务层
@ -26,12 +27,6 @@ use app\plugins\wallet\service\WalletService;
*/ */
class PayService class PayService
{ {
// 充值支付状态
public static $recharge_status_list = [
0 => ['value' => 0, 'name' => '未支付', 'checked' => true],
1 => ['value' => 1, 'name' => '已支付'],
];
/** /**
* 支付 * 支付
* @author Devil * @author Devil
@ -299,7 +294,7 @@ class PayService
} }
if($params['recharge']['status'] > 0) if($params['recharge']['status'] > 0)
{ {
$status_text = self::$recharge_status_list[$params['recharge']['status']]['name']; $status_text = RechargeService::$recharge_status_list[$params['recharge']['status']]['name'];
return DataReturn('状态不可操作['.$status_text.']', 0); return DataReturn('状态不可操作['.$status_text.']', 0);
} }
@ -409,7 +404,7 @@ class PayService
} }
// 消息通知 // 消息通知
MessageService::MessageAdd($params['recharge']['user_id'], '账户充值', $log_data['msg'], 2, $params['recharge']['id']); MessageService::MessageAdd($params['recharge']['user_id'], '账户余额变动', $log_data['msg'], 2, $params['recharge']['id']);
} }
} }

View File

@ -0,0 +1,137 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\wallet\service;
use think\Db;
/**
* 充值服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class RechargeService
{
// 充值支付状态
public static $recharge_status_list = [
0 => ['value' => 0, 'name' => '未支付', 'checked' => true],
1 => ['value' => 1, 'name' => '已支付'],
];
/**
* 充值订单创建
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function RechargeCreate($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user_wallet',
'error_msg' => '用户钱包有误',
],
[
'checked_type' => 'fun',
'key_name' => 'money',
'checked_data' => 'CheckPrice',
'error_msg' => '请输入有效的充值金额',
],
[
'checked_type' => 'min',
'key_name' => 'money',
'checked_data' => 0.01,
'error_msg' => '请输入大于0的充值金额',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 添加
$data = [
'recharge_no' => date('YmdHis').GetNumberCode(6),
'wallet_id' => $params['user_wallet']['id'],
'user_id' => $params['user']['id'],
'money' => PriceNumberFormat($params['money']),
'status' => 0,
'add_time' => time(),
];
$recharge_id = Db::name('PluginsWalletRecharge')->insertGetId($data);
if($recharge_id > 0)
{
return DataReturn('添加成功',0, [
'recharge_id' => $recharge_id,
'recharge_no' => $data['recharge_no'],
'money' => $data['money'],
]);
}
return DataReturn('添加失败', -100);
}
/**
* 充值纪录删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-14
* @desc description
* @param [array] $params [输入参数]
*/
public static function RechargeDelete($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '删除数据id有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 删除
$where = [
'id' => intval($params['id']),
'user_id' => $params['user']['id']
];
if(Db::name('PluginsWalletRecharge')->where($where)->delete())
{
return DataReturn('删除成功', 0);
}
return DataReturn('删除失败或资源不存在', -100);
}
}
?>

View File

@ -53,131 +53,6 @@ class WalletService
2 => ['value' => 2, 'name' => '赠送'], 2 => ['value' => 2, 'name' => '赠送'],
]; ];
/**
* 钱包列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-30T00:13:14+0800
* @param [array] $params [输入参数]
*/
public static function WalletList($params = [])
{
$where = empty($params['where']) ? [] : $params['where'];
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
$field = empty($params['field']) ? '*' : $params['field'];
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
// 获取数据列表
$data = Db::name('PluginsWallet')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$wallet_status_list = WalletService::$wallet_status_list;
foreach($data as &$v)
{
// 用户信息
$v['user'] = self::GetUserInfo($v['user_id']);
// 状态
$v['status_text'] = (isset($v['status']) && isset($wallet_status_list[$v['status']])) ? $wallet_status_list[$v['status']]['name'] : '未知';
// 创建时间
$v['add_time_text'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
* 获取用户信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-05
* @desc description
* @param [int] $user_id [用户id]
*/
private static function GetUserInfo($user_id)
{
$user = Db::name('User')->field('username,nickname,mobile,email,avatar')->find($user_id);
if(!empty($user))
{
$user['user_name_view'] = $user['username'];
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['nickname'];
}
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['mobile'];
}
if(empty($user['user_name_view']))
{
$user['user_name_view'] = $user['email'];
}
// 头像
if(!empty($user['avatar']))
{
$user['avatar'] = ResourcesService::AttachmentPathViewHandle($user['avatar']);
} else {
$user['avatar'] = config('shopxo.attachment_host').'/static/index/'.strtolower(config('DEFAULT_THEME', 'default')).'/images/default-user-avatar.jpg';
}
}
return $user;
}
/**
* 钱包总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
public static function WalletTotal($where = [])
{
return (int) Db::name('PluginsWallet')->where($where)->count();
}
/**
* 钱包条件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function WalletWhere($params = [])
{
$where = [];
// 用户
if(!empty($params['keywords']))
{
$user_ids = Db::name('User')->where('username|nickname|mobile|email', '=', $params['keywords'])->column('id');
if(!empty($user_ids))
{
$where[] = ['user_id', 'in', $user_ids];
} else {
// 无数据条件,避免用户搜索条件没有数据造成的错觉
$where[] = ['id', '=', 0];
}
}
// 状态
if(isset($params['status']) && $params['status'] > -1)
{
$where[] = ['status', '=', $params['status']];
}
return $where;
}
/** /**
* 用户钱包 * 用户钱包
* @author Devil * @author Devil
@ -207,13 +82,43 @@ class WalletService
$wallet_id = Db::name('PluginsWallet')->insertGetId($data); $wallet_id = Db::name('PluginsWallet')->insertGetId($data);
if($wallet_id > 0) if($wallet_id > 0)
{ {
$wallet = Db::name('PluginsWallet')->find($wallet_id); return DataReturn('操作成功', 0, Db::name('PluginsWallet')->find($wallet_id));
} else { } else {
return DataReturn('钱包添加失败', -100); return DataReturn('钱包添加失败', -100);
} }
} else {
return self::UserWalletStatusCheck($wallet);
}
}
/**
* 用户钱包状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-08
* @desc description
* @param [array] $user_wallet [用户钱包]
*/
public static function UserWalletStatusCheck($user_wallet)
{
// 用户钱包状态
$wallet_error = '';
if(isset($user_wallet['status']))
{
if($user_wallet['status'] != 0)
{
$wallet_error = array_key_exists($user_wallet['status'], self::$wallet_status_list) ? '用户钱包[ '.self::$wallet_status_list[$user_wallet['status']]['name'].' ]' : '用户钱包状态异常错误';
}
} else {
$wallet_error = '用户钱包异常错误';
} }
return DataReturn('操作成功', 0, $wallet); if(!empty($wallet_error))
{
return DataReturn($wallet_error, -30);
}
return DataReturn('操作成功', 0, $user_wallet);
} }
/** /**

File diff suppressed because one or more lines are too long

View File

@ -233,9 +233,29 @@ ul.plug-file-upload-view-video li {
/** /**
* 覆盖框架样式 * 覆盖框架样式
*/ */
.am-alert {
background: #f1faff;
border: 1px solid #e2f5ff;
color: #1490d2;
}
.am-alert-danger {
background-color: #fff1f0;
border-color: #ffe4e3;
color: #dd514c;
}
.am-alert-secondary {
background-color: #f6f6f6;
border-color: #efefef;
color: #666;
}
.am-alert-success {
background-color: #eef7ea;
border-color: #e3f3d6;
color: #468847;
}
.am-alert-warning { .am-alert-warning {
background-color: #ffeee1; background-color: #fff7f1;
border-color: #f9e4d3; border-color: #fff0e4;
color: #f37b1d; color: #f37b1d;
} }
.am-input-radius input.am-form-field { .am-input-radius input.am-form-field {

View File

@ -738,12 +738,6 @@ img.common-user-icon {
vertical-align: middle; vertical-align: middle;
} }
/**
* 用户中心
*/
.user-content-body {-webkit-box-flex:1;-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto; overflow: hidden; }
/** /**
* 用户中心左侧菜单 * 用户中心左侧菜单
*/ */

View File

@ -11,6 +11,7 @@
.user-content-body #verify-win .am-modal-bd { margin-top: 10px; } .user-content-body #verify-win .am-modal-bd { margin-top: 10px; }
.user-content-body #verify-win .am-modal-bd .base { overflow: hidden; } .user-content-body #verify-win .am-modal-bd .base { overflow: hidden; }
.user-content-body #verify-win .am-modal-bd .base .verify-tips { font-size: 12px; } .user-content-body #verify-win .am-modal-bd .base .verify-tips { font-size: 12px; }
.user-content-body #verify-img { vertical-align: middle; }
.user-content-body legend { .user-content-body legend {
padding-bottom: 0.2rem; padding-bottom: 0.2rem;

View File

@ -0,0 +1,47 @@
/**
* 操作提示
*/
.user-content-body .wallet-cash-auth-tips .title {
font-weight: 500;
font-size: 16px;
margin-bottom: 2px;
}
.user-content-body .wallet-cash-auth-tips ul li {
color: #486d48;
line-height: 24px;
}
.user-content-body .wallet-cash-auth-tips ul li a {
color: #0085ef;
text-decoration: underline;
}
/**
* 弹窗图片验证码
*/
.user-content-body .verify-submit-win, .user-content-body .verify-submit-win-new { margin-top: 20px; display: block; }
.user-content-body .reg-switch-tips { font-weight: 100; font-size: 12px; color: #f87689; margin-left: 20px; }
.user-content-body #verify-win .am-modal-bd { margin-top: 10px; }
.user-content-body #verify-win .am-modal-bd .base { overflow: hidden; }
.user-content-body #verify-win .am-modal-bd .base .verify-tips { font-size: 12px; }
.user-content-body #verify-img { vertical-align: middle; }
/**
* 提现可用金额
*/
.user-content-body form.create-info .am-alert {
color: #90cae9;
}
.user-content-body form.create-info .cash-normal-mony {
font-weight: 700;
color: #55b35a;
}
.user-content-body form.create-info .am-form-group:hover .am-alert {
color: #1490d2;
}
/**
* 列表
*/
.user-content-body .data-list .operation-msg {
width: 20%;
}

View File

@ -74,8 +74,6 @@
* 账户信息 * 账户信息
*/ */
.user-content-body .am-alert-secondary { .user-content-body .am-alert-secondary {
background-color: #f6f6f6;
border-color: #ececec;
margin-bottom: 20px; margin-bottom: 20px;
} }
.user-content-body .normal .integral-value { .user-content-body .normal .integral-value {

View File

@ -0,0 +1,108 @@
$(function()
{
$verify_win = $('#verify-win');
// 原帐号验证码发送
$('.verify-submit, .verify-submit-win').on('click', function()
{
// 是否选择验证账号类型
var $account_type_tag = $('form.form-validation select[name="account_type"]');
var account_type = $account_type_tag.val() || null;
if(account_type == null)
{
$account_type_tag.trigger('change');
Prompt($account_type_tag.data('validation-message'));
return false;
}
// 图片验证码校验
var $this = $(this);
var $verify = $('#verify-img-value');
var verify = '';
// 是否需要先校验图片验证码
if($this.data('verify') == 1)
{
// 开启图片验证码窗口
$verify_win.modal('open');
$verify.focus();
return false;
}
// 验证码窗口操作按钮则更新按钮对象
var is_win = $(this).data('win');
if(is_win == 1)
{
$this = $('.verify-submit');
// 验证码参数处理
verify = $verify.val().replace(/\s+/g, '');
if(verify.length < 6)
{
Prompt($verify.data('validation-message'));
$verify.focus();
return false;
}
}
// 验证码时间间隔
var time_count = parseInt($this.data('time'));
// 按钮交互
$this.button('loading');
if(is_win == 1)
{
$('.verify-submit-win').button('loading');
}
// 发送验证码
$.ajax({
url:$('.verify-submit').data('url'),
type:'POST',
data:{"verify":verify, "account_type":account_type},
dataType:'json',
success:function(result)
{
if(result.code == 0)
{
var intervalid = setInterval(function()
{
if(time_count == 0)
{
$this.button('reset');
if(is_win == 1)
{
$('.verify-submit-win').button('reset');
}
$this.text($this.data('text'));
$verify.val('');
clearInterval(intervalid);
} else {
var send_msg = $this.data('send-text').replace(/{time}/, time_count--);
$this.text(send_msg);
}
}, 1000);
$verify_win.modal('close');
} else {
$this.button('reset');
if(is_win == 1)
{
$('.verify-submit-win').button('reset');
}
Prompt(result.msg);
}
},
error:function()
{
$this.button('reset');
if(is_win == 1)
{
$('.verify-submit-win').button('reset');
}
Prompt('网络错误');
}
});
});
});