优化换绑

master
chenzhi 4 years ago
parent 831c87c9ee
commit 617cfbd4bf

@ -118,7 +118,6 @@ class MendController extends ThinkController {
public function edit($id = null) public function edit($id = null)
{ {
if (IS_POST) { if (IS_POST) {
$promoteService = new PromoteService(); $promoteService = new PromoteService();
if ($_POST['prmoote_id_to'] == -1){ if ($_POST['prmoote_id_to'] == -1){
@ -178,11 +177,15 @@ class MendController extends ThinkController {
$this->error($res['msg']); $this->error($res['msg']);
} }
} else { } else {
$user = A('User', 'Event'); // echo 1;die();
$user_data = $user->user_entity($id); $map['id'] = $id;
$user_data || $this->error("用户数据异常"); $data = M("user","tab_")->where($map)->find();
// $user = A('User', 'Event');
// $user_data = $user->user_entity($id);
// $user_data || $this->error("用户数据异常");
// var_dump($user_data);die; // var_dump($user_data);die;
$this->assign("data", $user_data); $this->assign("data", $data);
$this->meta_title = '编辑推广补链'; $this->meta_title = '编辑推广补链';
$this->m_title = '推广补链'; $this->m_title = '推广补链';
@ -200,43 +203,50 @@ class MendController extends ThinkController {
$map = array( $map = array(
"pay_status"=>1, "pay_status"=>1,
"user_account"=>$account, "user_account"=>$account,
"pay_time"=>array("EGT",$order_time) "payed_time"=>array("EGT",$order_time)
); );
$spendlist = M("Spend","tab_")->field("id,selle_status,pay_order_number")->where($map)->select(); $spendlist = M("Spend","tab_")->field("id,selle_status,pay_order_number")->where($map)->select();
if(count($spendlist) < 1){ if(count($spendlist) < 1){
return false; return false;
} }
//获取所有未审核 //获取结算方式
$withmap = array( $c_id = M("User","tab_")
"status"=>0, ->alias('a')
"settlement_begin_time"=>array("EGT",$order_time), ->field("IFNULL(p.company_id,0) company_id")
"settlement_end_time"=>array("ELT",$order_time) ->join('tab_promote p ON a.promote_id= p.id')
); ->where("a.account = '{$account}'")
$withspendlist = M("withdraw","tab_")->field("spend_ids")->select(); ->find();
$dsh_list = false;
if(!empty($withspendlist)){
//获取所有涉及订单
foreach ($withspendlist as $value) {
$dsh_list .= (','.$value['spend_ids']);
}
}
if($dsh_list){
$dsh_list = array_flip(explode(",",$dsh_list));
}
foreach($spendlist as $k=>$v){
if($v['selle_status'] == 1){ if(empty($c_id) || $c_id['company_id'] == 0){
$this->tempid = $v['pay_order_number']; //官方渠道不结算,可换绑
return true; //有已结算 return false;
} }
if($dsh_list && $dsh_list[$v['id']]){ $c_id = $c_id['company_id'];
$this->tempid = $v['pay_order_number']; $r = M("CompanyRelation","tab_")->where("(first_company_type = 2 AND first_company_id = '{$c_id}') OR (second_company_type = 2 AND second_company_id = '{$c_id}')")->find();
return true; //有待审核的 if(empty($r) || $r['settlement_type'] == 0){
//不结算的公司允许换绑
return false;
} }
$checktime = 0;
if($r['settlement_type'] == 1){
//周结
$sdefaultDate = date("Y-m-d");
$first=1;
$w=date('w',strtotime($sdefaultDate));
$checktime=strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'); //本周开始时间
}else{
//月结
$y = date("Y", time()); //年
$m = date("m", time()); //月
$checktime = mktime(0, 0, 0, $m, 1, $y); // 本月开始时间
} }
if($order_time >= $checktime){
//未在结算期内,允许换绑
return false; return false;
} }
//其他情况不允许换绑
return true;
}
/** /**
* 2020.1.3 之前判断订单是否已经结算 * 2020.1.3 之前判断订单是否已经结算

Loading…
Cancel
Save