Authored by yangyang

增加Home文件夹(改大写)

  1 +<?php
  2 +
  3 +namespace home;
  4 +
  5 +use LibModels\Wap\Home\GradeData;
  6 +use Action\AbstractAction;
  7 +use Plugin\Helpers;
  8 +
  9 +/**
  10 + * 会员等级相关数据处理
  11 + */
  12 +class GradeModel
  13 +{
  14 + /*
  15 + * 获取个人中心-会员等级数据
  16 + */
  17 +
  18 + public function getGrade($gender, $channel, $uid) {
  19 + $result = array();
  20 +
  21 + if (USE_CACHE) {
  22 + // 先尝试获取一级缓存(master), 有数据则直接返回.
  23 + $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'master');
  24 + if (!empty($result)) {
  25 + return $result;
  26 + }
  27 + }
  28 + //调用接口获取数据
  29 + $data = GradeData::getGradeData($gender,$channel, $uid);
  30 + switch (intval($data['grade']['current_vip_level'])) {
  31 + case 0://普通会员
  32 + $result['vipGrade']['vip0'] = true;
  33 + break;
  34 + case 1://银卡会员
  35 + $result['vipGrade']['vip1'] = true;
  36 + break;
  37 + case 2://金卡会员
  38 + $result['vipGrade']['vip2'] = true;
  39 + break;
  40 + case 3://白金会员
  41 + $result['vipGrade']['vip3'] = true;
  42 + break;
  43 + }
  44 +
  45 + //今年总消费
  46 + $result['vipGrade']['costOfThisYear'] = $data['grade']['current_year_cost'];
  47 + //升级下一等级会员的进度;
  48 + $result['vipGrade']['percent'] = 100*(round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2));
  49 + //距离升级所需消费金额
  50 +
  51 + if ($data['grade']['current_vip_level'] != 3) {
  52 + $result['vipGrade']['costGap'] = $data['grade']['upgrade_need_cost'];
  53 + }
  54 + //消费总计
  55 + $result['vipGrade']['sumCost'] = $data['grade']['current_total_cost'];
  56 + //username 调用获取用户基本信息数据,获得username;
  57 + //$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
  58 + $result['vipGrade']['name'] = $data['userProfile']['username'];
  59 + //跳转url(会员特权详情)
  60 + $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null);
  61 + //当前vip等级享受的特权
  62 + $result['vipGrade']['privilege'] = $data['grade']['enjoy_preferential'];
  63 +
  64 +
  65 + if (USE_CACHE) {
  66 + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
  67 + if (empty($result)) {
  68 + $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave');
  69 + }
  70 + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
  71 + else {
  72 + Cache::set(CacheConfig::KEY_ACTION_HOME_GRADE, $result);
  73 + }
  74 + }
  75 +
  76 + return $result;
  77 + }
  78 +
  79 + /*
  80 + * 获取个人中心-会员特权详情页
  81 + */
  82 +
  83 + public function getPreferential($channel, $uid) {
  84 + $result = array();
  85 +
  86 + if (USE_CACHE) {
  87 + // 先尝试获取一级缓存(master), 有数据则直接返回.
  88 + $result = Cache::get(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, 'master');
  89 + if (!empty($result)) {
  90 + return $result;
  91 + }
  92 + }
  93 + //调取接口获得数据
  94 + $data = GradeData::getPreferentialData($channel, $uid);
  95 + if (isset($data['code']) && $data['code'] == 200) {
  96 + $result['vipGrade']['privilege'] = $data['data'];
  97 + }
  98 +
  99 +
  100 + if (USE_CACHE) {
  101 + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
  102 + if (empty($result)) {
  103 + $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave');
  104 + }
  105 + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
  106 + else {
  107 + Cache::set(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, $result);
  108 + }
  109 + }
  110 +
  111 + return $result;
  112 + }
  113 +
  114 +}
  1 +<?php
  2 +
  3 + namespace home;
  4 +
  5 + use LibModels\Wap\Home\OrderData;
  6 +/*
  7 + * To change this license header, choose License Headers in Project Properties.
  8 + * To change this template file, choose Tools | Templates
  9 + * and open the template in the editor.
  10 + */
  11 +
  12 +/**
  13 + * Description of Order
  14 + *
  15 + */
  16 +class OrderModel
  17 +{
  18 +
  19 + /**
  20 + * 订单相关数据处理
  21 + */
  22 + public function getOrder($type = 1,$page = 1,$limit,$gender,$yh_channel,$uid){
  23 +
  24 + $data = OrderData::getOrderData($type,$page,$limit,$gender,$yh_channel,$uid);
  25 +
  26 + return $data;
  27 + }
  28 +
  29 +}