Commit b97b807a authored by liuyuzhen's avatar liuyuzhen

定时器

parent 4515c75b
...@@ -1494,4 +1494,9 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -1494,4 +1494,9 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
} }
public function syncGoodsCommonStorageByGoods(){
$goodsCommonDao = \DAO\GoodsCommonModel::getInstance();
$return = $goodsCommonDao->syncGoodsCommonStorageByGoods();
}
} }
...@@ -1207,6 +1207,11 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -1207,6 +1207,11 @@ class StoreServiceModel extends \Business\AbstractModel{
} }
} }
} }
public function updateStoreTotalDeposit(){
\DAO\StoreModel::getInstance()->updateStoreDeposit();
}
/** /**
*/ */
private static $_instance = null; private static $_instance = null;
......
...@@ -124,6 +124,13 @@ class GoodsCommonModel extends \DAO\AbstractModel { ...@@ -124,6 +124,13 @@ class GoodsCommonModel extends \DAO\AbstractModel {
eval($str); eval($str);
return $data; return $data;
} }
public function syncGoodsCommonStorageByGoods(){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$sql =" update han_goods_common t set t.goods_storage = (select sum(a.goods_storage) from han_goods a where a.goods_commonid = t.goods_commonid)";
return $this->db->update($this->_tableName)->query($sql);
}
/** /**
* 商品列表(需要获取销售价格) * 商品列表(需要获取销售价格)
* @param $where * @param $where
......
...@@ -173,6 +173,14 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -173,6 +173,14 @@ class PBundlingModel extends \DAO\AbstractModel {
$pBundlingDao->tableDelAll($pBundlingDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId)); $pBundlingDao->tableDelAll($pBundlingDao->tableKeys('*'.\Our\NameConst::blGoods.$goodsCommonId));
} }
public function delPBundlingListByStoreIdAndBlIds($storeId,$blId){
\Our\RedisHelper::delCachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$this, 'getList'),array(),array('*'.$blId.'*'));
\Our\RedisHelper::delCachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$this, 'getList'),array(),array($storeId));
$cartRedis = \Redis\Db7\CartRedisModel::getInstance();
$memberCartKey = \Our\NameConst::memberStoreCartsPrefix.'*_'.$storeId;
$cartRedis->tableDelAll($cartRedis->tableKeys($memberCartKey));
}
/** /**
* 类实例 * 类实例
* *
......
...@@ -57,6 +57,16 @@ class StoreModel extends \DAO\AbstractModel ...@@ -57,6 +57,16 @@ class StoreModel extends \DAO\AbstractModel
return $res; return $res;
} }
public function updateStoreDeposit(){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$addKey=\Our\Common::getConfig('password.key');
$storeDepositSql = 'update han_store_extend t set t.total_deposit = (SELECT max(a.deposit) from han_qm_store_class a where a.store_id = t.store_id and a.class_style =2 and a.is_charged =1), t.total_deposit_sign = MD5(CONCAT(t.gmt_create,(SELECT max(a.deposit) from han_qm_store_class a where a.store_id = t.store_id and a.class_style =2 and a.is_charged =1),\''.$addKey.'\'))';
$result = $this->db->update($this->_tableNameFull)->query($storeDepositSql);
$emptyDepositSql = 'update han_store_extend t set t.total_deposit_sign =\'\' where t.total_deposit = 0';
$resultEmpty = $this->db->update($this->_tableNameFull)->query($emptyDepositSql);
return $result&&$resultEmpty;
}
/** /**
* 获取店铺信息 * 获取店铺信息
* @param $where * @param $where
......
<?php
/**
* 修改goodsCommon表的缓存保证和goods表的总和一致.
* User: liuyu
* Date: 2018/12/7
* Time: 20:06
*/
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 cliSyncGoodsStorage 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 syncGoodsCommonStorageByGoods(){
\Business\Goods\GoodsCommonServiceModel::getInstance()->syncGoodsCommonStorageByGoods();
}
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('syncGoodsStorage');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .'.locks';
var_dump($this->lockFileName);
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 24*60*60*2 )
{
echo "文件被锁超过2天,被强制删除";
@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->syncGoodsCommonStorageByGoods();
echo 'goodsCommon库存更新成功'."\r\n";
}
}
$oCli = new cliSyncGoodsStorage(TRUE);
EXIT;
?>
\ No newline at end of file
<?php
/**
* 更新店铺总保证金
* User: liuyuzhen
* Date: 2018/12/07
* Time: 15:00
* 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);
class cliUpdateStoreTotalDeposit 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 updateStoreTotalDeposit(){
\Business\Store\StoreServiceModel::getInstance()->updateStoreTotalDeposit();
}
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('updateStoreTotalDeposit');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .'.locks';
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 24*60*60*2 )
{
echo "文件被锁超过2天,被强制删除";
@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->updateStoreTotalDeposit();
echo '店铺总保证金更新成功'."\r\n";
}
}
$oCli = new cliUpdateStoreTotalDeposit(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