更新农科后台数据添加编辑,优化之前遗留问题
This commit is contained in:
parent
79a8ab55a0
commit
e6a7e01101
@ -35,11 +35,15 @@ class SupplyAccount extends BaseController
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = [];
|
||||
|
||||
$list = $this->model->getSupplyAccountList($where,$param);
|
||||
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||
|
||||
$list = SupplyAccountModel::with('team')->where($where)
|
||||
->paginate($rows, false, ['query' => $param]);
|
||||
|
||||
foreach ($list as $k =>$v){
|
||||
$list[$k]['fa_supply_team_id'] = Db::table('fa_supply_team')->where('id',$v['fa_supply_team_id'])->value('name');
|
||||
}
|
||||
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
@ -62,11 +66,25 @@ class SupplyAccount extends BaseController
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
|
||||
$this->model->addSupplyAccount($param);
|
||||
|
||||
// 如果存在,则更新
|
||||
if(SupplyAccountModel::where('fa_supply_team_id', $this->uid)->find())
|
||||
{
|
||||
$param['fa_supply_team_id'] = $this->uid; // 供应链服务小组ID
|
||||
$this->model->updateSupplyAccount($param);
|
||||
|
||||
}else{ // 不存在,则创建新的提现账户
|
||||
|
||||
$param['fa_supply_team_id'] = $this->uid; // 供应链服务小组ID
|
||||
$this->model->addSupplyAccount($param);
|
||||
}
|
||||
|
||||
}else{
|
||||
$team = Db::table('fa_supply_team')->select();
|
||||
View::assign('team', $team);
|
||||
|
||||
// 获取当前账号提现信息
|
||||
$account = SupplyAccountModel::where('fa_supply_team_id', $this->uid)->find();
|
||||
View::assign('account', $account);
|
||||
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,43 @@ class Extract extends BaseController
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = get_params();
|
||||
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
// 撤销提现,更新状态
|
||||
$status = SupplyExtract::where('id', $params['id'])->update(['status' => 3]);
|
||||
|
||||
// 返回提现金额
|
||||
if($status)
|
||||
{
|
||||
// 申请提现的金额
|
||||
$extractInfo = SupplyExtract::where('id', $params['id'])->find();
|
||||
$extract_price = $extractInfo['extract_price'];
|
||||
$fa_supply_team_id = $extractInfo['fa_supply_team_id'];
|
||||
|
||||
if($extract_price)
|
||||
{
|
||||
// 返还提现余额
|
||||
SupplyTeam::where('id', $fa_supply_team_id)
|
||||
->inc('brokerage', $extract_price)
|
||||
->update();
|
||||
}
|
||||
}
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
|
||||
return to_assign(1, '操作失败,原因:' . $e->getMessage());
|
||||
}
|
||||
|
||||
return to_assign(0, '操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,16 @@ class SupplyAccount extends Model
|
||||
// 设置当前模型对应的完整数据表名称
|
||||
protected $table = 'fa_supply_account';
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取关联小组
|
||||
*
|
||||
*/
|
||||
public function team()
|
||||
{
|
||||
return $this->hasOne(SupplyTeam::class, 'id', 'fa_supply_team_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
@ -45,16 +55,17 @@ class SupplyAccount extends Model
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function editSupplyAccount($param)
|
||||
public function updateSupplyAccount($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
$param['update_time'] = time();
|
||||
self::where('fa_supply_team_id', $param['fa_supply_team_id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['fa_supply_team_id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,22 +11,16 @@ use think\Validate;
|
||||
class SupplyAccountValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'account' => 'require',
|
||||
'name' => 'require',
|
||||
'bank' => 'require',
|
||||
'amount' => 'require',
|
||||
'balance' => 'require',
|
||||
'free_balance' => 'require',
|
||||
'fa_supply_team_id' => 'require',
|
||||
];
|
||||
'account' => 'require',
|
||||
'name' => 'require',
|
||||
'bank' => 'require',
|
||||
'bank_address' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'account.require' => '账号不能为空',
|
||||
'name.require' => '用户名不能为空',
|
||||
'bank.require' => '开户行不能为空',
|
||||
'amount.require' => '已提现金额不能为空',
|
||||
'balance.require' => '账户余额不能为空',
|
||||
'free_balance.require' => '冻结余额不能为空',
|
||||
'fa_supply_team_id.require' => '所属后台供应链团队ID不能为空',
|
||||
'account.require' => '账号不能为空',
|
||||
'name.require' => '用户名不能为空',
|
||||
'bank.require' => '开户银行不能为空',
|
||||
'bank_address.require' => '开户地址不能为空',
|
||||
];
|
||||
}
|
@ -1,36 +1,64 @@
|
||||
{extend name="common/base"/}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<form class="layui-form p-4">
|
||||
<h3 class="pb-3">新建提现账户信息</h3>
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr><td class="layui-td-gray-2">账号<font>*</font></td>
|
||||
<td><input type="text" name="account" lay-verify="required" lay-reqText="请完善账号" value="" autocomplete="off" placeholder="请输入账号" class="layui-input"></td><td class="layui-td-gray-2">用户名<font>*</font></td>
|
||||
<td><input type="text" name="name" lay-verify="required" lay-reqText="请完善用户名" value="" autocomplete="off" placeholder="请输入用户名" class="layui-input"></td><td class="layui-td-gray-2">开户行<font>*</font></td>
|
||||
<td><input type="text" name="bank" lay-verify="required" lay-reqText="请完善开户行" value="" autocomplete="off" placeholder="请输入开户行" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr><td class="layui-td-gray-2">已提现金额<font>*</font></td>
|
||||
<td><input type="text" name="amount" lay-verify="required" lay-reqText="请完善已提现金额" value="" autocomplete="off" placeholder="请输入已提现金额" class="layui-input"></td><td class="layui-td-gray-2">账户余额<font>*</font></td>
|
||||
<td><input type="text" name="balance" lay-verify="required" lay-reqText="请完善账户余额" value="" autocomplete="off" placeholder="请输入账户余额" class="layui-input"></td><td class="layui-td-gray-2">冻结余额<font>*</font></td>
|
||||
<td><input type="text" name="free_balance" lay-verify="required" lay-reqText="请完善冻结余额" value="" autocomplete="off" placeholder="请输入冻结余额" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr><td class="layui-td-gray-2">所属后台供应链团队ID<font>*</font></td>
|
||||
<td>
|
||||
<select name="fa_supply_team_id" lay-verify="required" lay-reqText="请完善所属后台供应链团队ID">
|
||||
<option value="">请选择</option>
|
||||
{volist name='team' id='vo'}
|
||||
<option value="{$vo.id}" >{$vo.name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td><td colspan='4'></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="pt-3">
|
||||
<input type="hidden" name="id" value="0"/>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
{if condition="$account"}
|
||||
<form class="layui-form p-4">
|
||||
<h3 class="pb-3">提现账户信息</h3>
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">用户名<font>*</font></td>
|
||||
<td colspan="2"><input type="text" name="name" value="{$account.name}" lay-verify="required" lay-reqText="请完善用户名" value="" autocomplete="off" placeholder="请输入用户名" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">账号<font>*</font></td>
|
||||
<td><input type="text" name="account" value="{$account.account}" lay-verify="required" lay-reqText="请完善账号" value="" autocomplete="off" placeholder="请输入账号" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">开户银行<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="bank" value="{$account.bank}" lay-verify="required" lay-reqText="请完善开户行" value="" autocomplete="off" placeholder="请输入开户银行" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">开户银行地址<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="bank_address" value="{$account.bank_address}" lay-verify="required" lay-reqText="请完善开户银行地址" value="" autocomplete="off" placeholder="请输入开户银行" class="layui-input"></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div class="pt-3">
|
||||
<input type="hidden" name="id" value="0"/>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
{else/}
|
||||
<form class="layui-form p-4">
|
||||
<h3 class="pb-3">提现账户信息</h3>
|
||||
<table class="layui-table layui-table-form">
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">用户名<font>*</font></td>
|
||||
<td colspan="2"><input type="text" name="name" lay-verify="required" lay-reqText="请完善用户名" value="" autocomplete="off" placeholder="请输入用户名" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">账号<font>*</font></td>
|
||||
<td><input type="text" name="account" lay-verify="required" lay-reqText="请完善账号" value="" autocomplete="off" placeholder="请输入账号" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">开户银行<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="bank" lay-verify="required" lay-reqText="请完善开户行" value="" autocomplete="off" placeholder="请输入开户银行" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray-2">开户银行地址<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="bank_address" lay-verify="required" lay-reqText="请完善开户银行地址" value="" autocomplete="off" placeholder="请输入开户银行" class="layui-input"></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div class="pt-3">
|
||||
<input type="hidden" name="id" value="0"/>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
{/block}
|
||||
<!-- /主体 -->
|
||||
|
||||
|
@ -9,12 +9,14 @@
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
|
||||
</form>
|
||||
|
||||
<table class="layui-hide" id="supply_account" lay-filter="supply_account"></table>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加供应链团队角色提现账户信息">+ 添加供应链团队角色提现账户信息</span>
|
||||
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加提现账户">+ 添加提现账户</span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
@ -47,50 +49,81 @@
|
||||
title: '编号',
|
||||
align: 'center',
|
||||
width: 80
|
||||
},{
|
||||
field: 'fa_supply_team_id',
|
||||
title: '所属小组服务',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
templet: function (d)
|
||||
{
|
||||
if(d.team)
|
||||
{
|
||||
return d.team.name;
|
||||
}
|
||||
|
||||
return '数据错误';
|
||||
}
|
||||
},{
|
||||
field: 'account',
|
||||
title: '账号',
|
||||
align: 'center',
|
||||
width: 100
|
||||
width: 150
|
||||
},{
|
||||
field: 'name',
|
||||
title: '用户名',
|
||||
align: 'center',
|
||||
width: 100
|
||||
width: 150
|
||||
},{
|
||||
field: 'bank',
|
||||
title: '开户行',
|
||||
align: 'center',
|
||||
width: 100
|
||||
width: 150
|
||||
},{
|
||||
field: 'amount',
|
||||
field: 'bank_address',
|
||||
title: '开户行地址',
|
||||
align: 'center',
|
||||
width: 250
|
||||
},{
|
||||
field: 'withdraw_brokerage',
|
||||
title: '已提现金额',
|
||||
align: 'center',
|
||||
width: 100
|
||||
templet: function (d)
|
||||
{
|
||||
if(d.team)
|
||||
{
|
||||
return d.team.withdraw_brokerage;
|
||||
}
|
||||
|
||||
return '0.00';
|
||||
}
|
||||
},{
|
||||
field: 'balance',
|
||||
field: 'brokerage',
|
||||
title: '账户余额',
|
||||
align: 'center',
|
||||
width: 100
|
||||
templet: function (d)
|
||||
{
|
||||
if(d.team)
|
||||
{
|
||||
return d.team.brokerage;
|
||||
}
|
||||
|
||||
return '0.00';
|
||||
}
|
||||
},{
|
||||
field: 'free_balance',
|
||||
field: 'free_brokerage',
|
||||
title: '冻结余额',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'fa_supply_team_id',
|
||||
title: '所属后台供应链团队ID',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
fixed: 'right',
|
||||
field: 'right',
|
||||
title: '操作',
|
||||
toolbar: '#barDemo',
|
||||
width: 136,
|
||||
align: 'center'
|
||||
}
|
||||
templet: function (d)
|
||||
{
|
||||
if(d.team)
|
||||
{
|
||||
return d.team.free_brokerage;
|
||||
}
|
||||
|
||||
return '0.00';
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
@ -13,7 +13,7 @@
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="status">
|
||||
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close }}"></i>
|
||||
</script>
|
||||
<script type="text/html" id="is_home">
|
||||
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||
@ -32,7 +32,7 @@
|
||||
<script type="text/html" id="barDemo">
|
||||
<div class="layui-btn-group">
|
||||
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">撤销</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs {{# if(d.status != 0){ }}layui-hide{{# } }}" lay-event="cancel">撤销</a>
|
||||
{/if}
|
||||
</div>
|
||||
</script>
|
||||
@ -75,12 +75,12 @@
|
||||
field: 'uid',
|
||||
title: '用户UID',
|
||||
align: 'center',
|
||||
width:120,
|
||||
width: 260,
|
||||
templet: function (d)
|
||||
{
|
||||
if(d.user)
|
||||
{
|
||||
return d.user;
|
||||
return '昵称:' + d.user.nickname + '手机号:' + d.user.phone;
|
||||
}
|
||||
|
||||
return '数据错误';
|
||||
@ -145,6 +145,9 @@
|
||||
case 1:
|
||||
return '提现完成';
|
||||
break;
|
||||
case 3:
|
||||
return '撤销提现';
|
||||
break;
|
||||
}
|
||||
}
|
||||
},{
|
||||
@ -159,7 +162,12 @@
|
||||
return d.adminUser;
|
||||
}
|
||||
|
||||
return '数据错误';
|
||||
if(d.status == 0)
|
||||
{
|
||||
return '等待审核';
|
||||
}
|
||||
|
||||
return '无';
|
||||
}
|
||||
},{
|
||||
field: 'fail_msg',
|
||||
@ -192,11 +200,22 @@
|
||||
|
||||
//监听表格行工具事件
|
||||
table.on('tool(article)', function(obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
tool.side('{$url[2]}?id='+obj.data.id);
|
||||
}
|
||||
|
||||
if (obj.event === 'cancel') {
|
||||
|
||||
layer.confirm('确定要撤销提现吗?', {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function(index) {
|
||||
let callback = function (e) {
|
||||
layer.msg(e.msg);
|
||||
window.location.reload()
|
||||
}
|
||||
tool.delete('{$url[2]}', { id: obj.data.id }, callback);
|
||||
layer.close(index);
|
||||
});
|
||||
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
||||
<div class="layui-col-md4">
|
||||
<label class="layui-form-label">分润比例<font>*</font></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="shareRate" required lay-verify="required" placeholder="{$detail.shareRate}" autocomplete="off" class="layui-input">
|
||||
<input type="text" name="shareRate" required lay-verify="required" value="{$detail.shareRate}" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user