Commit 08d0088b authored by liuyuzhen's avatar liuyuzhen

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

parents 10a09617 85f90c9f
...@@ -43,7 +43,7 @@ class GoodsController extends \Our\Controller_AbstractIndex { ...@@ -43,7 +43,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
public function testAction(){ public function testAction(){
//$info = $this->goodsService->recommend(); //$info = $this->goodsService->recommend();
//\Business\Goods\GoodsCommonServiceModel::getInstance()->saleGoods(); //\Business\Goods\GoodsCommonServiceModel::getInstance()->saleGoods();
\Business\Store\StoreServiceModel::getInstance()->pendingItemsInform(); \Business\Store\StoreServiceModel::getInstance()->tryExpireInform();
} }
public function getAttrsAction(){ public function getAttrsAction(){
......
...@@ -88,7 +88,21 @@ class SmsTemplateConst{ ...@@ -88,7 +88,21 @@ class SmsTemplateConst{
'storeCount', 'storeCount',
'weiCount' 'weiCount'
) )
),
//尊敬的${storename},您的店铺试用期将于{limitday}天后到期,请及时登录商户后台进行注册信息核对。为了您继续享有独家推荐权,请及时缴纳保证金及相应的签约分类技术服务费。
'tryExpire'=> array(
'templateId'=>'SMS_154585403',
'parameters'=>array(
'storename',
'limitday'
)
),
//尊敬的${storename},您的店铺存在即将到期的签约分类,请及时登录商户后台续费,以免过期,过期后需重新申请。
'signClassExpire'=> array(
'templateId'=>'SMS_154590436',
'parameters'=>array(
'storename'
)
) )
); );
} }
...@@ -1230,6 +1230,10 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -1230,6 +1230,10 @@ class StoreServiceModel extends \Business\AbstractModel{
public function updateStoreTotalDeposit(){ public function updateStoreTotalDeposit(){
\DAO\StoreModel::getInstance()->updateStoreDeposit(); \DAO\StoreModel::getInstance()->updateStoreDeposit();
} }
/**
* 待办事务通知
*/
public function pendingItemsInform() { public function pendingItemsInform() {
$storePaymentDao = \DAO\Store\StorePaymentModel::getInstance(); $storePaymentDao = \DAO\Store\StorePaymentModel::getInstance();
$weiCount = $storePaymentDao->getStorePaymentCount(array('payment_type'=>0,'status'=>0)); $weiCount = $storePaymentDao->getStorePaymentCount(array('payment_type'=>0,'status'=>0));
...@@ -1239,6 +1243,47 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -1239,6 +1243,47 @@ class StoreServiceModel extends \Business\AbstractModel{
$phone = $settingDAO->getListCache(array('pending_items_inform_tel'))['pending_items_inform_tel']; $phone = $settingDAO->getListCache(array('pending_items_inform_tel'))['pending_items_inform_tel'];
\DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($phone,'storeWaitCheck',array('storeCount'=>$storeCount,'weiCount'=>$weiCount)); \DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($phone,'storeWaitCheck',array('storeCount'=>$storeCount,'weiCount'=>$weiCount));
} }
/**
* 试用快到期通知
*/
public function tryExpireInform() {
$storeList = \DAO\StoreModel::getInstance()->getTryExpireStore();
if($storeList) {
foreach ($storeList as $store) {
if( TIMESTAMP+9*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+10*24*3600) {
$limitday = 10;
}elseif (TIMESTAMP+4*24*3600<$store['store_end_time'] and $store['store_end_time'] <= TIMESTAMP+5*24*3600) {
$limitday = 5;
}else{
$limitday = 3;
}
\DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($store['store_phone'],'tryExpire',array('storename'=>$store['store_name'],'limitday'=>$limitday));
}
}
}
/**
* 签约分类快到期通知
*/
public function signedClassExpireInform() {
$classList = \DAO\QmStoreClassModel::getInstance()->selectByWhere(array('is_charged'=>1,'deadline'=>array('between',TIMESTAMP+2*24*3600+1,TIMESTAMP+3*24*3600),'class_style'=>2),'deadline,store_id');
if($classList) {
$storeIds = array_column($classList,'store_id');
$storeFullList = \DAO\StoreModel::getInstance()->getStoreFullList(array('store_id'=>array('in',$storeIds)),'contract_time,store_id,store_phone,store_name');
$list = \Our\Common::intergrateOneToOne($classList,$storeFullList,'store_id','store_id');
foreach ($list as $v) {
$deadline = $v['deadline'];
$contarct_time = $v['contract_time'];
if($deadline<$contarct_time){
$maxSignEndTime = mktime(0,0,0,date('m',$contarct_time),1,date('Y',$contarct_time))-1;
if($maxSignEndTime==$deadline){
continue;
}
\DAO\ShortMessageModel::getInstance()->sendMessageSmsForPlatform($v['store_phone'],'signClassExpire',array('storename'=>$v['store_name']));
}
}
}
}
/** /**
*/ */
private static $_instance = null; private static $_instance = null;
......
...@@ -113,7 +113,14 @@ class StoreModel extends \DAO\AbstractModel ...@@ -113,7 +113,14 @@ class StoreModel extends \DAO\AbstractModel
return $store; return $store;
} }
} }
public function getStoreFullList($where, $field) {
$this->setDb($this->dbName);
if(is_array($where)) {
$where = $this->db->getSqlWhereByArray($where);
}
$result = $this->db->from($this->_tableNameFull)->select($field)->where($where)->fetchAll();
return $result;
}
public function getInfoByMemberId($memberId, $field = '*', $isField = false, $db = DbNameConst::salveDBConnectName) public function getInfoByMemberId($memberId, $field = '*', $isField = false, $db = DbNameConst::salveDBConnectName)
{ {
$this->setDb($db); $this->setDb($db);
...@@ -627,4 +634,14 @@ class StoreModel extends \DAO\AbstractModel ...@@ -627,4 +634,14 @@ class StoreModel extends \DAO\AbstractModel
} }
return array('mchId'=>$mchId,'errorCode'=>$errorCode); return array('mchId'=>$mchId,'errorCode'=>$errorCode);
} }
/**
* 获取试用期快到期的店铺
*/
public function getTryExpireStore() {
$this->setDb($this->dbName);
$sql = "SELECT store.store_id,store.store_end_time,store.store_phone,store.store_name FROM han_store store LEFT JOIN han_store_class_pay_log store_class_pay_log on store.store_id = store_class_pay_log.store_id where ((unix_timestamp(now())+9*24*3600) < store.store_end_time and store.store_end_time <= (unix_timestamp(now())+10*24*3600) ) or ((unix_timestamp(now())+2*24*3600) < store.store_end_time and store.store_end_time <= (unix_timestamp(now())+3*24*3600) ) or ((unix_timestamp(now())+4*24*3600) < store.store_end_time and store.store_end_time <= (unix_timestamp(now())+5*24*3600) ) and store_class_pay_log.id IS NULL";
$query = $this->db->query($sql);
return $query->rows;
}
} }
...@@ -8,3 +8,4 @@ define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向 ...@@ -8,3 +8,4 @@ define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向
require APPLICATION_PATH . '/scripts/crontab/common.php'; require APPLICATION_PATH . '/scripts/crontab/common.php';
\Business\Store\StoreServiceModel::getInstance()->pendingItemsInform(); \Business\Store\StoreServiceModel::getInstance()->pendingItemsInform();
echo '发送成功'; echo '发送成功';
<?php
/**
* 签约分类快到期通知
* 执行时间:每天9:00
*/
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 cliSaleOrder 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 signedClassExpireInform(){
\Business\Store\StoreServiceModel::getInstance()->signedClassExpireInform();
}
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('store');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .'/signedClassExpireInform.locks';
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 3600 )
{
echo "文件被锁超过3600秒,被强制删除";
@unlink($this->lockFileName);
}
else
{
$this->halt( '[' . date('Y-m-d H:i:s') .'] The CLI is running'."\n");
}
}
$this->bDoUnLock = true;
file_put_contents($this->lockFileName ,"running" ); // CLI 独占锁
$this->signedClassExpireInform();
echo '签约分类到期短信发送成功'."\r\n";
}
}
$oCli = new cliSaleOrder(TRUE);
EXIT;
<?php
/**
* 试用快到期通知
* 执行时间:每天9:00
*/
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 cliSaleOrder 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 tryExpireInform(){
\Business\Store\StoreServiceModel::getInstance()->tryExpireInform();
}
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('store');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .'/tryExpireInform.locks';
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 3600 )
{
echo "文件被锁超过3600秒,被强制删除";
@unlink($this->lockFileName);
}
else
{
$this->halt( '[' . date('Y-m-d H:i:s') .'] The CLI is running'."\n");
}
}
$this->bDoUnLock = true;
file_put_contents($this->lockFileName ,"running" ); // CLI 独占锁
$this->tryExpireInform();
echo '试用到期短信发送成功'."\r\n";
}
}
$oCli = new cliSaleOrder(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