//删除会员
public function delete_user(){
header("Content-Type:text/html; charset=utf-8");
$merchant_id = !empty($_GET['id'])? intval($_GET['id']) : 0;
if(empty($merchant_id)){
$this->error("参数错误", 'Merchant/user_index.html', 3);
}
$result = M('merchant_venue')->where("merchant_id='{$merchant_id}'")->find();
$venue_id=$result['venue_id'];
if(M("Merchant_user")->where("merchant_id='{$merchant_id}'")->delete()){
M("merchant")->where("mid='{$merchant_id}'")->delete();
M("merchant_order")->where("merchant_id='{$merchant_id}'")->delete();
M("merchant_img")->where("mid='{$merchant_id}'")->delete();
M("merchant_venue")->where("merchant_id='{$merchant_id}'")->delete();
M("merchant_venueservice")->where("service_venue_id='{$venue_id}'")->delete();
M("merchant_venueweek")->where("venue_id='{$venue_id}'")->delete();
// unlink("图片文件夹");
$this->success("删除成功!");
}else{
$this->error("删除失败");
}
}
如果修改了密码就发送短信,其他修改则直接保存到数据库中
public function upload_user(){
$Merchant_user = M("Merchant_user");
if(I("olde_venue_phone")==I("venue_phone")){
$mobile = !empty($_POST['venue_phone'])? trim($_POST['venue_phone']) : '';
$user_id= !empty($_POST['user_id'])? trim($_POST['user_id']) : '';
$user_count = M("Merchant_user")->where(array('user_id'=>$user_id))->select();
if(empty($user_count)){
return $this->errorReturn("ID不存在");
}
$_POST['passwd']=md5($_POST['password']);
if($_POST['password']!=""&&$_POST['passwd']!=$_POST['olde_password']){
$_POST['passwd']=md5($_POST['password']);
$_POST['company_name']=$_POST['venue_name'];
$_POST['mail']=$_POST['venue_emall'];
$_POST['address']=$_POST['venue_address'];
$_POST['user_state']=$_POST["user_mer"]['user_state'];
$add_user=$Merchant_user->save($_POST);
if($add_user!==FALSE){
$sms_code=$_POST['olde_venue_user'];
$password=$_POST['password'];
$sms_msg = '亲爱的用户,您在“UU运动”的场馆名称是:' . $sms_code .',修改密码是: ' .$password .',UU运动祝你生活愉快!';
$params = '';
$argv = array(
'name'=>'', //必填参数。用户账号
'pwd'=>'', //必填参数。(web平台:基本资料中的接口密码)
'content'=>$sms_msg,
'mobile'=>$mobile, //必填参数。手机号码。多个以英文逗号隔开
'sign'=>'UU运动', //必填参数。用户签名。
'type'=>'pt', //必填参数。固定值 pt
'extno'=>'' //可选参数,扩展码,用户定义扩展码,只能为数字
);
//构造要post的字符串
foreach ($argv as $key=>$value) {
$params.= "&" . $key . "=" . urlencode($value);
}
$url = "http://web.duanxinwang.cc/asmx/smsservice.aspx?".substr($params, 1); //提交的url地址
$con= substr( file_get_contents($url), 0, 1 ); //获取信息发送后的状态
if(!$con){
return $this->successReturn('修改会员成功,用户名密码已发送至手机内请查收!', U('Merchant/user_index'));
exit(json_encode(array('result'=>1, 'msg'=>'验证码发送成功')));
}else{
exit(json_encode(array('result'=>-2, 'msg'=>'验证码发送失败')));
}
}
else {
return $this->errorReturn('修改失败!!!');
}
//OK 解决了
}else{
//这里表示没修改密码
if($_POST['password']==''&&$_POST['passwd']!=$_POST['olde_password'])
{
unset($_POST['passwd']);//这里貌似你的逻辑有问题 等下自己去看看。
}
$_POST['mail']=$_POST['venue_emall'];
$_POST['address']=$_POST['venue_address'];
$_POST['user_state']=$_POST["user_mer"]['user_state'];
$_POST['company_name']=$_POST['venue_name'];
$add_user=$Merchant_user->save($_POST);
if($add_user!==FALSE){
$this->successReturn("修改成功!", U('Merchant/user_index'));
} else {
$this->errorReturn("修改失败!");
}
}
}
else
{
$mobile = !empty($_POST['venue_phone'])? trim($_POST['venue_phone']) : '';
$telephone = M("Merchant_user")->where(array('telephone'=>$mobile))->count();
if($user_count[0] > 0){
return $this->errorReturn('该手机号码已被注册');
}
$_POST['passwd']=md5($_POST['password']);
if($_POST['password']==''){
unset($_POST['passwd']);
}
$_POST['company_name']=$_POST['venue_name'];
$_POST['telephone']=$_POST['venue_phone'];
$_POST['mail']=$_POST['venue_emall'];
$_POST['address']=$_POST['venue_address'];
$_POST['user_state']=$_POST["user_mer"]['user_state'];
$add_user=$Merchant_user->save($_POST);
if($add_user!==FALSE){
// $this->successReturn("修改成功!!",U('Merchant/user_index'));
$sms_code=$_POST['user_name'];
$password=$_POST['password'];
$sms_msg = '亲爱的用户,您在“UU运动”的场馆名称是:' . $sms_code .',修改密码是: ' .$password .',UU运动祝你生活愉快!';
$params = '';
$argv = array(
'name'=>'heshicai', //必填参数。用户账号
'pwd'=>'051A553D3F04206FC3C77F42CC70', //必填参数。(web平台:基本资料中的接口密码)
'content'=>$sms_msg,
'mobile'=>$mobile, //必填参数。手机号码。多个以英文逗号隔开
'sign'=>'UU运动', //必填参数。用户签名。
'type'=>'pt', //必填参数。固定值 pt
'extno'=>'' //可选参数,扩展码,用户定义扩展码,只能为数字
);
//构造要post的字符串
foreach ($argv as $key=>$value) {
$params.= "&" . $key . "=" . urlencode($value);
}
$url = "http://web.duanxinwang.cc/asmx/smsservice.aspx?".substr($params, 1); //提交的url地址
$con= substr( file_get_contents($url), 0, 1 ); //获取信息发送后的状态
if(!$con){
return $this->successReturn('修改会员成功,用户名密码已发送至手机内请查收!', U('Merchant/user_index'));
exit(json_encode(array('result'=>1, 'msg'=>'验证码发送成功')));
}else{
exit(json_encode(array('result'=>-2, 'msg'=>'验证码发送失败')));
}
}else {
return $this->errorReturn('修改失败!!!');
}
}
}
新增Thinkphp
public function upload_merchant(){
$mobile = !empty($_POST['venue_phone'])? trim($_POST['venue_phone']) : '';
$user_name = !empty($_POST['user_name'])? trim($_POST['user_name']) : '';
$Merchant_user = M("Merchant_user");
$merchant=M("Merchant");
//先添加场馆记录 在根据场馆表里面的mid 生成场馆用户表的记录 merchant_id
$data['m_name']=$_POST['venue_name'];
$data['phone']=$_POST['venue_phone'];
$data['address']=$_POST['venue_address'];
$addmerchant=$merchant->add($data);
$_POST["merchant_id"] = $addmerchant;
$_POST['company_name']=$_POST['venue_name'];
$_POST['user_name']=$_POST['user_name'];
$_POST['passwd']=md5($_POST['password']);
$_POST['telephone']=$_POST['venue_phone'];
$_POST['address']=$_POST['venue_address'];
$_POST['mail']=$_POST['venue_emall'];
//添加场馆用户
$add_user=$Merchant_user->add($_POST);
if($add_user){
$sms_code=$_POST['user_name'];
$password=$_POST['password'];
$sms_msg = '亲爱的用户,您在“UU运动”的场馆名称是:' . $sms_code .',密码是: ' .$password .',UU运动祝你生活愉快!';
$params = '';
$argv = array(
'name'=>'OOXX', //必填参数。用户账号
'pwd'=>'XXOO', //必填参数。(web平台:基本资料中的接口密码)
'content'=>$sms_msg,
'mobile'=>$mobile, //必填参数。手机号码。多个以英文逗号隔开
'sign'=>'UU运动', //必填参数。用户签名。
'type'=>'pt', //必填参数。固定值 pt
'extno'=>'' //可选参数,扩展码,用户定义扩展码,只能为数字
);
//构造要post的字符串
foreach ($argv as $key=>$value) {
$params.= "&" . $key . "=" . urlencode($value);
}
$url = "http://web.duanxinwang.cc/asmx/smsservice.aspx?".substr($params, 1); //提交的url地址
$con= substr( file_get_contents($url), 0, 1 ); //获取信息发送后的状态
if(!$con){
return $this->successReturn('添加会员成功,用户名密码已发送至手机内请查收!', U('Merchant/user_index'));
exit(json_encode(array('result'=>1, 'msg'=>'验证码发送成功')));
}else{
exit(json_encode(array('result'=>-2, 'msg'=>'验证码发送失败')));
}
}else{
return $this->errorReturn('添加失败');
}
}