From 02b090522e01b2e5648fbe9a4b1b4bc7c53ae0b2 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Sat, 6 Nov 2021 21:55:36 +0800 Subject: [PATCH] edit-api-sum_deal_log --- api/controllers/wxapp/liche/Statistics.php | 14 ++++++++++++-- api/controllers/wxapp/licheb/Cusorder.php | 3 +++ common/libraries/entity/Deal_entity.php | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/api/controllers/wxapp/liche/Statistics.php b/api/controllers/wxapp/liche/Statistics.php index 8dbc2e2a..a9e00bda 100644 --- a/api/controllers/wxapp/liche/Statistics.php +++ b/api/controllers/wxapp/liche/Statistics.php @@ -19,6 +19,10 @@ class Statistics extends Wxapp{ $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); $this->load->model('auto/auto_attr_model'); + + $this->load->model('app/deal_log_model'); + + $this->load->library('entity/deal_entity',['app_id'=>$this->app_id]); } protected function get(){ @@ -63,6 +67,7 @@ class Statistics extends Wxapp{ $rows = $this->auto_brand_model->select($where,'',$page,$size,$fileds); $list = []; if($rows){ + $res = $this->deal_entity->deal_log($oid); foreach($rows as $key => $val){ $enroll = $this->clues_model->count(['app_id'=>$this->app_id,'recommend_id'=>$uid,'brand_id'=>$val['id']]); $where = [ @@ -77,13 +82,18 @@ class Statistics extends Wxapp{ 'lc_receiver_orders.status>' => 0 ]; $ispay = $this->clues_model->count_order($where); - $commision = 0; + $where = [ + 'lc_app_deal_log.status' => 1, + 'lc_app_deal_log.app_uid' => $uid, + 'lc_receiver_orders.brand_id' => $val['id'], + ]; + $done_commision = $this->deal_entity->sum_done($where); $list[] = [ 'title' => $val['name'], 'enroll' => $enroll, 'ispay' => $ispay, 'done' => $done, - 'commision' => number_format($done*500,2) + 'commision' => number_format($done_commision,2) ]; } } diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index df35b0d2..0649c727 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -490,6 +490,9 @@ class Cusorder extends Wxapp{ $result = $this->order_deliverys_model->update(['status'=>2],['id'=>$row['id']]); if($result){ $this->orders_model->update(['status'=>6],['id'=>$row['o_id']]); + //完成分销 + $this->load->library('entity/deal_entity',['app_id'=>1]); + $this->deal_entity->deal_log_finish($row['o_id']); throw new Exception('修改成功', API_CODE_SUCCESS); }else{ throw new Exception('修改失败', ERR_PARAMS_ERROR); diff --git a/common/libraries/entity/Deal_entity.php b/common/libraries/entity/Deal_entity.php index 9b1c0e9e..b05c8e82 100755 --- a/common/libraries/entity/Deal_entity.php +++ b/common/libraries/entity/Deal_entity.php @@ -273,6 +273,16 @@ 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->select_sum('lc_app_deal_log.money'); + $this->ci->db->where($where); + $result = $this->ci->db->get()->row_array(); + return $result['money'] ? $result['money'] : 0; + } + public function __get($name) { if ('_model' === substr($name, -6)) {