作者 邓超

Merge branch 'develop' into dc

@@ -37,7 +37,7 @@ class CountController extends BaseController @@ -37,7 +37,7 @@ class CountController extends BaseController
37 //TODO::询盘国家统计 37 //TODO::询盘国家统计
38 $data['country_data'] = $countLogic->inquiry_country_count(); 38 $data['country_data'] = $countLogic->inquiry_country_count();
39 //TODO::来源排名 39 //TODO::来源排名
40 - $data['country_data'] = $countLogic->referrer_count(); 40 + $data['referrer_count'] = $countLogic->referrer_count();
41 //TODO::访问国家前10 41 //TODO::访问国家前10
42 $data['access_country_count'] = $countLogic->access_country_count(); 42 $data['access_country_count'] = $countLogic->access_country_count();
43 //TODO::企业中心服务 43 //TODO::企业中心服务
@@ -95,8 +95,8 @@ class UserController extends BaseController @@ -95,8 +95,8 @@ class UserController extends BaseController
95 ],[ 95 ],[
96 'id.required' => 'ID不能为空', 96 'id.required' => 'ID不能为空',
97 ]); 97 ]);
98 - $userLogic->user_info();  
99 - $this->response('success'); 98 + $info = $userLogic->user_info();
  99 + $this->response('success',Code::SUCCESS,$info);
100 } 100 }
101 /** 101 /**
102 * @name :删除管理员 102 * @name :删除管理员
@@ -64,7 +64,7 @@ class CountLogic extends BaseLogic @@ -64,7 +64,7 @@ class CountLogic extends BaseLogic
64 $data = [ 64 $data = [
65 'total_pv'=>$pv, 65 'total_pv'=>$pv,
66 'total_ip'=>$ip, 66 'total_ip'=>$ip,
67 - 'conversion_rate' => isset($inquiry_num) ? ($inquiry_num / $ip) * 100 : 0, 67 + 'conversion_rate' => (isset($inquiry_num) && !empty($inquiry_num)) ? ($inquiry_num / $ip) * 100 : 0,
68 ]; 68 ];
69 return $this->success($data); 69 return $this->success($data);
70 } 70 }
@@ -148,12 +148,8 @@ class CountLogic extends BaseLogic @@ -148,12 +148,8 @@ class CountLogic extends BaseLogic
148 */ 148 */
149 public function referrer_count(){ 149 public function referrer_count(){
150 $data = DB::table('gl_customer_visit') 150 $data = DB::table('gl_customer_visit')
151 - ->select('referrer_url', 'country', DB::raw('COUNT(*) as count'))  
152 - ->groupBy('referrer_url', 'country')  
153 - ->orderByDesc('count')  
154 - ->limit(8)  
155 - ->get()  
156 - ->toArray(); 151 + ->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url')
  152 + ->orderByDesc('count')->limit(8)->get()->toArray();
157 $total = DB::table('gl_customer_visit')->count(); 153 $total = DB::table('gl_customer_visit')->count();
158 $data = object_to_array($data); 154 $data = object_to_array($data);
159 foreach ($data as $k=>$v){ 155 foreach ($data as $k=>$v){
@@ -116,6 +116,6 @@ class CategoryLogic extends BaseLogic @@ -116,6 +116,6 @@ class CategoryLogic extends BaseLogic
116 */ 116 */
117 public function getProductNum($cate_id){ 117 public function getProductNum($cate_id){
118 $cate_ids = $this->model->getChildIdsArr($cate_id); 118 $cate_ids = $this->model->getChildIdsArr($cate_id);
119 - return CategoryRelated::whereIn('cate_id', $cate_ids)->count(); 119 + return CategoryRelated::whereIn('cate_id', $cate_ids)->distinct()->count('product_id');
120 } 120 }
121 } 121 }
@@ -92,6 +92,6 @@ class KeywordLogic extends BaseLogic @@ -92,6 +92,6 @@ class KeywordLogic extends BaseLogic
92 } 92 }
93 93
94 public function getProductNum($keyword_id){ 94 public function getProductNum($keyword_id){
95 - return KeywordRelated::where('keyword_id', $keyword_id)->count(); 95 + return KeywordRelated::where('keyword_id', $keyword_id)->distinct()->count('product_id');
96 } 96 }
97 } 97 }
@@ -86,15 +86,28 @@ class ProductLogic extends BaseLogic @@ -86,15 +86,28 @@ class ProductLogic extends BaseLogic
86 86
87 DB::beginTransaction(); 87 DB::beginTransaction();
88 try { 88 try {
89 - foreach ($ids as $id){  
90 - //删除路由映射  
91 - RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 89 + foreach ($ids as $k => $id) {
92 90
93 - //删除分类关联  
94 - CategoryRelated::where('product_id', $id)->delete(); 91 + $info = $this->getCacheInfo($id);
  92 + if(!$info){
  93 + unset($ids[$k]);
  94 + continue;
  95 + }
95 96
96 - //删除关键词关联  
97 - KeywordRelated::where('product_id', $id)->delete(); 97 + if($info->status == Product::STATUS_RECYCLE){
  98 + //删除路由映射
  99 + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
  100 +
  101 + //删除分类关联
  102 + CategoryRelated::where('product_id', $id)->delete();
  103 +
  104 + //删除关键词关联
  105 + KeywordRelated::where('product_id', $id)->delete();
  106 + }else{
  107 + //回收站
  108 + parent::save(['id' => $id, 'status' => Product::STATUS_RECYCLE]);
  109 + unset($ids[$k]);
  110 + }
98 } 111 }
99 parent::delete($ids); 112 parent::delete($ids);
100 113
@@ -174,7 +174,7 @@ class Logic @@ -174,7 +174,7 @@ class Logic
174 public function delete($ids, $map = []){ 174 public function delete($ids, $map = []){
175 $ids = array_filter(Arr::splitFilterToArray($ids), 'intval'); 175 $ids = array_filter(Arr::splitFilterToArray($ids), 'intval');
176 if(!$ids){ 176 if(!$ids){
177 - $this->fail('ID不能为空'); 177 + return $this->success();
178 } 178 }
179 179
180 foreach ($ids as $id){ 180 foreach ($ids as $id){