|
- <?php
- header("Access-Control-Allow-Origin:*");
- $post = $_POST;
- $time = date("Y-m-d H:i:s",time());
- if($post['user_type'] == 0){
-
- $post['channel_id'] = empty($post['channel_id'])?0:$post['channel_id'];
- $post['teamwork'] = empty($post['teamwork'])?0:$post['teamwork'];
- if(!empty($post['channel_name']) && !empty($post['linkman']) && !empty($post['com_tel']) && !empty($post['channel_admin'])){
- $sql = "insert into base_customer(CHAN_QUALITY,ORG_ID,CHAN_NAME,CHAN_SHORT,CHAN_TYPE,AREA_ID,LINKMAN,LINK_TEL,RESMAN,SELA_TYPE,STATUS,CHAN_AGREEMENT,USER_TYPE,CREATE_TIME)
- values(2,0,'$post[channel_name]','$post[teamwork]',$post[saleStyle],$post[cantonal],'$post[linkman]',$post[com_tel],'$post[channel_admin]','$post[saleStyle_company]',0,$post[channel_id],0,'$time')";
- $result = $pdo ->exec($sql);
- if($result){
- $sql = "select CUST_ID from base_customer where CREATE_TIME = '$time'";
- $result=$pdo->query($sql);
- if($result){
- $arr = $result->fetchAll(PDO::FETCH_ASSOC);
-
- $cust_id = $arr[0]['CUST_ID'];
-
- $password = md5("Zzcx8888");
- $sql = "insert into base_user(USER_PASSWORD,CREATE_TIME,STATUS)
- values('$password','$time',1)";
-
- $result = $pdo ->exec($sql);
- if($result){
- $sql = "select ID from base_user where CREATE_TIME = '$time'";
- $result=$pdo->query($sql);
- if($result){
- $arr = $result->fetchAll(PDO::FETCH_ASSOC);
- $id = $arr[0]['ID'];
- $sql = "update base_customer set USER_ID = $id where CUST_ID = $cust_id";
- $result=$pdo->exec($sql);
- if($result){
- $code = 0;
- $info = 'success';
- $massge = '成功';
- $list = array('cust_id' => $cust_id,'user_id' => $id);
- }else{
- $code = -6;
- $info = 'fail';
- $massge = '失败';
- $list = '';
- }
- }else{
- $code = -7;
- $info = 'fail';
- $massge = '失败';
- $list = '';
- }
- }else{
- $code = -8;
- $info = 'fail';
- $massge = '失败';
- $list = '4';
- }
-
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list = '3';
- }
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list =$sql;
- }
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list = '1';
- }
-
- }else{
- if(!empty($post['agency_name']) && !empty($post['linkman_id']) && !empty($post['tel_personal']) && !empty($post['principal_personal'])){
- $post['com_name'] = empty($post['com_name'])?0:$post['com_name'];
- $sql = "insert into base_customer(CHAN_QUALITY,ORG_ID,CHAN_NAME,CHAN_TYPE,AREA_ID,LINKMAN,LINK_TEL,RESMAN,SELA_TYPE,STATUS,ID_CARD,COM_NAME,USER_TYPE,CREATE_TIME)
- values(0,0,'$post[agency_name]',$post[saleStyle_personal],$post[cantonal],'$post[agency_name]',$post[tel_personal],'$post[principal_personal]',$post[saleStyle_personal_channel],0,$post[linkman_id],'$post[com_name]',1,'$time')";
- $result = $pdo ->exec($sql);
- if($result){
- $sql = "select CUST_ID from base_customer where CREATE_TIME = '$time'";
- $result=$pdo->query($sql);
- if($result){
- $arr = $result->fetchAll(PDO::FETCH_ASSOC);
- $cust_id = $arr[0]['CUST_ID'];
-
- $password = md5("Zzcx8888");
- $sql = "insert into base_user(USER_PASSWORD,CREATE_TIME,STATUS)
- values('$password','$time',1)";
-
- $result = $pdo ->exec($sql);
- if($result){
- $sql = "select ID from base_user where CREATE_TIME = '$time'";
- $result=$pdo->query($sql);
- if($result){
- $arr = $result->fetchAll(PDO::FETCH_ASSOC);
- $id = $arr[0]['ID'];
- $sql = "update base_customer set USER_ID = $id where CUST_ID = $cust_id";
- $result=$pdo->exec($sql);
- if($result){
- $code = 0;
- $info = 'success';
- $massge = '成功';
- $list = array('cust_id' => $cust_id,'user_id' => $id);
- }else{
- $code = -6;
- $info = 'fail';
- $massge = '失败';
- $list = '6';
- }
- }else{
- $code = -7;
- $info = 'fail';
- $massge = '失败';
- $list = '5';
- }
- }else{
- $code = -8;
- $info = 'fail';
- $massge = '失败';
- $list = '4';
- }
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list = '3';
- }
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list = '';
- }
- }else{
- $code = -1;
- $info = 'fail';
- $massge = '失败';
- $list = '1';
- }
- }
-
- $json['code'] = $code;
- $json['info'] = $info;
- $json['massge'] = $massge;
- $json['list'] = $list;
-
- echo json_encode($json);
-
- ?>
|