Commit 17bbcf2d authored by zhz's avatar zhz

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

parents 38f91132 ce4c1b75
......@@ -3,6 +3,7 @@ namespace OSS;
use OSS\OssClient;
use OSS\Core\OssException;
use Our\SecretKeys;
/**
......@@ -17,13 +18,11 @@ class Common
const accessKeySecret = \Our\SecretKeys::ossAccessKey;
const bucket = \Our\SecretKeys::ossBucket;
/**
* Get an OSSClient instance according to config.
*
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
const endpointPre=SecretKeys::ossEndpointPre;
const buketPre=SecretKeys::ossBucket;
public static function getOssClientOnline(){
try {
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
} catch (OssException $e) {
......@@ -33,10 +32,40 @@ class Common
}
return $ossClient;
}
public static function getOssClientPre(){
try {
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpointPre, false);
} catch (OssException $e) {
printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
printf($e->getMessage() . "\n");
return null;
}
return $ossClient;
}
/**
* Get an OSSClient instance according to config.
*
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
if(APP_ENV=='product' || APP_ENV=='productone'){
return self::getOssClientOnline();
}else{
return self::getOssClientPre();
}
}
public static function getBucketName()
{
if(APP_ENV=='product' || APP_ENV=='productone'){
return self::bucket;
}else{
return self::buketPre;
}
}
/**
......
......@@ -523,6 +523,7 @@ class OrderConfirmUtil {
$order['add_time'] = TIMESTAMP;
$order['payment_type'] = $storeCarts['payway'];
$order['order_amount'] = $storeCarts['orderAmount'];
$order['origin_amount'] = $storeCarts['orderAmount'];
if($order['payment_type'] == 1 &&$storeCarts['orderAmount']>0){
$needPayFlag = \Our\ApiConst::one;
$order['order_state'] = \Our\ApiConst::orderStateWaitPay ;
......
......@@ -197,7 +197,8 @@ class ApiConst
//是否退款成功
const refundSuccess = 1;
const refundFail = 0;
//order refundState all
const refundStateAll=2;
const isNotSuccessRefund=0;
const refundCompleted=3;
......@@ -310,6 +311,7 @@ class ApiConst
const commonClassStyle = 1;
const signClassStyle = 2;
const isEffective=0;
const defaultAddressCount = 3;
......
......@@ -365,7 +365,10 @@ class Common
},$str);
return $str;
}
public static function getTodayBeginTimpSpan(){
$totayTimeSpan=strtotime(date('Y-m-d'));
return $totayTimeSpan;
}
/**
* 驼峰数组转下划线数组
* @param array $data
......
......@@ -25,6 +25,11 @@ class SecretKeys {
const ossBucket = 'qmoss-01';//存储空间名称
const ossDomain = 'http://qmoss-01.oss-cn-hangzhou.aliyuncs.com';//访问oss使用域名
//pre环境使用的oss
const ossEndpointPre = 'http://oss-cn-shanghai.aliyuncs.com';//地域节点
const ossBucketPre = 'qmoss-shanghai';//存储空间名称
const ossDomainPre = 'http://qmoss-shanghai.oss-cn-shanghai.aliyuncs.com';//访问oss使用域名
//短信验证码相关
const aliYunSmsAppId = 'LTAICEp88gU0DNMe';
......
......@@ -1378,6 +1378,9 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if(!$oldTemp){
$storeOnlineGoodsClassDao->insert($goodsClass);
}
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getList'),array(),array($goodsClass['store_id']));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getStoreOnlineGoodsClassesByGcId'),array(),array($goodsClass['store_id']));
return true;
}
......@@ -1398,7 +1401,12 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}
$tempOne = $goodsCommonDao->getOne($where,'goods_commonid');
if(!$tempOne){
$storeOnlineGoodsClassDao->del($goodsClass);
$result = $storeOnlineGoodsClassDao->del($goodsClass);
if($result){
$storeOnlineGoodsClassDao = \DAO\GoodsClass\StoreOnlineGoodsClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getList'),array(),array($goodsClass['store_id']));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$storeOnlineGoodsClassDao, 'getStoreOnlineGoodsClassesByGcId'),array(),array($goodsClass['store_id']));
}
}
}
}
......
......@@ -445,7 +445,7 @@ class MessageServiceModel extends \Business\AbstractModel
}
}
public function addMessageCenterToDb()
public function addMessageCenterToDb($pushPushCenter=true)
{
$conf = \Yaf\Registry::get('config')->get('redis.database.params');
$this->baseRedis = new \Redis();
......@@ -454,7 +454,9 @@ class MessageServiceModel extends \Business\AbstractModel
$this->baseRedis->auth($conf['password']);
}
while ($center = $this->baseRedis->lPop('message_center')) {
if($pushPushCenter){
$this->baseRedis->rPush('push_center', $center);
}
$addData = unserialize($center);
$addData['message'] = unserialize($addData['message']);
$this->addMessage($addData['fromId'], $addData['fromUserId'], $addData['fromUserName'], $addData['fromType'], $addData['message'], $addData['toId'], $addData['toUserId'], $addData['toUserName'], $addData['toType'], $addData['id']);
......
......@@ -638,7 +638,7 @@ class OrderServiceModel extends \Business\AbstractModel
echo " 退款操作操作成功:".$orderId;
return true;
}else{
echo $refundReturnDao->errorMessage;
echo $refundReturnDao->errorMessage."orderId:".$orderId;
}
......
......@@ -36,7 +36,7 @@ class RefundServiceModel extends \Business\AbstractModel
//获得退款详情字段
private $refundReturnField = 'refund_id as refundId,order_id as orderId,order_sn as orderSn,refund_sn as refundSn,store_id as storeId,store_name as storeName,seller_state as sellerState,goods_id as goodsId,order_goods_id as orderGoodsId,goods_name as goodsName,goods_num as goodsNum,refund_amount as refundAmount,goods_image as goodsImage,refund_type as refundType,refund_state as refundState,return_type as returnType,add_time as addTime,seller_time as sellerTime,admin_time as adminTime,reason_info as reasonInfo,pic_info as picInfo,buyer_message as buyerMessage,seller_message as sellerMessage,admin_message adminMessage,express_id as expressId,invoice_no as invoiceNo,ship_time as shipTime,delay_time as delayTime,receive_time as receiveTime,shipping_over as shippingOver,shipping_sign as shippingSign,shipping_html as shippingHtml,is_suc_refund as isSucRefund,refund_shipping_type as refundShippingType,address_id as addressId,diliveryman_id as diliverymanId,is_platform_in as isPlatformIn,platform_in_reason as platformInReason,platform_state as platformState,seller_state as sellerState,return_type as returnType,refund_shipping_type as refundShippingType,buyer_refund_amount as buyerRefundAmount,reason_id as reasonId,receive_message as receiveMessage,goods_state as goodsState';
private $storeRefundReturnField = 'refund_id as refundId,order_id as orderId,order_sn as orderSn,refund_sn as refundSn,store_id as storeId,store_name as storeName,seller_state as sellerState,goods_id as goodsId,order_goods_id as orderGoodsId,goods_name as goodsName,goods_num as goodsNum,refund_amount as refundAmount,buyer_refund_amount as buyerRefundAmount,goods_image as goodsImage,refund_type as refundType,refund_state as refundState,return_type as returnType,add_time as addTime,seller_time as sellerTime,admin_time as adminTime,reason_id as reasonId,reason_info as reasonInfo,pic_info as picInfo,buyer_message as buyerMessage,seller_message as sellerMessage,admin_message adminMessage,express_id as expressId,invoice_no as invoiceNo,ship_time as shipTime,delay_time as delayTime,receive_time as receiveTime,receive_message as receiveMessage,shipping_over as shippingOver,shipping_sign as shippingSign,shipping_html as shippingHtml,is_suc_refund as isSucRefund,refund_shipping_type as refundShippingType,address_id as addressId,diliveryman_id as diliverymanId,is_platform_in as isPlatformIn,platform_in_reason as platformInReason,platform_state as platformState,return_type as returnType,refund_shipping_type as refundShippingType,goods_state as goodsState';
private $storeRefundReturnField = 'refund_id as refundId,order_id as orderId,order_sn as orderSn,refund_sn as refundSn,store_id as storeId,store_name as storeName,seller_state as sellerState,goods_id as goodsId,order_goods_id as orderGoodsId,goods_name as goodsName,goods_num as goodsNum,refund_amount as refundAmount,buyer_refund_amount as buyerRefundAmount,goods_image as goodsImage,refund_type as refundType,refund_state as refundState,return_type as returnType,add_time as addTime,seller_time as sellerTime,admin_time as adminTime,reason_id as reasonId,reason_info as reasonInfo,pic_info as picInfo,buyer_message as buyerMessage,seller_message as sellerMessage,admin_message adminMessage,express_id as expressId,invoice_no as invoiceNo,ship_time as shipTime,delay_time as delayTime,receive_time as receiveTime,receive_message as receiveMessage,shipping_over as shippingOver,shipping_sign as shippingSign,shipping_html as shippingHtml,is_suc_refund as isSucRefund,refund_shipping_type as refundShippingType,address_id as addressId,diliveryman_id as diliverymanId,is_platform_in as isPlatformIn,platform_in_reason as platformInReason,platform_state as platformState,return_type as returnType,refund_shipping_type as refundShippingType,goods_state as goodsState,buyer_name as buyerName';
private $order;
......@@ -450,7 +450,7 @@ class RefundServiceModel extends \Business\AbstractModel
$refund_array['refund_amount'] = $refundAmount;
$refundReturnDao->db->doTransaction();
if($seller_state!=2){ //拒绝退款
$result= $orderGoodsDao->update(array('rec_id'=>$refund['order_goods_id']), array('is_refund'=>0, 'refund_state_name'=>'卖家拒绝退', 'gmt_update'=>TIMESTAMP));
$result= $orderGoodsDao->update(array('rec_id'=>$refund['order_goods_id']), array('is_refund'=>0, 'refund_state_name'=>'卖家拒绝退', 'gmt_update'=>TIMESTAMP));
if(!$result){
$refundReturnDao->db->doRollback();
......@@ -721,6 +721,8 @@ class RefundServiceModel extends \Business\AbstractModel
$diliveryWhere['order_type']=ApiConst::orderTypeRefund;
$orderWhere['order_id']=array('in',$orderIds);
$orders = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderDao, 'getList'), array($orderWhere, $orderDao->getOrderDetailField(), ApiConst::zero, $pageSize), \Our\ApiConst::oneDaySecond, array($storeId));
$orderConvert=$orderDao->convertOrder($orders['list'],'orderId');
$qmDeliveryManLogWhere['order_id']=array('in',$refundIds);
$qmDeliveryManLogWhere['order_type']= ApiConst::orderTypeRefund;
$qmDeliveryManLogs=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$qmDeliveryManLogDao, 'getList'), array($qmDeliveryManLogWhere, $qmDeliveryManLogDao->fieldDetail,ApiConst::zero,$pageSize), \Our\ApiConst::oneDaySecond, array($storeId));
......@@ -742,6 +744,7 @@ class RefundServiceModel extends \Business\AbstractModel
$value['deliveryTimeEnd'] = $value['deliveryTime'] + ApiConst::arriveTimeRadius;
$value['goodsImage'] = ImageUtil::getGoodsImgUrl($value['goodsImage'], ApiConst::goodsSmallSize);
$value['goodsAttr']=$goodsDao->getFormatGoodsAttr($value['goodsSpec']);
$value['finnshedTime']=$orders[$value['orderId']]['finnshedTime'];
$extent=$orderDao->getClienOrderCommon($orders[$value['orderId']]);
$value=array_merge($value,$extent);
$goodGroup=unserialize($value['goodsGroup']);
......@@ -780,6 +783,7 @@ class RefundServiceModel extends \Business\AbstractModel
}else{
$value['markRefundButton']=ApiConst::zero;;
}
$value['addTime']=$orderConvert[$value['orderId']]['addTime'];
unset($value['goodsSpec']);
// unset($value['picInfo']);
}
......
......@@ -61,6 +61,7 @@ class DeliveryServiceModel extends \Business\AbstractModel
$orderRes= $refundReturnDao->update($returnWhere,$orderData);
}else{
$orderData['order_state']=ApiConst::orderStateWaitRecieve;
$orderData['send_time']=TIMESTAMP;
$orderRes = $orderDao->updateByOrderId($orderData, $data['orderId']);
}
......
......@@ -49,6 +49,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
{
$memberDao = \DAO\MemberModel::getInstance();
$storeId = $memberDao->getInfo($memberId, 'store_id');
$storeStaticDao=\DAO\StoreStatisticsModel::getInstance();
//$storeId = $this->_getStoreByMemberId($memberId);
// $storeStatisticsDayDao = \DAO\Store\StoreStatisticsDayModel::getInstance();
// $storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
......@@ -67,7 +68,9 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// $storeStats=$orderDao->getShopKeeperCountByStoreId($storeId);
$storeStats = $orderDao->getShopKeeperCountByStoreIdCache($storeId);
$storeFavariteCount = $favoritesStoreDao->getFavoritesCountByStoreIdCache($storeId);
$todayTotalOnline=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderDao, 'getOrderOrderTotalOnlineByStoreId'), array($storeId,true), ApiConst::oneDaySecond, array($storeId));
$orderTotalOnline=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$storeStaticDao, 'getByStoreId'), array($storeId), ApiConst::oneDaySecond, array($storeId));;
$orderTotalOnline=$orderTotalOnline['orderTotalOnline']?$orderTotalOnline['orderTotalOnline']:ApiConst::zero;
$goodsCount = $totalOrderCount['orderGoodsCount'];
$orderTotal = $totalOrderCount['orderTotal'];
$data['storeId'] = $store['store_id'];
......@@ -76,9 +79,11 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$data['goodsCount'] = $goodsCount?$goodsCount:ApiConst::zero;
$data['orderCount'] = $storeStats['orderCount'];
$data['orderTotal'] = $orderTotal?$orderTotal:ApiConst::zero;
$data['orderTotalOnline'] = $orderTotalOnline;
$data['favCount'] = $storeFavariteCount['favCount'];
$data['todayOrderCount'] = $storeStats['todayOrderCount'];
$data['todayOrderTotal'] = $storeStats['todayOrderTotal'];
$data['todayOrderTotalOnline']=$todayTotalOnline;
$data['tadayFavCount'] = $storeFavariteCount['todayFavCount'];
$data['todayFavCount'] = $storeFavariteCount['todayFavCount'];
return $data;
......@@ -276,6 +281,8 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
'orderId'=>$order['order_id']));
$push->addOneToClient($pushData);
$push->sendTcpMessage();
$messageService=\Business\Message\MessageServiceModel::getInstance();
$messageService->addMessageCenterToDb();
// $push->addOneToClient();
// \Our\RedisHelper::rpush('client_push',array('storeId'=>$order['storeId'],'type'=>ApiConst::messageWaitReceive,'op'=>NameConst::reduce,'num'=>ApiConst::one,'params'=>array('c'=>'shopkeeper','m'=>'orderDetail','orderId'=>$order['orderId'])));
//\Our\RedisHelper::rpush('client_push',array('storeId'=>$order['storeId'],'type'=>$type,'op'=>NameConst::add,'num'=>ApiConst::one,'params'=>array('c'=>'shopkeeper','m'=>'orderDetail','orderId'=>$order['orderId'])));
......@@ -320,7 +327,9 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
//$orderCommons = $orderCommonDao->getAllByOrderIds($orderIds, $orderCommonDao->orderCommonField);
$ordersOrderCommons = Common::intergrateOneToOne($orders, $qmDeliveryManLogs['list'], 'orderId', 'orderId');
$ordersOrderCommons=Common::intergrateOneToOne($ordersOrderCommons, $orderCommons, 'orderId', 'orderId');
$orderMerge = \Our\Common::intergrateOneToMany($ordersOrderCommons, $orderGoods, 'orderId', 'orderId', 'orderGoods','addTime');
$orderMerge = \Our\Common::intergrateOneToMany($ordersOrderCommons, $orderGoods, 'orderId', 'orderId', 'orderGoods');
foreach ($orderMerge as &$value) {
$value['orderStateName'] = $orderDao->getStatusText($value);
$value['orderText'] = $orderDao->getText($value, ApiConst::orderListDescribe);
......@@ -357,6 +366,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
} else {
unset($value['reciverInfo']);
}
unset($value['couponId']);
unset($value['refundAmount']);
unset($value['distributionFee']);
......@@ -407,7 +417,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
public function getOrders($memberId, $pageIndex, $pageSize, $orderState, $keyword)
{
$order = array('add_time' => 'desc');
$order = array('gmt_update' => 'desc');
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeId = $this->_getStoreByMemberId($memberId);
if (empty($storeId)) {
......@@ -441,7 +451,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// 'gmt_update'=>'asc'
// );
$order=array(
'add_time'=>'desc'
'gmt_update'=>'desc'
);
// $where .= ' and han_order.shipping_type=' . ApiConst::bySeller;
$where=$orderDao->getWaitDeliveryCondition($storeId);
......@@ -449,7 +459,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
} else {
$order=array(
'add_time'=>'desc'
'gmt_update'=>'desc'
);
if (!empty($orderState)) {
$where .= ' and han_order.order_state=' . $orderState;
......@@ -649,51 +659,80 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
return $results;
}
public function insertStoreMemberStaticsDistinct($distincts){
$orderDao = \DAO\Order\OrderModel::getInstance();
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$reufndReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$storeStatisticsDao=\DAO\StoreStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$storeDao=\DAO\StoreModel::getInstance();
$memberFavoritesStoreMemberStatisticsDao=\DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
foreach($distincts as $order){
$storeDao->deleteStoreTotalCount($order['storeId']);
// $orderDao->deleteOrderCache($order['buyerId'], $order['orderId'], $order['storeId'], true, true);
$storeMemberStatisticsData['storeId']=$order['storeId'];
$storeMemberStatisticsData['buyerId']=$order['buyerId'];
$orderRes=$orderDao->getSumAmountCountByMemberIdAndStoreId($storeMemberStatisticsData['storeId'],$storeMemberStatisticsData['buyerId']);
$storeMemberStatisticsData['orderTotal']=$orderRes['orderTotal']?$orderRes['orderTotal']:ApiConst::zero;
$orderGoodsRes=$orderGoodDao->getOrderGoodsCountBuyStoreIdAndMemberId( $storeMemberStatisticsData['storeId'],$storeMemberStatisticsData['buyerId']);
$orderGoodsCount=$orderGoodsRes['orderGoodsCount']?$orderGoodsRes['orderGoodsCount']:ApiConst::zero;
$storeMemberStatisticsData['orderGoodsCount']=$orderGoodsCount;
$storeMemberStatisticsData['addTime']=TIMESTAMP;
$res=$reufndReturnDao->getSumRefundAmountByMemberIdAndStoreId($order['storeId'],$order['buyerId']);
$refundAmount=$res['refundAmount']?$res['refundAmount']:'';
$storeMemberStatisticsData['orderTotal']=$storeMemberStatisticsData['orderTotal']-$refundAmount;
try{
$storeMemberStatisticDao->addOrUpdate($storeMemberStatisticsData);
}catch(\Exception $ex){
echo $ex->getMessage().json_encode($storeMemberStatisticsData)."\r\n";
}
//插入 han_store_statistics
$orderCountObj=$orderDao->getOrderCountByStoreId($order['storeId']);
$storeStatisticsData['orderCount']=$orderCountObj['orderCount']?$orderCountObj['orderCount']:ApiConst::zero;
$orderRes=$orderDao->getSumAmountCountByMemberIdAndStoreId($storeMemberStatisticsData['storeId']);
$orderTotal= $orderRes['orderTotal']?$orderRes['orderTotal']:ApiConst::zero;
$res=$reufndReturnDao->getSumRefundAmountByMemberIdAndStoreId($order['storeId']);
$refundAmount=$res['refundAmount']?$res['refundAmount']:'';
$storeStatisticsData['orderTotal']=$orderTotal-$refundAmount;
$orderOnline=$orderDao->getOrderOrderTotalOnlineByStoreId($order['storeId']);
$storeStatisticsData['orderTotalOnline']=$orderOnline['orderTotalOnline']?$orderOnline['orderTotalOnline']:ApiConst::zero;
$favCount= $memberFavoritesStoreMemberStatisticsDao->getFavCountByStoreId($order['storeId']);
$storeStatisticsData['favCount']=$favCount['favCount']?$favCount['favCount']:ApiConst::zero;
$orderGoodsRes=$orderGoodDao->getOrderGoodsCountBuyStoreIdAndMemberId($storeMemberStatisticsData['storeId']);
$orderGoodsCount=$orderGoodsRes['orderGoodsCount']?$orderGoodsRes['orderGoodsCount']:ApiConst::zero;
$storeStatisticsData['goodsCount']=$orderGoodsCount;
$storeStatisticsData['storeId']=$order['storeId'];
try{
$storeStatisticsDao->addOrUpdate($storeStatisticsData);
}catch(\Exception $ex){
echo $ex->getMessage().json_encode($storeMemberStatisticsData)."\r\n";
}
}
}
//任务脚本原来的方法是下面那个
public function insertStoreMemberStatics()
{
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao = \DAO\Order\OrderModel::getInstance();
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$reufndReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime);
$gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero;
$beginTime = $gmtCreate;
$this->taskIndex = PageConst::taskPageBegin;
$this->taskSize = PageConst::taskPageSize;
do {
$storeMemberStatisticData = $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
if ($storeMemberStatisticData) {
$storeMemberStatisticDatas = $orderDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize);
$orders = isset($storeMemberStatisticDatas['list']) ? $storeMemberStatisticDatas['list'] : false;
$this->taskIndex++;
$storeId = array_column($storeMemberStatisticData, 'storeId');
$memberId = array_column($storeMemberStatisticData, 'buyerId');
$storeIds = array_unique($storeId);
$memberIds = array_unique($memberId);
$goodsNumCount = $orderGoodDao->getMemberStoreOrderGoodsCount($storeIds, $memberIds);
$ordersCount = $orderDao->getSumAmountCountByMemberAndStoreId($storeIds, $memberIds);
$refundLists = $reufndReturnDao->getRefundSuccessMoneyByStoreIdAndMemberId($storeIds, $memberIds);
if (!empty($ordersCount) && !empty($refundLists)) {
foreach ($ordersCount as &$order) {
foreach ($refundLists as $refund) {
if ($order['buyerId'] == $refund['buyerId'] && $order['storeId'] == $refund['storeId']) {
$order['orderTotal'] = $order['orderTotal'] - $refund['refundTotal'];
}
}
if ($orders) {
$distincts=array();
foreach($orders as $order){
$key=$order['storeId'].'+'.$order['buyerId'];
$distincts[$key]=$order;
}
$this->insertStoreMemberStaticsDistinct($distincts);
}
if (!empty($goodsNumCount)) {
$storeMemberStatisticDao->addAll($goodsNumCount, 'orderGoodsCount');
}
if (!empty($ordersCount)) {
$storeMemberStatisticDao->addAll($ordersCount, 'orderTotal');
}
}
} while ($storeMemberStatisticData);
} while ($orders);
file_put_contents($this->baseDir . PathConst::orderGoodsCreateTime, TIMESTAMP);
}
//任务脚本原来的方法是下面那个
// public function insertStoreMemberStatics()
......@@ -894,38 +933,66 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
}
//任务脚本
public function reduceStoreMemberStatics()
{
$refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName);
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
// $storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
$gmtUpdate = file_get_contents($this->baseDir . PathConst::refundRetrunGmtUpdate);
$gmtUpdate = $gmtUpdate ? $gmtUpdate : ApiConst::zero;
$this->taskIndex = PageConst::taskPageBegin;
$this->taskSize = PageConst::taskPageSize;
do {
$storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
if (!empty($storeMemberStatisticData)) {
foreach ($storeMemberStatisticData as $item) {
$orderDao->deleteOrderCache($item['buyerId'], $item['orderId'], $item['storeId'], true, true);
}
$orderIds = array_column($storeMemberStatisticData, 'orderId');
foreach ($orderIds as $orderId) {
$res = $orderGoodsDao->find(array('order_id' => $orderId, 'refund_id' => ApiConst::zero));
if (empty($res)) {
$orderDao->update(array('order_id' => $orderId), array('order_state' => ApiConst::orderStateClose));
}
$refundReturns = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
$this->taskIndex++;
$refundReturns = isset($refundReturns['list']) ? $refundReturns['list'] : false;
$reduceDatasDistinct=array();
if (!empty($refundReturns)) {
foreach ($refundReturns as $refundReturn) {
$key=$refundReturn['storeId'].'+'.$refundReturn['buyerId'];
$reduceDatasDistinct[$key]=$refundReturn;
}
}
$this->taskIndex++;
} while ($storeMemberStatisticData);
$this->insertStoreMemberStaticsDistinct($reduceDatasDistinct);
} while ($refundReturns);
//$storeMemberStatisticDao->addAllReduce($refundReturns);
file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
}
// //任务脚本
// public function reduceStoreMemberStatics()
// {
// $refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName);
// $storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
// $orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
// $gmtUpdate = file_get_contents($this->baseDir . PathConst::refundRetrunGmtUpdate);
// $gmtUpdate = $gmtUpdate ? $gmtUpdate : ApiConst::zero;
// $this->taskIndex = PageConst::taskPageBegin;
// $this->taskSize = PageConst::taskPageSize;
// do {
// $storeMemberStatisticData = $refundReturnDao->getMemberStoreStaticsByGmtUpdate($gmtUpdate, $this->taskIndex, $this->taskSize);
// $storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
// if (!empty($storeMemberStatisticData)) {
// foreach ($storeMemberStatisticData as $item) {
// $orderDao->deleteOrderCache($item['buyerId'], $item['orderId'], $item['storeId'], true, true);
// }
// $orderIds = array_column($storeMemberStatisticData, 'orderId');
// foreach ($orderIds as $orderId) {
// $res = $orderGoodsDao->find(array('order_id' => $orderId, 'refund_id' => ApiConst::zero));
// if (empty($res)) {
// $orderDao->update(array('order_id' => $orderId), array('order_state' => ApiConst::orderStateClose));
// }
// }
// }
// $this->taskIndex++;
// } while ($storeMemberStatisticData);
// file_put_contents($this->baseDir . PathConst::refundRetrunGmtUpdate, TIMESTAMP);
//
// }
//店铺订单统计任务脚本
public function storeStatictisTask()
......
......@@ -45,7 +45,7 @@ class OrderModel extends \DAO\AbstractModel
public function getOrderDetailField()
{
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,pay_sn as paySn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition,delay_time as delayTime,gmt_update as gmtUpdate,diliveryman_id as diliverymanId,shipping_arrival_time as shippingArrivalTime,delivery_time as deliveryTime,order_note as orderNote';
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,pay_sn as paySn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition,delay_time as delayTime,gmt_update as gmtUpdate,diliveryman_id as diliverymanId,shipping_arrival_time as shippingArrivalTime,delivery_time as deliveryTime,order_note as orderNote,send_time as sendTime';
}
public function getOrderShippingField()
......@@ -419,10 +419,11 @@ class OrderModel extends \DAO\AbstractModel
return [];
}
}
public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){
$this->setDb($this->dbName);
$where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1} and order_state={2}',$gmtCreate,TIMESTAMP,ApiConst::orderStateWaitRecieve);
$res=$this->lists($where,array('gmt_update'=>'asc'),$this->sumField,$pageIndex,$pageSize);
$where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1}',$gmtCreate,TIMESTAMP);
$res=$this->lists($where,array('gmt_update'=>'asc'),$this->getOrderDetailField(),$pageIndex,$pageSize);
return $res['list']?$res:false;
}
public function getSumAmountCountByMemberAndStoreId($storeIds,$memberIds)
......@@ -438,6 +439,62 @@ class OrderModel extends \DAO\AbstractModel
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(order_amount)) AS orderTotal")->group('buyer_id')->group('store_id')->fetchAll();
return $res;
}
public function getSumAmountCountByMemberIdAndStoreId($storeId,$memberId=false)
{
$this->setDb($this->dbName);
$where['store_id']=$storeId;
if($memberId){
$where['buyer_id']=$memberId;
}
$where['order_state']=array('notin',ArrayConst::orderCloseAndCancel);
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(order_amount)) AS orderTotal")->fetchOne();
return $res?$res:array();
}
public function getOrderCountByStoreId($storeId,$today=false){
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$where['order_state']=array('notin',ArrayConst::orderCloseAndCancel);
$where['refund_state']=array('neq',ApiConst::refundStateAll);
if($today){
$todayTimeSpan=Common::getTodayBeginTimpSpan();
$where['gmt_update']=array('egt', $todayTimeSpan);
$where['gmt_update']=array('elt', TIMESTAMP);
}
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(count(*)) AS orderCount")->fetchOne();
return $res?$res:array();
}
public function deleteGetOrderOrderTotalOnlineByStoreIdCache($storeId){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOrderOrderTotalOnlineByStoreId'), array(), array($storeId));
}
public function getOrderOrderTotalOnlineByStoreId($storeId,$today=false){
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$where['order_state']=array('notin',ArrayConst::orderCloseAndCancel);
$where['refund_state']=array('neq',ApiConst::refundStateAll);
$where['payment_type']=array('in',ArrayConst::payTypeOnlines);
if($today){
$todayBegin=Common::getTodayBeginTimpSpan();
$where['gmt_update']=array('egt',$todayBegin);
$where['gmt_update']=array('elt',TIMESTAMP);
}
if(is_array($where)){
$where= $this->db->getSqlWhereByArray($where);
}
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(order_amount-refund_amount) as orderTotalOnline")->fetchOne();
return $res?$res:array();
}
//待收货获取订单状态信息
public function getOrderStatusExtent($order)
......
......@@ -246,22 +246,42 @@ class OrderGoodsModel extends \DAO\AbstractModel {
}
public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){
$this->setDb($this->dbName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$whereOrder['store_id']=array('in',$storeIds);
$whereOrder['buyer_id']=array('in',$memberIds);
$whereOrder['order_state']=array('in',ArrayConst::orderCloseAndCancel);
$orderIds=$orderDao->getFieldByWhere($whereOrder,'order_id');
$where['store_id']=array('in',$storeIds);
$where['buyer_id']=array('in',$memberIds);
$where['is_refund']=array('neq',ApiConst::refundSuccess);
if($orderIds){
$where['order_id']=array('notin',$orderIds);
}
$where=$this->db->getSqlWhereByArray($where);
$res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
return $res;
}
public function getOrderGoodsCountBuyStoreIdAndMemberId($storeId,$memberId=false){
$this->setDb($this->dbName);
if($memberId){
$selectSql=Common::format("select {0} from {1} where store_id={2} and buyer_id={3} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and buyer_id={3} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");
}else{
$selectSql=Common::format("select {0} from {1} where store_id={2} and is_refund<>{4} and order_id in (select order_id from han_order where store_id={2} and order_state not in({5}) ) ",$this->sumGoodsNum,$this->_tableName,$storeId,$memberId,ApiConst::refundSuccess,"0,-1");
}
$res=$this->db->from($this->_tableName)->query($selectSql);
return $res->one?$res->one:array();
}
// public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){
// $this->setDb($this->dbName);
// $orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
// $whereOrder['store_id']=array('in',$storeIds);
// $whereOrder['buyer_id']=array('in',$memberIds);
// $whereOrder['order_state']=array('in',ArrayConst::orderCloseAndCancel);
// $orderIds=$orderDao->getFieldByWhere($whereOrder,'order_id');
// $where['store_id']=array('in',$storeIds);
// $where['buyer_id']=array('in',$memberIds);
// $where['is_refund']=array('neq',ApiConst::refundSuccess);
// if($orderIds){
// $where['order_id']=array('notin',$orderIds);
// }
// $where=$this->db->getSqlWhereByArray($where);
// $res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
// return $res;
//
// }
public function getMemberStoreOrderGoodsCountBak($storeIds,$memberIds){
$this->setDb($this->dbName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
......
......@@ -68,6 +68,20 @@ class RefundReturnModel extends \DAO\AbstractModel
}
// public function getRefundSuccessMoneyByStoreIdAndMemberId($storeId, $buyerId)
// {
// $this->setDb($this->dbName);
// if (is_array($storeId)) {
// $storeId = implode(',', $storeId);
// }
// if (is_array($buyerId)) {
// $buyerId = implode(',', $buyerId);
// }
// $where = \Our\Common::format(" store_id in({0}) and buyer_id in({1}) and is_suc_refund={2}", $storeId, $buyerId, ApiConst::refundSuccess);
// $res = $this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(refund_amount)) AS refundTotal")->group('buyer_id')->group('store_id')->fetchAll();
// return !empty($res) ? $res : [];
//
// }
public function getRefundSuccessMoneyByStoreIdAndMemberId($storeId, $buyerId)
{
$this->setDb($this->dbName);
......@@ -78,7 +92,7 @@ class RefundReturnModel extends \DAO\AbstractModel
$buyerId = implode(',', $buyerId);
}
$where = \Our\Common::format(" store_id in({0}) and buyer_id in({1}) and is_suc_refund={2}", $storeId, $buyerId, ApiConst::refundSuccess);
$res = $this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(refund_amount)) AS refundTotal")->group('buyer_id')->group('store_id')->fetchAll();
$res = $this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(refund_amount)) AS refundTotal,")->group('buyer_id')->group('store_id')->fetchAll();
return !empty($res) ? $res : [];
}
......@@ -662,7 +676,7 @@ class RefundReturnModel extends \DAO\AbstractModel
public function getMemberStoreStaticsByGmtUpdate($gmtUpdate, $pageIndex, $pageSize)
{
$this->setDb($this->dbName);
$where = \Our\Common::format(' gmt_update>={0} and gmt_update<{1} and refund_state={2}', $gmtUpdate, TIMESTAMP, ApiConst::refundStateComplete);
$where = \Our\Common::format(' gmt_update>={0} and gmt_update<{1} and is_suc_refund={2}', $gmtUpdate, TIMESTAMP, ApiConst::refundSuccess);
$res = $this->lists($where, array('gmt_update' => 'asc'), $this->sumField, $pageIndex, $pageSize);
return $res['list'] ? $res : false;
}
......@@ -698,7 +712,18 @@ class RefundReturnModel extends \DAO\AbstractModel
return self::$_instance;
}
public function getSumRefundAmountByMemberIdAndStoreId($storeId,$memberId=false)
{
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$where['buyer_id']=$memberId;
$where['is_suc_refund']=ApiConst::refundSuccess;
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$res=$this->db->from($this->_tableName)->where($where)->select(" buyer_id as buyerId,store_id as storeId,(SUM(refund_amount)) AS refundAmount")->fetchOne();
return $res?$res:array();
}
/**
* @param $storeId
* @param $orderState
......
......@@ -295,6 +295,18 @@ class StoreModel extends \DAO\AbstractModel
}
}
public function deleteStoreTotalCount($storeId){
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeStatisticsDao=\DAO\StoreStatisticsModel::getInstance();
$favoritesStoreDao->deleteGetFavoritesCountByStoreId($storeId);
$memberFavoritesStoreStoreMemberStatisticsDao = \DAO\Store\MemberFavoritesStoreStoreMemberStatisticsModel::getInstance();
$memberFavoritesStoreStoreMemberStatisticsDao->deleteGetGoodsCountOrderTotalByStoreIdCache($storeId);
$orderDao->deleteGetOrderOrderTotalOnlineByStoreIdCache($storeId);
$storeStatisticsDao->deleteGetByStoreIdCache($storeId);
}
public function getStoresByCityCode($cityCode, $field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope')
{
$storeClassCondition = " store_citycode = '" . $cityCode . "' ";
......
<?php
namespace DAO\Store;
use Our\ApiConst;
use Our\Common;
use Redis\Db6\StoreRedisModel;
/**
* 店铺数据统计
* @date 2018-5-14
* @author csw
*/
class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel {
class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
{
protected $redis;
......@@ -20,9 +23,9 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* @var string
*/
protected $_tableName = 'han_member-favorites_store-store_member_statistics';
public $sumField='sum(order_total) as orderTotal,sum(order_goods_count) as orderGoodsCount';
public $sumField = 'sum(order_total) as orderTotal,sum(order_goods_count) as orderGoodsCount';
public $field="fav_type as favType,member_id as memberId,member_mobile as memberMobile,is_backlist as isBacklist,fav_time as favTime,member_avatar as memberAvatar,member_name as memberName,order_total as orderTotal,order_goods_count as orderGoodsCount";
public $field = "fav_type as favType,member_id as memberId,member_mobile as memberMobile,is_backlist as isBacklist,fav_time as favTime,member_avatar as memberAvatar,member_name as memberName,order_total as orderTotal,order_goods_count as orderGoodsCount";
/**
* 主键
*
......@@ -30,67 +33,86 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
*/
protected $_primaryKey = 'id';
public function init(){
public function init()
{
$this->setDb();
}
/**
* 获取店铺统计信息
* @param $where
* @return array
*/
public function find($where) {
public function find($where)
{
$this->setDb($this->dbName);
$field = $this->_getColumns();
$data=$this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
$data = $this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
return $data;
}
public function getById($id){
$where['id']=$id;
$res=$this->find($where);
public function getById($id)
{
$where['id'] = $id;
$res = $this->find($where);
return $res;
}
public function getSortBySortType($sortType){
$order=array("fav_time"=>'asc');
switch($sortType){
case ApiConst::favTimeAsc: $order=array("fav_time"=>'asc');break;
case ApiConst::favTimeDesc: $order=array("fav_time"=>'desc');break;
case ApiConst::orderTotalAsc: $order=array("order_total"=>'asc');break;
case ApiConst::orderTotalDesc: $order=array("order_total"=>'desc');break;
default:break;
public function getSortBySortType($sortType)
{
$order = array("fav_time" => 'asc');
switch ($sortType) {
case ApiConst::favTimeAsc:
$order = array("fav_time" => 'asc');
break;
case ApiConst::favTimeDesc:
$order = array("fav_time" => 'desc');
break;
case ApiConst::orderTotalAsc:
$order = array("order_total" => 'asc');
break;
case ApiConst::orderTotalDesc:
$order = array("order_total" => 'desc');
break;
default:
break;
}
return $order;
}
public function getList($storeId, $pageIndex, $pageSize, $sort, $keyword=''){
public function getList($storeId, $pageIndex, $pageSize, $sort, $keyword = '')
{
$this->setDb($this->dbName);
$whereStr=" store_id=".$storeId;
if(!empty($keyword)){
$whereStr.=Common::format(" and(member_name like '%{0}%' or member_mobile like '%{0}%') ",$keyword);
}
$result=$this->lists($whereStr, $sort, $this->field, $pageIndex, $pageSize);
if(!empty($result['list'])){
$result['list']=$this->getListNotNull($result['list']);
foreach($result['list'] as $key=>$val){
if($val['favType']==ApiConst::two){
$result['list'][$key]['isBacklist']=ApiConst::one;
}else{
$result['list'][$key]['isBacklist']=ApiConst::zero;
$whereStr = " store_id=" . $storeId;
if (!empty($keyword)) {
$whereStr .= Common::format(" and(member_name like '%{0}%' or member_mobile like '%{0}%') ", $keyword);
}
$result = $this->lists($whereStr, $sort, $this->field, $pageIndex, $pageSize);
if (!empty($result['list'])) {
$result['list'] = $this->getListNotNull($result['list']);
foreach ($result['list'] as $key => $val) {
if ($val['favType'] == ApiConst::two) {
$result['list'][$key]['isBacklist'] = ApiConst::one;
} else {
$result['list'][$key]['isBacklist'] = ApiConst::zero;
}
// $result['list'][$key]['isBacklist']=$val['isBacklist']?$val['isBacklist']:ApiConst::zero;
$result['list'][$key]['orderTotal']=$val['orderTotal']?$val['orderTotal']:ApiConst::zero;
$result['list'][$key]['orderGoodsCount']=$val['orderGoodsCount']?$val['orderGoodsCount']:ApiConst::zero;
$result['list'][$key]['orderTotal'] = $val['orderTotal'] ? $val['orderTotal'] : ApiConst::zero;
$result['list'][$key]['orderGoodsCount'] = $val['orderGoodsCount'] ? $val['orderGoodsCount'] : ApiConst::zero;
}
}
return $result;
}
/**
* 更新数据
* @param $data
* @param $where
* @return mixed
*/
public function update($data,$where){
public function update($data, $where)
{
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
}
......@@ -99,7 +121,8 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* @param $data
* @return mixed
*/
public function insert($data){
public function insert($data)
{
return $this->db->insert($this->_tableName)->rows($data)->execute();
}
......@@ -107,29 +130,32 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* @param $storeId 店铺id
* @param $field 更新栏目
* @param $value 增加值
* @param $type,'INC':增加,'DEC':减少
* @param $type ,'INC':增加,'DEC':减少
*/
public function updateStoreStatisticsToday($storeId,$field,$value,$type='INC'){
$h = 'todayData'.date('Ymd');
public function updateStoreStatisticsToday($storeId, $field, $value, $type = 'INC')
{
$h = 'todayData' . date('Ymd');
$key = $storeId;
$this->redis = StoreRedisModel::getInstance();
$data = $this->redis->tableHGet($h,$key);
$data[$field] = $type=='INC' ? $data[$field] + $value : $data[$field] - $value;
StoreRedisModel::tableHSet($h,$storeId,$data,ApiConst::oneDaySecond);
$data = $this->redis->tableHGet($h, $key);
$data[$field] = $type == 'INC' ? $data[$field] + $value : $data[$field] - $value;
StoreRedisModel::tableHSet($h, $storeId, $data, ApiConst::oneDaySecond);
}
public function getInfoById($id,$field='*',$isField=false){
public function getInfoById($id, $field = '*', $isField = false)
{
$this->setDb();
$where[$this->_primaryKey]=$id;
$store=$this->db->from($this->_tableName)->select($field)->where($where)->fetchOne();
if($isField){
$where[$this->_primaryKey] = $id;
$store = $this->db->from($this->_tableName)->select($field)->where($where)->fetchOne();
if ($isField) {
return $store[$isField];
}else{
} else {
return $store;
}
}
public function getInfoByMemberId($memberId,$field='*',$isField=false)
public function getInfoByMemberId($memberId, $field = '*', $isField = false)
{
$this->setDb($this->dbName);
$where['member_id'] = $memberId;
......@@ -140,15 +166,29 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
return $store;
}
}
public function getGoodsCountOrderTotalByStoreId($storeId){
public function getGoodsCountOrderTotalByStoreId($storeId)
{
$this->setDb($this->dbName);
$where['store_id']=$storeId;
$res=$this->db->from($this->_tableName)->select($this->sumField)->where($where)->fetchOne();
return $res?$res:[];
$where['store_id'] = $storeId;
$res = $this->db->from($this->_tableName)->select($this->sumField)->where($where)->fetchOne();
return $res ? $res : [];
}
public function deleteCacheGetGoodsCountOrderTotalByStoreId($storeId){
return \Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getGoodsCountOrderTotalByStoreId'), array(),array($storeId));
public function deleteCacheGetGoodsCountOrderTotalByStoreId($storeId)
{
return \Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getGoodsCountOrderTotalByStoreId'), array(), array($storeId));
}
public function getFavCountByStoreId($storeId)
{
$this->setDb($this->dbName);
$where['store_id'] = $storeId;
$res = $this->db->from($this->_tableName)->select("store_id,count(*) as favCount")->where($where)->fetchOne();
return $res ? $res : [];
}
/**
* 类实例
*
......@@ -156,12 +196,18 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
*/
private static $_instance = null;
public function deleteGetGoodsCountOrderTotalByStoreIdCache($storeId)
{
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getGoodsCountOrderTotalByStoreId'), array(), array($storeId));
}
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public static function getInstance() {
public static function getInstance()
{
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
......@@ -173,7 +219,8 @@ class MemberFavoritesStoreStoreMemberStatisticsModel extends \DAO\AbstractModel
* 获取字段
* @return array
*/
private function _getColumns() {
private function _getColumns()
{
return array(
'store_id as storeId',
'order_count as orderCount',
......
......@@ -40,9 +40,10 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
* @return array
*/
public function find($where) {
$this->setDb();
$this->setDb($this->dbName);
$field='*';
$data=$this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
echo $this->db->getLastSql();exit;
return $data;
}
public function getField(){
......@@ -55,18 +56,15 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
* @return mixed
*/
public function update($data,$where){
$this->setDb();
$this->setDb(DbNameConst::masterDBConnectName);
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
}
/**
* 插入数据
* @param $data
* @return mixed
*/
public function insert($data){
$this->setDb(DbNameConst::masterDBConnectName);
return $this->db->insert($this->_tableName)->rows($data)->execute();
}
/**
* 排序,1:关注时间降序,2:关注时间升序,3:购买力降序,4:购买力升序,默认1
* @param $data
......@@ -169,6 +167,19 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
return $result;
}
//插入数据大量
public function addOrUpdate($data)
{
$this->setDb(DbNameConst::masterDBConnectName);
$error = 0;
$baseSql = "insert into {$this->_tableName}({$this->insertField}) values";
$addSql = \Our\Common::format("({0},{1},{2},{3},{4}) ", $data['storeId'], $data['buyerId'],$data['orderGoodsCount'], $data['orderTotal'],TIMESTAMP);
$extentSql=" ON DUPLICATE KEY UPDATE order_goods_count=values(order_goods_count),order_total=values(order_total),add_time=".TIMESTAMP;
$excuteSql=$baseSql.$addSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($excuteSql);
return $one;
}
//插入数据大量
public function addAll($datas,$field="orderGoodsCount")
{
......
......@@ -43,6 +43,15 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
return $data;
}
public function deleteGetByStoreIdCache($storeId){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getByStoreId'), array(), array($storeId));
}
public function getByStoreId($storeId){
$where['store_id']=$storeId;
$res=$this->find($where);
return $res?$res:array();
}
/**
* 更新数据
* @param $data
......@@ -141,7 +150,19 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
* @var \DAO\UserModel
*/
private static $_instance = null;
//插入数据大量
public $insertFields="store_id,order_count,order_total,order_total_online,fav_count,goods_count,add_time";
public function addOrUpdate($data)
{
$this->setDb(DbNameConst::masterDBConnectName);
$baseSql = "insert into {$this->_tableName}({$this->insertFields}) values";
$addSql = \Our\Common::format("({0},{1},{2},{3},{4},{5},{6}) ", $data['storeId'],$data['orderCount'], $data['orderTotal'],$data['orderTotalOnline'], $data['favCount'], $data['goodsCount'],TIMESTAMP);
$extentSql=" ON DUPLICATE KEY UPDATE order_count=values(order_count),order_total=values(order_total),order_total_online=values(order_total_online),fav_count=values(fav_count),goods_count=values(goods_count),add_time=".TIMESTAMP;
$excuteSql=$baseSql.$addSql.$extentSql;
$one = $this->db->insert($this->_tableName)->query($excuteSql);
return $one;
}
/**
* 获取类实例
*
......@@ -166,6 +187,7 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
'order_total as orderTotal',
'fav_count as favCount',
'goods_count as goodsCount',
'order_total_online as orderTotalOnline',
);
}
......
......@@ -38,7 +38,7 @@ config.url.resourcesHost = "http://api.shenbd.com"
config.url.userHost = ""
config.url.ossHost = "https://img.shenbd.com"
//config.url.ossHost = "https://qmoss-01.oss-cn-hangzhou.aliyuncs.com"
;config.url.ossHost = "https://qmoss-01.oss-cn-hangzhou.aliyuncs.com"
;推送域名
config.url.pushHost="127.0.0.1:9503";
......@@ -55,7 +55,7 @@ config.url.convert=/usr/local/bin/wkhtmltoimage
config.url.resourcesHost = "http://apitest.shenbd.com"
; 用户中心host
config.url.userHost = ""
config.url.ossHost = "http://testadmin.shenbd.com/data/upload"
config.url.ossHost = "https://imgpre.shenbd.com"
; oss 域名
;config.url.ossHost = "https://qmoss-01.oss-cn-hangzhou.aliyuncs.com"
......
......@@ -48,7 +48,7 @@ class cliOrderClose extends basecli
$redis->auth($conf['password']);
}
$clientPush=\JPush\ClientPush::getInstance();
$clientPush->pushTest(array());exit;
$clientPush->pushTest(array());
$memberCenterServiceDao=\Business\User\MemberCenterServiceModel::getInstance();
//$messageService=\DAO\MessageHistoryModel::getInstance();
while($pushData=$redis->rPop('push_center')){
......
......@@ -72,13 +72,13 @@ class cliShopkeeperIndex extends basecli
try {
$shopkeeperService->insertStoreMemberStatics();
//退货退款订单自动关闭
// $shopkeeperService->reduceStoreMemberStatics();
//$shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId();
$shopkeeperService->reduceStoreMemberStatics();
// $shopkeeperService->storeStatictisTask();
// $shopkeeperService->updateLastId();
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
}
echo '店铺统计数据插入成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
echo 'store static insert success' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
}
......
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