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)
{
if (IS_POST) {
$promoteService = new PromoteService();
if ($_POST['prmoote_id_to'] == -1){
@ -137,8 +136,12 @@ class MendController extends ThinkController {
// if(self::checkSettlement(strtotime($_POST['order_time']),$_POST['promote_id'])){
// $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'])){
$this->error('在订单日期内含有多个推广员,无法补链');
@ -178,20 +181,35 @@ class MendController extends ThinkController {
$this->error($res['msg']);
}
} else {
$user = A('User', 'Event');
$user_data = $user->user_entity($id);
$user_data || $this->error("用户数据异常");
// echo 1;die();
$map['id'] = $id;
$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;
$this->assign("data", $user_data);
$this->assign("data", $data);
$this->meta_title = '编辑推广补链';
$this->m_title = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
$this->m_title = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
$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 之后判断订单是否已经结算
*/
@ -200,42 +218,51 @@ class MendController extends ThinkController {
$map = array(
"pay_status"=>1,
"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();
if(count($spendlist) < 1){
//无流水可换绑
return false;
}
//获取所有未审核
$withmap = array(
"status"=>0,
"settlement_begin_time"=>array("EGT",$order_time),
"settlement_end_time"=>array("ELT",$order_time)
);
$withspendlist = M("withdraw","tab_")->field("spend_ids")->select();
//获取结算方式
$c_id = M("User","tab_")
->alias('a')
->field("IFNULL(p.company_id,0) company_id")
->join('tab_promote p ON a.promote_id= p.id')
->where("a.account = '{$account}'")
->find();
$dsh_list = false;
if(!empty($withspendlist)){
//获取所有涉及订单
foreach ($withspendlist as $value) {
$dsh_list .= (','.$value['spend_ids']);
}
if(empty($c_id) || $c_id['company_id'] == 0){
//官方渠道不结算,可换绑
return false;
}
if($dsh_list){
$dsh_list = array_flip(explode(",",$dsh_list));
$c_id = $c_id['company_id'];
$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){
if($v['selle_status'] == 1){
$this->tempid = $v['pay_order_number'];
return true; //有已结算
}
if($dsh_list && $dsh_list[$v['id']]){
$this->tempid = $v['pay_order_number'];
return true; //有待审核的
}
$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); // 本月开始时间
}
return false;
if($order_time >= $checktime){
//未在结算期内,允许换绑
return false;
}
//其他情况不允许换绑
return true;
}
/**

@ -87,7 +87,7 @@
<tr>
<td class="l noticeinfo">订单日期:</td>
<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>
</tr>
<tr>

Loading…
Cancel
Save