ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 单品销量排行栏 #### 1.视图展示 文件路径:\\shop\\views\\default\\Seller\\IndexCtl\\index.php ``` <pre class="calibre14">``` <span class="token"><</span>div class<span class="token">=</span><span class="token4">"m white-panel"</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"pannel_div"</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"mt"</span><span class="token">></span> <span class="token"><</span>h3 class<span class="token">=</span><span class="token4">"bbc_seller_border"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'单品销售排名'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>h3<span class="token">></span> <span class="token"><</span>h5<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'掌握30日内最热销的商品及时补充货源'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>h5<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"mc rank"</span><span class="token">></span> <span class="token"><</span>table width<span class="token">=</span><span class="token4">"100%"</span> cellspacing<span class="token">=</span><span class="token4">"0"</span> cellpadding<span class="token">=</span><span class="token4">"0"</span><span class="token">></span> <span class="token"><</span>tr<span class="token">></span> <span class="token"><</span>td width<span class="token">=</span><span class="token4">"50"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'排名'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span>td colspan<span class="token">=</span><span class="token4">"2"</span> class<span class="token">=</span><span class="token4">"tl"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'商品信息'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span>td width<span class="token">=</span><span class="token4">"70"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'销量'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span><span class="token">/</span>tr<span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$shop_top_rows<span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> foreach <span class="token1">(</span>$shop_top_rows as $key <span class="token">=</span><span class="token">></span> $shop_top_row<span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span> <span class="token"><</span>tr<span class="token">></span> <span class="token"><</span>td<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span> $key <span class="token">+</span> <span class="token6">1</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span>td class<span class="token">=</span><span class="token4">"tl"</span> width<span class="token">=</span><span class="token4">"40"</span><span class="token">></span><span class="token"><</span>a target<span class="token">=</span><span class="token4">"_blank"</span> href<span class="token">=</span><span class="token4">"<?= Yf_Registry::get('index_page') ?>?ctl=Goods_Goods&met=goods&type=goods&gid=<?= $shop_top_row['goods_id'] ?>"</span><span class="token">></span><span class="token"><</span>img width<span class="token">=</span><span class="token4">"32"</span> src<span class="token">=</span><span class="token4">"<?= image_thumb($shop_top_row['goods_image'], 60, 60) ?>"</span><span class="token">/</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span>td class<span class="token">=</span><span class="token4">"tl"</span><span class="token">></span><span class="token"><</span>a target<span class="token">=</span><span class="token4">"_blank"</span> href<span class="token">=</span><span class="token4">"<?= Yf_Registry::get('index_page') ?>?ctl=Goods_Goods&met=goods&type=goods&gid=<?= $shop_top_row['goods_id'] ?>"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span> $shop_top_row<span class="token1">[</span><span class="token4">'goods_name'</span><span class="token1">]</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span>td<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span> $shop_top_row<span class="token1">[</span><span class="token4">'goods_num'</span><span class="token1">]</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span> <span class="token"><</span><span class="token">/</span>tr<span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token1">}</span> <span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">/</span>table<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` #### 2.数据获取 接口地址:index.php?ctl=Seller\_Index&met=index&typ=e 接口文件:\\shop\\controllers\\Seller\\IndexCtl.php 控制器:Seller\_IndexCtl 方法:index() ``` <pre class="calibre15">``` $start_date <span class="token">=</span> <span class="token3">date</span><span class="token1">(</span><span class="token4">"Y-m-d"</span><span class="token1">,</span> <span class="token3">strtotime</span><span class="token1">(</span><span class="token4">"-30 days"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//单品销量</span> $shop_top_rows <span class="token">=</span> $Analysis_ShopGeneralModel<span class="token">-</span><span class="token">></span><span class="token3">getShopGoodsTop</span><span class="token1">(</span>Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">,</span> $start_date<span class="token1">)</span><span class="token1">;</span> ``` ```