diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 89d8bdefa..50ceddccc 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -249,6 +249,8 @@ class PromoteCompanyController extends ThinkController if (empty($data)) { $this->error('数据异常', U('lists')); } + $data['contact_begin']=date("Y-m-d",$data['contact_begin']); + $data['contact_end']=date("Y-m-d",$data['contact_end']); $this->assign('data', $data); $this->display(); } @@ -260,80 +262,29 @@ class PromoteCompanyController extends ThinkController $model = M($this->modelName, 'tab_'); if ($_POST) { - $company_name = I('post.company_name', ''); - $status = intval(I('post.status', 1)); - $id = intval(I('post.id', 0)); - - if (empty($company_name)) { - $this->error('请输入推广公司名称'); - } - if (empty(I('post.settlement_contact'))) { - $this->error('请输入结算联系人'); - } - if (empty(I('post.contact_phone'))) { - $this->error('请输入联系人电话'); - } - $pattern = "/^1[3|4|5|6|7|8|9]\\d{9}$/i";//手机号验证修改 - if(!preg_match($pattern, I('post.contact_phone'))) { - $this->error("手机号码格式不合法"); - return false; - } - if (empty(I('post.address'))) { - $this->error('请输入所在地址'); - } - if (empty(I('post.bank_card'))) { - $this->error('请输入银行卡号'); - } - $bank_card_pattern = "/^\d{10,19}$/u"; - if (!preg_match($bank_card_pattern, I('post.bank_card'))) { - $this->error('卡号格式错误'); - return false; - } - if (empty(I('post.bank_cardname'))) { - $this->error('请输入银行卡名'); - } - if (empty(I('post.bank_name'))) { - $this->error('请输入收款银行'); - } - if (empty(I('post.bank_address'))) { - $this->error('请输入开户网点'); - } - if (!in_array($status, [0, 1]) || $id == 0) { - $this->error('参数异常'); - } - if (!empty(I('post.content'))) { - $save['content'] = I('post.content'); - } - $data = $model->field('id,company_name')->find($id); - if (empty($data)) { - $this->error('数据异常'); - } - - $map['company_name'] = $company_name; - $res = $model->where($map)->getField('id'); - if ($res && $res != $id) { - $this->error('推广公司已存在'); - } - $time = time(); - $save['id'] = $id; - $save['company_name'] = $company_name; - $save['status'] = $status; + $save = I('post.');//前端已经验证 + $save['create_time'] = $time; $save['last_up_time'] = $time; - $save['settlement_contact'] = I('post.settlement_contact'); - $save['contact_phone'] = I('post.contact_phone'); - $save['address'] = I('post.address'); - $save['bank_card'] = I('post.bank_card'); - $save['bank_cardname'] = I('post.bank_cardname'); - $save['bank_name'] = I('post.bank_name'); - $save['bank_address'] = I('post.bank_address'); - + $save['contact_begin']=strtotime($save['contact_begin']); + $save['contact_end']=strtotime($save['contact_end']); + + if(isset($save['resources'])){ + $save['resources'] = json_encode($save['resources'],JSON_UNESCAPED_UNICODE); + } $res = $model->save($save); - if ($res === false) { - $this->error('保存失败'); + if ($res) { + \Think\Log::actionLog('PromoteCompany/edit', 'partner', $res); + $array=array( + "info"=>"修改成功", + "status"=>1 + ); + $this->ajaxReturn($array); } else { - \Think\Log::actionLog('PromoteCompany/edit', 'PromoteCompany', $id); - $this->success('保存成功', U('lists')); + $this->ajaxReturn(array( + 'status' => 0, + 'info' => "修改失败" + )); } } else { $id = $_REQUEST['id'] ?: 0; @@ -342,6 +293,9 @@ class PromoteCompanyController extends ThinkController if (empty($data)) { $this->error('数据异常', U('lists')); } + $data['contact_begin']=date("Y-m-d",$data['contact_begin']); + $data['contact_end']=date("Y-m-d",$data['contact_end']); + $this->assign('data', $data); $this->display(); } @@ -402,15 +356,30 @@ class PromoteCompanyController extends ThinkController public function delFile() { $id = $_REQUEST['id']; - $index = $_REQUEST['index'] ?: false; $file_path = $_REQUEST['file_path'] ?: false; + unlink("./".$file_path); if($id == 0){ - //未存入数据库,不用管 - unlink("./".$file_path); $this->ajaxReturn(array( 'status' => 1, 'info' => "删除成功" )); + }else{ + //需要修改 + $array = array( + "resources"=>json_encode($_REQUEST['resources'],JSON_UNESCAPED_UNICODE) + ); + $res = M($this->modelName, 'tab_')->where("id='{$id}'")->save($array); + if($res === false){ + $this->ajaxReturn(array( + 'status' => 0, + 'info' => "删除保存失败" + )); + }else{ + $this->ajaxReturn(array( + 'status' => 1, + 'info' => "删除成功" + )); + } } # code... } diff --git a/Application/Admin/View/PromoteCompany/edit.html b/Application/Admin/View/PromoteCompany/edit.html index 7a3b0e042..015297b55 100644 --- a/Application/Admin/View/PromoteCompany/edit.html +++ b/Application/Admin/View/PromoteCompany/edit.html @@ -37,7 +37,7 @@