Commit 49b6a28c by 杨树贤

审核通过后需要对剩余金额进行更新以及批量审核

parent 83ce91a8
......@@ -9,7 +9,9 @@ use App\Http\Services\UserIntegralService;
use App\Http\Transformers\UserExchangeTransformer;
use App\Http\Transformers\UserIntegralTransformer;
use Illuminate\Http\Request;
use function GuzzleHttp\Promise\all;
//用户兑换接口
class UserExchangesApiController extends Controller
{
private $service;
......@@ -21,7 +23,7 @@ class UserExchangesApiController extends Controller
$this->transformer = $transformer;
}
//用户兑换列表
public function userExchangeListApi(Request $request)
{
$params = $this->getListParams($request);
......@@ -34,6 +36,7 @@ class UserExchangesApiController extends Controller
]);
}
//用户兑换列表(单个用户)
public function userExchangeBillListApi(Request $request)
{
$data = $this->service->getUserExchangeList($request->all());
......@@ -45,6 +48,7 @@ class UserExchangesApiController extends Controller
]);
}
//获取请求参数
private function getListParams(Request $request)
{
//因为数据库没有存mobile,所以要根据mobile去获取userId
......@@ -58,19 +62,35 @@ class UserExchangesApiController extends Controller
return $params;
}
public function changeUserExchangeStatusApi(Request $request)
//审核用户兑换接口
public function auditUserExchangeApi(Request $request)
{
$id = $request->id;
$status = $request->status;
$result = $this->service->changeUserExchangeStatus($id, ['status' => $status]);
$data = [
'status' => $request->status,
'user_id' => $request->user_id,
'audit_id' => $request->user->userId,
'audit_reason' => $request->audit_reason,
'audit_email' => $request->user->email,
'exchange_amount' => $request->exchange_amount,
];
$result = $this->service->auditUserExchange($id, $data);
return $result;
}
//批量审核用户接口
public function batchUpdateStatusApi(Request $request)
{
$path = '/user_exchanges/batchUpdateStatus';
$result = $this->service->batchUpdateStatus($path, $request->all());
$path = '/user_exchanges/batchAuditReject';
$data = [
'ids' => $request->ids,
'status' => $request->status,
'audit_id' => $request->user->userId,
'audit_reason' => $request->audit_reason,
'audit_email' => $request->user->email,
];
$result = $this->service->batchAuditReject($path, $data);
return $result;
}
......
......@@ -67,11 +67,14 @@ class UserExchangesController extends Controller
$this->data['title'] = '审核用户兑换';
//获得该次申请的详情
$userExchange = $this->service->getUserExchange($request->user_id);
$userExchange = $this->service->getUserExchange($request->id);
//获取到user_id对应的电话号码给后台页面显示出来
$user = $this->service->getUser($request->user_id);
$userExchange['data']['mobile'] = $user['mobile'];
$this->data['audit_id'] = $request->user->userId;
$this->data['audit_name'] = $request->user->name;
$this->data['mobile'] = $user['mobile'];
//显示当前谁在审核
$this->data['audit_email'] = $request->user->email;
$this->data['user_exchange'] = $userExchange['data'];
return $this->view();
......
......@@ -15,8 +15,8 @@ class BaseService
public function __construct()
{
$this->client = new Client([
'base_uri' => '192.168.10.10:61009',
// 'base_uri' => 'http://ic_server_welfare.test',
// 'base_uri' => '192.168.10.10:61009',
'base_uri' => 'http://ic_server_welfare.test',
'timeout' => 20,
]);
}
......
......@@ -18,16 +18,23 @@ class UserExchangeService extends BaseService
public function getUserExchangeList($params)
{
$path = '/user_exchanges/list?' . http_build_query($params);
return $this->apiPost($path);
}
public function changeUserExchangeStatus($id, $data = [])
public function auditUserExchange($id, $data = [])
{
$path = 'user_exchanges/audit?id=' . $id;
return $this->apiPost($path, $data);
}
public function batchAuditReject($path, $data = [])
{
$path = 'user_exchanges/update?id=' . $id;
return $this->apiPost($path, $data);
}
public function batchUpdateStatus($path, $data = [])
public function updateExchangedIntegral($path, $data = [])
{
return $this->apiPost($path, $data);
}
......
......@@ -55,6 +55,9 @@ class UserExchangeTransformer
break;
}
});
$item['exchange_amount'] = array_get($item['exchange_setting'], 'amount', 0);
$item['exchanged_integral'] = array_get($item['user_integral'], 'exchanged_integral', 0);
}
return $data;
......
......@@ -2,7 +2,7 @@ layui.use('form', function () {
var form = layui.form;
form.on('submit(AuditUserExchange)', function (data) {
let url = '/user_exchanges/api/changeUserExchangeStatusApi';
let url = '/user_exchanges/api/auditUserExchangeApi';
$.ajax({
type: 'POST',
url: url,
......@@ -12,6 +12,8 @@ layui.use('form', function () {
if (result.errcode === 0) {
layer.msg('审核完成');
window.location = '/user_exchanges/userExchangeList';
} else {
layer.msg(result.errmsg, {icon: 5});
}
},
error: function () {
......
......@@ -17,28 +17,33 @@ function changeStatus(checkStatus, status, table) {
for (var key in data) {
ids.push(data[key].id);
}
var operateText = status ? '恢复' : '禁用';
layer.confirm('确定批量拒绝兑换选中行?', function (index) {
if (!ids || ids.length < 1) return layer.msg('没有可以操作的数据', {offset: 200, icon: 6});
layer.prompt({
formType: 2,
title: '请输入批量拒绝兑换理由',
area: ['300px', '200px'] //自定义文本域宽高
}, function (val, index) {
if (!val) return layer.msg('请输入禁用原因', {icon: 6});
layer.msg('处理中', {icon: 16, time: 10000});
$.ajax({
url: '/user_exchanges/api/batchUpdateStatusApi',
type: 'post',
data: {ids: ids, status: status},
data: {ids: ids, status: status, audit_reason: val},
dataType: 'json',
timeout: 10000,
success: function (res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
layer.msg(res.errmsg, {icon: 6});
if (res.errcode === 0) {
var msg = '批量拒绝成功';
layer.msg(msg);
table.reload('UserExchange');
window.location.reload();
}
},
error: function () {
return layer.msg('网络错误,请重试', {icon: 5});
}
})
})
});
}
layui.use(['table', 'form', 'laydate', 'layer'], function () {
......@@ -62,8 +67,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
{type: 'checkbox'}
, {field: 'id', title: '序号'}
, {field: 'mobile', title: '注册手机号'}
, {field: 'exchanged_amount', title: '兑换金额'}
, {field: 'exchanged_amount', title: '已兑换'}
, {field: 'exchange_amount', title: '兑换金额'}
, {field: 'type', title: '兑换类型', templet: '#type'}
, {field: 'certification_status', title: '认证状态'}
, {field: 'status', title: '兑换状态', templet: '#status'}
......@@ -76,10 +80,10 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
}
});
//头工具栏事件
table.on('toolbar(UserExchange)', function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
switch (obj.event) {
case 'batchDisableStatus':
changeStatus(checkStatus, -1, table);
......@@ -90,14 +94,15 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
//监听行工具事件
table.on('tool(UserExchange)', function (obj) {
var data = obj.data
, layEvent = obj.event;
var layEvent = obj.event;
switch (layEvent) {
case 'audit':
window.location = '/user_exchanges/auditUserExchange?user_id=' + obj.data.user_id;
window.location = '/user_exchanges/auditUserExchange?id='
+ obj.data.id;
break;
case 'bills':
window.location = '/user_exchanges/userExchangeBillList?user_id=' + obj.data.user_id;
window.location = '/user_exchanges/userExchangeBillList?user_id='
+ obj.data.user_id;
break;
}
});
......
......@@ -2,28 +2,38 @@
<div class="layui-card-body" style="padding-top: 20px">
<div class="layui-form">
<input type="hidden" name="id" value="{{$user_exchange['id']}}">
<input type="hidden" name="audit_id" value="{{$audit_id}}">
<input type="hidden" name="user_id" value="{{$user_exchange['user_id']}}">
<div class="layui-form-item">
<label class="layui-form-label">注册手机号</label>
<div class="layui-input-block">
<input type="text" value="{{$user_exchange['mobile']}}" disabled
<input type="text" value="{{$mobile}}" disabled
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">兑换金额</label>
<div class="layui-input-block">
<input type="text" value="{{$user_exchange['exchanged_amount']}}" disabled
<input type="text" name="exchange_amount" value="{{$user_exchange['exchange_setting']['amount']}}"
disabled
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">当前审核人</label>
<div class="layui-input-block">
<input type="text" value="{{$audit_name}}" disabled="disabled"
<input type="text" value="{{$audit_email}}" disabled="disabled"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">审核理由</label>
<div class="layui-input-block">
<input type="text" name="audit_reason" value="" lay-verify="required"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','审批选择',1,[1=>'通过',-1=>'拒绝']) !!}
......
......@@ -65,7 +65,7 @@ Route::namespace('Api')->group(function () {
'UserExchangesApiController@userExchangeListApi');
Route::match(['get', 'post'], '/user_exchanges/api/batchUpdateStatusApi',
'UserExchangesApiController@batchUpdateStatusApi');
Route::match(['get', 'post'], '/user_exchanges/api/changeUserExchangeStatusApi',
'UserExchangesApiController@changeUserExchangeStatusApi');
Route::match(['get', 'post'], '/user_exchanges/api/auditUserExchangeApi',
'UserExchangesApiController@auditUserExchangeApi');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment