You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.0 KiB
PHTML

<?php
namespace Admin\Controller;
/**
* 新功能之后还未来的急跑的脚本初始化数据
* @author chenzhi
*/
class OldCountController extends \Think\Controller
{
//超级签订单新增识别微信或者支付宝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");
}
}