Browse Source

Merge branch 'version1.5' into dev_wf

wufeng 2 years ago
parent
commit
c95536a8fc
3 changed files with 76 additions and 87 deletions
  1. 41 59
      app/admin/controller/Data.php
  2. 29 22
      app/admin/controller/Sale.php
  3. 6 6
      app/admin/controller/Stat.php

+ 41 - 59
app/admin/controller/Data.php

@@ -356,11 +356,19 @@ class Data extends BaseController
             ->column('(sum(s.total_price) - sum(s.th_fee)) sales_volume,u.itemid,c.name', 'c.name');
 
         //额外把网络部的销售数据跨数据库查询出来
-        $sales_volume['网络部'] = [
-            'sales_volume' => Db::connect('mysql3')->table('source_all')->whereMonth('ordertime')->where('depart', '网络部')->sum('sale_total'),
-            'itemid' => -1,
-            'name' => '网络部',
-        ];
+        $other_network = Db::connect('mysql3')
+            ->table('source_all')
+            ->whereMonth('ordertime')
+            ->where('depart', '网络部')
+            ->sum('sale_total');
+        if (isset($sales_volume['网络部'])) $sales_volume['网络部']['sales_volume'] += $other_network;
+        else {
+            $sales_volume['网络部'] = [
+                'sales_volume' => $other_network,
+                'itemid' => -1,
+                'name' => '网络部'
+            ];
+        }
 
         //部门销售指标
         $sale_indicators = Db::name('depart_tips')
@@ -394,29 +402,20 @@ class Data extends BaseController
     //9.转单率-今日
     public function orderTransferRateToday()
     {
+        $consulting = Db::name('sale')
+            ->alias('s')
+            ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
+            ->where(['s.order_type' => 3, 's.is_del' => 0])//order_type==3 咨询采反
+            ->whereDay('s.addtime')
+            ->group('u.itemid')
+            ->column('count(s.id) consulting', 'u.itemid');
 
-        //当天所有的咨询单
-        $temp_sql = Db::name('consult_info')
-            ->field('zxNo')
-            ->where(['is_del' => 0])
-            ->whereDay('addtime')
-            ->buildSql();
-
-        //转单成功的数据
-        $consulting = Db::name('consult_info')
-            ->alias('ci')
-            ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
-            ->where('ci.zxNo IN '.$temp_sql)
-            ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
-            ->group('co.depart')
-            ->column('count(ci.id) total', 'co.depart');
-
-        //处理全部数据
         $rs = Db::name('consult_order')
             ->alias('c')
             ->field('count(c.id) total,c.depart companyId,i.name companyName')
             ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
-            ->where('c.zxNo IN '.$temp_sql)
+            ->where(['c.is_del' => 0])
+            ->whereDay('c.addtime')
             ->group('c.depart')
             ->append(['transfer_rate'])
             ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
@@ -433,29 +432,20 @@ class Data extends BaseController
     //9.转单率-本月
     public function orderTransferRateMonth()
     {
+        $consulting = Db::name('sale')
+            ->alias('s')
+            ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
+            ->where(['s.order_type' => 3, 's.is_del' => 0])//order_type==3 咨询采反
+            ->whereMonth('s.addtime')
+            ->group('u.itemid')
+            ->column('count(s.id) consulting', 'u.itemid');
 
-        //当天所有的咨询单
-        $temp_sql = Db::name('consult_info')
-            ->field('zxNo')
-            ->where(['is_del' => 0])
-            ->whereMonth('addtime')
-            ->buildSql();
-
-        //转单成功的数据
-        $consulting = Db::name('consult_info')
-            ->alias('ci')
-            ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
-            ->where('ci.zxNo IN '.$temp_sql)
-            ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
-            ->group('co.depart')
-            ->column('count(ci.id) total', 'co.depart');
-
-        //处理全部数据
         $rs = Db::name('consult_order')
             ->alias('c')
             ->field('count(c.id) total,c.depart companyId,i.name companyName')
             ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
-            ->where('c.zxNo IN '.$temp_sql)
+            ->where(['c.is_del' => 0])
+            ->whereMonth('c.addtime')
             ->group('c.depart')
             ->append(['transfer_rate'])
             ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
@@ -473,28 +463,20 @@ class Data extends BaseController
     public function orderTransferRateYear()
     {
 
-        //当天所有的咨询单
-        $temp_sql = Db::name('consult_info')
-            ->field('zxNo')
-            ->where(['is_del' => 0])
-            ->whereYear('addtime')
-            ->buildSql();
-
-        //转单成功的数据
-        $consulting = Db::name('consult_info')
-            ->alias('ci')
-            ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
-            ->where('ci.zxNo IN '.$temp_sql)
-            ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
-            ->group('co.depart')
-            ->column('count(ci.id) total', 'co.depart');
+        $consulting = Db::name('sale')
+            ->alias('s')
+            ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
+            ->where(['s.order_type' => 3, 's.is_del' => 0])//order_type==3 咨询采反
+            ->whereYear('s.addtime', date('Y'))
+            ->group('u.itemid')
+            ->column('count(s.id) consulting', 'u.itemid');
 
-        //处理全部数据
         $rs = Db::name('consult_order')
             ->alias('c')
             ->field('count(c.id) total,c.depart companyId,i.name companyName')
             ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
-            ->where('c.zxNo IN '.$temp_sql)
+            ->where(['c.is_del' => 0])
+            ->whereYear('c.addtime', date('Y'))
             ->group('c.depart')
             ->append(['transfer_rate'])
             ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
@@ -505,7 +487,7 @@ class Data extends BaseController
             ->toArray();
 
         return app_show(0, '请求成功', $rs);
-    }
 
+    }
 
 }

