Commit 9a3c2507 authored by liuyuzhen's avatar liuyuzhen

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

parents 3f321f14 47a6b62c
...@@ -101,7 +101,7 @@ class Common ...@@ -101,7 +101,7 @@ class Common
return $url; return $url;
} }
function is_https() { public static function is_https() {
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true; return true;
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) { } elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
......
...@@ -169,7 +169,7 @@ class EvaluationServiceModel extends \Business\AbstractModel { ...@@ -169,7 +169,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
//删除缓存 //删除缓存
\Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderInstance, 'find'),array(),array($order['order_id'])); \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderInstance, 'find'),array(),array($order['order_id']));
//\DAO\MemberModel::getInstance()->_changeNum(\Our\NameConst::waitEvaluate,$memberId,-1); //\DAO\MemberModel::getInstance()->_changeNum(\Our\NameConst::waitEvaluate,$memberId,-1);
$orderInstance->deleteOrderCache($memberId, $order['order_id']); $orderInstance->deleteOrderCache($memberId, $order['order_id'],$order['store_id']);
} }
/** /**
......
...@@ -23,6 +23,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -23,6 +23,9 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
public function getGroupGoods($param){ public function getGroupGoods($param){
$groupId = intval($param['groupId']); $groupId = intval($param['groupId']);
$groupList = $this->getPBundlingListByBlIds(array($groupId)); $groupList = $this->getPBundlingListByBlIds(array($groupId));
if(!$groupList){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyPBundlingdForOrder);
}
$data = $groupList[0]; $data = $groupList[0];
if($data['goodsCountFlag'] === false){ if($data['goodsCountFlag'] === false){
$data['state'] = 0; $data['state'] = 0;
......
...@@ -274,7 +274,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -274,7 +274,7 @@ class OrderServiceModel extends \Business\AbstractModel
$res=$orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateCancel); $res=$orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateCancel);
if($res){ if($res){
if ($memberId) { if ($memberId) {
$orderDao->deleteOrderCache($memberId, $orderId); $orderDao->deleteOrderCache($memberId, $orderId,$order['store_id']);
// $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel); // $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
} }
} }
...@@ -296,7 +296,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -296,7 +296,7 @@ class OrderServiceModel extends \Business\AbstractModel
if ($isAllowConfirm) { if ($isAllowConfirm) {
$res = $orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateComplete, TRUE); $res = $orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateComplete, TRUE);
if ($res) { if ($res) {
$orderDao->deleteOrderCache($memberId, $orderId); $orderDao->deleteOrderCache($memberId, $orderId,$order['store_id']);
\Our\RedisHelper::memberTotalFromStateToState($memberId,$order['order_state'],ApiConst::orderStateComplete); \Our\RedisHelper::memberTotalFromStateToState($memberId,$order['order_state'],ApiConst::orderStateComplete);
return true; return true;
} else { } else {
...@@ -395,7 +395,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -395,7 +395,7 @@ class OrderServiceModel extends \Business\AbstractModel
$orders = $orderDao->getOrdersByOrderState(ApiConst::orderStateWaitConfirm, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField); $orders = $orderDao->getOrdersByOrderState(ApiConst::orderStateWaitConfirm, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
if (!empty($orders)) { if (!empty($orders)) {
foreach ($orders as $order) { foreach ($orders as $order) {
$orderDao->deleteOrderCache($order['buyerId'], $order['orderId']); $orderDao->deleteOrderCache($order['buyerId'], $order['orderId'],$order['storeId']);
\Our\RedisHelper::memberTotalFromStateToState($order['buyerId'],$order['orderState'],ApiConst::orderStateClose); \Our\RedisHelper::memberTotalFromStateToState($order['buyerId'],$order['orderState'],ApiConst::orderStateClose);
} }
$res = $orderDao->updateOrdersByorderState(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField); $res = $orderDao->updateOrdersByorderState(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
...@@ -425,13 +425,13 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -425,13 +425,13 @@ class OrderServiceModel extends \Business\AbstractModel
if ($order['shippingType'] == ApiConst::bySeller) { if ($order['shippingType'] == ApiConst::bySeller) {
if (isset($qmDeliverymanLogsOrderIds[$order['orderId']])) { if (isset($qmDeliverymanLogsOrderIds[$order['orderId']])) {
array_push($sellerOrderIds, $order['orderId']); array_push($sellerOrderIds, $order['orderId']);
$orderDao->deleteOrderCache($order['buyerId'], $order['orderId']); $orderDao->deleteOrderCache($order['buyerId'], $order['orderId'],$order['storeId']);
} }
} else { } else {
$limitTime = TIMESTAMP - ApiConst::orderWaitRecieveThreeDays; $limitTime = TIMESTAMP - ApiConst::orderWaitRecieveThreeDays;
if ($order['acceptTime'] < $limitTime) { if ($order['acceptTime'] < $limitTime) {
array_push($expressOrderIds, $order['orderId']); array_push($expressOrderIds, $order['orderId']);
$orderDao->deleteOrderCache($order['buyerId'], $order['orderId']); $orderDao->deleteOrderCache($order['buyerId'], $order['orderId'],$order['storeId']);
} }
} }
\Our\RedisHelper::memberTotalFromStateToState($order['buyerId'],$order['orderState'],ApiConst::orderStateComplete); \Our\RedisHelper::memberTotalFromStateToState($order['buyerId'],$order['orderState'],ApiConst::orderStateComplete);
...@@ -642,7 +642,7 @@ class OrderServiceModel extends \Business\AbstractModel ...@@ -642,7 +642,7 @@ class OrderServiceModel extends \Business\AbstractModel
$push=Push::getInstance(); $push=Push::getInstance();
$push->reacheRemind($order['buyerId'],$order['orderId'],$order['orderSn']); $push->reacheRemind($order['buyerId'],$order['orderId'],$order['orderSn']);
} }
$orderDao->deleteOrderCache($memberid, $qmDeliveryManLog['orderId']); $orderDao->deleteOrderCache($memberid, $qmDeliveryManLog['orderId'],$order['storeId']);
$qmDeliverymanLogDao->deleteOrderCache($deliverymanId, $id); $qmDeliverymanLogDao->deleteOrderCache($deliverymanId, $id);
return $updateResult; return $updateResult;
} else { } else {
......
...@@ -46,27 +46,31 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -46,27 +46,31 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
//获得统计数据 //获得统计数据
public function getStatistics($memberId) public function getStatistics($memberId)
{ {
$storeId = $this->_getStoreByMemberId($memberId); $memberDao=\DAO\MemberModel::getInstance();
$storeStatisticsDayDao = \DAO\Store\StoreStatisticsDayModel::getInstance(); $storeId=$memberDao->getInfo($memberId,'store_id');
$storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance(); //$storeId = $this->_getStoreByMemberId($memberId);
// $storeStatisticsDayDao = \DAO\Store\StoreStatisticsDayModel::getInstance();
// $storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
$orderDao=\DAO\Order\OrderModel::getInstance();
$favoritesStoreDao=\DAO\FavoritesStoreModel::getInstance();
$condition['store_id'] = $storeId; $condition['store_id'] = $storeId;
//获取店铺信息 //获取店铺信息
$store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId)); $store = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this->storeDao, 'getInfo'), array($condition), ApiConst::tenDaySecond, array($storeId));
//获取店铺数据统计 //获取店铺数据统计
$storeStats = $storeStatisticsDao->find($condition); //$storeStats = $storeStatisticsDao->find($condition);
//获取店铺今日销售额和订单量 //获取店铺今日销售额和订单量
$today = date('Y-m-d', TIMESTAMP); $storeStats = $orderDao->getShopKeeperCountByStoreIdCache($storeId);
$storeTodayStats = $storeStatisticsDayDao->getByStoreIdAndGmtCreate($storeId, $today); $storeFavariteCount=$favoritesStoreDao->getFavoritesCountByStoreIdCache($storeId);
$data['storeId'] = $store['store_id']; $data['storeId'] = $store['store_id'];
$data['storeName'] = $store['store_name']; $data['storeName'] = $store['store_name'];
$data['storeLabel'] = $store['store_label']; $data['storeLabel'] = $store['store_label'];
$data['goodsCount'] = isset($storeStats['goodsCount']) ? $storeStats['goodsCount'] : ApiConst::zero; $data['goodsCount'] = ApiConst::zero;
$data['orderCount'] = isset($storeStats['orderCount']) ? $storeStats['orderCount'] : ApiConst::zero; $data['orderCount'] =$storeStats['orderCount'];
$data['orderTotal'] = isset($storeStats['orderTotal']) ? $storeStats['orderTotal'] : ApiConst::zero; $data['orderTotal'] = $storeStats['orderTotal'];
$data['favCount'] = isset($storeStats['favCount']) ? $storeStats['favCount'] : ApiConst::zero; $data['favCount'] = $storeFavariteCount['favCount'];
$data['todayOrderCount'] = isset($storeTodayStats['orderCount']) ? $storeTodayStats['orderCount'] : ApiConst::zero; $data['todayOrderCount'] = $storeStats['todayOrderCount'];
$data['todayOrderTotal'] = isset($storeTodayStats['orderTotal']) ? $storeTodayStats['orderTotal'] : ApiConst::zero; $data['todayOrderTotal'] = $storeStats['todayOrderTotal'];
$data['tadayFavCount'] = isset($storeTodayStats['favCount']) ? $storeTodayStats['favCount'] : ApiConst::zero; $data['tadayFavCount'] = $storeFavariteCount['todayFavCount'];
return $data; return $data;
} }
...@@ -233,7 +237,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -233,7 +237,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
} else { } else {
$update_data['order_state'] = ApiConst::orderStateWaitSend; $update_data['order_state'] = ApiConst::orderStateWaitSend;
$result = $orderDao->update($where, $update_data); $result = $orderDao->update($where, $update_data);
$orderDao->deleteOrderCache($order['buyer_id'], $orderId); $orderDao->deleteOrderCache($order['buyer_id'], $orderId,$order['store_id']);
\Our\RedisHelper::memberTotalFromStateToState($order['buyer_id'], $order['order_state'], ApiConst::orderStateWaitSend); \Our\RedisHelper::memberTotalFromStateToState($order['buyer_id'], $order['order_state'], ApiConst::orderStateWaitSend);
return $result; return $result;
} }
...@@ -475,6 +479,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -475,6 +479,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
public function insertStoreMemberStatics() public function insertStoreMemberStatics()
{ {
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName); $orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName); $storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime); $gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime);
$gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero; $gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero;
...@@ -485,6 +490,13 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -485,6 +490,13 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$addDatas = array(); $addDatas = array();
$storeMemberStatisticData = $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize); $storeMemberStatisticData = $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize);
$storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false; $storeMemberStatisticData = isset($storeMemberStatisticData['list']) ? $storeMemberStatisticData['list'] : false;
$orderIds=array_column($storeMemberStatisticData,'orderId');
array_unique($orderIds);
if(!empty($orderIds)){
$orders=$orderDao->getByOrderId($orderIds,'order_amount as orderAmount,order_id as orderId','orderId');
}else{
$orders=[];
}
if ($storeMemberStatisticData) { if ($storeMemberStatisticData) {
$this->taskIndex++; $this->taskIndex++;
foreach ($storeMemberStatisticData as $value) { foreach ($storeMemberStatisticData as $value) {
...@@ -496,9 +508,10 @@ class ShopkeeperServiceModel extends \Business\AbstractModel ...@@ -496,9 +508,10 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'] = $value['goodsNum']; $addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'] = $value['goodsNum'];
} }
if (isset($addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'])) { if (isset($addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'])) {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] += $value['goodsPrice']; // $addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] += $value['goodsPrice'];
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] +=$orders[$value['orderId']]['orderAmount'];
} else { } else {
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] = $value['goodsPrice']; $addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderTotal'] = $orders[$value['orderId']]['orderAmount'];
} }
} }
} }
......
...@@ -113,7 +113,7 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -113,7 +113,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$defaultDeliveryTime = (empty($formula['default_time'])?$formula[2]['time']:$formula['default_time']); $defaultDeliveryTime = (empty($formula['default_time'])?$formula[2]['time']:$formula['default_time']);
} }
if(!$defaultDeliveryTime){ if(!$defaultDeliveryTime){
$in_store_service_flag = 0; //$in_store_service_flag = 0;
$defaultDeliveryTime = 0; $defaultDeliveryTime = 0;
} }
}else{ }else{
...@@ -734,86 +734,7 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -734,86 +734,7 @@ class StoreServiceModel extends \Business\AbstractModel{
} }
return false; return false;
} }
// /**
// * 获取组合销售对应商品列表
// * @param $param
// * @return array
// * @throws \Exception
// * @throws \Our\Exception
// */
// public function getGroupSaleGoodsList($param){
// $storeId = (int)$param['storeId'];
// if(!$storeId){
// \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyStoreId);
// }
// $pageSize = (int)$param['pageSize'];
// $pageIndex = (int)$param['pageIndex'];
// if($pageSize === 0){
// \Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
// }
// $limit = array($pageIndex*$pageSize,$pageSize);
// $where = array('store_id'=>$storeId);
// //$field = 'bl_id,bl_name,bl_title,store_id,bl_discount_price,bl_sum_price,bl_quota_starttime,bl_quota_endtime,bl_image';
// $field = 'bl_id AS blId,bl_name AS name,bl_title,store_id,store_name,bl_state,bl_quota_starttime,bl_image,bl_storage,bl_discount_price AS discountPrice,bl_sum_price AS sumPrice,bl_quota_endtime AS endTime,image';
// $pbundlingInstance = \DAO\PBundlingModel::getInstance();
//
// $list = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getList'),array($field,array('store_id'=>$storeId),$limit),\Our\ApiConst::oneDaySecond,array($storeId));
// $group = [];
// if($list){
// $totalCount = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(),array(&$pbundlingInstance, 'getCount'),array(array('store_id'=>$storeId)),\Our\ApiConst::oneDaySecond,array($storeId));
// $groupList = \Business\Goods\GroupSaleServiceModel::getInstance()->getGoods($list);
// foreach ($groupList as $k=>$v){
// $v['groupId'] = $v['blId'];
// $v['image'] = \Our\ImageUtil::getGoodsImgUrl($v['image']);
// unset($v['bl_title']);
// unset($v['store_id']);
// unset($v['store_name']);
// unset($v['bl_state']);
// unset($v['bl_quota_starttime']);
// unset($v['bl_image']);
// unset($v['bl_storage']);
// unset($v['blId']);
// unset($v['goodsCountFlag']);
// unset($v['endTime']);
// $goods = [];
// if($v['goodsList']){
// foreach ($v['goodsList'] as $v2){
// unset($v2['goods_id']);
// unset($v2['goodsStorage']);
// $goods[] = $v2;
// }
// }
// unset($v['goodsList']);
// $group[$k] = $v;
// $group[$k]['goods'] = $goods;
// }
// }else{
// $totalCount = 0;
// }
//
//// var_dump($group);exit;
//// $groupSaleGoods = [];
//// $blIds = [];
//// foreach ($list as $k=>$v){
//// $groupSaleGoods[$v['bl_id']] = array('groupId'=>$v['bl_id'],'name'=>$v['bl_name'],'image'=>\DAO\PBundlingModel::getInstance()->getImgPath($v['bl_image']),'price'=>$v['bl_discount_price'],'sumPrice'=>$v['bl_sum_price']);
//// $blIds[]=$v['bl_id'];
//// }
//// if($blIds){
//// $bundingGoodsDAO = \DAO\PBundlingGoodsModel::getInstance();
//// $goods = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingGoodsRedisModel::getInstance(),array(&$bundingGoodsDAO, 'getList'),array('bl_id,goods_commonid AS goodsCommonId,goods_name AS goodsName,goods_image AS goodsImage,bl_count_price AS goodsPrice,bl_goods_price AS discountPrice,num','bl_id in('.implode(',',$blIds).')'),\Our\ApiConst::oneDaySecond,array($storeId));
//// foreach ($goods as $v){
//// $v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage']);
//// $bl_id = $v['bl_id'];
//// $v['goodsAttr'] = [];
//// unset($v['bl_id']);
//// $groupSaleGoods[$bl_id]['goods'][] = $v;
////
//// }
//// }
//// $groupSaleGoods && $groupSaleGoods = array_values($groupSaleGoods);
// return array('totalCount'=>$totalCount,'groupGoods'=>$group);
// }
/** /**
* 获取热销专区的商品 * 获取热销专区的商品
......
...@@ -105,7 +105,7 @@ class FootprintServiceModel extends \Business\AbstractModel ...@@ -105,7 +105,7 @@ class FootprintServiceModel extends \Business\AbstractModel
$field = 'bl_id AS blId,bl_name AS name,bl_title,store_id,store_name,bl_state,bl_quota_starttime,bl_image,bl_storage,bl_discount_price AS discountPrice,bl_sum_price AS sumPrice,bl_quota_endtime AS endTime,image,is_transport,transport_id'; $field = 'bl_id AS blId,bl_name AS name,bl_title,store_id,store_name,bl_state,bl_quota_starttime,bl_image,bl_storage,bl_discount_price AS discountPrice,bl_sum_price AS sumPrice,bl_quota_endtime AS endTime,image,is_transport,transport_id';
$pbundlingInstance = \DAO\PBundlingModel::getInstance(); $pbundlingInstance = \DAO\PBundlingModel::getInstance();
$where2 = ' bl_id in ('.implode(',',$groupIds).')'; $where2 = ' bl_id in ('.implode(',',$groupIds).')';
$groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2), \Our\ApiConst::oneDaySecond); $groupList = \Our\RedisHelper::cachedFunction(\Redis\Db4\PBundlingRedisModel::getInstance(), array(&$pbundlingInstance, 'getList'), array($field,$where2), \Our\ApiConst::oneMinute);
if($groupList) { if($groupList) {
$dates = array_column($browseList,'browsedate','group_id'); $dates = array_column($browseList,'browsedate','group_id');
foreach ($groupList as $group) { foreach ($groupList as $group) {
...@@ -122,10 +122,10 @@ class FootprintServiceModel extends \Business\AbstractModel ...@@ -122,10 +122,10 @@ class FootprintServiceModel extends \Business\AbstractModel
} }
} }
foreach ($browseList as $browse) { foreach ($browseList as $browse) {
if($browse['goods_commonid']) { if($browse['goods_commonid'] && $goodsCommons[$browse['goods_commonid']]) {
$footPrints[] = $goodsCommons[$browse['goods_commonid']]; $footPrints[] = $goodsCommons[$browse['goods_commonid']];
} }
if($browse['group_id']) { if($browse['group_id'] && $groups[$browse['group_id']]) {
$footPrints[] = $groups[$browse['group_id']]; $footPrints[] = $groups[$browse['group_id']];
} }
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
namespace DAO; namespace DAO;
use OSS\Common;
use Our\ApiConst;
class FavoritesStoreModel extends \DAO\AbstractModel { class FavoritesStoreModel extends \DAO\AbstractModel {
...@@ -58,6 +61,25 @@ class FavoritesStoreModel extends \DAO\AbstractModel { ...@@ -58,6 +61,25 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
$this->setDb($this->dbName); $this->setDb($this->dbName);
return $this->db->from($this->_tableName)->where($where)->fetchNum(); return $this->db->from($this->_tableName)->where($where)->fetchNum();
} }
public function getFavoritesCountByStoreId($storeId){
$where=\Our\Common::format(" store_id={0}",$storeId);
$total['favCount']=$this->getFavoritesStoreCount($where);
$todayBegin=strtotime(date('Y-m-d',TIMESTAMP));
$todayEnd=TIMESTAMP;
$where.=\Our\Common::format( " and fav_time between {0} and {1}",$todayBegin,$todayEnd);
$total['todayFavCount']=$this->getFavoritesStoreCount($where);
return $total?$total:array();
}
//删除订单列表缓存
public function deleteGetFavoritesCountByStoreId($storeId)
{
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getFavoritesCountByStoreId'), array(), array($storeId));
}
public function getFavoritesCountByStoreIdCache($storeId){
return \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getFavoritesCountByStoreId'), array($storeId), \Our\ApiConst::oneDaySecond,array($storeId));
}
public function insertOrUpdate($data){ public function insertOrUpdate($data){
$this->setDb(\Our\DbNameConst::masterDBConnectName); $this->setDb(\Our\DbNameConst::masterDBConnectName);
$baseSql = "insert into {$this->_tableName}(member_id,store_id,fav_type,fav_time) values({0},{1},1,{2}) ON DUPLICATE KEY UPDATE fav_type=1,fav_time=VALUES (fav_time)"; $baseSql = "insert into {$this->_tableName}(member_id,store_id,fav_type,fav_time) values({0},{1},1,{2}) ON DUPLICATE KEY UPDATE fav_type=1,fav_time=VALUES (fav_time)";
......
...@@ -33,7 +33,11 @@ class GoodsAttributeModel extends \DAO\AbstractModel { ...@@ -33,7 +33,11 @@ class GoodsAttributeModel extends \DAO\AbstractModel {
$productData = []; $productData = [];
if(is_array($data) && !empty($data)){ if(is_array($data) && !empty($data)){
foreach ($data as $v){ foreach ($data as $v){
$productData[] = array('attrName'=>$v['attribute'],'attrValue'=>unserialize($v['attribute_value'])); $attrValue = unserialize($v['attribute_value']);
if(!is_array($attrValue)) {
$attrValue = array($attrValue);
}
$productData[] = array('attrName'=>$v['attribute'],'attrValue'=>$attrValue);
} }
} }
return $productData; return $productData;
......
...@@ -27,6 +27,8 @@ class OrderModel extends \DAO\AbstractModel ...@@ -27,6 +27,8 @@ class OrderModel extends \DAO\AbstractModel
* @var string * @var string
*/ */
protected $_tableName = 'han_order'; protected $_tableName = 'han_order';
private $countField = '(sum(order_amount)-sum(refund_amount)) as orderTotal,count(*) as orderCount';
/** /**
* 主键 * 主键
* *
...@@ -40,12 +42,16 @@ class OrderModel extends \DAO\AbstractModel ...@@ -40,12 +42,16 @@ class OrderModel extends \DAO\AbstractModel
//$this->setDb(); //$this->setDb();
} }
public function getOrderDetailField(){ public function getOrderDetailField()
{
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,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'; return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,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';
} }
public function getOrderShippingField(){
public function getOrderShippingField()
{
return "order_id as orderId,order_sn as orderSn,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,shipping_code as shippingCode"; return "order_id as orderId,order_sn as orderSn,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,shipping_code as shippingCode";
} }
public function getCount($where, $isArray = true) public function getCount($where, $isArray = true)
{ {
$this->setDb(); $this->setDb();
...@@ -68,6 +74,33 @@ class OrderModel extends \DAO\AbstractModel ...@@ -68,6 +74,33 @@ class OrderModel extends \DAO\AbstractModel
return $this->db->select($field)->from($this->_tableName)->where($where)->group($group)->fetchAll(); return $this->db->select($field)->from($this->_tableName)->where($where)->group($group)->fetchAll();
} }
public function getOrderCounts($where, $field)
{
$this->setDb();
return $this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
}
public function getShopKeeperCountByStoreId($storeId)
{
$begin = strtotime(date("Y-m-d"), time());
$end = TIMESTAMP;
$where = Common::format(" store_id={0}", $storeId);
$orderTotal = $this->getOrderCounts($where, $this->countField);
$where .= Common::format(" and add_time between {0} and {1}", $begin, $end);
$todayTotal = $this->getOrderCounts($where, $this->countField);
$total['todayOrderTotal'] = isset($todayTotal['orderTotal']) ? $todayTotal['orderTotal'] : ApiConst::zero;
$total['todayOrderCount'] = isset($todayTotal['orderCount']) ? $todayTotal['orderCount'] : ApiConst::zero;
$total['orderTotal'] = isset($orderTotal['orderTotal']) ? (int)$orderTotal['orderTotal'] : ApiConst::zero;
$total['orderCount'] = isset($orderTotal['orderCount']) ? $orderTotal['orderCount'] : ApiConst::zero;
return $total;
}
public function getShopKeeperCountByStoreIdCache($storeId)
{
return \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getShopKeeperCountByStoreId'), array($storeId), \Our\ApiConst::oneDaySecond, array($storeId));
}
/** /**
* 获取单条数据 * 获取单条数据
* @param $where * @param $where
...@@ -98,20 +131,23 @@ class OrderModel extends \DAO\AbstractModel ...@@ -98,20 +131,23 @@ class OrderModel extends \DAO\AbstractModel
//判断订单是否允许取消 //判断订单是否允许取消
public function isAllowCancel($order) public function isAllowCancel($order)
{ {
if ($order['order_state'] == ApiConst::orderStateWaitPay || $order['order_state'] == ApiConst::orderStateWaitConfirm || (($order['order_state'] == ApiConst::orderStateWaitSend || $order['order_state'] == ApiConst::orderStateWaitRecieve) && $order['is_receive_payment'] == ApiConst::noreceivePayment)) { if ($order['order_state'] == ApiConst::orderStateWaitPay || $order['order_state'] == ApiConst::orderStateWaitConfirm || (($order['order_state'] == ApiConst::orderStateWaitSend || $order['order_state'] == ApiConst::orderStateWaitRecieve) && $order['is_receive_payment'] == ApiConst::noreceivePayment)) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
//列表转换 //列表转换
public function convertOrderList($list){ public function convertOrderList($list)
$convertList=array(); {
foreach($list as $order){ $convertList = array();
$convertList[$order['orderId']]=$order; foreach ($list as $order) {
$convertList[$order['orderId']] = $order;
} }
return $convertList; return $convertList;
} }
//confirm //confirm
public function isAllowConfirm($order) public function isAllowConfirm($order)
{ {
...@@ -176,11 +212,13 @@ class OrderModel extends \DAO\AbstractModel ...@@ -176,11 +212,13 @@ class OrderModel extends \DAO\AbstractModel
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute(); return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
} }
public function insert($data){ public function insert($data)
{
$this->setDb(\Our\DbNameConst::masterDBConnectName); $this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->insert($this->_tableName)->rows($data)->execute(); $result = $this->db->insert($this->_tableName)->rows($data)->execute();
return $result ; return $result;
} }
/** /**
* 删除订单 * 删除订单
* @param $data * @param $data
...@@ -194,18 +232,18 @@ class OrderModel extends \DAO\AbstractModel ...@@ -194,18 +232,18 @@ class OrderModel extends \DAO\AbstractModel
return $this->update($where, $data); return $this->update($where, $data);
} }
public function updateStatusByOrderId($orderIds, $status,$isConfirm=false) public function updateStatusByOrderId($orderIds, $status, $isConfirm = false)
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
if(is_array($orderIds)){ if (is_array($orderIds)) {
$where['order_id']=array('in',$orderIds); $where['order_id'] = array('in', $orderIds);
}else{ } else {
$where['order_id'] = $orderIds; $where['order_id'] = $orderIds;
} }
$where = $this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
$data['order_state'] = $status; $data['order_state'] = $status;
if($isConfirm){ if ($isConfirm) {
$data['shipping_over']=ApiConst::shippingOver; $data['shipping_over'] = ApiConst::shippingOver;
} }
return $this->update($where, $data); return $this->update($where, $data);
} }
...@@ -287,8 +325,8 @@ class OrderModel extends \DAO\AbstractModel ...@@ -287,8 +325,8 @@ class OrderModel extends \DAO\AbstractModel
$totalCount = $this->db->select($field)->from($this->_tableName) $totalCount = $this->db->select($field)->from($this->_tableName)
->join('han_order_common', $this->_tableName . '.order_id = han_order_common.order_id', 'left') ->join('han_order_common', $this->_tableName . '.order_id = han_order_common.order_id', 'left')
->where($where)->fetchNum(); ->where($where)->fetchNum();
$returnData['orders']=$list; $returnData['orders'] = $list;
$returnData['totalCount']=$totalCount; $returnData['totalCount'] = $totalCount;
return $returnData; return $returnData;
} }
...@@ -303,6 +341,29 @@ class OrderModel extends \DAO\AbstractModel ...@@ -303,6 +341,29 @@ class OrderModel extends \DAO\AbstractModel
return $orders['list'] ? $orders : array(); return $orders['list'] ? $orders : array();
} }
public function getByOrderId($orderId, $field, $key = false)
{
if (is_array($orderId)) {
$orderId = implode(',', $orderId);
$where = Common::format(" order_id in ({0})", $orderId);
} else {
$where['order_id'] = $orderId;
}
$res = $this->getAllByWhere($where, $field);
if (!empty($res)) {
$returnResult=$res;
if ($key) {
$returnResult = array();
foreach ($res as $re) {
$returnResult[$re[$key]] = $re;
}
}
return $returnResult;
} else {
return [];
}
}
//待收货获取订单状态信息 //待收货获取订单状态信息
public function getOrderStatusExtent($order) public function getOrderStatusExtent($order)
{ {
...@@ -349,10 +410,10 @@ class OrderModel extends \DAO\AbstractModel ...@@ -349,10 +410,10 @@ class OrderModel extends \DAO\AbstractModel
} }
//待收货详情描述处理 //待收货详情描述处理
public function getStatusDetailTextExtent($order,$type=ApiConst::buyerText) public function getStatusDetailTextExtent($order, $type = ApiConst::buyerText)
{ {
$orderText = ''; $orderText = '';
if($type==ApiConst::buyerText){ if ($type == ApiConst::buyerText) {
if ($order['orderState'] == ApiConst::orderStateWaitRecieve) { if ($order['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderText = OrderConst::waitGetFromShop;//默认到店自取 $orderText = OrderConst::waitGetFromShop;//默认到店自取
if ($order['shippingType'] == ApiConst::express) { if ($order['shippingType'] == ApiConst::express) {
...@@ -363,7 +424,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -363,7 +424,7 @@ class OrderModel extends \DAO\AbstractModel
} }
} }
} }
if($type==ApiConst::storeText){ if ($type == ApiConst::storeText) {
if ($order['orderState'] == ApiConst::orderStateWaitRecieve) { if ($order['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderText = OrderConst::waitGetFromShop;//默认到店自取 $orderText = OrderConst::waitGetFromShop;//默认到店自取
if ($order['shippingType'] == ApiConst::express) { if ($order['shippingType'] == ApiConst::express) {
...@@ -377,8 +438,10 @@ class OrderModel extends \DAO\AbstractModel ...@@ -377,8 +438,10 @@ class OrderModel extends \DAO\AbstractModel
return $orderText; return $orderText;
} }
//获得买家文案详情 //获得买家文案详情
private function getBuyerDetailText($order){ private function getBuyerDetailText($order)
{
switch ($order['orderState']) { switch ($order['orderState']) {
case ApiConst::orderStateCancel: case ApiConst::orderStateCancel:
$statusText = OrderConst::orderCancel; $statusText = OrderConst::orderCancel;
...@@ -430,6 +493,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -430,6 +493,7 @@ class OrderModel extends \DAO\AbstractModel
} }
return $statusText; return $statusText;
} }
//获取销售员订单详情描述 //获取销售员订单详情描述
public function getStatusSaleText($orderState) public function getStatusSaleText($orderState)
{ {
...@@ -462,60 +526,62 @@ class OrderModel extends \DAO\AbstractModel ...@@ -462,60 +526,62 @@ class OrderModel extends \DAO\AbstractModel
//获取订单详情描述 //获取订单详情描述
public function getStatusDetailText($order,$type=ApiConst::buyerText) public function getStatusDetailText($order, $type = ApiConst::buyerText)
{ {
if(!in_array($type,array(ApiConst::buyerText,ApiConst::storeText,ApiConst::deliveryText))){ if (!in_array($type, array(ApiConst::buyerText, ApiConst::storeText, ApiConst::deliveryText))) {
ErrorModel::throwException(CodeConfigModel::commonError); ErrorModel::throwException(CodeConfigModel::commonError);
} }
if($type==ApiConst::buyerText){ if ($type == ApiConst::buyerText) {
return $this->getBuyerDetailText($order); return $this->getBuyerDetailText($order);
} }
if($type==ApiConst::storeText){ if ($type == ApiConst::storeText) {
return $this->getStoreDetailText($order); return $this->getStoreDetailText($order);
} }
} }
//获得退款状态 //获得退款状态
public function getRefundText($order){ public function getRefundText($order)
$refundStateName=''; {
if($order['paymentTime'] >ApiConst::zero ){ $refundStateName = '';
if($order['orderState']==ApiConst::orderStateWaitSend ){ if ($order['paymentTime'] > ApiConst::zero) {
$refundStateName=DescribeConst::refund; if ($order['orderState'] == ApiConst::orderStateWaitSend) {
$refundStateName = DescribeConst::refund;
} }
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::express ){ if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::express) {
$refundStateName=DescribeConst::refundRetund; $refundStateName = DescribeConst::refundRetund;
} }
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::bySeller ){ if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::bySeller) {
$refundStateName=DescribeConst::refundRetund; $refundStateName = DescribeConst::refundRetund;
} }
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::bySelf ){ if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::bySelf) {
$refundStateName=DescribeConst::refund; $refundStateName = DescribeConst::refund;
} }
} }
if($order['paymentTime'] ==ApiConst::zero ){ if ($order['paymentTime'] == ApiConst::zero) {
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::express){ if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::express) {
$refundStateName=DescribeConst::refundRetund; $refundStateName = DescribeConst::refundRetund;
} }
} }
$diff=TIMESTAMP-$order['finnshedTime']; $diff = TIMESTAMP - $order['finnshedTime'];
if($order['orderState']==ApiConst::orderStateComplete &&$diff<ApiConst::oneDaySecond ){ if ($order['orderState'] == ApiConst::orderStateComplete && $diff < ApiConst::oneDaySecond) {
$refundStateName=='退货'; $refundStateName == '退货';
} }
return $refundStateName; return $refundStateName;
} }
public function selectedTypeId($order){ public function selectedTypeId($order)
$refundStateName=$this->getRefundText($order); {
$selectedRefundId=ApiConst::refundTypeMoney; $refundStateName = $this->getRefundText($order);
if($refundStateName==DescribeConst::refundRetund){ $selectedRefundId = ApiConst::refundTypeMoney;
$selectedRefundId=ApiConst::refundTypeGoods; if ($refundStateName == DescribeConst::refundRetund) {
$selectedRefundId = ApiConst::refundTypeGoods;
} }
return $selectedRefundId; return $selectedRefundId;
} }
public function getText($order, $textType = ApiConst::orderListDescribe) public function getText($order, $textType = ApiConst::orderListDescribe)
{ {
$text = ''; $text = '';
...@@ -694,6 +760,12 @@ class OrderModel extends \DAO\AbstractModel ...@@ -694,6 +760,12 @@ class OrderModel extends \DAO\AbstractModel
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'findByOrderId'), array($orderId)); return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'findByOrderId'), array($orderId));
} }
//删除订单列表缓存
public function deleteGetShopKeeperCountByStoreId($storeId)
{
return \Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$this, 'getShopKeeperCountByStoreId'), array(), array($storeId));
}
//删除订单列表缓存 //删除订单列表缓存
public function deleteGetListByMemberId($memberId) public function deleteGetListByMemberId($memberId)
{ {
...@@ -701,28 +773,38 @@ class OrderModel extends \DAO\AbstractModel ...@@ -701,28 +773,38 @@ class OrderModel extends \DAO\AbstractModel
} }
//删除订单缓存 //删除订单缓存
public function deleteOrderCache($memberId, $orderId=false) public function deleteOrderCache($memberId, $orderId = false, $stroeId = false, $deleteGetShopKeeperCountByStoreId = false, $deleteGetFavoritesCountByStoreId = false)
{ {
if(!empty($memberId)){ if (!empty($memberId)) {
$this->deleteGetListByMemberId($memberId); $this->deleteGetListByMemberId($memberId);
} }
if(!empty($orderId)){ if (!empty($orderId)) {
$this->deleteFindByOrderIdCache($orderId); $this->deleteFindByOrderIdCache($orderId);
$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName); $orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao->deleteOrderGoodsCache($memberId,$orderId); $orderGoodsDao->deleteOrderGoodsCache($memberId, $orderId);
\DAO\MemberModel::getInstance()->deleteTotalCache($memberId); \DAO\MemberModel::getInstance()->deleteTotalCache($memberId);
} }
if (!empty($stroeId)) {
if ($deleteGetShopKeeperCountByStoreId) {
$this->deleteGetShopKeeperCountByStoreId($stroeId);
}
if ($deleteGetFavoritesCountByStoreId) {
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$favoritesStoreDao->deleteGetFavoritesCountByStoreId($stroeId);
}
}
} }
//任务脚本方法
public function getOrdersByOrderState($orderState, $timeField = 'add_time', $timeLimit = ApiConst::orderStateWaitConfirmBeyond, $field = '*',$shippingTypes=false) //任务脚本方法
public function getOrdersByOrderState($orderState, $timeField = 'add_time', $timeLimit = ApiConst::orderStateWaitConfirmBeyond, $field = '*', $shippingTypes = false)
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where['order_state'] = $orderState; $where['order_state'] = $orderState;
$limit = TIMESTAMP - $timeLimit; $limit = TIMESTAMP - $timeLimit;
$where[$timeField] = array('lt', $limit); $where[$timeField] = array('lt', $limit);
if($shippingTypes){ if ($shippingTypes) {
$where['shipping_type']=array('in',$shippingTypes); $where['shipping_type'] = array('in', $shippingTypes);
} }
$where = $this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
$list = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll(); $list = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
...@@ -730,27 +812,25 @@ class OrderModel extends \DAO\AbstractModel ...@@ -730,27 +812,25 @@ class OrderModel extends \DAO\AbstractModel
} }
//任务脚本方法 //任务脚本方法
public function getRecieveOrders($orderState,$addTime,$pageIndex,$pageSize,$timeField='add_time') public function getRecieveOrders($orderState, $addTime, $pageIndex, $pageSize, $timeField = 'add_time')
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where['order_state'] = ApiConst::orderStateWaitConfirm; $where['order_state'] = ApiConst::orderStateWaitConfirm;
$where=Common::format(' order_state={0} and {1}>={2} and {1}<{3}',$orderState,$timeField,$addTime,TIMESTAMP); $where = Common::format(' order_state={0} and {1}>={2} and {1}<{3}', $orderState, $timeField, $addTime, TIMESTAMP);
$list=$this->lists($where,array('add_time'=>'asc'),$this->getOrderDetailField(),$pageIndex,$pageSize); $list = $this->lists($where, array('add_time' => 'asc'), $this->getOrderDetailField(), $pageIndex, $pageSize);
return $list; return $list;
} }
//任务脚本方法
public function updateOrdersByorderState($orderState, $toState, $timeField = 'add_time', $timeLimit = ApiConst::orderStateWaitConfirmBeyond)
//任务脚本方法
public function updateOrdersByorderState($orderState,$toState, $timeField = 'add_time', $timeLimit = ApiConst::orderStateWaitConfirmBeyond)
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
$where['order_state'] = $orderState; $where['order_state'] = $orderState;
$limit = TIMESTAMP - $timeLimit; $limit = TIMESTAMP - $timeLimit;
$where[$timeField] = array('lt', $limit); $where[$timeField] = array('lt', $limit);
$where = $this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
return $this->db->update($this->_tableName)->where($where)->rows(array('order_state'=>$toState))->execute(); return $this->db->update($this->_tableName)->where($where)->rows(array('order_state' => $toState))->execute();
} }
...@@ -761,25 +841,28 @@ class OrderModel extends \DAO\AbstractModel ...@@ -761,25 +841,28 @@ class OrderModel extends \DAO\AbstractModel
* @param string $field * @param string $field
* @return mixed * @return mixed
*/ */
public function getListByCon($where,$field = \Our\NameConst::allField){ public function getListByCon($where, $field = \Our\NameConst::allField)
{
$this->setDb($this->dbName); $this->setDb($this->dbName);
if(is_array($where)){ if (is_array($where)) {
$where=$this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
} }
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll(); $result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
return $result; return $result;
} }
public function getShippingTypeSellerOrdersByOrders($orders){ public function getShippingTypeSellerOrdersByOrders($orders)
$shippingTypeOrderIds=array(); {
foreach($orders as $order){ $shippingTypeOrderIds = array();
if($order['shippingType']==ApiConst::bySeller){ foreach ($orders as $order) {
array_push($shippingTypeOrderIds,$order['orderId']); if ($order['shippingType'] == ApiConst::bySeller) {
array_push($shippingTypeOrderIds, $order['orderId']);
} }
} }
return $shippingTypeOrderIds; return $shippingTypeOrderIds;
} }
public function getConvertOrder($order, $fields = array()) public function getConvertOrder($order, $fields = array())
{ {
$convertResult = array(); $convertResult = array();
...@@ -816,6 +899,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -816,6 +899,7 @@ class OrderModel extends \DAO\AbstractModel
'deliveryTime' => 'delivery_time', 'deliveryTime' => 'delivery_time',
); );
} }
public function getOrderAndOrderGoods($where, $field, $group = false, $limit = [], $order = []) public function getOrderAndOrderGoods($where, $field, $group = false, $limit = [], $order = [])
{ {
$this->setDb($this->dbName); $this->setDb($this->dbName);
...@@ -829,30 +913,36 @@ class OrderModel extends \DAO\AbstractModel ...@@ -829,30 +913,36 @@ class OrderModel extends \DAO\AbstractModel
eval($str); eval($str);
return $result; return $result;
} }
public function getAllByWhere($where,$field){
public function getAllByWhere($where, $field)
{
$this->setDb($this->dbName); $this->setDb($this->dbName);
if(is_array($where)){ if (is_array($where)) {
$where=$this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
} }
return $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll(); return $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
} }
public function updateCancelUnpayedOrderTimeCache($time){ public function updateCancelUnpayedOrderTimeCache($time)
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnPayedOrderTimePrefix,$time); {
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnPayedOrderTimePrefix, $time);
} }
public function getCancelUnpayedOrderTimeCache(){ public function getCancelUnpayedOrderTimeCache()
$res=\Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix); {
echo 'abcd'.json_encode($res); $res = \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix); echo 'abcd' . json_encode($res);
return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
} }
public function updateCancelUnReceivedOrderTimeCache($time){ public function updateCancelUnReceivedOrderTimeCache($time)
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnReceivedOrderTimePrefix,$time); {
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnReceivedOrderTimePrefix, $time);
} }
public function getCancelUnReceivedOrderTimeCache(){ public function getCancelUnReceivedOrderTimeCache()
{
return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnReceivedOrderTimePrefix); return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnReceivedOrderTimePrefix);
} }
......
...@@ -17,7 +17,7 @@ class OrderGoodsModel extends \DAO\AbstractModel { ...@@ -17,7 +17,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
* @var string * @var string
*/ */
protected $_tableName = 'han_order_goods'; protected $_tableName = 'han_order_goods';
public $sumField="rec_id,store_id as storeId,buyer_id as buyerId,goods_num as goodsNum,goods_price as goodsPrice,gmt_create as gmtCreate"; public $sumField="rec_id,store_id as storeId,buyer_id as buyerId,goods_num as goodsNum,goods_price as goodsPrice,gmt_create as gmtCreate,order_id as orderId";
public $groupField=array('buyer_id','store_id'); public $groupField=array('buyer_id','store_id');
public $orderGoodsField = "order_id as orderId,rec_id as recId,goods_id as goodsId,goods_name as goodsName,goods_price as goodsPrice,goods_num as goodsNum,goods_image as goodsImage,goods_pay_price as goodsPayPrice,sale_act_id as saleActId,sale_id as saleId,comment_state as commentState,is_refund as isRefund,goods_spec as goodsSpec,refund_state_name as refundStateName,refund_id as refundId"; public $orderGoodsField = "order_id as orderId,rec_id as recId,goods_id as goodsId,goods_name as goodsName,goods_price as goodsPrice,goods_num as goodsNum,goods_image as goodsImage,goods_pay_price as goodsPayPrice,sale_act_id as saleActId,sale_id as saleId,comment_state as commentState,is_refund as isRefund,goods_spec as goodsSpec,refund_state_name as refundStateName,refund_id as refundId";
......
...@@ -38,7 +38,7 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -38,7 +38,7 @@ class PBundlingModel extends \DAO\AbstractModel {
if(is_array($where)){ if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where); $where = $this->db->getSqlWhereByArray($where);
} }
return $this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->limit($limit[0],$limit[1])->fetchAll(); return $this->db->select($field)->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->limit($limit[0],$limit[1])->fetchAll();
} }
public function getImgPath($image){ public function getImgPath($image){
if($image){ if($image){
...@@ -48,11 +48,11 @@ class PBundlingModel extends \DAO\AbstractModel { ...@@ -48,11 +48,11 @@ class PBundlingModel extends \DAO\AbstractModel {
public function getDetail($where,$field,$limit=false){ public function getDetail($where,$field,$limit=false){
$this->setDb($this->dbName); $this->setDb($this->dbName);
return $this->db->select($field)->from($this->_tableName)->join('han_p_bundling_goods',"han_p_bundling_goods.bl_id = han_p_bundling.bl_id",'inner')->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->limit($limit[0],$limit[1])->fetchAll(); return $this->db->select($field)->from($this->_tableName)->join('han_p_bundling_goods',"han_p_bundling_goods.bl_id = han_p_bundling.bl_id",'inner')->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->limit($limit[0],$limit[1])->fetchAll();
} }
public function getCount($where){ public function getCount($where){
$this->setDb($this->dbName); $this->setDb($this->dbName);
return $this->db->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->fetchNum(); return $this->db->from($this->_tableName)->where($where)->where("bl_quota_starttime <= ".time())->where('bl_quota_endtime >= '.time())->where('bl_state=1')->where('is_del=0')->fetchNum();
} }
......
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