Example #1
0
 public function gcreate()
 {
     $public = array();
     $AgentID = $this->_POST['agentid'];
     $token = $this->_POST['_token'];
     $timemap = $this->_POST['timemap'];
     $public['AgentID'] = $AgentID;
     $public['timemap'] = $timemap;
     $AgentApiModule = new AgentApiModule();
     $AgentApiInfo = $AgentApiModule->GetOneInfoByForID($AgentID);
     if ($AgentID == '' || $token == '' || ($timemap = '' || empty($AgentApiInfo))) {
         die(jsonp(array('0', '数据提供错误'), 'JSONP'));
     }
     $type = $this->_POST['type'];
     $public['private'] = $AgentApiInfo['private'];
     $verify = $this->verify($public, $token);
     if ($verify) {
         $username = $this->_POST['username'];
         $company = $this->_POST['company'];
         $realname = $this->_POST['realname'];
         $phone = $this->_POST['phone'];
         $fax = $this->_POST['fax'];
         $email = $this->_POST['email'];
         $address = $this->_POST['address'];
         $weixinname = $this->_POST['weixinname'];
         $weixinid = $this->_POST['weixinid'];
         $weixnno = $this->_POST['weixnno'];
         $remark = $this->_POST['remark'];
         $CustomersModule = new CustomersModule();
         $CustProModule = new CustProModule();
         $where = "where CompanyName='{$company}'";
         $num = $CustomersModule->GetListsNum($where);
         if ($num['Num']) {
             $where = "CompanyName='{$company}' and AgentID={$AgentID}";
             if ($realname != '') {
                 $update['CustomersName'] = $realname;
             }
             if ($phone != '') {
                 $update['Tel'] = $phone;
             }
             if ($fax != '') {
                 $update['Fax'] = $fax;
             }
             if ($email != '') {
                 $update['Email'] = $email;
             }
             if ($address != '') {
                 $update['Addresss'] = $address;
             }
             $update['UpdateTime'] = date('Y-m-d');
             if ($CustomersModule->UpdateWhere($update, $where)) {
                 $SelectID = $CustomersModule->GetOneInfoByArrayKeys();
                 $id = $SelectID['CustomersID'];
                 $message = '已更新' . $company . '公司的信息';
                 $show = array('err' => 0, 'msg' => $message);
             } else {
                 $show = array('err' => 1001, 'msg' => '更新客户信息失败');
             }
         } else {
             if ($company == '') {
                 $show = array('err' => 1001, 'msg' => '提供一个空的公司名,无法进行处理');
             } else {
                 $insert = array('CompanyName' => $company, 'CustomersName' => $realname, 'Tel' => $phone, 'Fax' => $fax, 'Email' => $email, 'Address' => $address, 'AgentID' => $AgentID);
                 if ($CustomersModule->InsertArray($insert)) {
                     $id = mysql_insert_id();
                     $show = array('err' => 0, 'msg' => '成功添加一个新的风信客户记录');
                 } else {
                     $show = array('err' => 1001, 'msg' => '添加新的客户记录失败');
                 }
             }
         }
         if ($domain != '') {
             $gbaopen['AddTime'] = date('Y-m-d');
             $gbaopen['StartTime'] = $fengxin['AddTime'];
             $gbaopen['EndTime'] = date('Y-m-d', strtotime("{$fengxin['AddTime']} + 7 days"));
             $gbaopen['CustomersID'] = $id;
             $gbaopen['G_domain'] = $domain;
             $fengxing['G_beian'] = $isbeian;
             $fengxing['G_name'] = $username;
             $CustProModule->InsertArray();
             $show['msg'] = $show['msg'] + ',创建G宝盆账号成功';
         }
     } else {
         $show = array('err' => 1001, 'msg' => '提供信息错误,无法进行处理');
     }
     print_r($show);
     die(jsonp($show, 'JSONP'));
 }