Commit 9f12a21f authored by zhz's avatar zhz

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

parents 24361181 baa6c650
......@@ -157,8 +157,8 @@ class ArrayConst
);
const defaultDeliveryMan=array(
'id'=>0,
'trueName'=>'配送员a',
'mobile'=>'18650329907',
'trueName'=>'',
'mobile'=>'',
);
const messageOrderButtonsType=array(
0,1,2
......
......@@ -251,6 +251,10 @@ class MessageServiceModel extends \Business\AbstractModel
*/
public function getMemberList($memberId, $selfType, $toId, $otherId, $toType = ApiConst::systemMessageType, $field = '*', $pageIndex = ApiConst::pageIndex, $pageSize = ApiConst::pageSize)
{
if($memberId==$toId){
$toType=ApiConst::storeMessageType;
$selfType=ApiConst::memberMessageType;
}
$messageHistory = \DAO\MessageHistoryModel::getInstance();
$self = $this->getUserByMemberIdAndSelfType($memberId, $selfType);
if (empty($toId)) {
......@@ -352,6 +356,10 @@ class MessageServiceModel extends \Business\AbstractModel
public function update($fromId, $fromType, $toId, $toType)
{
if($fromId==$toId){
$fromType=ApiConst::memberMessageType;
$toType=ApiConst::storeMessageType;
}
$messageHistoryDao = \DAO\MessageHistoryModel::getInstance();
$messageOneDao = \DAO\MessageOneModel::getInstance();
$messageOneDao->setDb(DbNameConst::masterDBConnectName);
......
......@@ -292,6 +292,7 @@ class OrderServiceModel extends \Business\AbstractModel
$returnData['diliverymanId'] = ApiConst::zero;
$returnData['deliveryman'] = new \stdClass();
}
$returnData['offlinePayway']=$storeDao->convertOfflinePayway($returnData['offlinePayway']);
$returnData['storeMemberId']=$this->store['memberId'];
$returnData['totalGoodsNum'] = $orderGoodsDao->getGoodsCount($this->orderGoodsList);
$returnData['offlinePayway'] = $this->store['offlinePayway'] ? $this->store['offlinePayway'] : '';
......
......@@ -942,7 +942,8 @@ class RefundServiceModel extends \Business\AbstractModel
if($info['refundShippingType']==ApiConst::bySeller){
if($info['returnType']==ApiConst::returnTypeMustReturn){
if(!$info['diliverymanId']){
$info['diliveryman']=ArrayConst::defaultDeliveryMan;
$info['diliveryman']=new \stdClass();
// $info['diliveryman']=ArrayConst::defaultDeliveryMan;
}else{
$diliveryMan=$diliveryManDao->findById($info['diliverymanId']);
if(!empty($diliveryMan)){
......
......@@ -72,7 +72,11 @@ class MessageHistoryModel extends \DAO\AbstractModel {
}
public function updateByFromIdAndSelfTypeAndToIdAndToType($fromId,$fromType,$toId,$toType){
if($fromId!=$toId){
$where=Common::format(" (((fromId={0} and toId={1} and toType={2} and fromType={3}) and status=0))",$toId,$fromId,$fromType,$toType);
}else{
$where=Common::format(" (((fromId={0} and toId={1} and toType={2} and fromType={3}) and status=0))",$toId,$fromId,$toType,$fromType);
}
$data['status']=ApiConst::read;
return $this->updateByWhere($where,$data);
}
......
......@@ -1035,7 +1035,8 @@ class OrderModel extends \DAO\AbstractModel
'buyerId' => 'buyer_id',
'deliveryTime' => 'delivery_time',
'evaluationState'=>'evaluation_state',
'orderNote'=>'order_note'
'orderNote'=>'order_note',
'isReceivePayment'=>'is_receive_payment'
);
}
......
......@@ -2,6 +2,7 @@
namespace DAO;
use Our\ApiConst;
use Our\ArrayConst;
use Our\DbNameConst;
use Our\ImageConst;
......@@ -13,7 +14,7 @@ use Our\ImageConst;
class StoreModel extends \DAO\AbstractModel
{
public $detailField= " member_id as memberId,store_id as storeId,offline_payway as offlinePayway,store_label as storeLabel";
public $detailField = " member_id as memberId,store_id as storeId,offline_payway as offlinePayway,store_label as storeLabel,offline_payway as offlinePayway";
protected function init()
{
......@@ -35,6 +36,18 @@ class StoreModel extends \DAO\AbstractModel
protected $_primaryKey = 'store_id';
public function convertOfflinePayway($offlinPayway)
{
$res = new \stdClass();
// $res['images'] = Array();
// $res['payway'] = '';
if (!empty($offlinPayway)) {
$offlinPayway=unserialize($offlinPayway);
$res['images']=$offlinPayway['images'];
$res['payway']=$offlinPayway['payway']?$offlinPayway['payway']:'';
}
return $res;
}
/**
* 获取店铺信息
......@@ -52,7 +65,6 @@ class StoreModel extends \DAO\AbstractModel
}
public function getInfoById($id, $field = '*', $isField = false)
{
$this->setDb($this->dbName);
......@@ -97,6 +109,7 @@ class StoreModel extends \DAO\AbstractModel
}
return $storeLabel;
}
/**
* 店铺首页banner
*
......@@ -113,6 +126,7 @@ class StoreModel extends \DAO\AbstractModel
$storeLabel .= "?x-oss-process=image/resize,m_fill,h_314,w_750";
return $storeLabel;
}
/**
* 店铺月销量
*
......@@ -134,12 +148,12 @@ class StoreModel extends \DAO\AbstractModel
* @param $field 可获取
* @return mixed 返回店铺列表
*/
public function getOnlineStores($where = null, $field = '*', $limit=[])
public function getOnlineStores($where = null, $field = '*', $limit = [])
{
$conditionSql = 'store_state =1 and open_flag =1 and (store_end_time >=' . TIMESTAMP . ' or store_end_time =0 ) ';
if ($where) {
$conditionSql = $where. ' and '.$conditionSql;
$conditionSql = $where . ' and ' . $conditionSql;
}
$result = $this->getStores($conditionSql, $field, $limit);
return $result;
......@@ -182,12 +196,13 @@ class StoreModel extends \DAO\AbstractModel
return $this->isChargeGet($storeId);
}
}
//获取是否应该收取服务费或快递费
public function isFee($storeId,$shippingtype,$orderStatus)
public function isFee($storeId, $shippingtype, $orderStatus)
{
if($shippingtype!=ApiConst::express){
return $this->isGetFee($storeId,$orderStatus);
}else{
if ($shippingtype != ApiConst::express) {
return $this->isGetFee($storeId, $orderStatus);
} else {
return $this->isChargeGet($storeId);
}
......@@ -199,12 +214,12 @@ class StoreModel extends \DAO\AbstractModel
* @param $field
* @return mixed
*/
public function getStores($where, $field = "*", $limit =[])
public function getStores($where, $field = "*", $limit = [])
{
$this->setDb();
if($limit){
$result = $this->db->select($field)->from($this->_tableName)->where($where)->limit($limit[0],$limit[1])->fetchAll();
}else{
if ($limit) {
$result = $this->db->select($field)->from($this->_tableName)->where($where)->limit($limit[0], $limit[1])->fetchAll();
} else {
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
}
return $result;
......@@ -218,8 +233,9 @@ class StoreModel extends \DAO\AbstractModel
return $stores;
}
public function delStoresCacheByCityCode($cityCode){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'),array(),array($cityCode));
public function delStoresCacheByCityCode($cityCode)
{
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'), array(), array($cityCode));
}
/**
......@@ -228,7 +244,7 @@ class StoreModel extends \DAO\AbstractModel
* @return mixed 当前城市列表
* @throws \Our\Exception
*/
public function getExpressStores( $field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope')
public function getExpressStores($field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope')
{
$storeClassCondition = " express_distribution = 1 ";
......@@ -237,9 +253,10 @@ class StoreModel extends \DAO\AbstractModel
return $stores;
}
public function deleteExpressStores($field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope'){
public function deleteExpressStores($field = 'store_id,store_longitude,store_latitude,max_sign_rang,max_sales_rang,store_sales_scope')
{
$storeClassCondition = " express_distribution = 1 ";
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'),array(array($storeClassCondition, $field)));
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'), array(array($storeClassCondition, $field)));
}
public function getNearbyStores($cityCode, $storeIds)
......@@ -250,51 +267,55 @@ class StoreModel extends \DAO\AbstractModel
return $returnStores;
}
public function delNearbyStoresCache($cityCode){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'),array(),array($cityCode));
public function delNearbyStoresCache($cityCode)
{
\Our\RedisHelper::delCachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getOnlineStores'), array(), array($cityCode));
}
public function getAddress($storeId){
public function getAddress($storeId)
{
$storeInfo = $this->getStoreInfoCache($storeId);
//地址
$address = '';
if($storeInfo['area_info']){
if ($storeInfo['area_info']) {
$address .= $storeInfo['area_info'];
}
if($storeInfo['store_address']){
if ($storeInfo['store_address']) {
$address .= $storeInfo['store_address'];
}
return $address;
}
public function get($storeId,$label = true,$reportError = true)
public function get($storeId, $label = true, $reportError = true)
{
$storeInfo = $this->getStoreInfoCache($storeId);
if(!$storeInfo) {
if (!$storeInfo) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::storeNotExistOrClose);
}
if($storeInfo['open_flag'] != 1 || $storeInfo['store_state'] != 1){
if($reportError) {
if ($storeInfo['open_flag'] != 1 || $storeInfo['store_state'] != 1) {
if ($reportError) {
\Error\ErrorModel::throwException(\Error\CodeConfigModel::storeNotExistOrClose);
}else{
} else {
$storeInfo['isClose'] = 1;
}
}else{
} else {
$storeInfo['isClose'] = 0;
}
if($label){
if ($label) {
//店铺头像
$storeLabel = $this->getStoreLabelSrc($storeInfo['store_label']);
return array($storeInfo,$storeLabel);
return array($storeInfo, $storeLabel);
}
return $storeInfo;
}
public function getStoreInfoCache($storeId) {
$storeInfo = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(),array(&$this, 'getInfoById'),array($storeId),\Our\ApiConst::sevenDaySecond,array($storeId));
public function getStoreInfoCache($storeId)
{
$storeInfo = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$this, 'getInfoById'), array($storeId), \Our\ApiConst::sevenDaySecond, array($storeId));
return $storeInfo;
}
......@@ -317,18 +338,18 @@ class StoreModel extends \DAO\AbstractModel
*/
public function getShareInfo($storeInfo)
{
if(!is_array($storeInfo)){
$storeInfo = $this->get($storeInfo,false);
if (!is_array($storeInfo)) {
$storeInfo = $this->get($storeInfo, false);
}
$share['title'] = $storeInfo['store_share_title']?$storeInfo['store_share_title']:$storeInfo['store_name'];
$share['desc']= $storeInfo['store_share_desc']?$storeInfo['store_share_desc']:$storeInfo['store_notice'];
if($storeInfo['store_share_img']){
$share['title'] = $storeInfo['store_share_title'] ? $storeInfo['store_share_title'] : $storeInfo['store_name'];
$share['desc'] = $storeInfo['store_share_desc'] ? $storeInfo['store_share_desc'] : $storeInfo['store_notice'];
if ($storeInfo['store_share_img']) {
$img = $this->getStoreShareSrc($storeInfo['store_share_img']);
}else{
} else {
$img = $this->getStoreLabelSrc($storeInfo['store_label']);
}
$share['imgUrl'] = $img;
$share['link']='http://www.shenbd.com';
$share['link'] = 'http://www.shenbd.com';
return $share;
}
......@@ -338,15 +359,16 @@ class StoreModel extends \DAO\AbstractModel
* @param $store
* @return int
*/
public function checkAddressInServiceArea($address,$store){
public function checkAddressInServiceArea($address, $store)
{
$inAreaFlag = \Our\ApiConst::zero;
if($store['buyer_distribution']||$store['express_distribution']){//如果店铺开启了到店自提和快递配送,则认为存在可用配送方式
if ($store['buyer_distribution'] || $store['express_distribution']) {//如果店铺开启了到店自提和快递配送,则认为存在可用配送方式
$inAreaFlag = \Our\ApiConst::one;
return $inAreaFlag;
}
if($store['seller_distribution']&&$address){
$result = \Store\StoreUtil::getInstance()->checkAddressInServiceArea(array('lng'=>$address['lng'],'lat'=>$address['lat']),$store['store_id']);
if($result){
if ($store['seller_distribution'] && $address) {
$result = \Store\StoreUtil::getInstance()->checkAddressInServiceArea(array('lng' => $address['lng'], 'lat' => $address['lat']), $store['store_id']);
if ($result) {
$inAreaFlag = \Our\ApiConst::one;
}
}
......@@ -354,7 +376,6 @@ class StoreModel extends \DAO\AbstractModel
}
/**
* 类实例
*
......@@ -367,7 +388,7 @@ class StoreModel extends \DAO\AbstractModel
*
* @return \DAO\UserModel
*/
public static function getInstance($dbName=\Our\DbNameConst::salveDBConnectName)
public static function getInstance($dbName = \Our\DbNameConst::salveDBConnectName)
{
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($dbName);
......@@ -451,23 +472,25 @@ class StoreModel extends \DAO\AbstractModel
);
}
public function getAll($where=array()){
public function getAll($where = array())
{
$this->setDb($this->dbName);
if($where){
$where=$this->db->getSqlWhereByArray($where);
if ($where) {
$where = $this->db->getSqlWhereByArray($where);
}
if($where){
$res=$this->db->from($this->_tableName)->where($where)->fetchAll();
}else{
$res=$this->db->from($this->_tableName)->fetchAll();
if ($where) {
$res = $this->db->from($this->_tableName)->where($where)->fetchAll();
} else {
$res = $this->db->from($this->_tableName)->fetchAll();
}
$resArray=array();
foreach($res as $val){
$resArray[$val['store_id']]=$val;
$resArray = array();
foreach ($res as $val) {
$resArray[$val['store_id']] = $val;
}
return $resArray;
}
/**
* 保存用户信息
*/
......@@ -478,7 +501,8 @@ class StoreModel extends \DAO\AbstractModel
return $result;
}
public function save($data,$where){
public function save($data, $where)
{
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->update($this->_tableName)->rows($data)->where($where)->execute();
return $result;
......
......@@ -107,7 +107,10 @@ $serv->on('Message', function($server, $frame) use($conf){
$sendMessage['toType']= $rev_data['toType'];
if(!empty($sendFd)){
echo '发送fd:'.$sendFd;
if($sendFd!=$frame->fd){
$server->push($sendFd, responseJson(1,"fromMsg","success", $sendMessage));
}
}
echo 'afterSendFd:'.$sendFd;
}
......
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