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 是世界上最流行.热门的编程语言之一,原因很多,比 ...
随机推荐
- Swift UITextField各种属性的设置
//MARK: 文本输入框 func _initTextField() { //如果需要在模拟器中调用电脑的键盘 快捷键:command + shift + k let textField = UIT ...
- BZOJ5301: [Cqoi2018]异或序列(莫队)
5301: [Cqoi2018]异或序列 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 400 Solved: 291[Submit][Status ...
- Codeforces 1030D 【构造】
LINK 题目大意:给你n,m,k,让你在一个n*m的点阵里构造出一个面积为\(\frac{n*m}{k}\)的三角形 思路 首先要有一个结论是整点三角形的面积分母最多为2,然后就可以判断不存在的情况 ...
- koa2 中间件里面的next到底是什么
koa2短小精悍,女人不爱男人爱. 之前一只有用koa写一点小程序,自认为还吼吼哈,知道有一天某人问我,你说一下 koa或者express中间件的实现原理.然后我就支支吾吾,好久吃饭都不香. 那么了解 ...
- 利用Topshelf把.NET Core Generic Host管理的应用程序部署为Windows服务
背景 2019第一篇文章. 此文源于前公司在迁移项目到.NET Core的过程中,希望使用Generic Host来管理定时任务程序时,没法部署到Windows服务的问题,而且官方也没给出解决方案,只 ...
- BestCoder Round #1 第一题 逃生
// 等了好久,BESTCODER 终于出来了..像咋这样的毕业的人..就是去凑凑热闹// 弱校搞acm真是难,不过还是怪自己不够努力// 第一题是明显的拓扑排序,加了了个字典序限制而已// 用优先队 ...
- 2017-2018-2 20165222实验四《Android程序设计》实验报告
Android Stuidio的安装测试: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)>第二十四章: - 参考http: ...
- 《selenium2 python 自动化测试实战》(6)——打印信息和设置等待时间
打印信息经常用的有两个: # coding: utf-8 from selenium import webdriver driver = webdriver.Firefox() driver.get( ...
- {Reship}{Emgu}{vs2010}C#配置Emgu
=============================================================================================This Ar ...
- win32鼠标和键盘相关函数
键盘相关函数:http://msdn.microsoft.com/en-us/library/windows/desktop/ms645530%28v=vs.85%29.aspx 鼠标相关函数:htt ...