Commit 42768e47 authored by wwccw0591's avatar wwccw0591

pc

parent 6d4fa08a
...@@ -30,6 +30,7 @@ class PathConst { ...@@ -30,6 +30,7 @@ class PathConst {
const cutVertical='|'; const cutVertical='|';
//统计store_member_statistic表最后更新时间 //统计store_member_statistic表最后更新时间
const orderGoodsCreateTime="/orderGoodsCreateTime.conf"; const orderGoodsCreateTime="/orderGoodsCreateTime.conf";
const orderLastCreateTime="/orderLastCreateTime.conf";
const favoritesStoreFavTimeConf="/favoritesStoreFavTime.conf"; const favoritesStoreFavTimeConf="/favoritesStoreFavTime.conf";
const orderPaymentTimeConf="/orderPaymentTime.conf"; const orderPaymentTimeConf="/orderPaymentTime.conf";
......
...@@ -240,7 +240,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -240,7 +240,7 @@ class OrderServiceModel extends \Business\AbstractModel
if($res){ if($res){
if ($memberId) { if ($memberId) {
$orderDao->deleteOrderCache($memberId, $orderId); $orderDao->deleteOrderCache($memberId, $orderId);
$memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel); // $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
} }
} }
return $res; return $res;
......
...@@ -468,6 +468,52 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -468,6 +468,52 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}while($storeMemberStatisticData); }while($storeMemberStatisticData);
file_put_contents($this->baseDir . PathConst::orderGoodsCreateTime, TIMESTAMP); 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){ public function reduceRefundModel($storeMemberDatas){
$convertStoreMember=array(); $convertStoreMember=array();
......
...@@ -32,7 +32,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -32,7 +32,7 @@ class OrderModel extends \DAO\AbstractModel
* *
* @var string * @var string
*/ */
protected $_primaryKey = 'order_id'; public $_primaryKey = 'order_id';
public $errorMessage; public $errorMessage;
public function init() public function init()
...@@ -300,7 +300,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -300,7 +300,7 @@ class OrderModel extends \DAO\AbstractModel
$where = $this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
} }
$orders = $this->lists($where, $order, $field, $pageIndex, $pageSize); $orders = $this->lists($where, $order, $field, $pageIndex, $pageSize);
return $orders ? $orders : array(); return $orders['list'] ? $orders : array();
} }
//待收货获取订单状态信息 //待收货获取订单状态信息
......
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