wugg hace 2 años
padre
commit
70992c4132
Se han modificado 1 ficheros con 72 adiciones y 270 borrados
  1. 72 270
      app/command/good.php

+ 72 - 270
app/command/good.php

@@ -8,289 +8,91 @@ use think\console\Input;
 use think\console\input\Argument;
 use think\console\input\Option;
 use think\console\Output;
-use think\facade\Db;
+use think\facade\Cache;use think\facade\Db;
 
 class good extends Command
 {
-    private $db;
     protected function configure()
     {   $this->setName('good')
         ->setDescription('the good command');
-
     }
 
     protected function execute(Input $input, Output $output)
     {
-        $this->db =Db::connect("mysql2");
-        $data = $this->Getdata();
-        foreach ($data as $value){
-            $value['spucode']= str_replace("GY","SPU",$value['good_code']);
-            $value['item_code']=str_replace("GY","SKU",$value['good_code']);
-            $isT=Db::name("good")->where("good_code","=",$value['good_code'])->find();
-            $temp=[
-                "spuCode"=>$value['spucode'],
-                "good_code"=>$value['good_code'],
-                "createrid"=>0,
-                "ownerid"=>0,
-                "cgderid"=>0,
-                "creater"=>$value['creater']??"",
-                "owner"=>$value['owner']??"",
-                "cgder"=>$value['cg_saler']==""?"":$value['cg_saler'],
-                "gys_code"=>$value['gys_code'],
-                "license"=>'',
-                "platform_code"=>$value['item']??"",
-                "cat_id"=>$this->getCat($value['sort_f'],$value['sort_s'],$value['sort_t']),
-                "addtime"=>isset($value['addtime'])&&$value['addtime']!=""? $value['addtime']:date("Y-m-d H:i:s"),
-                "updatetime"=>isset($value['updatetime'])&&$value['updatetime']!=""? $value['updatetime']:date("Y-m-d H:i:s"),
-            ];
-            if($isT){
-                Db::name("good")->where($isT)->save($temp);
-            }else{
-                Db::name("good")->save($temp);
-            }
-            $this->addType($value);
-            $this->laddle($value);
-        }
-    }
-    public function laddle($value){
-        if($value['step_num_1']!=""){
-            $temp=[
-                "skuCode"=>$value['item_code'],
-                "platform_code"=>$value['item']??"",
-                "min_num"=>$value['step_num_1'],
-                "max_num"=>$value['step_num_2']??0,
-                "sale_price"=>$value['step_price_1'],
-                "origin_price"=>$value['market_fee'],
-                "ladder"=>1,
-                "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
-            ];
-            $upda= Db::name("good_ladder")->where(["skuCode"=>$value['item_code'],"platform_code"=>$temp['platform_code'],"ladder"=>$temp['ladder']])->find();
-            if($upda){
-                Db::name("good_ladder")->where($upda)->save($temp);
-            }else{
-                Db::name("good_ladder")->save($temp);
-            }
-        }
-        if($value['step_num_2']!=""){
-            $temp=[
-                "skuCode"=>$value['item_code'],
-                "platform_code"=>$value['item']??"",
-                "min_num"=>$value['step_num_2'],
-                "max_num"=>$value['step_num_3']??0,
-                "sale_price"=>$value['step_price_2'],
-                "origin_price"=>$value['market_fee'],
-                "ladder"=>2,
-                "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
-            ];
-            $upda= Db::name("good_ladder")->where(["skuCode"=>$value['item_code'],"platform_code"=>$temp['platform_code'],"ladder"=>$temp['ladder']])->find();
-            if($upda){
-                Db::name("good_ladder")->where($upda)->save($temp);
-            }else{
-                Db::name("good_ladder")->save($temp);
-            }
-        }
-        if($value['step_num_3']!=""){
-            $temp=[
-                "skuCode"=>$value['item_code'],
-                "platform_code"=>$value['item']??"",
-                "min_num"=>$value['step_num_3'],
-                "max_num"=>0,
-                "sale_price"=>$value['step_price_3'],
-                "origin_price"=>$value['market_fee'],
-                "ladder"=>3,
-                "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
-            ];
-            $upda= Db::name("good_ladder")->where(["skuCode"=>$value['item_code'],"platform_code"=>$temp['platform_code'],"ladder"=>$temp['ladder']])->find();
-            if($upda){
-                Db::name("good_ladder")->where($upda)->save($temp);
-            }else{
-                Db::name("good_ladder")->save($temp);
-            }
-        }
-    }
-
-    public function getCat($f,$s,$t){
-        if($f==''){
-            return 0;
-        }
-        $first = Db::name("cat")->where(['cat_name'=>$f,"level"=>1])->find();
-        if(empty($first)){
-            return 0;
-        }
-        if($s==""){
-            return $first['id'];
-        }
-        $sec = Db::name("cat")->where(['cat_name'=>$s,"level"=>2,"pid"=>$first['id']])->find();
-        if(empty($sec)){
-            return $first['id'];
-        }
-        if($t==""){
-            return $sec['id'];
-        }
-        $thd = Db::name("cat")->where(['cat_name'=>$t,"level"=>3,"pid"=>$sec['id']])->find();
-        if(empty($thd)){
-            return $sec['id'];
-        }
-        return $thd['id'];
+    	 // 指令输出
+        $sttime = Cache::get("departTips");
+        if($sttime==1) return '';
+        Cache::set("departTips",1,1800);
+    	$daprtid = [56,64,52,57];
+		$temp=["p"=>"总计","thtotal"=>0,"mtotal"=>0,"mthfee"=>0,"wtotal"=>0,"wthfee"=>0,"dtotal"=>0,"thfee"=>0,"tips"=>0,"rate"=>0,"thrate"=>0];
+		$data=[];
+		$uidArr =Db::name("depart_user")->where(['itemid'=>$daprtid])->column("uid","itemid");
+		foreach ($uidArr as $key=>$uid){
+			$data[]=$this->GetData($uid,$key);
+		}
+		$temp['thtotal'] = sprintf( "%.2f",array_sum(array_column($data,'thtotal')));
+        $temp['mtotal'] = sprintf( "%.2f",array_sum(array_column($data,'mtotal')));
+        $temp['mthfee'] = sprintf( "%.2f",array_sum(array_column($data,'mthfee')));
+        $temp['wtotal'] = sprintf( "%.2f",array_sum(array_column($data,'wtotal')));
+        $temp['wthfee'] = sprintf( "%.2f",array_sum(array_column($data,'wthfee')));
+        $temp['dtotal'] = sprintf( "%.2f",array_sum(array_column($data,'dtotal')));
+        $temp['thfee'] = sprintf( "%.2f",array_sum(array_column($data,'thfee')));
+        $temp['tips'] = sprintf( "%.2f",array_sum(array_column($data,'tips')));
+        $temp["rate"]=number_format( $temp['mtotal']/$temp['tips']*100,2);
+		$temp["thrate"]=number_format( $temp['thtotal']/$temp['tips']*100,2);
 
+		$sort = array_column($data,"thrate");
+        array_multisort($sort,SORT_DESC,$data);
+        array_unshift($data,$temp);
+        Cache::set("departContent",$data);
+        $date=date('Y-m-d H:i:s');
+        $output->writeln("[{$date}] 更新数据成功");
     }
-
-    public function addType($value){
-        $data=[
-            "skuCode"=>$value['item_code'],
-            "spuCode"=>$value['spucode'],
-            "good_name"=>$value['good_name'],
-            "good_desc"=>'',
-            "good_img"=>'',
-            "good_type"=>$value['good_type'],
-            "good_title"=>'',
-            "barnd"=>$value['brand'],
-            "model"=>$value['model'],
-            "origin_place"=>$value['good_addr'],
-            "unit"=>$value['unit'],
-            "weight"=>$value['good_weight'],
-            "color"=>$value['color']??'',
-            "material"=>$value['material']??'',
-            "craft_desc"=>'',
-            "specs"=>$value['specs'],
-            "good_size"=>"",
-            "packing_size"=>$value['pack_size'],
-            "packing_way"=>"",
-            "packing_specs"=>"",
-            "packing_weight"=>"0",
-            "bar_code"=>$value['bar_code'],
-            "supply_area"=>$value['supply_area'],
-            "packing_img"=>"",
-            "delivery_place"=>$value['shipment'],
-            "delivery_day"=>intval($value['logistics']),
-            "market_price"=>$value['market_fee'],
-            "warn_stock"=>0,
-            "web_url"=>"",
-            "is_diff"=>$value['is_diff']=="是"?1 :0,
-            "cert_fee"=>$value['cert_fee']??0,
-            "packing_fee"=>$value['packing_fee']??0,
-            "mark_fee"=>$value['mark_fee']??0,
-            "cost_fee"=>$value['cost_fee']??0,
-            "demo_fee"=>0,
-            "noble_metal"=>$value['noble_metal'],
-            "open_fee"=>0,
-            "response_time"=>intval($value['fk_day']),
-            "lead_time"=>intval($value['duration']),
-            "custom_moq"=>intval($value['min_num']),
-            "custome_day"=>0,
-            "sample_day"=>intval($value['sampling_period']),
-            "sample_fee"=>floor($value['sample_fee']),
-            "nake_price"=>$value['nake_fee'],
-            "addtime"=>date("Y-m-d H:i:s"),
-            "updatetime"=>date("Y-m-d H:i:s")
-        ];
-        $ist = Db::name("good_type")->where(["skuCode"=>$data['skuCode']])->find();
-        if($ist){
-            Db::name("good_type")->where($ist)->save($data);
-        }else{
-            Db::name("good_type")->save($data);
-        }
+	//各部门统计数据
+    public  function GetData($uid,$departid=0){
+		$temp=["p"=>"","thtotal"=>0,"mtotal"=>0,"mthfee"=>0,"wtotal"=>0,"wthfee"=>0,"dtotal"=>0,"thfee"=>0,"tips"=>0,"rate"=>0,"thrate"=>0];
+    	$tips = Db::name("depart_tips")->where(['year'=>Db::raw('YEAR(NOW())') ,"month"=>Db::raw('month(NOW())'),"depart_id"=>$departid])
+    	->column("department,total_tips");
+		$temp['p']= $tips['department']??"";
+		$temp['tips']= sprintf( "%.2f",$tips['total_tips']??0);
+    	$month_total =Db::name("sale")->where([["apply_id","in",$uid],["is_del","=",0]])->whereMonth("addtime","this month")
+		->sum('total_price');
+		$month_thtotal=Db::name("th_data")->where([["apply_id","in",$uid],["is_del","=",0]])->whereMonth("addtime","this month")
+		->sum('th_fee');
+		$week_total =Db::name("sale")->where([["apply_id","in",$uid],["is_del","=",0]])->whereWeek("addtime","this week")
+		->sum('total_price');
+		$week_thtotal=Db::name("th_data")->where([["apply_id","in",$uid],["is_del","=",0]])->whereWeek("addtime","this week")
+		->sum('th_fee');
+		$day_total =Db::name("sale")->where([["apply_id","in",$uid],["is_del","=",0]])->whereDay("addtime","today")
+		->sum('total_price');
+		$day_thtotal=Db::name("th_data")->where([["apply_id","in",$uid],["is_del","=",0]])->whereDay("addtime","today")->sum('th_fee');
+		if($departid==56){
+			$wlb= $this->wlb();
+			$month_total+=$wlb['month_total'];
+			$week_total+=$wlb['week_total'];
+			$day_total+=$wlb['day_total'];
+		}
+			$temp['thtotal']=sprintf( "%.2f",(($month_total??0) - ($month_thtotal??0)));
+			$temp['mtotal']=sprintf( "%.2f",$month_total??0 );
+			$temp['mthfee']=sprintf( "%.2f",$month_thtotal??0);
+			$temp['wtotal']=sprintf( "%.2f",$week_total??0);
+			$temp['wthfee']= sprintf( "%.2f",$week_thtotal??0);
+			$temp['dtotal']=sprintf( "%.2f",$day_total??0);
+			$temp['thfee']= sprintf( "%.2f",$day_thtotal??0);
+			$temp["rate"]=number_format( $temp['mtotal']/$tips['total_tips']*100,2);
+			$temp["thrate"]=number_format( $temp['thtotal']/$tips['total_tips']*100,2);
+		return $temp;
     }
 
-    public function Getplat($name){
-        $plat=Db::name("platform")->where(["paltform_name"=>$name])->find();
-        return isset($plat['paltform_code'])&&$plat['paltform_code']!='' ?$plat['paltform_code']:$name;
-    }
-    public function  Getdata(){
-        $date = date("Y-m-d H:i:s",strtotime("-1 day"));
-        $sql="SELECT
-b.Date1618678149288 as 'addtime',
-b.ShortText1621438752474 as 'good_code',
-b.ShortText1615776172238 as 'item',
-(SELECT 
-    b_.`name` 
-  FROM
-    h_org_user b_ 
-  WHERE b_.id =b.creater) as 'creater',
-		(SELECT 
-    b_.`name` 
-  FROM
-    h_org_user b_ 
-  WHERE b_.id =b.`owner`) as 'owner',
-b.text1615776332933 as 'good_name',
-b.ShortText1622973543024 as 'old_item',
-b.ShortText1618630964434 as 'tkcode',
-b.text1615776271768 as 'item_code',
-b.text1618981719029 as 'spucode',
-b.text1615776440661 as 'model',
-b.text1615776695388 as 'color',
-b.text1615776685415 as 'material',
-b.text1618677034797 as 'technology',
-b.ShortText1615776786473 as 'unit',
-b.text1618677035673 as 'good_type',
-b.text1619509430228 as 'specs',
-b.ShortText1618677119629 as 'is_main',
-b.ShortText1617875730953 as 'is_diff',
-ifnull(b.Number1618677207590,0)  as 'good_weight',
-ifnull(b.Number1619054377997,0)  as 'box_weight',
-b.ShortText1618677229373 as 'box_specs',
-b.text1618677251640 as 'box_size',
-b.text1618677252567 as 'pack_size',
-b.ShortText1618677280883 as 'bar_code',
-b.ShortText1618677293358 as 'good_addr',
-b.ShortText1618677303623 as 'fk_day',
-b.ShortText1618677324610 as 'supply_area',
-b.text1619517580239 as 'shipment',
-ifnull(b.ShortText1615776990102,'') as 'gys_code',
-b.Number1618677463881 as 'min_num',
-b.number1619054436137 as 'order_minnum',
-b.Number1617867853654 as 'duration',
-b.Number1618677510201 as 'sampling_period',
-ifnull(b.Number1618677523586,0) as 'sample_fee',
-ifnull(b.number1615788597819,0)  as 'nake_fee',
-b.number1617867867574 as 'logistics',
-ifnull(b.number1615788674789,0)  as 'logistics_fee',
-ifnull(b.number1615788650916,0)  as 'cert_fee',
-ifnull(b.number1615788639684,0)  as 'packing_fee',
-ifnull(b.number1615788611295,0)  as 'mark_fee',
-ifnull(b.number1617875705335,0)  as 'cost_fee',
-ifnull(b.number1615788686735,0)  as 'unit_price',
-ifnull(b.ShortText1615454226082,'') as 'noble_metal',
-ifnull(b.number1618677641446,0)  as 'metal_weight',
-ifnull(b.Number1616399256021,0)  as 'market_fee',
-b.ShortText1616119282513 as 'wsm_nature',
-b.ShortText1619054472299 as 'is_step',
-b.ShortText1618677768792 as 'tax',
-b.Number1618677857395 as 'step_num_1',
-b.Number1619054496274 as 'step_post_1',
-b.Number1618677862829 as 'step_price_1',
-b.number1618677888101 as 'step_num_2',
-b.number1619054497412 as 'step_post_2',
-b.number1618677890766 as 'step_price_2',
-b.number1618677920417 as 'step_num_3',
-b.number1619054516068 as 'step_post_3',
-b.number1618677922828 as 'step_price_3',
-b.number1618677997457 as 'sale_1',
-b.number1618677998335 as 'sale_2',
-b.number1618678013601 as 'sale_3',
-b.number1618964483608 as 'sale_other',
-(SELECT 
-    b_.`name` 
-  FROM
-    h_org_user b_ 
-  WHERE b_.id = JSON_EXTRACT (
-      b.StaffSelector1616205980618,
-      '$[0].id'
-    )) as 'cg_saler',
-b.ShortText1618678061783 as 'is_online',
-b.ShortText1618678132819 as 'fund',
-b.ShortText1615802884401 as 'brand',
-b.ShortText1615776612618 as 'sort_f',
-b.text1615776646788 as 'sort_s',
-b.ShortText1618558317611 as 'sort_t',
-b.ShortText1616222832962 as 'supplier',
-b.ShortText1631180192195 as 'change',
-b.modifiedTime as 'updatetime'
- from ibt0b_SPXX b ";
-    $result = $this->db->query($sql);
-    return $result;
+	//网络部数据统计
+    public function wlb(){
+    	$Db=Db::connect("mysql_cxinv");
+    	$month_total =$Db->name("inter_order")->alias("a")->leftjoin("qrd_info b","a.orderCode=b.sequenceNo")
+    	->whereMonth("addtime","this month")->sum('totalPrice');
+    	   	$week_total =$Db->name("inter_order")->alias("a")->leftjoin("qrd_info b","a.orderCode=b.sequenceNo")
+    	->whereWeek("addtime","this week")->sum('totalPrice');
+    	   	   	$day_total =$Db->name("inter_order")->alias("a")->leftjoin("qrd_info b","a.orderCode=b.sequenceNo")
+    	->whereDay("addtime","today")->sum('totalPrice');
+    	return ["month_total"=>$month_total,"week_total"=>$week_total,"day_total"=>$day_total] ;
     }
 }