Goods.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace app\shop\controller;
  3. use app\common\controller\Frontend;
  4. use app\common\library\Image;
  5. use GuzzleHttp\json_decode;
  6. use think\cache\driver\Redis;
  7. class Goods extends Frontend
  8. {
  9. protected $noNeedLogin = [''];
  10. protected $noNeedRight = '*';
  11. protected $layout = '';
  12. public function _initialize()
  13. {
  14. parent::_initialize();
  15. }
  16. /**
  17. * 主页
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. */
  22. public function index(){
  23. $cats = db('goods_cats')->where(['status'=>1])->order('id asc')->select();
  24. foreach ($cats as $k=>$v)
  25. {
  26. $start=strtotime(date("Y-m-d {$v['start']}"));
  27. $end=strtotime(date("Y-m-d {$v['end']}"));
  28. /*未开始*/
  29. if(time()<$start)
  30. {
  31. $cats[$k]['jctime1']=$start-time();
  32. $cats[$k]['flag']=1;
  33. }elseif(time()>=$start && time()<$end)
  34. {
  35. $cats[$k]['jctime1']=$end-time();
  36. $cats[$k]['flag']=2;
  37. }else{
  38. $cats[$k]['flag']=0;
  39. $cats[$k]['jctime1']=0;
  40. }
  41. }
  42. $sinfo=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  43. $awards = \app\common\model\Trade::getAwardTotal();
  44. $counts = \app\common\model\Trade::getReleaseTotal($this->auth->id);
  45. $awards = [
  46. 'total'=> isset($awards['total'])? $awards['total'] : 0,
  47. 'total_usdt'=> isset($awards['total_usdt'])? $awards['total_usdt'] : 0,
  48. 'release_total_usdt'=> isset($counts['total'])? $counts['total'] : 0,
  49. 'surplus_usdt'=> isset($counts['surplus_usdt'])? $counts['surplus_usdt'] : 0,
  50. 'release_usdt'=> isset($counts['release_usdt'])? $counts['release_usdt'] : 0,
  51. ];
  52. $this->view->assign('awards', $awards);
  53. $this->view->assign('cats', $cats);
  54. $this->view->assign('logo', Image::makeLogo($sinfo['name']));
  55. return $this->fetch();
  56. }
  57. function goodslist()
  58. {
  59. $catid=input('catid');
  60. $login_studio=$this->auth->login_studio;
  61. $studio=db('studio')->where(['title'=>$login_studio])->find();
  62. if(time()>=strtotime(date("Y-m-d {$studio['start']}")) && time()<= strtotime(date("Y-m-d {$studio['end']}")) )
  63. {
  64. $status='营业中';
  65. }elseif(time()< strtotime(date("Y-m-d {$studio['start']}"))){
  66. $status='停业中';
  67. }elseif(time() > strtotime(date("Y-m-d {$studio['end']}"))){
  68. $status='停业中';
  69. }
  70. $isappoint=db('studio_user')->where(['sid'=>$studio['id'],'userid'=>$this->auth->id])->find();
  71. if($isappoint)
  72. {
  73. $flag=0;
  74. }else{
  75. $flag=1;
  76. }
  77. $this->view->assign([
  78. 'title'=>get_table_column('goods_cats',$catid,'name'),
  79. 'catid'=>$catid,
  80. 'studio'=>$studio,
  81. 'status'=>$status,
  82. 'flag'=>$flag,
  83. ]);
  84. return $this->fetch();
  85. }
  86. /* 商品详情 */
  87. function goodsdetailed()
  88. {
  89. $id=input('id');
  90. $info=db('goods')->where(['id'=>$id])->find();
  91. if(!empty($info['images']))
  92. {
  93. $images=$info['image'].','.$info['images'];
  94. $info['img']=explode(',', $images);
  95. }else{
  96. $info['img']=[$info['image']];
  97. }
  98. $this->view->assign([
  99. "info"=>$info,
  100. ]);
  101. return $this->fetch();
  102. }
  103. /* 商品详情 */
  104. function goodsdetailed1()
  105. {
  106. $id=input('id');
  107. $info=db('goods')->where(['id'=>$id])->find();
  108. if(!empty($info['images']))
  109. {
  110. $images=$info['image'].','.$info['images'];
  111. $info['img']=explode(',', $images);
  112. }else{
  113. $info['img']=[$info['image']];
  114. }
  115. $this->view->assign([
  116. "info"=>$info,
  117. ]);
  118. return $this->fetch();
  119. }
  120. /* 评论 */
  121. function appraise()
  122. {
  123. $goodsid=input('goodsid');
  124. $this->view->assign('goodsid',$goodsid);
  125. return $this->fetch();
  126. }
  127. /* 购物车 */
  128. function cart()
  129. {
  130. return $this->fetch();
  131. }
  132. }