Commit 759c43a0 authored by christ's avatar christ

refundstatic

parents 0a754718 9e150f7d
File mode changed from 100755 to 100644
...@@ -197,7 +197,8 @@ class ApiConst ...@@ -197,7 +197,8 @@ class ApiConst
//是否退款成功 //是否退款成功
const refundSuccess = 1; const refundSuccess = 1;
const refundFail = 0; const refundFail = 0;
//order refundState all
const refundStateAll=2;
const isNotSuccessRefund=0; const isNotSuccessRefund=0;
const refundCompleted=3; const refundCompleted=3;
...@@ -310,6 +311,7 @@ class ApiConst ...@@ -310,6 +311,7 @@ class ApiConst
const commonClassStyle = 1; const commonClassStyle = 1;
const signClassStyle = 2; const signClassStyle = 2;
const isEffective=0;
const defaultAddressCount = 3; const defaultAddressCount = 3;
......
...@@ -365,7 +365,10 @@ class Common ...@@ -365,7 +365,10 @@ class Common
},$str); },$str);
return $str; return $str;
} }
public static function getTodayBeginTimpSpan(){
$totayTimeSpan=strtotime(date('Y-m-d'));
return $totayTimeSpan;
}
/** /**
* 驼峰数组转下划线数组 * 驼峰数组转下划线数组
* @param array $data * @param array $data
......
...@@ -638,7 +638,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -638,7 +638,7 @@ class OrderServiceModel extends \Business\AbstractModel
echo " 退款操作操作成功:".$orderId; echo " 退款操作操作成功:".$orderId;
return true; return true;
}else{ }else{
echo $refundReturnDao->errorMessage; echo $refundReturnDao->errorMessage."orderId:".$orderId;
} }
......
...@@ -419,10 +419,11 @@ class OrderModel extends \DAO\AbstractModel ...@@ -419,10 +419,11 @@ class OrderModel extends \DAO\AbstractModel
return []; return [];
} }
} }
public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){ public function getMemberStoreStaticsByCreateTime($gmtCreate,$pageIndex,$pageSize){
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1} and order_state={2}',$gmtCreate,TIMESTAMP,ApiConst::orderStateWaitRecieve); $where =\Our\Common::format(' gmt_update>={0} and gmt_update<{1}',$gmtCreate,TIMESTAMP);
$res=$this->lists($where,array('gmt_update'=>'asc'),$this->sumField,$pageIndex,$pageSize); $res=$this->lists($where,array('gmt_update'=>'asc'),$this->getOrderDetailField(),$pageIndex,$pageSize);
return $res['list']?$res:false; return $res['list']?$res:false;
} }
public function getSumAmountCountByMemberAndStoreId($storeIds,$memberIds) public function getSumAmountCountByMemberAndStoreId($storeIds,$memberIds)
...@@ -438,6 +439,62 @@ class OrderModel extends \DAO\AbstractModel ...@@ -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(); $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; 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) public function getOrderStatusExtent($order)
......
...@@ -246,22 +246,42 @@ class OrderGoodsModel extends \DAO\AbstractModel { ...@@ -246,22 +246,42 @@ class OrderGoodsModel extends \DAO\AbstractModel {
} }
public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){ public function getMemberStoreOrderGoodsCount($storeIds,$memberIds){
$this->setDb($this->dbName); $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['store_id']=array('in',$storeIds);
$where['buyer_id']=array('in',$memberIds); $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); $where=$this->db->getSqlWhereByArray($where);
$res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll(); $res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
return $res; 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){ public function getMemberStoreOrderGoodsCountBak($storeIds,$memberIds){
$this->setDb($this->dbName); $this->setDb($this->dbName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName); $orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
......
...@@ -68,6 +68,20 @@ class RefundReturnModel extends \DAO\AbstractModel ...@@ -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) public function getRefundSuccessMoneyByStoreIdAndMemberId($storeId, $buyerId)
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
...@@ -78,7 +92,7 @@ class RefundReturnModel extends \DAO\AbstractModel ...@@ -78,7 +92,7 @@ class RefundReturnModel extends \DAO\AbstractModel
$buyerId = implode(',', $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); $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 : []; return !empty($res) ? $res : [];
} }
...@@ -662,7 +676,7 @@ class RefundReturnModel extends \DAO\AbstractModel ...@@ -662,7 +676,7 @@ class RefundReturnModel extends \DAO\AbstractModel
public function getMemberStoreStaticsByGmtUpdate($gmtUpdate, $pageIndex, $pageSize) public function getMemberStoreStaticsByGmtUpdate($gmtUpdate, $pageIndex, $pageSize)
{ {
$this->setDb($this->dbName); $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); $res = $this->lists($where, array('gmt_update' => 'asc'), $this->sumField, $pageIndex, $pageSize);
return $res['list'] ? $res : false; return $res['list'] ? $res : false;
} }
...@@ -698,7 +712,18 @@ class RefundReturnModel extends \DAO\AbstractModel ...@@ -698,7 +712,18 @@ class RefundReturnModel extends \DAO\AbstractModel
return self::$_instance; 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 $storeId
* @param $orderState * @param $orderState
......
...@@ -295,6 +295,18 @@ class StoreModel extends \DAO\AbstractModel ...@@ -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') public function getStoresByCityCode($cityCode, $field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope')
{ {
$storeClassCondition = " store_citycode = '" . $cityCode . "' "; $storeClassCondition = " store_citycode = '" . $cityCode . "' ";
......
...@@ -40,9 +40,10 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -40,9 +40,10 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
* @return array * @return array
*/ */
public function find($where) { public function find($where) {
$this->setDb(); $this->setDb($this->dbName);
$field='*'; $field='*';
$data=$this->db->select($field)->from($this->_tableName)->where($where)->fetchOne(); $data=$this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
echo $this->db->getLastSql();exit;
return $data; return $data;
} }
public function getField(){ public function getField(){
...@@ -55,18 +56,15 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -55,18 +56,15 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
* @return mixed * @return mixed
*/ */
public function update($data,$where){ public function update($data,$where){
$this->setDb(); $this->setDb(DbNameConst::masterDBConnectName);
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute(); return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
} }
/**
* 插入数据
* @param $data
* @return mixed
*/
public function insert($data){ public function insert($data){
$this->setDb(DbNameConst::masterDBConnectName);
return $this->db->insert($this->_tableName)->rows($data)->execute();
} }
/** /**
* 排序,1:关注时间降序,2:关注时间升序,3:购买力降序,4:购买力升序,默认1 * 排序,1:关注时间降序,2:关注时间升序,3:购买力降序,4:购买力升序,默认1
* @param $data * @param $data
...@@ -169,6 +167,19 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel { ...@@ -169,6 +167,19 @@ class StoreMemberStatisticsModel extends \DAO\AbstractModel {
return $result; 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") public function addAll($datas,$field="orderGoodsCount")
{ {
......
...@@ -43,6 +43,15 @@ class StoreStatisticsModel extends \DAO\AbstractModel { ...@@ -43,6 +43,15 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
return $data; 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 * @param $data
...@@ -141,7 +150,19 @@ class StoreStatisticsModel extends \DAO\AbstractModel { ...@@ -141,7 +150,19 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
* @var \DAO\UserModel * @var \DAO\UserModel
*/ */
private static $_instance = null; 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 { ...@@ -166,6 +187,7 @@ class StoreStatisticsModel extends \DAO\AbstractModel {
'order_total as orderTotal', 'order_total as orderTotal',
'fav_count as favCount', 'fav_count as favCount',
'goods_count as goodsCount', 'goods_count as goodsCount',
'order_total_online as orderTotalOnline',
); );
} }
......
...@@ -48,7 +48,7 @@ class cliOrderClose extends basecli ...@@ -48,7 +48,7 @@ class cliOrderClose extends basecli
$redis->auth($conf['password']); $redis->auth($conf['password']);
} }
$clientPush=\JPush\ClientPush::getInstance(); $clientPush=\JPush\ClientPush::getInstance();
$clientPush->pushTest(array());exit; $clientPush->pushTest(array());
$memberCenterServiceDao=\Business\User\MemberCenterServiceModel::getInstance(); $memberCenterServiceDao=\Business\User\MemberCenterServiceModel::getInstance();
//$messageService=\DAO\MessageHistoryModel::getInstance(); //$messageService=\DAO\MessageHistoryModel::getInstance();
while($pushData=$redis->rPop('push_center')){ while($pushData=$redis->rPop('push_center')){
......
...@@ -70,15 +70,15 @@ class cliShopkeeperIndex extends basecli ...@@ -70,15 +70,15 @@ class cliShopkeeperIndex extends basecli
$shopkeeperService = \Business\Store\ShopkeeperServiceModel::getInstance(); $shopkeeperService = \Business\Store\ShopkeeperServiceModel::getInstance();
$shopkeeperService->baseDir= \Our\Common::getConfig('out.config'); $shopkeeperService->baseDir= \Our\Common::getConfig('out.config');
try { try {
// $shopkeeperService->insertStoreMemberStatics(); $shopkeeperService->insertStoreMemberStatics();
//退货退款订单自动关闭 //退货退款订单自动关闭
$shopkeeperService->reduceStoreMemberStatics(); $shopkeeperService->reduceStoreMemberStatics();
//$shopkeeperService->storeStatictisTask(); // $shopkeeperService->storeStatictisTask();
$shopkeeperService->updateLastId(); // $shopkeeperService->updateLastId();
} catch (Exception $ex) { } catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage()); 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