diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php index 75af22d7..42b99c60 100644 --- a/admin/controllers/receiver/Orders.php +++ b/admin/controllers/receiver/Orders.php @@ -480,10 +480,13 @@ class Orders extends HD_Controller $this->order_ckcars_model->replace($replace); } elseif ($params['status'] == 3) { //设置完成按揭 $order_row = $this->orders_model->get(['id' => $row['o_id']], 'status'); - if ($order_row['status'] == 4) { //完成代办 - $this->orders_model->update(['status' => 5], ['id' => $oid]); - if (!$this->order_deliverys_model->count(['o_id' => $oid])) { - $this->order_deliverys_model->add(['o_id' => $oid, 'c_time' => time]); + if ($order_row['status'] > 2) { + $agent_rows = $this->order_agents_model->get(['o_id'=>$oid]); //判断是否代办完成 + if($agent_rows && $agent_rows['status']){ + $this->orders_model->update(['status' => 5], ['id' => $oid]); + if (!$this->order_deliverys_model->count(['o_id' => $oid])) { + $this->order_deliverys_model->add(['o_id' => $oid, 'c_time' => time]); + } } } else { $this->orders_model->update(['status' => 2], ['id' => $row['o_id']]); @@ -667,23 +670,16 @@ class Orders extends HD_Controller if ($row['status'] < 4) { return $this->show_json(SYS_CODE_FAIL, '修改失败,该订单不处于代办阶段'); } + $loan = $this->order_loans_model->get(['o_id' => $oid]); + if (!$row['payway'] && $loan['status']!=3) { //分期且分期未完成 + return $this->show_json(SYS_CODE_FAIL, '修改失败,请先完成按揭'); + } + $this->order_agents_model->update(['status' => 1], ['o_id' => $oid]); - $loan = $this->order_loans_model->get(['o_id' => $oid]); - if ($loan && !$row['payway']) { //分期 - if ($loan['status'] == 3) { //判断是否完成代办 - $this->orders_model->update(['status' => 5], ['id' => $oid]); - if (!$this->order_deliverys_model->count(['o_id' => $oid])) { - $this->order_deliverys_model->add(['o_id' => $oid, 'c_time' => time]); - } - } else { - return $this->show_json(SYS_CODE_FAIL, '修改失败,请先完成按揭'); - } - } else { - $row['status'] == 4 && $this->orders_model->update(['status' => 5], ['id' => $oid]); - if (!$this->order_deliverys_model->count(['o_id' => $oid])) { - $this->order_deliverys_model->add(['o_id' => $oid, 'c_time' => time]); - } + $row['status']==4 && $this->orders_model->update(['status' => 5], ['id' => $oid]); + if (!$this->order_deliverys_model->count(['o_id' => $oid])) { + $this->order_deliverys_model->add(['o_id' => $oid, 'c_time' => time]); } return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } diff --git a/api/controllers/wxapp/liche/Clues.php b/api/controllers/wxapp/liche/Clues.php index 25054d3b..844c8bb7 100644 --- a/api/controllers/wxapp/liche/Clues.php +++ b/api/controllers/wxapp/liche/Clues.php @@ -210,13 +210,6 @@ class Clues extends Wxapp{ } //获取账单记录 $mlogs = []; - //$mlogs[] = [ - // 'id' => 1, - // 'title' => '报备佣金', - // 'money' => '+500元', - // 'status' => '有效', - // 'c_time' => date('Y-m-d H:i:s') - //]; $data = [ 'title' => "{$row['name']}·{$mobile}", 'brand' => $brand['name'], @@ -228,4 +221,39 @@ class Clues extends Wxapp{ ]; return $data; } + + protected function get_lists(){ + $uid = $this->session['uid']; + $page = $this->input_param('page'); + $size = $this->input_param('size'); + !$type && $type = 0; + !$page && $page = 1; + !$size && $size = 20; + + $list = []; + + $where = [ + 'app_id' => $this->app_id, + "recommend_id" => $uid + ]; + $count = $this->receiver_clues_model->count($where); //总数 + + if($count){ + $rows = $this->receiver_clues_model->select($where,'id desc',$page,$size,'id,name,mobile,c_time'); + foreach($rows as $key=>$val){ + $list[] = [ + 'id' => $val['id'], + 'name' => $val['name'], + 'mobile' => mobile_asterisk($val['mobile']), + 'c_time' => date('Y-m-d H:i:s',$val['c_time']), + ]; + } + } + + $data = [ + 'list' => $list, + 'total' => $count, + ]; + return $data; + } } diff --git a/api/controllers/wxapp/liche/Statistics.php b/api/controllers/wxapp/liche/Statistics.php index 6cc927d9..8dbc2e2a 100644 --- a/api/controllers/wxapp/liche/Statistics.php +++ b/api/controllers/wxapp/liche/Statistics.php @@ -14,6 +14,11 @@ class Statistics extends Wxapp{ parent::__construct($inputs, $app_key); $this->load->model('receiver/receiver_clue_statistics_model','statistics_model'); $this->load->model('receiver/receiver_clues_model','clues_model'); + $this->load->model('receiver/order/receiver_orders_model','orders_model'); + + $this->load->model('auto/auto_brand_model'); + $this->load->model('auto/auto_series_model'); + $this->load->model('auto/auto_attr_model'); } protected function get(){ @@ -36,17 +41,16 @@ class Statistics extends Wxapp{ ]; $ispay = $this->clues_model->count_order($where); $data = [ - ['name'=>'浏览','value'=>intval($brower['browse_num'])], - ['name'=>'报名','value'=>$clues], - ['name'=>'下定','value'=>$ispay], - ['name'=>'成交','value'=>$done] + ['name'=>'浏览','value'=>intval($brower['browse_num']),'url' => ''], + ['name'=>'报名','value'=>$clues,'url' => '/pages/distribute/statistics/customer'], + ['name'=>'下定','value'=>$ispay,'url' => '/pages/distribute/statistics/order?type=0&title=下定'], + ['name'=>'成交','value'=>$done,'url' => '/pages/distribute/statistics/order?type=1&title=成交'] ]; return $data; } //根据车型获取统计 protected function get_car(){ - $this->load->model('auto/auto_brand_model'); $uid = $this->session['uid']; $page = $this->input_param('page'); $size = $this->input_param('size'); @@ -182,4 +186,71 @@ class Statistics extends Wxapp{ throw new Exception('保存失败', API_CODE_FAIL); } } + + protected function get_orders(){ + $type = $this->input_param('type'); + $page = $this->input_param('page'); + $size = $this->input_param('size'); + + !$page && $page = 1; + !$size && $size = 20; + $t1 = 'lc_receiver_clues'; + $t2 = 'lc_receiver_orders'; + + $where = [ + "{$t1}.recommend_id" => $this->session['uid'], + ]; + if($type){ + $where["{$t2}.status"] = 6; + }else{ + $where["{$t2}.status>"] = 0; + } + $count = $this->clues_model->count_order($where); + $lists = []; + if($count){ + $fileds = "{$t2}.id,{$t2}.name,{$t2}.mobile,{$t2}.brand_id,{$t2}.s_id,{$t2}.v_id,{$t2}.cor_id,{$t2}.incor_id,{$t2}.deposit,{$t2}.payway,{$t2}.status,{$t2}.c_time"; + $rows = $this->clues_model->select_order($where,"{$t2}.id desc",$page,$size,$fileds); + //品牌车型 + $brand_arr = array_unique(array_column($rows,'brand_id')); + $brands = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name'); + //车系车型 + $series_arr = array_unique(array_column($rows,'s_id')); + $series = $this->auto_series_model->get_map_by_ids($series_arr,'id,name'); + + //获取车辆属性 + $version_arr = array_unique(array_column($rows,'v_id')); + $color_arr = array_unique(array_column($rows,'cor_id')); + $attrs_arr = array_merge($version_arr,$color_arr); + $attrs = $this->auto_attr_model->get_map_by_ids($attrs_arr,'id,title'); + + $status_arr = $this->orders_model->get_status(); + foreach($rows as $key=>$val){ + + $brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : ''; + $serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : ''; + $color = isset($attrs[$val['cor_id']]) ? $attrs[$val['cor_id']][0]['title'] : ''; + $version = isset($attrs[$val['v_id']]) ? $attrs[$val['v_id']][0]['title'] : ''; + + $other_data = [ + '品牌车型' => "{$brand_name}{$serie_name}-{$color}-{$version}", + '付款方式' => $val['payway']?'全款':'分期', + '代办车牌' => '需要', + '定金金额' => $val['deposit'], + '订单日期' => date('Y-m-d',$val['c_time']), + ]; + $lists[] = [ + 'id' => $val['id'], + 'name' => $val['name'], + 'mobile' => mobile_asterisk($val['mobile']), + 'status_name' => $status_arr[$val['status']], + 'other_data' => $other_data, + ]; + } + } + $data = [ + 'list' => $lists, + 'total' => $count + ]; + return $data; + } }