Commit 1a9d6d95 by 杨树贤

Merge branch 'ysx-解决update结果判断的问题和缓存放到数据库事务的问题-20190820' into Development

parents 7f4517a0 d852b681
......@@ -6,14 +6,23 @@ namespace App\Http\Controllers;
use App\Http\Filters\ExchangeSettingFilter;
use App\Models\ExchangeSetting;
use App\Models\Integral;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* 红包兑换项管理
* Class ExchangeSettingsController
* @package App\Http\Controllers
*/
class ExchangeSettingsController extends Controller
{
/**
* 单个红包兑换项详细信息
* @param Request $request
* @return array
*/
public function show(Request $request)
{
$id = $request->id;
......@@ -22,6 +31,12 @@ class ExchangeSettingsController extends Controller
return $this->Export(0, 'ok', ['data' => $exchangeSetting]);
}
/**
* 红包兑换项列表
* @param Request $request
* @param ExchangeSettingFilter $filter
* @return array
*/
public function index(Request $request, ExchangeSettingFilter $filter)
{
$page = $request->has('page') ? $request->page : 1;
......@@ -37,6 +52,11 @@ class ExchangeSettingsController extends Controller
}
/**
* 存储新增的红包配置项
* @param Request $request
* @return array
*/
public function store(Request $request)
{
$res = DB::table('exchange_settings')->insert([
......@@ -51,20 +71,34 @@ class ExchangeSettingsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(041, 5), '新增积分信息失败');
return $this->Export(ErrorCode(041, 5), '新增红包配置项失败');
}
}
/**
* 更新红包配置项
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]);
$res = DB::table('exchange_settings')->where('id', $id)
->update($data);
if (!$res) {
return $this->Export(042, '更新红包配置项失败');
} else {
return $this->Export(0, 'ok');
}
}
/**
* 删除红包配置项
* @param Request $request
* @return array
*/
public function destroy(Request $request)
{
$ids = $request->ids;
......@@ -73,10 +107,15 @@ class ExchangeSettingsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(043, 5), '删除积分信息失败');
return $this->Export(ErrorCode(043, 5), '删除红包配置项失败');
}
}
/**
* 批量更新红包配置项状态
* @param Request $request
* @return array
*/
public function batchUpdateStatus(Request $request)
{
$ids = $request->ids;
......@@ -84,11 +123,14 @@ class ExchangeSettingsController extends Controller
return Log::Info('批量修改参数不是数组');
}
$status = $request->status;
$result = DB::table('exchange_settings')
$res = DB::table('exchange_settings')
->whereIn('id', $ids)
->update(['status' => (int)$status, 'update_time' => time()]);
if ($res) {
return $this->Export(0, 'ok');
// return $this->Export(033, '批量修改用户积分失败');
} else {
return $this->Export(ErrorCode(044, 5), '删除红包配置项失败');
}
}
}
\ No newline at end of file
......@@ -5,14 +5,22 @@ namespace App\Http\Controllers;
use App\Http\Filters\IntegralBillFilter;
use App\Http\Filters\UserIntegralFilter;
use App\Models\IntegralBill;
use App\Models\UserIntegral;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* 用户红包获取流水
* Class IntegralBillsController
* @package App\Http\Controllers
*/
class IntegralBillsController extends Controller
{
/**
* @param Request $request
* @param IntegralBillFilter $filter
* @return array
*/
public function index(Request $request, IntegralBillFilter $filter)
{
$page = $request->has('page') ? $request->page : 1;
......@@ -26,6 +34,11 @@ class IntegralBillsController extends Controller
}
/**
* 创建红包账单
* @param Request $request
* @return array
*/
public function create(Request $request)
{
$res = DB::table('integral_bills')->insert([
......@@ -39,10 +52,15 @@ class IntegralBillsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(021, 5), '新增积分账单失败');
return $this->Export(ErrorCode(021, 5), '新增红包账单失败');
}
}
/**
* 更新红包账单
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
......@@ -57,10 +75,15 @@ class IntegralBillsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(022, 5), '更新积分账单失败');
return $this->Export(ErrorCode(022, 5), '更新红包账单失败');
}
}
/**
* 删除红包账单
* @param Request $request
* @return array
*/
public function destroy(Request $request)
{
$ids = $request->ids;
......@@ -69,7 +92,7 @@ class IntegralBillsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(023, 5), '删除积分账单失败');
return $this->Export(ErrorCode(023, 5), '删除红包账单失败');
}
}
}
\ No newline at end of file
......@@ -8,8 +8,16 @@ use App\Models\IntegralType;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* 红包类型管理
* Class IntegralTypesController
* @package App\Http\Controllers
*/
class IntegralTypesController extends Controller
{
/**红包类型列表
* @return array
*/
public function index()
{
$integrals = IntegralType::all()->toArray();
......@@ -17,6 +25,11 @@ class IntegralTypesController extends Controller
return $this->Export(0, 'ok', ['data' => $integrals]);
}
/**
* 创建红包类型
* @param Request $request
* @return array
*/
public function create(Request $request)
{
$res = DB::table('integral_types')->insert([
......@@ -28,10 +41,15 @@ class IntegralTypesController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(011, 5), '新增积分信息失败');
return $this->Export(ErrorCode(011, 5), '新增红包分类失败');
}
}
/**
* 更新红包类型
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
......@@ -43,10 +61,15 @@ class IntegralTypesController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(012, 5), '更新积分信息失败');
return $this->Export(ErrorCode(012, 5), '更新红包分类失败');
}
}
/**
* 删除红包类型
* @param Request $request
* @return array
*/
public function destroy(Request $request)
{
$ids = $request->ids;
......@@ -55,7 +78,7 @@ class IntegralTypesController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(013, 5), '删除积分信息失败');
return $this->Export(ErrorCode(013, 5), '删除红包分类失败');
}
}
}
\ No newline at end of file
......@@ -10,8 +10,18 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* 红包基础信息管理
* Class IntegralsController
* @package App\Http\Controllers
*/
class IntegralsController extends Controller
{
/**
* 单个红包信息
* @param Request $request
* @return array
*/
public function show(Request $request)
{
$id = $request->id;
......@@ -20,6 +30,12 @@ class IntegralsController extends Controller
return $this->Export(0, 'ok', ['data' => $integral]);
}
/**
* 红包列表
* @param Request $request
* @param IntegralFilter $filter
* @return array
*/
public function index(Request $request, IntegralFilter $filter)
{
$page = $request->has('page') ? $request->page : 1;
......@@ -35,6 +51,11 @@ class IntegralsController extends Controller
return $this->Export(0, 'ok', ['data' => $integrals, 'count' => $count]);
}
/**
* 创建红包
* @param Request $request
* @return array
*/
public function create(Request $request)
{
$res = DB::table('integrals')->insert([
......@@ -48,20 +69,33 @@ class IntegralsController extends Controller
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(001, 5), '新增积分信息失败');
return $this->Export(ErrorCode(001, 5), '新增红包信息失败');
}
}
/**
* 更新红包
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
$data = array_merge($request->all(), ['update_time' => time()]);
$res = DB::table('integrals')->where('id', $id)
->update($data);
if (!$res) {
return $this->Export(002, '更新红包信息失败');
} else {
return $this->Export(0, 'ok');
}
}
/**
* 批量更改状态
* @param Request $request
* @return array
*/
public function batchUpdateStatus(Request $request)
{
$ids = $request->ids;
......@@ -69,23 +103,31 @@ class IntegralsController extends Controller
return Log::Info('批量修改参数不是数组');
}
$status = $request->status;
$result = DB::table('integrals')
$res = DB::table('integrals')
->whereIn('id', $ids)
->update(['status' => (int)$status]);
->update(['status' => (int)$status, 'update_time' => time()]);
if (!$res) {
return $this->Export(004, '批量更新红包信息状态失败');
} else {
return $this->Export(0, 'ok');
// return $this->Export(033, '批量修改用户积分失败');
}
}
/**
* 删除红包
* @param Request $request
* @return array
*/
public function destroy(Request $request)
{
$ids = $request->ids;
$ids = explode(',', trim($ids));
$res = DB::table('integrals')->whereIn('id', $ids)->delete();
if ($res) {
return $this->Export(0, 'ok');
if (!$res) {
return $this->Export(ErrorCode(003, 5), '删除红包信息失败');
} else {
return $this->Export(ErrorCode(003, 5), '删除积分信息失败');
return $this->Export(0, 'ok');
}
}
......
......@@ -10,8 +10,17 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* 用户红包兑换管理
* Class UserExchangesController
* @package App\Http\Controllers
*/
class UserExchangesController extends Controller
{
/**
* @param Request $request
* @return array
*/
public function show(Request $request)
{
$id = $request->id;
......@@ -20,6 +29,12 @@ class UserExchangesController extends Controller
return $this->Export(0, 'ok', ['data' => $userExchange]);
}
/**
* 用户兑换红包列表
* @param Request $request
* @param UserExchangeFilter $filter
* @return array
*/
public function index(Request $request, UserExchangeFilter $filter)
{
$page = $request->has('page') ? $request->page : 1;
......@@ -33,16 +48,29 @@ class UserExchangesController extends Controller
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, '更新用户兑换红包信息失败');
}
}
/**
* 批量审核
* @param Request $request
* @return array
*/
public function batchUpdateStatus(Request $request)
{
$ids = $request->ids;
......@@ -50,11 +78,14 @@ class UserExchangesController extends Controller
return Log::Info('批量修改参数不是数组');
}
$status = $request->status;
$result = DB::table('user_exchanges')
$res = DB::table('user_exchanges')
->whereIn('id', $ids)
->update(['status' => (int)$status]);
->update(['status' => (int)$status, 'update_time' => time()]);
if ($res) {
return $this->Export(0, 'ok');
// return $this->Export(033, '批量修改用户积分失败');
} else {
return $this->Export(032, '批量更新用户兑换红包信息状态失败');
}
}
}
\ No newline at end of file
......@@ -5,14 +5,23 @@ namespace App\Http\Controllers;
use App\Http\Filters\UserIntegralFilter;
use App\Models\Integral;
use App\Models\UserIntegral;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* 用户红包详情列表
* Class UserIntegralsController
* @package App\Http\Controllers
*/
class UserIntegralsController extends Controller
{
/**
* 查看用户红包情况
* @param Request $request
* @return array
*/
public function show(Request $request)
{
$id = $request->id;
......@@ -24,6 +33,12 @@ class UserIntegralsController extends Controller
}
/**
* 用户红包详情列表
* @param Request $request
* @param UserIntegralFilter $filter
* @return array
*/
public function index(Request $request, UserIntegralFilter $filter)
{
$integrals = UserIntegral::filter($filter)->page($request->page, $request->page_size)
......@@ -34,6 +49,11 @@ class UserIntegralsController extends Controller
return $this->Export(0, 'ok', ['data' => $integrals, 'count' => $count]);
}
/**
* 更新用户红包详情
* @param Request $request
* @return array
*/
public function update(Request $request)
{
$id = $request->id;
......@@ -41,9 +61,18 @@ class UserIntegralsController extends Controller
$res = DB::table('user_integrals')->where('id', $id)
->update($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(051, '修改用户红包详情失败');
}
}
/**
* 批量修改用户红包是否领取
* @param Request $request
* @return array
*/
public function batchUpdateStatus(Request $request)
{
$ids = $request->ids;
......@@ -51,11 +80,14 @@ class UserIntegralsController extends Controller
return Log::Info('批量修改参数不是数组');
}
$status = $request->status;
$result = DB::table('user_integrals')
$res = DB::table('user_integrals')
->whereIn('id', $ids)
->update(['status' => (int)$status]);
->update(['status' => (int)$status, 'update_time' => time()]);
if ($res) {
return $this->Export(0, 'ok');
// return $this->Export(033, '批量修改用户积分失败');
} else {
return $this->Export(052, '批量修改用户是否可领取红包失败');
}
}
}
\ No newline at end of file
5983
\ No newline at end of file
2182
\ 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