Commit b666877d authored by wwccw0591's avatar wwccw0591

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

parents af66d50d 2120fbca
......@@ -40,7 +40,8 @@ class GoodsController extends \Our\Controller_AbstractIndex {
}
public function testAction(){
//$info = $this->goodsService->recommend();
\Business\Goods\GoodsCommonServiceModel::getInstance()->saleGoods();
//\Business\Goods\GoodsCommonServiceModel::getInstance()->saleGoods();
\Business\Goods\EvaluationServiceModel::getInstance()->autoEvaluate();
}
public function getAttrsAction(){
......
......@@ -213,10 +213,17 @@ class ApiConst
//一个小时
const oneHourCache = 1;
//forStoreMember
const storeQrcodeMember = 1;//扫描店铺二维码
const sellerQrcodeMember = 2;//扫描销售员二维码
const buyMember = 3;//购买
//forFavoritesStore
const selfFavor = 1;//主动关注
const buyFavor = 2;//购买关注
const scanFavor = 3;//扫码关注
const messageTypeRegister = 1;//注册类短信
const messageTypeLogin = 2; //登录类短信
const messageTypeSeller = 3; //销售员登录短信
......
......@@ -131,6 +131,18 @@ class ImageUtil {
}
return $goodsImg;
}
public function getStoreLabel($storeLabel, $directory = \Our\ImageConst::storeLabel,$width=\Our\ApiConst::zero,$height=\Our\ApiConst::zero){
$storeLableImage = \Our\Common::getStaticFile($storeLabel, $directory);
if($width){
if(!$height){
$height = $width;
}
$storeLableImage .= "?x-oss-process=image/resize,m_fill,h_{$height},w_{$width}";
}
return $storeLableImage;
}
public function getGoodsImgWithUrl($goodsImgUrl,$width=\Our\ImageConst::goodsListImgSize, $height = 0) {
$width = $width * \Our\ImageConst::sizeScale;
$height ? $height = $height * \Our\ImageConst::sizeScale : $height = $width;
......
......@@ -53,7 +53,7 @@ class OrderConst {
const waitBuyerConfirmRecieve='等待用户确认收货';
const defaultComment = '好评!';
const beyondTimeDefaultComment = '此用户没有填写评价';//超期评价
}
?>
\ No newline at end of file
......@@ -90,6 +90,8 @@ class CouponServiceModel extends \Business\AbstractModel{
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyCouponId);
}
$coupon = $couponDao->findById($where['couponId']);
$coupon['cash_money'] = $coupon['cash_money']?($coupon['cash_money']/\Our\ApiConst::hundred):\Our\ApiConst::zero;
$coupon['order_amount'] = $coupon['order_amount']?($coupon['order_amount']/\Our\ApiConst::hundred):\Our\ApiConst::zero;
if(!$coupon || $coupon['is_del'] == 1 || time() > $coupon['end_time'] || time() < $coupon['start_time']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::couponNotExist);
}
......
This diff is collapsed.
......@@ -539,7 +539,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$commonInstance = \DAO\GoodsCommonModel::getInstance();
$count = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonInstance, 'getCount'),array(array('store_id'=>$storeId)),\Our\ApiConst::oneDaySecond);
return array('storeId'=>$storeId,'storeName'=>$storeInfo['store_name'],'storeLabel'=>\DAO\StoreModel::getInstance()->getStoreLabelSrc($storeInfo['store_label'],\Our\ImageConst::goodsStoreImg),'goodsTotal'=>$count,'isQuality'=>$storeInfo['store_zhping'],'freeShippingPrice'=>$storeInfo['free_shipping_price'],'shareDesc'=>$storeInfo['store_share_desc']);
return array('storeId'=>$storeId,'storeName'=>$storeInfo['store_name'],'storeLabel'=>\DAO\StoreModel::getInstance()->getStoreLabelSrc($storeInfo['store_label'],\Our\ImageConst::goodsStoreImg),'goodsTotal'=>$count,'isQuality'=>$storeInfo['store_zhping'],'freeShippingPrice'=>$storeInfo['free_shipping_price'],'shareDesc'=>$storeInfo['store_share_desc'],'memberId'=>$storeInfo['member_id']);
}
/**
......@@ -932,13 +932,13 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$goodsCommonRedis->tableDel('weekSales:' . $storeId);
$goodsCommonRedis->tableDel('weekSaleGoods:' . $storeId);
$goodsCommonRedis->tableDel('recommendGoods:' . $storeId);
$goodsCommonids = $orderDAO->getOrderAndOrderGoods("han_order.store_id={$storeId} AND han_order.payment_time between ".(time()-\Our\ApiConst::sevenDaySecond)." AND ".time(), 'sum(goods_num) as num,goods_commonid', 'goods_commonid', [0, 3], ['num', 'DESC']);
$goodsCommonids = $orderDAO->getOrderAndOrderGoods("han_order.store_id={$storeId} AND han_order_goods.goods_commonid > 0 AND han_order.payment_time between ".(time()-\Our\ApiConst::sevenDaySecond)." AND ".time(), 'sum(goods_num) as num,goods_commonid', 'goods_commonid', [0, 3], ['num', 'DESC']);
if ($goodsCommonids) {
foreach ($goodsCommonids as $v) {
$goodsCommonRedis->tableSAdd('weekSales:' . $storeId, $v['goods_commonid']);
}
}
$goodsCommonids = $orderDAO->getOrderAndOrderGoods("han_order.store_id={$storeId} AND han_order.payment_time between ".(time()-\Our\ApiConst::sevenDaySecond)." AND ".time(), 'distinct goods_commonid');
$goodsCommonids = $orderDAO->getOrderAndOrderGoods("han_order.store_id={$storeId} AND han_order_goods.goods_commonid > 0 AND han_order.payment_time between ".(time()-\Our\ApiConst::sevenDaySecond)." AND ".time(), 'distinct goods_commonid');
if ($goodsCommonids) {
foreach ($goodsCommonids as $v) {
$goodsCommonRedis->tableSAdd('weekSaleGoods:' . $storeId, $v['goods_commonid']);
......
......@@ -123,7 +123,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$favType = 1;
}
}
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'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']);
return array('storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'grade'=>$grade,'fansCount'=>\DAO\FavoritesStoreModel::getInstance()->getFavoritesStoreCountByStoreId($storeId),'favType'=>$favType,'monthlySalesCount'=>$monthlySalesCount,'defaultDeliveryTime'=>$defaultDeliveryTime,'freeShippingPrice'=>$storeInfo['free_shipping_price'] * 100,'storeDistance'=>$distince,'storeNotice'=>$storeInfo['store_notice'],'startShippingPrice'=>$storeInfo['start_shipping_price'] * 100,'memberId'=>$storeInfo['member_id'],'inStoreService'=>$in_store_service_flag,'adv'=>$adv,'memberId'=>$storeInfo['member_id']);
}
/**
......@@ -718,7 +718,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$store['storeDistance'] = \Our\CommonExtension::getDistance($lat,$lng,$store['store_latitude'],$store['store_longitude']);
unset($store['store_longitude']);
unset($store['store_latitude']);
$store['storeLabel'] = \Our\Common::getStaticFile($store['storeLabel'], \Our\ImageConst::storeLabel);
$store['storeLabel'] = \Our\ImageUtil::getStoreLabel($store['storeLabel'], \Our\ImageConst::storeLabel,213);
$storeList[$store['storeId']] = $store;
}
return $storeList;
......
......@@ -261,6 +261,7 @@ class MemberServiceModel extends \Business\AbstractModel
$member['member_mobile'] = $where['mobile'];
$member['member_mobile_bind'] = \Our\ApiConst::one;
$member['member_passwd'] = md5($where['password']);
$member['member_time'] = TIMESTAMP;
$result = $memberDao->addInfo($member);
return $result;
}
......@@ -285,14 +286,20 @@ class MemberServiceModel extends \Business\AbstractModel
if($scan_store_ids){
$storeMembers = array();
foreach($scan_store_ids as $storeId){
$storeMember['storeId'] = $storeId;
$storeMember['memberId'] = $memberId;
$storeMember['type'] = \Our\ApiConst::storeQrcodeMember;
$storeMember = array();
$storeMember['store_id'] = $storeId;
$storeMember['member_id'] = $memberId;
$storeMember['fav_from'] = \Our\ApiConst::scanFavor;
$storeMembers[] = $storeMember;
}
$storeMemberDao = \DAO\StoreMemberModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$result = $storeMemberDao->addBatch($storeMember);
return $result;
/*$storeMemberDao = \DAO\StoreMemberModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$result = $storeMemberDao->addBatch($storeMember);*/
$favoritesStoreDao = \DAO\FavoritesStoreModel::getInstance();
$result = $favoritesStoreDao->insertAll($storeMembers);
if(!$result){
\Our\Log::getInstance()->write(json_encode($storeMembers).'扫码数据写入失败');
return false;
}
}
$scan_sale_ids = $sess->get('scan_sale_ids');
if($scan_sale_ids){
......
......@@ -86,6 +86,57 @@ class FavoritesStoreModel extends \DAO\AbstractModel {
$sql = \Our\Common::format($baseSql, $data['member_id'], $data['store_id'],$data['fav_time']);
return $this->db->insert($this->_tableName)->query($sql);
}
public function insertAll($datas){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$error = 0;
$baseSql = "insert IGNORE into {$this->_tableName}(member_id,store_id,fav_from,fav_time) values";
$insertAllSql = $baseSql;
for ($i = 0; $i < count($datas); $i++) {
$addSql = \Our\Common::format("('{0}','{1}','{2}','{3}'),", $datas[$i]['member_id'], $datas[$i]['store_id'], $datas[$i]['fav_from'],TIMESTAMP);
$insertAllSql .= $addSql;
if ($i % 1000 == 0 && $i != 0) {
$insertAllSql = rtrim($insertAllSql, ',');
$insertAllSql .= 'ON DUPLICATE KEY UPDATE fav_time=VALUES (fav_time)';
$one = $this->db->insert($this->_tableName)->query($insertAllSql);
if (!$one) {
$error++;
}
$insertAllSql = $baseSql;
}
}
if ($insertAllSql != $baseSql) {
$insertAllSql = rtrim($insertAllSql, ',');
$insertAllSql .= 'ON DUPLICATE KEY UPDATE fav_time=VALUES (fav_time)';
$one = $this->db->insert($this->_tableName)->query($insertAllSql);
if (!$one) {
$error++;
}
}
if ($error > 0) {
return false;
}
return true;
}
/**
* 批量添加
* @param $datas
*/
public function addBatch($datas){
parent::setDb(\Our\DbNameConst::masterDBConnectName);
$sql = "INSERT INTO {$this->_tableName} ( store_id,member_id,fav_from,fav_time) values";
foreach($datas as $key => $data){
$sql .=\Our\Common::format(" (store_id={0} and member_id = {1} and fav_from={2} ),",$data['storeId'],$data['memberId'],$data['type']);
}
$sql = trim($sql,',');
$sql .= ";";
$res = $this->db->insert($this->_tableName)->query($sql);
return $res;
}
public function getFavoritesStoreCountByStoreId($storeId, $num = 0) {
$statisticsDb6Redis = \Redis\Db6\StatisticsRedisModel::getInstance();
$collectCount = $statisticsDb6Redis->tableCacheGet('storeCollectCount:'.$storeId);
......
......@@ -60,7 +60,7 @@ class StoreMemberModel extends \DAO\AbstractModel{
foreach($datas as $key => $data){
$sql .=\Our\Common::format(" (store_id={0} and member_id = {1} and type={2} ),",$data['storeId'],$data['memberId'],$data['type']);
}
$sql = substr($sql,0,strlen($sql)-1);
$sql = trim($sql,',');
$sql .= ";";
$res = $this->db->insert($this->_tableName)->query($sql);
return $res;
......
......@@ -2,7 +2,7 @@
/**
* 自动评价
* 执行时间:一小时执行一次
* 执行时间:十分钟执行一次
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
......@@ -39,10 +39,7 @@ class cliOrderEvaluate extends basecli
}
}
protected function autoEvaluate(){
$orderService=\Business\Order\OrderServiceModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$orderService->changeOrderStatus();
$messageService=\Business\Message\MessageServiceModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$messageService->addMessageCenterToDb();
\Business\Goods\EvaluationServiceModel::getInstance()->autoEvaluate();
}
protected function _runCli()
{
......@@ -62,9 +59,9 @@ class cliOrderEvaluate extends basecli
if( file_exists( $this->lockFileName ) )
{
$stat = stat($this->lockFileName);
if( (TIMESTAMP - $stat['mtime']) > 5400 )
if( (TIMESTAMP - $stat['mtime']) > 1800 )
{
echo "文件被锁超过5400秒,被强制删除";
echo "文件被锁超过1800秒,被强制删除";
@unlink($this->lockFileName);
}
else
......
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