Commit 12773438 authored by christ's avatar christ

order_service

parent 785db763
......@@ -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'] : '';
......
......@@ -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);
......@@ -95,6 +107,7 @@ class StoreModel extends \DAO\AbstractModel
$storeLabel .= "?x-oss-process=image/resize,m_fill,h_{$height},w_{$width}";
return $storeLabel;
}
/**
* 店铺首页banner
*
......@@ -111,6 +124,7 @@ class StoreModel extends \DAO\AbstractModel
$storeLabel .= "?x-oss-process=image/resize,m_fill,h_314,w_750";
return $storeLabel;
}
/**
* 店铺月销量
*
......@@ -132,12 +146,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;
......@@ -180,12 +194,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);
}
......@@ -197,12 +212,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;
......@@ -216,8 +231,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));
}
/**
......@@ -226,7 +242,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 ";
......@@ -235,9 +251,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)
......@@ -248,51 +265,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;
}
......@@ -315,18 +336,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;
}
......@@ -336,15 +357,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;
}
}
......@@ -352,7 +374,6 @@ class StoreModel extends \DAO\AbstractModel
}
/**
* 类实例
*
......@@ -365,7 +386,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);
......@@ -449,23 +470,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;
}
/**
* 保存用户信息
*/
......@@ -476,7 +499,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;
......
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