ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
:-: 商品列表 #### 1、商家中心商品列表 文件路径:shop/controllers/Seller/GoodsCtl.php; ##### 后台数据: $Yf_Page = new Yf_Page(); $row = $Yf_Page->listRows; $offset = request_int('firstRow', 0); $page = ceil_r($offset / $row); $goods = $Goods_CommonModel->getRecommonRow($goods_rows); 出售中的商品(online()): $cront_row = array('shop_id' => Perm::$shopId,'common_state' => Goods_CommonModel::GOODS_STATE_NORMAL, 'common_verify' => Goods_CommonModel::GOODS_VERIFY_ALLOW); $goods_rows = $Goods_CommonModel->getCommonNormal($cront_row, array('common_id' => 'DESC'), $page, $row); 已下架的商品(offline()) : 参数:op=1; $cront_row = array('shop_id' => Perm::$shopId); $goods_rows = $Goods_CommonModel->getCommonOffline($cront_row, array('common_id' => 'DESC'), $page, $row); 外部导入待上架商品(OutsideImport()): $cront_row = array('shop_id' => Perm::$shopId); $goods_rows = $Goods_CommonModel->getCommonOutsideImport($cront_row, array('common_id' => 'DESC'), $page, $row); 待审核商品(verify()): 参数:op=3; $cront_row = array('shop_id' => Perm::$shopId); $goods_rows = $Goods_CommonModel->getCommonVerifyWaiting($cront_row, array('common_id' => 'DESC'), $page, $row); 未通过审核商品(verifyDeny()): $cront_row = array('shop_id' => Perm::$shopId); $goods_rows = $Goods_CommonModel->getCommonVerifyDeny($cront_row, array('common_id' => 'DESC'), $page, $row); 待发布的商品(waitReleaseGoods()): $conditions = ['common_verify'=> Goods_CommonModel::GOODS_VERIFY_ALLOW, //common_verify=> 1 审核通过 'common_state'=> Goods_CommonModel::GOODS_STATE_TIMING, //common_state=> 2 定时发布 'shop_id'=> Perm::$shopId //所属店铺 ]; $common_goods_rows = $this->goodsCommonModel->listByWhere($conditions, ['common_id' => 'DESC'], $page, $row); $goods = $this->goodsCommonModel->getRecommonRow($common_goods_rows); 违规的商品(lockup()): $cront_row = array('shop_id' => Perm::$shopId); $goods_rows = $Goods_CommonModel->getCommonIllegal($cront_row, array('common_id' => 'DESC'), $page, $row); ##### 前台显示: <?php foreach ($goods as $item){ ?> <tr id="tr_common_id_<?= $item['common_id']; ?>"> <td class="tl th" colspan="99"> <label class="checkbox"><input <?php if(isset($item['disabled_up'])&&$item['disabled_up']) echo 'disabled'; ?> class="checkitem" type="checkbox" name="chk[]" value="<?= $item['common_id'] ?>" is_virtual="<?= $item['common_is_virtual'] ?>" common_virtual_date="<?= $item['common_virtual_date'] ?>"></label><?=__('平台货号')?>:<?= $item['common_id']; ?> <?php if(isset($item['disabled_up'])&&$item['disabled_up']) echo '<span style="color:red;">('.__('供应商下架商品').')</span>'; ?> </td> </tr> <tr> <td class="tl"> <dl class="fn-clear fn_dl"> <dt> <i date-type="ajax_goods_list" data-id="237" class="iconfont icon-jia disb"></i> <p style="display:inline" target="_blank"><img width="60" src="<?= $item['common_image'] ?>"></p> </dt> <dd> <h3> <?php if($item['common_parent_id']){ ?> <span class="dis_flag"><?=__('分销')?></span> <?php } ?> <p target="_blank"><?= $item['common_name'] ?></p> </h3> <p><?= $item['cat_name'] ?></p> <p><?= ($item['common_code'] ? sprintf(__('商家货号').':%s', $item['common_code']) : '') ?></p> </dd> </dl> </td> <td><?= format_money($item['common_price']); ?></td> <td <?php if($item['common_stock'] < $item['common_alarm']){?> class="colred" <?php }?>><?= $item['common_stock'] ?> <?=__('件')?></td> <td><?php $item['common_sell_time']!=='0000-00-00 00:00:00' ? print($item['common_sell_time']) : print($item['common_add_time']); ?></td> <td> <span class="edit"><a href="<?php echo Yf_Registry::get('url'); ?>?ctl=Seller_Goods&met=online&typ=e&common_id=<?= $item['common_id'] ?>&action=edit_goods"><i class="iconfont icon-zhifutijiao"></i><?=__('编辑')?></a></span> <span class="del"><a data-param="{'id':'<?= $item['common_id'] ?>','ctl':'Seller_Goods','met':'deleteGoodsCommon'}" href="javascript:void(0)"><i class="iconfont icon-lajitong"></i><?=__('删除')?></a></span> </td> </tr> <tr class="tr-goods-list" style="display: none;"> <td colspan="5" class="tl"> <ul class="fn-clear"> <?php if (!empty($goods_detail_rows[$item['common_id']])): foreach ($goods_detail_rows[$item['common_id']] as $g_k => $g_v): ?> <li> <div class="goods-image"> <a herf="" target="_blank"><img width="100" src="<?= $g_v['goods_image']; ?>"></a> </div> <?php if (!empty($g_v['spec'])) { foreach ($g_v['spec'] as $ks => $vs):?> <div class="goods_spec"><?= $ks; ?>:<span><?= $vs ?></span></div> <?php endforeach; } ?> <div class="goods-price"> <?=__('价格')?>:<span><?= format_money($g_v['goods_price']); ?></span></div> <div class="goods-stock"><?=__('库存')?>:<span><?= $g_v['goods_stock'] ?> <?=__('件')?></span></div> <a href="index.php?ctl=<?=$ctl?>&met=goods&gid=<?= $g_v['goods_id'] ?>" target="_blank"><?=__('查看商品详情')?></a> </li> <?php endforeach; endif; ?> </ul> </td> </tr> <?php } ?> 商品搜索: $(".search").on("click", "a.button", function () { $("#search_form").submit(); }); 商品下架: $.post(SITE_URL + '?ctl=Seller_Goods&met=editGoodsCommon&typ=json&act=down', {chk: chk_value}, function (data) { }); $flag = $Goods_CommonModel->editCommon($goods_common_id, array('common_state' => Goods_CommonModel::GOODS_STATE_OFFLINE)); //如果是供货商下架,同时下架其分销商的该商品 if($shop_base['shop_type'] == 2){ $MessageModel = new MessageModel(); $all_dist_common = $Goods_CommonModel->getByWhere(array('common_parent_id' => $goods_common_id)); if(!empty($all_dist_common)){ foreach ($all_dist_common as $k => $v) { $dist_shop_base = $this->shopBaseModel ->getOne($v['shop_id']); $dist_common_row['common_state'] = 0;//下架 //给每个商品下架的店铺发通知 $common_state_remark = '供货商修改了商品-'.$v["common_name"].'!'; $MessageModel->sendMessage('Commodity violation is under the shelf',$dist_shop_base['user_id'], $dist_shop_base['user_name'], $order_id = NULL, $shop_name = NULL, 1, 1, $end_time = Null,$v['common_id'],$goods_id=NULL,$common_state_remark); $Goods_CommonModel->editCommon($v['common_id'],$dist_common_row); } } } 商品上架: $.post(SITE_URL + '?ctl=Seller_Goods&met=editGoodsCommon&typ=json&act=up&me='+me, {chk: chk_value}, function (data) { }); if(request_string('me') == 'lockup'){ $flag = $Goods_CommonModel->editCommon($goods_common_id, array('common_state' => Goods_CommonModel::GOODS_STATE_NORMAL,'common_verify' => Goods_CommonModel::GOODS_STATE_ILLEGAL)); }else{ $flag = $Goods_CommonModel->editCommon($goods_common_id, [ 'common_state' => Goods_CommonModel::GOODS_STATE_NORMAL, 'common_verify' => Goods_CommonModel::GOODS_STATE_NORMAL, 'common_goods_from' => 1 //外部导入一经上架,撕掉外部导入标签 ]); //对goods_base对应的数据上架 $goodsBaseModel = new Goods_BaseModel(); $goods_item = $goodsBaseModel->getByWhere(array("common_id:IN"=> $goods_common_id)); $goods_ids = array_column($goods_item, 'goods_id'); $flag = $goodsBaseModel->editBase($goods_ids, array("goods_is_shelves"=> Goods_BaseModel::GOODS_UP), false); } 删除商品: <label class="del" data-param="{'ctl':'Seller_Goods','met':'deleteGoodsCommonRows'}"><i class="iconfont icon-lajitong"></i><?=__('删除')?></label> $flag = $Goods_CommonModel->removeCommon($goods_common_id); //批量删除分销商的商品 if($shop_base == 2 && !empty($id)){ foreach ($id as $key => $value) { $all_dist_common = $Goods_CommonModel->getByWhere(array('common_parent_id' => $value)); if(!empty($all_dist_common)){ foreach ($all_dist_common as $k => $v) { $Goods_CommonModel->removeCommon($v['common_id']); } } } } #### 2、前台商品列表 文件路径:shop/controllers/Goods/GoodsCtl.php; 方法名:goodslist(); ##### 后台数据 //查询分类品牌和分类关联属性 if ( count($brand_property['common_ids']) == 1 && $brand_property['common_ids'][0] === false ) { $cond_row['common_id'] = -1; } else { $cond_row['common_id:IN'] = $brand_property['common_ids']; } //查找该分类下所有的子分类 $cat_list = $Goods_CatModel->getCatChildId($cat_id); //查找该分类的父级分类 $parent_cat_id = $Goods_CatModel->getCatParentTree($cat_id); $cond_row['cat_id:IN'] = $cat_list; //不显示供货商商品 $shop_list = $shopBaseModel -> getByWhere(array('shop_type' => 1)); $shop_ids = array_column($shop_list,'shop_id'); $cond_row['shop_id:IN'] = $shop_ids; //商品品牌 $cond_row['brand_id:in'] = $brand_id; //商品common_id $cond_row['common_id:IN'] = $com_id; //商品的配送区域 //获取默认区域 $transport_id = request_string('transport_id', isset($cookid_area['city']['id']) ? $cookid_area['city']['id'] : ''); $transport_area = request_string('transport_area', isset($cookid_area['area']) ? $cookid_area['area'] : '请选择地区'); //获取该售卖区域的所有模板 $transport_area_list = $Transport_AreaModel->getAreaTemplate($transport_id); $transport_area_id = array_column($transport_area_list,'id'); $cond_row['transport_area_id:IN'] = $transport_area_id; //pc分站 $sub_site_id = $_COOKIE['sub_site_id']; $pc_site = true; //wap分站 $sub_site_id = request_int('sub_site_id'); $wap_site = true; unset($cond_row['transport_area_id:IN']); //获取站点信息 $sub_site_district_ids = $Sub_SiteModel->getDistrictChildId($sub_site_id); $cond_row['district_id:IN'] = $sub_site_district_ids; //商品搜索(总) if(preg_match('/http:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is',$_REQUEST['keywords'])){ $_REQUEST['keywords'] = ""; } $_REQUEST['keywords'] = $this->strFilter(strip_tags($_REQUEST['keywords'])); //统计中心 Yf_Plugin_Manager::getInstance()->trigger('analyticsKeywords',$analytics_data); //记录搜索关键词 $search_cond_row['search_keyword'] = $search; $search_row = $Search_WordModel->getSearchWordInfo($search_cond_row); if ($search_row) { $search_data['search_nums'] = $search_row['search_nums'] + 1; $flag = $Search_WordModel->editSearchWord($search_row['search_id'], $search_data); } else { $search_data['search_keyword'] = $search; $search_data['search_char_index'] = Text_Pinyin::pinyin($search, ''); $search_data['search_nums'] = 1; $flag = $Search_WordModel->addSearchWord($search_data); } if($sear_row){ $cond_row['common_name:LIKE'] = $sear_row; } $cond_row['shop_status'] = Shop_BaseModel::SHOP_STATUS_OPEN; $actorder = strtolower(request_string('actorder','desc')); //按上架时间排序 $order_row['common_id'] = $actorder; //按销量排序 $order_row['common_salenum'] = $actorder; //按价格排序 $order_row['common_price'] = $actorder; //按评论数排序 $order_row['common_evaluate'] = $actorder; //仅显示有货 $cond_row['common_stock:>'] = 0; //仅显示促销商品 $cond_row['common_is_xian:!='] = 0; $cond_row['common_is_jia:!='] = 0; //自营店铺 $cond_row['shop_self_support'] = 1; //入驻店铺 $cond_row['shop_self_support'] = 0; //价格区间 $cond_row['common_price:>='] = $price_from; $cond_row['common_price:<='] = $price_to; //虚拟商品 $cond_row['common_is_virtual'] = Goods_CommonModel::GOODS_VIRTUAL; //判断是否有属性 $cond_row['common_state'] = Goods_CommonModel::GOODS_STATE_NORMAL; $cond_row['common_verify'] = Goods_CommonModel::GOODS_VERIFY_ALLOW; //推广产品 $recommend_cond_row['common_state'] = Goods_CommonModel::GOODS_STATE_NORMAL; $recommend_cond_row['common_verify'] = Goods_CommonModel::GOODS_VERIFY_ALLOW; //如果有查找的分类就显示该分类下的推广商品 $recommond_cond_row['goods_cat_id'] = $cat_id; //如果没有传递分类就显示最新设置的分类推广 $recommond_order_row['goods_recommend_id'] = 'DESC'; /如果有分站,查询分站 $recommond_cond_row['sub_site_id'] = $sub_site_id; $recommend_row = $Goods_RecommendModel->getRccommonGoodsInfo($recommond_cond_row, $recommond_order_row); //如果商城没有设定推广商品,则将最新发布的四件商品作为推广商品显示 $recommend_row = $Goods_CommonModel->getGoodsList($recommend_cond_row, $recommend_order_row, 1, 4); //热卖推荐,查找商城中销量最多的商品 $hot_cond_row['common_state'] = Goods_CommonModel::GOODS_STATE_NORMAL; $hot_cond_row['common_verify'] = Goods_CommonModel::GOODS_VERIFY_ALLOW; if($sub_site_district_ids){ $hot_cond_row['district_id:IN'] = $sub_site_district_ids; } $hot_order_row['common_salenum'] = 'DESC'; $hot_sale = $Goods_CommonModel->getGoodsList($hot_cond_row, $hot_order_row, 1, 3); $hot_sale = $hot_sale['items']; //获取品牌信息 //如果有查找的分类就显示该分类的相关品牌,如果没有传递分类就不显示品牌 $type_cond_row['cat_id'] = $cat_id; $brand_row = $Goods_TypeModel->getTypeBrand($type_cond_row); //获取分类信息 //如果有品牌就显示该品牌下的分类,如果没有就不显示分类 $tbrand_cond_row['brand_id'] = $brand_id; $cat_row = $Goods_TypeBrandModel->getBrandType($tbrand_cond_row); ##### 前台显示 //显示分类 <?php if($parent_cat){?> <?php foreach($parent_cat as $catkey => $catval):?> <a href="<?= Yf_Registry::get('url') ?>?ctl=Goods_Goods&met=goodslist&cat_id=<?=($catval['cat_id'])?>"><?=($catval['cat_name'])?></a><?php if(!isset($catval['ext'])){ ?><i class="iconfont icon-iconjiantouyou"></i><?php }?> <?php endforeach;?> <?php }?> //限时折扣 <?php if($goods_detail['goods_base']['promotion_type'] == 'xianshi' ){ ?> <i class="group_purchase "><?=__('限时折扣:')?></i> <strong><?=__('直降')?></strong><?=($goods_detail['goods_base']['down_price'])?> <?php if($goods_detail['goods_base']['lower_limit']){ ?> <?php echo sprintf('最低购%s件,',$goods_detail['goods_base']['lower_limit']);?><?php echo $goods_detail['goods_base']['explain'];?> <?php }} ?> //团购 <?php if($goods_detail['goods_base']['promotion_type'] == 'groupbuy') {?> <?php if ($goods_detail['goods_base']['upper_limit']) {?> <i class="group_purchase "><?=__('团购:')?></i> <em><?php echo sprintf('最多限购%s件',$goods_detail['goods_base']['upper_limit']);?></em> <?php } ?> <span><?php echo $goods_detail['goods_base']['remark'];?></span> <?php }?> //加价购 <?php if($goods_detail['goods_base']['increase_info']) { ?> <div class="ncs-mansong"> <i class="group_purchase "><?=__('加价购:')?></i> <span class="sale-rule"> <em><?=($goods_detail['goods_base']['increase_info']['increase_name'])?></em> <?php if(!empty($goods_detail['goods_base']['increase_info']['rule'])) { ?> <?=__('购物满')?><em><?=format_money($goods_detail['goods_base']['increase_info']['rule'][0]['rule_price'])?></em><?=__('即可加价换购最多')?><?php if($goods_detail['goods_base']['increase_info']['rule'][0]['rule_goods_limit']):?><?=($goods_detail['goods_base']['increase_info']['rule'][0]['rule_goods_limit'])?><?=__('样')?><?php endif;?><?=__('商品')?> <?php }?> <span class="sale-rule-more" nctype="show-rule"> <a href="javascript:void(0);"> <?=__('详情')?><i class="iconfont icon-iconjiantouxia"></i> </a> </span> <?php if(!empty($goods_detail['goods_base']['increase_info']['goods'])) {?> <div class="sale-rule-content" style="display: none;" nctype="rule-content"> <div class="title"><span class="sale-name"> <?=($goods_detail['goods_base']['increase_info']['increase_name'])?></span><?=__(',共')?> <strong><?php echo count($goods_detail['goods_base']['increase_info']['rule']);?></strong> <?=__('种活动规则')?><a href="javascript:;" nctype="hide-rule"><?=__('关闭')?></a> </div> <?php foreach($goods_detail['goods_base']['increase_info']['rule'] as $rule) { ?> <div class="content clearfix"> <div class="mjs-tit"> <?=__('购物满')?><em><?=format_money($rule['rule_price'])?></em><?=__('即可加价换购更多')?><?php if($rule['rule_goods_limit']):?><?=($rule['rule_goods_limit'])?><?=__('样')?><?php endif;?><?=__('商品')?> </div> <ul class="mjs-info clearfix"> <?php foreach($rule['redemption_goods'] as $goods) { ?> <li> <a href="<?= Yf_Registry::get('url') ?>?ctl=Goods_Goods&met=goods&type=goods&gid=<?=($goods['goods_id'])?>" title="<?=($goods['goods_name'])?>" target="_blank" class="gift"> <img src="<?=image_thumb($goods['goods_image'],80,80)?>" alt="<?=($goods['goods_name'])?>"> </a>&nbsp; </li> <?php }?> </ul> </div> <?php } ?> </div> <?php } ?> </div> <?php } ?> //满即送 <?php if($goods_detail['mansong_info'] && $goods_detail['mansong_info']['rule'] ) { ?> <div class="ncs-mansong"> <i class="group_purchase "><?=__('满即送:')?></i> <span class="sale-rule"> <?php $rule = $goods_detail['mansong_info']['rule'][0]; ?> <?=__('购物满')?><em><?=format_money($rule['rule_price'])?></em> <?php if(!empty($rule['rule_discount'])) { ?> <?=__(',即享')?><em><?=($rule['rule_discount'])?></em><?=__('元优惠')?> <?php } ?> <?php if(!empty($rule['goods_id'])) { ?> <?=__(',送')?><a href="<?= Yf_Registry::get('url') ?>?ctl=Goods_Goods&met=goods&type=goods&gid=<?=($rule['goods_id'])?>" title="<?=($rule['goods_name'])?>" target="_blank"><?=__('赠品')?></a> <?php } ?> </span> <span class="sale-rule-more" nctype="show-rule"><a href="javascript:void(0);"><?=__('共')?><strong><?php echo count($goods_detail['mansong_info']['rule']);?></strong><?=__('项,展开')?><i class="iconfont icon-iconjiantouxia"></i></a></span> <div class="sale-rule-content" style="display: none;" nctype="rule-content"> <div class="title"><span class="sale-name"><?=__('满即送')?></span><?=__('共')?><strong><?php echo count($goods_detail['mansong_info']['rule']);?></strong><?=__('项,促销活动规则')?><a href="javascript:;" nctype="hide-rule"><?=__('关闭')?></a></div> <div class="content clearfix"> <div class="mjs-tit"><?=($goods_detail['mansong_info']['mansong_name'])?> <time>(<?=($goods_detail['mansong_info']['mansong_start_time'])?> -- <?=($goods_detail['mansong_info']['mansong_end_time'])?> )</time> </div> <ul class="mjs-info clearfix"> <?php foreach($goods_detail['mansong_info']['rule'] as $rule) { ?> <li> <span class="sale-rule"><?=__('购物满')?><em><?=format_money($rule['rule_price'])?></em> <?php if(!empty($rule['rule_discount'])) { ?> <?=__(', 即享')?><em><?=(($rule['rule_discount']))?></em><?=__('元优惠')?> <?php } ?> <?php if(!empty($rule['goods_id'])) { ?> <?=__(', 送 ')?><a href="<?= Yf_Registry::get('url') ?>?ctl=Goods_Goods&met=goods&type=goods&gid=<?=($rule['goods_id'])?>" title="<?=($rule['goods_name'])?>" target="_blank" class="gift"> <img src="<?=image_thumb($rule['goods_image'],60,60)?>" alt="<?=($rule['goods_name'])?>"> </a>&nbsp;<br><?=__(',数量有限,赠完为止。 ')?> <?php } ?> </span> </li> <?php } ?> </ul> <div class="mjs-remark wp100 overflow"><?=($goods_detail['mansong_info']['mansong_remark'])?></div> </div> </div> </div> <?php } ?> 加入购物车 $.ajax({ url: SITE_URL + '?ctl=Buyer_Cart&met=addCart&typ=json', data: {goods_id:goods_id, goods_num: goods_num}, dataType: "json", contentType: "application/json;charset=utf-8", async: false, success: function (a) { if (a.status == 250) { Public.tips.error(a.msg); } else { //加入购物车成功后,修改购物车数量 $.ajax({ type: "GET", url: SITE_URL + "?ctl=Buyer_Cart&met=getCartGoodsNum&typ=json", data: {}, dataType: "json", success: function(data){ getCartList(); $('#cart_num').html(data.data.cart_count); $('.cart_num_toolbar').html(data.data.cart_count); } }); $.dialog({ title: "<?=__('加入购物车')?>", height: 100, width: 250, lock: true, drag: false, content: 'url: '+SITE_URL + '?ctl=Buyer_Cart&met=add&typ=e' }); } }, failure: function (a) { Public.tips.error('<?=__('操作失败!')?>'); } }); 收藏商品 $.post(SITE_URL + '?ctl=Goods_Goods&met=collectGoods&typ=json',{goods_id:e},function(data) { if(data.status == 200) { Public.tips.success(data.data.msg); $(".icon-icoheart").addClass("icon-taoxinshi").removeClass('icon-icoheart'); //toolbar显示收藏效果 $("#collect_lable").removeClass('icon-icoheart'); $("#collect_lable").addClass('icon-taoxinshi').addClass('bbc_color'); } else { Public.tips.error(data.data.msg); } }); 收藏店铺 $.post(SITE_URL + '?ctl=Shop&met=addCollectShop&typ=json',{shop_id:e},function(data) { });