|
@@ -21,7 +21,7 @@ class companyStats extends Command
|
|
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
|
{
|
|
|
- $supplier = ["GS2302231124114965","GS2302231125079621","GS2302231323386950"];
|
|
|
+ $supplier = ["GS2302231124114965","GS2302231125079621","GS2302231323386950",'GS2203161855277894'];
|
|
|
try{
|
|
|
foreach ($supplier as $sp){
|
|
|
$this->checkData($sp);
|
|
@@ -32,7 +32,10 @@ class companyStats extends Command
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function checkData($supplierNo){
|
|
|
+ /**
|
|
|
+ * @param $supplierNo
|
|
|
+ */
|
|
|
+ public function checkData($supplierNo):void {
|
|
|
$sup =Db::connect("mysql_sys")->name("headquarters")->where(["code"=>$supplierNo])->field("code,name,relation_code")->findOrEmpty();
|
|
|
if(empty($sup)) return;
|
|
|
$date=date("Y-m-d");
|
|
@@ -40,14 +43,13 @@ class companyStats extends Command
|
|
|
$temp=[];
|
|
|
$total =Db::name("qrd_info")
|
|
|
->where(["companyNo"=>$supplierNo,"is_del"=>0,"cxCode"=>""])
|
|
|
- ->whereDay("createdTime","today")
|
|
|
+ ->whereDay("createdTime",$date)
|
|
|
->field("sum(totalPrice+th_fee) as total")->findOrEmpty();
|
|
|
$day_thtotal=Db::name("th_source")->alias("a")
|
|
|
->leftJoin("qrd_info b","a.th_qrdNo=b.sequenceNo")
|
|
|
->where([['a.th_companyNo',"=",$supplierNo],["b.is_del","=",0]])
|
|
|
- ->whereDay("a.createtime","today")->field('sum(a.th_qrd_fee) as th_total')->findOrEmpty();;
|
|
|
- if(isset($d[1]))Db::name("depart_company")->where($d[1])->save(["sale_total"=>$total['total']??0,
|
|
|
- "th_total"=>$day_thtotal['th_total']??0]);
|
|
|
+ ->whereDay("a.createtime",$date)->field('sum(a.th_qrd_fee) as th_total')->findOrEmpty();;
|
|
|
+ if(isset($d[1]))Db::name("depart_company")->where($d[1])->save(["sale_total"=>$total['total']??0,"th_total"=>$day_thtotal['th_total']??0]);
|
|
|
else $temp[]=[
|
|
|
"companyNo"=>$supplierNo,
|
|
|
"companyName"=>$sup['name']??"",
|
|
@@ -60,12 +62,12 @@ class companyStats extends Command
|
|
|
$total_cx =Db::name("qrd_info")
|
|
|
->where(["companyNo"=>$supplierNo,"is_del"=>0])
|
|
|
->where("cxCode","<>","")
|
|
|
- ->whereDay("createdTime","today")
|
|
|
+ ->whereDay("createdTime",$date)
|
|
|
->field("sum(totalPrice+th_fee) as total")->findOrEmpty();
|
|
|
$day_thtotal_cx=Db::name("th_source")->alias("a")
|
|
|
->leftJoin("qrd_info b","a.th_qrdNo=b.cxCode")
|
|
|
->where([['a.th_companyNo',"=",$supplierNo],["b.is_del","=",0]])
|
|
|
- ->whereDay("a.createtime","today")
|
|
|
+ ->whereDay("a.createtime",$date)
|
|
|
->field("sum(a.th_num*b.goodPrice) as th_total")->findOrEmpty();
|
|
|
if(isset($d[2]))Db::name("depart_company")->where($d[2])->save(["sale_total"=>$total_cx['total']??0,
|
|
|
"th_total"=>$day_thtotal_cx['th_total']??0]);
|
|
@@ -78,7 +80,7 @@ class companyStats extends Command
|
|
|
"th_total"=>$day_thtotal_cx['th_total']??0,
|
|
|
"addtime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
- $cgd=$this->cgdData($sup['relation_code']);
|
|
|
+ $cgd=$this->cgdData($sup['relation_code'],$date);
|
|
|
if(isset($d[3]))Db::name("depart_company")->where($d[3])->save(["sale_total"=>$cgd['cgd_total'],
|
|
|
"th_total"=>$cgd['cgd_thtotal']]);
|
|
|
else $temp[]=[
|
|
@@ -93,16 +95,23 @@ class companyStats extends Command
|
|
|
if(!empty($temp))Db::name("depart_company")->insertAll($temp);
|
|
|
|
|
|
}
|
|
|
- public function cgdData($sup){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $sup
|
|
|
+ * @param $date
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ private function cgdData($sup,$date): array
|
|
|
+ {
|
|
|
|
|
|
$total =Db::name("cgd_info")
|
|
|
->where(["supplierNo"=>$sup,"is_del"=>0,"cxCode"=>""])
|
|
|
- ->whereDay("createdTime","today")
|
|
|
+ ->whereDay("createdTime",$date)
|
|
|
->field("sum(totalPrice+th_fee) as total")->findOrEmpty();
|
|
|
$day_thtotal=Db::name("th_source")->alias("a")
|
|
|
->leftJoin("cgd_info b","(a.th_cgdNo=b.sequenceNo and a.is_th=1) or (a.th_qrdNo=b.cxCode)")
|
|
|
->where([['b.supplierNo',"=",$sup],["b.is_del","=",0]])
|
|
|
- ->whereDay("a.createtime","today")
|
|
|
+ ->whereDay("a.createtime",$date)
|
|
|
->field("sum(a.th_num*b.goodPrice) as th_total")->findOrEmpty();
|
|
|
return ["cgd_total"=>$total['total']??0,"cgd_thtotal"=>$day_thtotal['th_total']??0];
|
|
|
}
|