execute($sql); echo "tab_financial_summary 清空成功".PHP_EOL; //获取19年9月到上个月的所有月份 $monthList = $this->getMonthsList(); $Financial = new FinancialSummarySetController(); foreach ($monthList as $k => $v) { $Financial->setMonthFinancialSummary($v); } } //超级签订单新增识别微信或者支付宝2019-12-11 public function gameSupersignPaywayInit() { $map = array( "pay_status"=>1, "pay_way"=>0 ); $GameSupersign = M("GameSupersign","tab_"); $dbres = $GameSupersign->field("id,trade_id")->where($map)->select(); $countdb = count($dbres); if($countdb < 1){ die("No initialization required"); } foreach ($dbres as $key => $value) { $savedata = array( "id"=>$value['id'] ); $tmp = (int)substr($value['trade_id'],0,4); if($tmp > 3000){ $savedata['pay_way'] = 2; //微信 }else{ $savedata['pay_way'] = 1;//支付宝 } $tres = $GameSupersign->save($savedata); if($tres === false){ die("DB ERROR"); } } 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"); } //获取公司月结所需要的所有月份截止至上个月 public function getMonthsList() { $start_month = "2019-09"; $temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month'))); $end_month = date('Y',$temp)."-".date('m',$temp); $time_arr = []; $begin = new \DateTime($start_month); $end = new \DateTime($end_month); $end = $end->modify('+1 month'); $interval = new \DateInterval('P1M'); $daterange = new \DatePeriod($begin, $interval ,$end); foreach($daterange as $date){ $time_arr[] = $date->format("Y-m"); } return $time_arr; } }