From a8347603948a5c75857c51153155284a7873b80a Mon Sep 17 00:00:00 2001 From: dengbw Date: Thu, 4 Nov 2021 10:39:08 +0800 Subject: [PATCH] api_biz_1104 --- api/controllers/wxapp/material/Biz.php | 78 ++++++++++++-------------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/api/controllers/wxapp/material/Biz.php b/api/controllers/wxapp/material/Biz.php index 346a3cb9..8e02ebe1 100644 --- a/api/controllers/wxapp/material/Biz.php +++ b/api/controllers/wxapp/material/Biz.php @@ -56,52 +56,44 @@ class Biz extends Wxapp $where_s['browse_num'] = 1; $this->mdBizStatistics->add($where_s); } - $lists = []; - $sql = "SELECT id,brand_id,s_id,v_id,cor_id,ori_price FROM lc_items WHERE biz_id={$biz_id} -AND bill_time='0000-00-00 00:00:00' AND status<>0 GROUP BY cor_id ORDER BY in_time DESC"; - $res = $this->mdItems->db->query($sql)->result_array(); - $brand_ids = $s_ids = $attr_vids = array(); - foreach ($res as $v) { - $v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id']; - $v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id']; - $v['v_id'] && !in_array($v['v_id'], $attr_vids) && $attr_vids[] = $v['v_id']; - } - $map_brand = $map_sery = $map_vid = array(); - if ($brand_ids) { - $str_ids = implode(',', $brand_ids); - $where = array("id in ({$str_ids})" => null); - $map_brand = $this->mdAutoBrand->map('id', 'name', $where); - } - if ($s_ids) { - $str_ids = implode(',', $s_ids); - $where = array("id in ({$str_ids})" => null); - $map_sery = $this->mdAutoSeries->map('id', 'name', $where); - } - if ($attr_vids) { - $str_ids = implode(',', $attr_vids); - $where = array("id in ({$str_ids})" => null); - $map_vid = $this->mdAutoAttr->map('id', 'title', $where); - } - foreach ($res as $key => $val) { - $id = $img = ''; - $re_attr = $this->mdAutoAttr->get(['id' => $val['cor_id']], 'jsondata'); - if ($re_attr['jsondata']) { - $jsondata = json_decode($re_attr['jsondata'], true); - $jsondata['img'] && $img = build_qiniu_image_url($jsondata['img']); - } - $title = $map_brand[$val['brand_id']]; - $map_sery[$val['s_id']] && $title .= '-' . $map_sery[$val['s_id']]; - $map_vid[$val['v_id']] && $title .= '-' . $map_vid[$val['v_id']]; + $lists = [ + [ + 'brand_id' => 1, 'cms_id' => 0, 'sort' => 0, + 'title' => '东风EX1', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '45700 ~ 52700'], + 'img' => 'https://img.liche.cn/liche/2021/08/d646e4d674bbd4ce/01391b9663c09c6e.png' + ], + [ + 'brand_id' => 2, 'cms_id' => 0, 'sort' => 0, + 'title' => '雷丁芒果', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '29800 ~ 54900'], + 'img' => 'https://img.liche.cn/liche/2021/08/263d62f0cfee4729/169ea481e36f5b19.png' + ], + [ + 'brand_id' => 4, 'cms_id' => 0, 'sort' => 0, + 'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '63900 ~ 72900'], + 'img' => 'https://img.liche.cn/liche/2021/09/1b2acea849cf0aba/803b58e45d98fc75.png' + ], + [ + 'brand_id' => 5, 'cms_id' => 0, 'sort' => 0, + 'title' => '零跑T03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '59800 ~ 76800'], + 'img' => 'https://img.liche.cn/liche/2021/10/16563346c511be65/1db60b37c1418006.png' + ], + [ + 'brand_id' => 5, 'cms_id' => 0, 'sort' => 0, + 'title' => '零跑C11', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '159800 ~ 199800'], + 'img' => 'https://img.liche.cn/liche/2021/10/a5d183944abf748b/b67eb2e08f84890f.png' + ], + ]; + shuffle($lists); + foreach ($lists as $key => $val) { $where_l = ['target_id' => $val['brand_id'], 'position' => 2, 'status' => 1, 'e_time>=' => time()]; $re_l = $this->mdLicheCms->max('id', $where_l); - $re_l['id'] && $id = $re_l['id']; - $lists[] = [ - 'cms_id' => $id, - 'title' => $title, - 'img' => $img, - 'ori_price' => ['title' => '厂商指导价¥', 'value' => $val['ori_price']], - ]; + $re_l['id'] && $lists[$key]['cms_id'] = $re_l['id']; + $count = $this->mdItems->count(['brand_id' => $val['brand_id'], 'status<>' => 0, 'biz_id' => $biz_id + , 'bill_time' => '0000-00-00 00:00:00']); + $lists[$key]['sort'] = $count ? $count + 5 : 5 - $key; } + $countKey = array_column($lists, 'sort'); + array_multisort($countKey, SORT_DESC, $lists);//排序 $this->data['title'] = '店铺'; $this->data['bg_img'] = 'https://qs.haodian.cn/wechat_app/liche/storeInfo/theme.png'; $this->data['biz_name'] = '狸车· ' . $re['biz_name'] . '店';