| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- namespace app\shop\controller;
- use app\common\controller\Frontend;
- use app\common\library\Image;
- use app\common\model\Config;
- use GuzzleHttp\json_decode;
- use think\cache\driver\Redis;
- class Goods extends Frontend
- {
- protected $noNeedLogin = [''];
- protected $noNeedRight = '*';
- protected $layout = '';
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 主页
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function index(){
- $cats = db('goods_cats')->where(['status'=>1])->order('sort asc,id asc')->select();
- foreach ($cats as $k=>$v)
- {
- $start=strtotime(date("Y-m-d {$v['start']}"));
- $end=strtotime(date("Y-m-d {$v['end']}"));
- /*未开始*/
- if(time()<$start)
- {
- $cats[$k]['jctime1']=$start-time();
- $cats[$k]['flag']=1;
- }elseif(time()>=$start && time()<$end)
- {
- $cats[$k]['jctime1']=$end-time();
- $cats[$k]['flag']=2;
- }else{
- $cats[$k]['flag']=0;
- $cats[$k]['jctime1']=0;
- }
- }
- $sinfo=db('studio')->where(['title'=>$this->auth->login_studio])->find();
- $awards = \app\common\model\Trade::getAwardTotal();
- //var_dump($awards);
- $counts = \app\common\model\Trade::getReleaseTotal($this->auth->id);
- $awards = [
- 'total'=> isset($awards['total'])? $awards['total'] : 0,
- 'total_usdt'=> isset($awards['total_usdt'])? $awards['total_usdt'] : 0,
- 'release_total_usdt'=> isset($counts['total_usdt'])? $counts['total_usdt'] : 0, //
- 'surplus_usdt'=> isset($counts['surplus_usdt'])? $counts['surplus_usdt'] : 0,
- 'release_usdt'=> isset($counts['release_usdt'])? $counts['release_usdt'] : 0,
- ];
- $config = Config::getConfigByGroup('trade');
- $rates['release_rate'] = isset($config['release_rate'])? floatval($config['release_rate']['value']) : 0;
- $rates['award_rate'] = isset($config['award_rate'])? floatval($config['award_rate']['value']) : 0;
- $loginStu = db('studio')->where(['title' => $this->auth->login_studio])->find();
- $stuid = isset($loginStu['id'])? $loginStu['id'] : 0;
- $counts = [
- 'status1'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>1,'stuid'=>$stuid])->count('id'),
- 'status2'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>2,'stuid'=>$stuid])->count('id'),
- 'status3'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>3,'issell'=>[['egt',0],['elt',2]],'stuid'=>$stuid])->count('id'),
- ];
- $config = Config::getConfigByGroup('basic');
- $this->view->assign('config', $rates);
- $this->view->assign('awards', $awards);
- $this->view->assign('cats', $cats);
- $this->view->assign('counts', $counts);
- $this->view->assign('logo', Image::makeLogo($sinfo['name']));
- $this->view->assign('product_img', isset($config['product_img']['value'])? $config['product_img']['value'] : '');
- return $this->fetch();
- }
- /**
- * 模式
- * @return mixed
- */
- function model(){
- $config = Config::getConfigByGroup('basic');
- $siteModel = isset($config['site_model'])? htmlspecialchars_decode($config['site_model']['value']) : '';
- $this->view->assign('site_model', $siteModel);
- return $this->fetch();
- }
- function goodslist()
- {
- $catid=input('catid');
- $login_studio=$this->auth->login_studio;
- $studio=db('studio')->where(['title'=>$login_studio])->find();
- if(time()>=strtotime(date("Y-m-d {$studio['start']}")) && time()<= strtotime(date("Y-m-d {$studio['end']}")) )
- {
- $status='营业中';
- }elseif(time()< strtotime(date("Y-m-d {$studio['start']}"))){
- $status='停业中';
- }elseif(time() > strtotime(date("Y-m-d {$studio['end']}"))){
- $status='停业中';
- }
- if(empty($user['bank_number']) && empty($user['wxprc']) &&empty($user['alipayprc']) && empty($user['usdt_address']) && empty($user['thb_bank_number']) && empty($user['idr_bank_number']))
- {
- $this->view->assign('no_auth', true);
- }else{
- $this->view->assign('no_auth', false);
- }
- $isappoint=db('studio_user')->where(['sid'=>$studio['id'],'userid'=>$this->auth->id])->find();
- if($isappoint)
- {
- $flag=0;
- }else{
- $flag=1;
- }
- $startTimeText = isset($studio['start'])? $studio['start'] : 0;
- $endTime = isset($studio['end'])? $studio['end'] : 0;
- $startTime = $startTimeText? strtotime(date('Y-m-d').' '.$startTimeText) : 0;
- $endTime = $endTime? strtotime(date('Y-m-d').' '.$endTime) : 0;
- $expired = $startTime > time()? $startTime - time() : 0;
- if($endTime <= time()){
- $startTime = strtotime(date('Y-m-d',strtotime(date('Y-m-d'))+86400).' '.$startTimeText);
- $expired = $startTime > time()? $startTime - time() : 0;
- }
- $this->view->assign([
- 'title'=>get_table_column('goods_cats',$catid,'name'),
- 'expired'=> $expired,
- 'catid'=>$catid,
- 'studio'=>$studio,
- 'status'=>$status,
- 'flag'=>$flag,
- ]);
- return $this->fetch();
- }
- /* 商品详情 */
- function goodsdetailed()
- {
- $id=input('id');
- $info=db('goods')->where(['id'=>$id])->find();
- if(!empty($info['images']))
- {
- $images=$info['image'].','.$info['images'];
- $info['img']=explode(',', $images);
- }else{
- $info['img']=[$info['image']];
- }
- $this->view->assign([
- "info"=>$info,
- ]);
- return $this->fetch();
- }
- /* 商品详情 */
- function goodsdetailed1()
- {
- $id=input('id');
- $info=db('goods')->where(['id'=>$id])->find();
- if(!empty($info['images']))
- {
- $images=$info['image'].','.$info['images'];
- $info['img']=explode(',', $images);
- }else{
- $info['img']=[$info['image']];
- }
- $this->view->assign([
- "info"=>$info,
- ]);
- return $this->fetch();
- }
- /* 评论 */
- function appraise()
- {
- $goodsid=input('goodsid');
- $this->view->assign('goodsid',$goodsid);
- return $this->fetch();
- }
- /* 购物车 */
- function cart()
- {
- return $this->fetch();
- }
- }
|