Commit 20dcfe2e authored by wwccw0591's avatar wwccw0591

pc

parent a8d80988
......@@ -2,6 +2,9 @@
namespace JPush;
use InvalidArgumentException;
use Our\ApiConst;
use Our\ArrayConst;
use Our\DescribeConst;
use Our\SecretKeys;
class ClientPush
......@@ -31,8 +34,38 @@ class ClientPush
}
return true;
}
private function getMessageType($type){
$baseTitle=DescribeConst::appName;
switch($type){
case ApiConst::systemMessageType:$baseTitle=$baseTitle.ArrayConst::messageName[ApiConst::systemMessageType];break;
case ApiConst::orderMessageType:$baseTitle=$baseTitle.ArrayConst::messageName[ApiConst::orderMessageType];break;
case ApiConst::deliveryMessageType:$baseTitle=$baseTitle.ArrayConst::messageName[ApiConst::deliveryMessageType];break;
case ApiConst::storeMessageType:$baseTitle=$baseTitle.ArrayConst::messageName[ApiConst::storeMessageType];break;
case ApiConst::memberMessageType:$baseTitle=$baseTitle.ArrayConst::messageName[ApiConst::memberMessageType];break;
default:$baseTitle;break;
}
return $baseTitle;
}
private function getMessageContent($message){
$messageContent='';
switch($message['type']){
case ApiConst::reacheCallMessage:
case ApiConst::refundReturnMessage:
case ApiConst::deliveryChangeMessage:
case ApiConst::autoSendMessage:
case ApiConst::orderStateChangeMessage:
case ApiConst::orderReceiveMessage:
case ApiConst::orderMessageType:$messageContent=$message['content'];break;
case ApiConst::onePictureMessage:$messageContent=DescribeConst::imageMessage;break;
}
return $messageContent;
}
public function push($pushData)
{
$title=$this->getMessageType($pushData['fromType']);
$messageContent=$this->getMessageContent($pushData['message']);
try {
$response = $this->client->push()
->setPlatform(array('ios', 'android'))
......@@ -41,36 +74,27 @@ class ClientPush
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
// ->addAlias('alias')
->addTag(array('tag1', 'tag2'))
// ->addRegistrationId($registration_id)
// ->addTag(array('tag1', 'tag2'))
->addRegistrationId($pushData['toId'])
->setNotificationAlert('Hi, JPush')
->iosNotification('Hello IOS', array(
->setNotificationAlert($title)
->iosNotification($messageContent, array(
'sound' => 'sound.caf',
// 'badge' => '+1',
// 'content-available' => true,
// 'mutable-content' => true,
'category' => 'jiguang',
'extras' => array(
'key' => 'value',
'jiguang'
),
'category' => 'shenbd',
'extras' => $pushData,
))
->androidNotification('Hello Android', array(
'title' => 'hello jpush',
->androidNotification($messageContent, array(
'title' => $title,
// 'builder_id' => 2,
'extras' => array(
'key' => 'value',
'jiguang'
),
'extras' => $pushData,
))
->message('message content', array(
->message($messageContent, array(
'title' => 'hello jpush',
// 'content_type' => 'text',
'extras' => array(
'key' => 'value',
'jiguang'
),
'content_type' => $pushData['type'],
'extras' => $pushData,
))
->options(array(
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
......
......@@ -82,6 +82,15 @@ class ApiConst
//普通用户消息类型
const memberMessageType = 5;
const ordinaryMessage=0;
const onePictureMessage=21;
const reacheCallMessage=1;
const refundReturnMessage=8;
const deliveryChangeMessage=12;
const autoSendMessage=13;
const orderStateChangeMessage=14;
const orderReceiveMessage=15;
const closeMessage=-1;
const openMessae=1;
//消息状态
......
......@@ -21,7 +21,9 @@ class ArrayConst
const messageName=array(
ApiConst::systemMessageType=>"系统消息",
ApiConst::orderMessageType=>"订单消息",
ApiConst::deliveryMessageType=>"订单消息",
ApiConst::deliveryMessageType=>"快递消息",
ApiConst::storeMessageType=>"店铺消息",
ApiConst::memberMessageType=>"用户消息",
);
//配送方式
const refundShippingType=array(
......
......@@ -9,7 +9,7 @@ namespace Our;
class DescribeConst
{
const appName='身边店';
//member表字段名
const successMessage = '操作成功';
//登陆成功提示
......@@ -164,5 +164,7 @@ class DescribeConst
const cancelOrderMessage='十分钟未支付,自动取消订单';
const anonymity = '匿名用户';
const imageMessage='【图片】';
}
?>
\ No newline at end of file
......@@ -23,7 +23,7 @@ class SettingServiceModel extends \Business\AbstractModel{
public function getSetting(){
$settingDAO = \DAO\SettingModel::getInstance();
$setting = $settingDAO->getListCache(array('unpayed_order_close_minutes','unreceived_order_close_minutes'));
$setting = $settingDAO->getListCache(array('unpayed_order_close_minutes','unreceived_order_close_minutes','service'));
$return = array();
if($setting['unpayed_order_close_minutes']){
$return['unpayedOrderColseTime'] = (int)$setting['unpayed_order_close_minutes'];
......@@ -31,6 +31,9 @@ class SettingServiceModel extends \Business\AbstractModel{
if($setting['unreceived_order_close_minutes']){
$return['unreceivedOrderColseTime'] = (int)$setting['unreceived_order_close_minutes'];
}
if($setting['service']){
$return['service'] = unserialize($setting['service']);
}
return $return;
}
private static $_instance = null;
......
......@@ -376,6 +376,7 @@ class MessageServiceModel extends \Business\AbstractModel
$redis->auth($conf['password']);
}
while ($center = $redis->lPop('message_center')) {
$redis->rPush('push_center',$center);
$addData = unserialize($center);
$addData['message'] = unserialize($addData['message']);
$this->addMessage($addData['fromId'], $addData['fromUserId'], $addData['fromUserName'], $addData['fromType'], $addData['message'], $addData['toId'], $addData['toUserId'], $addData['toUserName'], $addData['toType'], $addData['id']);
......
File mode changed from 100755 to 100644
......@@ -93,6 +93,8 @@ push.clientHost="wss://api.shenbd.com/wss"
push.host="127.0.0.1"
push.port="9503"
push.open=1
push.user.service.id=293
push.user.service.type=7
elastic.master.host="127.0.0.1"
elastic.master.port="9200"
......@@ -137,7 +139,8 @@ push.clientHost="wss://apiceshi.shenbd.com/wss"
push.host="127.0.0.1"
push.port="9503"
push.open=1
push.user.service.id=293
push.user.service.type=7
elastic.master.host="127.0.0.1"
elastic.master.port="9200"
elastic.master.scheme="http";
......@@ -181,6 +184,9 @@ push.host="127.0.0.1"
push.port="9503"
push.open=1
push.user.service.id=293
push.user.service.type=7
[develop : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
......@@ -208,7 +214,8 @@ redis.database.params.port = "6379"
redis.database.params.prefix = "qm_"
out.config="/data/config"
; redis配置
push.user.service.id=293
push.user.service.type=7
;redis.database.params.password = "test"
;推送配置
push.clientHost="ws://192.168.80.18:9502"
......@@ -253,7 +260,8 @@ push.clientHost="ws://192.168.80.18:9502"
push.host="192.168.80.18"
push.port="9503"
push.open=1
push.user.service.id=293
push.user.service.type=7
elastic.master.host="192.168.1.201"
elastic.master.port="9200"
elastic.master.scheme="http";
......@@ -300,6 +308,9 @@ push.host="192.168.80.18"
push.port="9503"
push.open=1
push.user.service.id=293
push.user.service.type=7
elastic.master.host="192.168.1.201"
elastic.master.port="9200"
elastic.master.scheme="http";
File mode changed from 100755 to 100644
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>设置命中地址(</title>
<style>
</style>
</head>
<body>
<form action="/common/getSetting" method="post">
key:<input name="data[key]" value="fd4b739c4815297044191451eabf0eb5"/><br />
<input type="submit" value="提交">
</form>
</body>
</html>
\ No newline at end of file
<?php
/**
* 推送10秒推送一次
* 推送10秒推送一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE);
class cliOrderClose extends basecli
{
const CLI_ADMIN_ID = 255;
private $bDoUnLock = FALSE; // 是否允许释放 LOCK 文件
private $_debug = 0;
private $lockFileName;
private $fromState;
private function mkdirs($dir, $mode = 0777)
{
if (is_dir($dir) || @mkdir($dir, $mode)){
return TRUE;
}
if (!$this->mkdirs(dirname($dir), $mode)){
return FALSE;
}
return @mkdir($dir, $mode);
}
/**
* 析构
*/
public function __destruct()
{
parent::__destruct();
if ($this->bDoUnLock)
{
@unlink($this->lockFileName);
}
}
protected function autoPushMessage(){
$conf = \Yaf\Registry::get('config')->get('redis.database.params');
$redis = new \Redis();
$redis->pconnect($conf['host'], $conf['port']);
$clientPush=\JPush\ClientPush::getInstance();
while($pushData=$redis->lPop('push_center')){
$addData = unserialize($pushData);
$addData['message'] = unserialize($addData['message']);
$clientPush->push($addData);
}
}
protected function _runCli()
{
$this->_debug = isset($this->aArgv[1]) ? intval($this->aArgv[1]) : 0;
if ($this->_debug)
{
echo "*** Debug mode ***\n";
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir=$this->_getBaseFileName('push');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .DS.'jpush.locks';
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 1800 )
{
echo "文件被锁超过1800秒,被强制删除";
@unlink($this->lockFileName);
}
else
{
$this->halt( '[' . date('Y-m-d H:i:s') .'] The CLI is running'."\n");
}
}
$this->bDoUnLock = true;
if(APP_ENV =='pre' || APP_ENV=='product'){
file_put_contents($this->lockFileName ,"running" ); // CLI 独占锁
}
$this->autoPushMessage();
echo date('Y-m-d H:i:s',TIMESTAMP).'消息推送成功'."\r\n";
}
}
$oCli = new cliOrderClose(TRUE);
EXIT;
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment