Commit 01a0b3ba by 杨树贤

修复使用$request->all()的问题

parent 34ff923f
...@@ -39,8 +39,8 @@ class ExchangeSettingsController extends Controller ...@@ -39,8 +39,8 @@ class ExchangeSettingsController extends Controller
*/ */
public function index(Request $request, ExchangeSettingFilter $filter) public function index(Request $request, ExchangeSettingFilter $filter)
{ {
$page = $request->has('page') ? $request->page : 1; $page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$page_size = $request->has('page_size') ? $request->page_size : 10; $page_size = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$settings = ExchangeSetting::filter($filter) $settings = ExchangeSetting::filter($filter)
->page($page, $page_size) ->page($page, $page_size)
...@@ -83,7 +83,14 @@ class ExchangeSettingsController extends Controller ...@@ -83,7 +83,14 @@ class ExchangeSettingsController extends Controller
public function update(Request $request) public function update(Request $request)
{ {
$id = $request->id; $id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]); $data = [
'name' => $request->name,
'amount' => $request->amount,
'stock' => $request->stock,
'type' => $request->type,
'status' => $request->status,
'update_time' => time(),
];
$res = DB::table('exchange_settings')->where('id', $id) $res = DB::table('exchange_settings')->where('id', $id)
->update($data); ->update($data);
if (!$res) { if (!$res) {
...@@ -95,6 +102,29 @@ class ExchangeSettingsController extends Controller ...@@ -95,6 +102,29 @@ class ExchangeSettingsController extends Controller
} }
/** /**
* 修改配置项是否可用状态
* @param Request $request
* @return array
*/
public function updateStatus(Request $request)
{
$id = $request->id;
$status = $request->status;
$data = [
'status' => $status,
'update_time' => time(),
];
$res = DB::table('exchange_settings')->where('id', $id)
->update($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(045, '修改配置项可使用状态失败');
}
}
/**
* 删除红包配置项 * 删除红包配置项
* @param Request $request * @param Request $request
* @return array * @return array
......
...@@ -24,8 +24,8 @@ class IntegralBillsController extends Controller ...@@ -24,8 +24,8 @@ class IntegralBillsController extends Controller
*/ */
public function index(Request $request, IntegralBill $integralBill, IntegralBillFilter $filter) public function index(Request $request, IntegralBill $integralBill, IntegralBillFilter $filter)
{ {
$page = $request->has('page') ? $request->page : 1; $page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->has('page_size') ? $request->page_size : 10; $pageSize = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$res = $integralBill->getIntegralBillList($page, $pageSize, $filter); $res = $integralBill->getIntegralBillList($page, $pageSize, $filter);
return $this->Export(0, 'ok', $res); return $this->Export(0, 'ok', $res);
......
...@@ -38,8 +38,8 @@ class IntegralsController extends Controller ...@@ -38,8 +38,8 @@ class IntegralsController extends Controller
*/ */
public function index(Request $request, IntegralFilter $filter) public function index(Request $request, IntegralFilter $filter)
{ {
$page = $request->has('page') ? $request->page : 1; $page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$page_size = $request->has('page_size') ? $request->page_size : 10; $page_size = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$integrals = Integral::with('integralType:id,name') $integrals = Integral::with('integralType:id,name')
->filter($filter) ->filter($filter)
...@@ -81,7 +81,13 @@ class IntegralsController extends Controller ...@@ -81,7 +81,13 @@ class IntegralsController extends Controller
public function update(Request $request) public function update(Request $request)
{ {
$id = $request->id; $id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]); $data = [
'name' => $request->name,
'amount' => $request->amount,
'status' => $request->status,
'daily_limit' => $request->daily_limit,
'update_time' => time(),
];
$res = DB::table('integrals')->where('id', $id) $res = DB::table('integrals')->where('id', $id)
->update($data); ->update($data);
if (!$res) { if (!$res) {
...@@ -92,6 +98,29 @@ class IntegralsController extends Controller ...@@ -92,6 +98,29 @@ class IntegralsController extends Controller
} }
/** /**
* 更新红包是否可用状态
* @param Request $request
* @return array
*/
public function updateStatus(Request $request)
{
$id = $request->id;
$status = $request->status;
$data = [
'status' => $status,
'update_time' => time(),
];
$res = DB::table('integrals')->where('id', $id)
->update($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(005, '修改红包可使用状态失败');
}
}
/**
* 批量更改状态 * 批量更改状态
* @param Request $request * @param Request $request
* @return array * @return array
......
...@@ -37,8 +37,8 @@ class UserExchangesController extends Controller ...@@ -37,8 +37,8 @@ class UserExchangesController extends Controller
*/ */
public function index(Request $request, UserExchangeFilter $filter) public function index(Request $request, UserExchangeFilter $filter)
{ {
$page = $request->has('page') ? $request->page : 1; $page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->has('page_size') ? $request->page_size : 10; $pageSize = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$userExchanges = UserExchange::with(['exchange_setting', 'user_integral'])->filter($filter)->page($page, $userExchanges = UserExchange::with(['exchange_setting', 'user_integral'])->filter($filter)->page($page,
$pageSize) $pageSize)
...@@ -49,24 +49,6 @@ class UserExchangesController extends Controller ...@@ -49,24 +49,6 @@ class UserExchangesController extends Controller
return $this->Export(0, 'ok', ['data' => $userExchanges, 'count' => $count]); return $this->Export(0, 'ok', ['data' => $userExchanges, 'count' => $count]);
} }
/**
* 更新用户兑换红包账单
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]);
$res = DB::table('user_exchanges')->where('id', $id)
->update($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(031, '更新用户兑换红包信息失败');
}
}
/** /**
* 审核用户的兑换 * 审核用户的兑换
......
...@@ -51,26 +51,30 @@ class UserIntegralsController extends Controller ...@@ -51,26 +51,30 @@ class UserIntegralsController extends Controller
} }
/** /**
* 更新用户红包详情 * 更新用户红包可领取状态
* @param Request $request * @param Request $request
* @return array * @return array
*/ */
public function update(Request $request) public function updateStatus(Request $request)
{ {
$id = $request->id; $id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]); $status = $request->status;
$data = [
'status' => $status,
'update_time' => time(),
];
$res = DB::table('user_integrals')->where('id', $id) $res = DB::table('user_integrals')->where('id', $id)
->update($data); ->update($data);
if ($res) { if ($res) {
return $this->Export(0, 'ok'); return $this->Export(0, 'ok');
} else { } else {
return $this->Export(051, '修改用户红包详情失败'); return $this->Export(051, '修改用户红包可领取状态失败');
} }
} }
/** /**
* 批量修改用户红包是否领取 * 批量修改用户是否能够领取红包
* @param Request $request * @param Request $request
* @return array * @return array
*/ */
...@@ -92,30 +96,13 @@ class UserIntegralsController extends Controller ...@@ -92,30 +96,13 @@ class UserIntegralsController extends Controller
} }
} }
/** /**
* 修改用户红包的已兑换值 * 单个用户的红包兑换统计信息
* @param Request $request * @param Request $request
* @param IntegralBill $integralBill
* @return array * @return array
*/ */
public function updateExchangedIntegral(Request $request)
{
// DB::transaction(function () use ($request) {
$userId = $request->user_id;
$exchangeAmount = $request->exchange_amount;
$oldAmount = DB::table('user_integrals')->where('user_id', $userId)->value('exchanged_integral');
$res = DB::table('user_integrals')->where('user_id', $userId)->update([
'exchanged_integral' => $oldAmount + $exchangeAmount,
'update_time' => time(),
]);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(053, '批量修改用户是否可领取红包失败');
}
// });
}
public function statistics(Request $request, IntegralBill $integralBill) public function statistics(Request $request, IntegralBill $integralBill)
{ {
$userId = $request->user_id; $userId = $request->user_id;
......
...@@ -24,6 +24,7 @@ $router->post('/integrals/list', 'IntegralsController@index'); ...@@ -24,6 +24,7 @@ $router->post('/integrals/list', 'IntegralsController@index');
$router->post('/integrals/info', 'IntegralsController@show'); $router->post('/integrals/info', 'IntegralsController@show');
$router->post('/integrals/add', 'IntegralsController@create'); $router->post('/integrals/add', 'IntegralsController@create');
$router->post('/integrals/update', 'IntegralsController@update'); $router->post('/integrals/update', 'IntegralsController@update');
$router->post('/integrals/updateStatus', 'IntegralsController@updateStatus');
$router->post('/integrals/delete', 'IntegralsController@destroy'); $router->post('/integrals/delete', 'IntegralsController@destroy');
$router->post('/integrals/batchUpdateStatus', 'IntegralsController@batchUpdateStatus'); $router->post('/integrals/batchUpdateStatus', 'IntegralsController@batchUpdateStatus');
...@@ -43,7 +44,7 @@ $router->post('/integral_bills/delete', 'IntegralBillsController@destroy'); ...@@ -43,7 +44,7 @@ $router->post('/integral_bills/delete', 'IntegralBillsController@destroy');
//用户积分信息 //用户积分信息
$router->post('/user_integrals/info', 'UserIntegralsController@show'); $router->post('/user_integrals/info', 'UserIntegralsController@show');
$router->post('/user_integrals/list', 'UserIntegralsController@index'); $router->post('/user_integrals/list', 'UserIntegralsController@index');
$router->post('/user_integrals/update', 'UserIntegralsController@update'); $router->post('/user_integrals/updateStatus', 'UserIntegralsController@updateStatus');
$router->post('/user_integrals/batchUpdateStatus', 'UserIntegralsController@batchUpdateStatus'); $router->post('/user_integrals/batchUpdateStatus', 'UserIntegralsController@batchUpdateStatus');
$router->post('/user_integrals/updateExchangedIntegral', 'UserIntegralsController@updateExchangedIntegral'); $router->post('/user_integrals/updateExchangedIntegral', 'UserIntegralsController@updateExchangedIntegral');
$router->post('/user_integrals/statistics', 'UserIntegralsController@statistics'); $router->post('/user_integrals/statistics', 'UserIntegralsController@statistics');
...@@ -55,6 +56,7 @@ $router->post('/exchange_settings/info', 'ExchangeSettingsController@show'); ...@@ -55,6 +56,7 @@ $router->post('/exchange_settings/info', 'ExchangeSettingsController@show');
$router->post('/exchange_settings/list', 'ExchangeSettingsController@index'); $router->post('/exchange_settings/list', 'ExchangeSettingsController@index');
$router->post('/exchange_settings/add', 'ExchangeSettingsController@store'); $router->post('/exchange_settings/add', 'ExchangeSettingsController@store');
$router->post('/exchange_settings/update', 'ExchangeSettingsController@update'); $router->post('/exchange_settings/update', 'ExchangeSettingsController@update');
$router->post('/exchange_settings/updateStatus', 'ExchangeSettingsController@updateStatus');
$router->post('/exchange_settings/delete', 'ExchangeSettingsController@destroy'); $router->post('/exchange_settings/delete', 'ExchangeSettingsController@destroy');
$router->post('/exchange_settings/batchUpdateStatus', 'ExchangeSettingsController@batchUpdateStatus'); $router->post('/exchange_settings/batchUpdateStatus', 'ExchangeSettingsController@batchUpdateStatus');
......
2182 17991
\ No newline at end of file \ No newline at end of file
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