Commit 4bac56c9 authored by zhz's avatar zhz

定时器

parent d4dffb39
...@@ -42,7 +42,7 @@ class GoodsController extends \Our\Controller_AbstractIndex { ...@@ -42,7 +42,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()->signedClassExpireInform();
} }
public function getAttrsAction(){ public function getAttrsAction(){
......
...@@ -89,7 +89,21 @@ class SmsTemplateConst{ ...@@ -89,7 +89,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;
}
} }
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级 define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
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 '发送成功';
\ No newline at end of file
<?php
/**
* 签约分类快到期通知
* 执行时间:每天9:00
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/common.php';
\Business\Store\StoreServiceModel::getInstance()->signedClassExpireInform();
echo '执行成功';
<?php
/**
* 试用快到期通知
* 执行时间:每天9:00
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/common.php';
\Business\Store\StoreServiceModel::getInstance()->tryExpireInform();
echo '执行成功';
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