diff --git a/backstage/application/api/controllers/api/Recharge.php b/backstage/application/api/controllers/api/Recharge.php index 811fa4d..34212be 100644 --- a/backstage/application/api/controllers/api/Recharge.php +++ b/backstage/application/api/controllers/api/Recharge.php @@ -924,6 +924,6 @@ class Recharge extends REST_Controller $fee = $this->input->post('fee'); $userInfo = $this->user; $this->load->library('Recharge_config'); - echo $this->recharge_config->rechargeRule((object)$userInfo, $userInfo->company_id, $fee, 1); + echo $this->recharge_config->rechargeRule((array)$userInfo, $userInfo->company_id, $fee, 1); } } \ No newline at end of file diff --git a/backstage/application/backstage/controllers/Recharge.php b/backstage/application/backstage/controllers/Recharge.php index c45c731..03c8abb 100644 --- a/backstage/application/backstage/controllers/Recharge.php +++ b/backstage/application/backstage/controllers/Recharge.php @@ -502,7 +502,7 @@ class Recharge extends CI_Controller if($jobInfo['account_type_id'] == 2){ // 判断是否有充值赠送 $this->load->library('Recharge_config'); - $rechargeInfo = $this->recharge_config->rechargeRule((object)$rowUser, $rowUser['company_id'], floatval($detail['jf']), 2); + $rechargeInfo = $this->recharge_config->rechargeRule($rowUser, $rowUser['company_id'], floatval($detail['jf']), 2); $rechargeInfo = json_decode($rechargeInfo, 1); if($rechargeInfo['status'] == 1) { $giveFee = $rechargeInfo['data']['gift_fee']; @@ -1082,7 +1082,7 @@ class Recharge extends CI_Controller //send_sms_p($smsList); // 获取充值在赠送金额 $this->load->library('Recharge_config'); - $rechargeInfo = $this->recharge_config->rechargeRule((object)$userInfo, $userInfo['company_id'], $count, 2); + $rechargeInfo = $this->recharge_config->rechargeRule($userInfo, $userInfo['company_id'], $count, 2); $rechargeInfo = json_decode($rechargeInfo, 1); if($rechargeInfo['status'] == 1){ $giveFee = $rechargeInfo['data']['gift_fee']; @@ -1414,20 +1414,22 @@ class Recharge extends CI_Controller $paramFilter = array('name'); $data = $this->lw_pagination2->lists($sql,$param,$page,$hasWhere,$group,$order,$action,$dataName,$paramFilter); - foreach ($data['dataList'] as $k => $v){ - if($v['user_type_id'] == '*'){ - $data['dataList'][$k]['user_type_id'] = "全部"; - }else{ - $user_type_id = explode(',', $v['user_type_id']); - // 去重 - $user_type_id = array_unique($user_type_id); - $user_type_ids = join(",", $user_type_id); - $user_type_list = $this->user_model->get_user_type_by_ids($user_type_ids); - $user_type_name = array_column($user_type_list, 'name'); - $data['dataList'][$k]['user_type_id'] = join(',', $user_type_name); + if(empty($data['dataList'])){ + foreach ($data['dataList'] as $k => $v){ + if($v['user_type_id'] == '*'){ + $data['dataList'][$k]['user_type_id'] = "全部"; + }else{ + $user_type_id = explode(',', $v['user_type_id']); + // 去重 + $user_type_id = array_unique($user_type_id); + $user_type_ids = join(",", $user_type_id); + $user_type_list = $this->user_model->get_user_type_by_ids($user_type_ids); + $user_type_name = array_column($user_type_list, 'name'); + $data['dataList'][$k]['user_type_id'] = join(',', $user_type_name); + } + $data['dataList'][$k]['effective_type'] = $v['effective_type'] == 1 ? "app充值" : "后台充值"; + $data['dataList'][$k]['gift_type'] = $v['gift_type'] == 1 ? "每年" : "每次"; } - $data['dataList'][$k]['effective_type'] = $v['effective_type'] == 1 ? "app充值" : "后台充值"; - $data['dataList'][$k]['gift_type'] = $v['gift_type'] == 1 ? "每年" : "每次"; } echo $this->load->view('recharge/config/list',$data,true); } diff --git a/backstage/system/libraries/Recharge_config.php b/backstage/system/libraries/Recharge_config.php index e5f0850..a2aefc1 100644 --- a/backstage/system/libraries/Recharge_config.php +++ b/backstage/system/libraries/Recharge_config.php @@ -17,6 +17,7 @@ class CI_Recharge_config { * @return void */ public function rechargeRule($userInfo, $companyId, $fee, $effective_type=1){ + $userInfo = (array)$userInfo; $gift_fee = 0; // 把金额转换为分 @@ -42,14 +43,14 @@ class CI_Recharge_config { if($pz) { foreach ($pz as $k => $v) { $user_type_id = explode(',', $v['user_type_id']); - if ($v['user_type_id'] != '*' || (!in_array($userInfo->type_id, $user_type_id) && !in_array('*', $user_type_id))) { + if ($v['user_type_id'] != '*' || (!in_array($userInfo['type_id'], $user_type_id) && !in_array('*', $user_type_id))) { // 如果规则不含有用户类型 && 不含有*,则跳过 continue; } if($v['gift_type'] == 1){ // 每年赠送 // 获取今年的充值次数 - $year_count = $this->get_recharge_count($userInfo->id, $v['gift_type']); + $year_count = $this->get_recharge_count($userInfo['id'], $v['gift_type']); if($year_count != 0){ $year_count = $year_count+1; @@ -65,7 +66,7 @@ class CI_Recharge_config { continue; } }else{ - $count = $this->get_recharge_count($userInfo->id, $v['gift_type']); + $count = $this->get_recharge_count($userInfo['id'], $v['gift_type']); if($count != 0){ $count = $count+1; }