+ 29 - 22
app/admin/controller/Sale.php

@@ -96,33 +96,18 @@ class Sale extends Base
             }
             $origin_price = 0;
         }else{
-            $origin = Db::name("good_nake")->where([["spuCode","=",$spuCode],["min_num","<=",$good_num],["is_del","=",0]])->order("min_num desc")->find();
-            if($origin==false){
-                return error_show(1003,"未找到相关阶梯成本价格");
+            if($is_activity==0){
+                $origin = Db::name("good_nake")->where([["spuCode","=",$spuCode],["min_num","<=",$good_num],["is_del","=",0]])->order("min_num desc")->find();
+                if($origin==false){
+                    return error_show(1003,"未找到相关阶梯成本价格");
+                }
+                $origin_price = $origin['nake_total'];
             }
-            $origin_price = $origin['nake_total'];
         }
 
         $sale_price = isset($this->post['good_price'])&&$this->post['good_price']!=="" ? floatval($this->post['good_price']):'';
         $ct['cgd_gold_price']=0;
-        if($goodtype==1){
-            $good = Db::name("good_ladder")->where(["skuCode"=>$skuCode,"is_del"=>0,"status"=>1])->where([["min_num","<=",$good_num]])->order("min_num desc")->find();
-            if($good==false){
-                return error_show(1003,"未找到相关阶梯价格");
-            }
-            $sale_price = $sale_price!==""?$sale_price: $good['sale_price'];
-            if($ct['is_gold_price']==1 && $is_stock!=1){
-                $gold = Db::name("gold_price1")
-                    ->field('id,price')
-                    ->where(["type" => $ct['noble_metal'], "is_del" => 0, "status" => 1])
-                    ->order("addtime desc")
-                    ->find();
-
-                //$saleprice(最终售价) = (打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价+物流费)/(1-成本售价/100);
-                $sale_price = $sale_price!==""?$sale_price:($ct['demo_fee'] / $good_num + $ct['open_fee'] / $good_num
-                    + $ct['noble_weight'] * $gold["price"] + $good['cost_fee'] * $ct['noble_weight'] + $origin['package_fee'] + $origin['mark_fee'] + $origin['cert_fee'] + $origin['nake_fee'] + $origin['delivery_fee']);
-                $ct['cgd_gold_price']=$gold["price"];
-            }
+        if($goodtype==1 ){
             if($is_activity==1){
                 $act = Db::name("activity_info")->alias("a")->leftJoin("good_activity b","a.activity_code=b.activity_code")
                     ->where(["a.skuCode"=>$skuCode,"a.activity_code"=>$actcode,"a.is_del"=>0,"a.status"=>1,"b.status"=>6,"b.is_del"=>0])
@@ -137,7 +122,29 @@ class Sale extends Base
                     return error_show(1003,"商品活动库存剩余{$act['activity_stock']}");
                 }
                 $sale_price = $sale_price!==""?$sale_price:$act['activity_price'];
+                $origin_price = $act['cost_price'];
+            }else{
+                $good = Db::name("good_ladder")->where(["skuCode"=>$skuCode,"is_del"=>0,"status"=>1])->where([["min_num","<=",$good_num]])->order("min_num desc")->find();
+                if($good==false){
+                    return error_show(1003,"未找到相关阶梯价格");
+                }
+                $sale_price = $sale_price!==""?$sale_price: $good['sale_price'];
+                if($ct['is_gold_price']==1 && $is_stock!=1){
+                    $gold = Db::name("gold_price1")
+                        ->field('id,price')
+                        ->where(["type" => $ct['noble_metal'], "is_del" => 0, "status" => 1])
+                        ->order("addtime desc")
+                        ->find();
+
+                    //$saleprice(最终售价) = (打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价+物流费)/(1-成本售价/100);
+                    $sale_price = $sale_price!==""?$sale_price:($ct['demo_fee'] / $good_num + $ct['open_fee'] / $good_num
+                        + $ct['noble_weight'] * $gold["price"] + $good['cost_fee'] * $ct['noble_weight'] + $origin['package_fee'] + $origin['mark_fee'] + $origin['cert_fee'] + $origin['nake_fee'] + $origin['delivery_fee']);
+                    $ct['cgd_gold_price']=$gold["price"];
+                }
             }
+
+        }else{
+            $sale_price=0;
         }
         $cgd=[
             "supplierNo"=>$ct['supplierNo'],

+ 6 - 6
app/admin/controller/Stat.php

@@ -45,7 +45,7 @@ FROM
 				wsm_sale_return e
 				LEFT JOIN wsm_depart_user k ON e.apply_id = k.uid 
 				AND k.is_del = 0 
-				AND k.STATUS = 1 
+				AND k.STATUS = 1 and e.status=4
 			WHERE
 				k.itemid = c.id 
 				AND e.platform_id = a.platform_id 
@@ -56,7 +56,7 @@ FROM
 				wsm_order_back f
 				LEFT JOIN wsm_depart_user p ON f.apply_id = p.uid 
 				AND p.is_del = 0 
-				AND p.STATUS = 1 
+					AND p.STATUS = 1 and f.status=4
 			WHERE
 				p.itemid = c.id 
 				AND f.platform_id = a.platform_id 
@@ -92,7 +92,7 @@ FROM
 				wsm_sale_return e
 				LEFT JOIN wsm_depart_user k ON e.apply_id = k.uid 
 				AND k.is_del = 0 
-				AND k.STATUS = 1 
+				AND k.STATUS = 1 and e.status=4
 			WHERE
 				k.itemid = c.id 
 				AND e.platform_id = a.platform_id 
@@ -104,7 +104,7 @@ FROM
 				wsm_order_back f
 				LEFT JOIN wsm_depart_user p ON f.apply_id = p.uid 
 				AND p.is_del = 0 
-				AND p.STATUS = 1 
+					AND p.STATUS = 1 and f.status=4
 			WHERE
 				p.itemid = c.id 
 				AND f.platform_id = a.platform_id 
@@ -143,7 +143,7 @@ FROM
 				wsm_sale_return e
 				LEFT JOIN wsm_depart_user k ON e.apply_id = k.uid 
 				AND k.is_del = 0 
-				AND k.STATUS = 1 
+				AND k.STATUS = 1 and e.status=4
 			WHERE
 				k.itemid = c.id 
 				AND e.platform_id = a.platform_id 
@@ -154,7 +154,7 @@ FROM
 				wsm_order_back f
 				LEFT JOIN wsm_depart_user p ON f.apply_id = p.uid 
 				AND p.is_del = 0 
-				AND p.STATUS = 1 
+					AND p.STATUS = 1 and f.status=4
 			WHERE
 				p.itemid = c.id 
 				AND f.platform_id = a.platform_id