1、问题描述:

2、E:\html\pim\php_aspire-mcloud\module\pim\controller\Configure.class.php

    public function popupGetAction( $params )
{
$keys = array(
self::KEY_CLIENT_ID,
self::KEY_SESSION,
self::KEY_VERSION,
self::KEY_DEVICE_ID,
self::KEY_FROM
);
parent::checkBaseParam($params, $keys); $params->useEnv = '1'; //是否区分环境
$params->type = 'activity_popup_config'; //相对于pms yellowPage.php 里面popupConfig方法
$return = Service_Configure::getConfigureByType($params); $user = Util_User::getInstance();
$mobile = $user->getMobile(); $authHelper = new Auth_Helper();
$authHelper->{Auth_Helper::KEY_MOBILE} = $mobile;
$returns = $authHelper->operatorGet();
$provinceId = $returns['data']['provCode'];
$cityId = $returns['data']['regionCode'];
$operator = $returns['data']['operator']; //安卓版本限制
if (isset($return['android_version']) && $return['android_version']) {
if ($params->{self::KEY_CLIENT_ID} == '4') {
$allow_android_version_arr = explode(',', $return['android_version']);
if (!in_array($params->{self::KEY_VERSION}, $allow_android_version_arr)) {
return array();
}
}
} //ios版本限制
if (isset($return['ios_version']) && $return['ios_version']) {
if ($params->{self::KEY_CLIENT_ID} == '1') {
$allow_ios_version_arr = explode(',', $return['ios_version']);
if (!in_array($params->{self::KEY_VERSION}, $allow_ios_version_arr)) {
return array();
}
}
} //运营商限制
if (isset($return['operator']) && !empty($return['operator']) && !in_array($operator, $return['operator'])) {
return array();
} //地市限制
if (isset($return['region']) && !empty($return['region'])) {
$sign = false;
foreach ($return['region'] as $region) {
if ($region[0] == "" || ($region[0] == $provinceId && ($region[1] == "" || $region[1] == $cityId))) {
$sign = true;
break;
}
}
if ($sign == false) {
return array();
}
} if ($return['switchValue'] == 1) { //无弹框
return array();
} elseif ($return['switchValue'] == 2) { //微力活动弹框
$param = array('mobi' => $mobile); if (isset($return['whost']) && $return['whost']) {
$url = $return['whost'];
} else {
$_conf = Rpc_Context::getConfig();
$config = include ($_conf['config_path'] . 'wxactivity.config.php');
$host = $config['hosts'][APPLICATION_ENV];
$url = rtrim($host, '/').'/open/txl_api/multi_call_popup';
} $h = new Util_Curl($url); $r = $h->httpPost($param, false, array('content-type:application/x-www-form-urlencoded'))->getResponse(); $result = json_decode($r, true); if (isset($result['code']) && $result['code'] == 0) {
return array(
'id' => strval($result['data']['id']),
'title' => $result['data']['title'],
'content' => $result['data']['content'],
'link' => $result['data']['button_url'],
'text' => $result['data']['button_name'],
);
} else {
return array();
}
} else { //自定义弹框
return $return['defineActivityInfo'];
}
}

适配服务请求pms平台

E:\html\pim\php_aspire-mcloud\configure\officialdb.config.php

<?php
return array(
'hosts' => array(
'development' => 'http://pms.svn.com',//本地svn环境
'qa' => 'http://pms.qa.cytxl.com.cn',//10.9.20.65 pms.qa.cytxl.com.cn
'test' => 'http://pms.cytxl.com.cn', //192.168.19.32 pms.cytxl.com.cn
'production' => 'http://pms.cytxl.com.cn' //172.16.79.10 pms.cytxl.com.cn
),
'appkey' => '470004',
);
mysql --default-character-set=utf8 -utxl_pms_user -h192.168.2.116 -ppms#@139com! -P3307 -D txl_pms
mysql> select content from config where type = 'activity_popup_config_plus';
{"switchValue":"2","defineActivityInfo":{"id":"haha","title":"\u5f55\u54e5\u6709\u793c\u8fd9\u662f\u4e0d\u80fd\u4e2d\u5956\u7684\u94fe\u63a5\u7eaf\u6d4b\u5f39\u7a97","content":"\u606d\u559c\u5c0f\u4e3b\u83b7\u5f97300\u5206\u949f\u591a\u65b9\u7535\u8bdd~ \u798f\u5229\u5df2\u53d1\u51fa~","link":"http:\/\/1.activity.cytxl.com.cn\/static\/html\/super_lottery\/h5\/multi_call\/index.html?super_lottery_id=48","text":"\u731b\u6233\u9886\u53d6"},"whost":"","android_version":"","ios_version":"","operator":["CM","CT","CU"],"region":[["",""]]}

适配服务请求微力平台

E:\html\pim\php_aspire-mcloud\configure\wxactivity.config.php

<?php
/**
* 微力活动 配置参数
*/
return array(
'hosts' => array(
'development' => 'http://1.activity.cytxl.com.cn',
'qa' => 'http://1.activity.cytxl.com.cn',
'test' => 'https://activity1.cytxl.com.cn',
'production' => 'https://activity.cytxl.com.cn'
),
);

