From f2c1bc754093b1a0300f8e77ac59bd72eea7cbd4 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Thu, 7 Apr 2022 16:29:54 +0800 Subject: [PATCH] edit-liche-deal --- api/controllers/wxapp/liche/Clues.php | 4 +-- api/controllers/wxapp/liche/Contract.php | 3 --- api/controllers/wxapp/liche/Protocol.php | 8 +++--- api/controllers/wxapp/liche/Statistics.php | 26 +++++++------------ common/libraries/entity/Deal_entity.php | 10 +++---- .../models/receiver/Receiver_clues_model.php | 7 +++-- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/api/controllers/wxapp/liche/Clues.php b/api/controllers/wxapp/liche/Clues.php index 7da0b348..25503838 100644 --- a/api/controllers/wxapp/liche/Clues.php +++ b/api/controllers/wxapp/liche/Clues.php @@ -194,10 +194,10 @@ class Clues extends Wxapp $total = $this->receiver_clues_model->count($where); //总数 if ($type == 1) { //待确认 - $where["lc_receiver_orders.id is null"] = null; + $where["lc_receiver_orders_v2.id is null"] = null; $where["lc_receiver_clues.status !="] = 3; } elseif ($type == 2) { //有效 - $where['lc_receiver_orders.id >'] = 0; + $where['lc_receiver_orders_v2.id >'] = 0; } elseif ($type == 3) { $where['lc_receiver_clues.status'] = 3; } diff --git a/api/controllers/wxapp/liche/Contract.php b/api/controllers/wxapp/liche/Contract.php index 26ff7df2..227dd73d 100644 --- a/api/controllers/wxapp/liche/Contract.php +++ b/api/controllers/wxapp/liche/Contract.php @@ -167,9 +167,6 @@ class Contract extends Wxapp{ //增加分销记录 $this->load->library('entity/deal_entity',['app_id'=>1]); $deal_res = $this->deal_entity->deal_log($row['o_id']); - if(time()<= strtotime('2021-12-24')){ - debug_log("[info]". __FUNCTION__ . ": order_id:{$row['o_id']},return:".json_encode($deal_log), 'deal_log.log'); - } if(!$order['srv_ids']){ $userinfo = $this->app_user_model->get(['mobile'=>$order['mobile']]); $this->orders_entity->sign_after_v2($id,$userinfo); diff --git a/api/controllers/wxapp/liche/Protocol.php b/api/controllers/wxapp/liche/Protocol.php index b50c1263..1f35e7fe 100644 --- a/api/controllers/wxapp/liche/Protocol.php +++ b/api/controllers/wxapp/liche/Protocol.php @@ -7,9 +7,7 @@ require_once APPPATH.'controllers/wxapp/Wxapp.php'; * Created by Vim * User: lcc * Date: 2021.06.23 - * Time: 14:08 - */ -class Protocol extends Wxapp{ + * Time: 14:08 */ class Protocol extends Wxapp{ function __construct($inputs, $app_key){ parent::__construct($inputs, $app_key); @@ -28,6 +26,7 @@ class Protocol extends Wxapp{ $this->load->library('receiver/orders_v2_entity'); $this->load->library('receiver/orders_status_entity'); $this->load->library('pdftk'); + $this->load->library('entity/deal_entity',['app_id'=>1]); } /** @@ -174,6 +173,7 @@ class Protocol extends Wxapp{ } $res = $this->orders_v2_entity->create_pdf($row['id']); if($res['code']){ + $deal_res = $this->deal_entity->deal_log($row['id']); throw new Exception('操作成功', API_CODE_SUCCESS); }else{ throw new Exception($res['msg'], API_CODE_FAIL); @@ -222,6 +222,8 @@ class Protocol extends Wxapp{ $this->orders_status_entity->set_status($row['id'],4,2); $this->orders_status_entity->set_status($row['id'],5,1); $this->receiver_orders_v2_model->update(['status'=>1],['id'=>$row['id']]); + //完成分销 + $this->deal_entity->deal_log_finish($row['id']); throw new Exception('操作成功', API_CODE_SUCCESS); }else{ throw new Exception('保存失败', API_CODE_FAIL); diff --git a/api/controllers/wxapp/liche/Statistics.php b/api/controllers/wxapp/liche/Statistics.php index f521c5d2..a78a69f8 100644 --- a/api/controllers/wxapp/liche/Statistics.php +++ b/api/controllers/wxapp/liche/Statistics.php @@ -36,18 +36,15 @@ class Statistics extends Wxapp{ $clues = $this->clues_model->count(['app_id'=>$this->app_id,'recommend_id'=>$uid]); $where = [ 'lc_receiver_clues.recommend_id' => $uid, - 'lc_receiver_orders.status' => 6 + 'lc_receiver_orders_v2.status' => 1 ]; $done = $this->clues_model->count_order($where); - $where = [ - 'lc_receiver_clues.recommend_id' => $uid, - 'lc_receiver_orders.status>' => 0 - ]; - $ispay = $this->clues_model->count_order($where); + $sql = "select count(distinct c.o_id) as total from lc_receiver_clues as a left join lc_receiver_orders_v2 as b on a.id=b.clue_id left join lc_app_liche_orders as c on c.o_id=b.id where c.status=1 and a.recommend_id={$uid}"; + $re=$this->db->query($sql)->result_array(); $data = [ ['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'=>$re[0]['total'],'url' => '/pages/distribute/statistics/order?type=0&title=下定'], ['name'=>'成交','value'=>$done,'url' => '/pages/distribute/statistics/order?type=1&title=成交'] ]; return $data; @@ -71,20 +68,17 @@ class Statistics extends Wxapp{ $enroll = $this->clues_model->count(['app_id'=>$this->app_id,'recommend_id'=>$uid,'brand_id'=>$val['id']]); $where = [ 'lc_receiver_clues.recommend_id' => $uid, - 'lc_receiver_orders.brand_id' => $val['id'], - 'lc_receiver_orders.status' => 6 + 'lc_receiver_orders_v2.brand_id' => $val['id'], + 'lc_receiver_orders_v2.status' => 1 ]; $done = $this->clues_model->count_order($where); - $where = [ - 'lc_receiver_clues.recommend_id' => $uid, - 'lc_receiver_orders.brand_id' => $val['id'], - 'lc_receiver_orders.status>' => 0 - ]; - $ispay = $this->clues_model->count_order($where); + $sql = "select count(distinct c.o_id) as total from lc_receiver_clues as a left join lc_receiver_orders_v2 as b on a.id=b.clue_id left join lc_app_liche_orders as c on c.o_id=b.id where c.status=1 and a.recommend_id={$uid} and a.brand_id={$val['id']}"; + $re=$this->db->query($sql)->result_array(); + $ispay = $re[0]['total']; $where = [ 'lc_app_deal_log.status' => 1, 'lc_app_deal_log.app_uid' => $uid, - 'lc_receiver_orders.brand_id' => $val['id'], + 'lc_receiver_orders_v2.brand_id' => $val['id'], ]; $done_commision = $this->deal_entity->sum_done($where); $list[] = [ diff --git a/common/libraries/entity/Deal_entity.php b/common/libraries/entity/Deal_entity.php index ea6fe8e4..fcb2639f 100755 --- a/common/libraries/entity/Deal_entity.php +++ b/common/libraries/entity/Deal_entity.php @@ -36,13 +36,13 @@ class Deal_entity * @return bool */ public function deal_log($oid){ - $this->load->model('receiver/order/receiver_orders_model'); + $this->load->model('receiver/order/receiver_orders_v2_model'); $this->load->model('receiver/receiver_clues_model'); $this->load->model('auto/auto_cars_model'); $this->load->model($this->app_config['model'], 'mdUser'); $this->load->model('app/Deal_log_model', 'mdDealLog'); $this->load->model('app/licheb/app_licheb_brokerage_model'); - $order = $this->ci->receiver_orders_model->get(['id'=>$oid]); + $order = $this->ci->receiver_orders_v2_model->get(['id'=>$oid]); $clue = $this->ci->receiver_clues_model->get(['id'=>$order['clue_id']]); if(!$clue){ return array('code' => 0, 'msg' => '参数错误'); @@ -110,8 +110,8 @@ class Deal_entity $this->load->model('app/User_account_model', 'mdUserAccount'); $this->load->model('app/User_accountlog_model', 'mdUserAccountLog'); $this->load->model('app/Deal_log_model', 'mdDealLog'); - $this->load->model('receiver/order/receiver_orders_model'); - $order = $this->ci->receiver_orders_model->get(['id'=>$oid]); + $this->load->model('receiver/order/receiver_orders_v2_model'); + $order = $this->ci->receiver_orders_v2_model->get(['id'=>$oid]); if(!$order){ return array('code' => 0, 'msg' => '订单不存在'); } @@ -283,7 +283,7 @@ class Deal_entity //统计完成订单金额 public function sum_done($where=[]){ $this->ci->db->from('lc_app_deal_log'); - $this->ci->db->join('lc_receiver_orders', "lc_receiver_orders.sid = lc_app_deal_log.cf_sid"); + $this->ci->db->join('lc_receiver_orders_v2', "lc_receiver_orders_v2.sid = lc_app_deal_log.cf_sid"); $this->ci->db->select_sum('lc_app_deal_log.money'); $this->ci->db->where($where); $result = $this->ci->db->get()->row_array(); diff --git a/common/models/receiver/Receiver_clues_model.php b/common/models/receiver/Receiver_clues_model.php index 996b0f9b..e431e193 100644 --- a/common/models/receiver/Receiver_clues_model.php +++ b/common/models/receiver/Receiver_clues_model.php @@ -49,8 +49,7 @@ class Receiver_clues_model extends HD_Model !$fileds && $fileds = 'lc_receiver_clues.*'; $this->db->select($fileds); $this->db->from('lc_receiver_clues'); - $this->db->join('lc_receiver_customers', 'lc_receiver_customers.rid = lc_receiver_clues.id', 'left'); - $this->db->join('lc_receiver_orders', 'lc_receiver_orders.rid = lc_receiver_customers.id', 'left'); + $this->db->join('lc_receiver_orders_v2', 'lc_receiver_orders_v2.clue_id = lc_receiver_clues.id', 'left'); if ($where) { $this->db->where($where); @@ -74,7 +73,7 @@ class Receiver_clues_model extends HD_Model public function selectClues($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0 ,$fileds = ''){ $this->db->from('lc_receiver_clues'); - $this->db->join('lc_receiver_orders', 'lc_receiver_orders.clue_id = lc_receiver_clues.id and lc_receiver_orders.status>=0', 'left'); + $this->db->join('lc_receiver_orders_v2', 'lc_receiver_orders_v2.clue_id = lc_receiver_clues.id and lc_receiver_orders_v2.status>=0', 'left'); if ($where) { $this->db->where($where); @@ -87,7 +86,7 @@ class Receiver_clues_model extends HD_Model if($fileds){ $this->db->select($fileds); }else{ - $this->db->select('lc_receiver_clues.*,lc_receiver_orders.id as o_id'); + $this->db->select('lc_receiver_clues.*,lc_receiver_orders_v2.id as o_id'); } $this->db->group_by('lc_receiver_clues.id'); }