diff --git a/Application/Admin/Controller/MendController.class.php b/Application/Admin/Controller/MendController.class.php index 6b4bf9ca6..e937f5b80 100644 --- a/Application/Admin/Controller/MendController.class.php +++ b/Application/Admin/Controller/MendController.class.php @@ -1,8 +1,11 @@ field("user_account,promote_account,pay_amount,promote_account_to,order_time,create_time,op_account,remark") + ->field("user_account,promote_account,pay_amount,promote_account_to,order_time,create_time,op_account,remark,status") ->where($map) ->order("create_time desc"); @@ -79,6 +82,7 @@ class MendController extends ThinkController { $data = $data->page($page, $row)->select(); } //格式化信息 + $mendService = new MendService(); foreach ($data as $key => $value) { ($data[$key]['promote_account']=='官方渠道')?($data[$key]['promote_account']=C('OFFICIEL_CHANNEL')):''; @@ -88,9 +92,10 @@ class MendController extends ThinkController { if(!$show_data_power){ $data[$key]['user_account'] = encryptStr($data[$key]['user_account']); } + $data[$key]['status'] = $mendService->getStatusText($value['status']); } - if($export) db2csv($data,"推广员管理_推广补链_补链记录",["玩家账号","补链前渠道","补链前归属金额","补链后渠道","切分时间","补链时间","操作人员","备注"]); + if($export) db2csv($data,"推广员管理_推广补链_补链记录",["玩家账号","补链前渠道","补链前归属金额","补链后渠道","切分时间","补链时间","操作人员","备注","处理状态"]); if(IS_POST){ $page = set_pagination($_REQUEST['row_count'],$row); @@ -112,73 +117,37 @@ class MendController extends ThinkController { $this->assign('show_data_power', $show_data_power); $this->display(); - // 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('没有订单日期'); - } - //判断是否已经结算 - // if(self::checkSettlement(strtotime($_POST['order_time']),$_POST['promote_id'])){ - // $this->error('在订单日期内含有已经结算的订单,无法补链'); - // } - - // 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('在订单日期内含有多个推广员,无法补链'); - } - - $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']], - "creator_type"=>0, - "creator_id"=>$_SESSION["onethink_admin"]["user_auth"]["uid"] - ); - if(!empty($create['remark'])){ - $params['remark'] = $create['remark']; - } - -// dump($create);die(); - - $res = $promoteService->addShiftTask($params); - if($res['status']){ - - $userData = M('user','tab_')->field('account')->where(['id'=>$create['user_id']])->find(); - $promoteToData = M('promote','tab_')->field('account')->where(['id'=>$create['prmoote_id_to']])->find(); - $promoteFromData = M('promote','tab_')->field('account')->where(['id'=>$create['promote_id']])->find(); - if ($create['promote_id'] == '0') { - $promoteFromData['account'] = '官方渠道'; + $params = I('post.'); + $service = new MendService(); + try { + + if (session('user_auth')['allow_over_week'] && $params['allow_over_week'] == 1) { + $params['allow_over_week'] = 1; + } else { + $params['allow_over_week'] = 0; } - - addOperationLog(['op_type'=>1,'key'=>$userData['account'].'/'.$promoteFromData['account'].'/'.$promoteToData['account'],'op_name'=>'编辑推广补链','url'=>U('Mend/edit',['id'=>$create['user_id']]),'menu'=>'推广员-推广员管理-推广补链-编辑推广补链']); + $service->addMendTask($params); + + $userData = M('user','tab_')->field(['account', 'promote_id', 'promote_account'])->where(['id' => $params['user_id']])->find(); + $promoteToData = M('promote','tab_')->field('account')->where(['id'=> $params['prmoote_id_to']])->find(); + addOperationLog([ + 'op_type' => 1, + 'key' => $userData['account'].'/'.$userData['promote_account'].'/'.$promoteToData['account'], + 'op_name' => '编辑推广补链', + 'url' => U('Mend/edit', ['id' => $userData['id']]), + 'menu' => '推广员-推广员管理-推广补链-编辑推广补链', + 'content' => json_encode($params) + ]); $this->success('补链成功', U('lists'), 2); - }else{ - $this->error($res['msg']); + } catch (\Exception $e) { + $this->error($e->getMessage()); } } else { // echo 1;die(); @@ -194,8 +163,7 @@ class MendController extends ThinkController { $this->m_title = '推广补链'; $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find()); - - + $this->assign('allow_over_week', session('user_auth')['allow_over_week']); $this->display(); } } @@ -300,17 +268,11 @@ class MendController extends ThinkController { public function shiftInfo() { $id = I('id'); - $info = M("shift_task")->where("id = {$id} and status = 0")->find(); - + $info = M("mend", 'tab_')->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']); - $userid = $info['user_id']; - $info['account'] = M("User","tab_")->field("account")->where("id = '{$userid}'")->find()['account']; $this->assign('data',$info); $this->display(); } @@ -318,11 +280,16 @@ class MendController extends ThinkController { public function cancelShift() { $id = I('id'); - $status = M('ShiftTask')->where(['id' => $id,'status' => 0])->save(['status' => 2]); - if ($status) { - addOperationLog(['op_type'=>1,'key'=>$id,'op_name'=>'取消补链','url'=>U('Mend/shiftInfo',['id'=>$id]),'menu'=>'推广员-推广员管理-推广补链-取消补链']); + $model = new Model(); + $model->startTrans(); + $status1 = M('ShiftTask')->where(['id' => $id,'status' => 0])->save(['status' => 2]); + $status2 = M('mend', 'tab_')->where(['task_id' => $id, 'status' => 0])->save(['status' => 2, 'update_time' => time()]); + + if ($status1 && $status2) { + $model->commit(); + addOperationLog(['op_type'=>1,'key'=>$id,'op_name'=>'取消补链','url'=>U('Mend/shiftInfo',['id'=>$id]),'menu'=>'推广员-推广员管理-推广补链-取消补链']); $this->ajaxReturn(array("status"=>1,"url"=> U('lists'))); } else { $this->ajaxReturn(array("status"=>0,"url"=> U('lists'))); diff --git a/Application/Admin/View/Mend/edit.html b/Application/Admin/View/Mend/edit.html index 16f777fc6..30b5e336f 100644 --- a/Application/Admin/View/Mend/edit.html +++ b/Application/Admin/View/Mend/edit.html @@ -72,7 +72,7 @@
玩家账号 | +补链前推广账号 | +补链前归属金额 | +补链后推广账号 | +备注 | +切分时间 | +补链时间 | +状态 | +操作人员 | +
---|---|---|---|---|---|---|---|---|
+
+ 暂无数据 + |
+ ||||||||
=getHideAccount($vo['user_account'])?> | +{$vo.promote_account} | +{$vo.pay_amount} | +{$vo.promote_account_to} | +{$vo.remark} | +{$vo.order_time|date='Y-m-d H:i:s',###} | +{$vo.create_time|date='Y-m-d H:i:s',###} | +{$vo.status_text} | +{$vo.op_account} | +