@ -91,26 +91,25 @@ class WithdrawController extends BaseController
{
$this->ajaxReturn(["msg"=>"打款成功","data"=>[],"status"=>1]);die();
$id = $_REQUEST['id'];
$remark = $_REQUEST['remark'];
var_dump(1);die();
Vendor("Alipay2020/Fund");
$fund = new \Fund();
//
$dbres = M("company_statement_info","tab_")->where("id='{$id}'")->find();
// $this->ajaxReturn(["msg"=>"打款成功","data"=>$dbres,"status"=>1]);die();
$company_info = json_decode($dbres['company_info'],true);
//TODO:未进行真实打款
if($dbres['pay_status'] != 1 & & $dbres['verify_status'] == 1){
//执行打款
$title = "测试-".$dbres['company_name']."结算";
$amount = $dbres['statement_money'];
$amount = 0.1;//测试金额为0
// $amount = 0.1;//测试金额为0
$payres = $fund->transfer($company_info['ali_account'],$company_info['ali_user'],$dbres['statement_num'],$amount, $title);
$resultCode = $payres->code;
$savedata = ["id"=>$dbres['id']];
if(!empty($resultCode)& & $resultCode == 10000){
$savedata["pay_status"]=1;
@ -122,22 +121,84 @@ var_dump(1);die();
$payres["remark"] = $remark;
$savedata["pay_info"] = json_encode($payres,JSON_UNESCAPED_UNICODE);
$savedata["pay_type"]=2 ;
$savedata["pay_type"]=1 ;
$savedata["pay_time"]=time();
} else {
$this->ajaxReturn(["msg"=>"已经打款过","data"=>[],"status"=>0]);
$this->poolCount($dbres['pool_id']);
$this->ajaxReturn(["msg"=>"已经打款过","data"=>$dbres,"status"=>0]);
}
$this->poolCount($dbres['pool_id']);
M("company_statement_info","tab_")->save($savedata);
$this->ajaxReturn(["msg"=>"打款成功","data"=>[] ,"status"=>1]);
$this->ajaxReturn(["msg"=>"打款成功","data"=>$dbres ,"status"=>1]);
# code...
}
/**
* 执行最后聚合表统计
* 整合数据,全部成功则支付成功,否则为支付中
*/
public function poolCount($poolid){
$pool_id = $poolid;
$CompanyInfo = M("company_statement_info","tab_");
if(count($pool_id) > 0){
foreach($pool_id as $k=>$v){
$f = $CompanyInfo->where("pool_id = {$v} AND pay_status < > 1")->find();
if(empty($f)){
//全部完成
$this->setOneVerifyStatus(4,"payment",$v);
}else{
//打款中
$this->setOneVerifyStatus(3,"payment",$v);
}
}
}
$this->ajaxReturn(["success"=>"打款成功","data"=>[]]);
}
protected function setOneVerifyStatus($change_status,$op_pre,$id)
{
$dbres = M("company_statement_pool","tab_")->field("id,verify_status,verify_log")->where("id = {$id}")->find();
$dbres['verify_log'] = json_decode($dbres['verify_log'],true);
$dbres['verify_log'][$op_pre.'_user']=$this->admininfo["mobile"];
$dbres['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s");
$dbres['verify_log'] = json_encode($dbres['verify_log']);
$dbres['verify_status']=$change_status;
M("company_statement_pool","tab_")->save($dbres);
}
public function withdrawDetail() {
$id = $_REQUEST["id"];
$dbres = M("company_statement_info","tab_")->where("id='{$id}'")->find();
$dbres = M("company_statement_info","tab_")
->field("*,tab_company_statement_info.id")
->join("left join tab_promote_company company on tab_company_statement_info.company_id=company.id")
->where("tab_company_statement_info.id='{$id}'")->find();
// dump($dbres);die();
$relation = M("company_relation","tab_")->where("second_company_id={$dbres['company_id']}")->find();
if (!$relation) {
$this->error("乙方关联信息不存在!");
}
if ($relation['invoice_type']==1) {
$relation['invoice_type'] = "专票";
} else if ($relation['invoice_type'] == 2) {
$relation['invoice_type'] = "普票";
} else {
$relation['invoice_type'] = "无";
}
$first_companmInfo = M("company_info","tab_")->where("id={$relation['first_company_id']}")->find();
if (!$first_companmInfo) {
$this->error("甲方公司信息不存在!");
}
$this->assign("relation",$relation);
$this->assign("first_company_info",$first_companmInfo);
$company_info = json_decode($dbres['company_info'],true);
$statemnt_info = json_decode($dbres['statement_info'],true);
@ -175,14 +236,31 @@ var_dump(1);die();
$game_id = M("game","tab_")->field("id")->where($game_map)->select();
$promote_data = [];
$promote_id = M("promote","tab_")->field("id")->where(['company_id'=>$_REQUEST['company_id']])->select();
foreach ($promote_id as $key => $value) {
$promote_data[] = $value['id'];
$data = M("promote","tab_")->field("id")->where(['chain'=>['like',"/{$value['id']}/"]])->select();
foreach ($data as $k => $v) {
$promote_data[] = $v['id'];
}
}
if ($promote_data) {
$map['promote_id'] = ['in',$promote_data];
}
$game_id = array_column($game_id,'id');
$map['pay_time'] = ['between',[strtotime($start),strtotime($end)+86399]];
$map['pay_status'] = 1;
$map['game_id'] = ['in',$game_id];
if ($_REQUEST['team_leader_id']||$_REQUEST['team_leader_id']=="0") {
$map['promote_id'] = $_REQUEST['team_leader_id'];
if ($_REQUEST['team_leader_id']) {
$promote_id = M("promote","tab_")->field("id")->where("id = {$_REQUEST['team_leader_id']} or chain like '%/{$_REQUEST['team_leader_id']}/%'")->select();
$map['promote_id'] = ['in',array_column($promote_id,'id')];
}
if(!empty($_REQUEST['start'])& & empty($_REQUEST['end'])){
@ -209,6 +287,7 @@ var_dump(1);die();
->where($map)
->page($page,$row)
->select();
// var_dump($data);die();
foreach ($data as $key => $value) {
$data[$key]['pay_time'] = date("Y-m-d H:i:s",$data[$key]['pay_time']);