Commit 650bf243 by mushishixian

精选

parent f007a769
......@@ -97,7 +97,8 @@ class SkuApiController extends Controller
$this->response(-1, '请选择要操作的SKU', '0');
}
$skuService = new SkuService();
if ($result['errcode'] == 0) {
$result = $skuService->setPreferSku($skuIds,$prefer);
if ($result) {
$this->response(0, '操作成功');
} else {
$this->response(-1, '操作失败,原因是 : ' . $result['errmsg']);
......
......@@ -13,7 +13,7 @@ class SkuListFilter
public function listFilter()
{
$map = request()->all();
//dd($map);
//只获取专卖的数据
$map['supplier_id'] = 17;
if ((!empty($map['create_time']))) {
......@@ -66,7 +66,6 @@ class SkuListFilter
unset($map[$k]);
}
}
$map['p'] = $map['page'];
unset($map['page']);
......
......@@ -68,6 +68,12 @@ class SkuService
}
$sku['cn_price'] = array_get($moqPrice, 'price_cn');
$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;
}
$intracodeModel = new IntracodeModel();
......@@ -87,22 +93,47 @@ class SkuService
];
}
//设置精选
public function setPreferSku($skuIds, $prefer)
{
//直接操作redis的goods_tag,然后推送es的修改任务即可
$redis = new RedisModel();
foreach ($skuIds as $skuId) {
$goodsTag = $redis->hget('goods_tag', $skuId);
if (!empty($goodsTag['tags'])) {
$tag = json_decode($goodsTag['tag'], true);
$goodsTag = json_decode($goodsTag, true);
if (!empty($goodsTag)) {
$tag = $goodsTag['tags'];
//判断是否有精选标签(1),而且操作是取消精选
if (in_array(1, $tag) && $prefer == -1) {
$key = array_search(1, $tag);
if (!empty($key)) {
unset($goodsTag['tag'][$key]);
if ($prefer == -1) {
if (in_array(1, $tag)) {
$key = array_search(1, $tag);
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 @@
field: 'brand_name', title: '品牌', align: 'center', width: 120
},
{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: 'moq', title: '起订量', align: 'center', width: 70
......@@ -64,6 +65,11 @@
"<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: 'update_time', title: '更新时间', align: 'center', width: 150},
{field: 'mpq', title: '标准包装量', align: 'center', width: 120},
......
......@@ -73,16 +73,19 @@
</div>
<div class="layui-inline">
@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 class="layui-inline">
@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 class="layui-row">
<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">
<select name="moq_stock_compare">
<option value="">请选择</option>
......@@ -116,6 +119,9 @@
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
$userCodes) !!}
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $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