Commit 3c41fd88 authored by liuyuzhen's avatar liuyuzhen

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

parents 8bfee942 12c019b5
<?php
echo 3333;
......@@ -24,7 +24,6 @@ class StoreController extends \Our\Controller_AbstractIndex {
*/
public function indexAction(){
$recommendGoods = $this->storeService->getRecommendGoodsCache($this->req[\Our\NameConst::data],$this->memberId);
// $adv = array('href'=>'http://qm.22ca.com/qm/tmpl/goods.html?goods_commonid=101654','imageUrl'=>'http://qmoss-01.oss-cn-hangzhou.aliyuncs.com/data/upload/mall/adv/05715960161498410.jpg');
$adv = \Business\Common\AdvServiceModel::getInstance()->getStoreAdvs($this->req[\Our\NameConst::data], \Our\AdvConst::storePageMid);
$hotSale = $this->storeService->getHotSaleGoods($this->req[\Our\NameConst::data], $this->memberId);
$recommendGoodsClasses = $this->storeService->getRecommendClassCache($this->req[\Our\NameConst::data]);
......
......@@ -94,13 +94,23 @@ class Common
public static function getBaseUrl(){
$prefix = 'http';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){
if(self::is_https()){
$prefix = 'https';
}
$url = $prefix.'://'.$_SERVER['SERVER_NAME'];
return $url;
}
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' ) {
return true;
} elseif ( !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
return true;
}
return false;
}
/**
* 获取静态资源文件
......
......@@ -52,7 +52,7 @@ class OrderConst {
const storeWaiteSend='请尽快发货';
const waitBuyerConfirmRecieve='等待用户确认收货';
const defaultComment = '好评!';
}
......
......@@ -44,7 +44,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
* @throws \Our\Exception
*/
public function submit($data,$memberId){
list($order,$orderGoods) = $this->_submitValite($data,$memberId);
list($data, $order, $orderGoods) = $this->_submitValite($data,$memberId);
foreach ($orderGoods as $v){
$orderGoods[$v['goods_id']] = $v;
......@@ -63,7 +63,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$evaluation['geval_goodsprice'] = $orderGoods[$v['goodsId']]['goods_pay_price'];
$evaluation['geval_goodsimage'] = $orderGoods[$v['goodsId']]['goods_image'];
$evaluation['geval_scores'] = intval($v['scores']);
$evaluation['geval_content'] = trim($v['geval_content']);
$evaluation['geval_content'] = $v['geval_content'] ? trim($v['geval_content']) : \Our\OrderConst::defaultComment;
$evaluation['geval_isanonymous'] = intval($data['isanonymous']);
$evaluation['geval_addtime'] = time();
$evaluation['geval_storeid'] = $order['store_id'];
......@@ -73,6 +73,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$evaluation['memberAvatar'] = $memberAvatar;
//$images = $this->_upload($v['images']);
$images = $v['images'];
if(!is_array($images)) $images = json_decode($images, true);
$images ? $data['goods'][$k]['haveImg'] = 1 : $data['goods'][$k]['haveImg'] = 0;
$evaluation['geval_image'] = serialize($images);
$goodsInstance = \DAO\GoodsModel::getInstance();
......@@ -81,8 +82,10 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$data['goods'][$k]['goodsCommonId'] = $evaluation['geval_goods_commonid'];
$evaluations[] = $evaluation;
}
$log = \Our\Log::getInstance();
$log->write(json_encode($evaluations));
$result = \DAO\EvaluateGoodsModel::getInstance()->insertAll($evaluations);
$log->write(json_encode($result));
if(!$result){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
......@@ -153,12 +156,13 @@ class EvaluationServiceModel extends \Business\AbstractModel {
\DAO\StoreScoreStatisticsModel::getInstance()->insertOrUpdate(array('store_id'=>$order['store_id'],'evaluation_score'=>$grade['evaluation_score'],'evaluation_number'=>$grade['evaluation_number']));
}
//修改订单状态
\DAO\Order\OrderModel::getInstance()->update(array('order_id'=>$order['order_id']),array('evaluation_state'=>1));
// 删除缓存 首页待评价数量-1
$orderInstance = \DAO\Order\OrderModel::getInstance();
//修改订单状态
$orderInstance->update(array('order_id'=>$order['order_id']),array('evaluation_state'=>1));
//删除缓存
\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']);
}
/**
......@@ -205,9 +209,12 @@ class EvaluationServiceModel extends \Business\AbstractModel {
$param['descCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyDescCredit);
$param['deliveryCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyDeliveryCredit);
$param['deliveryCredit'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyServiceCredit);
$log = \Our\Log::getInstance();
$log->write(json_encode($param['goods']));
if(!is_array($param['goods'])) {
$param['goods'] = json_decode($param['goods'],true);
}
$log->write(json_encode($param['goods']));
foreach ($param['goods'] as $v){
$v['goodsId'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyGoodsId);
$v['scores'] || \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyScores);
......@@ -228,7 +235,7 @@ class EvaluationServiceModel extends \Business\AbstractModel {
if($goodsIds1 != $goodsIds2){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::orderError);
}
return array($order,$orderGoods);
return array($param, $order, $orderGoods);
}
public function autoEvaluate() {
$list = \DAO\Order\OrderModel::getInstance()->getList(array('finnshed_time'=>array('elt',time()-(\Our\ApiConst::sevenDaySecond)),'evaluation_state'=>\Our\ApiConst::waitEvaluation),'order_id',0,1000,'');
......
......@@ -326,7 +326,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$attrbuteDAO = \DAO\GoodsAttributeModel::getInstance();
$productData = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsAttributeRedisModel::getInstance(),array(&$attrbuteDAO, 'option'),array('attribute,attribute_value',array('goods_commonid'=>$goodsCommonId)),\Our\ApiConst::oneDaySecond,array($goodsCommonId));
$html = array('width'=>750,'height'=>$commonInfo['goods_height'],'url'=>'/index/goodsDetail?goodsCommonId='.$goodsCommonId);
$html = array('width'=>750,'height'=>$commonInfo['goods_height'],'url'=>\Our\Common::getBaseUrl().'/index/goodsDetail?goodsCommonId='.$goodsCommonId);
unset($attrs['commonInfo']);
return array_merge(array('storeId'=>$commonInfo['store_id'],'goodsId'=>$commonInfo['goodsId'],'goodsName'=>$commonInfo['goods_name'],'goodsVerify'=>$commonInfo['goods_verify'],'goodsState'=>$commonInfo['goods_state'],'saleCount'=>$commonInfo['sale_num'],'collectionState'=>$collectionState,'isOwn'=>$isOwn,'isHot'=>$commonInfo['goods_hot'],'isRecoment'=>$commonInfo['goods_commend'],'isFree'=>$commonInfo['goods_free'],'isVirtual'=>$commonInfo['is_virtual'],'goodsMostLimit'=>$commonInfo['goods_most_limit'],'goodsLeastLimit'=>$commonInfo['goods_least_limit'],'goodsTotalLimit'=>$commonInfo['goods_total_limit'],'address'=>$area,'range'=>$rangePrice,'productData'=>$productData,'htmlContent'=>$html,'videoUrl'=>$commonInfo['goods_youku_url']),$attrs);
}
......
......@@ -5,6 +5,7 @@ namespace Business\Store;
use DAO\StoreModel;
use DAO\MemberModel;
use DAO\StoreStatisticsModel;
use Elastics\ElasticsToolModel;
use Error\CodeConfigModel;
use Error\ErrorModel;
use Our\ApiConst;
......@@ -479,16 +480,85 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$beginTime=$gmtCreate;
$this->taskIndex=PageConst::taskPageBegin;
$this->taskSize=PageConst::taskPageSize;
$elasticsTool=ElasticsToolModel::getInstance('orders');
$res= $elasticsTool->indexExists();
echo json_encode($res);exit;
do{
$addDatas=array();
$where['add_time']=Common::format(" add_time>={0} and add_time<",$beginTime,TIMESTAMP);
$orders=$orderDao->getList($where, $orderDao->_primaryKey, $this->taskIndex, $this->taskSize, $orderField = 'add_time', $sort = 'desc');
$where=Common::format(" add_time>={0} and add_time<{1} ",$beginTime,TIMESTAMP);
$orders=$orderDao->getList($where, 'order_id as orderId,delete_state as deleteState,order_sn as orderSn,store_id as storeId,buyer_id as buyerId', $this->taskIndex, $this->taskSize, array( 'add_time'=>'desc'));
if(!empty($orders['list'])){
$orderIds=array_column($orders['list'],$orderDao->_primaryKey);
$resultOrders=array();
foreach($orders as $order){
$indexs=array();
$orderIds=array_column($orders['list'],'orderId');
$orderGoods=$orderGoodDao->getOrderGoodsByOrderIds($orderIds,'order_id as orderId,goods_name as goodsName');
$resultOrders=Common::intergrateOneToMany($orders['list'], $orderGoods, 'orderId', 'orderId', 'orderGoods');
foreach($resultOrders as $result){
$one['orderId']=$result['orderId'];
$one['orderSn']=$result['orderSn'];
$namesArr=array_column($result['orderGoods'],'goodsName');
$nameStr=implode(',',$namesArr);
$one['goodsName']=$nameStr;
$one['orderId']=$result['orderId'];
array_push($indexs,$one);
}
}
$storeMemberStatisticData= $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime,$this->taskIndex,$this->taskSize);
$storeMemberStatisticData=isset($storeMemberStatisticData['list'])?$storeMemberStatisticData['list']:false;
if($storeMemberStatisticData){
$this->taskIndex++;
foreach($storeMemberStatisticData as $value){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['storeId']=$value['storeId'];
$addDatas[$value['buyerId'].'-'.$value['storeId']]['memberId']=$value['buyerId'];
if(isset($addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount'])){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount']+=$value['goodsNum'];
}else{
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderGoodsCount']=$value['goodsNum'];
}
if(isset($addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal'])){
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal']+=$value['goodsPrice'];
}else{
$addDatas[$value['buyerId'].'-'.$value['storeId']]['orderTotal']=$value['goodsPrice'];
}
}
}
$addDatas=array_values($addDatas);
$storeMemberStatisticDao->addAll($addDatas);
}while($orders);
file_put_contents($this->baseDir . PathConst::orderLastCreateTime, TIMESTAMP);
}
//grow orderIndex
//创建索引
public function growOrdersIndex()
{
$orderGoodDao=\DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$gmtCreate = file_get_contents($this->baseDir . PathConst::orderLastCreateTime);
$gmtCreate = !empty($gmtCreate)?$gmtCreate:ApiConst::zero;
$beginTime=$gmtCreate;
$this->taskIndex=PageConst::taskPageBegin;
$this->taskSize=PageConst::taskPageSize;
$elasticsTool=ElasticsToolModel::getInstance('orders');
$res= $elasticsTool->indexExists();
echo json_encode($res);exit;
do{
$addDatas=array();
$where=Common::format(" add_time>={0} and add_time<{1} ",$beginTime,TIMESTAMP);
$orders=$orderDao->getList($where, 'order_id as orderId,delete_state as deleteState,order_sn as orderSn,store_id as storeId,buyer_id as buyerId', $this->taskIndex, $this->taskSize, array( 'add_time'=>'desc'));
if(!empty($orders['list'])){
$indexs=array();
$orderIds=array_column($orders['list'],'orderId');
$orderGoods=$orderGoodDao->getOrderGoodsByOrderIds($orderIds,'order_id as orderId,goods_name as goodsName');
$resultOrders=Common::intergrateOneToMany($orders['list'], $orderGoods, 'orderId', 'orderId', 'orderGoods');
foreach($resultOrders as $result){
$one['orderId']=$result['orderId'];
$one['orderSn']=$result['orderSn'];
$namesArr=array_column($result['orderGoods'],'goodsName');
$nameStr=implode(',',$namesArr);
$one['goodsName']=$nameStr;
$one['orderId']=$result['orderId'];
array_push($indexs,$one);
}
}
$storeMemberStatisticData= $orderGoodDao->getMemberStoreStaticsByCreateTime($beginTime,$this->taskIndex,$this->taskSize);
$storeMemberStatisticData=isset($storeMemberStatisticData['list'])?$storeMemberStatisticData['list']:false;
......
......@@ -132,7 +132,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$favType = 1;
}
}
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>$storeInfo['store_collect'],'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv);
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>$storeInfo['store_collect'],'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'],'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'],'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv,'memberId'=>$storeInfo['member_id']);
}
/**
......
......@@ -41,19 +41,19 @@ class FootprintServiceModel extends \Business\AbstractModel
*/
public function getFootprints($param,$memberId){
// $pageSize = (int)($param['pageSize']);
// $pageIndex = (int)($param['pageIndex']);
// k = (int)($param['pageIndex']);
$viewTime = (int)($param['viewTime']);
if($viewTime === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::ViewTimeNotExist);
}
$viewTime += \Our\ApiConst::oneDaySecond;
//$viewTime += \Our\ApiConst::oneDaySecond;
// if($pageSize === 0){
// \Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
// }
$acts = \DAO\SaleMemberModel::getInstance()->isJoinPlatform($memberId);
$browseDAO = \DAO\GoodsBrowseModel::getInstance();
$commonDAO = \DAO\GoodsCommonModel::getInstance();
$where1 = "member_id = {$memberId} AND browsetime <".$viewTime;
$where1 = "member_id = {$memberId} AND browsedate =".$viewTime;
$field = 'goods_commonid,browsedate,group_id';
//$limit = array($pageIndex*$pageSize,$pageSize);
......@@ -82,19 +82,21 @@ class FootprintServiceModel extends \Business\AbstractModel
'goodsPrice'=>$goodsCommon['goods_price'],
'viewDate'=>$dates[$v]
];
$footPrints[] = $temp;
//$footPrints[] = $temp;
$goodsCommons[$goodsCommon['goods_commonid']] = $temp;
}
}
}else{
$acts = array_keys($acts);
$field = 'han_goods_common.goods_commonid AS goodsCommonId,goods_name AS goodsName,goods_image AS goodsImage,goods_price AS goodsPrice';
$list = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getListWithSale'),array($where,$field,$acts,[],[],'',false),\Our\ApiConst::oneMinute);
$list = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getListWithSale'),array($where,$field,$acts,[],[],'',false),\Our\ApiConst::oneMinute);;
if($list){
foreach ($list as $goodsCommon) {
$goodsCommon['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($goodsCommon['goodsImage'],360);
$goodsCommon['viewDate'] = $dates[$goodsCommon['goodsCommonId']];
$goodsCommon['groupId'] = 0;
$footPrints[] = $goodsCommon;
//$footPrints[] = $goodsCommon;
$goodsCommons[$goodsCommon['goodsCommonId']] = $goodsCommon;
}
}
}
......@@ -115,10 +117,18 @@ class FootprintServiceModel extends \Business\AbstractModel
'goodsPrice'=>$group['discountPrice'],
'viewDate'=>$dates[$group['blId']]
];
$footPrints[] = $temp;
$groups[$group['blId']] = $temp;
}
}
}
foreach ($browseList as $browse) {
if($browse['goods_commonid']) {
$footPrints[] = $goodsCommons[$browse['goods_commonid']];
}
if($browse['group_id']) {
$footPrints[] = $groups[$browse['group_id']];
}
}
}
return array('footprints'=>$footPrints);
}
......
......@@ -13,7 +13,7 @@ class GoodsCommonStorageModel extends \DAO\AbstractModel {
*
* @var string
*/
protected $_tableName = 'han_goods_common_storage;';
protected $_tableName = 'han_goods_common_storage';
/**
* 主键
......@@ -63,13 +63,53 @@ class GoodsCommonStorageModel extends \DAO\AbstractModel {
}
public function getAll(){
$this->setDb($this->dbName);
$res=$this->db->fetchAll();
$res=$this->db->from($this->_tableName)->fetchAll();
return $res;
}
public function createTestData(){
$res =$this->getAll();
echo json_encode($res);exit;
$insertNames=array();
$insertArray=array();
$one= array('状元笔记','三点一测','初高中','另类学习','天才辅导','启蒙','课外学习','小天才','深入理解','黄冈练习');
$two=array('七年级','八年级','九年级');
$three=array('语文','数学','英语','物理','化学','生物','地理','历史','政治');
$four=array('人教版','北师大版','苏教版');
$five=array('上册','下册');
$goodsStorage=\DAO\Storage\GoodsStorageModel::getInstance();
foreach($one as $onekey=>$oneVal){
foreach($two as $twoKey=>$twoVal){
foreach($three as $threeKey=>$threeVal){
foreach($four as $fourKey=>$fourVal){
foreach($five as $fiveKey=>$fiveVal){
$diffKey=(string)$onekey.(string)$twoKey.(string)$threeKey.(string)$fourKey.(string)$fiveKey;
$catName=$oneVal.$twoVal.$threeVal.$fourVal.$fiveVal;
$resultIndex=array_rand($res);
$re=$res[$resultIndex];
$re['goods_commonid']=5000000+(int)$diffKey;
$re['goods_name']=$catName;
$re['goods_jingle']=$catName;
$re['gc_name']='学习辅导课程';
$re['store_id']=117;
$re['store_name']='testlyz1的小店';
$re['goods_addtime']=TIMESTAMP;
$re['gc_id']=1152;
$re['gc_id_1']=1064;
$re['gc_id_2']=1081;
$re['gc_id_3']=1152;
$this->db->insert($this->_tableName)->rows($re)->execute();
$goodsStorage->addOne($re);
}
}
}
}
}
}
/**
* 商品列表(需要获取销售价格)
* @param $where
......
......@@ -94,8 +94,41 @@ class GoodsStorageModel extends \DAO\AbstractModel {
}
return $goodsList;
}
public function getAll(){
$this->setDb($this->dbName);
$res=$this->db->from($this->_tableName)->fetchAll();
return $res;
}
public function addOne($res){
$addData['goods_id']=$res['goods_commonid'];
$addData['goods_commonid']=$res['goods_commonid'];
$addData['goods_name']=$res['goods_name'];
$addData['goods_jingle']=$res['goods_jingle'];
$addData['store_id']=$res['store_id'];
$addData['store_name']=$res['store_name'];
$addData['gc_id']=$res['gc_id'];
$addData['gc_id_1']=$res['gc_id_1'];
$addData['gc_id_2']=$res['gc_id_2'];
$addData['gc_id_3']=$res['gc_id_3'];
$addData['brand_id']=$res['brand_id'];
$addData['goods_price']=$res['goods_price'];
$addData['goods_marketprice']=$res['goods_marketprice'];
$addData['goods_spec']='';
$addData['goods_image']=$res['goods_image'];
$addData['goods_state']=$res['goods_state'];
$addData['goods_verify']=$res['goods_verify'];
$addData['goods_addtime']=$res['goods_addtime'];
$addData['goods_edittime']=$res['goods_edittime'];
$addData['color_id']=0;
$addData['is_virtual']=$res['is_virtual'];
$addData['virtual_indate']=$res['virtual_indate'];
$addData['virtual_limit']=$res['virtual_limit'];
$addData['virtual_invalid_refund']=$res['virtual_invalid_refund'];
$addData['goods_youku_url']=$res['goods_youku_url'];
$addData['goods_barcode']=$res['goods_barcode'];
$this->setDb($this->dbName);
$this->db->insert($this->_tableName)->rows($addData)->execute();
}
public function validEditCartGoods($where,$cart,$storageFlag = true){
$goods = $this->getOnlineOne($where['goodsId']);
......
......@@ -43,6 +43,7 @@ class ElasticsToolModel
'type' => $this->tbName
];
}
/**
* 创建索引 结果["acknowledged": true]
*/
......@@ -74,7 +75,7 @@ class ElasticsToolModel
],
]
],
$this->tbName=> [
$this->tbName => [
'properties' => [
'phone' => [
'type' => 'string',
......@@ -87,6 +88,7 @@ class ElasticsToolModel
$res = $this->client->indices()->create($params);
return $res;
}
/*
* 陈传文
* 创建索引在设置mapping之前要创建索引
......@@ -153,25 +155,26 @@ class ElasticsToolModel
$response = $this->client->update($updateParams);
}
//一般传where就可以了,
public function searchMatch($where,$pageIndex=ApiConst::pageIndex,$pageSize=ApiConst::pageSize,$sort=array('_score' => array('order' => 'desc')))
public function searchMatch($where, $pageIndex = ApiConst::pageIndex, $pageSize = ApiConst::pageSize, $sort = array('_score' => array('order' => 'desc')))
{
$searchParams['index'] = $this->dbName;
$searchParams['type'] = $this->tbName;
$from=($pageIndex)*$pageSize;
$from = ($pageIndex) * $pageSize;
$searchParams['from'] = $from;
$searchParams['size'] = $pageSize;
$searchParams['sort'] =$sort;
$searchParams['body']=array(
'query'=>array('match'=>$where),
$searchParams['sort'] = $sort;
$searchParams['body'] = array(
'query' => array('match' => $where),
);
$retDoc = $this->client->search($searchParams);
if(!isset($retDoc['hits'])){
if (!isset($retDoc['hits'])) {
ErrorModel::throwException(CodeConfigModel::elasticsError);
}
$htis=$retDoc['hits']['hits'];
$returnData['list']=array_column($htis,'_source');
$returnData['total']=$retDoc['hits']['total'];
$htis = $retDoc['hits']['hits'];
$returnData['list'] = array_column($htis, '_source');
$returnData['total'] = $retDoc['hits']['total'];
return $returnData;
}
......@@ -215,12 +218,16 @@ class ElasticsToolModel
*/
public function deleteIndex()
{
try {
$params = [
'index' => $this->dbName
];
$res = $this->client->indices()->delete($params);
return $res;
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage(), $ex->getCode());
}
}
/**
......@@ -236,6 +243,7 @@ class ElasticsToolModel
$res = $this->client->indices()->delete($params);
return $res;
}
/**
* 删除索引
*/
......@@ -249,30 +257,34 @@ class ElasticsToolModel
$res = $this->client->index($params);
return $res;
}
//插入多条 Document:
public function postBulkDoc($rows){
public function postBulkDoc($rows)
{
foreach($rows as $row){
foreach ($rows as $row) {
$params['body'][] = [
'index' => [
'_index' => $this->dbName,
'_type' => $this->tbName,
]
];
$params['body'][]=$row;
$params['body'][] = $row;
}
$res = $this->client->bulk($params);
return $res;
}
public function createIkField(){
public function createIkField()
{
$params = [
'index' => $this->dbName, //索引名称
'body' => [
'settings' => [ //配置
'analysis' => array(
'analyzer'=>array(
'ik'=>[
'tokenizer'=>'ik_max_word',
'analyzer' => array(
'ik' => [
'tokenizer' => 'ik_max_word',
]
)
),
......@@ -284,8 +296,8 @@ class ElasticsToolModel
],
'properties' => [ //配置数据结构与类型
'goodsName' => [ //字段1
"type" =>"string",
"analyzer"=> "ik_max_word"
"type" => "string",
"analyzer" => "ik_max_word"
],
]
],
......@@ -326,14 +338,30 @@ class ElasticsToolModel
$res = $this->client->search($params);
return $res;
}
//查看mapping
public function indexExists()
{
try{
$res =$this->client->exists(array('index'=>$this->dbName));
}catch(\Exception $ex){
return false;
}
return $res;
}
//查看mapping
public function getMappings()
{
try {
$params = [
'index' =>$this->dbName,
'index' => $this->dbName,
];
$res = $this->es->indices()->getMapping($params);
$res = $this->client->indices()->getMapping($params);
return $res;
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage(), $ex->getCode());
}
}
/**
......
......@@ -3,10 +3,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8 ?>">
<title>Document</title>
<title>商品详情</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
</head>
<body>
<div style="width: 750px">
<div>
<?php echo $commonInfo['goods_body']; ?>
</div>
</body>
......@@ -16,5 +17,9 @@
margin:0;
padding: 0;
}
img{
max-width:100%;
height:auto;
}
</style>
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE);
class cliShopkeeperOrders extends basecli
{
const CLI_ADMIN_ID = 255;
private $bDoUnLock = FALSE; // 是否允许释放 LOCK 文件
private $_debug = 0;
private $lockFileName;
public $key='';
private $fromState;
private function mkdirs($dir, $mode = 0777)
{
if (is_dir($dir) || @mkdir($dir, $mode)) {
return TRUE;
}
if (!$this->mkdirs(dirname($dir), $mode)) {
return FALSE;
}
return @mkdir($dir, $mode);
}
/**
* 析构
*/
public function __destruct()
{
parent::__destruct();
if ($this->bDoUnLock) {
@unlink($this->lockFileName);
}
}
protected function _runCli()
{
$this->_debug = isset($this->aArgv[1]) ? intval($this->aArgv[1]) : 0;
if ($this->_debug) {
echo "*** Debug mode ***\n";
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir = $this->_getBaseFileName('shopkeeper');
if (!$this->mkdirs($lockDir)) {
echo '****create dir fail ****';
exit;
}
$this->lockFileName = $lockDir . DS . 'orders.locks';
if (file_exists($this->lockFileName)) {
$stat = stat($this->lockFileName);
if ((TIMESTAMP - $stat['mtime']) > 1800) {
echo "文件被锁超过1800秒,被强制删除";
@unlink($this->lockFileName);
} else {
$this->halt('[' . date('Y-m-d H:i:s') . '] The CLI is running' . "\n");
}
}
$this->bDoUnLock = true;
file_put_contents($this->lockFileName, "running"); // CLI 独占锁
$shopkeeperService = \Business\Store\ShopkeeperServiceModel::getInstance();
$shopkeeperService->baseDir= \Our\Common::getConfig('out.config');
try {
$shopkeeperService->createOrdersIndex();
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage(),$ex->getCode());
}
echo '店铺订单索引生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
}
$oCli = new cliShopkeeperOrders(TRUE);
EXIT;
?>
......@@ -51,7 +51,7 @@ class cliGrow extends basecli
echo "*** Debug mode ***\n";
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir = $this->_getBaseFileName('shopkeeper');
$lockDir = $this->_getBaseFileName('growGoodsStores');
if (!$this->mkdirs($lockDir)) {
echo '****create dir fail ****';
exit;
......@@ -77,7 +77,7 @@ class cliGrow extends basecli
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
}
echo '店铺订单索引生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
echo '店铺生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
}
......
......@@ -58,13 +58,13 @@ $serv->on('Message', function($server, $frame) use($conf){
$rev_data=$rev_data['data'];
$realKey = KEY_REDIS_PRE.$key;
$sessData=$redis->get($realKey);
$sessDataSpilt1=explode(';',$sessData);
$sessDataSpilt2=explode('|',$sessDataSpilt1[1]);
$sessDataSpilt3=explode(':', $sessDataSpilt2[1]);
$res= $sessDataSpilt3[1];
// $sessDataSpilt1=explode(';',$sessData);
// $sessDataSpilt2=explode('|',$sessDataSpilt1[1]);
// $sessDataSpilt3=explode(':', $sessDataSpilt2[1]);
// $res= $sessDataSpilt3[1];
$matchs=array();
preg_match("/\d+/i",$res,$matchs);
$memberId= $matchs[0];
preg_match("/member_id\|i:(\d+)/i",$sessData,$matchs);
$memberId= $matchs[1];
$messageService=\Business\Message\MessageServiceModel::getInstance();
$sendFd=$redis->hGet(KEY_PRE.$rev_data['toId'],'fd');
......@@ -97,7 +97,7 @@ $serv->on('Message', function($server, $frame) use($conf){
$sendMessage['fromId']=$memberId;
$sendMessage['fromUserId']= $rev_data['fromUserId'];
$sendMessage['fromUserName']= $rev_data['fromUserName'];
$sendMessage['fromAvatar']= $messageService->getAvatar( $rev_data['fromType'],$frame->fd);
$sendMessage['fromAvatar']= $messageService->getAvatar( $rev_data['fromType'],$rev_data['fromUserId']);
$sendMessage['fromType']= $rev_data['fromType'];
$sendMessage['toId']= $rev_data['toId'];
$sendMessage['toUserId']=$rev_data['toUserId'];
......
......@@ -73,8 +73,8 @@ class cliShopkeeperOrders extends basecli
try {
$shopkeeperService->createOrdersIndex();
} catch (Exception $ex) {
throw new Exception($ex->getCode() . '|' . $ex->getMessage());
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage(),$ex->getCode());
}
echo '店铺订单索引生成成功' .date('Y-m-d H:i:s',TIMESTAMP). "\r\n";
}
......
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