E:\html\pim\php_weili_activities\application\controllers\open\txl_api.php

    public function multi_call_popup(){
$mobi = $this->input->post('mobi'); $multi_call = $this->super_lottery_model->get_multi_call();
if (!$multi_call){
return $this->send_json(false,'查无活动信息或不在活动时间内');
} $limit_goal_arr = array(
'super_lottery_id'=>$multi_call->id,
'prize_type !='=>SPLT_PRIZE_TYPE_THANKS,
'mobi' => $mobi,
); $goal_counts = $this->super_lottery_result_model->count('',$limit_goal_arr);
if ($goal_counts > 0) { //已中奖
return $this->send_json(false,'用户已中奖!');
} $ret = array(
'id' => strval($multi_call->id),
'title' => $multi_call->pop_up_title,
'point'=>'',
'content'=>$multi_call->pop_up_content,
'button_name'=>$multi_call->pop_up_button_name,
'button_url'=>base_url('static/html/super_lottery/h5/multi_call/index.html?super_lottery_id='.$multi_call->id)
); return $this->send_json(true,'',$ret); }

PHP根据问题追踪代码技巧一的更多相关文章

  1. 优化 PHP 代码技巧

    优化 PHP 代码技巧1. 如果一个方法能被静态,那就声明他为静态的,速度可提高 1/4;2. echo 的效率高于 print,因为 echo 没有返回值,print 返回一个整型;3. 在循环之前 ...

  2. CSS 代码技巧与维护 ★ Mozilla Hacks – the Web developer blog

    原文链接:https://hacks.mozilla.org/2016/05/css-coding-techniques/ 译文链接 :http://www.zcfy.cc/article/css-c ...

  3. 20个JS优化代码技巧

    原文网址链接为:http://www.jstips.co/ .截取了一部分本人认为比较实用的技巧分享给大家.其中一小部分技巧为JS面向对象的写法,不宜一一列出.关于JS面向对象的写法可参考本人前几篇随 ...

  4. Javascript 优化项目代码技巧之语言基础(二)

        上一篇随笔介绍了如何正确判断对象类型.避免变量污染,特殊值(null.undefined.NaN)的使用,以及其他Javascript中常用关键字与方法的优化,这篇随笔将着重介绍Javascr ...

  5. Javascript 优化项目代码技巧之语言基础(一)

        Javascript的弱类型以及函数作用域等规则使用编写Javascript代码极为容易,但是编写可维护.高质量的代码却变得十分困难,这个系列的文章将总结在项目开发过程中,能够改善代码可读性. ...

  6. php优化代码技巧

    1. 如果一个方法可静态化,就对它做静态声明.速率可提升至 4 倍. 2. echo 比 print 快. 3. 使用 echo 的多重参数(译注:指用逗号而不是句点)代替字符串连接. 4. 在执行 ...

  7. 一些你需要知道的Python代码技巧

    被人工智能捧红的 Python 已是一种发展完善且非常多样化的语言,其中肯定有一些你尚未发现的功能.本文或许能够让你学到一些新技巧.   Python 是世界上最流行.热门的编程语言之一,原因很多,比 ...

  8. FireFox调试代码技巧

    本文版权归 csdn DyncRole 所有,此处为技术收藏,如有再转请标明原创作者及出处,以示尊重! 作者:DyncRole 原文:http://blog.csdn.net/qqhjqs/artic ...

  9. 掌握这些Python代码技巧,编程至少快一半!

    被人工智能捧红的 Python 已是一种发展完善且非常多样化的语言,其中肯定有一些你尚未发现的功能.本文或许能够让你学到一些新技巧. ​ Python 是世界上最流行.热门的编程语言之一,原因很多,比 ...

随机推荐

  1. swift 3新特性总结

    swift新特性之String 参考自[Swift 3.0 变化汇总系列总结-String] 使用方法:直接CMD+F搜索相应的函数或关键字符串,比较修改代码. 重要: /// 使用String的方法 ...

  2. [剑指offer]数组中最小的K个数,C++实现

    原创博文,转载请注明出处! http://github.com/wanglei5205 http://cnblogs.com/wanglei5205 # 题目 输入n个整数,找出其中最小的K个数.例如 ...

  3. enum枚举类型的定义

    enum枚举类型的定义方式与某种用法 #include <iostream> using namespace std; int main() { enum TOT{ zero, one, ...

  4. web端高德地图javascript API的调用

    [转载https://www.cnblogs.com/zimuzimu/p/6202244.html]web端高德地图javascript API的调用 关于第三放地图的使用,腾讯.百度.高德 具体怎 ...

  5. 20179223《Linux内核原理与分析》第五周学习笔记

    视频内容知识学习 一.用户态.内核态和中断 1.内核态:处于高的执行级别下,代码可以执行特权指令,访问任意的物理地址,这时的CPU就对应内核态 2.用户态:处于低的执行级别下,代码只能在级别允许的特定 ...

  6. 《selenium2 python 自动化测试实战》(17)——几个cookies操作

    之前我们已经学过利用cookies跳过验证码登录了,那时候我们用的方法是add_cookie()方法,这里再给大家介绍两个,一般情况下我们用不到,了解一下就可以,而且如果真的用到的时候百度也很快的: ...

  7. linux python 图形编程 qt开发环境搭建

    我的系统是 ubuntu14.04 我们使用的是python2.7,建议安装qt4+pyqt4+eric4 eric是pyqt的界面设计器的代码生成软件. 1.安装sip 这个是python和qt之间 ...

  8. vs2010 C++创建和使用动态链接库(dll)

    一.用C++创建动态链接库项目:  1.打开Microsoft Visual Studio 2010,选择File->New->Project.  2.在NewProject中选择Inst ...

  9. Serf 了解

    Introduction to Serf Welcome to the intro guide to Serf! This guide will show you what Serf is, expl ...

  10. ASP.NET常用标准配置web.config

    在我们的项目开发过程中,我们经常要配置wei.config文件,而大多数的时候配置差不多,下面的是一个简单的配置,其他的配置可以在这个基础上在添加 <?xml version="1.0 ...