Commit f17dd9e9 by 杨树贤

商品配置列表返回redis的可用库存

parent da9e8419
...@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; ...@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Requests\ExchangeSettingApiRequest; use App\Http\Requests\ExchangeSettingApiRequest;
use App\Http\Services\ExchangeSettingService; use App\Http\Services\ExchangeSettingService;
use App\Model\RedisModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
...@@ -24,7 +25,7 @@ class ExchangeSettingsApiController extends Controller ...@@ -24,7 +25,7 @@ class ExchangeSettingsApiController extends Controller
return $this->apiReturn(0, 'ok', [ return $this->apiReturn(0, 'ok', [
'data' => $data['data'], 'data' => $data['data'],
'count' => array_get($data,'count',0), 'count' => array_get($data, 'count', 0),
]); ]);
} }
...@@ -33,7 +34,16 @@ class ExchangeSettingsApiController extends Controller ...@@ -33,7 +34,16 @@ class ExchangeSettingsApiController extends Controller
if (!is_array($data['data'])) { if (!is_array($data['data'])) {
return $data; return $data;
} }
$redis = new RedisModel();
foreach ($data['data'] as &$item) { foreach ($data['data'] as &$item) {
//获取当前剩余名额
if ($item['status'] == 1) {
$availableStock = $redis->llen('ic_exchange_settings_' . $item['id']);
$item['available_stock'] = $availableStock;
} else {
$item['available_stock'] = '已禁用';
}
$item['status'] = $item['status'] ? '使用中' : '已停用'; $item['status'] = $item['status'] ? '使用中' : '已停用';
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']); $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
$item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '暂无更新'; $item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '暂无更新';
......
...@@ -33,7 +33,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () { ...@@ -33,7 +33,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
, {field: 'id', title: '序号'} , {field: 'id', title: '序号'}
, {field: 'name', title: '商品名称'} , {field: 'name', title: '商品名称'}
, {field: 'type', title: '商品类型', templet: '#type'} , {field: 'type', title: '商品类型', templet: '#type'}
, {field: 'stock', title: '库存'} , {field: 'stock', title: '名额'}
, {field: 'available_stock', title: '当前可用名额'}
, {field: 'amount', title: '兑换所需金额'} , {field: 'amount', title: '兑换所需金额'}
, {field: 'status', title: '配置状态', templet: '#status'} , {field: 'status', title: '配置状态', templet: '#status'}
, {field: 'update_time', title: '配置更新时间', templet: '#update_time'} , {field: 'update_time', title: '配置更新时间', templet: '#update_time'}
......
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