Commit 15035075 authored by zhz's avatar zhz

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

parents 487f83e6 2e4fd0e5
......@@ -30,6 +30,7 @@ class PathConst {
const cutVertical='|';
//统计store_member_statistic表最后更新时间
const orderGoodsCreateTime="/orderGoodsCreateTime.conf";
const orderLastCreateTime="/orderLastCreateTime.conf";
const favoritesStoreFavTimeConf="/favoritesStoreFavTime.conf";
const orderPaymentTimeConf="/orderPaymentTime.conf";
......
......@@ -118,7 +118,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$whereSql = ' coupon_state ='.\Our\ApiConst::couponUnused.' and member_id ='.$memberId.' and out_time > '.time();
$memberCoupons = $memberCouponDao->getList($whereSql);
}else{//不允许领用多张的优惠券
$memberCoupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(array('coupon_id'=>$where['couponId'],'member_id'=>$memberId)),\Our\ApiConst::oneHour);
$memberCoupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(array('coupon_id'=>$where['couponId'],'member_id'=>$memberId)),\Our\ApiConst::oneHour,array($where['couponId']));
}
if($memberCoupons&&count($memberCoupons)>0){
$result['isGet'] = \Our\ApiConst::one;
......@@ -167,6 +167,8 @@ class CouponServiceModel extends \Business\AbstractModel{
return true;
}
public function receiveCouponBatch($coupons,$memberId,$orderId=\Our\ApiConst::zero){
$dbName = \Our\DbNameConst::masterDBConnectName;
$couponDao = \DAO\Coupon\CouponModel::getInstance($dbName);
......@@ -256,7 +258,7 @@ class CouponServiceModel extends \Business\AbstractModel{
public function getStorePromotionCouponTitles($where){
$this->validCouponStore($where);
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponTitles = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array($where['storeId']),\Our\ApiConst::oneHour);
$couponTitles = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array($where['storeId']),\Our\ApiConst::oneHour,array($where['storeId']));
return $couponTitles;
}
......@@ -266,7 +268,7 @@ class CouponServiceModel extends \Business\AbstractModel{
public function getStoreCoupons($where,$memberId = null){
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponDao->validStoreCouponParam($where);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId),\Our\ApiConst::oneHour);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId),\Our\ApiConst::oneHour,array($where['storeId']));
if($couponList){
$couponList = array_values($couponList);
}
......@@ -277,7 +279,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$this->validCouponStore($where);
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$couponDao->validStoreCouponParam($where);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId,true),\Our\ApiConst::oneHour);
$couponList = \Our\RedisHelper::cachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array($where['storeId'],$memberId,true),\Our\ApiConst::oneHour,array($where['storeId']));
if($couponList){
$couponList = array_values($couponList);
if(count($couponList)>=\Our\ApiConst::defaultCouponTitleLength){
......@@ -356,6 +358,22 @@ class CouponServiceModel extends \Business\AbstractModel{
return $couponList;
}
/**
* 删除店铺优惠券缓存
* @param $storeId 店铺ID
* @param bool $couponId 指定优惠券ID
* @throws \Our\Exception
*/
public function deleteCouponCache($storeId,$couponId=false){
$couponDao = \DAO\Coupon\CouponModel::getInstance();
$memberCouponDao = \DAO\Coupon\MemberCouponModel::getInstance();
if($couponId){
\Our\RedisHelper::delCachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array(),array($couponId));
}
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$couponDao, 'getStorePromotionCouponList'),array(),array($storeId));
\Our\RedisHelper::delCachedFunction(\Redis\Db13\CouponRedisModel::getInstance(), array(&$this, 'getStoreCouponsById'),array(),array($storeId));
}
/**
* 类实例
*/
......
......@@ -333,6 +333,18 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
return $adv;
}
/**
* 删除店铺分类顶部缓存
* @param $gcId
* @param $storeId
*/
public function deleteStoreTopClassAdvsFromCache($storeId,$gcId){
$goodsClassImageDao = \DAO\Adv\GoodsClassImageModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db9\GoodsClassImageRedisModel::getInstance(),array(&$this, 'getStoreTopClassAdvs'),array($storeId,$gcId));
\Our\RedisHelper::delCachedFunction(\Redis\Db9\GoodsClassImageRedisModel::getInstance(),array(&$goodsClassImageDao, 'find'),array(array('store_id'=>$storeId,'gc_id'=>$gcId)));
}
public function getStoreTopClassAdvs($storeId,$gcId){
$goodsClassImage = \DAO\Adv\GoodsClassImageModel::getInstance()->findByStoreIdAndGcId($storeId,$gcId);
$adv['isSwiper'] = \Our\ApiConst::zero;
......
......@@ -240,7 +240,7 @@ class OrderServiceModel extends \Business\AbstractModel
if($res){
if ($memberId) {
$orderDao->deleteOrderCache($memberId, $orderId);
$memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
// $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
}
}
return $res;
......
......@@ -468,6 +468,52 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}while($storeMemberStatisticData);
file_put_contents($this->baseDir . PathConst::orderGoodsCreateTime, TIMESTAMP);
}
//创建索引
public function createOrdersIndex()
{
$orderGoodDao=\DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderLastCreateTime);
$gmtCreate = !empty($gmtCreate)?$gmtCreate:ApiConst::zero;
$beginTime=$gmtCreate;
$this->taskIndex=PageConst::taskPageBegin;
$this->taskSize=PageConst::taskPageSize;
do{
$addDatas=array();
$where['add_time']=Common::format(" add_time>={0} and add_time<",$beginTime,TIMESTAMP);
$orders=$orderDao->getList($where, $orderDao->_primaryKey, $this->taskIndex, $this->taskSize, $orderField = 'add_time', $sort = 'desc');
if(!empty($orders['list'])){
$orderIds=array_column($orders['list'],$orderDao->_primaryKey);
$resultOrders=array();
foreach($orders as $order){
}
}
$storeMemberStatisticData= $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime,$this->taskIndex,$this->taskSize);
$storeMemberStatisticData=isset($storeMemberStatisticData['list'])?$storeMemberStatisticData['list']:false;
if($storeMemberStatisticData){
$this->taskIndex++;
foreach($storeMemberStatisticData as $value){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['storeId']=$value['storeId'];
$addDatas[$value['buyerId'].'-'.$value['storeId']]['memberId']=$value['buyerId'];
if(isset($addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount'])){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount']+=$value['goodsNum'];
}else{
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount']=$value['goodsNum'];
}
if(isset($addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal'])){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal']+=$value['goodsPrice'];
}else{
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal']=$value['goodsPrice'];
}
}
}
$addDatas=array_values($addDatas);
$storeMemberStatisticDao->addAll($addDatas);
}while($orders);
file_put_contents($this->baseDir . PathConst::orderLastCreateTime, TIMESTAMP);
}
public function reduceRefundModel($storeMemberDatas){
$convertStoreMember=array();
......
......@@ -881,6 +881,18 @@ class StoreServiceModel extends \Business\AbstractModel{
$gc_names = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsClassImageRedisModel::getInstance(),array(&$this, 'getRecommendClass'),array($storeId),\Our\ApiConst::oneDaySecond,array($storeId));
return $gc_names;
}
/**
* 删除首页店铺及分类缓存
* @param $cityCode
*/
public function deleteStoreAndStoreClassCacheByCitycode($cityCode){
\DAO\QmStoreClassModel::getInstance()->delStoreClassesCache($cityCode);
$storeDao = \DAO\StoreModel::getInstance();
$storeDao->delNearbyStoresCache($cityCode);
$storeDao->delStoresCacheByCityCode($cityCode);
}
/**
*/
private static $_instance = null;
......
......@@ -394,6 +394,7 @@ class CouponModel extends \DAO\AbstractModel {
return false;
}
/**
* 满额赠礼品券
* @param $coupon
......
......@@ -32,7 +32,7 @@ class OrderModel extends \DAO\AbstractModel
*
* @var string
*/
protected $_primaryKey = 'order_id';
public $_primaryKey = 'order_id';
public $errorMessage;
public function init()
......@@ -300,7 +300,7 @@ class OrderModel extends \DAO\AbstractModel
$where = $this->db->getSqlWhereByArray($where);
}
$orders = $this->lists($where, $order, $field, $pageIndex, $pageSize);
return $orders ? $orders : array();
return $orders['list'] ? $orders : array();
}
//待收货获取订单状态信息
......@@ -843,6 +843,8 @@ class OrderModel extends \DAO\AbstractModel
public function getCancelUnpayedOrderTimeCache(){
$res=\Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
echo 'abcd'.json_encode($res);
return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
}
......
This diff is collapsed.
<?php
namespace DAO\Storage;
class GoodsImagesStorageModel extends \DAO\AbstractModel {
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_goods_images_storage';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'goods_image_id';
public function init(){
}
public function getListByCommonId($goodsCommonId,$field){
$this->setDb();
return $this->db->select($field)->from($this->_tableName)->where(array('goods_commonid'=>$goodsCommonId))->fetchAll();
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private static $_instance = null;
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
This diff is collapsed.
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE);
class cliGrow extends basecli
{
const CLI_ADMIN_ID = 255;
private $bDoUnLock = FALSE; // 是否允许释放 LOCK 文件
private $_debug = 0;
private $lockFileName;
public $key='';
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 _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('shopkeeper');
if (!$this->mkdirs($lockDir)) {
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir . DS . 'grow.locks';
if (file_exists($this->lockFileName)) {
$stat = stat($this->lockFileName);
if ((TIMESTAMP - $stat['mtime']) > 1800) {
echo "文件被锁超过1800秒,被强制删除";
@unlink($this->lockFileName);
} else {
$this->halt('[' . date('Y-m-d H:i:s') . '] The CLI is running' . "\n");
}
}
$this->bDoUnLock = true;
file_put_contents($this->lockFileName, "running"); // CLI 独占锁
$goodsCommonStrorageDao = \DAO\Storage\GoodsCommonStorageModel::getInstance();
$goodsStorageDao = \DAO\Storage\GoodsStorageModel::getInstance();
$goodsImagesStorageDao = \DAO\Storage\GoodsImagesStorageModel::getInstance();
try {
$goodsCommonStrorageDao->createTestData();
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
}
echo '店铺订单索引生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
}
$oCli = new cliGrow(TRUE);
EXIT;
?>
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE);
class cliShopkeeperOrders extends basecli
{
const CLI_ADMIN_ID = 255;
private $bDoUnLock = FALSE; // 是否允许释放 LOCK 文件
private $_debug = 0;
private $lockFileName;
public $key='';
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 _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('shopkeeper');
if (!$this->mkdirs($lockDir)) {
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir . DS . 'orders.locks';
if (file_exists($this->lockFileName)) {
$stat = stat($this->lockFileName);
if ((TIMESTAMP - $stat['mtime']) > 1800) {
echo "文件被锁超过1800秒,被强制删除";
@unlink($this->lockFileName);
} else {
$this->halt('[' . date('Y-m-d H:i:s') . '] The CLI is running' . "\n");
}
}
$this->bDoUnLock = true;
file_put_contents($this->lockFileName, "running"); // CLI 独占锁
$shopkeeperService = \Business\Store\ShopkeeperServiceModel::getInstance();
$shopkeeperService->baseDir= \Our\Common::getConfig('out.config');
try {
$shopkeeperService->createOrdersIndex();
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
}
echo '店铺订单索引生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
}
$oCli = new cliShopkeeperOrders(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