|
@@ -87,11 +87,41 @@ class ElasticSearchGoodsNewCrontab2 implements JobInterface
|
|
|
$new_goods = [];
|
|
|
foreach ($goods as $k => $item) {
|
|
|
$item['operators_id'] = $this->getOperatorsIdByGoodsId($item['id']);
|
|
|
+ $item['category'] = $this->getOperatorsCategory($item['id'], $item['pcate'], $item['ccate'], $item['tcate'], $item['operators_id']);
|
|
|
$new_goods[$k] = $item;
|
|
|
}
|
|
|
return $new_goods;
|
|
|
}
|
|
|
|
|
|
+ function getOperatorsCategory($goods_id, $pcate, $ccate, $tcate, $operators_ids)
|
|
|
+ {
|
|
|
+ $result = array();
|
|
|
+ $queryBuild = new QueryBuilder();
|
|
|
+ $category_type = 0;
|
|
|
+ foreach ($operators_ids as $operators_id) {
|
|
|
+ $sql = "select category_type from ims_superdesk_shop_operators_user where id = '{$operators_id}'";
|
|
|
+ $queryBuild->raw($sql);
|
|
|
+ $res_data = DbManager::getInstance()->query($queryBuild, true, 'default')->toArray();
|
|
|
+ $res = $res_data['result'];
|
|
|
+ if ($res) {
|
|
|
+ $category_type = $res[0]['category_type'];
|
|
|
+ }
|
|
|
+ if ($category_type == 2) { //自建分类
|
|
|
+ $sql = "select pcate,ccate,tcate from ims_superdesk_shop_operators_goods where goodsid = '{$goods_id}' and operators_id = '{$operators_id}' ";
|
|
|
+ $queryBuild->raw($sql);
|
|
|
+ $res_data = DbManager::getInstance()->query($queryBuild, true, 'default')->toArray();
|
|
|
+ $res = $res_data['result'];
|
|
|
+ if ($res) {
|
|
|
+ $pcate = $res[0]['pcate'];
|
|
|
+ $ccate = $res[0]['ccate'];
|
|
|
+ $tcate = $res[0]['tcate'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result[] = $operators_id.'_'.$category_type.'_'.$pcate.'-'.$ccate.'-'.$tcate;
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
function getOperatorsIdByGoodsId($goods_id)
|
|
|
{
|
|
|
$sql = "select operators_id from ims_superdesk_shop_operators_goods where goodsid = '{$goods_id}' and `status`=1 AND deleted=0 AND checked=0 ";
|