merchant_info.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
  3. class merchant_infoControl extends merchant_baseControl
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. }
  9. public function indexOp()
  10. {
  11. $model_merchant = Model('merchant');
  12. $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']],'mchid,name,alarm_amount,ip_white_list');
  13. $model_member = Model('member');
  14. $member_info = $model_member->getMemberInfo(
  15. array(
  16. 'member_id' => $merchant_info['admin_id']
  17. ),
  18. 'available_predeposit'
  19. );
  20. $merchant_info['member'] = $member_info;
  21. if(empty($merchant_info['ip_white_list'])){
  22. $merchant_info['ips'] = [];
  23. }else{
  24. $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
  25. }
  26. return self::outsuccess($merchant_info);
  27. }
  28. public function addipOp()
  29. {
  30. $ip = $_POST['ip'];
  31. if (empty($ip)){
  32. return self::outerr(errcode::ErrParamter , "参数错误" );
  33. }
  34. $ip = trim($ip);
  35. if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
  36. $model_merchant = Model('merchant');
  37. $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
  38. $ips = unserialize($merchant_info['ip_white_list']);
  39. $ips[] = $ip;
  40. $ips = array_unique($ips);
  41. $model_merchant->editMerchant(array('ip_white_list'=>serialize($ips)), array('mchid' => $merchant_info['mchid']));
  42. return self::outsuccess([]);
  43. }
  44. else {
  45. return self::outerr(errcode::ErrParamter , "ip地址错误" );
  46. }
  47. }
  48. public function ipdelOp(){
  49. $ip = $_POST['ip'];
  50. if (empty($ip)){
  51. return self::outerr(errcode::ErrParamter , "参数错误" );
  52. }
  53. $ip = trim($ip);
  54. $model_merchant = Model('merchant');
  55. $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
  56. $ips = unserialize($merchant_info['ip_white_list']);
  57. $new_ips = [];
  58. foreach ($ips as $value){
  59. if($value != $ip){
  60. $new_ips[] = $value;
  61. }
  62. }
  63. $model_merchant->editMerchant(array('ip_white_list'=>serialize($new_ips)), array('mchid' => $merchant_info['mchid']));
  64. return self::outsuccess([]);
  65. }
  66. public function setkeyOp(){
  67. $secure_key = $_POST['secure_key'];
  68. if (empty($_POST['secure_key'])){
  69. return self::outerr(errcode::ErrParamter , "参数错误" );
  70. }
  71. $model_merchant = Model('merchant');
  72. $ret = $model_merchant->editMerchant(array('secure_key'=>$_POST['secure_key']), array('mchid' => $_SESSION['mch_id']));
  73. if($ret){
  74. return self::outsuccess([]);
  75. }else{
  76. return self::outerr(errcode::ErrOperation, "系统错误.");
  77. }
  78. }
  79. public function modifypwOp()
  80. {
  81. $new_pw = $_POST['new_pw'];
  82. $new_pw2 = $_POST['new_pw2'];
  83. if (trim($new_pw) !== trim($new_pw2)){
  84. return self::outerr(errcode::ErrPasswd , "密码错误" );
  85. }
  86. $model_merchant = Model('merchant');
  87. $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
  88. if(!$merchant_info){
  89. return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
  90. }
  91. $pwd = trim($new_pw);
  92. if(md5($pwd) == $merchant_info['password']){
  93. return self::outsuccess([]);
  94. }
  95. $ret = $model_merchant->editMerchant(array('password'=>md5($pwd)), array('mchid' => $merchant_info['mchid']));
  96. if($ret){
  97. return self::outsuccess([]);
  98. }else{
  99. return self::outerr(errcode::ErrOperation, "系统错误.");
  100. }
  101. }
  102. public function pdlogOp(){
  103. $model_pd = Model('merchant');
  104. $condition = array();
  105. $condition['lg_member_id'] = $_SESSION['member_id'];
  106. if ($_GET['lg_type'] != '')
  107. {
  108. $condition['lg_type'] = $_GET['lg_type'];
  109. }
  110. if($_GET['start_time'] && $_GET['end_time']){
  111. $condition['lg_add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
  112. }
  113. $list = $model_pd->getPdlog($condition,$this->page,'*','lg_id desc',10);
  114. $result['data'] = $list;
  115. $result['total'] = $model_pd->gettotalpage();
  116. return self::outsuccess($result);
  117. }
  118. }