|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
use User\Api\UserApi as UserApi;
|
|
|
|
use Base\Service\PromoteService as PromoteService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 后台首页控制器
|
|
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
|
|
*/
|
|
|
|
class MendController extends ThinkController {
|
|
|
|
|
|
|
|
public function lists($p=1){
|
|
|
|
$this->m_title = '推广补链';
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
|
|
|
|
|
|
|
|
switch ($_GET['type']) {
|
|
|
|
case '':
|
|
|
|
case 1:
|
|
|
|
$this->mendList();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->recordList();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function mendList(){
|
|
|
|
if(isset($_REQUEST['account'])){
|
|
|
|
if ($_REQUEST['account']=='全部') {
|
|
|
|
unset($_REQUEST['account']);
|
|
|
|
}
|
|
|
|
$map['account']=array('like','%'.$_REQUEST['account'].'%');
|
|
|
|
unset($_REQUEST['account']);
|
|
|
|
}
|
|
|
|
$map['puid']=0;
|
|
|
|
$map['length(account)'] = array('gt', 0);
|
|
|
|
$map['register_time'] = array('gt', 0);
|
|
|
|
$p = I('p');
|
|
|
|
$map['register_type'] = array('in','(0,1,2,3,4,5,6,7)');
|
|
|
|
parent::lists("user",$p,$map);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function recordList()
|
|
|
|
{
|
|
|
|
if(isset($_REQUEST['account'])){
|
|
|
|
if ($_REQUEST['account']=='全部') {
|
|
|
|
unset($_REQUEST['account']);
|
|
|
|
}
|
|
|
|
$map['user_account']=array('like','%'.$_REQUEST['account'].'%');
|
|
|
|
unset($_REQUEST['account']);
|
|
|
|
}
|
|
|
|
$p = I('p');
|
|
|
|
$this->assign('show_status',1);
|
|
|
|
parent::lists("Mend",$p,$map);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function edit($id = null)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IS_POST) {
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
if ($_POST['prmoote_id_to'] == -1){
|
|
|
|
$_POST['prmoote_id_to'] = 0;
|
|
|
|
}
|
|
|
|
if ($_POST['prmoote_id_to'] === ''){
|
|
|
|
$this->error('请选择需要变更的渠道');
|
|
|
|
}
|
|
|
|
if ($_POST['promote_id'] == $_POST['prmoote_id_to']) {
|
|
|
|
$this->error('没有变更数据');
|
|
|
|
}
|
|
|
|
if ($_POST['order_time'] == '') {
|
|
|
|
$this->error('没有订单日期');
|
|
|
|
}
|
|
|
|
$create = $_REQUEST;
|
|
|
|
$create['order_time'] = date($create['order_time']);
|
|
|
|
$params = array(
|
|
|
|
"from_promote_id"=>$create['promote_id'],
|
|
|
|
"to_promote_id"=>$create['prmoote_id_to'],
|
|
|
|
"order_time"=>$create['order_time'],
|
|
|
|
"type"=>2,
|
|
|
|
"shift_ids"=>[$create['user_id']],
|
|
|
|
);
|
|
|
|
if(!empty($create['remark'])){
|
|
|
|
$params['remark'] = $create['remark'];
|
|
|
|
}
|
|
|
|
$res = $promoteService->addShiftTask($params);
|
|
|
|
if($res['status']){
|
|
|
|
$this->success('补链成功', U('lists'), 2);
|
|
|
|
}else{
|
|
|
|
$this->error($res['msg']);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$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->meta_title = '编辑推广补链';
|
|
|
|
|
|
|
|
$this->m_title = '推广补链';
|
|
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
|
|
|
|
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//补链详情
|
|
|
|
public function shiftInfo()
|
|
|
|
{
|
|
|
|
$id = I('id');
|
|
|
|
$info = M("shift_task")->where("id = {$id} and status = 0")->find();
|
|
|
|
if(empty($info)){
|
|
|
|
$this->error("补链不存在或已处理");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$info['user_id'] = json_decode($info['shift_ids'])[0];
|
|
|
|
$info['order_time'] = date("Y-m-d",$info['order_time']);
|
|
|
|
$this->assign('data',$info);
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
//取消补链
|
|
|
|
public function cancelShift()
|
|
|
|
{
|
|
|
|
$id = I('id');
|
|
|
|
$status = M('ShiftTask')->where(['id' => $id,'status' => 0])->save(['status' => 2]);
|
|
|
|
if ($status) {
|
|
|
|
$this->success('取消补链成功', U('lists'), 2);
|
|
|
|
} else {
|
|
|
|
$this->error("取消失败,或补链已生效",U('lists'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|