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 是世界上最流行.热门的编程语言之一,原因很多,比 ...
随机推荐
- [Linux] 使用rename批量重命名文件
例如把所有png文件的后缀改为jpg $ rename 's/png/jpg/' *png
- css工具类封装
温馨提示:一下css封装,建议按需使用,否则会造成很大的代码冗余,且很多样式会造成不符合预期的效果,建议合理使用 <a href="https://meyerweb.com/eric/ ...
- phpcms tag页调用缩略图
\phpcms\modules\content\tag.php 找到: 'title, description, url, inputtime, style' 改成:'title, thumb, de ...
- CF的Architecture,把它搞透!
Architecture Cloud Controller - Maintains a database with tables for orgs, spaces, apps, services, s ...
- Java并发--synchronized
以下是本文的目录大纲: 一.什么时候会出现线程安全问题? 二.如何解决线程安全问题? 三.synchronized同步方法或者同步块 转载原文链接:http://www.cnblogs.com/dol ...
- bzoj 4573 大森林
bzoj 4573 大森林 由于树上路径是唯一的,查询合法的两个点间路径长度显然与其他加点操作无关,所以可以离线处理,将所有的查询放在加点后. 这样我们可以对每棵树都在上颗树的基础上处理好形态后,处理 ...
- BZOJ4521 Cqoi2016 手机号码 【数位DP】
Description 人们选择手机号码时都希望号码好记.吉利.比如号码中含有几位相邻的相同数字.不含谐音不吉利的数字等.手机运营商在发行新号码时也会考虑这些因素,从号段中选取含有某些特征的号码单独出 ...
- HTTP错误类别
http_status_bad_request (400) the request could not be processed by the server due to invalid syntax ...
- LeetCode Best Time to Buy and Sell Stock with Transaction Fee
原题链接在这里:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/descripti ...
- filter防盗链
1这次练习中一直受到相对路径的干扰,现在澄清一点 forward中不是不需要包含根目录的 比如 http://localhost:8080/filter/upload/images/no.jpg 你 ...