Commit 7f9fcf63 authored by wwccw0591's avatar wwccw0591

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev

parents 57b3e4f5 9f4abe0f
......@@ -52,6 +52,10 @@ class IndexController extends \Our\Controller_Abstract {
}
public function indexAction() {
$clientPush=\JPush\ClientPush::getInstance();
$clientPush->pushAll();
echo 'success';
exit;
\Our\Log::getInstance()->write('testLog|||||testLog');
var_dump($_SERVER);exit;
// echo $_SERVER['USER']);exit;
......
......@@ -21,9 +21,9 @@ class MessageController extends \Our\Controller_AbstractApi {
$pageIndex=isset($this->req['data']['pageIndex'])?$this->req['data']['pageIndex']:0;
$pageSize=isset($this->req['data']['pageSize'])?$this->req['data']['pageSize']:20;
if(!empty($this->req['data']['toType'])){
$returnMessage=\Our\RedisHelper::cachedFunction(\Redis\Db15\MessageRedisModel::getInstance(),array(&$this->messageService, 'getMemberList'),array($this->memberId,$this->req['data']['fromType'],$this->req['data']['toId'],$this->req['data']['toType'],'*',$pageIndex,$pageSize),\Our\ApiConst::oneHourCache,array($this->memberId));
$returnMessage=\Our\RedisHelper::cachedFunction(\Redis\Db15\MessageRedisModel::getInstance(),array(&$this->messageService, 'getMemberList'),array($this->memberId,$this->req['data']['fromType'],$this->req['data']['toId'],$this->req['data']['toType'],'*',$pageIndex,$pageSize),\Our\ApiConst::tenSecond,array($this->memberId));
}else{
$returnMessage=\Our\RedisHelper::cachedFunction(\Redis\Db15\MessageRedisModel::getInstance(),array(&$this->messageService, 'getList'),array($this->memberId,$pageIndex,$pageSize),\Our\ApiConst::oneHourCache,array($this->memberId));
$returnMessage=\Our\RedisHelper::cachedFunction(\Redis\Db15\MessageRedisModel::getInstance(),array(&$this->messageService, 'getList'),array($this->memberId,$pageIndex,$pageSize),\Our\ApiConst::tenSecond,array($this->memberId));
if($returnMessage){
$returnMessage['users']=$returnMessage['list'];
}else{
......@@ -129,13 +129,23 @@ class MessageController extends \Our\Controller_AbstractApi {
}
public function setAction(){
$messageService = \Business\Message\MessageServiceModel::getInstance();
$type=$this->req['data']['type'];
if(!empty($type)){
$res=$messageService->set($this->memberId,$type);
$pushSet['canPush']=$this->req['data']['canPush'];
$pushSet['sound']=$this->req['data']['sound'];
$pushSet['vibrate']=$this->req['data']['vibrate'];
if(isset($pushSet['canPush'])&& isset($pushSet['sound']) && isset($pushSet['vibrate']) ){
$res=$messageService->set($this->memberId,$pushSet);
if($res){
$this->success(\Our\DescribeConst::setMessageSuccess);
}
}
\Error\ErrorModel::throwException(\Error\CodeConfigModel::setMessageFail);
}
public function getSetAction(){
$memberCenterService=\Business\User\MemberCenterServiceModel::getInstance();
$messageSet=$memberCenterService->getMessageSet($this->memberId);
if(!empty($messageSet)){
$this->success($messageSet);
}
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
}
<?php
namespace JPush;
class AdminClient {
const ADMIN_URL = 'https://admin.jpush.cn/v1/app/';
private $devKey;
private $devSecret;
private $retryTimes;
private $logFile;
function __construct($devKey, $devSecret) {
if (!is_string($devKey) || !is_string($devSecret)) {
throw new InvalidArgumentException("Invalid devKey or devSecret");
}
$this->devKey = $devKey;
$this->devSecret = $devSecret;
$this->retryTimes = 1;
$this->logFile = null;
}
public function getAuthStr() { return $this->devKey . ":" . $this->devSecret; }
public function getRetryTimes() { return $this->retryTimes; }
public function getLogFile() { return $this->logFile; }
public function createApp($appName, $androidPackage, $groupName=null) {
$url = AdminClient::ADMIN_URL;
$body = [
'app_name' => $appName,
'android_package'=> $androidPackage,
'group_name' => $groupName
];
return Http::post($this, $url, $body);
}
public function deleteApp($appKey) {
$url = AdminClient::ADMIN_URL . $appKey . '/delete';
return Http::post($this, $url, []);
}
}
<?php
namespace JPush;
use InvalidArgumentException;
class Client {
private $appKey;
private $masterSecret;
private $retryTimes;
private $logFile;
private $zone;
private static $zones = [
'DEFAULT' => [
'push' => 'https://api.jpush.cn/v3/',
'report' => 'https://report.jpush.cn/v3/',
'device' => 'https://device.jpush.cn/v3/devices/',
'alias' => 'https://device.jpush.cn/v3/aliases/',
'tag' => 'https://device.jpush.cn/v3/tags/',
'schedule' => 'https://api.jpush.cn/v3/schedules/'
],
'BJ' => [
'push' => 'https://bjapi.push.jiguang.cn/v3/',
'report' => 'https://bjapi.push.jiguang.cn/v3/report/',
'device' => 'https://bjapi.push.jiguang.cn/v3/device/',
'alias' => 'https://bjapi.push.jiguang.cn/v3/device/aliases/',
'tag' => 'https://bjapi.push.jiguang.cn/v3/device/tags/',
'schedules' => 'https://bjapi.push.jiguang.cn/v3/push/schedules/'
]
];
public function __construct($appKey, $masterSecret, $logFile=Config::DEFAULT_LOG_FILE, $retryTimes=Config::DEFAULT_MAX_RETRY_TIMES, $zone = null) {
if (!is_string($appKey) || !is_string($masterSecret)) {
throw new InvalidArgumentException("Invalid appKey or masterSecret");
}
$this->appKey = $appKey;
$this->masterSecret = $masterSecret;
if (!is_null($retryTimes)) {
$this->retryTimes = $retryTimes;
} else {
$this->retryTimes = 1;
}
$this->logFile = $logFile;
if (!is_null($zone) && in_array(strtoupper($zone), array_keys(self::$zones))) {
$this->zone = strtoupper($zone);
} else {
$this->zone= null;
}
}
public function push() { return new PushPayload($this); }
public function report() { return new ReportPayload($this); }
public function device() { return new DevicePayload($this); }
public function schedule() { return new SchedulePayload($this);}
public function getAuthStr() { return $this->appKey . ":" . $this->masterSecret; }
public function getRetryTimes() { return $this->retryTimes; }
public function getLogFile() { return $this->logFile; }
public function is_group() {
$str = substr($this->appKey, 0, 6);
return $str === 'group-';
}
public function makeURL($key) {
if (is_null($this->zone)) {
return self::$zones['DEFAULT'][$key];
} else {
return self::$zones[$this->zone][$key];
}
}
}
<?php
namespace JPush;
use InvalidArgumentException;
use Our\SecretKeys;
class ClientPush
{
private $client;
public function __construct()
{
$app_key = SecretKeys::pushKey;
$master_secret = SecretKeys::pushSecret;
//$registration_id = getenv('registration_id');
$this->client = new Client($app_key, $master_secret);
}
public function pushAll(){
$push_payload = $this->client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert('Hi, JPush');
try {
$response = $push_payload->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
return true;
}
public function push($pushData)
{
try {
$response = $this->client->push()
->setPlatform(array('ios', 'android'))
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
// ->addAlias('alias')
->addTag(array('tag1', 'tag2'))
// ->addRegistrationId($registration_id)
->setNotificationAlert('Hi, JPush')
->iosNotification('Hello IOS', array(
'sound' => 'sound.caf',
// 'badge' => '+1',
// 'content-available' => true,
// 'mutable-content' => true,
'category' => 'jiguang',
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->androidNotification('Hello Android', array(
'title' => 'hello jpush',
// 'builder_id' => 2,
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->message('message content', array(
'title' => 'hello jpush',
// 'content_type' => 'text',
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->options(array(
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
// 这里设置为 100 仅作为示例
// 'sendno' => 100,
// time_to_live: 表示离线消息保留时长(秒),
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
// 这里设置为 1 仅作为示例
// 'time_to_live' => 1,
// apns_production: 表示APNs是否生产环境,
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送生产环境
'apns_production' => false,
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
// 这里设置为 1 仅作为示例
// 'big_push_duration' => 1
))
->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private static $_instance = null;
/**
* 获取类实例
*
* @ccw push
*/
public static function getInstance()
{
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
<?php
namespace JPush;
class Config {
const DISABLE_SOUND = "_disable_Sound";
const DISABLE_BADGE = 0x10000;
const USER_AGENT = 'JPush-API-PHP-Client';
const CONNECT_TIMEOUT = 20;
const READ_TIMEOUT = 120;
const DEFAULT_MAX_RETRY_TIMES = 3;
const DEFAULT_LOG_FILE = "./jpush.log";
const HTTP_GET = 'GET';
const HTTP_POST = 'POST';
const HTTP_DELETE = 'DELETE';
const HTTP_PUT = 'PUT';
}
<?php
namespace JPush;
use InvalidArgumentException;
class DevicePayload {
private $client;
/**
* DevicePayload constructor.
* @param $client JPush
*/
public function __construct($client)
{
$this->client = $client;
}
public function getDevices($registrationId) {
$url = $this->client->makeURL('device') . $registrationId;
return Http::get($this->client, $url);
}
public function updateAlias($registration_id, $alias) {
return $this->updateDevice($registration_id, $alias);
}
public function addTags($registration_id, $tags) {
$tags = is_array($tags) ? $tags : array($tags);
return $this->updateDevice($registration_id, null, null, $tags);
}
public function removeTags($registration_id, $tags) {
$tags = is_array($tags) ? $tags : array($tags);
return $this->updateDevice($registration_id, null, null, null, $tags);
}
public function updateMoblie($registration_id, $mobile) {
return $this->updateDevice($registration_id, null, $mobile);
}
public function clearTags($registrationId) {
$url = $this->client->makeURL('device') . $registrationId;
return Http::post($this->client, $url, ['tags' => '']);
}
public function updateDevice($registrationId, $alias = null, $mobile = null, $addTags = null, $removeTags = null) {
$payload = array();
if (!is_string($registrationId)) {
throw new InvalidArgumentException('Invalid registration_id');
}
$aliasIsNull = is_null($alias);
$mobileIsNull = is_null($mobile);
$addTagsIsNull = is_null($addTags);
$removeTagsIsNull = is_null($removeTags);
if ($aliasIsNull && $addTagsIsNull && $removeTagsIsNull && $mobileIsNull) {
throw new InvalidArgumentException("alias, addTags, removeTags not all null");
}
if (!$aliasIsNull) {
if (is_string($alias)) {
$payload['alias'] = $alias;
} else {
throw new InvalidArgumentException("Invalid alias string");
}
}
if (!$mobileIsNull) {
if (is_string($mobile)) {
$payload['mobile'] = $mobile;
} else {
throw new InvalidArgumentException("Invalid mobile string");
}
}
$tags = array();
if (!$addTagsIsNull) {
if (is_array($addTags)) {
$tags['add'] = $addTags;
} else {
throw new InvalidArgumentException("Invalid addTags array");
}
}
if (!$removeTagsIsNull) {
if (is_array($removeTags)) {
$tags['remove'] = $removeTags;
} else {
throw new InvalidArgumentException("Invalid removeTags array");
}
}
if (count($tags) > 0) {
$payload['tags'] = $tags;
}
$url = $this->client->makeURL('device') . $registrationId;
return Http::post($this->client, $url, $payload);
}
public function getTags() {
$url = $this->client->makeURL('tag');
return Http::get($this->client, $url);
}
public function isDeviceInTag($registrationId, $tag) {
if (!is_string($registrationId)) {
throw new InvalidArgumentException("Invalid registration_id");
}
if (!is_string($tag)) {
throw new InvalidArgumentException("Invalid tag");
}
$url = $this->client->makeURL('tag') . $tag . '/registration_ids/' . $registrationId;
return Http::get($this->client, $url);
}
public function addDevicesToTag($tag, $addDevices) {
$device = is_array($addDevices) ? $addDevices : array($addDevices);
return $this->updateTag($tag, $device, null);
}
public function removeDevicesFromTag($tag, $removeDevices) {
$device = is_array($removeDevices) ? $removeDevices : array($removeDevices);
return $this->updateTag($tag, null, $device);
}
public function updateTag($tag, $addDevices = null, $removeDevices = null) {
if (!is_string($tag)) {
throw new InvalidArgumentException("Invalid tag");
}
$addDevicesIsNull = is_null($addDevices);
$removeDevicesIsNull = is_null($removeDevices);
if ($addDevicesIsNull && $removeDevicesIsNull) {
throw new InvalidArgumentException("Either or both addDevices and removeDevices must be set.");
}
$registrationId = array();
if (!$addDevicesIsNull) {
if (is_array($addDevices)) {
$registrationId['add'] = $addDevices;
} else {
throw new InvalidArgumentException("Invalid addDevices");
}
}
if (!$removeDevicesIsNull) {
if (is_array($removeDevices)) {
$registrationId['remove'] = $removeDevices;
} else {
throw new InvalidArgumentException("Invalid removeDevices");
}
}
$url = $this->client->makeURL('tag') . $tag;
$payload = array('registration_ids'=>$registrationId);
return Http::post($this->client, $url, $payload);
}
public function deleteTag($tag) {
if (!is_string($tag)) {
throw new InvalidArgumentException("Invalid tag");
}
$url = $this->client->makeURL('tag') . $tag;
return Http::delete($this->client, $url);
}
public function getAliasDevices($alias, $platform = null) {
if (!is_string($alias)) {
throw new InvalidArgumentException("Invalid alias");
}
$url = $this->client->makeURL('alias') . $alias;
if (!is_null($platform)) {
if (is_array($platform)) {
$isFirst = true;
foreach($platform as $item) {
if ($isFirst) {
$url = $url . '?platform=' . $item;
$isFirst = false;
} else {
$url = $url . ',' . $item;
}
}
} else if (is_string($platform)) {
$url = $url . '?platform=' . $platform;
} else {
throw new InvalidArgumentException("Invalid platform");
}
}
return Http::get($this->client, $url);
}
public function deleteAlias($alias) {
if (!is_string($alias)) {
throw new InvalidArgumentException("Invalid alias");
}
$url = $this->client->makeURL('alias') . $alias;
return Http::delete($this->client, $url);
}
public function getDevicesStatus($registrationId) {
if (!is_array($registrationId) && !is_string($registrationId)) {
throw new InvalidArgumentException('Invalid registration_id');
}
if (is_string($registrationId)) {
$registrationId = explode(',', $registrationId);
}
$payload = array();
if (count($registrationId) <= 0) {
throw new InvalidArgumentException('Invalid registration_id');
}
$payload['registration_ids'] = $registrationId;
$url = $this->client->makeURL('device') . 'status';
return Http::post($this->client, $url, $payload);
}
}
<?php
namespace JPush\Exceptions;
class APIConnectionException extends JPushException {
function __toString() {
return "\n" . __CLASS__ . " -- {$this->message} \n";
}
}
<?php
namespace JPush\Exceptions;
class APIRequestException extends JPushException {
private $http_code;
private $headers;
private static $expected_keys = array('code', 'message');
function __construct($response){
$this->http_code = $response['http_code'];
$this->headers = $response['headers'];
$body = json_decode($response['body'], true);
if (key_exists('error', $body)) {
$this->code = $body['error']['code'];
$this->message = $body['error']['message'];
} else {
$this->code = $body['code'];
$this->message = $body['message'];
}
}
public function __toString() {
return "\n" . __CLASS__ . " -- [{$this->code}]: {$this->message} \n";
}
public function getHttpCode() {
return $this->http_code;
}
public function getHeaders() {
return $this->headers;
}
}
<?php
namespace JPush\Exceptions;
class JPushException extends \Exception {
function __construct($message) {
parent::__construct($message);
}
}
<?php
namespace JPush\Exceptions;
class ServiceNotAvaliable extends JPushException {
private $http_code;
private $headers;
function __construct($response){
$this->http_code = $response['http_code'];
$this->headers = $response['headers'];
$this->message = $response['body'];
}
function __toString() {
return "\n" . __CLASS__ . " -- [{$this->http_code}]: {$this->message} \n";
}
public function getHttpCode() {
return $this->http_code;
}
public function getHeaders() {
return $this->headers;
}
}
<?php
namespace JPush;
use JPush\Exceptions\APIConnectionException;
use JPush\Exceptions\APIRequestException;
use JPush\Exceptions\ServiceNotAvaliable;
final class Http {
public static function get($client, $url) {
$response = self::sendRequest($client, $url, Config::HTTP_GET, $body=null);
return self::processResp($response);
}
public static function post($client, $url, $body) {
$response = self::sendRequest($client, $url, Config::HTTP_POST, $body);
return self::processResp($response);
}
public static function put($client, $url, $body) {
$response = self::sendRequest($client, $url, Config::HTTP_PUT, $body);
return self::processResp($response);
}
public static function delete($client, $url) {
$response = self::sendRequest($client, $url, Config::HTTP_DELETE, $body=null);
return self::processResp($response);
}
private static function sendRequest($client, $url, $method, $body=null, $times=1) {
self::log($client, "Send " . $method . " " . $url . ", body:" . json_encode($body) . ", times:" . $times);
if (!defined('CURL_HTTP_VERSION_2_0')) {
define('CURL_HTTP_VERSION_2_0', 3);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, Config::USER_AGENT);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Config::CONNECT_TIMEOUT); // 连接建立最长耗时
curl_setopt($ch, CURLOPT_TIMEOUT, Config::READ_TIMEOUT); // 请求最长耗时
// 设置SSL版本 1=CURL_SSLVERSION_TLSv1, 不指定使用默认值,curl会自动获取需要使用的CURL版本
// curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// 如果报证书相关失败,可以考虑取消注释掉该行,强制指定证书版本
//curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
// 设置Basic认证
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $client->getAuthStr());
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
// 设置Post参数
if ($method === Config::HTTP_POST) {
curl_setopt($ch, CURLOPT_POST, true);
} else if ($method === Config::HTTP_DELETE || $method === Config::HTTP_PUT) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
}
if (!is_null($body)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Connection: Keep-Alive'
));
$output = curl_exec($ch);
$response = array();
$errorCode = curl_errno($ch);
// $msg = '';
// $data = json_decode($body, true);
// if (isset($data['options']['sendno'])) {
// $sendno = $data['options']['sendno'];
// $msg = 'sendno: ' . $sendno;
// }
$msg = '';
if (isset($body['options']['sendno'])) {
$sendno = $body['options']['sendno'];
$msg = 'sendno: ' . $sendno;
}
if ($errorCode) {
$retries = $client->getRetryTimes();
if ($times < $retries) {
return self::sendRequest($client, $url, $method, $body, ++$times);
} else {
if ($errorCode === 28) {
throw new APIConnectionException($msg . "Response timeout. Your request has probably be received by JPush Server,please check that whether need to be pushed again." );
} elseif ($errorCode === 56) {
// resolve error[56 Problem (2) in the Chunked-Encoded data]
throw new APIConnectionException($msg . "Response timeout, maybe cause by old CURL version. Your request has probably be received by JPush Server, please check that whether need to be pushed again.");
} else {
throw new APIConnectionException("$msg . Connect timeout. Please retry later. Error:" . $errorCode . " " . curl_error($ch));
}
}
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header_text = substr($output, 0, $header_size);
$body = substr($output, $header_size);
$headers = array();
foreach (explode("\r\n", $header_text) as $i => $line) {
if (!empty($line)) {
if ($i === 0) {
$headers[0] = $line;
} else if (strpos($line, ": ")) {
list ($key, $value) = explode(': ', $line);
$headers[$key] = $value;
}
}
}
$response['headers'] = $headers;
$response['body'] = $body;
$response['http_code'] = $httpCode;
}
curl_close($ch);
return $response;
}
public static function processResp($response) {
$data = json_decode($response['body'], true);
if ($response['http_code'] === 200) {
$result = array();
$result['body'] = $data;
$result['http_code'] = $response['http_code'];
$result['headers'] = $response['headers'];
return $result;
} elseif (is_null($data)) {
throw new ServiceNotAvaliable($response);
} else {
throw new APIRequestException($response);
}
}
public static function log($client, $content) {
if (!is_null($client->getLogFile())) {
error_log($content . "\r\n", 3, $client->getLogFile());
}
}
}
This diff is collapsed.
<?php
namespace JPush;
use InvalidArgumentException;
class ReportPayload {
private static $EFFECTIVE_TIME_UNIT = array('HOUR', 'DAY', 'MONTH');
private $client;
/**
* ReportPayload constructor.
* @param $client JPush
*/
public function __construct($client)
{
$this->client = $client;
}
public function getReceived($msgIds) {
$queryParams = '?msg_ids=';
if (is_array($msgIds) && !empty($msgIds)) {
$msgIdsStr = implode(',', $msgIds);
$queryParams .= $msgIdsStr;
} elseif (is_string($msgIds)) {
$queryParams .= $msgIds;
} else {
throw new InvalidArgumentException("Invalid msg_ids");
}
$url = $this->client->makeURL('report') . 'received' . $queryParams;
return Http::get($this->client, $url);
}
public function getMessageStatus($msgId, $rids, $data = null) {
$url = $this->client->makeURL('report') . 'status/message';
$registrationIds = is_array($rids) ? $rids : array($rids);
$body = [
'msg_id' => $msgId,
'registration_ids' => $registrationIds
];
if (!is_null($data)) {
$body['data'] = $data;
}
return Http::post($this->client, $url, $body);
}
public function getMessages($msgIds) {
$queryParams = '?msg_ids=';
if (is_array($msgIds) && !empty($msgIds)) {
$msgIdsStr = implode(',', $msgIds);
$queryParams .= $msgIdsStr;
} elseif (is_string($msgIds)) {
$queryParams .= $msgIds;
} else {
throw new InvalidArgumentException("Invalid msg_ids");
}
$url = $this->client->makeURL('report') . 'messages/' .$queryParams;
return Http::get($this->client, $url);
}
public function getUsers($time_unit, $start, $duration) {
$time_unit = strtoupper($time_unit);
if (!in_array($time_unit, self::$EFFECTIVE_TIME_UNIT)) {
throw new InvalidArgumentException('Invalid time unit');
}
$url = $this->client->makeURL('report') . 'users/?time_unit=' . $time_unit . '&start=' . $start . '&duration=' . $duration;
return Http::get($this->client, $url);
}
}
<?php
namespace JPush;
use InvalidArgumentException;
class SchedulePayload {
private $client;
/**
* SchedulePayload constructor.
* @param $client JPush
*/
public function __construct($client) {
$this->client = $client;
}
public function createSingleSchedule($name, $push_payload, $trigger) {
if (!is_string($name)) {
throw new InvalidArgumentException('Invalid schedule name');
}
if (!is_array($push_payload)) {
throw new InvalidArgumentException('Invalid schedule push payload');
}
if (!is_array($trigger)) {
throw new InvalidArgumentException('Invalid schedule trigger');
}
$payload = array();
$payload['name'] = $name;
$payload['enabled'] = true;
$payload['trigger'] = array("single"=>$trigger);
$payload['push'] = $push_payload;
$url = $this->client->makeURL('schedule');
return Http::post($this->client, $url, $payload);
}
public function createPeriodicalSchedule($name, $push_payload, $trigger) {
if (!is_string($name)) {
throw new InvalidArgumentException('Invalid schedule name');
}
if (!is_array($push_payload)) {
throw new InvalidArgumentException('Invalid schedule push payload');
}
if (!is_array($trigger)) {
throw new InvalidArgumentException('Invalid schedule trigger');
}
$payload = array();
$payload['name'] = $name;
$payload['enabled'] = true;
$payload['trigger'] = array("periodical"=>$trigger);
$payload['push'] = $push_payload;
$url = $this->client->makeURL('schedule');
return Http::post($this->client, $url, $payload);
}
public function updateSingleSchedule($schedule_id, $name=null, $enabled=null, $push_payload=null, $trigger=null) {
if (!is_string($schedule_id)) {
throw new InvalidArgumentException('Invalid schedule id');
}
$payload = array();
if (!is_null($name)) {
if (!is_string($name)) {
throw new InvalidArgumentException('Invalid schedule name');
} else {
$payload['name'] = $name;
}
}
if (!is_null($enabled)) {
if (!is_bool($enabled)) {
throw new InvalidArgumentException('Invalid schedule enable');
} else {
$payload['enabled'] = $enabled;
}
}
if (!is_null($push_payload)) {
if (!is_array($push_payload)) {
throw new InvalidArgumentException('Invalid schedule push payload');
} else {
$payload['push'] = $push_payload;
}
}
if (!is_null($trigger)) {
if (!is_array($trigger)) {
throw new InvalidArgumentException('Invalid schedule trigger');
} else {
$payload['trigger'] = array("single"=>$trigger);
}
}
if (count($payload) <= 0) {
throw new InvalidArgumentException('Invalid schedule, name, enabled, trigger, push can not all be null');
}
$url = $this->client->makeURL('schedule') . "/" . $schedule_id;
return Http::put($this->client, $url, $payload);
}
public function updatePeriodicalSchedule($schedule_id, $name=null, $enabled=null, $push_payload=null, $trigger=null) {
if (!is_string($schedule_id)) {
throw new InvalidArgumentException('Invalid schedule id');
}
$payload = array();
if (!is_null($name)) {
if (!is_string($name)) {
throw new InvalidArgumentException('Invalid schedule name');
} else {
$payload['name'] = $name;
}
}
if (!is_null($enabled)) {
if (!is_bool($enabled)) {
throw new InvalidArgumentException('Invalid schedule enable');
} else {
$payload['enabled'] = $enabled;
}
}
if (!is_null($push_payload)) {
if (!is_array($push_payload)) {
throw new InvalidArgumentException('Invalid schedule push payload');
} else {
$payload['push'] = $push_payload;
}
}
if (!is_null($trigger)) {
if (!is_array($trigger)) {
throw new InvalidArgumentException('Invalid schedule trigger');
} else {
$payload['trigger'] = array("periodical"=>$trigger);
}
}
if (count($payload) <= 0) {
throw new InvalidArgumentException('Invalid schedule, name, enabled, trigger, push can not all be null');
}
$url = $this->client->makeURL('schedule') . "/" . $schedule_id;
return Http::put($this->client, $url, $payload);
}
public function getSchedules($page = 1) {
if (!is_int($page)) {
$page = 1;
}
$url = $this->client->makeURL('schedule') . "?page=" . $page;
return Http::get($this->client, $url);
}
public function getSchedule($schedule_id) {
if (!is_string($schedule_id)) {
throw new InvalidArgumentException('Invalid schedule id');
}
$url = $this->client->makeURL('schedule') . "/" . $schedule_id;
return Http::get($this->client, $url);
}
public function deleteSchedule($schedule_id) {
if (!is_string($schedule_id)) {
throw new InvalidArgumentException('Invalid schedule id');
}
$url = $this->client->makeURL('schedule') . "/" . $schedule_id;
return Http::delete($this->client, $url);
}
}
<?php
// 这只是使用样例,不应该直接用于实际生产环境中 !!
require 'config.php';
use JPush\AdminClient as Admin;
$admin = new Admin($dev_key, $dev_secret);
$response = $admin->createApp('aaa', 'cn.jpush.app');
print_r($response);
$appKey = $response['body']['app_key'];
$response = $admin->deleteApp($appKey);
print_r($response);
<?php
require 'config.php';
$response = $client->push()->getCid();
print_r($response);
<?php
require __DIR__ . '/../autoload.php';
use JPush\Client as JPush;
$app_key = getenv('app_key');
$master_secret = getenv('master_secret');
$registration_id = getenv('registration_id');
$client = new JPush($app_key, $master_secret);
<?php
require __DIR__ . '/../config.php';
$response = $client->device()->deleteAlias('alias');
print_r($response);
<?php
require __DIR__ . '/../config.php';
$response = $client->device()->deleteTag('tag');
print_r($response);
<?php
require __DIR__ . '/../config.php';
// 更新 Alias
$response = $client->device()->getAliasDevices('alias');
print_r($response);
<?php
require __DIR__ . '/../config.php';
// 获取指定设备的 Mobile,Alias,Tags 等信息
$response = $client->device()->getDevices($registration_id);
print_r($response);
\ No newline at end of file
<?php
require __DIR__ . '/../config.php';
// 获取用户在线状态(VIP专属接口)
try {
$response = $client->device()->getDevicesStatus($registration_id);
} catch(\JPush\Exceptions\APIRequestException $e) {
print $e;
print $e->getHttpCode();
print $e->getHeaders();
}
print_r($response);
<?php
require __DIR__ . '/../config.php';
// 获取Tag列表
$response = $client->device()->getDevices($registration_id);
print_r($response);
\ No newline at end of file
<?php
require __DIR__ . '/../config.php';
// 更新 Alias
$result = $client->device()->getDevices($registration_id);
print "before update alias = " . $result['body']['alias'] . "\n";
print 'updating alias ... response = ';
$response = $client->device()->updateAlias($registration_id, 'jpush_alias');
print_r($response);
$result = $client->device()->getDevices($registration_id);
print "after update alias = " . $result['body']['alias'] . "\n\n";
// 添加 tag
$result = $client->device()->getDevices($registration_id);
print "before add tags = [" . implode(',', $result['body']['tags']) . "]\n";
print 'add tag1 tag2 ... response = ';
$response = $client->device()->addTags($registration_id, 'tag0');
print_r($response);
$response = $client->device()->addTags($registration_id, ['tag1', 'tag2']);
print_r($response);
$result = $client->device()->getDevices($registration_id);
print "after add tags = [" . implode(',', $result['body']['tags']) . "]\n\n";
// 移除 tag
$result = $client->device()->getDevices($registration_id);
print "before remove tags = [" . implode(',', $result['body']['tags']) . "]\n";
print 'removing tag1 tag2 ... response = ';
$response = $client->device()->removeTags($registration_id, 'tag0');
print_r($response);
$response = $client->device()->removeTags($registration_id, ['tag1', 'tag2']);
print_r($response);
$result = $client->device()->getDevices($registration_id);
print "after remove tags = [" . implode(',', $result['body']['tags']) . "]\n\n";
// 更新 mobile
$result = $client->device()->getDevices($registration_id);
print "before update mobile = " . $result['body']['mobile'] . "\n";
print 'updating mobile ... response = ';
$response = $client->device()->updateMoblie($registration_id, '13800138000');
print_r($response);
$result = $client->device()->getDevices($registration_id);
print "after update mobile = " . $result['body']['mobile'] . "\n\n";
\ No newline at end of file
<?php
require __DIR__ . '/../config.php';
// 为一个标签添加设备
$result = $client->device()->isDeviceInTag($registration_id, 'tag');
$r = $result['body']['result'] ? 'true' : 'false';
print "before add device = " . $r . "\n";
print 'adding device ... response = ';
$response = $client->device()->addDevicesToTag('tag', $registration_id);
print_r($response);
$result = $client->device()->isDeviceInTag($registration_id, 'tag');
$r = $result['body']['result'] ? 'true' : 'false';
print "after add tags = " . $r . "\n\n";
// 为一个标签删除设备
$result = $client->device()->isDeviceInTag($registration_id, 'tag');
$r = $result['body']['result'] ? 'true' : 'false';
print "before remove device = " . $r . "\n";
print 'removing device ... response = ';
$response = $client->device()->removeDevicesFromTag('tag', $registration_id);
print_r($response);
$result = $client->device()->isDeviceInTag($registration_id, 'tag');
$r = $result['body']['result'] ? 'true' : 'false';
print "after remove device = " . $r . "\n\n";
<?php
require __DIR__ . '/../autoload.php';
use JPush\Client as JPush;
$group_key = 'xxxx';
$group_master_secret = 'xxxx';
$client = new JPush('group-' . $group_key, $group_master_secret, null);
$push_payload = $client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert('Hi, JPush');
try {
$response = $push_payload->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
<?php
// 这只是使用样例,不应该直接用于实际生产环境中 !!
require 'config.php';
try {
$payload = $client->push()
->setPlatform(array('ios', 'android'))
// ->addAlias('alias')
->addTag(array('tag1', 'tag2'))
// ->addRegistrationId($registration_id)
->setNotificationAlert('Hi, JPush')
->androidNotification('Hello HUAWEI', array(
'title' => 'huawei demo',
// ---------------------------------------------------
// `uri_activity` 字段用于指定想要打开的 activity.
// 值为 activity 节点的 “android:name” 属性值。
'uri_activity' => 'cn.jpush.android.ui.OpenClickActivity',
// ---------------------------------------------------
'extras' => array(
'key' => 'value',
'jiguang'
),
));
// ->send();
print_r($payload->build());
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
<?php
// 这只是使用样例,不应该直接用于实际生产环境中 !!
require 'config.php';
// 简单推送示例
// 这只是使用样例,不应该直接用于实际生产环境中 !!
$push_payload = $client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert('Hi, JPush');
try {
$response = $push_payload->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
// 完整的推送示例
// 这只是使用样例,不应该直接用于实际生产环境中 !!
try {
$response = $client->push()
->setPlatform(array('ios', 'android'))
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
// ->addAlias('alias')
->addTag(array('tag1', 'tag2'))
// ->addRegistrationId($registration_id)
->setNotificationAlert('Hi, JPush')
->iosNotification('Hello IOS', array(
'sound' => 'sound.caf',
// 'badge' => '+1',
// 'content-available' => true,
// 'mutable-content' => true,
'category' => 'jiguang',
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->androidNotification('Hello Android', array(
'title' => 'hello jpush',
// 'builder_id' => 2,
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->message('message content', array(
'title' => 'hello jpush',
// 'content_type' => 'text',
'extras' => array(
'key' => 'value',
'jiguang'
),
))
->options(array(
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
// 这里设置为 100 仅作为示例
// 'sendno' => 100,
// time_to_live: 表示离线消息保留时长(秒),
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
// 这里设置为 1 仅作为示例
// 'time_to_live' => 1,
// apns_production: 表示APNs是否生产环境,
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送生产环境
'apns_production' => false,
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
// 这里设置为 1 仅作为示例
// 'big_push_duration' => 1
))
->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
<?php
// 这只是使用样例不应该直接用于实际生产环境中 !!
require 'config.php';
$payload = $client->push()
->setPlatform("all")
->addAllAudience()
->setNotificationAlert("Hi, 这是一条定时发送的消息")
->build();
// 创建一个2016-12-22 13:45:00触发的定时任务
$response = $client->schedule()->createSingleSchedule("每天14点发送的定时任务", $payload, array("time"=>"2016-12-22 13:45:00"));
print_r($response);
// 创建一个每天14点发送的定时任务
$response = $client->schedule()->createPeriodicalSchedule("每天14点发送的定时任务", $payload,
array(
"start"=>"2016-12-22 13:45:00",
"end"=>"2016-12-25 13:45:00",
"time"=>"14:00:00",
"time_unit"=>"DAY",
"frequency"=>1
));
print_r($response);
<?php
// 这只是使用样例,不应该直接用于实际生产环境中 !!
require 'config.php';
use JPush\Client as JPush;
// 简单推送示例
// 这只是使用样例,不应该直接用于实际生产环境中 !!
$client = new JPush($app_key, $master_secret, null, null, 'BJ');
$push_payload = $client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert('Hi, JPush');
try {
$response = $push_payload->send();
print_r($response);
} catch (\JPush\Exceptions\APIConnectionException $e) {
// try something here
print $e;
} catch (\JPush\Exceptions\APIRequestException $e) {
// try something here
print $e;
}
\ No newline at end of file
<?php
namespace JPush;
const VERSION = '3.6.1';
......@@ -30,6 +30,8 @@ class ApiConst
//7天秒数
const sevenDaySecond = 604800;
const oneMinute = 60;
const tenSecond=10;
//八小时秒数
const EightHoursSecond = 28800;
const hundred = 100;
......
......@@ -63,9 +63,9 @@ class ArrayConst
//系统默认地址
const defaultAddress = array(
NameConst::cityCode => '0591',
NameConst::lat => '26.053183',
NameConst::lng => '119.24174',
NameConst::address => '横一号路特力林科技大厦',
NameConst::lat => '26.043194',
NameConst::lng => '119.331196',
NameConst::address => '福远文创园',
'default'=>\Our\ApiConst::one
);
......
......@@ -347,13 +347,15 @@ class Common
* @param array $data
* @return array
*/
public static function convertHump(array $data){
public static function convertHump($data = array()){
$result = [];
foreach ($data as $key => $item) {
if (is_array($item) || is_object($item)) {
$result[self::humpToLine($key)] = self::convertHump((array)$item);
} else {
$result[self::humpToLine($key)] = $item;
if($data){
foreach ($data as $key => $item) {
if (is_array($item) || is_object($item)) {
$result[self::humpToLine($key)] = self::convertHump((array)$item);
} else {
$result[self::humpToLine($key)] = $item;
}
}
}
return $result;
......@@ -365,13 +367,15 @@ class Common
* @param array $data
* @return array
*/
public static function convertUnderline(array $data){
public static function convertUnderline( $data=array()){
$result = [];
foreach ($data as $key => $item) {
if (is_array($item) || is_object($item)) {
$result[self::underlineToHump($key)] = self::convertUnderline((array)$item);
} else {
$result[self::underlineToHump($key)] = $item;
if($data){
foreach ($data as $key => $item) {
if (is_array($item) || is_object($item)) {
$result[self::underlineToHump($key)] = self::convertUnderline((array)$item);
} else {
$result[self::underlineToHump($key)] = $item;
}
}
}
return $result;
......@@ -434,18 +438,34 @@ class Common
public static function intergrateOneToMany($list1,$list2,$mergekey1,$mergekey2,$listName='orderGoods'){
$mergeArray=array();
$list2key=array();
foreach($list2 as $value){
$list2key[$value[$mergekey2]]=$value;
foreach($list1 as $value){
$list2key[$value[$mergekey1]]=$value;
}
$value[$listName]=array();
foreach($list1 as &$value){
if(isset($list2key[$value[$mergekey1]])&&!empty($list2key[$value[$mergekey1]])){
$value[$listName][]=$list2key[$value[$mergekey1]];
foreach($list2 as &$value){
if(isset($list2key[$value[$mergekey2]])&&!empty($list2key[$value[$mergekey2]])){
$list2key[$value[$mergekey2]][$listName][]=$value;
}
array_push($mergeArray,$value);
}
return $mergeArray;
$orders=array_values($list2key);
return $orders;
}
// //合并一对多列表
// public static function intergrateOneToMany($list1,$list2,$mergekey1,$mergekey2,$listName='orderGoods'){
// $mergeArray=array();
// $list2key=array();
// foreach($list2 as $value){
// $list2key[$value[$mergekey2]]=$value;
// }
// $value[$listName]=array();
// foreach($list1 as &$value){
// if(isset($list2key[$value[$mergekey1]])&&!empty($list2key[$value[$mergekey1]])){
// $value[$listName][]=$list2key[$value[$mergekey1]];
// }
// array_push($mergeArray,$value);
// }
// return $mergeArray;
// }
//合并一对一数组
//合并一对多列表
public static function intergrateOneToOne($list1,$list2,$mergekey1,$mergekey2){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -46,6 +46,9 @@ class SecretKeys {
const expressUrl='https://kdwlcxf.market.alicloudapi.com';
const expressPath='/kdwlcx';
const pushKey='37e9a38cf2983bcdf885e5fd';
const pushSecret='c59868c235bc7ccbe865f9d9';
}
......
......@@ -12,7 +12,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$order = $this->_validate(intval($param['orderId']),$memberId);
//获取订单商品
$orderGoodsDAO =\DAO\Order\OrderGoodsModel::getInstance();
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderGoodsRedisModel::getInstance(),array(&$orderGoodsDAO, 'getOrderGoodsList'),array(array('order_id'=>$order['order_id']),'rec_id,goods_id,goods_commonid,goods_name,goods_image,goods_pay_price,goods_num,goods_spec'),\Our\ApiConst::oneHour);
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderGoodsRedisModel::getInstance(),array(&$orderGoodsDAO, 'getOrderGoodsList'),array(array('order_id'=>$order['order_id']),'rec_id,goods_id,goods_commonid,goods_name,goods_image,goods_pay_price,goods_num,goods_spec'),\Our\ApiConst::tenMinSecond,array($order['order_id']));
if(!$orderGoods){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::orderError);
}
......@@ -45,7 +45,6 @@ class EvaluationServiceModel extends \Business\AbstractModel {
*/
public function submit($data,$memberId){
list($data, $order, $orderGoods) = $this->_submitValite($data,$memberId);
$log = \Our\Log::getInstance();
foreach ($orderGoods as $v){
$orderGoods[$v['goods_id']] = $v;
}
......@@ -205,7 +204,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
//验证订单状态 是否待评价
$orderInstance = \DAO\Order\OrderModel::getInstance();
$orderInstance->setDb(\Our\DbNameConst::masterDBConnectName);
$order = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderInstance, 'find'),array(array('order_id'=>$orderId)),\Our\ApiConst::oneMinSecond,array($orderId));
$order = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderInstance, 'find'),array(array('order_id'=>$orderId)),\Our\ApiConst::tenMinSecond,array($orderId));
if($order['evaluation_state'] != 0 || $order['order_state'] != 40 || $order['buyer_id'] != $memberId){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::orderError);
}
......@@ -218,19 +217,19 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$param['descCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyDescCredit);
$param['deliveryCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyDeliveryCredit);
$param['deliveryCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyServiceCredit);
$log = \Our\Log::getInstance();
$log->write(json_encode($param['goods']));
if(!is_array($param['goods'])) {
$param['goods'] = json_decode($param['goods'],true);
}
$log->write(json_encode($param['goods']));
foreach ($param['goods'] as $v){
$v['goodsId'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyGoodsId);
$v['scores'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyScores);
if(!empty($v['content']) && ( mb_strlen($v['content']) < 6 || mb_strlen($v['content']) > 500 )) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::wrongEvaluation);
}
}
//获取订单商品
$orderGoodsInstance = \DAO\Order\OrderGoodsModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderGoodsRedisModel::getInstance(),array(&$orderGoodsInstance, 'getOrderGoodsList'),array(array('order_id'=>$order['order_id']),'rec_id,goods_id,goods_commonid,goods_name,goods_image,goods_pay_price,goods_num,goods_spec'),\Our\ApiConst::oneMinSecond,array($order['order_id']));
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderGoodsRedisModel::getInstance(),array(&$orderGoodsInstance, 'getOrderGoodsList'),array(array('order_id'=>$order['order_id']),'rec_id,goods_id,goods_commonid,goods_name,goods_image,goods_pay_price,goods_num,goods_spec'),\Our\ApiConst::tenMinSecond,array($order['order_id']));
// $orderGoods = \DAO\OrderGoodsModel::getInstance()->getOrderGoodsList(array('order_id'=>$order['order_id']),'rec_id,goods_id,goods_name,goods_image,goods_pay_price,goods_num');
if(!$orderGoods){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::orderError);
......
......@@ -165,20 +165,13 @@ class MessageServiceModel extends \Business\AbstractModel
public function getList($memberId, $pageIndex = ApiConst::pageIndex, $pageSize = ApiConst::pageSize)
{
$messageOneDao = \DAO\MessageOneModel::getInstance();
$messageHistoryDao=\DAO\MessageHistoryModel::getInstance();
$messageOneList = $messageOneDao->getListByMemberId($memberId, '*', $pageIndex, $pageSize);
foreach ($messageOneList['list'] as &$val) {
$self = $this->getUserByMemberIdAndSelfType($val['fromId'], $val['fromType']);
$toMember = $this->getUserByMemberIdAndSelfType($val['toId'], $val['toType']);
$val['message'] = unserialize($val['message']);
$val['toAvatar'] = $self['avatar'];
foreach($val['message']['buttons'] as &$button){
if($button['type']==ApiConst::messageButtonTypeConfirmButton || $button['type']==ApiConst::messageButtonTypeReciverButton){
$timeDiff=TIMESTAMP-$val['message']['createTime'];
if($timeDiff>(ApiConst::tenMinSecond-ApiConst::oneMinute)){
$button['showType']=ApiConst::messageButtonShowTypeGray;
}
}
}
$val['message'] =$messageHistoryDao->convertMessage($val['message']);
$val['fromAvatar'] = $toMember['avatar'];
// $val['toAvatar']=$this->getAvatar($val['toType'],$val['toId']);
// $val['fromAvatar']=$this->getAvatar($val['fromType'],$val['fromId']);
......@@ -232,8 +225,8 @@ class MessageServiceModel extends \Business\AbstractModel
$returnMemeber['fromAvatar'] = $self['avatar'];
$memberMessages = $messageHistory->getListByMemberIdAndToIdAndToType($memberId, $selfType, $toId, $toType, $field, $pageIndex, $pageSize);
foreach ($memberMessages['list'] as &$val) {
$val['message'] = unserialize($val['message']);
$val['message']['title'] = !empty($val['message']['title']) ? $val['message']['title'] : '';
$val['message'] = $messageHistory->convertMessage($val['message']);
}
$memberMessages['list'] = array_reverse($memberMessages['list']);
$returnMemeber['messages'] = $memberMessages;
......@@ -445,9 +438,9 @@ class MessageServiceModel extends \Business\AbstractModel
return false;
}
}
public function set($memberId,$type){
public function set($memberId,$pushData){
$memberDao=\DAO\MemberModel::getInstance(DbNameConst::masterDBConnectName);
if($memberDao->setIsWxsend($memberId,$type)!==false){
if($memberDao->setIsWxsend($memberId,$pushData)!==false){
return true;
}
return false;
......
......@@ -609,7 +609,7 @@ class OrderServiceModel extends \Business\AbstractModel
$beginTime = file_get_contents($this->baseDir . \Our\PathConst::orderCloseWaitRecieveOrder, TIMESTAMP);
$beginTime = $beginTime ? $beginTime : ApiConst::zero;
$endTime = TIMESTAMP - ApiConst::orderStateWaitConfirmBeyond;
$beginTime=0;
// $beginTime=0;
$orders = $orderDao->getMustCecelRecieveOrders($beginTime, $endTime, $orderDao->getOrderDetailField());
if (!empty($orders)) {
foreach ($orders as $order) {
......
......@@ -338,6 +338,7 @@ class RefundServiceModel extends \Business\AbstractModel
*/
public function addRefund($memberId, $refund)
{
error_reporting(E_ALL);
$refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$refundReasonDao = \DAO\Order\RefundReasonModel::getInstance(DbNameConst::masterDBConnectName);
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
......
......@@ -53,23 +53,28 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// $storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
$orderDao = \DAO\Order\OrderModel::getInstance();
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$memberFavoritesStoreStoreMemberStatisticsDao=\DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance();
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance();
$goodsCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
//$goodsCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsCountByStoreId'), array($storeId), ApiConst::tenDaySecond, array($storeId));
$totalOrderCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$memberFavoritesStoreStoreMemberStatisticsDao, 'getGoodsCountOrderTotalByStoreId'), array($storeId), ApiConst::oneDaySecond, array($storeId));
$condition['store_id'] = $storeId;
//获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::oneDaySecond, array($storeId));
//获取店铺数据统计
//$storeStats = $storeStatisticsDao->find($condition);
//获取店铺今日销售额和订单量
// $storeStats=$orderDao->getShopKeeperCountByStoreId($storeId);
$storeStats = $orderDao->getShopKeeperCountByStoreIdCache($storeId);
$storeFavariteCount = $favoritesStoreDao->getFavoritesCountByStoreIdCache($storeId);
$goodsCount=$totalOrderCount['orderGoodsCount'];
$orderTotal=$totalOrderCount['orderTotal'];
$data['storeId'] = $store['store_id'];
$data['storeName'] = $store['store_name'];
$data['storeLabel'] = $store['store_label'];
$data['goodsCount'] = $goodsCount;
$data['orderCount'] = $storeStats['orderCount'];
$data['orderTotal'] = $storeStats['orderTotal'];
$data['orderTotal'] = $orderTotal;
$data['favCount'] = $storeFavariteCount['favCount'];
$data['todayOrderCount'] = $storeStats['todayOrderCount'];
$data['todayOrderTotal'] = $storeStats['todayOrderTotal'];
......@@ -240,6 +245,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
} else {
$update_data['order_state'] = ApiConst::orderStateWaitSend;
$update_data['accept_time']=TIMESTAMP;
$result = $orderDao->update($where, $update_data);
$orderDao->deleteOrderCache($order['buyer_id'], $orderId, $order['store_id'], true);
// \Our\RedisHelper::memberTotalFromStateToState($order['buyer_id'], $order['order_state'], ApiConst::orderStateWaitSend);
......
......@@ -48,6 +48,14 @@ class StoreServiceModel extends \Business\AbstractModel{
\Redis\Db4\SaleActivityRedisModel::getInstance()->tableDel('storeId:'.$storeId);
}
}
$storeMembers = array();
$storeMember = array();
$storeMember['store_id'] = $storeId;
$storeMember['member_id'] = $memberId;
$storeMember['fav_from'] = \Our\ApiConst::scanFavor;
$storeMembers[] = $storeMember;
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$result = $favoritesStoreDao->insertAll($storeMembers);
}else{
$sess=\Yaf\Session::getInstance();
$scan_store_ids = $sess->get('scan_store_ids');
......
......@@ -76,51 +76,59 @@ class AddressServiceModel extends \Business\AbstractModel {
$sess=\Yaf\Session::getInstance();
$currentAddress = $sess->get('currentAddress');
//if($currentAddress)
if(isset($data['choosedFlag'])&&$data['choosedFlag']){
if((isset($data['choosedFlag'])&&$data['choosedFlag'])){
$chooseFlag = $data['choosedFlag'];
}else if(!$memberId){
$chooseFlag = \Our\ApiConst::one;
}
$returnAddress = array();
if(isset($data['addressId'])&&$data['addressId']){
$returnAddress = $this->setAddressById($data['addressId'],$memberId);
}else if(($data['lng']&&$data['lat']&&$data['cityCode'])){
if(isset($chooseFlag)&&$chooseFlag){
$returnAddress = $this->setCurrentAddress($data,$memberId,$chooseFlag);
}else{
$returnAddress = $this->setCurrentAddress($data,$memberId);
}
}else {
if($currentAddress){
if($currentAddress['addressId']&&$currentAddress['chooseFlag']){
$addresses = array();
if($currentAddress['addressId'] >\Our\ApiConst::zero){
$address['addressId'] = $currentAddress['addressId'];
$address['address'] = $currentAddress['address'];
$address['name'] = $currentAddress['name'];
$address['tagType'] = $currentAddress['tagType'];
$address['lat'] = $currentAddress['lat'];
$address['lng'] = $currentAddress['lng'];
$address['cityCode'] = $currentAddress['cityCode'];
$addresses[] = $address;
}
$returnAddress = array('returnAddressId'=>$currentAddress['addressId'],'choosedAddressFlag'=>$currentAddress['chooseFlag'],'addresses'=>$addresses);
}
if(!$returnAddress){
if(($data['lng']&&$data['lat']&&$data['cityCode'])){
if(isset($chooseFlag)&&$chooseFlag){
$returnAddress = $this->setCurrentAddress($data,$memberId,$chooseFlag);
}else{
$returnAddress = array('returnAddressId'=>$currentAddress['addressId'],'choosedAddressFlag'=>isset($currentAddress['chooseFlag'])&&$currentAddress['chooseFlag']?$currentAddress['chooseFlag']:\Our\ApiConst::zero);
if($memberId){
$myAddresses = $this->getMyCurrentAddressByMemberId($memberId);
if($myAddresses){
$returnAddress['addresses'] = $myAddresses;
$returnAddress = $this->setCurrentAddress($data,$memberId);
}
}else {
if($currentAddress){
if($currentAddress['addressId']&&$currentAddress['chooseFlag']){
$addresses = array();
if($currentAddress['addressId'] >\Our\ApiConst::zero){
$address['addressId'] = $currentAddress['addressId'];
$address['address'] = $currentAddress['address'];
$address['name'] = $currentAddress['name'];
$address['tagType'] = $currentAddress['tagType'];
$address['lat'] = $currentAddress['lat'];
$address['lng'] = $currentAddress['lng'];
$address['cityCode'] = $currentAddress['cityCode'];
$addresses[] = $address;
}
$returnAddress = array('returnAddressId'=>$currentAddress['addressId'],'choosedAddressFlag'=>$currentAddress['chooseFlag'],'addresses'=>$addresses);
}else{
$returnAddress = array('returnAddressId'=>$currentAddress['addressId'],'choosedAddressFlag'=>isset($currentAddress['chooseFlag'])&&$currentAddress['chooseFlag']?$currentAddress['chooseFlag']:\Our\ApiConst::zero);
if($memberId){
$myAddresses = $this->getMyCurrentAddressByMemberId($memberId);
if($myAddresses){
$returnAddress['addresses'] = $myAddresses;
}
}
}
}else{
if(isset($data['choosedFlag'])&&$data['choosedFlag']) {//设置地址时执行到这里属于非法情况
\Error\ErrorModel::throwException(\Error\CodeConfigModel::illegalAccess);
}
$data = \Our\ArrayConst::defaultAddress; //如果没有传任何地址信息,系统提供默认地址
$returnAddress = $this->setCurrentAddress($data,$memberId,$memberId?\Our\ApiConst::zero:\Our\ApiConst::one);
}
}else{
if(isset($data['choosedFlag'])&&$data['choosedFlag']) {//设置地址时执行到这里属于非法情况
\Error\ErrorModel::throwException(\Error\CodeConfigModel::illegalAccess);
}
$data = \Our\ArrayConst::defaultAddress; //如果没有传任何地址信息,系统提供默认地址
$returnAddress = $this->setCurrentAddress($data,$memberId);
}
}
if(isset($data['choosedFlag'])&&$data['choosedFlag']){ //如果调用设置地址接口时,前台不需要弹窗
if((isset($data['choosedFlag'])&&$data['choosedFlag'])||!$memberId){ //如果调用设置地址接口时,前台不需要弹窗
$returnAddress['choosedAddressFlag'] = \Our\ApiConst::one;
}
return $returnAddress;
......@@ -134,9 +142,10 @@ class AddressServiceModel extends \Business\AbstractModel {
if(!$addressId){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::illegalAccess);
}
$address = $this->getMyAddress(array('addressId'=>$addressId),$memberId);
$address = $this->getMyAddress(array('addressId'=>$addressId),$memberId,false);
if(!$address){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::addressNotExist);
//\Error\ErrorModel::throwException(\Error\CodeConfigModel::addressNotExist);
return array();
}
$sess = \Yaf\Session::getInstance();
$newAddress['addressId'] = $address['addressId'];
......@@ -342,10 +351,11 @@ class AddressServiceModel extends \Business\AbstractModel {
* 获取单个收货地址
* @param $where
* @param $memberId
* @param $validFlag 地址不存在是否需要抛出异常
* @return array|bool|mixed
* @throws \Exception
*/
public function getMyAddress($where,$memberId){
public function getMyAddress($where,$memberId,$validFlag = true){
$addressDao = \DAO\AddressModel::getInstance();
$columns = $addressDao->getAddressColumns();
if($where['addressId']){
......@@ -354,7 +364,7 @@ class AddressServiceModel extends \Business\AbstractModel {
$address = \Our\RedisHelper::cachedFunction(\Redis\Db8\AddressRedisModel::getInstance(),array(&$addressDao, 'findByWhereWithColumns'),array($condition,$columns),3600,array($addressId));
//$address = $this->findFromRedis($condition,'han_address','address_id',$columns);
if(!$address||($address&&$address['member_id']!=$memberId)){
if((!$address||($address&&$address['member_id']!=$memberId))&&$validFlag){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::addressNotExist);
}
};
......@@ -413,6 +423,22 @@ class AddressServiceModel extends \Business\AbstractModel {
return $result;
}
public function createPinyin(){
$areaDao =\DAO\AreaModel::getInstance();
$pageSize=1000;
$pageIndex=0;
for($i=$pageIndex;$i<4;$i++){
$pageIndex = $i*$pageSize;
$limit = array($pageIndex,$pageSize);
$areaList = $areaDao->getList($limit);
foreach($areaList as $area){
$updateData = array();
$updateData['pinyin'] = ucfirst(\Our\Pinyin::pinyin($area['area_name']));
$areaDao->update(array('area_id'=>$area['area_id']),$updateData);
}
}
}
/**
* 获取城市列表
* @return bool
......
......@@ -107,7 +107,7 @@ class FootprintServiceModel extends \Business\AbstractModel
$field = 'bl_id AS blId,bl_name AS name,bl_title,store_id,store_name,bl_state,bl_quota_starttime,bl_image,bl_storage,bl_discount_price AS discountPrice,bl_sum_price AS sumPrice,bl_quota_endtime AS endTime,image,is_transport,transport_id';
$pbundlingInstance = \DAO\PBundlingModel::getInstance();
$where2 = ' bl_id in ('.implode(',',$groupIds).')';
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2), \Our\ApiConst::oneMinute);
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2,[],\Our\ApiConst::one), \Our\ApiConst::oneMinute);
if($groupList) {
$dates = array_column($browseList,'browsedate','group_id');
foreach ($groupList as $group) {
......
......@@ -29,10 +29,15 @@ class MemberCenterServiceModel extends \Business\AbstractModel
$memberInfo['diliverymanId'] ? $memberCenter['isDeliveryman'] = 1 : $memberCenter['isDeliveryman'] = 0;
//是否店主
$memberInfo['storeId'] ? $memberCenter['isSeller'] = 1 : $memberCenter['isSeller'] = 0;
if($memberInfo['isWxsend']>=ApiConst::zero){
$memberCenter['canSendMsg']=ApiConst::canSendMsg;
if(!empty($memberInfo['pushSet'])){
$memberInfo['pushSet']=unserialize($memberInfo['pushSet']);
}else{
$memberCenter['canSendMsg']=ApiConst::cannotSendMsg;
$memberInfo['pushSet']=array(
'canPush'=>ApiConst::openMessae,
'sound'=>ApiConst::openMessae,
'vibrate'=>ApiConst::openMessae,
);
}
$memberInfo['storeId'] ? $memberCenter['is'] = 1 : $memberCenter['isSeller'] = 0;
//是否销售员
......@@ -42,8 +47,31 @@ class MemberCenterServiceModel extends \Business\AbstractModel
$sale_act = $saleInstance->getOneByMIdCache($memberId);
$sale_act ? $memberCenter['isSalesman'] = 1 : $memberCenter['isSalesman'] = 0;
$memberCenter['memberMobile'] = \DAO\MemberModel::getInstance()->getInfo($memberId)['memberMobile'];
$memberCenter['canSendMsg']= (int)$memberInfo['pushSet']['canPush'];
$memberCenter['sound']= (int)$memberInfo['pushSet']['sound'];
$memberCenter['vibrate']=(int)$memberInfo['pushSet']['vibrate'];
return $memberCenter;
}
public function getMessageSet($memberId){
$memberInfo = \DAO\MemberModel::getInstance()->getInfo($memberId);
// $pushSet=array();
if(!empty($memberInfo['pushSet'])){
$pushSet=unserialize($memberInfo['pushSet']);
$pushSet=array(
'canPush'=>(int)$pushSet['canPush'],
'sound'=>(int)$pushSet['sound'],
'vibrate'=>(int)$pushSet['vibrate'],
);
}else{
$pushSet=array(
'canPush'=>ApiConst::openMessae,
'sound'=>ApiConst::openMessae,
'vibrate'=>ApiConst::openMessae,
);
}
return $pushSet;
}
public function getStatistics($memberId){
$memebrCenterDb1Redis = \Redis\Db1\MemberCenterRedisModel::getInstance();
$memberCenter = $memebrCenterDb1Redis->tableHGAll($memberId);
......
......@@ -50,6 +50,22 @@ class AreaModel extends \DAO\AbstractModel {
return $result;
}
public function update($where, $data){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
}
public function getList($limit){
$this->setDb($this->dbName);
$this->db->select(\Our\NameConst::allField)->from($this->_tableName);
if($limit){
$this->db->limit($limit[0],$limit[1]);
}
$areaList = $this->db->fetchAll();
return $areaList;
}
public function getCityListWithoutCounty(){
$addressRedis = AddressRedisModel::getInstance();
$cityList = $addressRedis->find('cityListWithoutCounty');
......@@ -60,17 +76,19 @@ class AreaModel extends \DAO\AbstractModel {
$addressRedis->update('allCityListWithoutCounty',$areaList);
$cityListInitial = array();
$cityInitialList = array();
$cityPinyinList = array();
foreach($areaList as $area){
if(isset($area['initial'])&&$area['initial']&&!($cityInitialList&&in_array($area['initial'],$cityInitialList))){
$cityInitialList[] = $area['initial'];
}
$cityListInitial[$area['initial']][] = $area['area_name'];
$cityListInitial[$area['initial']][] =$area['area_name'] ;
$cityPinyinList[$area['initial']][] = array('name'=>$area['area_name'],'pinyin'=>$area['pinyin']);
}
$list = array();
foreach($cityInitialList as $inital){
$initalCity['initial'] = $inital;
$initalCity['list'] = $cityListInitial[$inital];
$initalCity['pinyinList'] = $cityPinyinList[$inital];
$list[] = $initalCity;
}
$addressRedis->update('cityListWithoutCounty',$list);
......@@ -93,11 +111,13 @@ class AreaModel extends \DAO\AbstractModel {
}
$cityListInitial[$area['initial']][] = $area['area_name'];
$cityPinyinList[$area['initial']][] = array('name'=>$area['area_name'],'pinyin'=>$area['pinyin']);
}
$list = array();
foreach($cityInitialList as $inital){
$initalCity['initial'] = $inital;
$initalCity['list'] = $cityListInitial[$inital];
$initalCity['pinyinList'] = $cityPinyinList[$inital];
$list[] = $initalCity;
}
$addressRedis->update('cityList',$list);
......@@ -106,16 +126,13 @@ class AreaModel extends \DAO\AbstractModel {
public function getAllCityList($withoutCounty=false){
$this->setDb($this->dbName);
$sql = " SELECT t1.area_name, t2.f_py as initial FROM han_area t1 ";
$sql .= " left join han_coslers t2 ";
$sql .= " on CONV(HEX(LEFT(CONVERT(t1.area_name USING gbk ), 1)), 16, 10) BETWEEN t2.cbegin AND t2.cend
where t1.is_city=1 ";
$sql = " SELECT t1.area_name,t1.pinyin, LEFT(t1.pinyin,1) as initial FROM han_area t1 ";
$sql .= " where t1.is_city=1 ";
if($withoutCounty){
$sql .= " and t1.area_name not like '%县'";
}
$sql .= " ORDER BY t1.area_deep,convert(t1.area_name using gbk) ASC ";
$sql .= " ORDER BY t1.area_deep,t1.pinyin ASC ";
$area_list = $this->db->query($sql)->rows;
echo $this->db->getLastSql();
return $area_list;
}
......
......@@ -381,7 +381,7 @@ class CouponModel extends \DAO\AbstractModel {
if($coupon['coupon_type'] ==\Our\ApiConst::fullMinusCouponType&&($totalPrice>\Our\ApiConst::zero&&$totalPrice>=$coupon['order_amount'])){ //指定品类满减券
$reliefAmount = $coupon['cash_money'];
}else if($coupon['coupon_type'] ==\Our\ApiConst::discountCouponType&&($totalPrice>=$coupon['order_amount']||$coupon['order_amount']==\Our\ApiConst::zero)){//指定品类折扣券,可能没有订单限制,或有订单金额限制
$reliefAmount = round($totalPrice * $coupon['discount']/\Our\ApiConst::ten,\Our\ApiConst::zero);
$reliefAmount = round($totalPrice * (\Our\ApiConst::ten-$coupon['discount'])/\Our\ApiConst::ten,\Our\ApiConst::zero);
}else if(($coupon['coupon_type']== \Our\ApiConst::fullForCouponCouponType)
&&($totalPrice>\Our\ApiConst::zero&&$totalPrice>=$coupon['order_amount'])){
$reliefAmount = \Our\ApiConst::zero;
......
......@@ -176,6 +176,7 @@ class MemberModel extends \DAO\AbstractModel
'storeId' => (int)$member['store_id'],
'memberAvatarUrl' => $member['memberAvatarUrl'],
'isWxsend'=>$member['is_wxsend'],
'pushSet'=>$member['push_set'],
);
} else {
$member = $this->getOneByMemberId($memberId, '*');
......@@ -197,6 +198,7 @@ class MemberModel extends \DAO\AbstractModel
'storeId' => $member['store_id'],
'memberAvatarUrl' => $member['memberAvatarUrl'],
'isWxsend'=>$member['is_wxsend'],
'pushSet'=>$member['push_set'],
);
foreach ($member as $key => $value) {
if (empty($value) || is_null($value)) {
......@@ -580,13 +582,14 @@ class MemberModel extends \DAO\AbstractModel
$this->changeNum($memberId, $fromState, null, -1);
$this->changeNum($memberId, $toState, null, 1);
}
public function setIsWxsend($memberId,$type){
if(in_array($type,array(ApiConst::closeMessage,ApiConst::openMessae))){
$data['is_wxsend']=$type;
}else{
ErrorModel::throwException(CodeConfigModel::paramsError);
public function setIsWxsend($memberId,$pushData){
foreach($pushData as $val){
if(!in_array($val,array(ApiConst::closeMessage,ApiConst::openMessae))){
ErrorModel::throwException(CodeConfigModel::paramsError);
}
}
if(isset( $data['is_wxsend'])){
$data['push_set']=serialize($pushData);
if(isset( $data['push_set'])){
$res=$this->saveInfo($data,$memberId);
return $res;
}
......
......@@ -83,6 +83,9 @@ class MessageModel extends \DAO\AbstractModel {
$messages['list']=$convertList;
return $messages;
}
/**
* 类实例
*
......
......@@ -92,6 +92,22 @@ class MessageHistoryModel extends \DAO\AbstractModel {
$res=$this->db->insert($this->_tableName)->rows($data)->execute();
return $res;
}
public function convertMessage($message){
$message = unserialize($message);
$message['title'] = !empty($message['title']) ? $message['title'] : '';
if(!empty($message['buttons'])){
foreach($message['buttons'] as &$button){
if($button['type']==ApiConst::messageButtonTypeConfirmButton || $button['type']==ApiConst::messageButtonTypeReciverButton){
$timeDiff=TIMESTAMP-$message['createTime'];
if($timeDiff>(ApiConst::tenMinSecond-ApiConst::oneMinute)){
$button['showType']=ApiConst::messageButtonShowTypeGray;
}
}
}
}
return $message;
}
/**
* 类实例
......
......@@ -124,6 +124,7 @@ class MessageOneModel extends \DAO\AbstractModel {
}
}
/**
* 类实例
*
......
......@@ -409,7 +409,7 @@ class OrderModel extends \DAO\AbstractModel
if(is_array($memberIds)){
$memberIds=implode(',',$memberIds);
}
$where=Common::format(" store_id in({0}) and buyer_id in({1}) and order_state not in({2})",$storeIds,$memberIds,'-1,0');
$where=Common::format(" store_id in({0}) and buyer_id in({1}) and order_state not in({2}) and refund_amount={3}",$storeIds,$memberIds,'-1,0',ApiConst::zero);
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(order_amount)) AS orderTotal")->group('buyer_id')->group('store_id')->fetchAll();
return $res;
}
......@@ -854,6 +854,8 @@ class OrderModel extends \DAO\AbstractModel
}
$this->deleteGetListByMemberId($stroeId);
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
\DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance()->deleteCacheGetGoodsCountOrderTotalByStoreId($stroeId);
$orderGoodsDao->deleteOrderGoodsCache($memberId, $orderId,$stroeId);
}
......
......@@ -46,9 +46,9 @@ class PBundlingModel extends \DAO\AbstractModel {
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1');
$this->db->select($field)->from($this->_tableName)->where($where);
if($isDel==\Our\ApiConst::zero){
$this->db->where('is_del=0');
$this->db->where('is_del=0')->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1');
}
if($limit){
$this->db->limit($limit[0],$limit[1]);
......
......@@ -20,6 +20,7 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* @var string
*/
protected $_tableName = 'han_member-favorites_store-store_member_statistics';
public $sumField='sum(order_total) as orderTotal,sum(order_goods_count) as orderGoodsCount';
public $field="fav_type as favType,member_id as memberId,member_mobile as memberMobile,is_backlist as isBacklist,fav_time as favTime,member_avatar as memberAvatar,member_name as memberName,order_total as orderTotal,order_goods_count as orderGoodsCount";
/**
......@@ -130,7 +131,7 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
}
public function getInfoByMemberId($memberId,$field='*',$isField=false)
{
$this->setDb();
$this->setDb($this->dbName);
$where['member_id'] = $memberId;
$store = $this->db->from($this->_tableName)->select($field)->where($where)->fetchOne();
if ($isField) {
......@@ -139,7 +140,15 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
return $store;
}
}
public function getGoodsCountOrderTotalByStoreId($storeId){
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$res=$this->db->from($this->_tableName)->select($this->sumField)->where($where)->fetchOne();
return $res?$res:[];
}
public function deleteCacheGetGoodsCountOrderTotalByStoreId($storeId){
return \Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getGoodsCountOrderTotalByStoreId'), array(),array($storeId));
}
/**
* 类实例
*
......
......@@ -282,6 +282,7 @@ class CodeConfigModel {
const noEnoughStorageForBundlingGoods = 30118;
const noOrderWaitToPay = 30119;
const wrongEvaluation = 30120;
//店铺相关错误码
//商品分类
......@@ -758,6 +759,7 @@ class CodeConfigModel {
self::goodsNoStoreForCartOrOrder1 => '商品库存紧张,您的购买数量太多啦',
self::noEnoughStorageForBundlingGoods =>'组合销售库存紧张,您购买的数量太多啦',
self::noOrderWaitToPay => '您的订单已支付,请勿重复支付',
self::wrongEvaluation => '商品评论应在6-500字之间',
//销售员
self::emptySaleGoodsId=>'商品id不能为空',
self::emptySaleGoods=>'销售商品不存在',
......
......@@ -9,10 +9,10 @@
</head>
<body>
<form action="/message/get" method="post">
用户登录状态key:<input name="data[key]" value="6d212e880869eb4960cf81700f1369fe"/><br />
接受消息用户ID:<input name="data[toId]" value=""/><br />
接受消息用户类型:<input name="data[toType]" value="1" type="radio" checked/>系统消息 <input type="radio" name="data[toType]" value="2"/>订单消息 <input name="data[toType]" value="3" type="radio" />快递消息 <input type="radio" name="data[toType]" value="4"/>店铺消息 <input type="radio" name="data[toType]" value="5"/>普通消息 <input name="data[toType]" value="6" type="radio" />老师 <br />
自己发送消息的用户类型:<input name="data[fromType]" value=""/> <br />
用户登录状态key:<input name="data[key]" value="fd4b739c4815297044191451eabf0eb5"/><br />
接受消息用户ID:<input name="data[toId]" value="-2"/><br />
接受消息用户类型:<input name="data[toType]" value="1" type="radio" />系统消息 <input type="radio" name="data[toType]" value="2" checked/>订单消息 <input name="data[toType]" value="3" type="radio" />快递消息 <input type="radio" name="data[toType]" value="4"/>店铺消息 <input type="radio" name="data[toType]" value="5"/>普通消息 <input name="data[toType]" value="6" type="radio" />老师 <br />
自己发送消息的用户类型:<input name="data[fromType]" value="4"/> <br />
页码:<input name="data[pageIndex]" value="" /><br/>
每页条数:<input name="data[pageSize]" value="" /><br/>
<input type="submit" value="提交">
......
<!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="/message/getSet" method="post">
用户登录状态key:<input name="data[key]" value="ca44044c38f5a6d06ddd7304e1c7666c"/><br />
<input type="submit" value="提交">
</form>
</body>
</html>
\ No newline at end of file
......@@ -10,8 +10,10 @@
<body>
<form action="/message/set" method="post">
用户登录状态key:<input name="data[key]" value="ca44044c38f5a6d06ddd7304e1c7666c"/><br />
是否 接受消息:<input name="data[type]" value="1"/><br />
是否 接受消息:<input name="data[debug]" value="1"/><br />
是否 接受消息:<input name="data[canPush]" value="1"/><br />
声音消息:<input name="data[sound]" value="1"/><br />
是否震动:<input name="data[vibrate]" value="0"/><br />
debug:<input name="data[debug]" value="1"/><br />
<input type="submit" value="提交">
</form>
......
<?php
/**
* User: liuyuzhen
* Date: 2018/9/26
* Time: 10:15
* Description:
*/
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);
\Business\User\AddressServiceModel::getInstance()->createPinyin();
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