Commit 4f4c8fa3 by 杨树贤

添加可使用库存字段

parent 4c13de3c
Showing with 14 additions and 2 deletions
......@@ -41,7 +41,6 @@ class ExchangeSetting extends Model
//先从redis里面查询是否有列表,没有的话从MySQL里面取出并且放入redis
$redis = new RedisModel();
$settings = $this->getExchangeSettingsFromRedis();
$count = 0;
if (!$settings) {
$result = $this->addExchangeSettingListToRedis();
if (!$result) {
......@@ -49,7 +48,8 @@ class ExchangeSetting extends Model
$settings = $this->getExchangeSettingsFromRedis();
}
}
//这边还要去redis获取每项的可使用库存
$settings = $this->getAvailableStock($settings);
//如果需要过滤type
if ($map['type']) {
$settings = array_filter($settings, function ($value) use ($map) {
......@@ -138,6 +138,18 @@ class ExchangeSetting extends Model
}
}
public function getAvailableStock($settings = [])
{
$redis = new RedisModel();
foreach ($settings as $key => &$setting) {
$key = 'ic_exchange_settings_' . $setting['id'];
$setting['available_stock'] = $redis->llen($key);
}
unset($setting);
return $settings;
}
public function updateExchangeSetting($id, $data = [])
{
$result = DB::transaction(function () use ($id, $data) {
......
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