common.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 流年 <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // 应用公共文件
  12. if(!function_exists('unThumb')){
  13. function unThumb($src){
  14. return str_replace('/s_','/',$src);
  15. }
  16. }
  17. /**
  18. *判断拼团是否结束*/
  19. function isPinkStatus($pink){
  20. if(!$pink) return false;
  21. return \app\wap\model\store\StorePink::isSetPinkOver($pink);
  22. }
  23. /**
  24. * 设置浏览信息
  25. * @param $uid
  26. * @param int $product_id
  27. * @param int $cate
  28. * @param string $type
  29. * @param string $content
  30. * @param int $min
  31. */
  32. function setView($uid,$product_id=0,$cate=0,$type='',$content='',$min=20){
  33. $Db=think\Db::name('store_visit');
  34. $view=$Db->where(['uid'=>$uid,'product_id'=>$product_id])->field('count,add_time,id')->find();
  35. if($view && $type!='search'){
  36. $time=time();
  37. if(($view['add_time']+$min)<$time){
  38. $Db->where(['id'=>$view['id']])->update(['count'=>$view['count']+1,'add_time'=>time()]);
  39. }
  40. }else{
  41. $cate = explode(',',$cate)[0];
  42. $Db->insert([
  43. 'add_time'=>time(),
  44. 'count'=>1,
  45. 'product_id'=>$product_id,
  46. 'cate_id'=>$cate,
  47. 'type'=>$type,
  48. 'uid'=>$uid,
  49. 'content'=>$content
  50. ]);
  51. }
  52. }