PHP根据问题追踪代码技巧一
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根据问题追踪代码技巧一的更多相关文章
- 优化 PHP 代码技巧
优化 PHP 代码技巧1. 如果一个方法能被静态,那就声明他为静态的,速度可提高 1/4;2. echo 的效率高于 print,因为 echo 没有返回值,print 返回一个整型;3. 在循环之前 ...
- CSS 代码技巧与维护 ★ Mozilla Hacks – the Web developer blog
原文链接:https://hacks.mozilla.org/2016/05/css-coding-techniques/ 译文链接 :http://www.zcfy.cc/article/css-c ...
- 20个JS优化代码技巧
原文网址链接为:http://www.jstips.co/ .截取了一部分本人认为比较实用的技巧分享给大家.其中一小部分技巧为JS面向对象的写法,不宜一一列出.关于JS面向对象的写法可参考本人前几篇随 ...
- Javascript 优化项目代码技巧之语言基础(二)
上一篇随笔介绍了如何正确判断对象类型.避免变量污染,特殊值(null.undefined.NaN)的使用,以及其他Javascript中常用关键字与方法的优化,这篇随笔将着重介绍Javascr ...
- Javascript 优化项目代码技巧之语言基础(一)
Javascript的弱类型以及函数作用域等规则使用编写Javascript代码极为容易,但是编写可维护.高质量的代码却变得十分困难,这个系列的文章将总结在项目开发过程中,能够改善代码可读性. ...
- php优化代码技巧
1. 如果一个方法可静态化,就对它做静态声明.速率可提升至 4 倍. 2. echo 比 print 快. 3. 使用 echo 的多重参数(译注:指用逗号而不是句点)代替字符串连接. 4. 在执行 ...
- 一些你需要知道的Python代码技巧
被人工智能捧红的 Python 已是一种发展完善且非常多样化的语言,其中肯定有一些你尚未发现的功能.本文或许能够让你学到一些新技巧. Python 是世界上最流行.热门的编程语言之一,原因很多,比 ...
- FireFox调试代码技巧
本文版权归 csdn DyncRole 所有,此处为技术收藏,如有再转请标明原创作者及出处,以示尊重! 作者:DyncRole 原文:http://blog.csdn.net/qqhjqs/artic ...
- 掌握这些Python代码技巧,编程至少快一半!
被人工智能捧红的 Python 已是一种发展完善且非常多样化的语言,其中肯定有一些你尚未发现的功能.本文或许能够让你学到一些新技巧. Python 是世界上最流行.热门的编程语言之一,原因很多,比 ...
随机推荐
- Ethernet、VLAN、QinQ
以太网帧格式: 各字段解释: DMAC:目的MAC地址,该字段确定帧的接收者. SMAC:源MAC地址,该字段标识发送帧的工作站. Type:上层协议类型(0x0800:IP;0x0808:ARP;0 ...
- MPI 学习
一.编译MPI mpic++ test.cc -o test 二.启动MPI mpiexec -np 10 ./test 三.几个例子 第一个进程向第二个发一个数,第二个进程向第三个进程发送一个数.. ...
- 今天需要做手机端访问的页面,所以把meta的整理一下。
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale= ...
- LeetCode - Course Schedule 解题报告
以前从来没有写过解题报告,只是看到大肥羊河delta写过不少.最近想把写博客的节奏给带起来,所以就挑一个比较容易的题目练练手. 原题链接 https://leetcode.com/problems/c ...
- 数位DP新识
简单题:HDU2089 HDU3652 HDU4734 HDU3555 POJ3252 HigoCoder1033(需要前导0,或者用方法4) 总结: 1,dfs(pos,state, ...
- Luogu3576 POI2014 MRO-Ant colony 【树形DP】*
Luogu3576 POI2014 MRO-Ant colony The ants are scavenging an abandoned ant hill in search of food. Th ...
- 通过Excel生成批量SQL语句,处理大量数据的好办法
我们经常会遇到这样的要求:用户给发过来一些数据,要我们直接给存放到数据库里面,有的是Insert,有的是Update等等,少量的数据我们可以采取最原始的办法,也就是在SQL里面用Insert into ...
- ThinkPHP5 使用create 获取表单所有字段
TP5没有 TP3的那个create创建表单字段,如果字段太多,写起来是非常麻烦 只需要在 框架里面 think/db/Query.php 里面加上函数 public function create( ...
- Nginx——Nginx概述(一)
1.什么是Nginx? Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.其特点是占有内存少,并发能力强,事实上n ...
- 《selenium2 python 自动化测试实战》(6)——打印信息和设置等待时间
打印信息经常用的有两个: # coding: utf-8 from selenium import webdriver driver = webdriver.Firefox() driver.get( ...