Commit 650bf243 by mushishixian

精选

parent f007a769
...@@ -97,7 +97,8 @@ class SkuApiController extends Controller ...@@ -97,7 +97,8 @@ class SkuApiController extends Controller
$this->response(-1, '请选择要操作的SKU', '0'); $this->response(-1, '请选择要操作的SKU', '0');
} }
$skuService = new SkuService(); $skuService = new SkuService();
if ($result['errcode'] == 0) { $result = $skuService->setPreferSku($skuIds,$prefer);
if ($result) {
$this->response(0, '操作成功'); $this->response(0, '操作成功');
} else { } else {
$this->response(-1, '操作失败,原因是 : ' . $result['errmsg']); $this->response(-1, '操作失败,原因是 : ' . $result['errmsg']);
......
...@@ -13,7 +13,7 @@ class SkuListFilter ...@@ -13,7 +13,7 @@ class SkuListFilter
public function listFilter() public function listFilter()
{ {
$map = request()->all(); $map = request()->all();
//dd($map);
//只获取专卖的数据 //只获取专卖的数据
$map['supplier_id'] = 17; $map['supplier_id'] = 17;
if ((!empty($map['create_time']))) { if ((!empty($map['create_time']))) {
...@@ -66,7 +66,6 @@ class SkuListFilter ...@@ -66,7 +66,6 @@ class SkuListFilter
unset($map[$k]); unset($map[$k]);
} }
} }
$map['p'] = $map['page']; $map['p'] = $map['page'];
unset($map['page']); unset($map['page']);
......
...@@ -68,6 +68,12 @@ class SkuService ...@@ -68,6 +68,12 @@ class SkuService
} }
$sku['cn_price'] = array_get($moqPrice, 'price_cn'); $sku['cn_price'] = array_get($moqPrice, 'price_cn');
$sku['us_price'] = array_get($moqPrice, 'price_us'); $sku['us_price'] = array_get($moqPrice, 'price_us');
//获取是否精选和标签
$goodsTag = $this->getGoodsTag($sku['goods_id']);
$sku['goods_label'] = array_get($goodsTag, 'goods_label', '');
$sku['goods_label_name'] = array_get(config('field.SkuGoodsLabel'), $sku['goods_label'], '');
$sku['tags'] = array_get($goodsTag, 'tags', []);
$sku['is_prefer'] = in_array(1, $sku['tags']) ? 1 : 0;
$list[] = $sku; $list[] = $sku;
} }
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
...@@ -87,22 +93,47 @@ class SkuService ...@@ -87,22 +93,47 @@ class SkuService
]; ];
} }
//设置精选
public function setPreferSku($skuIds, $prefer) public function setPreferSku($skuIds, $prefer)
{ {
//直接操作redis的goods_tag,然后推送es的修改任务即可 //直接操作redis的goods_tag,然后推送es的修改任务即可
$redis = new RedisModel(); $redis = new RedisModel();
foreach ($skuIds as $skuId) { foreach ($skuIds as $skuId) {
$goodsTag = $redis->hget('goods_tag', $skuId); $goodsTag = $redis->hget('goods_tag', $skuId);
if (!empty($goodsTag['tags'])) { $goodsTag = json_decode($goodsTag, true);
$tag = json_decode($goodsTag['tag'], true); if (!empty($goodsTag)) {
$tag = $goodsTag['tags'];
//判断是否有精选标签(1),而且操作是取消精选 //判断是否有精选标签(1),而且操作是取消精选
if (in_array(1, $tag) && $prefer == -1) { if ($prefer == -1) {
$key = array_search(1, $tag); if (in_array(1, $tag)) {
if (!empty($key)) { $key = array_search(1, $tag);
unset($goodsTag['tag'][$key]); if ($key !== false) {
unset($goodsTag['tags'][$key]);
}
}
} else {
if (!in_array(1, $tag)) {
$tag[] = 1;
$goodsTag['tags'] = $tag;
} }
} }
$result = $redis->hset('goods_tag', $skuId, json_encode($goodsTag));
} else {
//没有直接跳过
continue;
} }
if ($result === false) {
return false;
}
$redis->lpush('update_list_sku', $skuId);
} }
return true;
}
private function getGoodsTag($skuId)
{
$redis = new RedisModel();
$result = $redis->hget('goods_tag', $skuId);
return $result ? json_decode($result, true) : [];
} }
} }
\ No newline at end of file
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
field: 'brand_name', title: '品牌', align: 'center', width: 120 field: 'brand_name', title: '品牌', align: 'center', width: 120
}, },
{field: 'encap', title: '封装', align: 'center', width: 80}, {field: 'encap', title: '封装', align: 'center', width: 80},
{field: 'goods_label_name', title: 'SKU显示类型', align: 'center', width: 120},
{field: 'canal', title: '供应商编码', align: 'center', width: 120}, {field: 'canal', title: '供应商编码', align: 'center', width: 120},
{ {
field: 'moq', title: '起订量', align: 'center', width: 70 field: 'moq', title: '起订量', align: 'center', width: 70
...@@ -64,6 +65,11 @@ ...@@ -64,6 +65,11 @@
"<a class='layui-btn layui-btn-xs'></a>"; "<a class='layui-btn layui-btn-xs'></a>";
} }
}, },
{
field: 'is_prefer', title: '精选', align: 'center', width: 70, templet: function (d) {
return d.is_prefer ? "是" : "否";
}
},
{field: 'encoded_user_name', title: '内部采购', align: 'center', width: 100}, {field: 'encoded_user_name', title: '内部采购', align: 'center', width: 100},
{field: 'update_time', title: '更新时间', align: 'center', width: 150}, {field: 'update_time', title: '更新时间', align: 'center', width: 150},
{field: 'mpq', title: '标准包装量', align: 'center', width: 120}, {field: 'mpq', title: '标准包装量', align: 'center', width: 120},
......
...@@ -73,16 +73,19 @@ ...@@ -73,16 +73,19 @@
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!} {!! $statusPresenter->render('goods_label/condition','SKU显示类型','',config('field.SkuGoodsLabel')) !!}
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('goods_label/condition','SKU显示类型','',config('field.SkuGoodsLabel')) !!} {!! $statusPresenter->render('tags/condition','是否精选',request()->get('tags/condition'),[1=>'是',0=>'否']) !!}
</div> </div>
</div>
<div class="layui-row">
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">起订量和库存</label> @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!}
</div>
<div class="layui-inline">
<label class="layui-form-label">起订量库存</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<select name="moq_stock_compare"> <select name="moq_stock_compare">
<option value="">请选择</option> <option value="">请选择</option>
...@@ -116,6 +119,9 @@ ...@@ -116,6 +119,9 @@
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'), {!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
$userCodes) !!} $userCodes) !!}
</div> </div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px"> <div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter') @inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'上传时间']) !!} {!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_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