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
return $url;
}
function is_https() {
public static function is_https() {
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
......
......@@ -169,7 +169,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
//删除缓存
\Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderInstance, 'find'),array(),array($order['order_id']));
//\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 {
public function getGroupGoods($param){
$groupId = intval($param['groupId']);
$groupList = $this->getPBundlingListByBlIds(array($groupId));
if(!$groupList){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyPBundlingdForOrder);
}
$data = $groupList[0];
if($data['goodsCountFlag'] === false){
$data['state'] = 0;
......
......@@ -274,7 +274,7 @@ class OrderServiceModel extends \Business\AbstractModel
$res=$orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateCancel);
if($res){
if ($memberId) {
$orderDao->deleteOrderCache($memberId, $orderId);
$orderDao->deleteOrderCache($memberId, $orderId,$order['store_id']);
// $memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
}
}
......@@ -296,7 +296,7 @@ class OrderServiceModel extends \Business\AbstractModel
if ($isAllowConfirm) {
$res = $orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateComplete, TRUE);
if ($res) {
$orderDao->deleteOrderCache($memberId, $orderId);
$orderDao->deleteOrderCache($memberId, $orderId,$order['store_id']);
\Our\RedisHelper::memberTotalFromStateToState($memberId,$order['order_state'],ApiConst::orderStateComplete);
return true;
} else {
......@@ -395,7 +395,7 @@ class OrderServiceModel extends \Business\AbstractModel
$orders = $orderDao->getOrdersByOrderState(ApiConst::orderStateWaitConfirm, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
if (!empty($orders)) {
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);
}
$res = $orderDao->updateOrdersByorderState(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
......@@ -425,13 +425,13 @@ class OrderServiceModel extends \Business\AbstractModel
if ($order['shippingType'] == ApiConst::bySeller) {
if (isset($qmDeliverymanLogsOrderIds[$order['orderId']])) {
array_push($sellerOrderIds, $order['orderId']);
$orderDao->deleteOrderCache($order['buyerId'], $order['orderId']);
$orderDao->deleteOrderCache($order['buyerId'], $order['orderId'],$order['storeId']);
}
} else {
$limitTime = TIMESTAMP - ApiConst::orderWaitRecieveThreeDays;
if ($order['acceptTime'] < $limitTime) {
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);
......@@ -642,7 +642,7 @@ class OrderServiceModel extends \Business\AbstractModel
$push=Push::getInstance();
$push->reacheRemind($order['buyerId'],$order['orderId'],$order['orderSn']);
}
$orderDao->deleteOrderCache($memberid, $qmDeliveryManLog['orderId']);
$orderDao->deleteOrderCache($memberid, $qmDeliveryManLog['orderId'],$order['storeId']);
$qmDeliverymanLogDao->deleteOrderCache($deliverymanId, $id);
return $updateResult;
} else {
......
......@@ -46,27 +46,31 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
//获得统计数据
public function getStatistics($memberId)
{
$storeId = $this->_getStoreByMemberId($memberId);
$storeStatisticsDayDao = \DAO\Store\StoreStatisticsDayModel::getInstance();
$storeStatisticsDao = \DAO\StoreStatisticsModel::getInstance();
$memberDao=\DAO\MemberModel::getInstance();
$storeId=$memberDao->getInfo($memberId,'store_id');
//$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;
//获取店铺信息
$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);
$storeTodayStats = $storeStatisticsDayDao->getByStoreIdAndGmtCreate($storeId, $today);
$storeStats = $orderDao->getShopKeeperCountByStoreIdCache($storeId);
$storeFavariteCount=$favoritesStoreDao->getFavoritesCountByStoreIdCache($storeId);
$data['storeId'] = $store['store_id'];
$data['storeName'] = $store['store_name'];
$data['storeLabel'] = $store['store_label'];
$data['goodsCount'] = isset($storeStats['goodsCount']) ? $storeStats['goodsCount'] : ApiConst::zero;
$data['orderCount'] = isset($storeStats['orderCount']) ? $storeStats['orderCount'] : ApiConst::zero;
$data['orderTotal'] = isset($storeStats['orderTotal']) ? $storeStats['orderTotal'] : ApiConst::zero;
$data['favCount'] = isset($storeStats['favCount']) ? $storeStats['favCount'] : ApiConst::zero;
$data['todayOrderCount'] = isset($storeTodayStats['orderCount']) ? $storeTodayStats['orderCount'] : ApiConst::zero;
$data['todayOrderTotal'] = isset($storeTodayStats['orderTotal']) ? $storeTodayStats['orderTotal'] : ApiConst::zero;
$data['tadayFavCount'] = isset($storeTodayStats['favCount']) ? $storeTodayStats['favCount'] : ApiConst::zero;
$data['goodsCount'] = ApiConst::zero;
$data['orderCount'] =$storeStats['orderCount'];
$data['orderTotal'] = $storeStats['orderTotal'];
$data['favCount'] = $storeFavariteCount['favCount'];
$data['todayOrderCount'] = $storeStats['todayOrderCount'];
$data['todayOrderTotal'] = $storeStats['todayOrderTotal'];
$data['tadayFavCount'] = $storeFavariteCount['todayFavCount'];
return $data;
}
......@@ -233,7 +237,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
} else {
$update_data['order_state'] = ApiConst::orderStateWaitSend;
$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);
return $result;
}
......@@ -475,6 +479,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
public function insertStoreMemberStatics()
{
$orderGoodDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeMemberStatisticDao = \DAO\StoreMemberStatisticsModel::getInstance(DbNameConst::masterDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderGoodsCreateTime);
$gmtCreate = $gmtCreate ? $gmtCreate : ApiConst::zero;
......@@ -485,6 +490,13 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$addDatas = array();
$storeMemberStatisticData = $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime, $this->taskIndex, $this->taskSize);
$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) {
$this->taskIndex++;
foreach ($storeMemberStatisticData as $value) {
......@@ -496,9 +508,10 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$addDatas[$value['buyerId'] . '-' . $value['storeId']]['orderGoodsCount'] = $value['goodsNum'];
}
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 {
$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{
$defaultDeliveryTime = (empty($formula['default_time'])?$formula[2]['time']:$formula['default_time']);
}
if(!$defaultDeliveryTime){
$in_store_service_flag = 0;
//$in_store_service_flag = 0;
$defaultDeliveryTime = 0;
}
}else{
......@@ -734,86 +734,7 @@ class StoreServiceModel extends \Business\AbstractModel{
}
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
$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();
$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) {
$dates = array_column($browseList,'browsedate','group_id');
foreach ($groupList as $group) {
......@@ -122,10 +122,10 @@ class FootprintServiceModel extends \Business\AbstractModel
}
}
foreach ($browseList as $browse) {
if($browse['goods_commonid']) {
if($browse['goods_commonid'] && $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']];
}
}
......
......@@ -3,6 +3,9 @@
namespace DAO;
use OSS\Common;
use Our\ApiConst;
class FavoritesStoreModel extends \DAO\AbstractModel {
......@@ -58,6 +61,25 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
$this->setDb($this->dbName);
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){
$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)";
......
......@@ -33,7 +33,11 @@ class GoodsAttributeModel extends \DAO\AbstractModel {
$productData = [];
if(is_array($data) && !empty($data)){
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;
......
......@@ -27,6 +27,8 @@ class OrderModel extends \DAO\AbstractModel
* @var string
*/
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
//$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';
}
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";
}
public function getCount($where, $isArray = true)
{
$this->setDb();
......@@ -68,6 +74,33 @@ class OrderModel extends \DAO\AbstractModel
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
......@@ -98,20 +131,23 @@ class OrderModel extends \DAO\AbstractModel
//判断订单是否允许取消
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;
} else {
return false;
}
}
//列表转换
public function convertOrderList($list){
$convertList=array();
foreach($list as $order){
$convertList[$order['orderId']]=$order;
public function convertOrderList($list)
{
$convertList = array();
foreach ($list as $order) {
$convertList[$order['orderId']] = $order;
}
return $convertList;
}
//confirm
public function isAllowConfirm($order)
{
......@@ -176,11 +212,13 @@ class OrderModel extends \DAO\AbstractModel
return $this->db->update($this->_tableName)->where($where)->rows($data)->execute();
}
public function insert($data){
public function insert($data)
{
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->insert($this->_tableName)->rows($data)->execute();
return $result ;
return $result;
}
/**
* 删除订单
* @param $data
......@@ -194,18 +232,18 @@ class OrderModel extends \DAO\AbstractModel
return $this->update($where, $data);
}
public function updateStatusByOrderId($orderIds, $status,$isConfirm=false)
public function updateStatusByOrderId($orderIds, $status, $isConfirm = false)
{
$this->setDb($this->dbName);
if(is_array($orderIds)){
$where['order_id']=array('in',$orderIds);
}else{
if (is_array($orderIds)) {
$where['order_id'] = array('in', $orderIds);
} else {
$where['order_id'] = $orderIds;
}
$where = $this->db->getSqlWhereByArray($where);
$data['order_state'] = $status;
if($isConfirm){
$data['shipping_over']=ApiConst::shippingOver;
if ($isConfirm) {
$data['shipping_over'] = ApiConst::shippingOver;
}
return $this->update($where, $data);
}
......@@ -287,8 +325,8 @@ class OrderModel extends \DAO\AbstractModel
$totalCount = $this->db->select($field)->from($this->_tableName)
->join('han_order_common', $this->_tableName . '.order_id = han_order_common.order_id', 'left')
->where($where)->fetchNum();
$returnData['orders']=$list;
$returnData['totalCount']=$totalCount;
$returnData['orders'] = $list;
$returnData['totalCount'] = $totalCount;
return $returnData;
}
......@@ -303,6 +341,29 @@ class OrderModel extends \DAO\AbstractModel
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)
{
......@@ -349,10 +410,10 @@ class OrderModel extends \DAO\AbstractModel
}
//待收货详情描述处理
public function getStatusDetailTextExtent($order,$type=ApiConst::buyerText)
public function getStatusDetailTextExtent($order, $type = ApiConst::buyerText)
{
$orderText = '';
if($type==ApiConst::buyerText){
if ($type == ApiConst::buyerText) {
if ($order['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderText = OrderConst::waitGetFromShop;//默认到店自取
if ($order['shippingType'] == ApiConst::express) {
......@@ -363,7 +424,7 @@ class OrderModel extends \DAO\AbstractModel
}
}
}
if($type==ApiConst::storeText){
if ($type == ApiConst::storeText) {
if ($order['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderText = OrderConst::waitGetFromShop;//默认到店自取
if ($order['shippingType'] == ApiConst::express) {
......@@ -377,8 +438,10 @@ class OrderModel extends \DAO\AbstractModel
return $orderText;
}
//获得买家文案详情
private function getBuyerDetailText($order){
private function getBuyerDetailText($order)
{
switch ($order['orderState']) {
case ApiConst::orderStateCancel:
$statusText = OrderConst::orderCancel;
......@@ -430,6 +493,7 @@ class OrderModel extends \DAO\AbstractModel
}
return $statusText;
}
//获取销售员订单详情描述
public function getStatusSaleText($orderState)
{
......@@ -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))){
ErrorModel::throwException(CodeConfigModel::commonError);
}
if($type==ApiConst::buyerText){
return $this->getBuyerDetailText($order);
}
if($type==ApiConst::storeText){
if (!in_array($type, array(ApiConst::buyerText, ApiConst::storeText, ApiConst::deliveryText))) {
ErrorModel::throwException(CodeConfigModel::commonError);
}
if ($type == ApiConst::buyerText) {
return $this->getBuyerDetailText($order);
}
if ($type == ApiConst::storeText) {
return $this->getStoreDetailText($order);
}
return $this->getStoreDetailText($order);
}
}
//获得退款状态
public function getRefundText($order){
$refundStateName='';
if($order['paymentTime'] >ApiConst::zero ){
if($order['orderState']==ApiConst::orderStateWaitSend ){
$refundStateName=DescribeConst::refund;
public function getRefundText($order)
{
$refundStateName = '';
if ($order['paymentTime'] > ApiConst::zero) {
if ($order['orderState'] == ApiConst::orderStateWaitSend) {
$refundStateName = DescribeConst::refund;
}
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::express ){
$refundStateName=DescribeConst::refundRetund;
if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::express) {
$refundStateName = DescribeConst::refundRetund;
}
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::bySeller ){
$refundStateName=DescribeConst::refundRetund;
if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::bySeller) {
$refundStateName = DescribeConst::refundRetund;
}
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::bySelf ){
$refundStateName=DescribeConst::refund;
if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::bySelf) {
$refundStateName = DescribeConst::refund;
}
}
if($order['paymentTime'] ==ApiConst::zero ){
if($order['orderState']==ApiConst::orderStateWaitRecieve && $order['shippingType']==ApiConst::express){
$refundStateName=DescribeConst::refundRetund;
if ($order['paymentTime'] == ApiConst::zero) {
if ($order['orderState'] == ApiConst::orderStateWaitRecieve && $order['shippingType'] == ApiConst::express) {
$refundStateName = DescribeConst::refundRetund;
}
}
$diff=TIMESTAMP-$order['finnshedTime'];
if($order['orderState']==ApiConst::orderStateComplete &&$diff<ApiConst::oneDaySecond ){
$refundStateName=='退货';
$diff = TIMESTAMP - $order['finnshedTime'];
if ($order['orderState'] == ApiConst::orderStateComplete && $diff < ApiConst::oneDaySecond) {
$refundStateName == '退货';
}
return $refundStateName;
}
public function selectedTypeId($order){
$refundStateName=$this->getRefundText($order);
$selectedRefundId=ApiConst::refundTypeMoney;
if($refundStateName==DescribeConst::refundRetund){
$selectedRefundId=ApiConst::refundTypeGoods;
public function selectedTypeId($order)
{
$refundStateName = $this->getRefundText($order);
$selectedRefundId = ApiConst::refundTypeMoney;
if ($refundStateName == DescribeConst::refundRetund) {
$selectedRefundId = ApiConst::refundTypeGoods;
}
return $selectedRefundId;
}
public function getText($order, $textType = ApiConst::orderListDescribe)
{
$text = '';
......@@ -694,6 +760,12 @@ class OrderModel extends \DAO\AbstractModel
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)
{
......@@ -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);
}
if(!empty($orderId)){
if (!empty($orderId)) {
$this->deleteFindByOrderIdCache($orderId);
$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao->deleteOrderGoodsCache($memberId,$orderId);
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao->deleteOrderGoodsCache($memberId, $orderId);
\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);
$where['order_state'] = $orderState;
$limit = TIMESTAMP - $timeLimit;
$where[$timeField] = array('lt', $limit);
if($shippingTypes){
$where['shipping_type']=array('in',$shippingTypes);
if ($shippingTypes) {
$where['shipping_type'] = array('in', $shippingTypes);
}
$where = $this->db->getSqlWhereByArray($where);
$list = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
......@@ -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);
$where['order_state'] = ApiConst::orderStateWaitConfirm;
$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);
$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);
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);
$where['order_state'] = $orderState;
$limit = TIMESTAMP - $timeLimit;
$where[$timeField] = array('lt', $limit);
$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
* @param string $field
* @return mixed
*/
public function getListByCon($where,$field = \Our\NameConst::allField){
public function getListByCon($where, $field = \Our\NameConst::allField)
{
$this->setDb($this->dbName);
if(is_array($where)){
$where=$this->db->getSqlWhereByArray($where);
if (is_array($where)) {
$where = $this->db->getSqlWhereByArray($where);
}
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
return $result;
}
public function getShippingTypeSellerOrdersByOrders($orders){
$shippingTypeOrderIds=array();
foreach($orders as $order){
if($order['shippingType']==ApiConst::bySeller){
array_push($shippingTypeOrderIds,$order['orderId']);
public function getShippingTypeSellerOrdersByOrders($orders)
{
$shippingTypeOrderIds = array();
foreach ($orders as $order) {
if ($order['shippingType'] == ApiConst::bySeller) {
array_push($shippingTypeOrderIds, $order['orderId']);
}
}
return $shippingTypeOrderIds;
}
public function getConvertOrder($order, $fields = array())
{
$convertResult = array();
......@@ -816,6 +899,7 @@ class OrderModel extends \DAO\AbstractModel
'deliveryTime' => 'delivery_time',
);
}
public function getOrderAndOrderGoods($where, $field, $group = false, $limit = [], $order = [])
{
$this->setDb($this->dbName);
......@@ -829,30 +913,36 @@ class OrderModel extends \DAO\AbstractModel
eval($str);
return $result;
}
public function getAllByWhere($where,$field){
public function getAllByWhere($where, $field)
{
$this->setDb($this->dbName);
if(is_array($where)){
$where=$this->db->getSqlWhereByArray($where);
if (is_array($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){
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnPayedOrderTimePrefix,$time);
public function updateCancelUnpayedOrderTimeCache($time)
{
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnPayedOrderTimePrefix, $time);
}
public function getCancelUnpayedOrderTimeCache(){
$res=\Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
echo 'abcd'.json_encode($res);
return \Redis\Db5\OrderRedisModel::getInstance()->tableCacheGet(\Our\NameConst::cancelUnPayedOrderTimePrefix);
public function getCancelUnpayedOrderTimeCache()
{
$res = \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){
\Redis\Db5\OrderRedisModel::getInstance()->tableCacheSet(\Our\NameConst::cancelUnReceivedOrderTimePrefix,$time);
public function updateCancelUnReceivedOrderTimeCache($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);
}
......
......@@ -17,7 +17,7 @@ class OrderGoodsModel extends \DAO\AbstractModel {
* @var string
*/
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 $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 {
if(is_array($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){
if($image){
......@@ -48,11 +48,11 @@ class PBundlingModel extends \DAO\AbstractModel {
public function getDetail($where,$field,$limit=false){
$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){
$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