Commit f17dd9e9 by 杨树贤

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

parent da9e8419
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Requests\ExchangeSettingApiRequest;
use App\Http\Services\ExchangeSettingService;
use App\Model\RedisModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
......@@ -24,7 +25,7 @@ class ExchangeSettingsApiController extends Controller
return $this->apiReturn(0, 'ok', [
'data' => $data['data'],
'count' => array_get($data,'count',0),
'count' => array_get($data, 'count', 0),
]);
}
......@@ -33,7 +34,16 @@ class ExchangeSettingsApiController extends Controller
if (!is_array($data['data'])) {
return $data;
}
$redis = new RedisModel();
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['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']) : '暂无更新';
......
......@@ -33,7 +33,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
, {field: 'id', title: '序号'}
, {field: 'name', title: '商品名称'}
, {field: 'type', title: '商品类型', templet: '#type'}
, {field: 'stock', title: '库存'}
, {field: 'stock', title: '名额'}
, {field: 'available_stock', title: '当前可用名额'}
, {field: 'amount', title: '兑换所需金额'}
, {field: 'status', title: '配置状态', templet: '#status'}
, {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