@@ -29,15 +29,63 @@ class StoreServiceModel extends \Business\AbstractModel{
$beginTime=$beginTime?$beginTime:ApiConst::zero;
$endTime=TIMESTAMP;
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select se.store_id from han_store_extend se where se.gmt_update > '.$beginTime.' ) and store_id in (select qs.store_id from han_qm_store_class qs where qs.gmt_update > '.$beginTime.' or (qs.deadline>'.$beginTime.' and qs.deadline<='.$endTime.'))';
$field='store_id,store_state,store_time,store_end_time,province_id,city_id,area_id,(select se.cashed_deposit from han_store_extend se where se.store_id=han_store.store_id) cashed_deposit,if((store_state=1 and store_end_time>=0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id), 0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id and qs.deadline>=0), 0)) service_fee';
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select se.store_id from han_store_extend se where se.gmt_update > '.$beginTime.' )';
$field='store_id,store_name,store_state,store_time,store_end_time,province_id,city_id,area_id,(select se.cashed_deposit from han_store_extend se where se.store_id=han_store.store_id) cashed_deposit';
if($datas=$storeDao->getStores($where,$field)){
echo'extend in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
unset($update_data['store_id']);
$where='store_id='.$val['store_id'];
if(!$statDao->update($where,$update_data)){
$result=false;
}
}
}
//更新店铺经营分类数据
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select qs.store_id from han_qm_store_class qs where qs.gmt_update > '.$beginTime.' or (qs.deadline>'.$beginTime.' and qs.deadline<='.$endTime.'))';
$field='store_id, (select count(qs.store_id) from han_qm_store_class qs where qs.is_charged<>0 and qs.store_id=han_store.store_id) class_style1_count, (select count(qs.store_id) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id) class_style2_count, if((store_state=1 and store_end_time>=0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id), 0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id and qs.deadline>=0), 0)) service_fee';
if($datas=$storeDao->getStores($where,$field)){
echo'class in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
unset($update_data['store_id']);
$where='store_id='.$val['store_id'];
if(!$statDao->update($where,$update_data)){
$result=false;
}
}
}
//更新店铺关注信息
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select fs.store_id from han_favorites_store fs where fs.fav_time > '.$beginTime.')';
$field='store_id,(select count(fs.store_id) from han_favorites_store fs where fs.fav_type=1 and fs.store_id=han_store.store_id) fav_total,(select count(fs.store_id) from han_favorites_store fs where fs.fav_type=1 and fs.fav_from=3 and fs.store_id=han_store.store_id) fav3_total';
if($datas=$storeDao->getStores($where,$field)){
echo'favorite in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
unset($update_data['store_id']);
$where='store_id='.$val['store_id'];
if(!$statDao->update($where,$update_data)){
$result=false;
}
}
}
//更新店铺有效订单信息
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select ss.store_id from han_store_statistics ss where ss.add_time > '.$beginTime.')';
$field='store_id,(select t.order_count from han_store_statistics t where t.store_id=han_store.store_id limit 1) order_count,(select t.order_total from han_store_statistics t where t.store_id=han_store.store_id limit 1) order_total';
if($datas=$storeDao->getStores($where,$field)){
echo'statistics in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
...
...
@@ -49,12 +97,74 @@ class StoreServiceModel extends \Business\AbstractModel{
}
}
//更新店铺订单超时信息
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select o.store_id from han_order o where o.gmt_update > '.$beginTime.')';
$field='store_id,(select count(*) from han_order o where o.store_id=han_store.store_id) all_order_count,(select count(*) from han_order o where o.is_effective=1 and o.store_id=han_store.store_id) expire_order_count';
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select rr.store_id from han_refund_return rr where rr.gmt_update > '.$beginTime.')';
$field='store_id,(select count(distinct t.order_id) from han_refund_return t where t.store_id=han_store.store_id and t.seller_state!=3) refund_order_count,(select sum(t.refund_amount) from han_refund_return t where t.seller_state!=3 and t.store_id=han_store.store_id) refund_order_total';
if($datas=$storeDao->getStores($where,$field)){
echo'refund in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
unset($update_data['store_id']);
$where='store_id='.$val['store_id'];
if(!$statDao->update($where,$update_data)){
$result=false;
}
}
}
//更新店铺举报信息
$where='store_id in (select ss.store_id from han_stat_store ss) and store_id in (select t.seller_id from han_report t where t.report_time > '.$beginTime.')';
$field='store_id,(select count(*) from han_report t where t.seller_id=han_store.store_id) report_count';
if($datas=$storeDao->getStores($where,$field)){
echo'favorite in:'.count($datas);
foreach($datasas$key=>$val){
$update_data=$val;
$update_data['upd_time']=$endTime;
unset($update_data['store_id']);
$where='store_id='.$val['store_id'];
if(!$statDao->update($where,$update_data)){
$result=false;
}
}
}
//处理新店铺信息
$where='store_id not in (select ss.store_id from han_stat_store ss)';
$field='store_id,store_state,store_time,store_end_time,province_id,city_id,area_id,(select se.cashed_deposit from han_store_extend se where se.store_id=han_store.store_id) cashed_deposit';
$field.=',(select count(qs.store_id) from han_qm_store_class qs where qs.is_charged<>0 and qs.store_id=han_store.store_id) class_style1_count, (select count(qs.store_id) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id) class_style2_count, if((store_state=1 and store_end_time>=0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id), 0), ifnull((select sum(qs.service_fee) from han_qm_store_class qs where qs.is_charged<>0 and qs.class_style=2 and qs.store_id=han_store.store_id and qs.deadline>=0), 0)) service_fee';
$field.=',(select count(fs.store_id) from han_favorites_store fs where fs.fav_type=1 and fs.store_id=han_store.store_id) fav_total,(select count(fs.store_id) from han_favorites_store fs where fs.fav_type=1 and fs.fav_from=3 and fs.store_id=han_store.store_id) fav3_total';
$field.=',(select t.order_count from han_store_statistics t where t.store_id=han_store.store_id limit 1) order_count,(select t.order_total from han_store_statistics t where t.store_id=han_store.store_id limit 1) order_total';
$field.=',(select count(*) from han_order o where o.store_id=han_store.store_id) all_order_count,(select count(*) from han_order o where o.is_effective=1 and o.store_id=han_store.store_id) expire_order_count';
$field.=',(select count(distinct t.order_id) from han_refund_return t where t.store_id=han_store.store_id and t.seller_state!=3) refund_order_count,(select sum(t.refund_amount) from han_refund_return t where t.seller_state!=3 and t.store_id=han_store.store_id) refund_order_total';
$field.=',(select count(*) from han_report t where t.seller_id=han_store.store_id) report_count';