Membergoodsbrowse.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 浏览历史控制器
  15. */
  16. class Membergoodsbrowse extends MobileMember {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/membergoodsbrowse.lang.php');
  20. }
  21. /**
  22. * 我的足迹
  23. */
  24. public function browse_list() {
  25. $goodsbrowse_model = model('goodsbrowse');
  26. $page = intval(input('param.page'));
  27. $per_page = intval(input('param.per_page'));
  28. //查询浏览记录
  29. $condition = array();
  30. $condition[] = array('member_id','=',$this->member_info['member_id']);
  31. $timearray = $goodsbrowse_model->getGoodsbrowseList($condition,'goodsbrowse_time',0,'goodsbrowse_time desc');
  32. foreach($timearray as $key => $val){
  33. $timearray[$key]['goodsbrowse_time'] = date('Y-m-d',$val['goodsbrowse_time']);
  34. }
  35. $timearray = array_unique(array_column($timearray,'goodsbrowse_time'));//去除日期数组里面的重复日期
  36. $count = count($timearray);//日期数组长度
  37. $page_total = ceil($count/$per_page);//总页数
  38. if(($count - ($per_page * $page)) > 0){
  39. $hasmore = true;
  40. }else{
  41. $hasmore = false;
  42. }
  43. $start = $per_page * ($page - 1);//数组起始位置
  44. $pagetimearray = array_slice($timearray,$start,$per_page);//获取页数日期数组
  45. $browsegoodslist = array();
  46. foreach($pagetimearray as $key => $val){
  47. $browsegoodslist[$key]['time'] =$val;
  48. $condition = array();
  49. $condition[] = array('member_id' ,'=', $this->member_info['member_id']);
  50. $condition[] = array('goodsbrowse_time' ,'>=', strtotime($val));
  51. $condition[] = array('goodsbrowse_time' ,'<=', strtotime($val)+86399);
  52. $goodsidarray = $goodsbrowse_model->getGoodsbrowseList($condition,'goods_id');
  53. $goodsidarray = array_column($goodsidarray,'goods_id');
  54. $goodsidarray = implode(',',$goodsidarray);
  55. $goods_list = model('goods')->getGoodsList(array(array('goods_id','in', $goodsidarray)), 'goods_id, goods_name, goods_advword, goods_promotion_price, goods_promotion_type, goods_marketprice, goods_image, store_id, gc_id, gc_id_1, gc_id_2, gc_id_3');
  56. foreach($goods_list as $k => $v){
  57. $goods_list[$k]['goods_image_url'] = goods_cthumb($v['goods_image'], 480, $v['store_id']);
  58. }
  59. $browsegoodslist[$key]['goods_list'] =$goods_list;
  60. }
  61. $result = array_merge(array('goodsbrowse_list' => $browsegoodslist),array('hasmore' => $hasmore),array('page_total' => $page_total));
  62. ds_json_encode(10000, '', $result);
  63. }
  64. /**
  65. * 清空足迹
  66. */
  67. public function browse_clearall() {
  68. //清除缓存中浏览记录
  69. dcache($this->member_info['member_id'], 'goodsbrowse');
  70. model('goodsbrowse')->delGoodsbrowse(array('member_id' => $this->member_info['member_id']));
  71. ds_json_encode(10000, '', 1);
  72. }
  73. }