You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
100
hyhproject/mobile2/model/Articles.php
Executable file
100
hyhproject/mobile2/model/Articles.php
Executable file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 文章类
|
||||
*/
|
||||
class Articles extends Base{
|
||||
|
||||
/**
|
||||
* 获取咨询中中心所有文章
|
||||
*/
|
||||
public function getArticles(){
|
||||
// 获取咨询中心下的所有分类id
|
||||
$catId = input('catId');
|
||||
$rs = $this->alias('a')
|
||||
->field('a.*')
|
||||
->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
|
||||
->where(['a.catId'=>$catId,
|
||||
'a.isShow'=>1,
|
||||
'a.dataFlag'=>1,
|
||||
'ac.dataFlag'=>1,
|
||||
'ac.isShow'=>1,
|
||||
'ac.catType'=>0,
|
||||
])
|
||||
->order('createTime desc')
|
||||
->paginate((int)input('pagesize'));
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取资讯文章
|
||||
*/
|
||||
public function getNewsById(){
|
||||
$id = (int)input('id');
|
||||
WSTArticleVisitorNum($id);// 统计文章访问量
|
||||
$article = $this->alias('a')
|
||||
->field('a.*')
|
||||
->join('__ARTICLE_CATS__ ac','a.catId=ac.catId','inner')
|
||||
->where('ac.catType=0 and a.dataFlag=1 and a.isShow=1')
|
||||
->cache(true)
|
||||
->find($id);
|
||||
// 图片延迟加载
|
||||
$article['articleContent']=htmlspecialchars_decode($article['articleContent']);
|
||||
$rule = '/<img src="\/(wstmartp.*?)"/';
|
||||
preg_match_all($rule, $article['articleContent'],$images);
|
||||
foreach($images[0] as $k=>$v){
|
||||
$article['articleContent'] = str_replace($v, "<img src='/".WSTImg($images[1][$k],3)."'", $article['articleContent']);
|
||||
}
|
||||
$articleId = cookie("mobile_like_articleId");
|
||||
$articleId = is_array($articleId)?$articleId:[];
|
||||
$rc = !empty($articleId)?in_array($id,$articleId):'';
|
||||
if($rc){
|
||||
$article['likeState'] = 1;
|
||||
}else{
|
||||
$article['likeState'] = 0;
|
||||
}
|
||||
return $article;
|
||||
}
|
||||
/**
|
||||
* 点赞
|
||||
*/
|
||||
public function like(){
|
||||
$id = input("param.id/d");
|
||||
//判断记录是否存在
|
||||
$articleId = cookie("mobile_like_articleId");
|
||||
$articleId = is_array($articleId)?$articleId:[];
|
||||
$rc = !empty($articleId)?in_array($id,$articleId):'';
|
||||
if($rc)return WSTReturn("已点赞成功", -1);
|
||||
$rs = $this->where(['isShow'=>1,'dataFlag'=>1,'articleId'=>$id])->setInc('likeNum',1);
|
||||
//判断是否点赞成功
|
||||
if(false !== $rs){
|
||||
array_push($articleId,$id);
|
||||
cookie("mobile_like_articleId",$articleId,25920000);
|
||||
return WSTReturn("点赞成功", 1);
|
||||
}else{
|
||||
return WSTReturn($this->getError(),-1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取资讯中心的子集分类
|
||||
*/
|
||||
public function getChildInfos(){
|
||||
$infos = cache('NEW_INFOS');
|
||||
$i = 0;
|
||||
if(!$infos){
|
||||
$data = Db::name('article_cats')->cache(true)->select();
|
||||
foreach($data as $k=>$v){
|
||||
if($v['parentId']== 8){
|
||||
$infos[$i]['catId'] = $v['catId'];
|
||||
$infos[$i]['catName'] = $v['catName'];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
cache('NEW_INFOS',$infos);
|
||||
}
|
||||
return $infos;
|
||||
}
|
||||
}
|
8
hyhproject/mobile2/model/Base.php
Executable file
8
hyhproject/mobile2/model/Base.php
Executable file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Base as CBase;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 基础模型器
|
||||
*/
|
||||
class Base extends CBase {}
|
173
hyhproject/mobile2/model/Goods.php
Executable file
173
hyhproject/mobile2/model/Goods.php
Executable file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Goods as CGoods;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品类
|
||||
*/
|
||||
class Goods extends CGoods{
|
||||
/**
|
||||
* 获取列表
|
||||
*/
|
||||
public function pageQuery($goodsCatIds = []){
|
||||
//查询条件
|
||||
$keyword = input('keyword');
|
||||
$brandId = input('brandId/d');
|
||||
$where = $where2 = [];
|
||||
$where['goodsStatus'] = 1;
|
||||
$where['g.dataFlag'] = 1;
|
||||
$where['isSale'] = 1;
|
||||
$where['goodsCatIdPath']=['notlike','389'.'%'];
|
||||
if($keyword!='')$where['goodsName'] = ['like','%'.$keyword.'%'];
|
||||
if($brandId>0)$where['g.brandId'] = $brandId;
|
||||
//排序条件
|
||||
$orderBy = input('condition/d',0);
|
||||
$orderBy = ($orderBy>=0 && $orderBy<=4)?$orderBy:0;
|
||||
$order = (input('desc/d',0)==1)?1:0;
|
||||
$pageBy = ['saleNum','shopPrice','visitNum','saleTime'];
|
||||
$pageOrder = ['desc','asc'];
|
||||
if(!empty($goodsCatIds))$where['goodsCatIdPath'] = ['like',implode('_',$goodsCatIds).'_%'];
|
||||
$list = Db::name('goods')->alias('g')->join("__SHOPS__ s","g.shopId = s.shopId")->join('__GOODS_SCORES__ gs','gs.goodsId=g.goodsId')
|
||||
->where($where)
|
||||
->field('g.goodsId,goodsName,saleNum,shopPrice,marketPrice,isSpec,goodsImg,appraiseNum,visitNum,s.shopId,shopName,isSelf,isFreeShipping,gallery,gs.totalScore,gs.totalUsers')
|
||||
->order($pageBy[$orderBy]." ".$pageOrder[$order].",goodsId asc")
|
||||
->paginate(input('pagesize/d'))->toArray();
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品资料在前台展示
|
||||
*/
|
||||
public function getBySale($goodsId){
|
||||
$key = input('key');
|
||||
// 浏览量
|
||||
$this->where('goodsId',$goodsId)->setInc('visitNum',1);
|
||||
$rs = Db::name('goods')->where(['goodsId'=>$goodsId,'dataFlag'=>1])->find();
|
||||
if(!empty($rs)){
|
||||
$rs['read'] = false;
|
||||
//判断是否可以公开查看
|
||||
$viKey = WSTShopEncrypt($rs['shopId']);
|
||||
if(($rs['isSale']==0 || $rs['goodsStatus']==0) && $viKey != $key)return [];
|
||||
if($key!='')$rs['read'] = true;
|
||||
//获取店铺信息
|
||||
$rs['shop'] = model('shops')->getBriefShop((int)$rs['shopId']);
|
||||
if(empty($rs['shop']))return [];
|
||||
//获取商店的授权商店分类和商铺电话信息
|
||||
$goodsCats = Db::name('cat_shops')->alias('cs')->join('__GOODS_CATS__ gc','cs.catId=gc.catId and gc.dataFlag=1','left')->join('__SHOPS__ s','s.shopId = cs.shopId','left')
|
||||
->where('cs.shopId',$rs['shopId'])->field('cs.shopId,s.shopTel,gc.catId,gc.catName')->select();
|
||||
$rs['shop']['catId'] = $goodsCats[0]['catId'];
|
||||
$rs['shop']['shopTel'] = $goodsCats[0]['shopTel'];
|
||||
|
||||
$cat = [];
|
||||
foreach ($goodsCats as $v){
|
||||
$cat[] = $v['catName'];
|
||||
}
|
||||
$rs['shop']['cat'] = implode(',',$cat);
|
||||
if(empty($rs['shop']))return [];
|
||||
$gallery = [];
|
||||
$gallery[] = $rs['goodsImg'];
|
||||
|
||||
if($rs['gallery']!=''){//有多个图片就把多个一维图片地址合成一个数组
|
||||
$tmp = explode(',',$rs['gallery']);
|
||||
$gallery = array_merge($gallery,$tmp);
|
||||
}
|
||||
$rs['gallery'] = $gallery;
|
||||
//获取规格值
|
||||
$specs = Db::name('spec_cats')->alias('gc')->join('__SPEC_ITEMS__ sit','gc.catId=sit.catId','inner')
|
||||
->where(['sit.goodsId'=>$goodsId,'gc.isShow'=>1,'sit.dataFlag'=>1])
|
||||
->field('gc.isAllowImg,gc.catName,sit.catId,sit.itemId,sit.itemName,sit.itemImg')
|
||||
->order('gc.isAllowImg desc,gc.catSort asc,gc.catId asc')->select();
|
||||
$rs['spec']=[];
|
||||
//把属于同一个分类的规格整合到一块
|
||||
foreach ($specs as $key =>$v){
|
||||
$rs['spec'][$v['catId']]['name'] = $v['catName'];
|
||||
$rs['spec'][$v['catId']]['list'][] = $v;
|
||||
}
|
||||
//dump($rs['spec']);die;
|
||||
//获取销售规格,商品规格的具体属性
|
||||
$sales = Db::name('goods_specs')->where('goodsId',$goodsId)->field('id,isDefault,productNo,specIds,marketPrice,specPrice,specStock')->select();
|
||||
if(!empty($sales)){
|
||||
//将规格ID格式如:3:4:5:6:7,设为数组键名,与$rs['spec']['catId']['list']['itemId'] 对应
|
||||
/*实例
|
||||
//$specs转换后$rs['spec']数据
|
||||
[11] => array(2) {//11代表规格分类ID
|
||||
["name"] => string(12) "机身颜色"//规格分类名称
|
||||
["list"] => array(2) {//当前分类11下的数据
|
||||
[0] => array(6) {
|
||||
["isAllowImg"] => int(1)
|
||||
["catName"] => string(12) "机身颜色"
|
||||
["catId"] => int(11)
|
||||
["itemId"] => int(5)//这个即代表数据的ID,3:4:(5):6:7就是对应的这个
|
||||
["itemName"] => string(6) "黄色"
|
||||
["itemImg"] => string(44) "upload/goods/2017-11/5a0a7e2ee935c_thumb.jpg"
|
||||
}
|
||||
[1] => array(6) {
|
||||
["isAllowImg"] => int(1)
|
||||
["catName"] => string(12) "机身颜色"
|
||||
["catId"] => int(11)
|
||||
["itemId"] => int(10)
|
||||
["itemName"] => string(6) "灰色"
|
||||
["itemImg"] => string(44) "upload/goods/2017-11/5a0a7e3970fed_thumb.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
//$sales原始数据
|
||||
[0] => array(7) {
|
||||
["id"] => int(3)
|
||||
["isDefault"] => int(1)
|
||||
["productNo"] => string(1) "3"
|
||||
["specIds"] => string(9) "3:4:5:6:7"
|
||||
["marketPrice"] => string(7) "1070.00"
|
||||
["specPrice"] => string(7) "1002.00"
|
||||
["specStock"] => int(0)
|
||||
}
|
||||
//$sales下面转换后数据
|
||||
["3:4:5:6:7"] => array(6) {
|
||||
["id"] => int(3)
|
||||
["isDefault"] => int(1)
|
||||
["productNo"] => string(1) "3"
|
||||
["marketPrice"] => string(7) "1070.00"
|
||||
["specPrice"] => string(7) "1002.00"
|
||||
["specStock"] => int(0)
|
||||
}*/
|
||||
foreach ($sales as $key =>$v){
|
||||
$str = explode(':',$v['specIds']);
|
||||
sort($str);
|
||||
unset($v['specIds']);
|
||||
$rs['saleSpec'][implode(':',$str)] = $v;
|
||||
}
|
||||
}
|
||||
//获取商品属性
|
||||
$rs['attrs'] = Db::name('attributes')->alias('a')->join('goods_attributes ga','a.attrId=ga.attrId','inner')
|
||||
->where(['a.isShow'=>1,'dataFlag'=>1,'goodsId'=>$goodsId])->field('a.attrName,ga.attrVal')
|
||||
->order('attrSort asc')->select();
|
||||
//获取商品评分
|
||||
$rs['scores'] = Db::name('goods_scores')->where('goodsId',$goodsId)->field('totalScore,totalUsers')->find();
|
||||
$rs['scores']['totalScores'] = ($rs['scores']['totalScore']==0)?5:WSTScore($rs['scores']['totalScore'],$rs['scores']['totalUsers'],5,0,3);
|
||||
WSTUnset($rs, 'totalUsers');
|
||||
//关注
|
||||
$f = model('Favorites');
|
||||
$rs['favShop'] = $f->checkFavorite($rs['shopId'],1);
|
||||
$rs['favGood'] = $f->checkFavorite($goodsId,0);
|
||||
}
|
||||
//dump($rs);die;
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
public function historyQuery(){
|
||||
$ids = cookie("wx_history_goods");
|
||||
if(empty($ids))return [];
|
||||
$where = [];
|
||||
$where['isSale'] = 1;
|
||||
$where['goodsStatus'] = 1;
|
||||
$where['dataFlag'] = 1;
|
||||
$where['goodsId'] = ['in',$ids];
|
||||
$orderBy = "field(`goodsId`,".implode(',',$ids).")";
|
||||
return Db::name('goods')
|
||||
->where($where)->field('goodsId,goodsName,goodsImg,saleNum,shopPrice')
|
||||
->order($orderBy)
|
||||
->paginate((int)input('pagesize'))->toArray();
|
||||
}
|
||||
}
|
27
hyhproject/mobile2/model/GoodsAppraises.php
Executable file
27
hyhproject/mobile2/model/GoodsAppraises.php
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\GoodsAppraises as CGoodsAppraises;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 评价类
|
||||
*/
|
||||
class GoodsAppraises extends CGoodsAppraises{
|
||||
/**
|
||||
* 获取评论
|
||||
*/
|
||||
public function getAppr(){
|
||||
$oId = (int)input('oId');
|
||||
$uId = (int)session('WST_USER.userId');
|
||||
$gId = (int)input('gId');
|
||||
$specId = (int)input('sId');
|
||||
$orderGoodsId = (int)input('orderGoodsId');
|
||||
$rs = $this->where(['orderId'=>$oId,'userId'=>$uId,'goodsId'=>$gId,'goodsSpecId'=>$specId,'orderGoodsId'=>$orderGoodsId])->find();
|
||||
if($rs!==false){
|
||||
$rs = !empty($rs)?$rs:['goodsScore'=>'','timeScore'=>'','serviceScore'=>'','content'=>''];
|
||||
return WSTReturn('',1,$rs);
|
||||
}
|
||||
return WSTReturn('获取出错',-1);
|
||||
}
|
||||
|
||||
}
|
75
hyhproject/mobile2/model/GoodsCats.php
Executable file
75
hyhproject/mobile2/model/GoodsCats.php
Executable file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use think\Cache;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 商品分类类
|
||||
*/
|
||||
class GoodsCats extends Base{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function getGoodsCats(){
|
||||
$list = cache('WST_CACHE_GOODS_CAT_MOB');
|
||||
if(!$list){
|
||||
//查询一级分类
|
||||
$trs1s = $this->where(["dataFlag"=>1,"isShow"=>1,"parentId"=>0])->field('catId,parentId,catName')->order('catSort asc')->select();
|
||||
$trs1 = array();
|
||||
$list = array();
|
||||
$rs2 = array();
|
||||
$maprs = array();
|
||||
$ids = array();
|
||||
foreach ($trs1s as $key =>$v){
|
||||
$trs1[$key]['catId'] = $v['catId'];
|
||||
$trs1[$key]['parentId'] = $v['parentId'];
|
||||
$trs1[$key]['catName'] = $v['catName'];
|
||||
$ids[] = $v['catId'];
|
||||
}
|
||||
$ids[] = -1;
|
||||
//查询二级分类
|
||||
$trs2s = $this->where("dataFlag=1 and isShow=1 and parentId in(".implode(',',$ids).")")->field('catId,parentId,catName')->order('catSort asc')->select();
|
||||
$trs2 = array();
|
||||
$ids = array();
|
||||
foreach ($trs2s as $key =>$v){
|
||||
$trs2[$key]['catId'] = $v['catId'];
|
||||
$trs2[$key]['parentId'] = $v['parentId'];
|
||||
$trs2[$key]['catName'] = $v['catName'];
|
||||
}
|
||||
foreach ($trs2 as $v2){
|
||||
$ids[] = $v2['catId'];
|
||||
$maprs[$v2['parentId']][] = $v2;
|
||||
}
|
||||
$ids[] = -1;
|
||||
//查询三级分类
|
||||
$trs3s = $this->where("dataFlag=1 and isShow=1 and parentId in(".implode(',',$ids).")")->field('catId,parentId,catName,catImg')->order('catSort asc')->select();
|
||||
$trs3 = array();
|
||||
$ids = array();
|
||||
foreach ($trs3s as $key =>$v){
|
||||
$trs3[$key]['catId'] = $v['catId'];
|
||||
$trs3[$key]['parentId'] = $v['parentId'];
|
||||
$trs3[$key]['catName'] = $v['catName'];
|
||||
$trs3[$key]['catImg'] = strval($v['catImg']);
|
||||
}
|
||||
foreach ($trs3 as $v2){
|
||||
$maprs[$v2['parentId']][] = $v2;
|
||||
}
|
||||
//倒序建立樹形
|
||||
foreach ($trs2 as $v2){
|
||||
$v2['childList'] = [];
|
||||
if(isset($maprs[$v2['catId']]))$v2['childList'] = $maprs[$v2['catId']];
|
||||
$rs2[] = $v2;
|
||||
}
|
||||
foreach ($trs1 as $v2){
|
||||
foreach ($rs2 as $vv2){
|
||||
if($vv2['parentId']==$v2['catId']){
|
||||
$v2['childList'][] = $vv2;
|
||||
}
|
||||
}
|
||||
$list[] = $v2;
|
||||
}
|
||||
Cache::set('WST_CACHE_GOODS_CAT_MOB',$list);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
68
hyhproject/mobile2/model/Index.php
Executable file
68
hyhproject/mobile2/model/Index.php
Executable file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Tags as T;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认类
|
||||
*/
|
||||
class Index extends Base{
|
||||
/**
|
||||
* 楼层
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$limit = (int)input('post.currPage');//楼层页码
|
||||
if($limit>9)return;
|
||||
$cacheData = cache('MO_CATS_ADS'.$limit);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('goods_cats')->where(['dataFlag'=>1,'isShow'=>1,'parentId'=>0,'isFloor'=>1])->field('catId,catName')->order('catSort asc')->limit($limit,1)->select();//按设定排序获取分类名称,异步下拉加载,传输楼层的层楼
|
||||
if($rs){
|
||||
$rs= $rs[0];//用select就选第一个,其实可以改成find
|
||||
$t = new T();
|
||||
$rs['ads'] = $t->listAds('mo-ads-'.$limit,'1');//获取手机版楼层页面的广告图
|
||||
$rs['goods'] = Db::name('goods')->alias('g')->join('__RECOMMENDS__ r','g.goodsId=r.dataId')->join('__GOODS_SCORES__ gs','gs.goodsId=g.goodsId')
|
||||
->where(['r.goodsCatId'=>$rs['catId'],'g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'r.dataSrc'=>0,'r.dataType'=>1])
|
||||
->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.marketPrice,g.saleNum,gs.totalScore,gs.totalUsers')->order('r.dataSort asc')->limit(8)->select();
|
||||
if(empty($rs['goods'])){
|
||||
$rs['goods'] = Db::name('goods')->alias('g')->join('__GOODS_SCORES__ gs','gs.goodsId=g.goodsId')
|
||||
->where(['g.goodsCatIdPath'=>['like',$rs['catId'].'_%'],'g.isSale'=>1,'g.dataFlag'=>1,'g.goodsStatus'=>1,'g.isHot'=>1])
|
||||
->field('g.goodsId,g.goodsName,g.goodsImg,g.shopPrice,g.marketPrice,g.saleNum,gs.totalScore,gs.totalUsers')
|
||||
->order('saleNum desc,goodsId asc')->limit(8)->select();
|
||||
}
|
||||
if($rs['goods']){
|
||||
foreach ($rs['goods'] as $key =>$v){
|
||||
$rs['goods'][$key]['praiseRate'] = ($v['totalScore']>0)?(sprintf("%.2f",$v['totalScore']/($v['totalUsers']*15))*100).'%':'100%';
|
||||
}
|
||||
}
|
||||
$rs['currPage'] = $limit;
|
||||
}
|
||||
cache('MO_CATS_ADS'.$limit,$rs,86400);
|
||||
return $rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统消息
|
||||
*/
|
||||
function getSysMsg($msg='',$order='',$follow='',$history=''){
|
||||
$data = [];
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
if($msg!=''){
|
||||
$data['message']['num'] = Db::name('messages')->where(['receiveUserId'=>$userId,'msgStatus'=>0,'dataFlag'=>1])->count();
|
||||
}
|
||||
if($order!=''){
|
||||
$data['order']['waitPay'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>-2,'dataFlag'=>1])->count();
|
||||
$data['order']['waitSend'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>0,'dataFlag'=>1])->count();
|
||||
$data['order']['waitReceive'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>1,'dataFlag'=>1])->count();
|
||||
$data['order']['waitAppraise'] = Db::name('orders')->where(['userId'=>$userId,'orderStatus'=>2,'isAppraise'=>0,'dataFlag'=>1])->count();
|
||||
}
|
||||
if($follow!=''){
|
||||
$data['follow']['goods'] = Db::name('favorites')->where(['userId'=>$userId,'favoriteType'=>0])->count();
|
||||
$data['follow']['shops'] = Db::name('favorites')->where(['userId'=>$userId,'favoriteType'=>1])->count();
|
||||
}
|
||||
if($history!=''){
|
||||
$history = cookie("wx_history_goods");
|
||||
$data['history']['num'] = count($history);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
11
hyhproject/mobile2/model/Orders.php
Executable file
11
hyhproject/mobile2/model/Orders.php
Executable file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Orders as COrders;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 订单类
|
||||
*/
|
||||
class Orders extends COrders{
|
||||
|
||||
}
|
9
hyhproject/mobile2/model/Payments.php
Executable file
9
hyhproject/mobile2/model/Payments.php
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Payments as CPayments;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 支付管理业务处理
|
||||
*/
|
||||
class Payments extends CPayments{
|
||||
}
|
134
hyhproject/mobile2/model/Shops.php
Executable file
134
hyhproject/mobile2/model/Shops.php
Executable file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Shops as CShops;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 门店类
|
||||
*/
|
||||
class Shops extends CShops{
|
||||
/**
|
||||
* 店铺街列表
|
||||
*/
|
||||
public function pageQuery($pagesize){
|
||||
$catId = (int)input("id");
|
||||
$keyword = input("keyword");
|
||||
$condition = input("condition");
|
||||
$desc = input("desc");
|
||||
$datas = array('sort'=>array('1'=>'ss.totalScore/ss.totalUsers'),'desc'=>array('desc','asc'));
|
||||
$rs = $this->alias('s');
|
||||
$where = [];
|
||||
$where['s.dataFlag'] = 1;
|
||||
$where['s.shopStatus'] = 1;
|
||||
$where['s.applyStatus'] = 2;
|
||||
if($keyword!='')$where['s.shopName'] = ['like','%'.$keyword.'%'];
|
||||
if($catId>0){
|
||||
$rs->join('__CAT_SHOPS__ cs','cs.shopId = s.shopId','left');
|
||||
$where['cs.catId'] = $catId;
|
||||
}
|
||||
$order = ['s.shopId'=>'asc'];
|
||||
if($condition>0){
|
||||
$order = [$datas['sort'][$condition]=>$datas['desc'][$desc]];
|
||||
}
|
||||
$page = $rs->join('__SHOP_SCORES__ ss','ss.shopId = s.shopId','left')
|
||||
->where($where)->order($order)
|
||||
->field('s.shopId,s.shopImg,s.shopName,s.shopCompany,ss.totalScore,ss.totalUsers,ss.goodsScore,ss.goodsUsers,ss.serviceScore,ss.serviceUsers,ss.timeScore,ss.timeUsers,s.areaIdPath')
|
||||
->paginate($pagesize)->toArray();
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
//商品列表
|
||||
$goods = db('goods')->where(['dataFlag'=> 1,'isSale'=>1,'goodsStatus'=> 1,'shopId'=> $v["shopId"]])->field('goodsId,goodsName,shopPrice,goodsImg')
|
||||
->order('saleTime desc')->limit(4)->select();
|
||||
$page['Rows'][$key]['goods'] = $goods;
|
||||
}
|
||||
if(empty($page['Rows']))return $page;
|
||||
$shopIds = [];
|
||||
$areaIds = [];
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
$shopIds[] = $v['shopId'];
|
||||
$tmp = explode('_',$v['areaIdPath']);
|
||||
$areaIds[] = $tmp[1];
|
||||
$page['Rows'][$key]['areaId'] = $tmp[1];
|
||||
//总评分
|
||||
$page['Rows'][$key]['totalScore'] = WSTScore($v["totalScore"]/3, $v["totalUsers"]);
|
||||
$page['Rows'][$key]['goodsScore'] = WSTScore($v['goodsScore'],$v['goodsUsers']);
|
||||
$page['Rows'][$key]['serviceScore'] = WSTScore($v['serviceScore'],$v['serviceUsers']);
|
||||
$page['Rows'][$key]['timeScore'] = WSTScore($v['timeScore'],$v['timeUsers']);
|
||||
}
|
||||
$rccredMap = [];
|
||||
$goodsCatMap = [];
|
||||
$areaMap = [];
|
||||
//认证、地址、分类
|
||||
if(!empty($shopIds)){
|
||||
$rccreds = Db::name('shop_accreds')->alias('sac')->join('__ACCREDS__ a','a.accredId=sac.accredId and a.dataFlag=1','left')
|
||||
->where('shopId','in',$shopIds)->field('sac.shopId,accredName,accredImg')->select();
|
||||
foreach ($rccreds as $v){
|
||||
$rccredMap[$v['shopId']][] = $v;
|
||||
}
|
||||
$goodsCats = Db::name('cat_shops')->alias('cs')->join('__GOODS_CATS__ gc','cs.catId=gc.catId and gc.dataFlag=1','left')
|
||||
->where('shopId','in',$shopIds)->field('cs.shopId,gc.catName')->select();
|
||||
foreach ($goodsCats as $v){
|
||||
$goodsCatMap[$v['shopId']][] = $v['catName'];
|
||||
}
|
||||
$areas = Db::name('areas')->alias('a')->join('__AREAS__ a1','a1.areaId=a.parentId','left')
|
||||
->where('a.areaId','in',$areaIds)->field('a.areaId,a.areaName areaName2,a1.areaName areaName1')->select();
|
||||
foreach ($areas as $v){
|
||||
$areaMap[$v['areaId']] = $v;
|
||||
}
|
||||
}
|
||||
foreach ($page['Rows'] as $key =>$v){
|
||||
$page['Rows'][$key]['accreds'] = (isset($rccredMap[$v['shopId']]))?$rccredMap[$v['shopId']]:[];
|
||||
$page['Rows'][$key]['catshops'] = (isset($goodsCatMap[$v['shopId']]))?implode(',',$goodsCatMap[$v['shopId']]):'';
|
||||
$page['Rows'][$key]['areas']['areaName1'] = (isset($areaMap[$v['areaId']]['areaName1']))?$areaMap[$v['areaId']]['areaName1']:'';
|
||||
$page['Rows'][$key]['areas']['areaName2'] = (isset($areaMap[$v['areaId']]['areaName2']))?$areaMap[$v['areaId']]['areaName2']:'';
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
/**
|
||||
* 获取卖家中心信息
|
||||
*/
|
||||
public function getShopSummary(){
|
||||
$shopId = (int)input('shopId',1);
|
||||
$shop = $this->alias('s')->join('__SHOP_SCORES__ cs','cs.shopId = s.shopId','left')->join('__SHOP_CONFIGS__ sc','sc.shopId = s.shopId','left')
|
||||
->where(['s.shopId'=>$shopId,'dataFlag'=>1])
|
||||
->field('s.shopId,shopImg,shopName,shopkeeper,shopAddress,shopQQ,shopTel,serviceStartTime,serviceEndTime,isInvoice,invoiceRemarks,cs.*,sc.shopBanner')
|
||||
->find();
|
||||
//评分
|
||||
$scores['totalScore'] = WSTScore($shop['totalScore'],$shop['totalUsers']);
|
||||
$scores['goodsScore'] = WSTScore($shop['goodsScore'],$shop['goodsUsers']);
|
||||
$scores['serviceScore'] = WSTScore($shop['serviceScore'],$shop['serviceUsers']);
|
||||
$scores['timeScore'] = WSTScore($shop['timeScore'],$shop['timeUsers']);
|
||||
WSTUnset($shop, 'totalUsers,goodsUsers,serviceUsers,timeUsers');
|
||||
$shop['scores'] = $scores;
|
||||
//认证
|
||||
$accreds = $this->shopAccreds($shopId);
|
||||
$shop['accreds'] = $accreds;
|
||||
return ['shop'=>$shop];
|
||||
}
|
||||
/**
|
||||
* 自营店铺楼层
|
||||
*/
|
||||
public function getFloorData(){
|
||||
$limit = (int)input('post.currPage');
|
||||
$cacheData = cache('WX_SHOP_FLOOR'.$limit);
|
||||
if($cacheData)return $cacheData;
|
||||
$rs = Db::name('shop_cats')->where(['dataFlag'=>1,'isShow'=>1,'parentId'=>0,'shopId'=>1])->field('catId,catName')->order('catSort asc')->limit($limit,1)->select();
|
||||
if($rs){
|
||||
$rs= $rs[0];
|
||||
$goods = Db::name('goods')->where('shopCatId1','=',$rs['catId'])->where(['dataFlag'=>1,'goodsStatus'=>1])->field('goodsId,goodsName,goodsImg,shopPrice,saleNum')->order('isHot desc')->limit(4)->select();
|
||||
$rs['goods'] = $goods;
|
||||
$rs['currPage'] = $limit;
|
||||
}
|
||||
cache('WX_SHOP_FLOOR'.$limit,$rs,86400);
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* 根据订单id 获取店铺名称
|
||||
*/
|
||||
public function getShopName($oId){
|
||||
return $this->alias('s')
|
||||
->join('__ORDERS__ o',"s.shopId=o.shopId",'inner')
|
||||
->where("o.orderId=$oId")
|
||||
->value('s.shopName');
|
||||
|
||||
}
|
||||
}
|
28
hyhproject/mobile2/model/Users.php
Executable file
28
hyhproject/mobile2/model/Users.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace wstmart\mobile\model;
|
||||
use wstmart\common\model\Users as CUsers;
|
||||
use Think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 用户类
|
||||
*/
|
||||
class Users extends CUsers{
|
||||
/**
|
||||
* 验证用户支付密码
|
||||
*/
|
||||
function checkPayPwd(){
|
||||
$payPwd = input('payPwd');
|
||||
$decrypt_data = WSTRSA($payPwd);
|
||||
if($decrypt_data['status']==1){
|
||||
$payPwd = $decrypt_data['data'];
|
||||
}else{
|
||||
return WSTReturn('验证失败');
|
||||
}
|
||||
$userId = (int)session('WST_USER.userId');
|
||||
$rs = $this->field('payPwd,loginSecret')->find($userId);
|
||||
if($rs['payPwd']==md5($payPwd.$rs['loginSecret'])){
|
||||
return WSTReturn('',1);
|
||||
}
|
||||
return WSTReturn('支付密码错误',-1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user