123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
- class merchant_infoControl extends merchant_baseControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $model_merchant = Model('merchant');
- $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']],'mchid,name,alarm_amount,ip_white_list');
- $model_member = Model('member');
- $member_info = $model_member->getMemberInfo(
- array(
- 'member_id' => $merchant_info['admin_id']
- ),
- 'available_predeposit'
- );
- $merchant_info['member'] = $member_info;
- if(empty($merchant_info['ip_white_list'])){
- $merchant_info['ips'] = [];
- }else{
- $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
- }
- return self::outsuccess($merchant_info);
- }
- public function addipOp()
- {
- $ip = $_POST['ip'];
- if (empty($ip)){
- return self::outerr(errcode::ErrParamter , "参数错误" );
- }
- $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['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(){
- $ip = $_POST['ip'];
- if (empty($ip)){
- return self::outerr(errcode::ErrParamter , "参数错误" );
- }
- $ip = trim($ip);
- $model_merchant = Model('merchant');
- $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(){
- $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['mch_id']));
- if($ret){
- return self::outsuccess([]);
- }else{
- return self::outerr(errcode::ErrOperation, "系统错误.");
- }
- }
- public function modifypwOp()
- {
- $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['mch_id']));
- if(!$merchant_info){
- return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
- }
- $pwd = trim($new_pw);
- if(md5($pwd) == $merchant_info['password']){
- return self::outsuccess([]);
- }
- $ret = $model_merchant->editMerchant(array('password'=>md5($pwd)), array('mchid' => $merchant_info['mchid']));
- if($ret){
- return self::outsuccess([]);
- }else{
- return self::outerr(errcode::ErrOperation, "系统错误.");
- }
- }
- public function pdlogOp(){
- $model_pd = Model('merchant');
- $condition = array();
- $condition['lg_member_id'] = $_SESSION['member_id'];
- if ($_GET['lg_type'] != '')
- {
- $condition['lg_type'] = $_GET['lg_type'];
- }
- if($_GET['start_time'] && $_GET['end_time']){
- $condition['lg_add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
- }
- $list = $model_pd->getPdlog($condition,$this->page,'*','lg_id desc',10);
- $result['data'] = $list;
- $result['total'] = $model_pd->gettotalpage();
- return self::outsuccess($result);
- }
- }
|