Commit e0283738 authored by chenchuanwen's avatar chenchuanwen

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

parents 6cb49176 2019d31c
......@@ -193,6 +193,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
$this->success($otherGoods);
}
/*
public function testMemberAction(){
$memberDao = \DAO\MemberModel::getInstance();
$memberList = $memberDao->getAll();
......@@ -203,6 +204,7 @@ class HomeController extends \Our\Controller_AbstractIndex{
public function writeToFileAction(){
\Business\User\AddressServiceModel::getInstance()->writeToFile();
}
}*/
}
\ No newline at end of file
......@@ -49,21 +49,14 @@ class OrderConfirmUtil {
private $couponCacheFlag = false;
public function addOrder($data,$memberId,$currentAddress){
$isLock = \Lock\RedisLock::getInstance()->getLock('addOrder');
if($isLock){
$storeCartData = $this->checkPostData($data,$memberId,$currentAddress);
//return $storeCartData;
if(CURRENTVERSION==\Our\NameConst::versionDefault){
$storeCartData = $this->checkDeliveryTypeAndPayway($storeCartData);
}else{
$storeCartData = $this->checkDeliveryTypeAndPaywayNew($storeCartData);
}
$result = $this->saveOrderInfo($storeCartData);
\Lock\RedisLock::getInstance()->releaseLock('addOrder');
return $result;
}else{
\Error\ErrorModel::throwException(\Error\CodeConfigModel::addOrderFrequently);
}
}
......@@ -743,9 +736,8 @@ class OrderConfirmUtil {
public function pushMessage(){
if($this->pushMessageOrders){
$orderService=\Business\Order\OrderServiceModel::getInstance();
foreach($this->pushMessageOrders as $tempOrder){
$orderService->pushRecieveOrder($tempOrder);
\Our\Common::redisPublish('\Business\Order\OrderServiceModel','pushRecieveOrder',array($tempOrder));
}
}
}
......
......@@ -678,7 +678,7 @@ class Common
*/
public static function getIpCity($ip)
{
$url = "http://ip.taobao.com/service/getIpInfo.php?ip=" . $ip;
$url = (self::is_https()?'https':'http')."://ip.taobao.com/service/getIpInfo.php?ip=" . $ip;
$ip = json_decode(file_get_contents($url));
if ((string)$ip->code == '1') {
return false;
......@@ -687,4 +687,23 @@ class Common
return $data;
}
public static function getAddressByLatLng($lat,$lng){
$key = \Our\SecretKeys::amapKey;
$url = (self::is_https()?'https':'http').'://restapi.amap.com/v3/geocode/regeo?key='.$key.'&location='.$lng.','.$lat.'&poitype=&radius=10&extensions=all&batch=false&roadlevel=0';
$address = json_decode(file_get_contents($url));
if($address->status){
return json_decode(json_encode($address->regeocode->addressComponent),true);
}
return false;
}
public static function getCityCodeByLatLng($lat,$lng){
$address = self::getAddressByLatLng($lat,$lng);
if($address&&isset($address['citycode'])){
return $address['citycode'];
}
return false;
}
}
......@@ -54,6 +54,8 @@ class SecretKeys {
const pushKey='37e9a38cf2983bcdf885e5fd';
const pushSecret='c59868c235bc7ccbe865f9d9';
const amapKey = '51540038b13949411b93f05fd94da971';
}
......
......@@ -64,7 +64,9 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
public function getPlatformGoodsClass($where){
//验证参数
$addressDao = \DAO\AddressModel::getInstance();
/*$addressDao = \DAO\AddressModel::getInstance();
$validFlag = $addressDao->getValidAddress($where);
if(!$validFlag){
\Error\ErrorModel::throwException($addressDao->errorCode);
......@@ -86,6 +88,8 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
if($serviceParentClassIds){
$classIds = array_merge($serviceParentClassIds,$classIds);
}
var_dump($classIds);*/
/*
//获取可快递店铺对应分类
$expressClassIds = $this->getExpressStoreClasses($where);
......@@ -93,6 +97,12 @@ class GoodsClassServiceModel extends \Business\AbstractModel{
$classIds = array_merge($expressClassIds,$classIds);
}
*/
$classIds = array();
$platformFirstClassDao = \DAO\GoodsClass\PlatformFirstClassModel::getInstance();
$firstClassList = \Our\RedisHelper::cachedFunction(\Redis\Db3\PlatformFirstClassRedisModel::getInstance(),array(&$platformFirstClassDao, 'getList'),array(),\Our\ApiConst::oneHour,array());
if($firstClassList){
$classIds = array_column($firstClassList,'gc_id');
}
$classIdKeys = array_flip($classIds);
$goodsClassDao = \DAO\GoodsClassModel::getInstance();
$parentClasses = $goodsClassDao->getParentClasses();
......
......@@ -1176,6 +1176,8 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeDao = \DAO\StoreModel::getInstance();
$storeDao->delNearbyStoresCache($cityCode);
$storeDao->delStoresCacheByCityCode($cityCode);
$platformFirstClassDao = \DAO\GoodsClass\PlatformFirstClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db3\PlatformFirstClassRedisModel::getInstance(),array(&$platformFirstClassDao, 'getList'),array(),array());
return true;
}
......
<?php
namespace DAO\GoodsClass;
/**
* User: liuyuzhen
* Date: 2018/7/18
* Time: 10:58
* Description:
*/
class PlatformFirstClassModel extends \DAO\AbstractModel{
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_platform_first_class';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'gc_parent_id';
public function init(){
}
public function findByWhere($where){
$this->setDb(\Our\DbNameConst::salveDBConnectName);
$address = $this->db->from($this->_tableName)->where($where)->fetchOne();
return $address;
}
public function getList($where,$field = \Our\NameConst::allField){
$this->setDb($this->dbName);
$result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchAll();
return $result;
}
public function getStoreOnlineGoodsClassesByGcIdFromCache($gcId,$storeId,$field = \Our\NameConst::allField){
$gcIds = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance(),array(&$this, 'getStoreOnlineGoodsClassesByGcId'),array($gcId,$storeId,$field),\Our\ApiConst::oneDaySecond,array($storeId));
return $gcIds;
}
public function getStoreOnlineGoodsClassesByGcId($gcId,$storeId,$field = \Our\NameConst::allField){
$where['gc_id_1'] = $gcId;
$where['store_id'] = $storeId;
$list = $this->getList($where);
if($list){
$platThirdGcIds = array();
$storeThirdGcIds = array();
$secondGcIds = array_unique(array_column($list,'gc_id_2'));
$treeGcIds =array();
foreach($list as $temp){
if($temp['gc_from']==\Our\ApiConst::zero){
$platThirdGcIds[] = $temp['gc_id_3'];
}else{
$storeThirdGcIds[] = $temp['gc_id_3'];
}
if(!(isset($treeGcIds[$temp['gc_id_2']][$temp['gc_from']])&&in_array($temp['gc_id_3'], $treeGcIds[$temp['gc_id_2']][$temp['gc_from']]))){
$treeGcIds[$temp['gc_id_2']][$temp['gc_from']][] = $temp['gc_id_3'];
}
}
$platThirdGcIds = array_unique($platThirdGcIds);
$storeThirdGcIds = array_unique($storeThirdGcIds);
return array('secondGcIds'=>$secondGcIds,'treeGcIds'=>$treeGcIds,'platThirdGcIds'=>$platThirdGcIds,'storeThirdGcIds'=>$storeThirdGcIds);
}
return false;
}
/**
* 检查获取店铺一级在售分类传参是否正确
*/
public function checkStoreTopClasses($data){
if(!isset($data['storeId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyStoreIdForOnlineTopClass);
}
}
/**
* 检查获取店铺下级在售分类及广告传参是否正确
*/
public function checkStoreChildrenClasses($data){
if(!isset($data['storeId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyStoreIdForOnlineChildrenClass);
}
if(!isset($data['gcId'])){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emtpyGcIdForOnlineChildrenClass);
}
}
/**
* 商品详情发生改变存如缓存
* @param $goodsCommon goodsCommon详情
* @param int $type 操作类型(1:加,0:减)
* @return bool
*/
public function addGoodsToGoodsClassCache($goodsCommon,$type = \Our\ApiConst::plus){
if(!$goodsCommon){
return false;
}
$goodsClass['gc_id_1'] = $goodsCommon['gc_id_1'];
$goodsClass['gc_id_2'] = $goodsCommon['gc_id_2'];
$goodsClass['gc_id_3'] = $goodsCommon['gc_id_3'];
$goodsClass['store_id'] = $goodsCommon['store_id'];
$goodsClass['gc_from'] = \Our\ApiConst::zero;
if($goodsClass['gc_id_3']){
$this->addChangedGoodsClass(serialize($goodsClass),$type);
}
if($goodsCommon['goods_class_t_id']){
$goodsClass['gc_id_3'] = $goodsCommon['goods_class_t_id'];
$goodsClass['gc_from'] = \Our\ApiConst::one;
$this->addChangedGoodsClass(serialize($goodsClass),$type);
}
return true;
}
public function addChangedGoodsClass($goodsClass,$type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
$storeOnlineClassRedisModel->tableLPush($key,$goodsClass);
}
public function getChangedGoodsClass($type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
return $storeOnlineClassRedisModel->tableLPop($key);
}
/**
* 获取更改商品
* @param $start 记录开始条数
* @param $end 记录结束条数
* @return \Redis\mix
*/
public function getChangedGoodsClasses($start,$end,$type = \Our\ApiConst::plus){
$key='changedAddGoodsClass';
if($type==\Our\ApiConst::minus){
$key = 'changedMinusGoodsClass';
}
$storeOnlineClassRedisModel = \Redis\Db6\StoreOnlineGoodsClassRedisModel::getInstance();
return $storeOnlineClassRedisModel->tableLRange($key,$start,$end);
}
/**
* 类实例
*/
private static $_instance = null;
/**
* 获取类实例
*/
public static function getInstance($dbName= \Our\DbNameConst::salveDBConnectName) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($dbName);
}
return self::$_instance;
}
}
\ No newline at end of file
......@@ -123,6 +123,8 @@ class QmStoreClassModel extends \DAO\AbstractModel{
if($storeId){
\Our\RedisHelper::delCachedFunction(\Redis\Db6\QmStoreClassRedisModel::getInstance(), array(&$this, 'getStoreSignClasses'),array(),array('store'.$storeId));
}
$platformFirstClassDao = \DAO\GoodsClass\PlatformFirstClassModel::getInstance();
\Our\RedisHelper::delCachedFunction(\Redis\Db3\PlatformFirstClassRedisModel::getInstance(),array(&$platformFirstClassDao, 'getList'),array(),array());
}
/**
......
......@@ -15,7 +15,6 @@ class ErrorModel {
* @throws \Exception
*/
public static function throwException($code, $message = null) {
\Lock\RedisLock::getInstance()->releaseLock('addOrder');
if (!$message) {
$codeConfig = \Error\CodeConfigModel::getCodeConfig();
if (empty($codeConfig[$code])) {
......
<?php
namespace Redis\Db3;
/**
* 平台在经营一级分类
* User: liuyuzhen
* Date: 2019/01/08
* Time: 15:36
* Description:
*/
class PlatformFirstClassRedisModel extends \Redis\Db3\AbstractModel{
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_platform_first_class';
/**
* 类实例
*
*/
private static $_instance = null;
/**
* 获取类实例
*/
public static function getInstance() {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
\ No newline at end of file
......@@ -12,6 +12,11 @@ application.dispatcher.catchException = true
; Admin模块用于后台管理
application.modules = Index,Api,Admin,Client
redis.redisPublishName='redisPublish';
[productone : common]
; 数据库配置
resources.database.params.driver = "pdo_mysql"
......
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