From ab29dafffc61db97e52c996b704c79691821320e Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 12 Dec 2019 14:56:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=93=BE=E6=97=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/OldCountController.class.php | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index fd2d252eb..37283c3ce 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -37,6 +37,55 @@ class OldCountController extends \Think\Controller } die("init ok"); } - + /** + * mend表新增paymount字段用于统计补链前归属金额 + */ + public function mendPayamountInit() + { + //获取符合条件的 + $map = array("pay_amount"=>0); + $Mend = M("mend","tab_"); + $Spend = M("Spend","tab_"); + $Mend->where($map)->select(); + $dbres = $Mend->field("id,user_account,promote_account,order_time,create_time")->where($map)->select(); + $countdb = count($dbres); + if($countdb < 1) die("No initialization required"); + echo "总需要统计数:{$countdb}".PHP_EOL; + foreach ($dbres as $key => $value) { + $savedata = array("id"=>$value['id']); + $saveflag = false; + //设置订单时间 + $order_time = $value['order_time']; + if($value['order_time'] == 0){ + $saveflag = true; + $savedata['order_time'] = $value['create_time']; + $order_time = $savedata['create_time']; + } + //获取金额 + $smap = array( + "user_account"=>$value['user_account'], + "promote_account"=>$value['promote_account'], + "pay_time"=>array("LT",$order_time), + "pay_status"=>1 + ); + $pay_amount = $Spend->field("IFNULL(sum(pay_amount),0) pay_amount")->where($smap)->find()["pay_amount"]; + if($pay_amount > 0){ + $saveflag = true; + $savedata['pay_amount'] = $pay_amount; + } + if($saveflag){ + $tres = $Mend->save($savedata); + if($tres === false){ + die("DB ERROR"); + } + } + if( $key % 20 == 0){ + $j = (floor)($key/$countdb*100); + echo "当前进度:{$j}%".PHP_EOL; + } + + } + die("init ok"); + } }