|
@@ -11,7 +11,7 @@ class merchant_infoControl extends merchant_baseControl
|
|
|
public function indexOp()
|
|
|
{
|
|
|
$model_merchant = Model('merchant');
|
|
|
- $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']),'mchid,name,ip_white_list');
|
|
|
$model_member = Model('member');
|
|
|
$member_info = $model_member->getMemberInfo(
|
|
|
array(
|
|
@@ -20,64 +20,55 @@ class merchant_infoControl extends merchant_baseControl
|
|
|
'available_predeposit'
|
|
|
);
|
|
|
$merchant_info['member'] = $member_info;
|
|
|
+ $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
|
|
|
return self::outsuccess($merchant_info);
|
|
|
}
|
|
|
|
|
|
- public function ipwhitelistOp()
|
|
|
- {
|
|
|
- $model_merchant = Model('merchant');
|
|
|
- $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
- $ipwhitelist = unserialize($merchant_info['ip_white_list']);
|
|
|
- return self::outsuccess($this->arrayTransitionObject($ipwhitelist));
|
|
|
- }
|
|
|
-
|
|
|
public function addipOp()
|
|
|
{
|
|
|
- if (!isset($_POST['ip'])){
|
|
|
+ $ip = $_POST['ip'];
|
|
|
+ if (empty($ip)){
|
|
|
return self::outerr(errcode::ErrParamter , "参数错误" );
|
|
|
}
|
|
|
- if(filter_var($_POST['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
|
|
|
- {
|
|
|
+ $ip = trim($ip);
|
|
|
+ if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
|
|
$model_merchant = Model('merchant');
|
|
|
- $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
- $ipwhitelist = unserialize($merchant_info['ip_white_list']);
|
|
|
- $ipwhitelist[] = $_POST['ip'];
|
|
|
- $ret = $model_merchant->editMerchant(array('ip_white_list'=>serialize($ipwhitelist)), array('mchid' => $merchant_info['mchid']));
|
|
|
- if($ret){
|
|
|
- return self::outsuccess([]);
|
|
|
- }else{
|
|
|
- return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
- }
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
|
|
|
+ $ips = unserialize($merchant_info['ip_white_list']);
|
|
|
+ $ips[] = $ip;
|
|
|
+ $ips = array_unique($ips);
|
|
|
+ $model_merchant->editMerchant(array('ip_white_list'=>serialize($ips)), array('mchid' => $merchant_info['mchid']));
|
|
|
+ return self::outsuccess([]);
|
|
|
}
|
|
|
else {
|
|
|
return self::outerr(errcode::ErrParamter , "ip地址错误" );
|
|
|
}
|
|
|
}
|
|
|
public function ipdelOp(){
|
|
|
- if (!isset($_POST['ip_key'])){
|
|
|
+ $ip = $_POST['ip'];
|
|
|
+ if (empty($ip_key)){
|
|
|
return self::outerr(errcode::ErrParamter , "参数错误" );
|
|
|
}
|
|
|
+ $ip = trim($ip);
|
|
|
$model_merchant = Model('merchant');
|
|
|
- $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
- $ipwhitelist = unserialize($merchant_info['ip_white_list']);
|
|
|
- unset($ipwhitelist[$_POST['ip_key']]);
|
|
|
- foreach ($ipwhitelist as $key =>$value){
|
|
|
- $new_ip_list[] = $value;
|
|
|
- }
|
|
|
- $ipwhitelist = serialize($new_ip_list);
|
|
|
- $ret = $model_merchant->editMerchant(array('ip_white_list'=>$ipwhitelist), array('mchid' => $merchant_info['mchid']));
|
|
|
- if($ret){
|
|
|
- return self::outsuccess([]);
|
|
|
- }else{
|
|
|
- return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
|
|
|
+ $ips = unserialize($merchant_info['ip_white_list']);
|
|
|
+ $new_ips = [];
|
|
|
+ foreach ($ips as $value){
|
|
|
+ if($value != $ip){
|
|
|
+ $new_ips[] = $value;
|
|
|
+ }
|
|
|
}
|
|
|
+ $model_merchant->editMerchant(array('ip_white_list'=>serialize($new_ips)), array('mchid' => $merchant_info['mchid']));
|
|
|
+ return self::outsuccess([]);
|
|
|
}
|
|
|
public function setkeyOp(){
|
|
|
- if (!isset($_POST['secure_key'])){
|
|
|
+ $secure_key = $_POST['secure_key'];
|
|
|
+ if (empty($_POST['secure_key'])){
|
|
|
return self::outerr(errcode::ErrParamter , "参数错误" );
|
|
|
}
|
|
|
$model_merchant = Model('merchant');
|
|
|
- $ret = $model_merchant->editMerchant(array('secure_key'=>$_POST['secure_key']), array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
+ $ret = $model_merchant->editMerchant(array('secure_key'=>$_POST['secure_key']), array('mchid' => $_SESSION['mch_id']));
|
|
|
if($ret){
|
|
|
return self::outsuccess([]);
|
|
|
}else{
|
|
@@ -86,15 +77,17 @@ class merchant_infoControl extends merchant_baseControl
|
|
|
}
|
|
|
public function modifypwOp()
|
|
|
{
|
|
|
- if (trim($_POST['new_pw']) !== trim($_POST['new_pw2'])){
|
|
|
+ $new_pw = $_POST['new_pw'];
|
|
|
+ $new_pw2 = $_POST['new_pw2'];
|
|
|
+ if (trim($new_pw) !== trim($new_pw2)){
|
|
|
return self::outerr(errcode::ErrPasswd , "密码错误" );
|
|
|
}
|
|
|
$model_merchant = Model('merchant');
|
|
|
- $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['merchant_login_id']));
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
|
|
|
if(!$merchant_info){
|
|
|
return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
|
}
|
|
|
- $pwd = trim($_POST['new_pw']);
|
|
|
+ $pwd = trim($new_pw);
|
|
|
if(md5($pwd) == $merchant_info['password']){
|
|
|
return self::outsuccess([]);
|
|
|
}
|
|
@@ -121,15 +114,4 @@ class merchant_infoControl extends merchant_baseControl
|
|
|
$result['total'] = $model_pd->gettotalpage();
|
|
|
return self::outsuccess($result);
|
|
|
}
|
|
|
-
|
|
|
- protected function arrayTransitionObject(Array $array)
|
|
|
- {
|
|
|
- $data = [];
|
|
|
- foreach ($array as $key => $val) {
|
|
|
- $obj = new class{};
|
|
|
- $obj->ip = $val;
|
|
|
- $data[] = $obj;
|
|
|
- }
|
|
|
- return $data;
|
|
|
- }
|
|
|
}
|