Commit 58e18cb9 authored by liuyuzhen's avatar liuyuzhen

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

parents 1a73e5da c9b22e02
...@@ -15,7 +15,7 @@ class GoodsController extends \Our\Controller_AbstractIndex { ...@@ -15,7 +15,7 @@ class GoodsController extends \Our\Controller_AbstractIndex {
public function getAction(){ public function getAction(){
$address = \Business\User\AddressServiceModel::getInstance()->getMyAddress($this->req[\Our\NameConst::data],$this->memberId,false); $address = \Business\User\AddressServiceModel::getInstance()->getMyAddress($this->req[\Our\NameConst::data],$this->memberId,false);
$goodsInfo = $this->goodsService->getCommonDetail($this->req[\Our\NameConst::data],$this->memberId,$address); $goodsInfo = $this->goodsService->getCommonDetail($this->req[\Our\NameConst::data],$this->memberId,$address);
$store = $this->goodsService->getStore($goodsInfo['storeId'],false,false); $store = $this->goodsService->getStore($goodsInfo['storeId'],false);
$goodsInfo['freeShippingPrice'] = $store['freeShippingPrice']; $goodsInfo['freeShippingPrice'] = $store['freeShippingPrice'];
$goodsInfo['isQuality'] = $store['isQuality']; $goodsInfo['isQuality'] = $store['isQuality'];
$evaluation =$this->goodsService->getEvaluation($this->req[\Our\NameConst::data]); $evaluation =$this->goodsService->getEvaluation($this->req[\Our\NameConst::data]);
......
...@@ -23,7 +23,7 @@ class GroupController extends \Our\Controller_AbstractIndex { ...@@ -23,7 +23,7 @@ class GroupController extends \Our\Controller_AbstractIndex {
$goods = $this->GroupSaleService->getGroupGoods($this->req[\Our\NameConst::data],$address); $goods = $this->GroupSaleService->getGroupGoods($this->req[\Our\NameConst::data],$address);
// $data = $this->GroupSaleService->getOnePBundingCache($this->req[\Our\NameConst::data]['groupId']); // $data = $this->GroupSaleService->getOnePBundingCache($this->req[\Our\NameConst::data]['groupId']);
// $this->GroupSaleService->handleData($data); // $this->GroupSaleService->handleData($data);
$storeInfo = \Business\Goods\GoodsCommonServiceModel::getInstance()->getStore($goods['store_id'],false,false); $storeInfo = \Business\Goods\GoodsCommonServiceModel::getInstance()->getStore($goods['store_id'],false);
unset($storeInfo['freeShippingPrice']);unset($storeInfo['isQuality']);unset($storeInfo['shareDesc']); unset($storeInfo['freeShippingPrice']);unset($storeInfo['isQuality']);unset($storeInfo['shareDesc']);
$otherGroups = \Business\Goods\GroupSaleServiceModel::getInstance()->getOtherGroup($goods['store_id'],$this->req[\Our\NameConst::data]['groupId']); $otherGroups = \Business\Goods\GroupSaleServiceModel::getInstance()->getOtherGroup($goods['store_id'],$this->req[\Our\NameConst::data]['groupId']);
\Business\Goods\GroupSaleServiceModel::getInstance()->addBrowseRecord($this->req[\Our\NameConst::data],$this->memberId); \Business\Goods\GroupSaleServiceModel::getInstance()->addBrowseRecord($this->req[\Our\NameConst::data],$this->memberId);
......
...@@ -49,6 +49,7 @@ class PathConst { ...@@ -49,6 +49,7 @@ class PathConst {
const orderCloseWaitRecieveOrder="/orderCloseWaitRecieveOrder.conf"; const orderCloseWaitRecieveOrder="/orderCloseWaitRecieveOrder.conf";
const goodsStatTime="/goodsStat.conf"; const goodsStatTime="/goodsStat.conf";
const goodsSellStatTime="/goodsSellStat.conf"; const goodsSellStatTime="/goodsSellStat.conf";
const storeStatTime="/storeStat.conf";
const orderCancelTime="/orderCancelTime.conf"; const orderCancelTime="/orderCancelTime.conf";
......
...@@ -744,8 +744,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -744,8 +744,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
* @return array * @return array
* @throws \Our\Exception * @throws \Our\Exception
*/ */
public function getStore($storeId){ public function getStore($storeId, $label = false){
list($storeInfo,$label) = \DAO\StoreModel::getInstance()->get($storeId); $storeInfo = \DAO\StoreModel::getInstance()->get($storeId,$label);
$commonInstance = \DAO\GoodsCommonModel::getInstance(); $commonInstance = \DAO\GoodsCommonModel::getInstance();
$count = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonInstance, 'getCount'),array(array('store_id'=>$storeId)),\Our\ApiConst::oneDaySecond); $count = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonInstance, 'getCount'),array(array('store_id'=>$storeId)),\Our\ApiConst::oneDaySecond);
......
...@@ -956,7 +956,7 @@ class RefundServiceModel extends \Business\AbstractModel ...@@ -956,7 +956,7 @@ class RefundServiceModel extends \Business\AbstractModel
} }
} }
} else { } else {
$refundAmount = $orderGoods['goodsPrice']; $refundAmount = $orderGoods['goodsPrice']*$orderGoods['goodsNum'];
} }
$returnData['refundAmount'] = $refundAmount - $orderInfo['refundAmount'] - $returnData['needShippingFee'] + $shippingFee; $returnData['refundAmount'] = $refundAmount - $orderInfo['refundAmount'] - $returnData['needShippingFee'] + $shippingFee;
// if($orderGoods['goodsType']==ApiConst::goodsTypeFour){ // if($orderGoods['goodsType']==ApiConst::goodsTypeFour){
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Business\Store; namespace Business\Store;
use Our\ApiConst; use Our\ApiConst;
use Our\DbNameConst;
/** /**
* 店铺service * 店铺service
...@@ -16,6 +17,58 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -16,6 +17,58 @@ class StoreServiceModel extends \Business\AbstractModel{
} }
/**
* 更新店铺分布数据
* @return bool
* User: King <358887571@qq.com>
* Date: 2018/11/30 0030
* Time: 下午 4:27
*/
public function updateStatStore(){
$beginTime = file_get_contents($this->baseDir . \Our\PathConst::storeStatTime, TIMESTAMP);
$beginTime = $beginTime ? $beginTime : ApiConst::zero;
$endTime = TIMESTAMP;
$where = 'store_id in (select ss.store_id from han_stat_store ss) and store_id in (select se.store_id from han_store_extend se where se.gmt_update > '.$beginTime.' ) and store_id in (select qs.store_id from han_qm_store_class qs where qs.gmt_update > '.$beginTime.' or (qs.deadline>'.$beginTime.' and qs.deadline<='.$endTime.'))';
$field = 'store_id,store_state,store_time,store_end_time,province_id,city_id,area_id,(select se.cashed_deposit from han_store_extend se where se.store_id=han_store.store_id) cashed_deposit,if((store_state=1 and store_end_time>=0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id), 0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id and qs.deadline>=0), 0)) service_fee';
$result = true;
$storeDao = \DAO\StoreModel::getInstance();
$statDao = \DAO\StatStoreModel::getInstance(DbNameConst::masterDBConnectName);
// $store_tmp = array();
if($datas = $storeDao->getStores($where, $field)) { //更新报表
echo 'in:'.count($datas);
foreach ($datas as $key=>$val) {
$update_data = $val;
$update_data['upd_time'] = $endTime;
unset($update_data['store_id']);
$where = 'store_id='.$val['store_id'];
if(!$statDao->update($where, $update_data)){
$result = false;
}
}
}
$where = 'store_id not in (select ss.store_id from han_stat_store ss)';
if($datas = $storeDao->getStores($where, $field)) { //插入报表
echo 'not in:'.count($datas);
foreach ($datas as $key=>$val) {
$insert_data = $val;
$insert_data['upd_time'] = $endTime;
if(!$statDao->insert($insert_data)){
echo 'insert fail'.var_export($val, true)."\n";
$result = false;
}
}
}
if($result) { //商品报表更新成功
file_put_contents($this->baseDir . \Our\PathConst::storeStatTime, $endTime);
}
return $result;
}
/** /**
* 获取店铺首页渲染信息 * 获取店铺首页渲染信息
* add by zhz * add by zhz
...@@ -894,7 +947,7 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -894,7 +947,7 @@ class StoreServiceModel extends \Business\AbstractModel{
} }
return false; return false;
} }
/** /**
* 获取热销专区的商品 * 获取热销专区的商品
......
...@@ -156,13 +156,15 @@ class OrderGoodsModel extends \DAO\AbstractModel { ...@@ -156,13 +156,15 @@ class OrderGoodsModel extends \DAO\AbstractModel {
} }
//获得已经退款退货的商品id //获得已经退款退货的商品id
public function getRefundOrderGoodsIds($orderGoods){ public function getRefundOrderGoodsIds($orderGoods){
$newOrderGoods=array();
$orderGoods=array_values($orderGoods); $orderGoods=array_values($orderGoods);
for($i=ApiConst::zero;$i<count($orderGoods);$i++){ for($i=ApiConst::zero;$i<count($orderGoods);$i++){
if($orderGoods[$i]['refundId']==ApiConst::zero){ if($orderGoods[$i]['refundId']!=ApiConst::zero){
unset($orderGoods[$i]); array_push($newOrderGoods,$orderGoods);
// unset($orderGoods[$i]);
} }
} }
return array_column($orderGoods,'goodsId'); return array_column($newOrderGoods,'goodsId');
} }
/** /**
* 根据订单id 获得订单商品记录 * 根据订单id 获得订单商品记录
......
...@@ -7,6 +7,15 @@ use Our\ApiConst; ...@@ -7,6 +7,15 @@ use Our\ApiConst;
use Our\Common; use Our\Common;
use Our\CommonExtension; use Our\CommonExtension;
/**
* 商品报表模型类
* Class StatGoodsModel
* @package DAO
* User: King <358887571@qq.com>
* Date: 2018/11/30 0030
* Time: 下午 5:30
*
*/
class StatGoodsModel extends \DAO\AbstractModel { class StatGoodsModel extends \DAO\AbstractModel {
public $errorCode; public $errorCode;
...@@ -25,7 +34,7 @@ class StatGoodsModel extends \DAO\AbstractModel { ...@@ -25,7 +34,7 @@ class StatGoodsModel extends \DAO\AbstractModel {
* *
* @var string * @var string
*/ */
protected $_primaryKey = ''; protected $_primaryKey = 'statg_id';
public function init(){ public function init(){
} }
......
<?php
namespace DAO;
use Our\ApiConst;
use Our\Common;
use Our\CommonExtension;
/**
*店铺报表模型类
* Class StatStoreModel
* @package DAO
* User: King <358887571@qq.com>
* Date: 2018/11/30 0030
* Time: 下午 5:29
*
*/
class StatStoreModel extends \DAO\AbstractModel {
public $errorCode;
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_stat_store';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'stats_id';
public function init(){
}
/**
*
* 分页获取商品列表
* @param $where
* @param $field
* @param $pageIndex
* @param $pageSize
* @param array $order
* @return array|mixed
*/
public function getListPage($where, $field, $pageIndex, $pageSize, $order = array('goods_id' => 'asc'))
{
$this->setDb($this->dbName);
if($datas = $this->lists($where, $order, $field, $pageIndex, $pageSize)) {
foreach ($datas['list'] as $key=>$val) {
$datas['list'][$key]['goodsAttr'] = $this->getFormatGoodsAttr($val['goodsAttr']);
}
}
return $datas ? $datas : array();
}
/**
* 根据条件更新
* @param $sql
* @return mixed
* User: King <358887571@qq.com>
* Date: 2018/11/27 0027
* Time: 下午 7:27
*/
public function updatBySql($sql) {
$this->setDb(\Our\DbNameConst::masterDBConnectName);
return $this->db->update($this->_tableName)->execute($sql);
}
/**
* 更新数据
* @param $data
* @param $where
* @return mixed
*/
public function update($where, $data, $setData = array())
{
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$this->db->update($this->_tableName)->where($where)->rows($data);
foreach ($setData as $val) {
$this->db->set($val['field'], $val['value'], TRUE);
}
return $this->db->execute();
}
/**
* 插入数据
* @param $data
* @return mixed
* User: King <358887571@qq.com>
* Date: 2018/11/27 0027
* Time: 下午 5:51
*/
public function insert($data){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->insert($this->_tableName)->rows($data)->execute();
return $result ;
}
public function getList($where,$field){
$this->setDb();
return $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
}
public function find($where,$field = \Our\NameConst::allField){
$this->setDb($this->dbName);
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
return $result;
}
/**
* 获取在线商品列表
* @param $where
* @param string $field
* @return mixed
*/
public function getOnlineList($where,$field = \Our\NameConst::allField){
$whereSql = ' goods_state ='.\Our\ApiConst::onlineGoodsState.' and goods_verify='.\Our\ApiConst::onlineGoodsVerify.' and is_del='.\Our\ApiConst::onlineGoodsDel;
if($where){
$whereSql .= ' and '.$where;
}
return $this->getList($whereSql,$field);
}
public function getOnlineOne($goodsId,$field= \Our\NameConst::allField){
$where['goods_state'] = \Our\ApiConst::onlineGoodsState;
$where['goods_verify'] = \Our\ApiConst::onlineGoodsVerify;
$where['is_del'] = \Our\ApiConst::onlineGoodsDel;
$where['goods_id'] = $goodsId;
$goods = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsRedisModel::getInstance(),array(&$this, 'find'),array($where,$field),\Our\ApiConst::oneHour,array($goodsId));
return $goods;
}
/**
* 类实例
*/
private static $_instance = null;
/**
* 获取类实例
*/
public static function getInstance($dbName=\Our\DbNameConst::salveDBConnectName) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($dbName);
}
return self::$_instance;
}
}
<?php
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 cliStoreStoreStat
* User: King <358887571@qq.com>
* Date: 2018/11/30 0030
* Time: 下午 3:00
*
*/
class cliStoreStoreStat extends basecli
{
const CLI_ADMIN_ID = 255;
private $bDoUnLock = FALSE; // 是否允许释放 LOCK 文件
private $_debug = 0;
private $lockFileName;
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);
}
}
/**
* 自动统计商品
* User: linqin <358887571@qq.com>
* Date: 2018/11/27 0027
* Time: 下午 3:23
*/
protected function autoStatGoods(){
$service = \Business\Store\StoreServiceModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$service->baseDir = \Our\Common::getConfig('out.config');
echo "update store stat \n";
if($service->updateStatStore()) { //更新商品基础信息
echo "update store others \n";
//$goodsService->updateStatGoodsSell();
}
}
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('goods');
if(!$this->mkdirs($lockDir)){
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir .DS.'stat.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;
if(APP_ENV =='pre' || APP_ENV=='product'){
file_put_contents($this->lockFileName ,"running" ); // CLI 独占锁
}
$this->autoStatGoods();
echo date('Y-m-d H:i:s',TIMESTAMP).'定单关闭消息成功'."\r\n";
}
}
$oCli = new cliStoreStoreStat(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