Merge branch 'hotfix/shift_promote' of wmtx/platform into master

优化换绑
master
万盟天下 4 years ago committed by Gogs
commit 0b1719958e

@ -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){
@ -137,8 +136,12 @@ class MendController extends ThinkController {
// if(self::checkSettlement(strtotime($_POST['order_time']),$_POST['promote_id'])){ // if(self::checkSettlement(strtotime($_POST['order_time']),$_POST['promote_id'])){
// $this->error('在订单日期内含有已经结算的订单,无法补链'); // $this->error('在订单日期内含有已经结算的订单,无法补链');
// } // }
if(self::checkSpend(strtotime($_POST['order_time']),$_POST['account'])){
$this->error("在订单日期内含有已经结算的订单,无法补链。如订单:{$this->tempid}"); // if(self::checkSpend(strtotime($_POST['order_time']),$_POST['account'])){
// $this->error("在订单日期内含有已经结算的订单,无法补链。");
// }
if(self::checkOrderTime(strtotime($_POST['order_time']))){
$this->error('仅能补链本周数据,请重新选择补链时间');
} }
if(self::checkPromote(strtotime($_POST['order_time']),$_POST['account'])){ if(self::checkPromote(strtotime($_POST['order_time']),$_POST['account'])){
$this->error('在订单日期内含有多个推广员,无法补链'); $this->error('在订单日期内含有多个推广员,无法补链');
@ -178,20 +181,35 @@ 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 = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find()); $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
$this->display(); $this->display();
} }
} }
private function checkOrderTime($order_time){
$sdefaultDate = date("Y-m-d");
$first=1;//周一开始
$w=date('w',strtotime($sdefaultDate));
$checktime=strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'); //本周开始时间
if($order_time >= $checktime){
//在本周允许换绑
return false;
}
return true;
}
/** /**
* 2020.1.3 之后判断订单是否已经结算 * 2020.1.3 之后判断订单是否已经结算
*/ */
@ -200,42 +218,51 @@ 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($c_id) || $c_id['company_id'] == 0){
if(!empty($withspendlist)){ //官方渠道不结算,可换绑
//获取所有涉及订单 return false;
foreach ($withspendlist as $value) {
$dsh_list .= (','.$value['spend_ids']);
}
} }
if($dsh_list){ $c_id = $c_id['company_id'];
$dsh_list = array_flip(explode(",",$dsh_list)); $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();
if(empty($r) || $r['settlement_type'] == 0){
//不结算的公司允许换绑
return false;
} }
foreach($spendlist as $k=>$v){ $checktime = 0;
if($r['settlement_type'] == 1){
if($v['selle_status'] == 1){ //周结
$this->tempid = $v['pay_order_number']; $sdefaultDate = date("Y-m-d");
return true; //有已结算 $first=1;
} $w=date('w',strtotime($sdefaultDate));
if($dsh_list && $dsh_list[$v['id']]){ $checktime=strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'); //本周开始时间
$this->tempid = $v['pay_order_number']; }else{
return true; //有待审核的 //月结
} $y = date("Y", time()); //年
$m = date("m", time()); //月
$checktime = mktime(0, 0, 0, $m, 1, $y); // 本月开始时间
} }
return false; if($order_time >= $checktime){
//未在结算期内,允许换绑
return false;
}
//其他情况不允许换绑
return true;
} }
/** /**

@ -87,7 +87,7 @@
<tr> <tr>
<td class="l noticeinfo">订单日期:</td> <td class="l noticeinfo">订单日期:</td>
<td class="r table_radio"> <td class="r table_radio">
<input type="text" name="order_time" class="date" value="{:I('order_time')}" placeholder="订单日期" /> <input type="text" name="order_time" autocomplete="off" class="date" value="{:I('order_time')}" placeholder="订单日期" />
</td> </td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save