code stringlengths 3 1.18M | language stringclasses 1 value |
|---|---|
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Event;
import java.util.List;
public abstract interface EventService {
public abstract List<Event> getEvent(String paramString);
public abstract Event getEvent(Long paramLong);
public abstract void deleteEvent(Event paramEvent);
public abstract Long saveEvent(Event paramEvent);
public abstract void updateEvent(Event paramEvent);
public abstract PageSupport getEvent(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Partner;
import java.util.List;
public abstract interface PartnerService {
public abstract List<Partner> getPartner(String paramString);
public abstract Partner getPartner(Long paramLong);
public abstract void deletePartner(Partner paramPartner);
public abstract Long savePartner(Partner paramPartner);
public abstract void updatePartner(Partner paramPartner);
public abstract PageSupport getPartner(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.service.ShopService;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.UserDetail;
public abstract interface ShopDetailService extends ShopService {
public abstract ShopDetail getShopDetailById(Long paramLong);
public abstract UserDetail getShopDetailByName(String paramString);
public abstract void delete(Long paramLong);
public abstract void delete(ShopDetail paramShopDetail);
public abstract void save(ShopDetail paramShopDetail);
public abstract void update(ShopDetail paramShopDetail);
public abstract PageSupport getShopDetail(CriteriaQuery paramCriteriaQuery);
public abstract ShopDetail getShopDetailByUserId(String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.UserAddress;
import java.util.List;
public abstract interface UserAddressService {
public abstract List<UserAddress> getUserAddress(String paramString);
public abstract UserAddress getUserAddress(Long paramLong);
public abstract void deleteUserAddress(UserAddress paramUserAddress);
public abstract Long saveUserAddress(UserAddress paramUserAddress);
public abstract void updateUserAddress(UserAddress paramUserAddress);
public abstract PageSupport getUserAddress(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.NewsCategory;
import java.util.List;
public abstract interface NewsCategoryService {
public abstract List<NewsCategory> getNewsCategoryList(String paramString);
public abstract NewsCategory getNewsCategoryById(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(NewsCategory paramNewsCategory);
public abstract void update(NewsCategory paramNewsCategory);
public abstract PageSupport getNewsCategoryList(
CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Brand;
import java.util.List;
public abstract interface BrandService {
public abstract List<Brand> getBrand(String paramString);
public abstract Brand getBrand(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(Brand paramBrand);
public abstract void update(Brand paramBrand);
public abstract PageSupport getDataByCriteriaQuery(
CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.News;
import java.util.List;
public abstract interface NewsService {
public abstract List<News> getNewsList(String paramString);
public abstract News getNewsById(Long paramLong);
public abstract News getNewsByIdAndName(Long paramLong, String paramString);
public abstract void delete(Long paramLong);
public abstract Long save(News paramNews);
public abstract void update(News paramNews);
public abstract PageSupport getNewsList(CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getNewsList(HqlQuery paramHqlQuery);
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.PartnerDao;
import com.legendshop.business.service.PartnerService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Partner;
import com.legendshop.util.AppUtils;
import java.util.List;
public class PartnerServiceImpl implements PartnerService {
private PartnerDao partnerDao;
public void setPartnerDao(PartnerDao partnerDao) {
this.partnerDao = partnerDao;
}
public List<Partner> getPartner(String userName) {
return this.partnerDao.getPartner(userName);
}
public Partner getPartner(Long id) {
return this.partnerDao.getPartner(id);
}
public void deletePartner(Partner partner) {
this.partnerDao.deletePartner(partner);
}
public Long savePartner(Partner partner) {
if (!AppUtils.isBlank(partner.getPartnerId())) {
updatePartner(partner);
return partner.getPartnerId();
}
return (Long) this.partnerDao.save(partner);
}
public void updatePartner(Partner partner) {
this.partnerDao.updatePartner(partner);
}
public PageSupport getPartner(CriteriaQuery cq) {
return this.partnerDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.LuceneDao;
import com.legendshop.business.service.LuceneService;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class LuceneServiceImpl implements LuceneService {
private LuceneDao luceneDao;
@Required
public void setLuceneDao(LuceneDao luceneDao) {
this.luceneDao = luceneDao;
}
public long getFirstPostIdByDate(int entityType, Date fromDate) {
return this.luceneDao.getFirstPostIdByDate(entityType, fromDate);
}
public List getPostsToIndex(int entityType, long firstPostId, long toPostId) {
return this.luceneDao
.getPostsToIndex(entityType, firstPostId, toPostId);
}
public long getLastPostIdByDate(int entityType, Date toDate) {
return this.luceneDao.getLastPostIdByDate(entityType, toDate);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.UserDetailDao;
import com.legendshop.business.service.UserDetailService;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.model.entity.UserDetail;
import org.springframework.beans.factory.annotation.Required;
public class UserDetailServiceImpl implements UserDetailService {
private UserDetailDao userDetailDao;
public Long getScore(String userName) {
return this.userDetailDao.getUserScore(userName);
}
public PageSupport getUserDetailList(HqlQuery hqlQuery) {
return this.userDetailDao.getUserDetailList(hqlQuery);
}
public UserDetail getUserDetail(String userName) {
return this.userDetailDao.getUserDetail(userName);
}
@Required
public void setUserDetailDao(UserDetailDao userDetailDao) {
this.userDetailDao = userDetailDao;
}
public PageSupport getUserDetailList(SqlQuery sqlQuery) {
return this.userDetailDao.getUserDetailList(sqlQuery);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.AdvertisementDao;
import com.legendshop.business.service.AdvertisementService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Advertisement;
import com.legendshop.util.AppUtils;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Required;
public class AdvertisementServiceImpl implements AdvertisementService {
private AdvertisementDao advertisementDao;
public List<Advertisement> getAdvertisementByUserName(String userName) {
return (List<Advertisement>) this.advertisementDao.findByHQL(
"from Advertisement where userName = ?", new Object[] {userName });
}
public Advertisement getAdvertisement(Long id) {
return (Advertisement) this.advertisementDao.get(Advertisement.class,
id);
}
public boolean isMaxNum(String userName, String type) {
return this.advertisementDao.isMaxNum(userName, type);
}
public void delete(Long id) {
this.advertisementDao.deleteById(Advertisement.class, id);
}
public Long save(Advertisement advertisement) {
if (!AppUtils.isBlank(advertisement.getId())) {
update(advertisement);
return advertisement.getId();
}
return (Long) this.advertisementDao.save(advertisement);
}
public void update(Advertisement advertisement) {
this.advertisementDao.update(advertisement);
}
public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
return this.advertisementDao.find(cq);
}
public List<Advertisement> getOneAdvertisement(String shopName, String key) {
return this.advertisementDao.getOneAdvertisement(shopName, key);
}
@Required
public void setAdvertisementDao(AdvertisementDao advertisementDao) {
this.advertisementDao = advertisementDao;
}
public Map<String, List<Advertisement>> getAdvertisement(String shopName) {
return this.advertisementDao.getAdvertisement(shopName);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.CashFlowDao;
import com.legendshop.business.service.CashFlowService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.CashFlow;
import com.legendshop.util.AppUtils;
import java.util.List;
public class CashFlowServiceImpl implements CashFlowService {
private CashFlowDao cashFlowDao;
public void setCashFlowDao(CashFlowDao cashFlowDao) {
this.cashFlowDao = cashFlowDao;
}
public List<CashFlow> getCashFlow(String userName) {
return this.cashFlowDao.getCashFlow(userName);
}
public CashFlow getCashFlow(Long id) {
return this.cashFlowDao.getCashFlow(id);
}
public void deleteCashFlow(CashFlow cashFlow) {
this.cashFlowDao.deleteCashFlow(cashFlow);
}
public Long saveCashFlow(CashFlow cashFlow) {
if (!AppUtils.isBlank(cashFlow.getFlowId())) {
updateCashFlow(cashFlow);
return cashFlow.getFlowId();
}
return (Long) this.cashFlowDao.save(cashFlow);
}
public void updateCashFlow(CashFlow cashFlow) {
this.cashFlowDao.updateCashFlow(cashFlow);
}
public PageSupport getCashFlow(CriteriaQuery cq) {
return this.cashFlowDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.core.tag.TableCache;
import com.legendshop.model.entity.ConstTable;
import com.legendshop.model.entity.ConstTableId;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MapCodeTablesCache implements TableCache {
private static Logger log = LoggerFactory
.getLogger(MapCodeTablesCache.class);
private Map<String, Map<String, String>> codeTables = new HashMap();
private BaseDao baseDao;
public Map<String, Map<String, String>> getCodeTables() {
return this.codeTables;
}
public void setCodeTables(Map<String, Map<String, String>> codeTables) {
this.codeTables = codeTables;
}
public Map<String, String> getCodeTable(String beanName) {
if ((beanName == null) || (beanName.trim().length() == 0)) {
return null;
}
Map table = (Map) this.codeTables.get(beanName);
return table;
}
public void initCodeTablesCache() {
List<ConstTable> list = loadAllConstTable();
for (ConstTable constTable : list) {
String type = constTable.getId().getType();
Map items = (Map) this.codeTables.get(type);
if (items == null) {
items = new LinkedHashMap();
}
items.put(constTable.getId().getKey(), constTable.getValue());
this.codeTables.put(type, items);
}
log.info("codeTables size = {}",
Integer.valueOf(this.codeTables.size()));
}
public void setBaseDao(BaseDao baseDao) {
this.baseDao = baseDao;
}
public List<ConstTable> loadAllConstTable() {
return (List<ConstTable>) this.baseDao
.findByHQL("from ConstTable c order by c.id.type, c.seq");
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ExternalLinkDao;
import com.legendshop.business.service.ExternalLinkService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.model.entity.ExternalLink;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class ExternalLinkServiceImpl implements ExternalLinkService {
private ExternalLinkDao externalLinkDao;
@Required
public void setExternalLinkDao(ExternalLinkDao baseDao) {
this.externalLinkDao = baseDao;
}
public List<ExternalLink> getExternalLink(String userName) {
return (List<ExternalLink>) this.externalLinkDao.findByHQL(
"from ExternalLink where userName = ?", new Object[] {userName });
}
public ExternalLink getExternalLinkById(Long id) {
return (ExternalLink) this.externalLinkDao.get(ExternalLink.class, id);
}
public ExternalLink getExternalLinkList(Long id, String userName) {
ExternalLink externalLink = (ExternalLink) this.externalLinkDao
.findUniqueBy("from ExternalLink where id = ? and userName = ?",
ExternalLink.class, new Object[] {id, userName });
if (externalLink == null) {
throw new BusinessException("no ExternalLink record", "15");
}
return externalLink;
}
public void delete(Long id) {
this.externalLinkDao.deleteById(ExternalLink.class, id);
}
public Long save(ExternalLink externalLink) {
if (!AppUtils.isBlank(externalLink.getId())) {
ExternalLink entity = (ExternalLink) this.externalLinkDao.get(
ExternalLink.class, externalLink.getId());
if (entity != null) {
entity.setUrl(externalLink.getUrl());
entity.setWordlink(externalLink.getWordlink());
entity.setContent(externalLink.getContent());
entity.setBs(externalLink.getBs());
update(entity);
return externalLink.getId();
}
return null;
}
return (Long) this.externalLinkDao.save(externalLink);
}
public void update(ExternalLink externalLink) {
this.externalLinkDao.update(externalLink);
}
public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
return this.externalLinkDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.Constants;
import com.legendshop.business.common.NewsCategoryStatusEnum;
import com.legendshop.business.common.OrderStatusEnum;
import com.legendshop.business.common.RegisterEnum;
import com.legendshop.business.common.ShopStatusEnum;
import com.legendshop.business.common.VisitTypeEnum;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.common.page.FrontPage;
import com.legendshop.business.common.page.TilesPage;
import com.legendshop.business.dao.AdvertisementDao;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.business.dao.BusinessDao;
import com.legendshop.business.dao.ExternalLinkDao;
import com.legendshop.business.dao.HotsearchDao;
import com.legendshop.business.dao.ImgFileDao;
import com.legendshop.business.dao.LogoDao;
import com.legendshop.business.dao.NewsDao;
import com.legendshop.business.dao.NsortDao;
import com.legendshop.business.dao.ProductDao;
import com.legendshop.business.dao.PubDao;
import com.legendshop.business.dao.ShopDetailDao;
import com.legendshop.business.dao.SortDao;
import com.legendshop.business.dao.SubDao;
import com.legendshop.business.dao.UserDetailDao;
import com.legendshop.business.dao.impl.VisitLogDaoImpl;
import com.legendshop.business.event.EventId;
import com.legendshop.business.form.MemberForm;
import com.legendshop.business.form.SearchForm;
import com.legendshop.business.form.UserForm;
import com.legendshop.business.helper.ShopStatusChecker;
import com.legendshop.business.helper.TaskThread;
import com.legendshop.business.helper.impl.PersistVisitLogTask;
import com.legendshop.business.helper.impl.SendMailTask;
import com.legendshop.business.service.BusinessService;
import com.legendshop.business.service.PayTypeService;
import com.legendshop.core.AttributeKeys;
import com.legendshop.core.UserManager;
import com.legendshop.core.constant.FunctionEnum;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.core.exception.ApplicationException;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.core.page.PagerUtil;
import com.legendshop.event.EventContext;
import com.legendshop.event.EventHome;
import com.legendshop.event.GenericEvent;
import com.legendshop.model.UserMessages;
import com.legendshop.model.entity.Advertisement;
import com.legendshop.model.entity.Myleague;
import com.legendshop.model.entity.News;
import com.legendshop.model.entity.Nsort;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductDetail;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.ShopDetailView;
import com.legendshop.model.entity.Sort;
import com.legendshop.model.entity.Sub;
import com.legendshop.model.entity.User;
import com.legendshop.model.entity.UserDetail;
import com.legendshop.model.entity.VisitLog;
import com.legendshop.search.LuceneIndexer;
import com.legendshop.search.SearchArgs;
import com.legendshop.search.SearchFacade;
import com.legendshop.search.SearchResult;
import com.legendshop.util.AppUtils;
import com.legendshop.util.BeanHelper;
import com.legendshop.util.MD5Util;
import com.legendshop.util.SafeHtml;
import com.legendshop.util.ip.IPSeeker;
import com.legendshop.util.sql.ConfigCode;
public class BusinessServiceImpl extends BaseServiceImpl
implements BusinessService {
private static Logger log = LoggerFactory
.getLogger(BusinessServiceImpl.class);
private final String defaultValue = "0";
private final Long defaultInt = Long.valueOf(0L);
private ShopDetailDao shopDetailDao;
private SortDao sortDao;
private PubDao pubDao;
private BusinessDao businessDao;
private LogoDao logoDao;
private AdvertisementDao advertisementDao;
private NewsDao newsDao;
private NsortDao nsortDao;
private ExternalLinkDao externalLinkDao;
private UserDetailDao userDetailDao;
private VisitLogDaoImpl visitLogDao;
private PayTypeService payTypeService;
private SearchFacade searchFacade;
private ProductDao productDao;
private ImgFileDao imgFileDao;
private BasketDao basketDao;
private ShopStatusChecker shopStatusChecker;
private SubDao subDao;
private HotsearchDao hotsearchDao;
public String getIndex(HttpServletRequest request,
HttpServletResponse response) {
String shopName = (String) request.getAttribute("shopName");
ShopDetailView shopDetail = getShopDetailView(shopName, request,
response);
if (shopDetail == null) {
String defaultShop = (String) PropertiesUtil.getObject(
ParameterEnum.DEFAULT_SHOP, String.class);
if (AppUtils.isNotBlank(defaultShop)) {
shopName = defaultShop;
shopDetail = getShopDetailView(shopName, request, response);
} else {
if (!PropertiesUtil.isSystemInstalled()) {
throw new BusinessException("system did not installed",
"00");
}
return PathResolver.getPath(request, FrontPage.ALL_PAGE);
}
} else {
shopName = shopDetail.getStoreName();
if (!this.shopStatusChecker.check(shopDetail, request)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
visit(shopDetail, request);
}
request.setAttribute("productList",
this.productDao.getCommendProd(shopName, 40));
request.setAttribute("newestList",
this.productDao.getNewestProd(shopName, 11));
request.setAttribute("adList",
this.externalLinkDao.getExternalLink(shopName));
request.setAttribute("logo", this.logoDao.getLogo(shopName));
request.setAttribute("sortList",
this.sortDao.getSort(shopName, Boolean.valueOf(true)));
request.setAttribute("pubList", this.pubDao.getPub(shopName));
request.setAttribute("newList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_NEWS, Integer.valueOf(6)));
request.setAttribute("newsTopList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_TOP, Integer.valueOf(8)));
request.setAttribute("newsSortList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_SORT, Integer.valueOf(8)));
setAdvertisement(shopName, request);
List indexJpgList = this.imgFileDao.getIndexJpeg(shopName);
if (!AppUtils.isBlank(indexJpgList)) {
request.setAttribute("MaxScreen",
Integer.valueOf(indexJpgList.size()));
JSONArray jsonArray = JSONArray.fromObject(indexJpgList);
request.setAttribute("indexJSON", jsonArray);
} else {
request.setAttribute("MaxScreen", Integer.valueOf(0));
}
String userName = UserManager.getUsername(request.getSession());
boolean shopExists = this.shopDetailDao.isShopExists(userName)
.booleanValue();
request.setAttribute("shopExists", Boolean.valueOf(shopExists));
request.setAttribute("canbeLeagueShop",
this.shopDetailDao.isBeLeagueShop(shopExists, userName, shopName));
if (((Boolean) PropertiesUtil.getObject(
ParameterEnum.VISIT_LOG_INDEX_ENABLE, Boolean.class))
.booleanValue()) {
VisitLog visitLog = new VisitLog();
visitLog.setDate(new Date());
visitLog.setIp(request.getRemoteAddr());
visitLog.setShopName(shopName);
visitLog.setUserName(userName);
visitLog.setPage(VisitTypeEnum.INDEX.value());
this.threadPoolExecutor.execute(new TaskThread(
new PersistVisitLogTask(visitLog, this.visitLogDao)));
} else {
log.info("[{}],{} visit index {}",
new Object[] {request.getRemoteAddr(), userName, shopName });
}
return PathResolver.getPath(request, FrontPage.INDEX_PAGE);
}
public ShopDetailView getShopDetailView(String shopName,
HttpServletRequest request, HttpServletResponse response) {
String currentShopName = getShopName(request, response);
if ((shopName == null) && (currentShopName == null)) {
log.debug("shopName and currentShopName can not both NULL");
return null;
}
boolean inShopDetail = true;
if (currentShopName != null) {
if ((shopName != null) && (!shopName.equals(currentShopName))) {
log.debug("从商城 currentShopName = {} 进入另外一个商城 shopName = {}",
currentShopName, shopName);
currentShopName = shopName;
request.getSession().setAttribute("shopName", currentShopName);
inShopDetail = false;
}
} else {
log.debug("第一次访问,currentShopName = {}, shopName = {}",
currentShopName, shopName);
currentShopName = shopName;
request.getSession().setAttribute("shopName", currentShopName);
inShopDetail = false;
}
ShopDetailView shopDetail = this.shopDetailDao
.getShopDetailView(currentShopName);
log.debug("getShopDetailView currentShopName = {}, shopDetail = {}",
currentShopName, shopDetail);
if (!inShopDetail) {
setLocalByShopDetail(shopDetail, request, response);
}
return shopDetail;
}
private void setAdvertisement(String shopName, HttpServletRequest request) {
Map<String, List<Advertisement>> advertisement = this.advertisementDao
.getAdvertisement(shopName);
if (!AppUtils.isBlank(advertisement))
for (String type : advertisement.keySet())
if ("COUPLET".equals(type)) {
List list = (List) advertisement.get(type);
if (AppUtils.isNotBlank(list))
request.setAttribute(type,
list.get(CommonServiceUtil.random(list.size())));
} else {
request.setAttribute(type, advertisement.get(type));
}
}
private void setAdvertisement(String shopName, String key,
HttpServletRequest request) {
List advertisement = this.advertisementDao.getAdvertisement(shopName,
key);
if (!AppUtils.isBlank(advertisement))
request.setAttribute(key, advertisement);
}
private void setOneAdvertisement(String shopName, String key,
HttpServletRequest request) {
List advertisement = this.advertisementDao.getOneAdvertisement(
shopName, key);
if (!AppUtils.isBlank(advertisement))
request.setAttribute(key, advertisement);
}
public void setLocalByShopDetail(ShopDetailView shopDetail,
HttpServletRequest request, HttpServletResponse response) {
log.debug("setLocalByShopDetail calling");
if (shopDetail == null) {
return;
}
String langStyle = shopDetail.getLangStyle();
if ((AppUtils.isBlank(langStyle))
|| ("userChoice".equals(langStyle))
|| (!"userChoice".equals(request.getSession().getServletContext()
.getAttribute("LANGUAGE_MODE")))) {
return;
}
String[] language = shopDetail.getLangStyle().split("_");
Locale locale = new Locale(language[0], language[1]);
log.debug("setLocal {}, By ShopDetail {}", locale,
shopDetail.getSitename());
this.localeResolver.setLocale(request, response, locale);
}
public String getTop(HttpServletRequest request,
HttpServletResponse response) {
String shopName = getShopName(request, response);
String userName = UserManager.getUsername(request.getSession());
ShopDetailView shopDetail = getShopDetailView(shopName, request,
response);
if (shopDetail == null) {
return PathResolver.getPath(request, FrontPage.TOPALL);
}
if (!this.shopStatusChecker.check(shopDetail, request)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
request.setAttribute("logo", this.logoDao.getLogo(shopName));
request.setAttribute("sortList",
this.sortDao.getSort(shopName, Boolean.valueOf(true)));
request.setAttribute("newsTopList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_TOP, Integer.valueOf(8)));
request.setAttribute("newsSortList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_SORT, Integer.valueOf(8)));
boolean shopExists = this.shopDetailDao.isShopExists(userName)
.booleanValue();
request.setAttribute("shopExists", Boolean.valueOf(shopExists));
request.setAttribute("canbeLeagueShop",
this.shopDetailDao.isBeLeagueShop(shopExists, userName, shopName));
return PathResolver.getPath(request, FrontPage.TOP);
}
public String getTopSort(HttpServletRequest request,
HttpServletResponse response) {
String shopName = getShopName(request, response);
request.setAttribute("sortList",
this.sortDao.getSort(shopName, Boolean.valueOf(true)));
return PathResolver.getPath(request, FrontPage.TOPSORT);
}
public String getTopnews(HttpServletRequest request,
HttpServletResponse response) {
String name = getShopName(request, response);
String topsortnews = request.getParameter("topsortnews");
if (topsortnews != null) {
request.setAttribute("newList", this.newsDao.getNews(name,
NewsCategoryStatusEnum.NEWS_NEWS, (Integer) PropertiesUtil
.getObject(ParameterEnum.FRONT_PAGE_SIZE, Integer.class)));
return PathResolver.getPath(request, FrontPage.TOPSORTNEWS);
}
request.setAttribute("newList", this.newsDao.getNews(name,
NewsCategoryStatusEnum.NEWS_NEWS, Integer.valueOf(6)));
return PathResolver.getPath(request, FrontPage.TOPNEWS);
}
public String search(HttpServletRequest request,
HttpServletResponse response, SearchForm searchForm) {
Sort sort = null;
List nsortList = null;
if (AppUtils.isBlank(searchForm.getKeyword())) {
log.error("search keyword can't be null!");
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
if ((!AppUtils.isBlank(searchForm.getSortId()))
&& (!this.defaultInt.equals(searchForm.getSortId()))) {
sort = this.sortDao.getSort(searchForm.getSortId());
if (sort != null) {
setShopName(request, response, sort.getUserName());
request.setAttribute("sort", sort);
request.setAttribute("CurrentSortId", sort.getSortId());
nsortList = this.nsortDao.getNsortBySortId(searchForm
.getSortId());
request.setAttribute("nsortList", nsortList);
}
}
try {
CriteriaQuery cq = new CriteriaQuery(Product.class,
searchForm.getCurPageNOTop());
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue() * 2);
cq.eq("userName", getShopName(request, response));
Criterion c = null;
if (!AppUtils.isBlank(searchForm.getKeyword())) {
String[] keywords = AppUtils.searchByKeyword(searchForm
.getKeyword());
for (String word : keywords) {
Criterion temp = Restrictions
.like("name", "%" + word + "%");
if (c == null)
c = temp;
else {
c = Restrictions.or(c, temp);
}
}
}
if ((!AppUtils.isBlank(searchForm.getSortId()))
&& (!this.defaultInt.equals(searchForm.getSortId()))) {
if (c == null)
c = Restrictions.eq("sortId", searchForm.getSortId());
else {
c = Restrictions.and(c,
Restrictions.eq("sortId", searchForm.getSortId()));
}
}
if (c != null) {
cq.add(c);
}
cq.addOrder("desc", "prodId");
cq.add();
PageSupport ps = this.productDao.getProdDetail(cq);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("prodDetailList", ps.getResultList());
request.setAttribute("searchForm", searchForm);
if (ps.hasMutilPage())
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
} catch (Exception e) {
log.error("getProdDetail", e);
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
return PathResolver.getPath(request, TilesPage.PRODUCTSORT);
}
public String searchall(HttpServletRequest request,
HttpServletResponse response, String keyword, Integer entityType) {
if (entityType == null) {
entityType = Integer.valueOf(0);
}
String priceStartValue = request.getParameter("priceStartValue");
String priceEndValue = request.getParameter("priceEndValue");
String curPageNOStr = request.getParameter("curPageNO");
if (AppUtils.isBlank(curPageNOStr)) {
curPageNOStr = "1";
}
log.debug("search by keyword {}", keyword);
if (AppUtils.isBlank(keyword)) {
return PathResolver.getPath(request, FrontPage.ALL);
}
int curPageNO = PagerUtil.getCurPageNO(curPageNOStr);
SearchArgs args = new SearchArgs();
args.setKeywords(keyword);
if (AppUtils.isNotBlank(priceStartValue)) {
try {
args.setPriceStart(Double.valueOf(priceStartValue));
request.setAttribute("priceStart", priceStartValue);
} catch (Exception e) {
log.error("error number of priceStart {}", priceStartValue);
}
}
if (AppUtils.isNotBlank(priceEndValue)) {
try {
args.setPriceEnd(Double.valueOf(priceEndValue));
request.setAttribute("priceEnd", priceEndValue);
} catch (Exception e) {
log.error("error number of priceEnd {}", priceEndValue);
}
}
args.setEntityType(entityType.intValue());
if (LuceneIndexer.SEARCH_ENTITY_SHOPDETAIL.equals(Integer.valueOf(args
.getEntityType()))) {
String provinceid = request.getParameter("provinceidValue");
if (AppUtils.isNotBlank(provinceid)) {
args.setProvinceid(provinceid);
request.setAttribute("provinceid", provinceid);
}
String cityid = request.getParameter("cityidValue");
if (AppUtils.isNotBlank(cityid)) {
args.setCityid(cityid);
request.setAttribute("cityid", cityid);
}
String areaid = request.getParameter("areaidValue");
if (AppUtils.isNotBlank(areaid)) {
args.setAreaid(areaid);
request.setAttribute("areaid", areaid);
}
}
args.startFetchingAtRecord((curPageNO - 1) * args.fetchCount());
SearchResult result = this.searchFacade.search(args);
request.setAttribute("keyword", keyword);
request.setAttribute("entityType",
Integer.valueOf(args.getEntityType()));
int allCounts = result.getNumberOfHits();
if (AppUtils.isNotBlank(result.getRecords())) {
int offset = PagerUtil.getOffset(allCounts, curPageNO,
args.fetchCount());
PageSupport ps = new PageSupport(result.getRecords(),
"javascript:pager", offset, curPageNO, allCounts,
args.fetchCount());
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("searchResult", ps.getResultList());
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
}
}
return PathResolver.getPath(request, TilesPage.SEARCHALL);
}
public String getSort(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Long sortId) {
if (AppUtils.isBlank(curPageNO)) {
curPageNO = "1";
}
if (sortId == null) {
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
Sort sort = this.sortDao.getSort(sortId);
if (sort == null) {
throw new NotFoundException("sort can not be null", "404");
}
setShopName(request, response, sort.getUserName());
setAdvertisement(sort.getUserName(), request);
List searchList = this.hotsearchDao.getSearch(sort.getUserName(),
sortId);
if (!AppUtils.isBlank(searchList)) {
request.setAttribute("searchList", searchList);
}
List nsortList = this.nsortDao.getNsortBySortId(sortId);
request.setAttribute("sort", sort);
request.setAttribute("nsortList", nsortList);
String userName = UserManager.getUsername(request.getSession());
log.info("[{}],{},{},sort", new Object[] {request.getRemoteAddr(),
userName == null ? ""
: userName, getSessionAttribute(request, "shopName") });
HqlQuery hql = new HqlQuery(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue(),
curPageNO);
String QueryNsortCount = ConfigCode.getInstance().getCode(
"biz.getSortProdCount");
String QueryNsort = ConfigCode.getInstance().getCode("biz.getSortProd");
hql.setAllCountString(QueryNsortCount);
hql.setQueryString(QueryNsort);
Date date = new Date();
hql.setParam(new Object[] {sortId, date, date });
PageSupport ps = this.productDao.getProdDetail(hql);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("prodDetailList", ps.getResultList());
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
}
return PathResolver.getPath(request, TilesPage.PRODUCTSORT);
}
public String getSecSort(HttpServletRequest request,
HttpServletResponse response, Long sortId, Long nsortId, Long subNsortId) {
String curPageNO = request.getParameter("curPageNO");
if (AppUtils.isBlank(curPageNO)) {
curPageNO = "1";
}
String userName = UserManager.getUsername(request);
log.info("{},{},{},{},{},nsort", new Object[] {request.getRemoteAddr(),
userName == null ? ""
: userName, getSessionAttribute(request, "shopName"),
sortId, nsortId });
Sort sort = this.sortDao.getSort(sortId);
if (sort != null) {
setShopName(request, response, sort.getUserName());
setAdvertisement(sort.getUserName(), request);
request.setAttribute("sort", sort);
}
Nsort nsort = this.nsortDao.getNsort(nsortId);
if ((nsort != null) && (!AppUtils.isBlank(nsort.getSubSort()))) {
request.setAttribute("hasSubSort", Boolean.valueOf(true));
}
if (subNsortId != null) {
Nsort subNsort = this.nsortDao.getNsort(subNsortId);
request.setAttribute("subNsort", subNsort);
if (subNsort != null) {
request
.setAttribute("CurrentSubNsortId", subNsort.getNsortId());
}
}
List nsortList = this.nsortDao.getNsortList(sortId);
request.setAttribute("nsort", nsort);
request.setAttribute("nsortList",
this.nsortDao.getOthorNsort(nsortList));
request.setAttribute("subNsortList",
this.nsortDao.getOthorSubNsort(nsortId, nsortList));
if (nsort != null) {
request.setAttribute("CurrentNsortId", nsort.getNsortId());
}
try {
CriteriaQuery cq = new CriteriaQuery(Product.class, curPageNO);
cq.setCurPage(curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue());
cq.addOrder("desc", "prodId");
cq.eq("sortId", sortId);
cq.eq("nsortId", nsortId);
cq.eq("subNsortId", subNsortId);
cq.add();
PageSupport ps = this.productDao.getProdDetail(cq);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("prodDetailList", ps.getResultList());
if (ps.hasMutilPage())
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
} catch (Exception e) {
log.error("getProdDetail", e);
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
return PathResolver.getPath(request, TilesPage.NSORT);
}
public String getViews(HttpServletRequest request,
HttpServletResponse response, Long prodId) {
if (prodId == null) {
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
ProductDetail prod = this.productDao.getProdDetail(prodId);
if (prod != null) {
if (!Constants.ONLINE.equals(prod.getStatus())) {
throw new NotFoundException("Product does not online.", "12");
}
List prodPics = this.imgFileDao.getProductPics(prod.getUserName(),
prodId);
if (AppUtils.isNotBlank(prodPics)) {
request.setAttribute("prodPics", prodPics);
}
ShopDetailView shopDetail = getShopDetailView(prod.getUserName(),
request, response);
if (shopDetail == null) {
return PathResolver.getPath(request, FrontPage.TOPALL);
}
if (!this.shopStatusChecker.check(shopDetail, request)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
List releationProds = this.productDao.getReleationProd(
prod.getUserName(), prod.getProdId(), 30);
if (!AppUtils.isBlank(releationProds)) {
request.setAttribute("productList", releationProds);
}
request.setAttribute("prod", prod);
setShopName(request, response, prod.getUserName());
setAdvertisement(prod.getUserName(), request);
if (((Boolean) PropertiesUtil.getObject(
ParameterEnum.VISIT_HW_LOG_ENABLE, Boolean.class))
.booleanValue()) {
this.productDao.updateProdViews(prodId);
}
String userName = UserManager.getUsername(request.getSession());
if (log.isInfoEnabled()) {
log.info(
"{},{},{},{},viewsprod",
new Object[] {request.getRemoteAddr(),
userName == null ? ""
: userName,
getSessionAttribute(request, "shopName"),
prod.getName() });
}
visit(prod, request);
if (((Boolean) PropertiesUtil.getObject(
ParameterEnum.VISIT_LOG_ENABLE, Boolean.class)).booleanValue()) {
VisitLog visitLog = new VisitLog();
visitLog.setDate(new Date());
visitLog.setIp(request.getRemoteAddr());
visitLog.setShopName(prod.getUserName());
visitLog.setProductName(prod.getName());
visitLog.setUserName(userName);
visitLog.setProductId(String.valueOf(prod.getProdId()));
visitLog.setPage(VisitTypeEnum.HW.value());
this.threadPoolExecutor.execute(new TaskThread(
new PersistVisitLogTask(visitLog, this.visitLogDao)));
}
return PathResolver.getPath(request, FrontPage.VIEWS);
}
UserMessages uem = new UserMessages();
Locale locale = this.localeResolver.resolveLocale(request);
uem.setTitle(ResourceBundleHelper
.getString(locale, "product.not.found"));
uem.setDesc(ResourceBundleHelper.getString(locale,
"product.status.check"));
uem.setCode("702");
request.setAttribute(UserMessages.MESSAGE_KEY, uem);
return PathResolver.getPath(request, FrontPage.FAIL);
}
public String getOrderDetail(HttpServletRequest request, Sub sub,
String userName, String subNumber) {
List subList = new ArrayList();
MemberForm form = new MemberForm();
form.setUserAdds(sub.getSubAdds());
form.setUserPostcode(sub.getSubPost());
form.setOrderName(sub.getUserName());
form.setOther(sub.getOther());
form.setUserTel(sub.getSubTel());
form.setPayTypeName(sub.getPayTypeName());
request.setAttribute("member", form);
List baskets = this.subDao.getBasketBySubNumber(subNumber);
if (!AppUtils.isBlank(baskets)) {
sub.setBasket(baskets);
sub.setPayType(this.payTypeService.getPayTypeList(sub.getShopName()));
subList.add(sub);
request.setAttribute("baskets", baskets);
request.setAttribute("subList", subList);
}
if (OrderStatusEnum.UNPAY.value().equals(sub.getStatus())) {
UserDetail userdetail = this.userDetailDao.getUserDetail(userName);
if (userdetail != null) {
if (userdetail.getScore() == null) {
userdetail.setScore(Long.valueOf(0L));
}
request.setAttribute("availableScore", userdetail.getScore());
}
} else {
request.setAttribute("availableScore", Long.valueOf(0L));
}
return PathResolver.getPath(request, TilesPage.PAGE_SUB);
}
public String getNews(HttpServletRequest request,
HttpServletResponse response, Long newsId) {
if (newsId != null) {
News news = this.newsDao.getNewsById(newsId);
if (news != null) {
setShopName(request, response, news.getUserName());
setAdvertisement(news.getUserName(), request);
request.setAttribute("news", news);
}
}
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_740",
request);
return PathResolver.getPath(request, TilesPage.NEWS);
}
public String getAllNews(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
Long newsCategoryId = null;
if (AppUtils.isNotBlank(newsCategory)) {
newsCategoryId = Long.valueOf(Long.parseLong(newsCategory));
}
if (AppUtils.isBlank(curPageNO)) {
curPageNO = "1";
}
String name = getShopName(request, response);
CriteriaQuery cq = new CriteriaQuery(News.class, curPageNO);
cq.setCurPage(curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue());
cq.eq("status", Constants.ONLINE);
cq.eq("userName", name);
cq.eq("newsCategory.newsCategoryId", newsCategoryId);
cq.addOrder("desc", "newsDate");
cq.add();
PageSupport ps = this.newsDao.getNews(cq);
List list = ps.getResultList();
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("newsCategoryId", newsCategoryId);
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_740",
request);
if (!AppUtils.isBlank(list)) {
request.setAttribute("newsList", list);
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
}
}
return PathResolver.getPath(request, TilesPage.ALL_NEWS);
}
private Sub makeSub(MemberForm form) {
Sub sub = new Sub();
sub.setUserName(form.getUserName());
sub.setSubDate(new Date());
sub.setSubTel(form.getUserTel());
sub.setSubPost(form.getUserPostcode());
sub.setSubMail(form.getUserMail());
sub.setSubAdds(form.getUserAdds());
sub.setPayId(form.getPayType());
sub.setOther(form.getOther());
sub.setSubCheck("N");
sub.setOrderName(form.getOrderName());
return sub;
}
public String getHotSale(HttpServletRequest request,
HttpServletResponse response) {
String name = getShopName(request, response);
List hotsaleList = this.productDao.gethotsale(name);
if (!AppUtils.isBlank(hotsaleList)) {
request.setAttribute("hotsaleList", hotsaleList);
}
return PathResolver.getPath(request, FrontPage.HOTSALE);
}
public String getFriendlink(HttpServletRequest request,
HttpServletResponse response) {
String name = getShopName(request, response);
List adList = this.externalLinkDao.getExternalLink(name);
if (!AppUtils.isBlank(adList)) {
request.setAttribute("adList", adList);
}
return PathResolver.getPath(request, FrontPage.FRIENDLINK);
}
public String getHotProduct(HttpServletRequest request,
HttpServletResponse response) {
String sortId = request.getParameter("sortId");
List hotonList = this.productDao.getHotOn(sortId);
if (AppUtils.isNotBlank(hotonList)) {
request.setAttribute("hotonList", hotonList);
}
return PathResolver.getPath(request, FrontPage.HOTON);
}
public String getHotView(HttpServletRequest request,
HttpServletResponse response) {
String shopName = getShopName(request, response);
List hotViewList = this.productDao.getHotViewProd(shopName,
Integer.valueOf(10));
if (AppUtils.isNotBlank(hotViewList)) {
request.setAttribute("hotViewList", hotViewList);
}
return PathResolver.getPath(request, FrontPage.HOTVIEW);
}
public String saveUserReg(HttpServletRequest request,
HttpServletResponse response, UserForm form) {
SafeHtml safeHtml = new SafeHtml();
form.setUserName(safeHtml.makeSafe(form.getUserName()));
form.setUserMemo(safeHtml.makeSafe(form.getUserMemo()));
form.setUserMobile(safeHtml.makeSafe(form.getUserMobile()));
form.setUserPostcode(safeHtml.makeSafe(form.getUserPostcode()));
form.setUserTel(safeHtml.makeSafe(form.getUserTel()));
form.setUserMail(safeHtml.makeSafe(form.getUserMail()));
form.setUserAdds(safeHtml.makeSafe(form.getUserAdds()));
form.setMsn(safeHtml.makeSafe(form.getMsn()));
form.setNote(safeHtml.makeSafe(form.getNote()));
form.setQq(safeHtml.makeSafe(form.getQq()));
form.setName(safeHtml.makeSafe(form.getName()));
form.setNickName(safeHtml.makeSafe(form.getNickName()));
ShopDetail shopDetail = form.getShopDetail();
if (shopDetail != null) {
shopDetail.setRealPath(RealPathUtil.getBigPicRealPath());
shopDetail.setIp(request.getRemoteAddr());
shopDetail.setSitename(safeHtml.makeSafe(shopDetail.getSitename()));
shopDetail.setYmaddr(safeHtml.makeSafe(shopDetail.getYmaddr()));
shopDetail
.setIdCardNum(safeHtml.makeSafe(shopDetail.getIdCardNum()));
}
if (isUserInfoValid(form, request)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
User user = new User();
UserDetail userDetail = new UserDetail();
BeanHelper.copyProperties(user, form, true);
BeanHelper.copyProperties(userDetail, form, true);
Date date = new Date();
String plaintPassword = user.getPassword();
user.setPassword(MD5Util.Md5Password(user.getName(), plaintPassword));
userDetail.setUserRegtime(date);
userDetail.setModifyTime(date);
userDetail.setUserRegip(request.getRemoteAddr());
userDetail.setTotalCash(Double.valueOf(0.0D));
userDetail.setTotalConsume(Double.valueOf(0.0D));
boolean isOpenShop = request.getParameter("openShop") != null;
this.userDetailDao.saveUser(user, userDetail, shopDetail, isOpenShop);
UserMessages uem = new UserMessages();
Locale locale = this.localeResolver.resolveLocale(request);
uem.setTitle(ResourceBundleHelper.getString(locale, "regFree") + " "
+ form.getName() + " "
+ ResourceBundleHelper.getString(locale, "success.hint"));
if (userDetail.getRegisterCode() == null)
uem.setDesc(ResourceBundleHelper.getString(locale,
"after.reg.success"));
else {
uem.setDesc(ResourceBundleHelper.getString(locale,
"reg.success.acknowledgement"));
}
uem.addCallBackList(ResourceBundleHelper.getString(locale, "login"),
ResourceBundleHelper.getString(locale, "logon.hint.desc"), "login"
+ AttributeKeys.WEB_SUFFIX);
request.setAttribute(UserMessages.MESSAGE_KEY, uem);
this.userDetailDao.flush();
if (sendMail()) {
try {
String filePath = request.getSession().getServletContext()
.getRealPath("/")
+ "/system/mailTemplate/registersuccess.jsp";
Map values = new HashMap();
values.put("#nickName#", userDetail.getNickName());
values.put("#userName#", userDetail.getUserName());
values.put("#password#", userDetail.getPassword());
if (AppUtils.isNotBlank(userDetail.getRegisterCode())) {
StringBuffer buffer = new StringBuffer();
buffer
.append("<p>你的帐号尚未开通,<a href=\"")
.append("http://www.legendesign.net")
.append(
"/userRegSuccess" + Constants.WEB_SUFFIX
+ "?userName=").append(user.getName())
.append("®isterCode=")
.append(userDetail.getRegisterCode())
.append("\">点击开通我的帐号</a></p><br>");
values.put("#registerCode#", buffer.toString());
} else {
StringBuffer buffer = new StringBuffer();
buffer.append("<p>你的帐号已经开通成功!</p><br>");
values.put("#registerCode#", buffer.toString());
}
String text = AppUtils.convertTemplate(filePath, values);
this.threadPoolExecutor.execute(new TaskThread(
new SendMailTask(this.javaMailSender, userDetail
.getUserMail(), "恭喜您,注册商城成功", text)));
log.info("{} 注册成功,发送通知邮件", userDetail.getUserMail());
} catch (Exception e) {
log.info("{},发送通知邮件失败,请检查邮件配置", userDetail.getUserMail());
throw new ApplicationException(e, "发送通知邮件失败,请检查邮件配置", "12");
}
}
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
public String saveUserReg(HttpServletRequest request,
HttpServletResponse response) {
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_950",
request);
EventContext eventContext = new EventContext(request);
EventHome.publishEvent(new GenericEvent(eventContext,
EventId.CAN_ADD_SHOPDETAIL_EVENT));
request.setAttribute("supportOpenShop",
eventContext.getBooleanResponse());
request.setAttribute("validationOnOpenShop", PropertiesUtil.getObject(
ParameterEnum.VALIDATION_ON_OPEN_SHOP, Boolean.class));
return PathResolver.getPath(request, TilesPage.REG);
}
public boolean isUserInfoValid(UserForm form, HttpServletRequest request) {
boolean result = false;
UserMessages messages = new UserMessages();
Locale locale = this.localeResolver.resolveLocale(request);
if (AppUtils.isBlank(form.getName())) {
messages.addCallBackList(ResourceBundleHelper.getString(locale,
"username.required"));
result = true;
}
if (!result) {
if (form.getName().length() < 4) {
messages.addCallBackList(ResourceBundleHelper.getString(locale,
"username.minlength"));
result = true;
}
if (this.userDetailDao.isUserExist(form.getName())) {
messages.addCallBackList(ResourceBundleHelper.getString(locale,
"error.User.IsExist"));
}
if (AppUtils.isBlank(form.getUserMail())) {
messages.addCallBackList(ResourceBundleHelper.getString(locale,
"user.email.required"));
} else if (this.userDetailDao.isEmailExist(form.getUserMail())) {
messages.addCallBackList("Email <b>"
+ form.getUserMail()
+ "</b> "
+ ResourceBundleHelper.getString(locale,
"user.email.exists"));
}
}
result = messages.hasError();
if (result) {
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
request.setAttribute("userForm", form);
}
return result;
}
public String saveShop(HttpServletRequest request,
HttpServletResponse response, ShopDetail shopDetail) {
Locale locale = this.localeResolver.resolveLocale(request);
try {
if (shopDetail != null) {
shopDetail.setRealPath(RealPathUtil.getBigPicRealPath());
}
UserDetail userDetail = new UserDetail();
userDetail.setUserId(UserManager.getUserId(request.getSession()));
userDetail
.setUserName(UserManager.getUsername(request.getSession()));
Integer status = this.userDetailDao.saveShopDetailAndRole(
userDetail, shopDetail);
String openResultDesc = null;
if (ShopStatusEnum.AUDITING.value().equals(status))
openResultDesc = ResourceBundleHelper.getString(locale,
"apply.shop.auditing");
else {
openResultDesc = ResourceBundleHelper.getString(locale,
"apply.shop.success.relogin");
}
UserMessages messages = new UserMessages("200",
ResourceBundleHelper.getString(locale, "apply.shop.success"),
openResultDesc);
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
} catch (Exception e) {
log.error("addShop ", e);
UserMessages messages = new UserMessages("601",
ResourceBundleHelper.getString(locale, "apply.shop.failed"),
ResourceBundleHelper.getString(locale, "check.parameter"));
messages.addCallBackList(
ResourceBundleHelper.getString(locale, "try.again"), null,
"openShop.do");
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
}
return PathResolver.getPath(request, FrontPage.ERROR_PAGE);
}
public String getMyAccount(HttpServletRequest request,
HttpServletResponse response) {
String userName = UserManager.getUsername(request);
if (userName == null) {
return PathResolver.getPath(request, TilesPage.LOGIN);
}
String viewName = request.getParameter("userName");
if ((AppUtils.isNotBlank(viewName))
&& (UserManager.hasFunction(request.getSession(),
FunctionEnum.FUNCTION_SECUREST.value()))) {
userName = viewName;
request.setAttribute("isAdmin", Boolean.valueOf(true));
}
UserDetail userDetail = this.userDetailDao.getUserDetail(userName);
if (userDetail == null) {
log.error("userDetail not found, userName = " + userName);
throw new NotFoundException("userDetail not found", "11");
}
ShopDetail shopDetail = userDetail.getShopDetail();
if (shopDetail != null) {
request.setAttribute("myShopDetail", shopDetail);
}
if (userDetail.getBirthDate() != null) {
setBirthDate(userDetail.getBirthDate(), request);
}
if (userDetail.getScore() == null) {
userDetail.setScore(Long.valueOf(0L));
}
request.setAttribute("user", userDetail);
EventContext eventContext = new EventContext(request);
EventHome.publishEvent(new GenericEvent(eventContext,
EventId.CAN_ADD_SHOPDETAIL_EVENT));
request.setAttribute("supportOpenShop",
eventContext.getBooleanResponse());
request.setAttribute("totalProcessingOrder",
this.businessDao.getTotalProcessingOrder(userName));
request.setAttribute("totalBasketByuserName",
this.basketDao.getTotalBasketByuserName(userName));
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_740",
request);
return PathResolver.getPath(request, TilesPage.MYACCOUNT);
}
private void setBirthDate(String birthDate, HttpServletRequest request) {
try {
String year = birthDate.substring(0, 4);
String month = birthDate.substring(4, 6);
String day = birthDate.substring(6, 8);
request.setAttribute("userBirthYear", year);
request.setAttribute("userBirthMonth", month);
request.setAttribute("userBirthDay", day);
} catch (Exception e) {
}
}
public ShopDetailView getSimpleInfoShopDetail(String storeName) {
return this.shopDetailDao.getSimpleInfoShopDetail(storeName);
}
public String updateAccount(HttpServletRequest request,
HttpServletResponse response, UserForm form) {
ShopDetail shopDetail = form.getShopDetail();
String userName = UserManager.getUsername(request);
if ((CommonServiceUtil.haveViewAllDataFunction(request))
&& (AppUtils.isNotBlank(form.getUserName()))) {
userName = form.getUserName();
}
User user = this.userDetailDao.getUserByName(userName);
Locale locale = this.localeResolver.resolveLocale(request);
if (user == null) {
UserMessages messages = new UserMessages(
"601",
ResourceBundleHelper.getString(locale, "update.myaccount.fail"),
ResourceBundleHelper.getString(locale, "check.parameter"));
messages.addCallBackList(
ResourceBundleHelper.getString(locale, "reupdate.myaccount"),
null, "updateAccount.do");
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
UserDetail userDetail = this.userDetailDao.getUserDetail(userName);
if ((!AppUtils.isBlank(form.getPassword()))
&& (!user.getPassword().equals(
MD5Util.Md5Password(userName, form.getPasswordOld())))) {
log.warn("old password does not match!");
UserMessages messages = new UserMessages("601",
ResourceBundleHelper.getString(locale, "error.old.password"),
ResourceBundleHelper.getString(locale, "check.parameter"));
messages
.addCallBackList(ResourceBundleHelper.getString(locale,
"reupdate.myaccount"), ResourceBundleHelper.getString(
locale, "notmatch.old.password"), "myaccount.do");
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
boolean update = true;
if (userDetail == null) {
update = false;
userDetail = new UserDetail();
}
Date date = new Date();
SafeHtml safeHtml = new SafeHtml();
userDetail.setNickName(safeHtml.makeSafe(form.getNickName()));
userDetail.setSex(safeHtml.makeSafe(form.getSex()));
userDetail.setBirthDate(form.getBirthDate());
if (UserManager.hasFunction(request, new String[] {
FunctionEnum.FUNCTION_VIEW_ALL_DATA.value(),
FunctionEnum.FUNCTION_F_OPERATOR.value() })) {
userDetail.setUserMail(form.getUserMail());
}
userDetail.setUserAdds(safeHtml.makeSafe(form.getUserAdds()));
userDetail.setUserTel(safeHtml.makeSafe(form.getUserTel()));
userDetail.setUserPostcode(safeHtml.makeSafe(form.getUserPostcode()));
userDetail.setPassword(form.getPassword());
userDetail.setFax(safeHtml.makeSafe(form.getFax()));
userDetail.setModifyTime(date);
userDetail.setUserId(user.getId());
userDetail.setUserMobile(safeHtml.makeSafe(form.getUserMobile()));
userDetail.setMsn(safeHtml.makeSafe(form.getMsn()));
userDetail.setQq(safeHtml.makeSafe(form.getQq()));
String year = form.getUserBirthYear();
String month = form.getUserBirthMonth();
String day = form.getUserBirthDay();
if ((year != null) && (form.getUserBirthMonth() != null)
&& (form.getUserBirthDay() != null)) {
if (month.length() < 2) {
month = "0" + month;
}
if (day.length() < 2) {
day = "0" + day;
}
userDetail.setBirthDate(year + month + day);
}
boolean openshop = request.getParameter("openShop") != null;
if (update) {
this.userDetailDao.updateUser(userDetail);
this.userDetailDao.updateShopDetail(userDetail, shopDetail,
openshop);
} else {
userDetail.setUserRegip(request.getRemoteAddr());
userDetail.setUserRegtime(date);
userDetail.setUserId(user.getId());
userDetail.setUserName(userName);
this.userDetailDao.saveUerDetail(userDetail, shopDetail, openshop);
this.userDetailDao.updatePassword(userDetail);
}
UserMessages messages = new UserMessages("200", "", "");
messages.addCallBackList(
ResourceBundleHelper.getString(locale, "myaccount"),
ResourceBundleHelper.getString(locale, "reupdate.myaccount"),
"myaccount" + Constants.WEB_SUFFIX);
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
public String getIpAddress(HttpServletRequest request,
HttpServletResponse response, String ipAddress) {
String address = null;
if (AppUtils.isNotBlank(ipAddress)) {
address = IPSeeker.getInstance().getAddress(ipAddress);
log.debug("{} search {} ", request.getRemoteAddr(), address);
}
request.setAttribute("ipAddress", ipAddress);
request.setAttribute("address", address);
return PathResolver.getPath(request, FrontPage.IPSEARCH);
}
public String getLeague(HttpServletRequest request,
HttpServletResponse response) {
String shopName = (String) getSessionAttribute(request, "shopName");
if (shopName == null) {
shopName = (String) PropertiesUtil.getObject(
ParameterEnum.DEFAULT_SHOP, String.class);
setShopName(request, response, shopName);
}
String curPageNO = request.getParameter("curPageNO");
SqlQuery sqlQuery = new SqlQuery(15, curPageNO);
String queryAllSQL = ConfigCode.getInstance().getCode(
"biz.QueryLeagueCount");
String querySQL = ConfigCode.getInstance().getCode("biz.QueryLeague");
sqlQuery.setAllCountString(queryAllSQL);
sqlQuery.setQueryString(querySQL);
sqlQuery.addParams(shopName);
sqlQuery.addEntityClass("myleague", Myleague.class);
PageSupport ps = this.businessDao.find(sqlQuery);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("leagues", ps.getResultList());
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar(
this.localeResolver.resolveLocale(request),
"SimplePageProvider"));
}
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_740",
request);
return PathResolver.getPath(request, TilesPage.LEAGUE);
}
@Required
public void setShopDetailDao(ShopDetailDao shopDetailDao) {
this.shopDetailDao = shopDetailDao;
}
@Required
public void setSortDao(SortDao sortDao) {
this.sortDao = sortDao;
}
@Required
public void setPubDao(PubDao pubDao) {
this.pubDao = pubDao;
}
@Required
public void setBusinessDao(BusinessDao businessDao) {
this.businessDao = businessDao;
}
@Required
public void setLogoDao(LogoDao logoDao) {
this.logoDao = logoDao;
}
@Required
public void setAdvertisementDao(AdvertisementDao advertisementDao) {
this.advertisementDao = advertisementDao;
}
@Required
public void setNewsDao(NewsDao newsDao) {
this.newsDao = newsDao;
}
@Required
public void setNsortDao(NsortDao nsortDao) {
this.nsortDao = nsortDao;
}
@Required
public void setExternalLinkDao(ExternalLinkDao externalLinkDao) {
this.externalLinkDao = externalLinkDao;
}
@Required
public void setUserDetailDao(UserDetailDao userDetailDao) {
this.userDetailDao = userDetailDao;
}
@Required
public void setVisitLogDao(VisitLogDaoImpl visitLogDao) {
this.visitLogDao = visitLogDao;
}
public String getShopcontact(HttpServletRequest request,
HttpServletResponse response) {
String shopName = request.getParameter("shop");
if (shopName == null) {
shopName = getShopName(request, response);
}
if (shopName == null) {
return PathResolver.getPath(request, TilesPage.SEARCHALL);
}
UserDetail userDetail = this.userDetailDao.getUserDetail(shopName);
request.setAttribute("user", userDetail);
return PathResolver.getPath(request, TilesPage.SHOPCONTACT);
}
@Required
public void setPayTypeService(PayTypeService payTypeService) {
this.payTypeService = payTypeService;
}
public String updateUserReg(HttpServletRequest request,
HttpServletResponse response, String userName, String registerCode) {
RegisterEnum result = this.userDetailDao.getUserRegStatus(userName,
registerCode);
if (!RegisterEnum.REGISTER_SUCCESS.equals(result)) {
throw new BusinessException(ResourceBundleHelper.getString(result
.value()), "11");
}
Locale locale = this.localeResolver.resolveLocale(request);
UserMessages messages = new UserMessages("200",
ResourceBundleHelper.getString(locale, "reg.success.actived"), "");
messages.addCallBackList(
ResourceBundleHelper.getString(locale, "login"),
ResourceBundleHelper.getString(locale, "logon.hint.desc"), "login"
+ Constants.WEB_SUFFIX);
request.setAttribute(UserMessages.MESSAGE_KEY, messages);
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
@Required
public void setShopStatusChecker(ShopStatusChecker shopStatusChecker) {
this.shopStatusChecker = shopStatusChecker;
}
@Required
public void setSearchFacade(SearchFacade searchFacade) {
this.searchFacade = searchFacade;
}
public String getNewsforCommon(HttpServletRequest request,
HttpServletResponse response) {
String shopName = PropertiesUtil.getDefaultShopName();
if (AppUtils.isBlank(shopName)) {
shopName = "common";
}
request.setAttribute("newsBottomList", this.newsDao.getNews(shopName,
NewsCategoryStatusEnum.NEWS_BOTTOM, Integer.valueOf(8)));
return PathResolver.getPath(request, FrontPage.COPY_ALL);
}
public String getProductGallery(HttpServletRequest request,
HttpServletResponse response, Long prodId) {
ProductDetail prod = this.productDao.getProdDetail(prodId);
if (prod != null) {
if (!Constants.ONLINE.equals(prod.getStatus())) {
throw new NotFoundException("Product does not online.", "12");
}
request.setAttribute("prod", prod);
List prodPics = this.imgFileDao.getProductPics(prod.getUserName(),
prodId);
if (AppUtils.isNotBlank(prodPics)) {
request.setAttribute("prodPics", prodPics);
}
return PathResolver.getPath(request, FrontPage.PROD_PIC_GALLERY);
}
UserMessages uem = new UserMessages();
Locale locale = this.localeResolver.resolveLocale(request);
uem.setTitle(ResourceBundleHelper
.getString(locale, "product.not.found"));
uem.setDesc(ResourceBundleHelper.getString(locale,
"product.status.check"));
uem.setCode("702");
request.setAttribute(UserMessages.MESSAGE_KEY, uem);
return PathResolver.getPath(request, FrontPage.FAIL);
}
public Sub getSubBySubNumber(String subNumber) {
return this.subDao.getSubBySubNumber(subNumber);
}
@Required
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
@Required
public void setImgFileDao(ImgFileDao imgFileDao) {
this.imgFileDao = imgFileDao;
}
@Required
public void setBasketDao(BasketDao basketDao) {
this.basketDao = basketDao;
}
@Required
public void setSubDao(SubDao subDao) {
this.subDao = subDao;
}
@Required
public void setHotsearchDao(HotsearchDao hotsearchDao) {
this.hotsearchDao = hotsearchDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.CashDao;
import com.legendshop.business.service.CashService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Cash;
import com.legendshop.util.AppUtils;
import java.util.List;
public class CashServiceImpl implements CashService {
private CashDao cashDao;
public void setCashDao(CashDao cashDao) {
this.cashDao = cashDao;
}
public List<Cash> getCash(String userName) {
return this.cashDao.getCash(userName);
}
public Cash getCash(Long id) {
return this.cashDao.getCash(id);
}
public void deleteCash(Cash cash) {
this.cashDao.deleteCash(cash);
}
public Long saveCash(Cash cash) {
if (!AppUtils.isBlank(cash.getCashId())) {
updateCash(cash);
return cash.getCashId();
}
return (Long) this.cashDao.save(cash);
}
public void updateCash(Cash cash) {
this.cashDao.updateCash(cash);
}
public PageSupport getCash(CriteriaQuery cq) {
return this.cashDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ProductDao;
import com.legendshop.business.dao.ShopDetailDao;
import com.legendshop.business.search.facade.ProductSearchFacade;
import com.legendshop.business.service.ProductService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Product;
import org.springframework.beans.factory.annotation.Required;
public class ProductServiceImpl implements ProductService {
private ProductDao productDao;
private ShopDetailDao shopDetailDao;
private ProductSearchFacade productSearchFacade;
@Required
public void setProductSearchFacade(ProductSearchFacade productSearchFacade) {
this.productSearchFacade = productSearchFacade;
}
@Required
public void setShopDetailDao(ShopDetailDao shopDetailDao) {
this.shopDetailDao = shopDetailDao;
}
public PageSupport getProductList(HqlQuery hql) {
return this.productDao.find(hql);
}
public PageSupport getProductList(CriteriaQuery cq) {
return this.productDao.find(cq);
}
@Required
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
public Product getProductById(Long prodId) {
if (prodId == null) {
return null;
}
return this.productDao.getProduct(prodId);
}
public void updateProduct(Product product) {
this.productDao.updateProduct(product);
this.shopDetailDao.updateShopDetailWhenProductChange(product);
this.productSearchFacade.update(product);
}
public Long saveProduct(Product product) {
Long prodId = this.productDao.saveProduct(product);
product.setProdId(prodId);
this.shopDetailDao.updateShopDetailWhenProductChange(product);
this.productSearchFacade.create(product);
return prodId;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.core.StartupService;
import com.legendshop.core.plugins.Plugin;
import com.legendshop.core.plugins.PluginConfig;
import com.legendshop.util.AppUtils;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
public class StartupServiceImpl implements StartupService {
private static Logger log = LoggerFactory
.getLogger(StartupServiceImpl.class);
private boolean isInited = false;
public synchronized void startup(ServletContext servletContext) {
if (!this.isInited) {
Map beans = ContextLoader.getCurrentWebApplicationContext()
.getBeansOfType(Plugin.class);
if (AppUtils.isNotBlank(beans)) {
// TODO 临时改动
for (Object object : beans.values()) {
Plugin plugin = (Plugin)object;
log.info("start to init plugins {}, version {}", plugin
.getPluginConfig().getPulginId(), plugin
.getPluginConfig().getPulginVersion());
plugin.bind(servletContext);
}
}
this.isInited = true;
}
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.common.CommentTypeEnum;
import com.legendshop.business.dao.UserCommentDao;
import com.legendshop.business.service.UserCommentService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.UserComment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class UserCommentServiceImpl implements UserCommentService {
Logger log = LoggerFactory
.getLogger(UserCommentServiceImpl.class);
private UserCommentDao userCommentDao;
@Required
public void setUserCommentDao(UserCommentDao userCommentDao) {
this.userCommentDao = userCommentDao;
}
public PageSupport getUserCommentList(CriteriaQuery cq) {
return this.userCommentDao.getUserCommentByCriteria(cq);
}
public UserComment getUserComment(Long id) {
return this.userCommentDao.getUserComment(id);
}
public void delete(UserComment userComment) {
this.userCommentDao.deleteUserComment(userComment);
}
public void updateUserCommentToReaded(UserComment comment) {
if (!comment.getStatus().equals(CommentTypeEnum.COMMENT_READED.value())) {
comment.setStatus(CommentTypeEnum.COMMENT_READED.value());
this.userCommentDao.updateUserComment(comment);
}
}
public void saveOrUpdateUserComment(UserComment comment) {
this.userCommentDao.saveOrUpdateUserComment(comment);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.NewsDao;
import com.legendshop.business.service.NewsService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.model.entity.News;
import com.legendshop.model.entity.NewsCategory;
import com.legendshop.model.entity.Sort;
import com.legendshop.util.AppUtils;
import java.util.Date;
import java.util.List;
public class NewsServiceImpl implements NewsService {
private NewsDao newsDao;
public void setNewsDao(NewsDao newsDao) {
this.newsDao = newsDao;
}
public List<News> getNewsList(String userName) {
return (List<News>) this.newsDao.findByHQL(
"from News where userName = ?", new Object[] {userName });
}
public News getNewsById(Long id) {
News news = (News) this.newsDao.get(News.class, id);
if (news.getSort() != null)
news.setSortId(news.getSort().getSortId());
if (news.getNewsCategory() != null)
news.setNewsCategoryId(news.getNewsCategory().getNewsCategoryId());
return news;
}
public News getNewsByIdAndName(Long id, String userName) {
News news = (News) this.newsDao.findUniqueBy(
"from News where newsId = ? and userName = ?", News.class,
new Object[] {id, userName });
if (news == null) {
throw new BusinessException("no News record", "13");
}
return news;
}
public void delete(Long id) {
this.newsDao.deleteById(News.class, id);
}
public Long save(News news) {
if (!AppUtils.isBlank(news.getNewsId())) {
News entity = (News) this.newsDao.get(News.class, news.getNewsId());
if (entity != null) {
news.setUserId(entity.getUserId());
news.setUserName(entity.getUserName());
update(news);
return news.getNewsId();
}
return null;
}
preUpdateNews(news);
return (Long) this.newsDao.save(news);
}
private void preUpdateNews(News news) {
if (news.getNewsCategoryId() != null) {
NewsCategory nc = new NewsCategory();
nc.setNewsCategoryId(news.getNewsCategoryId());
news.setNewsCategory(nc);
}
if (news.getSortId() != null) {
Sort sort = new Sort();
sort.setSortId(news.getSortId());
news.setSort(sort);
}
}
public void update(News news) {
preUpdateNews(news);
news.setNewsDate(new Date());
this.newsDao.update(news);
}
public PageSupport getNewsList(CriteriaQuery cq) {
return this.newsDao.find(cq);
}
public PageSupport getNewsList(HqlQuery hql) {
return this.newsDao.find(hql);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.service.BaseService;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.ProductDetail;
import com.legendshop.model.entity.ShopDetailView;
import com.legendshop.model.visit.VisitHistory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.servlet.LocaleResolver;
public abstract class BaseServiceImpl implements BaseService {
private static Logger log = LoggerFactory
.getLogger(BaseServiceImpl.class);
protected JavaMailSenderImpl javaMailSender;
protected ThreadPoolTaskExecutor threadPoolExecutor;
protected LocaleResolver localeResolver;
public Object getSessionAttribute(HttpServletRequest request, String name) {
Object obj = null;
HttpSession session = request.getSession(false);
if (session != null) {
obj = session.getAttribute(name);
}
return obj;
}
public String getShopName(HttpServletRequest request,
HttpServletResponse response) {
return (String) getSessionAttribute(request, "shopName");
}
public void setSessionAttribute(HttpServletRequest request, String name,
Object obj) {
HttpSession session = request.getSession(false);
if (session != null)
session.setAttribute(name, obj);
}
public void setShopName(HttpServletRequest request,
HttpServletResponse response, String shopName) {
String name = getShopName(request, response);
if ((name == null) || (!name.equals(shopName)))
setSessionAttribute(request, "shopName", shopName);
}
public Long convertStringToInteger(String id) {
try {
Long result = Long.valueOf(id);
if (result.longValue() == 0L) {
return null;
}
return result;
} catch (Exception e) {
log.error("can not convert id " + id);
}
return null;
}
protected void visit(ProductDetail prod, HttpServletRequest request) {
VisitHistory visitHistory = (VisitHistory) request.getSession()
.getAttribute("VisitHistory");
if (visitHistory == null) {
visitHistory = new VisitHistory();
}
visitHistory.visit(prod);
request.getSession().setAttribute("VisitHistory", visitHistory);
}
public void visit(ShopDetailView shopDetail, HttpServletRequest request) {
VisitHistory visitHistory = (VisitHistory) request.getSession()
.getAttribute("VisitHistory");
if (visitHistory == null) {
visitHistory = new VisitHistory();
}
visitHistory.visit(shopDetail);
request.getSession().setAttribute("VisitHistory", visitHistory);
}
@Required
public void setJavaMailSender(JavaMailSenderImpl javaMailSender) {
this.javaMailSender = javaMailSender;
}
protected boolean sendMail() {
return ((Boolean) PropertiesUtil.getObject(ParameterEnum.SEND_MAIL,
Boolean.class)).booleanValue();
}
@Required
public void setThreadPoolExecutor(ThreadPoolTaskExecutor threadPoolExecutor) {
this.threadPoolExecutor = threadPoolExecutor;
}
@Required
public void setLocaleResolver(LocaleResolver localeResolver) {
this.localeResolver = localeResolver;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.LogoDao;
import com.legendshop.business.service.LogoService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.model.entity.Logo;
import java.util.List;
public class LogoServiceImpl implements LogoService {
private LogoDao logoDao;
public List<Logo> getLogoList(String userName) {
return (List<Logo>) this.logoDao.findByHQL(
"from Logo where userName = ?", new Object[] {userName });
}
public Logo getLogoById(Long id) {
return (Logo) this.logoDao.get(Logo.class, id);
}
public Logo getLogoByIdAndName(Long id, String userName) {
Logo logo = (Logo) this.logoDao.findUniqueBy(
"from Logo where id = ? and userName = ?", Logo.class,
new Object[] {id, userName });
if (logo == null) {
throw new BusinessException("no Logo record", "22");
}
return logo;
}
public void delete(Long id) {
this.logoDao.deleteById(Logo.class, id);
}
public Long save(Logo logo) {
if (logo.getId() != null) {
update(logo);
return logo.getId();
}
return (Long) this.logoDao.save(logo);
}
public void update(Logo logo) {
this.logoDao.update(logo);
}
public PageSupport getLogoList(CriteriaQuery cq) {
return this.logoDao.find(cq);
}
public void setLogoDao(LogoDao logoDao) {
this.logoDao = logoDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.HotsearchDao;
import com.legendshop.business.service.HotsearchService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.model.entity.Hotsearch;
import com.legendshop.util.AppUtils;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class HotsearchServiceImpl implements HotsearchService {
Logger log = LoggerFactory
.getLogger(HotsearchServiceImpl.class);
private HotsearchDao hotsearchDao;
public List<Hotsearch> getHotsearch(String userName) {
return (List<Hotsearch>) this.hotsearchDao.findByHQL(
"from Hotsearch where userName = ?", new Object[] {userName });
}
public Hotsearch getHotsearchById(Long id) {
return (Hotsearch) this.hotsearchDao.get(Hotsearch.class, id);
}
public Hotsearch getHotsearchByIdAndName(Integer id, String userName) {
Hotsearch hotsearch = (Hotsearch) this.hotsearchDao.findUniqueBy(
"from Hotsearch where id = ? and userName = ?", Hotsearch.class,
new Object[] {id, userName });
if (hotsearch == null) {
throw new BusinessException("no Hotsearch record", "12");
}
return hotsearch;
}
public void delete(Long id) {
this.hotsearchDao.deleteById(Hotsearch.class, id);
}
public Long save(Hotsearch hotsearch, String userName,
boolean viewAllDataFunction) {
if (!AppUtils.isBlank(hotsearch.getId())) {
Hotsearch entity = (Hotsearch) this.hotsearchDao.get(
Hotsearch.class, hotsearch.getId());
if (entity != null) {
if ((!viewAllDataFunction)
&& (!userName.equals(entity.getUserName()))) {
throw new PermissionException(
"Can't edit Hotsearch does not onw to you!", "12");
}
entity.setDate(new Date());
entity.setMsg(hotsearch.getMsg());
entity.setTitle(hotsearch.getTitle());
entity.setSort(hotsearch.getSort());
update(entity);
return hotsearch.getId();
}
return null;
}
return (Long) this.hotsearchDao.save(hotsearch);
}
public void update(Hotsearch hotsearch) {
this.hotsearchDao.update(hotsearch);
}
public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
return this.hotsearchDao.find(cq);
}
public List<Hotsearch> getSearch(String userName, Long sortId) {
return this.hotsearchDao.getSearch(userName, sortId);
}
@Required
public void setHotsearchDao(HotsearchDao hotsearchDao) {
this.hotsearchDao = hotsearchDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.helper.TaskThread;
import com.legendshop.business.service.LoginHistoryService;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.event.TaskItem;
import com.legendshop.model.entity.LoginHistory;
import com.legendshop.util.ip.IPSeeker;
import com.legendshop.util.sql.ConfigCode;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
public class LoginHistoryServiceImpl implements LoginHistoryService {
private final Logger log;
private BaseDao baseDao;
private JdbcTemplate jdbcTemplate;
private ThreadPoolTaskExecutor threadPoolExecutor;
public LoginHistoryServiceImpl() {
this.log = LoggerFactory.getLogger(LoginHistoryServiceImpl.class);
}
@Required
public void setThreadPoolExecutor(ThreadPoolTaskExecutor threadPoolExecutor) {
this.threadPoolExecutor = threadPoolExecutor;
}
public void saveLoginHistory(String userName, String ip) {
if (((Boolean) PropertiesUtil.getObject(ParameterEnum.LOGIN_LOG_ENABLE,
Boolean.class)).booleanValue())
this.threadPoolExecutor.execute(new TaskThread(
new PersistLoginHistoryTask(userName, ip)));
}
@Required
public void setBaseDao(BaseDao baseDao) {
this.baseDao = baseDao;
}
@Required
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public PageSupport getLoginHistory(CriteriaQuery cq) {
return this.baseDao.find(cq);
}
public PageSupport getLoginHistoryBySQL(SqlQuery query) {
return this.baseDao.find(query);
}
class PersistLoginHistoryTask implements TaskItem {
private final String userName;
private final String ip;
public PersistLoginHistoryTask(String userName, String ip) {
this.userName = userName;
this.ip = ip;
}
public void execute() {
LoginHistoryServiceImpl.this.log.debug(
"user {} login system from ip {}", this.userName, this.ip);
try {
LoginHistory loginHistory = new LoginHistory();
loginHistory.setIp(this.ip);
loginHistory.setTime(new Date());
loginHistory.setArea(IPSeeker.getInstance().getArea(this.ip));
loginHistory.setCountry(IPSeeker.getInstance().getCountry(
this.ip));
loginHistory.setUserName(this.userName);
LoginHistoryServiceImpl.this.baseDao.save(loginHistory);
LoginHistoryServiceImpl.this.jdbcTemplate.update(ConfigCode
.getInstance().getCode("login.updateUserDetail"),
new Object[] {loginHistory.getIp(), loginHistory.getTime(),
loginHistory.getUserName() });
} catch (Exception e) {
LoginHistoryServiceImpl.this.log.error("save userLoginHistory",
e);
}
}
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ShopDetailDao;
import com.legendshop.business.dao.UserDetailDao;
import com.legendshop.business.search.facade.ShopDetailSearchFacade;
import com.legendshop.business.service.CommonUtil;
import com.legendshop.business.service.ShopDetailService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.ShopDetailView;
import com.legendshop.model.entity.UserDetail;
public class ShopDetailServiceImpl implements ShopDetailService {
private ShopDetailDao shopDetailDao;
private UserDetailDao userDetailDao;
private CommonUtil commonUtil;
private ShopDetailSearchFacade shopDetailSearchFacade;
public void setShopDetailDao(ShopDetailDao shopDetailDao) {
this.shopDetailDao = shopDetailDao;
}
public ShopDetail getShopDetailById(Long id) {
return (ShopDetail) this.shopDetailDao.get(ShopDetail.class, id);
}
public UserDetail getShopDetailByName(String userName) {
return this.userDetailDao.getUserDetailByName(userName);
}
public void delete(Long id) {
this.shopDetailDao.deleteById(ShopDetail.class, id);
}
public void delete(ShopDetail shopDetail) {
this.shopDetailDao.delete(shopDetail);
}
public void save(ShopDetail shopDetail) {
this.shopDetailDao.save(shopDetail);
this.commonUtil.saveAdminRight(this.shopDetailDao,
shopDetail.getUserId());
this.shopDetailSearchFacade.create(shopDetail);
}
public ShopDetailView getShopDetailView(String currentShopName) {
return this.shopDetailDao.getShopDetailView(currentShopName);
}
public void update(ShopDetail shopDetail) {
this.shopDetailDao.update(shopDetail);
}
public PageSupport getShopDetail(CriteriaQuery cq) {
return this.shopDetailDao.find(cq);
}
public void setUserDetailDao(UserDetailDao userDetailDao) {
this.userDetailDao = userDetailDao;
}
public void setCommonUtil(CommonUtil commonUtil) {
this.commonUtil = commonUtil;
}
public void setShopDetailSearchFacade(
ShopDetailSearchFacade shopDetailSearchFacade) {
this.shopDetailSearchFacade = shopDetailSearchFacade;
}
public ShopDetail getShopDetailByUserId(String userId) {
return this.shopDetailDao.getShopDetailByUserId(userId);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.MyleagueDao;
import com.legendshop.business.service.MyleagueService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Myleague;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class MyleagueServiceImpl implements MyleagueService {
private MyleagueDao myleagueDao;
@Required
public void setMyleagueDao(MyleagueDao myleagueDao) {
this.myleagueDao = myleagueDao;
}
public List<Myleague> getMyleagueList(String userName) {
return (List<Myleague>) this.myleagueDao.findByHQL(
"from Myleague where userName = ?", new Object[] {userName });
}
public Myleague getMyleagueById(Long id) {
return (Myleague) this.myleagueDao.get(Myleague.class, id);
}
public void delete(Long id) {
this.myleagueDao.deleteById(Myleague.class, id);
}
public Long save(Myleague myleague) {
if (!AppUtils.isBlank(myleague.getId())) {
update(myleague);
return myleague.getId();
}
return (Long) this.myleagueDao.save(myleague);
}
public void update(Myleague myleague) {
this.myleagueDao.update(myleague);
}
public PageSupport getMyleagueList(CriteriaQuery cq) {
return this.myleagueDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.service.CommonUtil;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.model.entity.UserRole;
import com.legendshop.model.entity.UserRoleId;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommonUtilImpl implements CommonUtil {
private static Logger log = LoggerFactory
.getLogger(CommonServiceUtil.class);
private static String adminRightSQL = "select id from ls_role where name = 'ROLE_ADMIN' or name = 'ROLE_OPERATOR'";
private static String userRightSQL = "select id from ls_role where name = 'ROLE_USER' or name = 'ROLE_OPERATOR'";
public void saveAdminRight(BaseDao baseDao, String userId) {
List roles = baseDao.findBySQL(adminRightSQL);
saveRole(baseDao, roles, userId);
}
public void saveUserRight(BaseDao baseDao, String userId) {
List roles = baseDao.findBySQL(userRightSQL);
saveRole(baseDao, roles, userId);
}
public void removeAdminRight(BaseDao baseDao, String userId) {
List roles = baseDao.findBySQL(adminRightSQL);
removeRole(baseDao, roles, userId);
saveUserRight(baseDao, userId);
}
public void removeUserRight(BaseDao baseDao, String userId) {
List roles = baseDao.findBySQL(userRightSQL);
removeRole(baseDao, roles, userId);
}
private void saveRole(BaseDao baseDao, List<String> roles, String userId) {
for (String roleId : roles) {
UserRole userRole = new UserRole();
UserRoleId id = new UserRoleId();
id.setRoleId(roleId);
id.setUserId(userId);
userRole.setId(id);
if (baseDao.get(UserRole.class, id) == null)
baseDao.save(userRole);
}
}
private void removeRole(BaseDao baseDao, List<String> roles, String userId) {
for (String roleId : roles) {
UserRole userRole = new UserRole();
UserRoleId id = new UserRoleId();
id.setRoleId(roleId);
id.setUserId(userId);
userRole.setId(id);
UserRole entity = (UserRole) baseDao.get(UserRole.class, id);
if (entity != null)
baseDao.delete(entity);
}
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.IndexJpgDao;
import com.legendshop.business.service.IndexJpgService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Indexjpg;
public class IndexJpgServiceImpl implements IndexJpgService {
private IndexJpgDao indexJpgDao;
public void setIndexJpgDao(IndexJpgDao indexJpgDao) {
this.indexJpgDao = indexJpgDao;
}
public PageSupport getIndexJpg(CriteriaQuery cq) {
return this.indexJpgDao.queryIndexJpg(cq);
}
public Indexjpg getIndexJpgById(Long id) {
return this.indexJpgDao.queryIndexJpg(id);
}
public void deleteIndexJpg(Indexjpg indexjpg) {
this.indexJpgDao.deleteIndexJpg(indexjpg);
}
public Long getIndexJpgNum(String name) {
return this.indexJpgDao.getIndexJpgNum(name);
}
public void updateIndexjpg(Indexjpg origin) {
this.indexJpgDao.updateIndexjpg(origin);
}
public void saveIndexjpg(Indexjpg indexjpg) {
this.indexJpgDao.saveIndexjpg(indexjpg);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.EventDao;
import com.legendshop.business.service.EventService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Event;
import com.legendshop.util.AppUtils;
import java.util.List;
public class EventServiceImpl implements EventService {
private EventDao eventDao;
public void setEventDao(EventDao eventDao) {
this.eventDao = eventDao;
}
public List<Event> getEvent(String userName) {
return this.eventDao.getEvent(userName);
}
public Event getEvent(Long id) {
return this.eventDao.getEvent(id);
}
public void deleteEvent(Event event) {
this.eventDao.deleteEvent(event);
}
public Long saveEvent(Event event) {
if (!AppUtils.isBlank(event.getEventId())) {
updateEvent(event);
return event.getEventId();
}
return (Long) this.eventDao.save(event);
}
public void updateEvent(Event event) {
this.eventDao.updateEvent(event);
}
public PageSupport getEvent(CriteriaQuery cq) {
return this.eventDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.BrandDao;
import com.legendshop.business.service.BrandService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Brand;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class BrandServiceImpl implements BrandService {
private BrandDao brandDao;
@Required
public void setBrandDao(BrandDao brandDao) {
this.brandDao = brandDao;
}
public List<Brand> getBrand(String userName) {
return (List<Brand>) this.brandDao.findByHQL(
"from Brand where userName = ?", new Object[] {userName });
}
public Brand getBrand(Long id) {
return (Brand) this.brandDao.get(Brand.class, id);
}
public void delete(Long id) {
this.brandDao.deleteById(Brand.class, id);
}
public Long save(Brand brand) {
if (!AppUtils.isBlank(brand.getBrandId())) {
update(brand);
return brand.getBrandId();
}
return (Long) this.brandDao.save(brand);
}
public void update(Brand brand) {
this.brandDao.update(brand);
}
public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
return this.brandDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.business.dao.ProductDao;
import com.legendshop.business.service.BasketService;
import com.legendshop.model.entity.Basket;
import com.legendshop.model.entity.ProductDetail;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class BasketServiceImpl implements BasketService {
private BasketDao basketDao;
private ProductDao productDao;
public void saveToCart(Long prodId, String addtoCart, String shopName,
String prodattr, String userName, Integer count) {
ProductDetail prod = this.productDao.getProdDetail(prodId);
if ((prod != null) && ("buy".equals(addtoCart))) {
String attribute = prodattr == null ? ""
: prodattr;
Basket basket = this.basketDao.getBasketByIdName(prodId, userName,
shopName, attribute);
if (basket == null)
this.basketDao.saveToCart(prod.getProdId(), prod.getPic(),
userName, shopName, count, attribute, prod.getName(),
prod.getCash(), prod.getCarriage());
}
}
public void saveToCart(Long prodId, String pic, String userName,
String shopName, Integer count, String attribute, String prodName,
Double cash, Double carriage) {
this.basketDao.saveToCart(prodId, pic, userName, shopName, count,
attribute, prodName, cash, carriage);
}
@Required
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
@Required
public void setBasketDao(BasketDao basketDao) {
this.basketDao = basketDao;
}
public void deleteBasketByUserName(String userName) {
this.basketDao.deleteBasketByUserName(userName);
}
public void deleteBasketById(Long id) {
this.basketDao.deleteBasketById(id);
}
public List<Basket> getBasketByuserName(String userName) {
return this.basketDao.getBasketByuserName(userName);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.processor.PaymentProcessor;
import com.legendshop.business.service.PaymentService;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class PaymentServiceImpl implements PaymentService {
private static Logger log = LoggerFactory
.getLogger(PaymentServiceImpl.class);
private Map<Integer, PaymentProcessor> paymentProcessor;
public String payto(String shopName, String userName, Integer payTypeId,
String out_trade_no, String subject, String body, String price,
String ip) {
log.debug("payto shopName = {},userName = {},payTypeId = {}",
new Object[] {shopName, userName, payTypeId });
return getPaymentProcessor(payTypeId).payto(shopName, userName,
payTypeId, out_trade_no, subject, body, price, ip);
}
private PaymentProcessor getPaymentProcessor(Integer payTypeId) {
PaymentProcessor processor = (PaymentProcessor) this.paymentProcessor
.get(payTypeId);
if (processor == null) {
processor = (PaymentProcessor) this.paymentProcessor.get(Integer
.valueOf(1));
}
return processor;
}
@Required
public void setPaymentProcessor(
Map<Integer, PaymentProcessor> paymentProcessor) {
this.paymentProcessor = paymentProcessor;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.PubDao;
import com.legendshop.business.service.PubService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.model.entity.Pub;
import com.legendshop.util.AppUtils;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class PubServiceImpl implements PubService {
private PubDao pubDao;
@Required
public void setPubDao(PubDao pubDao) {
this.pubDao = pubDao;
}
public List<Pub> getPubList(String userName) {
return (List<Pub>) this.pubDao.findByHQL("from Pub where userName = ?",
new Object[] {userName });
}
public Pub getPubById(Long id) {
return (Pub) this.pubDao.get(Pub.class, id);
}
public void delete(Long id) {
this.pubDao.deleteById(Pub.class, id);
}
public Long save(Pub pub, String userName, boolean viewAllDataFunction) {
if (!AppUtils.isBlank(pub.getId())) {
Pub entity = (Pub) this.pubDao.get(Pub.class, pub.getId());
if (entity != null) {
if ((!viewAllDataFunction)
&& (!userName.equals(entity.getUserName()))) {
throw new PermissionException(
"Can't edit Pub does not onw to you!", "14");
}
entity.setDate(new Date());
entity.setMsg(pub.getMsg());
entity.setTitle(pub.getTitle());
update(entity);
return pub.getId();
}
return null;
}
return (Long) this.pubDao.save(pub);
}
public void update(Pub pub) {
this.pubDao.update(pub);
}
public PageSupport getPubList(CriteriaQuery cq) {
return this.pubDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.service.AuthService;
import com.legendshop.core.security.GrantedFunction;
import com.legendshop.core.security.GrantedFunctionImpl;
import com.legendshop.core.security.cache.AuthorityBasedUserCache;
import com.legendshop.core.security.cache.FunctionCache;
import com.legendshop.core.security.cache.RoleByNameCache;
import com.legendshop.core.security.model.UserDetail;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.Role;
import com.legendshop.model.entity.UserEntity;
import com.legendshop.util.AppUtils;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
public class AuthServiceImpl implements AuthService {
Logger log = LoggerFactory
.getLogger(AuthServiceImpl.class);
private FunctionCache functionCache;
private RoleByNameCache roleCache;
private AuthorityBasedUserCache authorityUserCache;
private JdbcTemplate jdbcTemplate;
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
this.log.debug("loadUserByUsername calling {}", username);
UserEntity user = getUserByName(username);
if (AppUtils.isBlank(user)) {
return null;
}
Collection roles = getAuthoritiesByUsernameQuery(user);
if (AppUtils.isBlank(roles)) {
throw new UsernameNotFoundException("User has no GrantedAuthority");
}
Collection functoins = getFunctionByUsernameQuery(user);
User minuser = new UserDetail(username, user.getPassword(),
getBoolean(user.getEnabled()), true, true, true, roles, functoins,
user.getId());
return minuser;
}
private boolean getBoolean(String b) {
return "1".endsWith(b);
}
public Collection<GrantedAuthority> getAuthoritiesByUsernameQuery(
UserEntity user) throws DataAccessException {
Collection grantedAuthoritys = new ArrayList();
if (user != null) {
List roles = user.getRoles();
Iterator it = roles.iterator();
while (it.hasNext()) {
GrantedAuthorityImpl gai = new GrantedAuthorityImpl(
((Role) it.next()).getName());
grantedAuthoritys.add(gai);
}
}
this.log.debug("{} have roles number {}", user.getName(),
Integer.valueOf(grantedAuthoritys.size()));
return grantedAuthoritys;
}
public Collection<GrantedFunction> getFunctionByUsernameQuery(
UserEntity user) throws DataAccessException {
Collection grantedFunctions = new ArrayList();
if (user != null) {
this.log.debug("{} have functions number {}", user.getName(),
Integer.valueOf(grantedFunctions.size()));
List functions = user.getFunctions();
Iterator it = functions.iterator();
while (it.hasNext()) {
GrantedFunctionImpl gfi = new GrantedFunctionImpl(
((Function) it.next()).getName());
grantedFunctions.add(gfi);
}
}
return grantedFunctions;
}
public UserEntity getUserByName(String name) {
if (this.log.isDebugEnabled()) {
this.log.debug("getUserByName calling, name {}", name);
}
UserEntity user = findUserByName(name);
if (user != null) {
user.setRoles(findRolesByUser(user));
user.setFunctions(findFunctionsByUser(user));
}
if (this.log.isDebugEnabled()) {
this.log.debug("getUserByName calling with param {}, result {}",
name, user);
}
return user;
}
private List<Function> findFunctionsByUser(UserEntity user) {
return this.jdbcTemplate
.query(
"select f.* from ls_usr_role ur ,ls_role r,ls_perm p, ls_func f where ur.user_id= ? and ur.role_id=r.id and r.id=p.role_id and p.function_id=f.id",
new Object[] {user.getId() }, new RowMapper() {
public Function mapRow(ResultSet rs, int index)
throws SQLException {
Function function = new Function();
function.setId(rs.getString("id"));
function.setName(rs.getString("name"));
function.setNote(rs.getString("note"));
function.setProtectFunction(rs
.getString("protect_function"));
function.setUrl(rs.getString("url"));
return function;
}
});
}
public UserEntity findUserByName(String name) {
return (UserEntity) this.jdbcTemplate.queryForObject(
"select * from ls_user where name = ?", new Object[] {name },
new RowMapper() {
public Object mapRow(ResultSet rs, int index)
throws SQLException {
UserEntity user = new UserEntity();
user.setEnabled(rs.getString("enabled"));
user.setId(rs.getString("id"));
user.setName(rs.getString("name"));
user.setNote(rs.getString("note"));
user.setPassword(rs.getString("password"));
return user;
}
});
}
public List<Role> findRolesByUser(UserEntity user) {
return this.jdbcTemplate
.query(
"select r.* from ls_usr_role ur ,ls_role r where ur.user_id= ? and ur.role_id=r.id",
new Object[] {user.getId() }, new RowMapper() {
public Role mapRow(ResultSet rs, int index)
throws SQLException {
Role role = new Role();
role.setEnabled(rs.getString("enabled"));
role.setId(rs.getString("id"));
role.setName(rs.getString("name"));
role.setNote(rs.getString("note"));
role.setRoleType(rs.getString("role_type"));
return role;
}
});
}
public Map<String, String> getUrlAuthorities() {
Map urlAuthorities = new HashMap();
return urlAuthorities;
}
public Collection<GrantedFunction> getFunctionsByRoles(
Collection<? extends GrantedAuthority> roles) {
if (null == roles) {
throw new IllegalArgumentException("Granted Roles cannot be null");
}
Collection grantedFunctions = new HashSet();
for (GrantedAuthority grantedAuthority : roles) {
Role role = this.roleCache.getRoleByRoleNameCache(grantedAuthority
.getAuthority());
if (role == null) {
role = getgrantedAuthority(grantedAuthority.getAuthority());
if (role != null)
this.roleCache.putRoleInCache(role);
else {
return grantedFunctions;
}
}
if (role != null) {
List<Function> functions = role.getFunctions();
for (Function function : functions) {
grantedFunctions.add(new GrantedFunctionImpl(function
.getName()));
}
}
}
return grantedFunctions;
}
public Collection<GrantedFunction> getFunctionsByUser(UserEntity user) {
if (null == user)
throw new IllegalArgumentException("User Entity cannot be null");
Collection grantedFunctions = new HashSet();
List functions = user.getFunctions();
for (Iterator it = functions.iterator(); it.hasNext();) {
Function function = (Function) it.next();
GrantedFunction grantedFunction = new GrantedFunctionImpl(
function.getName());
grantedFunctions.add(grantedFunction);
}
return grantedFunctions;
}
public Role getgrantedAuthority(String authority) {
List roles = findRoleByName(authority);
if (AppUtils.isBlank(roles)) {
this.log.warn("authority {} can not get Role", authority);
return null;
}
Role role = (Role) roles.iterator().next();
if (role != null) {
role.setFunctions(findFunctionsByRole(role));
return role;
}
return null;
}
public List<Role> findRoleByName(String authority) {
return this.jdbcTemplate.query("select * from ls_role where name = ?",
new Object[] {authority }, new RowMapper() {
public Role mapRow(ResultSet rs, int index) throws SQLException {
Role role = new Role();
role.setEnabled(rs.getString("enabled"));
role.setId(rs.getString("id"));
role.setName(rs.getString("name"));
role.setNote(rs.getString("note"));
role.setRoleType(rs.getString("role_type"));
return role;
}
});
}
public List<Function> findFunctionsByRole(Role role) {
return this.jdbcTemplate
.query(
"select f.* from ls_perm p ,ls_func f where p.role_id= ? and p.function_id=f.id",
new Object[] {role.getId() }, new RowMapper() {
public Function mapRow(ResultSet rs, int index)
throws SQLException {
Function function = new Function();
function.setId(rs.getString("id"));
function.setName(rs.getString("name"));
function.setNote(rs.getString("note"));
function.setProtectFunction(rs
.getString("protect_function"));
function.setUrl(rs.getString("url"));
return function;
}
});
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
public void setRoleCache(RoleByNameCache roleCache) {
this.roleCache = roleCache;
}
public void setAuthorityUserCache(AuthorityBasedUserCache authorityUserCache) {
this.authorityUserCache = authorityUserCache;
}
public void setFunctionCache(FunctionCache functionCache) {
this.functionCache = functionCache;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.PayTypeDao;
import com.legendshop.business.service.PayTypeService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.PayType;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class PayTypeServiceImpl implements PayTypeService {
private PayTypeDao payTypeDao;
@Required
public void setPayTypeDao(PayTypeDao payTypeDao) {
this.payTypeDao = payTypeDao;
}
public List<PayType> getPayTypeList(String userName) {
return (List<PayType>) this.payTypeDao.findByHQL(
"from PayType where userName = ?", new Object[] {userName });
}
public PayType getPayTypeById(Long id) {
return (PayType) this.payTypeDao.get(PayType.class, id);
}
public PayType getPayTypeByIdAndName(String userName, Integer payTypeId) {
return (PayType) this.payTypeDao.findUniqueBy(
"from PayType where userName = ? and payTypeId = ?", PayType.class,
new Object[] {userName, payTypeId });
}
public void delete(Long id) {
this.payTypeDao.deleteById(PayType.class, id);
}
public Long save(PayType payType) {
return (Long) this.payTypeDao.save(payType);
}
public void update(PayType payType) {
this.payTypeDao.update(payType);
}
public PageSupport getPayTypeList(CriteriaQuery cq) {
return this.payTypeDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.DeliveryTypeDao;
import com.legendshop.business.service.DeliveryTypeService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.DeliveryType;
import com.legendshop.util.AppUtils;
import java.util.List;
public class DeliveryTypeServiceImpl implements DeliveryTypeService {
private DeliveryTypeDao deliveryTypeDao;
public void setDeliveryTypeDao(DeliveryTypeDao deliveryTypeDao) {
this.deliveryTypeDao = deliveryTypeDao;
}
public List<DeliveryType> getDeliveryType(String userName) {
return this.deliveryTypeDao.getDeliveryType(userName);
}
public DeliveryType getDeliveryType(Long id) {
return this.deliveryTypeDao.getDeliveryType(id);
}
public void deleteDeliveryType(DeliveryType deliveryType) {
this.deliveryTypeDao.deleteDeliveryType(deliveryType);
}
public Long saveDeliveryType(DeliveryType deliveryType) {
if (!AppUtils.isBlank(deliveryType.getDvyTypeId())) {
updateDeliveryType(deliveryType);
return deliveryType.getDvyTypeId();
}
return (Long) this.deliveryTypeDao.save(deliveryType);
}
public void updateDeliveryType(DeliveryType deliveryType) {
this.deliveryTypeDao.updateDeliveryType(deliveryType);
}
public PageSupport getDeliveryType(CriteriaQuery cq) {
return this.deliveryTypeDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.NsortDao;
import com.legendshop.business.service.NsortService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Nsort;
import com.legendshop.model.entity.Sort;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class NsortServiceImpl implements NsortService {
private NsortDao nsortDao;
public List<Nsort> getNsortList(String userName) {
return (List<Nsort>) this.nsortDao.findByHQL(
"from Nsort where userName = ?", new Object[] {userName });
}
public List<Nsort> getNSortBySort(Long sortId) {
return (List<Nsort>) this.nsortDao.findByHQL(
"from Nsort where sortId = ? and parentNsortId is not null",
new Object[] {sortId });
}
public boolean isHasChildNsort(Long id) {
Long result = (Long) this.nsortDao.findUniqueBy(
"select count(*) from Nsort where parentNsortId = ?", Long.class,
new Object[] {id });
return result.longValue() > 0L;
}
public boolean isHasChildNsortBrand(Long id) {
Long result = (Long) this.nsortDao.findUniqueBy(
"select count(*) from NsortBrand n where n.id.nsortId = ?",
Long.class, new Object[] {id });
return result.longValue() > 0L;
}
public Nsort getNsort(Long id) {
return (Nsort) this.nsortDao.get(Nsort.class, id);
}
public Sort getSort(Long id) {
return (Sort) this.nsortDao.get(Sort.class, id);
}
public void delete(Long id) {
this.nsortDao.deleteById(Nsort.class, id);
}
public Long save(Nsort nsort) {
if (!AppUtils.isBlank(nsort.getNsortId())) {
update(nsort);
return nsort.getNsortId();
}
return (Long) this.nsortDao.save(nsort);
}
public void update(Nsort nsort) {
this.nsortDao.update(nsort);
}
public PageSupport getNsortList(CriteriaQuery cq) {
return this.nsortDao.find(cq);
}
public PageSupport getNsortList(HqlQuery hql) {
return this.nsortDao.find(hql);
}
public Nsort getNsortById(Long id) {
return this.nsortDao.getNsort(id);
}
@Required
public void setNsortDao(NsortDao nsortDao) {
this.nsortDao = nsortDao;
}
public List<Nsort> getNsortBySortId(Long sortId) {
return this.nsortDao.getNsortBySortId(sortId);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.service.IndexService;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.model.UserInfo;
import com.legendshop.model.entity.ShopDetailView;
import org.springframework.beans.factory.annotation.Required;
public class IndexServiceImpl implements IndexService {
private BaseDao baseDao;
public UserInfo getAdminIndex(String userName, ShopDetailView shopDetail) {
UserInfo userInfo = new UserInfo();
if (shopDetail != null) {
Long totalNews = (Long) this.baseDao.findUniqueBy(
"select count(*) from News where userName = ?", Long.class,
new Object[] {userName });
userInfo.setArticleNum(totalNews);
Long totalProcessingOrder = (Long) this.baseDao
.findUniqueBy(
"select count(*) from Sub where subCheck = ? and shopName = ?",
Long.class, new Object[] {"N", userName });
userInfo.setProcessingOrderNum(totalProcessingOrder);
Long totalUnReadMessage = (Long) this.baseDao
.findUniqueBy(
"select count(*) from UserComment where status = ? and toUserName = ?",
Long.class, new Object[] {Integer.valueOf(0), userName });
userInfo.setUnReadMessageNum(totalUnReadMessage);
userInfo.setShopDetail(shopDetail);
} else {
Long userTotalNum = (Long) this.baseDao.findUniqueBy(
"select count(*) from UserDetail", Long.class, new Object[0]);
userInfo.setUserTotalNum(userTotalNum);
Long shopTotalNum = (Long) this.baseDao.findUniqueBy(
"select count(*) from ShopDetail ", Long.class, new Object[0]);
userInfo.setShopTotalNum(shopTotalNum);
}
return userInfo;
}
@Required
public void setBaseDao(BaseDao baseDao) {
this.baseDao = baseDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.common.ProductStatusEnum;
import com.legendshop.business.common.RoleEnum;
import com.legendshop.business.common.ShopStatusEnum;
import com.legendshop.business.dao.ShopDetailDao;
import com.legendshop.business.event.EventId;
import com.legendshop.business.helper.TaskThread;
import com.legendshop.business.helper.impl.SendMailTask;
import com.legendshop.business.service.AdminService;
import com.legendshop.business.service.CommonUtil;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.core.dao.impl.BaseDaoImpl;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.randing.RandomStringUtils;
import com.legendshop.event.EventContext;
import com.legendshop.event.EventHome;
import com.legendshop.event.GenericEvent;
import com.legendshop.model.entity.DynamicTemp;
import com.legendshop.model.entity.ImgFile;
import com.legendshop.model.entity.News;
import com.legendshop.model.entity.Nsort;
import com.legendshop.model.entity.NsortBrand;
import com.legendshop.model.entity.NsortBrandId;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.RelProduct;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.Sort;
import com.legendshop.model.entity.User;
import com.legendshop.model.entity.UserDetail;
import com.legendshop.model.entity.UserRole;
import com.legendshop.model.entity.UserRoleId;
import com.legendshop.util.AppUtils;
import com.legendshop.util.MD5Util;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import org.apache.oro.text.regex.MalformedPatternException;
import org.hibernate.Hibernate;
import org.hibernate.type.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
public class AdminServiceImpl extends BaseServiceImpl implements AdminService {
private static Logger log = LoggerFactory.getLogger(AdminServiceImpl.class);
private BaseDao baseDao;
private ShopDetailDao shopDetailDao;
private CommonUtil commonUtil;
@Required
public void setBaseDao(BaseDaoImpl baseDao) {
this.baseDao = baseDao;
}
public void saveNews(News news) {
this.baseDao.saveOrUpdate(news);
}
public News getNewsById(Long newsId) {
return (News) this.baseDao.get(News.class, newsId);
}
public PageSupport getDataByCQ(CriteriaQuery cq) {
return this.baseDao.find(cq, true);
}
public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
return this.baseDao.find(cq);
}
public PageSupport getDataByCriteriaQuery(SqlQuery sqlQuery) {
return this.baseDao.find(sqlQuery);
}
public PageSupport getDataByCriteriaQueryMap(SqlQuery sqlQuery) {
return this.baseDao.findMap(sqlQuery);
}
public PageSupport getUserDetailList(HqlQuery hql,
HttpServletRequest request) {
EventContext eventContext = new EventContext(request);
EventHome.publishEvent(new GenericEvent(eventContext,
EventId.CAN_ADD_SHOPDETAIL_EVENT));
Boolean isSupportOpenShop = eventContext.getBooleanResponse();
request.setAttribute("supportOpenShop", isSupportOpenShop);
return this.baseDao.find(hql);
}
public void deleteSort(Long sortId) {
List list = this.baseDao.findByHQL("from Product where sortId = ?",
new Object[] {sortId });
if (!AppUtils.isBlank(list)) {
throw new BusinessException("请删除该类型对应的商品", "12");
}
List nsortList = this.baseDao.findByHQL("from Nsort where sortId = ?",
new Object[] {sortId });
if (!AppUtils.isBlank(nsortList)) {
throw new BusinessException("请删除该类型对应的二级商品类型", "12");
}
this.baseDao.deleteById(Sort.class, sortId);
}
public Sort getSort(Long sortId) {
return (Sort) this.baseDao.get(Sort.class, sortId);
}
public void saveSort(Sort sort) {
this.baseDao.saveOrUpdate(sort);
}
public void saveNsort(Nsort nsort) {
this.baseDao.saveOrUpdate(nsort);
}
public void deleteNsort(Long nsortId) {
this.baseDao.deleteById(Nsort.class, nsortId);
}
public void deleteNsort(Nsort nsort) {
this.baseDao.delete(nsort);
}
public Nsort getNsort(Long nsortId) {
return (Nsort) this.baseDao.get(Nsort.class, nsortId);
}
public void saveOrUpdate(Object o) {
this.baseDao.saveOrUpdate(o);
}
public void updateProd(Product product) {
this.baseDao.update(product);
}
public <T> void deleteById(Class<T> entityClass, Serializable id) {
this.baseDao.deleteById(entityClass, id);
}
public <T> T get(Class<T> entityClass, Serializable id) {
return this.baseDao.get(entityClass, id);
}
public boolean updateProdOnline(Long prodId) {
Product product = (Product) this.baseDao.get(Product.class, prodId);
if (!ProductStatusEnum.PROD_ONLINE.value().equals(product.getStatus())) {
product.setStatus(ProductStatusEnum.PROD_ONLINE.value());
this.baseDao.update(product);
return true;
}
return false;
}
public boolean updateProdOffline(Long prodId) {
Product product = (Product) this.baseDao.get(Product.class, prodId);
if (!ProductStatusEnum.PROD_OFFLINE.value().equals(product.getStatus())) {
product.setStatus(ProductStatusEnum.PROD_OFFLINE.value());
this.baseDao.update(product);
return true;
}
return false;
}
public String deleteUserDetail(String userId, String userName,
String realPicPath, String smallPicPath) {
List<UserRole> list = (List<UserRole>) this.baseDao.findByHQL(
"from UserRole where id.userId = ?", new Object[] {userId });
boolean isAdmin = false;
for (UserRole role : list) {
if (role.getId().getRoleId()
.equals(RoleEnum.ROLE_SUPERVISOR.value())) {
isAdmin = true;
break;
}
}
if (isAdmin) {
return "不能删除商家用户或者管理员用户,请先备份好数据和去掉该用户的权限再试!";
}
Integer dbr = this.baseDao.exeByHQL(
"delete from Basket where userName = ?", new Object[] {userName },
new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Sub where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from ShopDetail where storeName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from ImgFile where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from RelProduct where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Myleague where userId = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Product where userId = ?",
new Object[] {userId }, new Type[] {Hibernate.STRING });
if (AppUtils.isNotBlank(userName)) {
FileProcessor
.deleteDirectory(new File(realPicPath + "/" + userName));
FileProcessor.deleteDirectory(new File(smallPicPath + "/"
+ userName));
}
this.baseDao.exeByHQL("delete from ProductComment where ownerName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from UserComment where userId = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Brand where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from DynamicTemp where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Indexjpg where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Advertisement where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Hotsearch where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Logo where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from News where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from NewsCategory where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from NsortBrand where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao
.exeByHQL(
"delete from Nsort n where exists (select 1 from Sort s where n.sortId = s.sortId and s.userName = ?)",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Sort where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from PayType where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from Pub where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.exeByHQL("delete from ExternalLink where userName = ?",
new Object[] {userName }, new Type[] {Hibernate.STRING });
this.baseDao.deleteAll(list);
this.baseDao.deleteById(UserDetail.class, userId);
this.baseDao.deleteById(User.class, userId);
log.debug("删除用户 {}, {} 成功", userId, userName);
return null;
}
public Long getIndexJpgNum(String userName) {
return (Long) this.baseDao.findUniqueBy(
"select count(*) from Indexjpg where userName = ?", Long.class,
new Object[] {userName });
}
public PageSupport getDataByHQL(HqlQuery hql) {
return this.baseDao.find(hql);
}
public PageSupport getDataBySQL(SqlQuery query) {
return this.baseDao.find(query);
}
public PageSupport getDataBySQL(HqlQuery query) {
return this.baseDao.findBySql(query);
}
public boolean updateShop(String loginUserName, String userId,
ShopDetail shopDetail, Integer status) {
boolean result = true;
try {
if ((new Integer(ShopStatusEnum.REJECT.value().intValue())
.equals(status))
|| (new Integer(ShopStatusEnum.CLOSE.value().intValue())
.equals(status))) {
this.commonUtil.removeAdminRight(this.baseDao, userId);
} else if (new Integer(1).equals(status)) {
this.commonUtil.saveAdminRight(this.baseDao, userId);
}
shopDetail.setStatus(status);
this.baseDao.saveOrUpdate(shopDetail);
} catch (Exception e) {
log.error("auditShop ", e);
result = false;
}
return result;
}
public String saveBrandItem(List<String> idList, Long nsortId,
String userName) {
List list = this.baseDao.find(
"from NsortBrand n where n.id.nsortId = ? and userName = ?",
new Object[] {nsortId, userName });
this.baseDao.deleteAll(list);
if (AppUtils.isNotBlank(idList)) {
for (String brandId : idList) {
NsortBrand nb = new NsortBrand();
NsortBrandId id = new NsortBrandId();
id.setBrandId(Long.valueOf(brandId));
id.setNsortId(nsortId);
nb.setId(id);
nb.setUserName(userName);
this.baseDao.save(nb);
}
}
return null;
}
public boolean updateImgFileOnline(Long fileId) {
ImgFile imgFile = (ImgFile) this.baseDao.get(ImgFile.class, fileId);
if (imgFile.getStatus().shortValue() != ProductStatusEnum.PROD_ONLINE
.value().shortValue()) {
imgFile.setStatus(Short.valueOf(ProductStatusEnum.PROD_ONLINE
.value().shortValue()));
this.baseDao.update(imgFile);
return true;
}
return false;
}
public boolean updateImgFileOffline(Long fileId) {
ImgFile imgFile = (ImgFile) this.baseDao.get(ImgFile.class, fileId);
if (imgFile.getStatus().shortValue() != ProductStatusEnum.PROD_OFFLINE
.value().shortValue()) {
imgFile.setStatus(Short.valueOf(ProductStatusEnum.PROD_OFFLINE
.value().shortValue()));
this.baseDao.update(imgFile);
return true;
}
return false;
}
public Product getProd(Long prodId, String userName) {
return (Product) this.baseDao.findUniqueBy(
"from Product prod where prod.prodId = ? and prod.userName = ?",
Product.class, new Object[] {prodId, userName });
}
public String getAttributeprodAttribute(Long prodId) {
return (String) this.baseDao.findUniqueBy(
"select prod.attribute from Product prod where prod.prodId = ?",
String.class, new Object[] {prodId });
}
public String getProdParameter(Long prodId) {
return (String) this.baseDao.findUniqueBy(
"select prod.parameter from Product prod where prod.prodId = ?",
String.class, new Object[] {prodId });
}
public boolean saveDynamicTemp(String tempName, String userName,
Short type, String content) {
if ((AppUtils.isBlank(tempName)) || (AppUtils.isBlank(userName))) {
return false;
}
List temps = this.baseDao.findByHQL(
"from DynamicTemp where type = ? and name = ? and userName = ?",
new Object[] {type, tempName, userName });
if (AppUtils.isNotBlank(temps)) {
return false;
}
DynamicTemp temp = new DynamicTemp();
temp.setContent(content);
temp.setName(tempName);
temp.setUserName(userName);
temp.setType(type);
this.baseDao.save(temp);
return true;
}
public boolean updateDynamicTemp(Long tempId, String userName, Short type,
String content) {
if ((AppUtils.isBlank(tempId)) || (AppUtils.isBlank(userName))) {
return false;
}
List temps = this.baseDao.findByHQL(
"from DynamicTemp where id = ? and userName = ?", new Object[] {
tempId, userName });
if (AppUtils.isBlank(temps)) {
return false;
}
DynamicTemp temp = (DynamicTemp) temps.get(0);
temp.setContent(content);
this.baseDao.update(temp);
return true;
}
public DynamicTemp getDynamicTemp(Long tempId, String userName) {
return (DynamicTemp) this.baseDao.findUniqueBy(
"from DynamicTemp where id = ? and userName = ?",
DynamicTemp.class, new Object[] {tempId, userName });
}
public boolean deleteDynamicTemp(Long tempId, String userName) {
DynamicTemp temp = (DynamicTemp) this.baseDao.findUniqueBy(
"from DynamicTemp where id = ? and userName = ?",
DynamicTemp.class, new Object[] {tempId, userName });
if (temp != null) {
this.baseDao.delete(temp);
}
return true;
}
public String saveProdItem(List<String> idList, List<String> nameList,
Long prodId, String userName) {
List list = this.baseDao.find(
"from RelProduct n where n.prodId = ? and userName = ?",
new Object[] {prodId, userName });
this.baseDao.deleteAll(list);
if (AppUtils.isNotBlank(idList)) {
for (int i = 0; i < idList.size(); i++) {
RelProduct rprod = new RelProduct();
rprod.setAddtime(new Date());
rprod.setProdId(prodId);
rprod.setRelProdId(Long.valueOf((String) idList.get(i)));
rprod.setRelProdName((String) nameList.get(i));
rprod.setUserName(userName);
this.baseDao.save(rprod);
}
}
return null;
}
public boolean updatePassword(String userName, String mail,
String templateFilePath)
throws MalformedPatternException, MessagingException {
UserDetail userDetail = (UserDetail) this.baseDao.findUniqueBy(
"from UserDetail n where n.userName = ? and n.userMail = ?",
UserDetail.class, new Object[] {userName, mail });
if (userDetail == null) {
return false;
}
User user = (User) this.baseDao.get(User.class, userDetail.getUserId());
String newPassword = RandomStringUtils.randomNumeric(10, 6);
user.setPassword(MD5Util.Md5Password(user.getName(), newPassword));
this.baseDao.update(user);
log.info("{} 修改密码,发送通知邮件到 {}", userName, userDetail.getUserMail());
Map values = new HashMap();
values.put("#nickName#", userDetail.getNickName());
values.put("#userName#", userDetail.getUserName());
values.put("#password#", newPassword);
String text = AppUtils.convertTemplate(templateFilePath, values);
if (sendMail()) {
this.threadPoolExecutor.execute(new TaskThread(new SendMailTask(
this.javaMailSender, userDetail.getUserMail(), "恭喜您,修改密码成功!",
text)));
}
return true;
}
@Required
public void setCommonUtil(CommonUtil commonUtil) {
this.commonUtil = commonUtil;
}
public void updateShopDetail(Product product) {
ShopDetail shopdetail = this.shopDetailDao
.getShopDetailForUpdate(product.getUserName());
if (shopdetail == null) {
throw new NotFoundException("ShopDetail is null, UserName = "
+ product.getUserName(), "12");
}
shopdetail.setProductNum(this.shopDetailDao.getProductNum(product
.getUserName()));
shopdetail.setOffProductNum(this.shopDetailDao.getOffProductNum(product
.getUserName()));
this.shopDetailDao.update(shopdetail);
}
@Required
public void setShopDetailDao(ShopDetailDao shopDetailDao) {
this.shopDetailDao = shopDetailDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.UserAddressDao;
import com.legendshop.business.service.UserAddressService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.UserAddress;
import com.legendshop.util.AppUtils;
import java.util.List;
public class UserAddressServiceImpl implements UserAddressService {
private UserAddressDao userAddressDao;
public void setUserAddressDao(UserAddressDao userAddressDao) {
this.userAddressDao = userAddressDao;
}
public List<UserAddress> getUserAddress(String userName) {
return this.userAddressDao.getUserAddress(userName);
}
public UserAddress getUserAddress(Long id) {
return this.userAddressDao.getUserAddress(id);
}
public void deleteUserAddress(UserAddress userAddress) {
this.userAddressDao.deleteUserAddress(userAddress);
}
public Long saveUserAddress(UserAddress userAddress) {
if (!AppUtils.isBlank(userAddress.getAddrId())) {
updateUserAddress(userAddress);
return userAddress.getAddrId();
}
return (Long) this.userAddressDao.save(userAddress);
}
public void updateUserAddress(UserAddress userAddress) {
this.userAddressDao.updateUserAddress(userAddress);
}
public PageSupport getUserAddress(CriteriaQuery cq) {
return this.userAddressDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ProductCommentDao;
import com.legendshop.business.service.ProductCommentService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductComment;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class ProductCommentServiceImpl implements ProductCommentService {
private ProductCommentDao productCommentDao;
public List<ProductComment> getProductCommentList(String userName) {
return (List<ProductComment>) this.productCommentDao.findByHQL(
"from ProductComment where userName = ?", new Object[] {userName });
}
public ProductComment getProductCommentById(Long id) {
return (ProductComment) this.productCommentDao.get(
ProductComment.class, id);
}
public Product getProduct(Long id) {
return (Product) this.productCommentDao.get(Product.class, id);
}
public void delete(Long id) {
this.productCommentDao.deleteById(ProductComment.class, id);
}
public Long save(ProductComment productComment) {
if (!AppUtils.isBlank(productComment.getId())) {
update(productComment);
return productComment.getId();
}
return (Long) this.productCommentDao.save(productComment);
}
public void update(ProductComment productComment) {
this.productCommentDao.update(productComment);
}
public PageSupport getProductCommentList(CriteriaQuery cq) {
return this.productCommentDao.find(cq);
}
public PageSupport getProductCommentList(HqlQuery hql) {
return this.productCommentDao.find(hql);
}
@Required
public void setProductCommentDao(ProductCommentDao productCommentDao) {
this.productCommentDao = productCommentDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.DeliveryCorpDao;
import com.legendshop.business.service.DeliveryCorpService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.DeliveryCorp;
import com.legendshop.util.AppUtils;
import java.util.List;
public class DeliveryCorpServiceImpl implements DeliveryCorpService {
private DeliveryCorpDao deliveryCorpDao;
public void setDeliveryCorpDao(DeliveryCorpDao deliveryCorpDao) {
this.deliveryCorpDao = deliveryCorpDao;
}
public List<DeliveryCorp> getDeliveryCorp(String userName) {
return this.deliveryCorpDao.getDeliveryCorp(userName);
}
public DeliveryCorp getDeliveryCorp(Long id) {
return this.deliveryCorpDao.getDeliveryCorp(id);
}
public void deleteDeliveryCorp(DeliveryCorp deliveryCorp) {
this.deliveryCorpDao.deleteDeliveryCorp(deliveryCorp);
}
public Long saveDeliveryCorp(DeliveryCorp deliveryCorp) {
if (!AppUtils.isBlank(deliveryCorp.getDvyId())) {
updateDeliveryCorp(deliveryCorp);
return deliveryCorp.getDvyId();
}
return this.deliveryCorpDao.saveDeliveryCorp(deliveryCorp);
}
public void updateDeliveryCorp(DeliveryCorp deliveryCorp) {
this.deliveryCorpDao.updateDeliveryCorp(deliveryCorp);
}
public PageSupport getDeliveryCorp(CriteriaQuery cq) {
return this.deliveryCorpDao.getDeliveryCorp(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ScoreDao;
import com.legendshop.business.service.ScoreService;
import com.legendshop.model.entity.Sub;
import java.util.Map;
public class ScoreServiceImpl implements ScoreService {
private ScoreDao scoreDao;
public void addScore(Sub sub) {
this.scoreDao.saveScore(sub);
}
public Map<String, Object> useScore(Sub sub, Long avaibleScore) {
return this.scoreDao.deleteScore(sub, avaibleScore);
}
public Long calScore(Double total, String scoreType) {
return this.scoreDao.calScore(total, scoreType);
}
public Double calMoney(Long score) {
return this.scoreDao.calMoney(score);
}
public void setScoreDao(ScoreDao scoreDao) {
this.scoreDao = scoreDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.ImgFileDao;
import com.legendshop.business.service.ImgFileService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.ImgFile;
import com.legendshop.model.entity.Product;
import com.legendshop.util.AppUtils;
import java.util.List;
public class ImgFileServiceImpl implements ImgFileService {
private ImgFileDao imgFileDao;
public List<ImgFile> getImgFile(String userName) {
return (List<ImgFile>) this.imgFileDao.findByHQL(
"from ImgFile where userName = ?", new Object[] {userName });
}
public ImgFile getImgFileById(Long id) {
return (ImgFile) this.imgFileDao.get(ImgFile.class, id);
}
public Product getProd(Long id) {
return (Product) this.imgFileDao.get(Product.class, id);
}
public void delete(Long id) {
this.imgFileDao.deleteById(ImgFile.class, id);
}
public Long save(ImgFile imgFile) {
if (!AppUtils.isBlank(imgFile.getFileId())) {
update(imgFile);
return imgFile.getFileId();
}
return (Long) this.imgFileDao.save(imgFile);
}
public void update(ImgFile imgFile) {
this.imgFileDao.update(imgFile);
}
public PageSupport getImgFileList(CriteriaQuery cq) {
return this.imgFileDao.find(cq);
}
public void setImgFileDao(ImgFileDao imgFileDao) {
this.imgFileDao = imgFileDao;
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.VisitLogDao;
import com.legendshop.business.service.VisitLogService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.VisitLog;
import com.legendshop.util.AppUtils;
import java.util.List;
public class VisitLogServiceImpl implements VisitLogService {
private VisitLogDao visitLogDao;
public void setVisitLogDao(VisitLogDao visitLogDao) {
this.visitLogDao = visitLogDao;
}
public List<VisitLog> getVisitLogList(String userName) {
return (List<VisitLog>) this.visitLogDao.findByHQL(
"from VisitLog where userName = ?", new Object[] {userName });
}
public VisitLog getVisitLogById(Long id) {
return (VisitLog) this.visitLogDao.get(VisitLog.class, id);
}
public void delete(Long id) {
this.visitLogDao.deleteById(VisitLog.class, id);
}
public Long save(VisitLog visitLog) {
if (!AppUtils.isBlank(visitLog.getVisitId())) {
update(visitLog);
return visitLog.getVisitId();
}
return (Long) this.visitLogDao.save(visitLog);
}
public void update(VisitLog visitLog) {
this.visitLogDao.update(visitLog);
}
public PageSupport getVisitLogList(CriteriaQuery cq) {
return this.visitLogDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.SystemParameterDao;
import com.legendshop.business.dao.impl.SystemParameterDaoImpl;
import com.legendshop.business.service.SystemParameterService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.SystemParameter;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class SystemParameterServiceImpl implements SystemParameterService {
private static Logger log = LoggerFactory
.getLogger(SystemParameterServiceImpl.class);
private SystemParameterDao systemParameterDao;
@Required
public void setBaseDao(SystemParameterDaoImpl systemParameterDao) {
this.systemParameterDao = systemParameterDao;
}
private List<SystemParameter> list() {
return (List<SystemParameter>) this.systemParameterDao
.findByHQL("from SystemParameter");
}
public SystemParameter getSystemParameter(String id) {
return (SystemParameter) this.systemParameterDao.get(
SystemParameter.class, id);
}
public void delete(String id) {
this.systemParameterDao.deleteById(SystemParameter.class, id);
}
public void save(SystemParameter systemParameter) {
SystemParameter orgin = getSystemParameter(systemParameter.getName());
if (!AppUtils.isBlank(orgin)) {
orgin.setValue(systemParameter.getValue());
update(orgin);
} else {
this.systemParameterDao.saveOrUpdate(systemParameter);
}
}
public void update(SystemParameter systemParameter) {
this.systemParameterDao.update(systemParameter);
}
public PageSupport getSystemParameterList(CriteriaQuery cq) {
return this.systemParameterDao.find(cq);
}
public void initSystemParameter() {
List<SystemParameter> list = list();
for (SystemParameter parameter : list) {
PropertiesUtil.setParameter(parameter, null);
}
log.info("System Parameter size = {}", Integer.valueOf(list.size()));
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.SortDao;
import com.legendshop.business.service.SortService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.model.entity.Sort;
import com.legendshop.util.AppUtils;
import java.util.List;
import org.springframework.beans.factory.annotation.Required;
public class SortServiceImpl implements SortService {
private SortDao sortDao;
public List<Sort> getSortList(String userName) {
return this.sortDao.getSortList(userName);
}
public Sort getSortById(Long id) {
return this.sortDao.getSort(id);
}
public void deleteSort(Long sortId) {
List list = this.sortDao.getProductBySortId(sortId);
if (!AppUtils.isBlank(list)) {
throw new BusinessException("请删除该类型对应的商品", "20");
}
List nsortList = this.sortDao.getNsortBySortId(sortId);
if (!AppUtils.isBlank(nsortList)) {
throw new BusinessException("请删除该类型对应的二级商品类型", "20");
}
this.sortDao.deleteSortById(sortId);
}
public Long save(Sort sort) {
if (!AppUtils.isBlank(sort.getSortId())) {
updateSort(sort);
return sort.getSortId();
}
return this.sortDao.saveSort(sort);
}
public void updateSort(Sort sort) {
this.sortDao.updateSort(sort);
}
public PageSupport getSortList(CriteriaQuery cq) {
return this.sortDao.find(cq);
}
public List<Sort> getSort(String shopName, boolean loadAll) {
return this.sortDao.getSort(shopName, Boolean.valueOf(loadAll));
}
public void delete(Sort sort) {
this.sortDao.deleteSort(sort);
}
@Required
public void setSortDao(SortDao sortDao) {
this.sortDao = sortDao;
}
public List<Sort> getSort(String name, String sortType, boolean loadAll) {
return this.sortDao.getSort(name, sortType, loadAll);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.NewsCategoryDao;
import com.legendshop.business.dao.impl.NewsCategoryDaoImpl;
import com.legendshop.business.service.NewsCategoryService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.NewsCategory;
import com.legendshop.util.AppUtils;
import java.util.List;
public class NewsCategoryServiceImpl implements NewsCategoryService {
private NewsCategoryDao newsCategoryDao;
public void setNewsCategoryDao(NewsCategoryDaoImpl newsCategoryDao) {
this.newsCategoryDao = newsCategoryDao;
}
public List<NewsCategory> getNewsCategoryList(String userName) {
return (List<NewsCategory>) this.newsCategoryDao.findByHQL(
"from NewsCategory where userName = ?", new Object[] {userName });
}
public NewsCategory getNewsCategoryById(Long id) {
return (NewsCategory) this.newsCategoryDao.get(NewsCategory.class, id);
}
public void delete(Long id) {
this.newsCategoryDao.deleteById(NewsCategory.class, id);
}
public Long save(NewsCategory newsCategory) {
if (!AppUtils.isBlank(newsCategory.getNewsCategoryId())) {
update(newsCategory);
return newsCategory.getNewsCategoryId();
}
return (Long) this.newsCategoryDao.save(newsCategory);
}
public void update(NewsCategory newsCategory) {
this.newsCategoryDao.update(newsCategory);
}
public PageSupport getNewsCategoryList(CriteriaQuery cq) {
return this.newsCategoryDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.OrderDao;
import com.legendshop.business.service.OrderService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
public class OrderServiceImpl implements OrderService {
private OrderDao orderDao;
public void setOrderDao(OrderDao orderDao) {
this.orderDao = orderDao;
}
public PageSupport getOrderList(CriteriaQuery cq) {
return this.orderDao.getOrder(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.dao.AskDao;
import com.legendshop.business.service.AskService;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Ask;
import com.legendshop.util.AppUtils;
import java.util.List;
public class AskServiceImpl implements AskService {
private AskDao askDao;
public void setAskDao(AskDao askDao) {
this.askDao = askDao;
}
public List<Ask> getAsk(String userName) {
return this.askDao.getAsk(userName);
}
public Ask getAsk(Long id) {
return this.askDao.getAsk(id);
}
public void deleteAsk(Ask ask) {
this.askDao.deleteAsk(ask);
}
public Long saveAsk(Ask ask) {
if (!AppUtils.isBlank(ask.getAskId())) {
updateAsk(ask);
return ask.getAskId();
}
return (Long) this.askDao.save(ask);
}
public void updateAsk(Ask ask) {
this.askDao.updateAsk(ask);
}
public PageSupport getAsk(CriteriaQuery cq) {
return this.askDao.find(cq);
}
}
| Java |
package com.legendshop.business.service.impl;
import com.legendshop.business.common.download.DownLoadCallBack;
import com.legendshop.business.dao.BusinessDao;
import com.legendshop.business.dao.DownloadLogDao;
import com.legendshop.business.service.DownloadLogService;
import com.legendshop.model.entity.DownloadLog;
import com.legendshop.util.DateUtil;
import java.util.Date;
import org.springframework.beans.factory.annotation.Required;
public class DownloadLogServiceImpl
implements DownLoadCallBack, DownloadLogService {
private DownloadLogDao downloadLogDao;
private BusinessDao businessDao;
private Integer maxTimes;
private Integer interValMinutes;
public boolean checkCanDownload(String ip, String filename) {
if (this.interValMinutes.intValue() >= 0) {
return true;
}
String sql = "select count(*) from DownloadLog where ip = ? and date > ? and fileName = ?";
Long result = (Long) this.downloadLogDao.findUniqueBy(
sql,
Long.class,
new Object[] {
ip,
DateUtil.add(new Date(), 12,
this.interValMinutes.intValue()), filename });
return result.longValue() > this.maxTimes.intValue();
}
public boolean isUserOrderProduct(Long prodId, String userName) {
return this.businessDao.isUserOrderProduct(prodId, userName);
}
public void save(DownloadLog downloadLog) {
this.downloadLogDao.save(downloadLog);
}
public Integer getMaxTimes() {
return this.maxTimes;
}
public void setMaxTimes(Integer maxTimes) {
this.maxTimes = maxTimes;
}
public Integer getInterValMinutes() {
return this.interValMinutes;
}
public void setInterValMinutes(Integer interValMinutes) {
this.interValMinutes = interValMinutes;
}
public void afterDownload(Object entity) {
DownloadLog downloadLog = (DownloadLog) entity;
save(downloadLog);
}
@Required
public void setBusinessDao(BusinessDao businessDao) {
this.businessDao = businessDao;
}
@Required
public void setDownloadLogDao(DownloadLogDao downloadLogDao) {
this.downloadLogDao = downloadLogDao;
}
}
| Java |
package com.legendshop.business.service.dwr.impl;
import com.legendshop.business.service.dwr.OptionService;
import com.legendshop.core.dao.BaseDao;
import com.legendshop.core.exception.ApplicationException;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.util.AppUtils;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class OptionServiceImpl implements OptionService {
private static Logger log = LoggerFactory
.getLogger(OptionServiceImpl.class);
private BaseDao baseDao;
public Map<Object, Object> getLinkedOptionsByHql(String hql) {
try {
List<Object[]> list = (List<Object[]>) this.baseDao.findByHQL(hql);
Map options = null;
if (!AppUtils.isBlank(list)) {
options = new LinkedHashMap(list.size());
for (Object[] objArray : list) {
options.put(objArray[0], objArray[1]);
}
}
return options;
} catch (Exception e) {
log.error("getLinkedOptionsByHql", e);
throw new BusinessException(e,
"invoke getLinkedOptionsByHql error", "15", "998");
}
}
public Map<Object, Object> getLinkedOptionsBySql(String sql) {
try {
List<Object[]> list = (List<Object[]>) this.baseDao.findBySQL(sql);
Map options = null;
if (!AppUtils.isBlank(list)) {
options = new LinkedHashMap(list.size());
for (Object[] objArray : list) {
options.put(objArray[0], objArray[1]);
}
}
return options;
} catch (Exception e) {
log.error("getLinkedOptionsBySql", e);
throw new ApplicationException(e,
"invoke getLinkedOptionsBySql error", "15", "998");
}
}
@Required
public void setBaseDao(BaseDao baseDao) {
this.baseDao = baseDao;
}
}
| Java |
package com.legendshop.business.service.dwr.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONArray;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.servlet.LocaleResolver;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.Constants;
import com.legendshop.business.common.DynamicPropertiesHelper;
import com.legendshop.business.common.MyLeagueEnum;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.business.dao.BrandDao;
import com.legendshop.business.dao.BusinessDao;
import com.legendshop.business.dao.ImgFileDao;
import com.legendshop.business.dao.ProductDao;
import com.legendshop.business.dao.ShopDetailDao;
import com.legendshop.business.dao.SubDao;
import com.legendshop.business.dao.UserDetailDao;
import com.legendshop.business.helper.PageGengrator;
import com.legendshop.business.search.facade.ProductSearchFacade;
import com.legendshop.business.service.AdminService;
import com.legendshop.business.service.PayTypeService;
import com.legendshop.business.service.ScoreService;
import com.legendshop.business.service.dwr.DwrCommonService;
import com.legendshop.core.UserManager;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.ApplicationException;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.randing.CaptchaServiceSingleton;
import com.legendshop.core.randing.RandomStringUtils;
import com.legendshop.model.dynamic.Item;
import com.legendshop.model.dynamic.Model;
import com.legendshop.model.entity.Basket;
import com.legendshop.model.entity.DynamicTemp;
import com.legendshop.model.entity.ImgFile;
import com.legendshop.model.entity.Indexjpg;
import com.legendshop.model.entity.Myleague;
import com.legendshop.model.entity.PayType;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductComment;
import com.legendshop.model.entity.ProductDetail;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.Sub;
import com.legendshop.util.AppUtils;
import com.legendshop.util.Arith;
import com.legendshop.util.converter.ByteConverter;
import com.legendshop.util.des.DES2;
public class DwrCommonServiceImpl implements DwrCommonService {
private static Logger log = LoggerFactory
.getLogger(DwrCommonServiceImpl.class);
private BusinessDao businessDao;
private AdminService adminService;
private UserDetailDao userDetailDao;
private ShopDetailDao shopDetailDao;
private PayTypeService payTypeService;
private ProductSearchFacade productSearchFacade;
private ScoreService scoreService;
private BasketDao basketDao;
private ImgFileDao imgFileDao;
private BrandDao brandDao;
private ProductDao productDao;
private SubDao subDao;
private LocaleResolver localeResolver;
public String getSessionId() {
WebContext webContext = WebContextFactory.get();
Random random = new Random();
String sessionId = "<b>暂无评论</b>";
webContext.getHttpServletRequest().setAttribute("sessionId", sessionId);
return sessionId;
}
public List<Indexjpg> getIndexJpg(String userName) {
return this.imgFileDao.getIndexJpeg(userName);
}
public String deleteSub(Long subId, String userName) {
log.debug("userName {} delete sub {}", userName, subId);
return adminDeleteSub(subId);
}
public String updateSub(Long subId, Integer status, String userName) {
if (userName == null) {
return "fail";
}
Sub sub = this.subDao.getSubById(subId);
if (sub == null) {
return "fail";
}
if ((!sub.getUserName().equals(userName))
&& (!sub.getShopName().equals(userName))
&& (!CommonServiceUtil.haveViewAllDataFunction(WebContextFactory
.get().getHttpServletRequest()))) {
log.warn(
"updateSub:userName {} or shopName {} not equal userName {}",
new Object[] {sub.getUserName(), sub.getShopName(), userName });
return "fail";
}
boolean result = this.subDao.updateSub(sub, status, userName);
if (result) {
return null;
}
return "fail";
}
public String adminDeleteSub(Long subId) {
if (subId == null) {
return "fail";
}
Sub sub = (Sub) this.businessDao.get(Sub.class, subId);
String userName = UserManager.getUsername(WebContextFactory.get()
.getSession());
if ((!CommonServiceUtil.haveViewAllDataFunction(WebContextFactory.get()
.getHttpServletRequest())) && (!sub.getUserName().equals(userName))) {
log.warn("{}, can not delete sub {} does not belongs to you",
userName, subId);
return "fail";
}
boolean result = this.subDao.deleteSub(sub);
if (result) {
return null;
}
return "fail";
}
public String adminChangeSubPrice(Long subId, String totalPrice) {
if ((subId == null) || (totalPrice == null)) {
return "fail";
}
Double price = null;
try {
price = Double.valueOf(totalPrice.trim());
} catch (Exception e) {
return "fail";
}
if ((price == null) || (price.doubleValue() < 0.0D)
|| (price.doubleValue() > 9999999999999.0D)) {
return "fail";
}
Sub sub = (Sub) this.businessDao.get(Sub.class, subId);
String userName = UserManager.getUsername(WebContextFactory.get()
.getSession());
if ((!CommonServiceUtil.haveViewAllDataFunction(WebContextFactory.get()
.getHttpServletRequest()))
&& (!sub.getUserName().equals(userName))
&& (!sub.getShopName().equals(userName))) {
log.warn("can not change sub {} does not belongs to you", subId);
return "fail";
}
boolean result = false;
try {
result = this.subDao.updateSubPrice(sub, userName, price);
} catch (Exception e) {
throw new ApplicationException("更新价格失败", "23");
}
if (result) {
return null;
}
return "fail";
}
public String deleteProduct(Long prodId) {
if (prodId == null) {
return "fail";
}
try {
Product product = this.productDao.getProduct(prodId);
if (product == null) {
log.warn("Product with Id {} does not exists ", prodId);
return "fail";
}
String userName = UserManager.getUsername(WebContextFactory.get()
.getSession());
if ((!CommonServiceUtil.haveViewAllDataFunction(WebContextFactory
.get().getHttpServletRequest()))
&& (!product.getUserName().equals(userName))) {
log.warn("can not delete Id {} does not belongs to you", prodId);
return "fail";
}
this.adminService.deleteById(Product.class, prodId);
String picUrl = RealPathUtil.getBigPicRealPath() + "/"
+ product.getPic();
log.debug("delete Big Image file {}", picUrl);
FileProcessor.deleteFile(picUrl);
String smallPicUrl = RealPathUtil.getSmallPicRealPath() + "/"
+ product.getPic();
log.debug("delete small Image file {}", smallPicUrl);
FileProcessor.deleteFile(smallPicUrl);
List list = this.businessDao.find(
"from RelProduct n where n.prodId = ? and userName = ?",
new Object[] {prodId, product.getUserName() });
if (AppUtils.isNotBlank(list)) {
this.businessDao.deleteAll(list);
}
List<ImgFile> imgFileList = (List<ImgFile>) this.businessDao
.findByHQL(
"from ImgFile where productType = 1 and userName = ? and productId = ? ",
new Object[] {product.getUserName(), prodId });
if (AppUtils.isNotBlank(imgFileList)) {
for (ImgFile imgFile : imgFileList) {
String imgFileUrl = RealPathUtil.getBigPicRealPath() + "/"
+ imgFile.getFilePath();
log.debug("delete Big imgFileUrl file {}", imgFileUrl);
FileProcessor.deleteFile(imgFileUrl);
this.businessDao.delete(imgFile);
}
}
this.businessDao
.exeByHQL(
"delete from ProductComment where prodId = ? and ownerName = ?",
new Object[] {prodId, product.getUserName() });
this.productSearchFacade.delete(product);
this.adminService.updateShopDetail(product);
return null;
} catch (Exception e) {
log.error("", e);
}
return "fail";
}
public String productTurnOn(Long prodId) {
if (prodId == null)
return "fail";
try {
if (this.adminService.updateProdOnline(prodId)) {
return null;
}
return "fail";
} catch (Exception e) {
log.error("", e);
}
return "fail";
}
public String imgFileOnline(Long fileId) {
if (fileId == null)
return "fail";
try {
if (this.adminService.updateImgFileOnline(fileId)) {
return null;
}
return "fail";
} catch (Exception e) {
log.error("deleteProd", e);
}
return "fail";
}
public String productTurnOff(Long prodId) {
if (prodId == null)
return "fail";
try {
if (this.adminService.updateProdOffline(prodId)) {
return null;
}
return "fail";
} catch (Exception e) {
log.error("", e);
}
return "fail";
}
public String imgFileOffline(Long fileId) {
if (fileId == null)
return "fail";
try {
if (this.adminService.updateImgFileOffline(fileId)) {
return null;
}
return "fail";
} catch (Exception e) {
log.error("", e);
}
return "fail";
}
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
public boolean isUserExist(String userName) {
return this.userDetailDao.isUserExist(userName);
}
public boolean isEmailExist(String email) {
return this.userDetailDao.isEmailExist(email);
}
public String deleteUserDetail(String userId, String userName) {
if (userId == null)
return "fail";
try {
return this.adminService.deleteUserDetail(userId, userName,
RealPathUtil.getBigPicRealPath(),
RealPathUtil.getSmallPicRealPath());
} catch (Exception e) {
log.error("deleteUserDetail", e);
}
return "fail";
}
public List<Model> loadDynamicAttribute(Long prodId, String userName) {
List list = new ArrayList();
Product product = this.adminService.getProd(prodId, userName);
if ((AppUtils.isNotBlank(product))
&& (AppUtils.isNotBlank(product.getAttribute()))) {
list = JSONArray.fromObject(product.getAttribute());
}
return list;
}
public List<Model> loadDynamicAttributeFromTemp(Long tempId, String userName) {
List list = new ArrayList();
DynamicTemp temp = this.adminService.getDynamicTemp(tempId, userName);
if ((AppUtils.isNotBlank(temp))
&& (AppUtils.isNotBlank(temp.getContent()))) {
list = JSONArray.fromObject(temp.getContent());
}
return list;
}
public boolean saveDynamic(Long prodId, String userName, Short type,
Model[] model) {
if (model != null) {
JSONArray json = JSONArray.fromObject(model);
String result = json.toString();
if (AppUtils.isNotBlank(result)) {
Product product = this.adminService.getProd(prodId, userName);
if ((type != null)
&& (type.equals(Constants.HW_TEMPLATE_ATTRIBUTE)))
product.setAttribute(result);
else {
product.setParameter(result);
}
this.adminService.updateProd(product);
}
}
return true;
}
public boolean saveDynamicTemp(String tempName, String userName,
Short type, Model[] model) {
boolean result = true;
if (model != null) {
JSONArray json = JSONArray.fromObject(model);
result = this.adminService.saveDynamicTemp(tempName, userName,
type, json.toString());
}
return result;
}
public boolean updateDynamicTemp(Long tempId, String userName, Short type,
Model[] model) {
boolean result = true;
if (model != null) {
JSONArray json = JSONArray.fromObject(model);
result = this.adminService.updateDynamicTemp(tempId, userName,
type, json.toString());
}
return result;
}
public boolean deleteDynamicTemp(Long tempId, String userName) {
String name = UserManager.getUsername(WebContextFactory.get()
.getSession());
if ((!CommonServiceUtil.haveViewAllDataFunction(WebContextFactory.get()
.getHttpServletRequest())) && (!userName.equals(name))) {
log.warn(
"can not delete DynamicTemp Id = {} does not belongs to you, userName = {}",
tempId, userName);
return false;
}
return this.adminService.deleteDynamicTemp(tempId, userName);
}
public Integer addMyLeague(String userName, String shopName, String sitename) {
if ((AppUtils.isBlank(userName)) || (AppUtils.isBlank(shopName))) {
return MyLeagueEnum.ERROR.value();
}
if (userName.equals(shopName)) {
return MyLeagueEnum.THESAME.value();
}
Myleague myleague = this.shopDetailDao.getMyleague(userName, shopName);
if (!AppUtils.isBlank(myleague)) {
return MyLeagueEnum.DONE.value();
}
myleague = new Myleague();
myleague.setAddtime(new Date());
myleague.setFriendId(shopName);
myleague.setStatus(MyLeagueEnum.ONGOING.value());
myleague.setFriendName(sitename);
myleague.setUserId(userName);
this.shopDetailDao.saveMyleague(myleague);
return MyLeagueEnum.ONGOING.value();
}
public String answerWord(Long id, String answer) {
String loginName = UserManager.getUsername(WebContextFactory.get()
.getSession());
if ((id == null) || (loginName == null)) {
return "fail";
}
boolean result = this.businessDao.updateUserComment(id, answer,
loginName);
if (result) {
return null;
}
return "fail";
}
public Map<String, String> changeRandImg() {
Map map = new HashMap();
DES2 des = new DES2();
String ra = RandomStringUtils.random(4, true, true);
String randStr = ByteConverter.encode(des.byteToString(des
.createEncryptor(ra)));
map.put("rand", ra);
map.put("randStr", randStr);
WebContext webContext = WebContextFactory.get();
webContext.getSession().setAttribute("randNum", ra);
return map;
}
public String auditShop(String loginUserName, String storeName,
Long shopId, Integer status) {
if (storeName == null) {
return "fail";
}
ShopDetail shopDetail = (ShopDetail) this.businessDao.get(
ShopDetail.class, shopId);
if (shopDetail != null) {
if ((!loginUserName.equals(shopDetail.getStoreName()))
&& (!CommonServiceUtil
.haveViewAllDataFunction(WebContextFactory.get()
.getHttpServletRequest()))) {
throw new BusinessException(loginUserName + "you can not edit "
+ shopDetail.getStoreName()
+ "'s data if you are not a admin", "12");
}
boolean result = this.adminService.updateShop(loginUserName,
storeName, shopDetail, status);
if (result) {
return null;
}
return "fail";
}
return "fail";
}
public List<Item> getUsableBrand(Long nsortId, String userName) {
List list = new ArrayList();
try {
list = this.brandDao.getUsableBrand(nsortId, userName);
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public List<Item> getUsableBrandByName(Long nsortId, String userName,
String brandName) {
return this.brandDao.getUsableBrandByName(nsortId, userName, brandName);
}
public List<Item> getUsedBrand(Long nsortId, String userName) {
return this.brandDao.getUsedBrand(nsortId, userName);
}
public List<Item> getUsedProductItem(Long prodId, String userName) {
List list = this.brandDao.getUsedProd(prodId, userName);
return list;
}
public List<Item> getUsableProductItemByName(Long prodId, String userName,
String prodName) {
return this.brandDao.getUsableProductItemByName(prodId, userName,
prodName);
}
public List<Item> getUsableProductItem(Long prodId, String userName) {
return this.brandDao.getUsableProductItem(prodId, userName);
}
public String saveBrandItem(String idJson, String nameJson, Long nsortId,
String userName) {
JSONArray array = JSONArray.fromObject(idJson);
return this.adminService.saveBrandItem(array, nsortId, userName);
}
public String saveProdItem(String idJson, String nameJson, Long prodId,
String userName) {
JSONArray arrayId = JSONArray.fromObject(idJson);
JSONArray arrayName = JSONArray.fromObject(nameJson);
return this.adminService.saveProdItem(arrayId, arrayName, prodId,
userName);
}
@Required
public void setBusinessDao(BusinessDao businessDao) {
this.businessDao = businessDao;
}
@Required
public void setUserDetailDao(UserDetailDao userDetailDao) {
this.userDetailDao = userDetailDao;
}
@Required
public void setShopDetailDao(ShopDetailDao shopDetailDao) {
this.shopDetailDao = shopDetailDao;
}
public Map addtocart(String userName, String shopName, Long prodId,
String pic, String prodName, Double cash, Double carriage,
Integer count, String attribute) {
Map map = new HashMap();
if (prodId == null) {
return map;
}
if (attribute == null) {
attribute = "";
}
if (count == null) {
count = Integer.valueOf(1);
}
boolean canAddToCart = true;
Product product = this.productDao.getProduct(prodId);
if ((product == null)
|| ((product.getStocks() != null) && (product.getStocks()
.intValue() < count.intValue()))) {
canAddToCart = false;
}
if (AppUtils.isBlank(userName)) {
WebContext webContext = WebContextFactory.get();
Map basketMap = (Map) webContext.getSession().getAttribute(
"BASKET_KEY");
if (basketMap == null) {
if (canAddToCart) {
basketMap = new HashMap();
Basket b = new Basket();
b.setProdId(prodId);
b.setUserName(userName);
b.setBasketCount(count);
b.setProdName(prodName);
b.setCash(cash);
b.setPic(pic);
b.setAttribute(attribute);
b.setCarriage(carriage);
b.setBasketDate(new Date());
b.setBasketCheck("N");
b.setShopName(shopName);
basketMap.put(getBasketKey(shopName, prodId, attribute), b);
webContext.getSession().setAttribute("BASKET_KEY",
basketMap);
map.put("BASKET_COUNT", Integer.valueOf(1));
Double totalCash = Double.valueOf(Arith.mul(
count.intValue(), cash.doubleValue()));
if (carriage != null) {
totalCash = Double.valueOf(Arith.add(
totalCash.doubleValue(), carriage.doubleValue()));
}
map.put("BASKET_TOTAL_CASH", totalCash);
} else {
map.put("BASKET_COUNT", Integer.valueOf(0));
map.put("BASKET_TOTAL_CASH", Integer.valueOf(0));
}
} else {
if (canAddToCart) {
Basket b = (Basket) basketMap.get(getBasketKey(shopName,
prodId, attribute));
if (b == null) {
b = new Basket();
b.setProdId(prodId);
b.setUserName(userName);
b.setBasketCount(count);
b.setProdName(prodName);
b.setCash(cash);
b.setAttribute(attribute);
b.setCarriage(carriage);
b.setBasketDate(new Date());
b.setBasketCheck("N");
b.setShopName(shopName);
basketMap.put(
getBasketKey(shopName, prodId, attribute), b);
webContext.getSession().setAttribute("BASKET_KEY",
basketMap);
} else if ((product.getStocks() != null)
&& (product.getStocks().intValue() < b.getBasketCount()
.intValue() + count.intValue())) {
canAddToCart = false;
} else {
b.setBasketCount(Integer.valueOf(b.getBasketCount()
.intValue() + count.intValue()));
basketMap.put(
getBasketKey(shopName, prodId, attribute), b);
webContext.getSession().setAttribute("BASKET_KEY",
basketMap);
}
}
map.put("BASKET_COUNT", Integer.valueOf(basketMap.size()));
map.put("BASKET_TOTAL_CASH",
CommonServiceUtil.calculateTotalCash(basketMap));
}
} else {
if (canAddToCart) {
canAddToCart = this.basketDao.saveToCart(prodId, pic, userName,
shopName, count, attribute, prodName, cash, carriage);
}
List baskets = this.basketDao.getBasketByuserName(userName);
Double totalcash = CommonServiceUtil.calculateTotalCash(baskets);
if (totalcash == null) {
totalcash = Double.valueOf(0.0D);
}
map.put("BASKET_COUNT", Integer.valueOf(baskets.size()));
map.put("BASKET_TOTAL_CASH", totalcash);
}
map.put("PRODUCT_LESS", Boolean.valueOf(!canAddToCart));
return map;
}
public void payToOrder(Long subId, String shopName, Integer payTypeId) {
if (AppUtils.isNotBlank(subId)) {
Sub sub = this.subDao.getSubById(subId);
PayType payType = this.payTypeService.getPayTypeByIdAndName(
shopName, payTypeId);
if (payType != null) {
sub.setPayTypeName(payType.getPayTypeName());
sub.setPayTypeId(payType.getPayTypeId());
sub.setPayId(payType.getPayId());
sub.setPayDate(new Date());
this.businessDao.update(sub);
}
}
}
private String getBasketKey(String shopName, Long prodId, String attribute) {
StringBuffer sb = new StringBuffer();
sb.append(shopName).append(prodId).append(AppUtils.getCRC32(attribute));
return sb.toString();
}
@Required
public void setPayTypeService(PayTypeService payTypeService) {
this.payTypeService = payTypeService;
}
public String resetPassword(String userName, String mail) {
if ((AppUtils.isBlank(userName)) || (AppUtils.isBlank(mail)))
return "fail";
try {
WebContext webContext = WebContextFactory.get();
String templateFilePath = webContext.getSession()
.getServletContext().getRealPath("/")
+ "/system/mailTemplate/resetpassmail.jsp";
if (this.adminService.updatePassword(userName, mail,
templateFilePath)) {
return null;
}
return "fail";
} catch (Exception e) {
log.error("", e);
}
return "fail";
}
public String addProdcutComment(Long prodId, String content) {
String userName = UserManager.getUsername(WebContextFactory.get()
.getSession());
String validation = validateComment(prodId, userName);
if (validation != null) {
return validation;
}
ProductComment productComment = new ProductComment();
productComment.setUserName(userName == null ? "anonymous"
: userName);
productComment.setAddtime(new Date());
productComment.setContent(content);
productComment.setProdId(prodId);
Product product = this.productDao.getProduct(prodId);
productComment.setOwnerName(product.getUserName());
HttpServletRequest request = WebContextFactory.get()
.getHttpServletRequest();
productComment.setPostip(request.getRemoteAddr());
this.businessDao.save(productComment);
String curPageNO = request.getParameter("curPageNO");
return getgetProductCommentHtml(request, prodId, curPageNO);
}
private String validateComment(Long prodId, String userName) {
String level = (String) PropertiesUtil.getObject(
ParameterEnum.COMMENT_LEVEL, String.class);
if ("LOGONED_COMMENT".equals(level)) {
if (AppUtils.isBlank(userName))
return "NOLOGON";
} else if ("BUYED_COMMENT".equals(level)) {
if (AppUtils.isBlank(userName)) {
return "NOLOGON";
}
if (!this.businessDao.isUserOrderProduct(prodId, userName))
return "NOBUYED";
} else if ("NO_COMMENT".equals(level)) {
return "NOCOMMENT";
}
return null;
}
public String getProductComment(Long prodId, String curPageNO) {
HttpServletRequest request = WebContextFactory.get()
.getHttpServletRequest();
return getgetProductCommentHtml(request, prodId, curPageNO);
}
private String getgetProductCommentHtml(HttpServletRequest request,
Long prodId, String curPageNO) {
Locale locale = this.localeResolver.resolveLocale(request);
if (locale == null)
locale = Locale.CHINA;
try {
CriteriaQuery cq = new CriteriaQuery(ProductComment.class,
curPageNO);
cq.setCurPage(curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue());
cq.addOrder("desc", "addtime");
cq.eq("prodId", prodId);
cq.add();
PageSupport ps = this.productDao.getProdDetail(cq);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
Map map = new HashMap();
List list = ps.getResultList();
map.put("productCommentList", list);
if (AppUtils.isNotBlank(list)) {
String userName = UserManager.getUsername(request);
if (((ProductComment) list.get(0)).getOwnerName().equals(
userName)) {
map.put("owner", Boolean.valueOf(true));
}
}
if (ps.hasMutilPage()) {
map.put("toolBar", ps.getToolBar(locale, "SimplePageProvider"));
}
map.put("totalProductComment", Long.valueOf(ps.getTotal()));
return PageGengrator.getInstance().crateHTML(
request.getSession().getServletContext(), "productComment.ftl",
map, locale);
} catch (Exception e) {
log.error("getProductComment", e);
}
return "FAIL";
}
public String queryParameter(Long prodId) {
HttpServletRequest request = WebContextFactory.get()
.getHttpServletRequest();
Locale locale = this.localeResolver.resolveLocale(request);
ProductDetail prod = (ProductDetail) request.getAttribute("prod");
String parameter = null;
if (prod != null)
parameter = prod.getParameter();
else {
parameter = this.adminService.getProdParameter(prodId);
}
Map map = new HashMap();
if (AppUtils.isNotBlank(parameter)) {
List modelList = JSONArray.fromObject(parameter);
DynamicPropertiesHelper helper = new DynamicPropertiesHelper();
map.put("dynamicProperties", "<table class='goodsAttributeTable'>"
+ helper.gerenateHTML(modelList) + "</table>");
return PageGengrator.getInstance().crateHTML(
request.getSession().getServletContext(), "showdynamic.ftl",
map, locale);
}
return "";
}
public Integer deleteFile(String filePath) {
String realPath = RealPathUtil.getFCKRealPath(filePath);
int result = FileProcessor.deleteFile(realPath);
return Integer.valueOf(result);
}
@Required
public void setProductSearchFacade(ProductSearchFacade productSearchFacade) {
this.productSearchFacade = productSearchFacade;
}
public Map<String, Object> userScore(Long subId, Long score) {
Sub sub = this.subDao.getSubById(subId);
if (sub == null) {
return null;
}
return this.scoreService.useScore(sub, score);
}
public Double calMoney(Long score) {
return this.scoreService.calMoney(score);
}
@Required
public void setScoreService(ScoreService scoreService) {
this.scoreService = scoreService;
}
@Required
public void setBasketDao(BasketDao basketDao) {
this.basketDao = basketDao;
}
@Required
public void setImgFileDao(ImgFileDao imgFileDao) {
this.imgFileDao = imgFileDao;
}
@Required
public void setBrandDao(BrandDao brandDao) {
this.brandDao = brandDao;
}
@Required
public void setProductDao(ProductDao productDao) {
this.productDao = productDao;
}
@Required
public void setSubDao(SubDao subDao) {
this.subDao = subDao;
}
@Required
public void setLocaleResolver(LocaleResolver localeResolver) {
this.localeResolver = localeResolver;
}
public boolean validateRandImg(String validateCodeParameter) {
if (((Boolean) PropertiesUtil.getObject(ParameterEnum.VALIDATION_IMAGE,
Boolean.class)).booleanValue()) {
WebContext webContext = WebContextFactory.get();
boolean result = CaptchaServiceSingleton
.getInstance()
.validateResponseForID(webContext.getSession().getId(),
validateCodeParameter).booleanValue();
return result;
}
throw new BusinessException("not support VALIDATION_IMAGE", "00");
}
}
| Java |
package com.legendshop.business.service.dwr;
import java.util.Map;
public abstract interface OptionService {
public abstract Map<Object, Object> getLinkedOptionsByHql(String paramString);
public abstract Map<Object, Object> getLinkedOptionsBySql(String paramString);
}
| Java |
package com.legendshop.business.service.dwr;
import com.legendshop.util.AppUtils;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class DwrRequestParser {
private static Logger loger = Logger.getLogger(DwrRequestParser.class);
private final String xmlsource;
private Document doc = null;
private final Map map = new HashMap();
public DwrRequestParser(String xmlsource) {
this.xmlsource = xmlsource;
if ((this.xmlsource != null) && (!this.xmlsource.trim().equals("")))
parseXml();
}
public List getParams(String paramName) {
List retList = new ArrayList();
Element root = getRoot();
List list = root.getChildren();
for (int i = 0; i < (list == null ? 0
: list.size()); i++) {
Element paramElement = (Element) list.get(i);
String name = paramElement.getAttributeValue("name");
if (name.equals(paramName)) {
retList.add(paramElement.getAttributeValue("value"));
}
}
return retList;
}
public void setParam(String key, Object value) {
this.map.put(key, value);
}
public List getKeys() {
List retList = new ArrayList();
Element root = getRoot();
List list = root.getChildren();
for (int i = 0; i < (list == null ? 0
: list.size()); i++) {
Element paramElement = (Element) list.get(i);
String name = paramElement.getAttributeValue("name");
if (!retList.contains(name)) {
retList.add(name);
}
}
return retList;
}
public String getParam(String paramName) {
Object obj = this.map.get(paramName);
if (!AppUtils.isBlank(obj)) {
return obj.toString();
}
Element root = getRoot();
List list = root.getChildren();
for (int i = 0; i < (list == null ? 0
: list.size()); i++) {
Element paramElement = (Element) list.get(i);
String name = paramElement.getAttributeValue("name");
if (name.equals(paramName)) {
return paramElement.getAttributeValue("value");
}
}
return null;
}
public String getParam(String paramName, int index) {
Element root = getRoot();
List list = root.getChildren();
int flag = 0;
for (int i = 0; i < (list == null ? 0
: list.size()); i++) {
Element paramElement = (Element) list.get(i);
String name = paramElement.getAttributeValue("name");
if (name.equals(paramName)) {
flag++;
if (flag == index) {
return paramElement.getAttributeValue("value");
}
}
}
return null;
}
public String getPlainParam() {
return this.xmlsource;
}
private void parseXml() {
try {
SAXBuilder builder = new SAXBuilder();
this.doc = builder.build(new StringReader(this.xmlsource));
} catch (JDOMException e) {
loger.debug("解析XML发生异常");
} catch (IOException e) {
e.printStackTrace();
}
}
private Element getRoot() {
if (this.doc == null)
parseXml();
Element root = this.doc.getRootElement();
return root;
}
public static void main(String[] args) {
String test = "<request><param name='name1' value='value1'/><param name='namen' value='valuen'/></request>";
DwrRequestParser xml = new DwrRequestParser(test);
}
}
| Java |
package com.legendshop.business.service.dwr;
import com.legendshop.util.StringUtil;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.directwebremoting.convert.BaseV20Converter;
import org.directwebremoting.dwrp.SimpleOutboundVariable;
import org.directwebremoting.extend.InboundContext;
import org.directwebremoting.extend.InboundVariable;
import org.directwebremoting.extend.MarshallException;
import org.directwebremoting.extend.OutboundContext;
import org.directwebremoting.extend.OutboundVariable;
public class CalendarConverter extends BaseV20Converter {
private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
private Date converToDate(String dateString) throws ParseException {
if (StringUtil.isNotEmpty(dateString)) {
return df.parse(dateString);
}
return null;
}
public Object convertInbound(Class clazz, InboundVariable inboundVariable,
InboundContext inboundContext) throws MarshallException {
if (Calendar.class.equals(clazz)) {
try {
Calendar ca = Calendar.getInstance();
ca.setTime(converToDate(inboundVariable.getValue()));
return ca;
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
public OutboundVariable convertOutbound(Object object,
OutboundContext outboundVariable) throws MarshallException {
String returnValue = null;
if ((object instanceof Calendar)) {
Calendar calendar = (Calendar) object;
returnValue = df.format(calendar.getTime());
}
return new SimpleOutboundVariable(returnValue, outboundVariable, true);
}
}
| Java |
package com.legendshop.business.service.dwr;
import com.legendshop.business.service.AdminService;
import com.legendshop.model.dynamic.Item;
import com.legendshop.model.dynamic.Model;
import com.legendshop.model.entity.Indexjpg;
import java.util.List;
import java.util.Map;
public abstract interface DwrCommonService {
public abstract String getSessionId();
public abstract List<Indexjpg> getIndexJpg(String paramString);
public abstract String deleteSub(Long paramLong, String paramString);
public abstract String updateSub(Long paramLong, Integer paramInteger,
String paramString);
public abstract String adminDeleteSub(Long paramLong);
public abstract String adminChangeSubPrice(Long paramLong,
String paramString);
public abstract String deleteProduct(Long paramLong);
public abstract String productTurnOn(Long paramLong);
public abstract String imgFileOnline(Long paramLong);
public abstract String productTurnOff(Long paramLong);
public abstract String imgFileOffline(Long paramLong);
public abstract void setAdminService(AdminService paramAdminService);
public abstract boolean isUserExist(String paramString);
public abstract boolean isEmailExist(String paramString);
public abstract String deleteUserDetail(String paramString1,
String paramString2);
public abstract List<Model> loadDynamicAttribute(Long paramLong,
String paramString);
public abstract List<Model> loadDynamicAttributeFromTemp(Long paramLong,
String paramString);
public abstract boolean saveDynamic(Long paramLong, String paramString,
Short paramShort, Model[] paramArrayOfModel);
public abstract boolean saveDynamicTemp(String paramString1,
String paramString2, Short paramShort, Model[] paramArrayOfModel);
public abstract boolean updateDynamicTemp(Long paramLong,
String paramString, Short paramShort, Model[] paramArrayOfModel);
public abstract boolean deleteDynamicTemp(Long paramLong, String paramString);
public abstract Integer addMyLeague(String paramString1,
String paramString2, String paramString3);
public abstract String answerWord(Long paramLong, String paramString);
public abstract Map<String, String> changeRandImg();
public abstract boolean validateRandImg(String paramString);
public abstract String auditShop(String paramString1, String paramString2,
Long paramLong, Integer paramInteger);
public abstract List<Item> getUsableBrand(Long paramLong, String paramString);
public abstract List<Item> getUsableBrandByName(Long paramLong,
String paramString1, String paramString2);
public abstract List<Item> getUsedBrand(Long paramLong, String paramString);
public abstract List<Item> getUsedProductItem(Long paramLong,
String paramString);
public abstract List<Item> getUsableProductItemByName(Long paramLong,
String paramString1, String paramString2);
public abstract List<Item> getUsableProductItem(Long paramLong,
String paramString);
public abstract String saveBrandItem(String paramString1,
String paramString2, Long paramLong, String paramString3);
public abstract String saveProdItem(String paramString1,
String paramString2, Long paramLong, String paramString3);
public abstract Map addtocart(String paramString1, String paramString2,
Long paramLong, String paramString3, String paramString4,
Double paramDouble1, Double paramDouble2, Integer paramInteger,
String paramString5);
public abstract void payToOrder(Long paramLong, String paramString,
Integer paramInteger);
public abstract String resetPassword(String paramString1,
String paramString2);
public abstract String addProdcutComment(Long paramLong, String paramString);
public abstract String getProductComment(Long paramLong, String paramString);
public abstract String queryParameter(Long paramLong);
public abstract Integer deleteFile(String paramString);
public abstract Map<String, Object> userScore(Long paramLong1,
Long paramLong2);
public abstract Double calMoney(Long paramLong);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.model.entity.DynamicTemp;
import com.legendshop.model.entity.News;
import com.legendshop.model.entity.Nsort;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.Sort;
import java.io.Serializable;
import java.util.List;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import org.apache.oro.text.regex.MalformedPatternException;
public abstract interface AdminService extends BaseService {
public abstract void saveNews(News paramNews);
public abstract News getNewsById(Long paramLong);
public abstract PageSupport getDataByCQ(CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getDataByCriteriaQuery(
CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getDataByCriteriaQuery(SqlQuery paramSqlQuery);
public abstract PageSupport getDataByCriteriaQueryMap(SqlQuery paramSqlQuery);
public abstract PageSupport getUserDetailList(HqlQuery paramHqlQuery,
HttpServletRequest paramHttpServletRequest);
public abstract void deleteSort(Long paramLong);
public abstract Sort getSort(Long paramLong);
public abstract void saveSort(Sort paramSort);
public abstract void saveNsort(Nsort paramNsort);
public abstract void deleteNsort(Long paramLong);
public abstract void deleteNsort(Nsort paramNsort);
public abstract Nsort getNsort(Long paramLong);
public abstract void saveOrUpdate(Object paramObject);
public abstract void updateProd(Product paramProduct);
public abstract <T> void deleteById(Class<T> paramClass,
Serializable paramSerializable);
public abstract <T> T get(Class<T> paramClass,
Serializable paramSerializable);
public abstract boolean updateProdOnline(Long paramLong);
public abstract boolean updateProdOffline(Long paramLong);
public abstract String deleteUserDetail(String paramString1,
String paramString2, String paramString3, String paramString4);
public abstract Long getIndexJpgNum(String paramString);
public abstract PageSupport getDataByHQL(HqlQuery paramHqlQuery);
public abstract PageSupport getDataBySQL(SqlQuery paramSqlQuery);
public abstract PageSupport getDataBySQL(HqlQuery paramHqlQuery);
public abstract boolean updateShop(String paramString1,
String paramString2, ShopDetail paramShopDetail, Integer paramInteger);
public abstract String saveBrandItem(List<String> paramList,
Long paramLong, String paramString);
public abstract boolean updateImgFileOnline(Long paramLong);
public abstract boolean updateImgFileOffline(Long paramLong);
public abstract Product getProd(Long paramLong, String paramString);
public abstract String getAttributeprodAttribute(Long paramLong);
public abstract String getProdParameter(Long paramLong);
public abstract boolean saveDynamicTemp(String paramString1,
String paramString2, Short paramShort, String paramString3);
public abstract boolean updateDynamicTemp(Long paramLong,
String paramString1, Short paramShort, String paramString2);
public abstract DynamicTemp getDynamicTemp(Long paramLong,
String paramString);
public abstract boolean deleteDynamicTemp(Long paramLong, String paramString);
public abstract String saveProdItem(List<String> paramList1,
List<String> paramList2, Long paramLong, String paramString);
public abstract boolean updatePassword(String paramString1,
String paramString2, String paramString3)
throws MalformedPatternException, MessagingException;
public abstract void updateShopDetail(Product paramProduct);
}
| Java |
package com.legendshop.business.service.timer.impl;
import com.legendshop.business.service.timer.HouseKeepService;
public class HouseKeepServiceImpl
implements HouseKeepService
{
public void turnOffBasket()
{
}
public void turnOffShop()
{
}
}
| Java |
package com.legendshop.business.service.timer.impl;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.OrderStatusEnum;
import com.legendshop.business.common.PayTypeEnum;
import com.legendshop.business.common.SubForm;
import com.legendshop.business.common.SubStatusEnum;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.business.dao.SubDao;
import com.legendshop.business.service.PayTypeService;
import com.legendshop.business.service.timer.SubService;
import com.legendshop.model.entity.Basket;
import com.legendshop.model.entity.PayType;
import com.legendshop.model.entity.Sub;
import com.legendshop.util.AppUtils;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
public class SubServiceImpl
implements SubService
{
private static Logger log = LoggerFactory.getLogger(SubServiceImpl.class);
private SubDao subDao;
private BasketDao basketDao;
private PayTypeService payTypeService;
private Integer commitInteval = Integer.valueOf(100);
private Integer expireDate = Integer.valueOf(-30);
public void finishUnAcklodge()
{
Date date = getDate(this.expireDate.intValue());
log.debug("finishUnAcklodge,date = {}", date);
boolean haveValue = true;
while (haveValue) {
List<Sub> list = this.subDao.getUnAcklodgeSub(this.commitInteval.intValue(), date);
log.debug("finishUnAcklodge,list = {}", list);
if (AppUtils.isBlank(list)) {
haveValue = false;
} else {
for (Sub sub : list) {
this.subDao.saveSubHistory(sub, SubStatusEnum.ORDER_OVER_TIME.value());
sub.setStatus(OrderStatusEnum.SUCCESS.value());
sub.setSubCheck("Y");
sub.setUpdateDate(new Date());
this.subDao.update(sub);
}
this.subDao.flush();
}
}
}
public void finishUnPay()
{
Date date = getDate(this.expireDate.intValue());
log.debug("finishUnPay,date = {}", date);
boolean haveValue = true;
while (haveValue) {
List<Sub> list = this.subDao.getFinishUnPay(this.commitInteval.intValue(), date);
log.debug("finishUnPay,list = {}", list);
if (AppUtils.isBlank(list)) {
haveValue = false;
} else {
for (Sub sub : list) {
this.subDao.saveSubHistory(sub, SubStatusEnum.ORDER_OVER_TIME.value());
sub.setStatus(OrderStatusEnum.CLOSE.value());
sub.setSubCheck("Y");
sub.setUpdateDate(new Date());
this.subDao.update(sub);
}
this.subDao.flush();
}
}
}
public void removeOverTimeBasket()
{
Date date = getDate(this.expireDate.intValue());
this.subDao.deleteOverTimeBasket(date);
}
private Date getDate(int days)
{
Date myDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(myDate);
cal.add(5, days);
return cal.getTime();
}
@Required
public void setSubDao(SubDao subDao)
{
this.subDao = subDao;
}
public void setCommitInteval(Integer commitInteval)
{
this.commitInteval = commitInteval;
}
public void setExpireDate(Integer expireDate)
{
this.expireDate = expireDate;
}
public List<Sub> saveSub(SubForm form)
{
List subList = new ArrayList();
Map<String,List<Basket>> basketMap = this.basketDao.getBasketByuserNameGroupByShopName(form.getUserName());
if (!AppUtils.isBlank(basketMap)) {
for (List<Basket> baskets : basketMap.values()) {
String subNember = CommonServiceUtil.getSubNember(form.getUserName());
String basketId = "";
String prodName = "";
for (Basket backet : baskets) {
basketId = basketId + backet.getBasketId() + ",";
prodName = prodName + backet.getProdName() + ",";
Basket basket = this.basketDao.getBasketById(backet.getBasketId());
if (basket != null) {
basket.setSubNumber(subNember);
basket.setBasketCheck("Y");
basket.setLastUpdateDate(new Date());
this.basketDao.updateBasket(basket);
this.basketDao.saveStocks(basket.getProdId(), basket.getBasketCount());
}
}
if (!AppUtils.isBlank(basketId)) {
basketId = basketId.substring(0, basketId.length() - 1);
}
if (!AppUtils.isBlank(prodName)) {
if (prodName.length() <= 1024)
prodName = prodName.substring(0, prodName.length() - 1);
else {
prodName = prodName.substring(0, 1021) + "...";
}
}
Sub bo = makeSub(form);
bo.setBasketId(basketId);
bo.setSubNumber(subNember);
bo.setTotal(CommonServiceUtil.calculateTotalCash(baskets));
bo.setActualTotal(bo.getTotal());
bo.setShopName(((Basket)baskets.get(0)).getShopName());
bo.setStatus(OrderStatusEnum.UNPAY.value());
List payTypeList = this.payTypeService.getPayTypeList(((Basket)baskets.get(0)).getShopName());
if ((payTypeList != null) && (payTypeList.size() == 1)) {
PayType payType = (PayType)payTypeList.get(0);
if (payType.getPayTypeId().equals(PayTypeEnum.PAY_AT_GOODS_ARRIVED.value())) {
bo.setPayId(payType.getPayId());
bo.setPayDate(new Date());
bo.setPayTypeId(payType.getPayTypeId());
bo.setPayTypeName(payType.getPayTypeName());
}
}
bo.setProdName(prodName);
this.subDao.saveSub(bo);
bo.setBasket(baskets);
bo.setPayType(payTypeList);
subList.add(bo);
}
}
return subList;
}
public List<Basket> getBasketBySubNumber(String subNumber)
{
return this.subDao.getBasketBySubNumber(subNumber);
}
private Sub makeSub(SubForm form)
{
Sub sub = new Sub();
sub.setUserName(form.getUserName());
sub.setSubDate(new Date());
sub.setSubTel(form.getUserTel());
sub.setSubPost(form.getUserPostcode());
sub.setSubMail(form.getUserMail());
sub.setSubAdds(form.getUserAdds());
sub.setPayId(form.getPayType());
sub.setOther(form.getOther());
sub.setSubCheck("N");
sub.setOrderName(form.getOrderName());
return sub;
}
@Required
public void setBasketDao(BasketDao basketDaoImpl)
{
this.basketDao = basketDaoImpl;
}
@Required
public void setPayTypeService(PayTypeService payTypeService)
{
this.payTypeService = payTypeService;
}
public Sub getSubBySubNumber(String subNumber)
{
return this.subDao.getSubBySubNumber(subNumber);
}
}
| Java |
package com.legendshop.business.service.timer;
import com.legendshop.business.common.SubForm;
import com.legendshop.model.entity.Basket;
import com.legendshop.model.entity.Sub;
import java.util.List;
public abstract interface SubService {
public abstract void finishUnPay();
public abstract void finishUnAcklodge();
public abstract void removeOverTimeBasket();
public abstract List<Sub> saveSub(SubForm paramSubForm);
public abstract List<Basket> getBasketBySubNumber(String paramString);
public abstract Sub getSubBySubNumber(String paramString);
}
| Java |
package com.legendshop.business.service.timer;
public abstract interface HouseKeepService {
public abstract void turnOffShop();
public abstract void turnOffBasket();
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.model.entity.UserDetail;
public abstract interface UserDetailService {
public abstract Long getScore(String paramString);
public abstract PageSupport getUserDetailList(HqlQuery paramHqlQuery);
public abstract PageSupport getUserDetailList(SqlQuery paramSqlQuery);
public abstract UserDetail getUserDetail(String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.SystemParameter;
public abstract interface SystemParameterService {
public abstract SystemParameter getSystemParameter(String paramString);
public abstract void delete(String paramString);
public abstract void save(SystemParameter paramSystemParameter);
public abstract void update(SystemParameter paramSystemParameter);
public abstract PageSupport getSystemParameterList(
CriteriaQuery paramCriteriaQuery);
public abstract void initSystemParameter();
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Indexjpg;
public abstract interface IndexJpgService {
public abstract PageSupport getIndexJpg(CriteriaQuery paramCriteriaQuery);
public abstract Indexjpg getIndexJpgById(Long paramLong);
public abstract void deleteIndexJpg(Indexjpg paramIndexjpg);
public abstract Long getIndexJpgNum(String paramString);
public abstract void updateIndexjpg(Indexjpg paramIndexjpg);
public abstract void saveIndexjpg(Indexjpg paramIndexjpg);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Hotsearch;
import java.util.List;
public abstract interface HotsearchService {
public abstract List<Hotsearch> getHotsearch(String paramString);
public abstract Hotsearch getHotsearchById(Long paramLong);
public abstract Hotsearch getHotsearchByIdAndName(Integer paramInteger,
String paramString);
public abstract void delete(Long paramLong);
public abstract Long save(Hotsearch paramHotsearch, String paramString,
boolean paramBoolean);
public abstract void update(Hotsearch paramHotsearch);
public abstract PageSupport getDataByCriteriaQuery(
CriteriaQuery paramCriteriaQuery);
public abstract List<Hotsearch> getSearch(String paramString, Long paramLong);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Nsort;
import com.legendshop.model.entity.Sort;
import java.util.List;
public abstract interface NsortService {
public abstract List<Nsort> getNsortList(String paramString);
public abstract List<Nsort> getNSortBySort(Long paramLong);
public abstract boolean isHasChildNsort(Long paramLong);
public abstract boolean isHasChildNsortBrand(Long paramLong);
public abstract Nsort getNsort(Long paramLong);
public abstract Sort getSort(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(Nsort paramNsort);
public abstract void update(Nsort paramNsort);
public abstract PageSupport getNsortList(CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getNsortList(HqlQuery paramHqlQuery);
public abstract Nsort getNsortById(Long paramLong);
public abstract List<Nsort> getNsortBySortId(Long paramLong);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
public abstract interface OrderService {
public abstract PageSupport getOrderList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.model.entity.Sub;
import java.util.Map;
public abstract interface ScoreService {
public abstract void addScore(Sub paramSub);
public abstract Map<String, Object> useScore(Sub paramSub, Long paramLong);
public abstract Long calScore(Double paramDouble, String paramString);
public abstract Double calMoney(Long paramLong);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.business.form.SearchForm;
import com.legendshop.business.form.UserForm;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.ShopDetailView;
import com.legendshop.model.entity.Sub;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public abstract interface BusinessService extends BaseService {
public abstract String getIndex(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract ShopDetailView getShopDetailView(String paramString,
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract void setLocalByShopDetail(
ShopDetailView paramShopDetailView,
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getTop(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getTopSort(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getTopnews(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String search(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, SearchForm paramSearchForm);
public abstract String searchall(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString,
Integer paramInteger);
public abstract String getSort(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString,
Long paramLong);
public abstract String getSecSort(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, Long paramLong1,
Long paramLong2, Long paramLong3);
public abstract String getViews(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, Long paramLong);
public abstract String getOrderDetail(
HttpServletRequest paramHttpServletRequest, Sub paramSub,
String paramString1, String paramString2);
public abstract String getNews(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, Long paramLong);
public abstract String getAllNews(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString1,
String paramString2);
public abstract String getHotSale(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getFriendlink(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getHotProduct(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getHotView(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String saveUserReg(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, UserForm paramUserForm);
public abstract String saveUserReg(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract boolean isUserInfoValid(UserForm paramUserForm,
HttpServletRequest paramHttpServletRequest);
public abstract String saveShop(HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, ShopDetail paramShopDetail);
public abstract String getMyAccount(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract ShopDetailView getSimpleInfoShopDetail(String paramString);
public abstract String updateAccount(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, UserForm paramUserForm);
public abstract String getIpAddress(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString);
public abstract String getLeague(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getShopcontact(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String updateUserReg(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString1,
String paramString2);
public abstract String getNewsforCommon(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract String getProductGallery(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, Long paramLong);
public abstract Sub getSubBySubNumber(String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.model.entity.Basket;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter;
import org.springframework.security.web.util.TextEscapeUtils;
public class MyRememberMeAuthenticationFilter
extends RememberMeAuthenticationFilter {
private BasketDao basketDaoImpl;
protected void onSuccessfulAuthentication(HttpServletRequest request,
HttpServletResponse response, Authentication authResult) {
request.getSession().setAttribute("SPRING_SECURITY_LAST_USERNAME",
TextEscapeUtils.escapeEntities(authResult.getName()));
Map basketMap = (Map) request.getSession().getAttribute("BASKET_KEY");
if (basketMap != null) {
for (Basket basket : (List<Basket>) basketMap.values()) {
this.basketDaoImpl.saveToCart(basket.getProdId(),
basket.getPic(), authResult.getName(),
basket.getShopName(), basket.getBasketCount(),
basket.getAttribute(), basket.getProdName(),
basket.getCash(), basket.getCarriage());
}
request.getSession().setAttribute("BASKET_KEY", null);
}
}
@Required
public void setBasketDao(BasketDao basketDaoImpl) {
this.basketDaoImpl = basketDaoImpl;
}
}
| Java |
package com.legendshop.business.service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public abstract interface BaseService {
public abstract Object getSessionAttribute(
HttpServletRequest paramHttpServletRequest, String paramString);
public abstract String getShopName(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse);
public abstract void setSessionAttribute(
HttpServletRequest paramHttpServletRequest, String paramString,
Object paramObject);
public abstract void setShopName(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString);
public abstract Long convertStringToInteger(String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.DeliveryCorp;
import java.util.List;
public abstract interface DeliveryCorpService {
public abstract List<DeliveryCorp> getDeliveryCorp(String paramString);
public abstract DeliveryCorp getDeliveryCorp(Long paramLong);
public abstract void deleteDeliveryCorp(DeliveryCorp paramDeliveryCorp);
public abstract Long saveDeliveryCorp(DeliveryCorp paramDeliveryCorp);
public abstract void updateDeliveryCorp(DeliveryCorp paramDeliveryCorp);
public abstract PageSupport getDeliveryCorp(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
public abstract interface PaymentService {
public abstract String payto(String paramString1, String paramString2,
Integer paramInteger, String paramString3, String paramString4,
String paramString5, String paramString6, String paramString7);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.DeliveryType;
import java.util.List;
public abstract interface DeliveryTypeService {
public abstract List<DeliveryType> getDeliveryType(String paramString);
public abstract DeliveryType getDeliveryType(Long paramLong);
public abstract void deleteDeliveryType(DeliveryType paramDeliveryType);
public abstract Long saveDeliveryType(DeliveryType paramDeliveryType);
public abstract void updateDeliveryType(DeliveryType paramDeliveryType);
public abstract PageSupport getDeliveryType(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
public abstract interface LoginHistoryService {
public abstract void saveLoginHistory(String paramString1,
String paramString2);
public abstract PageSupport getLoginHistory(CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getLoginHistoryBySQL(SqlQuery paramSqlQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.ImgFile;
import com.legendshop.model.entity.Product;
import java.util.List;
public abstract interface ImgFileService {
public abstract List<ImgFile> getImgFile(String paramString);
public abstract ImgFile getImgFileById(Long paramLong);
public abstract Product getProd(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(ImgFile paramImgFile);
public abstract void update(ImgFile paramImgFile);
public abstract PageSupport getImgFileList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Sort;
import java.util.List;
public abstract interface SortService {
public abstract List<Sort> getSortList(String paramString);
public abstract Sort getSortById(Long paramLong);
public abstract void deleteSort(Long paramLong);
public abstract Long save(Sort paramSort);
public abstract void updateSort(Sort paramSort);
public abstract PageSupport getSortList(CriteriaQuery paramCriteriaQuery);
public abstract List<Sort> getSort(String paramString, boolean paramBoolean);
public abstract void delete(Sort paramSort);
public abstract List<Sort> getSort(String paramString1,
String paramString2, boolean paramBoolean);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Myleague;
import java.util.List;
public abstract interface MyleagueService {
public abstract List<Myleague> getMyleagueList(String paramString);
public abstract Myleague getMyleagueById(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(Myleague paramMyleague);
public abstract void update(Myleague paramMyleague);
public abstract PageSupport getMyleagueList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.CashFlow;
import java.util.List;
public abstract interface CashFlowService {
public abstract List<CashFlow> getCashFlow(String paramString);
public abstract CashFlow getCashFlow(Long paramLong);
public abstract void deleteCashFlow(CashFlow paramCashFlow);
public abstract Long saveCashFlow(CashFlow paramCashFlow);
public abstract void updateCashFlow(CashFlow paramCashFlow);
public abstract PageSupport getCashFlow(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Logo;
import java.util.List;
public abstract interface LogoService {
public abstract List<Logo> getLogoList(String paramString);
public abstract Logo getLogoById(Long paramLong);
public abstract Logo getLogoByIdAndName(Long paramLong, String paramString);
public abstract void delete(Long paramLong);
public abstract Long save(Logo paramLogo);
public abstract void update(Logo paramLogo);
public abstract PageSupport getLogoList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.VisitLog;
import java.util.List;
public abstract interface VisitLogService {
public abstract List<VisitLog> getVisitLogList(String paramString);
public abstract VisitLog getVisitLogById(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(VisitLog paramVisitLog);
public abstract void update(VisitLog paramVisitLog);
public abstract PageSupport getVisitLogList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Ask;
import java.util.List;
public abstract interface AskService {
public abstract List<Ask> getAsk(String paramString);
public abstract Ask getAsk(Long paramLong);
public abstract void deleteAsk(Ask paramAsk);
public abstract Long saveAsk(Ask paramAsk);
public abstract void updateAsk(Ask paramAsk);
public abstract PageSupport getAsk(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.util.MD5Util;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
import org.springframework.util.StringUtils;
public class MyTokenBasedRememberMeServices
extends TokenBasedRememberMeServices {
public void onLoginSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication successfulAuthentication) {
String username = retrieveUserName(successfulAuthentication);
String password = retrievePassword(successfulAuthentication);
if ((!StringUtils.hasLength(username))
|| (!StringUtils.hasLength(password))) {
return;
}
int tokenLifetime = calculateLoginLifetime(request,
successfulAuthentication);
long expiryTime = System.currentTimeMillis();
expiryTime += 1000L * (tokenLifetime < 0 ? 1209600
: tokenLifetime);
String signatureValue = makeTokenSignature(expiryTime, username,
MD5Util.Md5Password(username, password));
setCookie(new String[] {username, Long.toString(expiryTime),
signatureValue }, tokenLifetime, request, response);
if (this.logger.isDebugEnabled())
this.logger.debug("Added remember-me cookie for user '" + username
+ "', expiry: '" + new Date(expiryTime) + "'");
}
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.PayType;
import java.util.List;
public abstract interface PayTypeService {
public abstract List<PayType> getPayTypeList(String paramString);
public abstract PayType getPayTypeById(Long paramLong);
public abstract PayType getPayTypeByIdAndName(String paramString,
Integer paramInteger);
public abstract void delete(Long paramLong);
public abstract Long save(PayType paramPayType);
public abstract void update(PayType paramPayType);
public abstract PageSupport getPayTypeList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.model.UserInfo;
import com.legendshop.model.entity.ShopDetailView;
public abstract interface IndexService {
public abstract UserInfo getAdminIndex(String paramString,
ShopDetailView paramShopDetailView);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Pub;
import java.util.List;
public abstract interface PubService {
public abstract List<Pub> getPubList(String paramString);
public abstract Pub getPubById(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(Pub paramPub, String paramString,
boolean paramBoolean);
public abstract void update(Pub paramPub);
public abstract PageSupport getPubList(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Cash;
import java.util.List;
public abstract interface CashService {
public abstract List<Cash> getCash(String paramString);
public abstract Cash getCash(Long paramLong);
public abstract void deleteCash(Cash paramCash);
public abstract Long saveCash(Cash paramCash);
public abstract void updateCash(Cash paramCash);
public abstract PageSupport getCash(CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.security.GrantedFunction;
import com.legendshop.core.security.SecurityManager;
import com.legendshop.core.security.service.FunctionService;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.Role;
import com.legendshop.model.entity.UserEntity;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetailsService;
public abstract interface AuthService
extends UserDetailsService, SecurityManager, FunctionService {
public abstract Collection<GrantedAuthority> getAuthoritiesByUsernameQuery(
UserEntity paramUserEntity) throws DataAccessException;
public abstract Collection<GrantedFunction> getFunctionByUsernameQuery(
UserEntity paramUserEntity) throws DataAccessException;
public abstract UserEntity getUserByName(String paramString);
public abstract UserEntity findUserByName(String paramString);
public abstract List<Role> findRolesByUser(UserEntity paramUserEntity);
public abstract Map<String, String> getUrlAuthorities();
public abstract Role getgrantedAuthority(String paramString);
public abstract List<Role> findRoleByName(String paramString);
public abstract List<Function> findFunctionsByRole(Role paramRole);
}
| Java |
package com.legendshop.business.service;
import java.util.Date;
import java.util.List;
public abstract interface LuceneService {
public abstract long getFirstPostIdByDate(int paramInt, Date paramDate);
public abstract List getPostsToIndex(int paramInt, long paramLong1,
long paramLong2);
public abstract long getLastPostIdByDate(int paramInt, Date paramDate);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.model.entity.DownloadLog;
public abstract interface DownloadLogService {
public abstract boolean checkCanDownload(String paramString1,
String paramString2);
public abstract boolean isUserOrderProduct(Long paramLong,
String paramString);
public abstract void save(DownloadLog paramDownloadLog);
public abstract Integer getMaxTimes();
public abstract Integer getInterValMinutes();
public abstract void afterDownload(Object paramObject);
}
| Java |
package com.legendshop.business.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import com.legendshop.business.dao.BasketDao;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.randing.CaptchaServiceSingleton;
import com.legendshop.model.entity.Basket;
public class ValidateCodeUsernamePasswordAuthenticationFilter
extends UsernamePasswordAuthenticationFilter implements LoginService {
Logger log = LoggerFactory
.getLogger(ValidateCodeUsernamePasswordAuthenticationFilter.class);
private boolean postOnly = true;
private LoginHistoryService loginHistoryService;
private BasketDao basketDao;
public static final String DEFAULT_SESSION_VALIDATE_CODE_FIELD = "randNum";
private boolean supportSSO = false;
public void setSupportSSO(boolean supportSSO) {
this.supportSSO = supportSSO;
}
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException {
if ((this.postOnly) && (!request.getMethod().equals("POST"))) {
throw new AuthenticationServiceException(
"Authentication method not supported: " + request.getMethod());
}
String username = obtainUsername(request);
String password = obtainPassword(request);
if (username == null) {
username = "";
}
if (password == null) {
password = "";
}
username = username.trim();
if ((isUseValidateCode()) && (!checkValidateCode(request))) {
throw new AuthenticationServiceException("验证码失败");
}
return onAuthentication(request, response, username, password);
}
public Authentication onAuthentication(HttpServletRequest request,
HttpServletResponse response, String username, String password) {
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
username, password);
HttpSession session = request.getSession();
setDetails(request, authRequest);
Authentication auth = getAuthenticationManager().authenticate(
authRequest);
if ((auth != null) && (auth.isAuthenticated())) {
this.loginHistoryService.saveLoginHistory(username,
request.getRemoteAddr());
session.setAttribute("SPRING_SECURITY_LAST_USERNAME", username);
Map basketMap = (Map) session.getAttribute("BASKET_KEY");
if (basketMap != null) {
for (Basket basket : (List<Basket>) basketMap.values()) {
this.basketDao.saveToCart(basket.getProdId(),
basket.getPic(), username, basket.getShopName(),
basket.getBasketCount(), basket.getAttribute(),
basket.getProdName(), basket.getCash(),
basket.getCarriage());
}
session.setAttribute("BASKET_KEY", null);
}
if (this.supportSSO) {
Cookie cookie = new Cookie("jforumUserInfo", username);
cookie.setPath("/");
cookie.setMaxAge(-1);
response.addCookie(cookie);
}
}
return auth;
}
@Deprecated
protected void checkValidateCode_bak(HttpServletRequest request) {
String sessionValidateCode = obtainSessionValidateCode(request);
String validateCodeParameter = obtainValidateCodeParameter(request);
if ((StringUtils.isEmpty(validateCodeParameter))
|| (!sessionValidateCode.equalsIgnoreCase(validateCodeParameter))) {
this.log.error("输入的验证码 {}不匹配 {}", validateCodeParameter,
sessionValidateCode);
throw new AuthenticationServiceException("验证码失败");
}
}
protected boolean checkValidateCode(HttpServletRequest request) {
String validateCodeParameter = obtainValidateCodeParameter(request);
return CaptchaServiceSingleton
.getInstance()
.validateResponseForID(request.getSession().getId(),
validateCodeParameter).booleanValue();
}
private String obtainValidateCodeParameter(HttpServletRequest request) {
return request.getParameter("randNum");
}
protected String obtainSessionValidateCode(HttpServletRequest request) {
Object obj = request.getSession().getAttribute("randNum");
return null == obj ? ""
: obj.toString();
}
public boolean isPostOnly() {
return this.postOnly;
}
public void setPostOnly(boolean postOnly) {
this.postOnly = postOnly;
}
public boolean isUseValidateCode() {
return ((Boolean) PropertiesUtil.getObject(
ParameterEnum.VALIDATION_IMAGE, Boolean.class)).booleanValue();
}
public void setLoginHistoryService(LoginHistoryService loginHistoryService) {
this.loginHistoryService = loginHistoryService;
}
public void setBasketDao(BasketDao basketDao) {
this.basketDao = basketDao;
}
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.BaseDao;
public abstract interface CommonUtil {
public abstract void saveAdminRight(BaseDao paramBaseDao, String paramString);
public abstract void saveUserRight(BaseDao paramBaseDao, String paramString);
public abstract void removeAdminRight(BaseDao paramBaseDao,
String paramString);
public abstract void removeUserRight(BaseDao paramBaseDao,
String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.model.entity.Basket;
import java.util.List;
public abstract interface BasketService {
public abstract void saveToCart(Long paramLong, String paramString1,
String paramString2, String paramString3, String paramString4,
Integer paramInteger);
public abstract void saveToCart(Long paramLong, String paramString1,
String paramString2, String paramString3, Integer paramInteger,
String paramString4, String paramString5, Double paramDouble1,
Double paramDouble2);
public abstract void deleteBasketByUserName(String paramString);
public abstract void deleteBasketById(Long paramLong);
public abstract List<Basket> getBasketByuserName(String paramString);
}
| Java |
package com.legendshop.business.payment.alipay.util;
import com.legendshop.business.payment.alipay.config.AlipayConfig;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5Encrypt {
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
public static String md5(String text) {
MessageDigest msgDigest = null;
try {
msgDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(
"System doesn't support MD5 algorithm.");
}
try {
msgDigest.update(text.getBytes(AlipayConfig.input_charset));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(
"System doesn't support your EncodingException.");
}
byte[] bytes = msgDigest.digest();
String md5Str = new String(encodeHex(bytes));
return md5Str;
}
public static char[] encodeHex(byte[] data) {
int l = data.length;
char[] out = new char[l << 1];
int i = 0;
for (int j = 0; i < l; i++) {
out[(j++)] = DIGITS[((0xF0 & data[i]) >>> 4)];
out[(j++)] = DIGITS[(0xF & data[i])];
}
return out;
}
}
| Java |
package com.legendshop.business.payment.alipay.util;
import com.legendshop.business.payment.alipay.config.AlipayConfig;
import com.legendshop.business.payment.alipay.util.httpclient.HttpProtocolHandler;
import com.legendshop.business.payment.alipay.util.httpclient.HttpRequest;
import com.legendshop.business.payment.alipay.util.httpclient.HttpResponse;
import com.legendshop.business.payment.alipay.util.httpclient.HttpResultType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.httpclient.NameValuePair;
public class AlipaySubmit {
private static Map<String, String> buildRequestPara(
Map<String, String> sParaTemp, String validateKey) {
Map sPara = AlipayCore.paraFilter(sParaTemp);
String mysign = AlipayCore.buildMysign(sPara, validateKey);
sPara.put("sign", mysign);
sPara.put("sign_type", AlipayConfig.sign_type);
return sPara;
}
private static NameValuePair[] generatNameValuePair(
Map<String, String> properties) {
NameValuePair[] nameValuePair = new NameValuePair[properties.size()];
int i = 0;
for (Map.Entry entry : properties.entrySet()) {
nameValuePair[(i++)] = new NameValuePair((String) entry.getKey(),
(String) entry.getValue());
}
return nameValuePair;
}
public static String sendPostInfo(Map<String, String> sParaTemp,
String gateway, String validateKey) throws Exception {
Map sPara = buildRequestPara(sParaTemp, validateKey);
HttpProtocolHandler httpProtocolHandler = HttpProtocolHandler
.getInstance();
HttpRequest request = new HttpRequest(HttpResultType.BYTES);
request.setCharset(AlipayConfig.input_charset);
request.setParameters(generatNameValuePair(sPara));
request
.setUrl(gateway + "_input_charset=" + AlipayConfig.input_charset);
HttpResponse response = httpProtocolHandler.execute(request);
if (response == null) {
return null;
}
String strResult = response.getStringResult();
return strResult;
}
public static String buildForm(Map<String, String> sParaTemp,
String gateway, String strMethod, String strButtonName,
String validateKey) {
Map sPara = buildRequestPara(sParaTemp, validateKey);
List keys = new ArrayList(sPara.keySet());
StringBuffer sbHtml = new StringBuffer();
sbHtml
.append("<form id=\"alipaysubmit\" name=\"alipaysubmit\" action=\""
+ gateway + "_input_charset=" + AlipayConfig.input_charset
+ "\" method=\"" + strMethod + "\">");
for (int i = 0; i < keys.size(); i++) {
String name = (String) keys.get(i);
String value = (String) sPara.get(name);
sbHtml.append("<input type=\"hidden\" name=\"" + name
+ "\" value=\"" + value + "\"/>");
}
sbHtml.append("<input type=\"submit\" value=\"" + strButtonName
+ "\" style=\"display:none;\"></form>");
sbHtml
.append("<script>document.forms['alipaysubmit'].submit();</script>");
return sbHtml.toString();
}
}
| Java |
package com.legendshop.business.payment.alipay.util.httpclient;
import java.io.IOException;
import java.net.UnknownHostException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
public class HttpProtocolHandler {
/* 39 */private static String DEFAULT_CHARSET = "utf-8";
/* */
/* 42 */private final int defaultConnectionTimeout = 8000;
/* */
/* 45 */private final int defaultSoTimeout = 30000;
/* */
/* 48 */private final int defaultIdleConnTimeout = 60000;
/* */
/* 51 */private final int defaultMaxConnPerHost = 30;
/* */
/* 54 */private final int defaultMaxTotalConn = 80;
/* */private static final long defaultHttpConnectionManagerTimeout = 3000L;
/* */private final HttpConnectionManager connectionManager;
/* 65 */private static HttpProtocolHandler httpProtocolHandler = new HttpProtocolHandler();
/* */
/* */public static HttpProtocolHandler getInstance()
/* */{
/* 73 */return httpProtocolHandler;
/* */}
/* */
/* */private HttpProtocolHandler()
/* */{
/* 81 */this.connectionManager = new MultiThreadedHttpConnectionManager();
/* 82 */this.connectionManager.getParams()
.setDefaultMaxConnectionsPerHost(30);
/* 83 */this.connectionManager.getParams().setMaxTotalConnections(80);
/* */
/* 85 */IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread();
/* 86 */ict.addConnectionManager(this.connectionManager);
/* 87 */ict.setConnectionTimeout(60000L);
/* */
/* 89 */ict.start();
/* */}
/* */
/* */public HttpResponse execute(HttpRequest request)
/* */{
/* 100 */HttpClient httpclient = new HttpClient(this.connectionManager);
/* */
/* 103 */int connectionTimeout = 8000;
/* 104 */if (request.getConnectionTimeout() > 0) {
/* 105 */connectionTimeout = request.getConnectionTimeout();
/* */}
/* 107 */httpclient.getHttpConnectionManager().getParams()
.setConnectionTimeout(connectionTimeout);
/* */
/* 110 */int soTimeout = 30000;
/* 111 */if (request.getTimeout() > 0) {
/* 112 */soTimeout = request.getTimeout();
/* */}
/* 114 */httpclient.getHttpConnectionManager().getParams()
.setSoTimeout(soTimeout);
/* */
/* 117 */httpclient.getParams().setConnectionManagerTimeout(3000L);
/* */
/* 119 */String charset = request.getCharset();
/* 120 */charset = charset == null ? DEFAULT_CHARSET
: charset;
/* 121 */HttpMethod method = null;
/* */
/* 123 */if (request.getMethod().equals("GET")) {
/* 124 */method = new GetMethod(request.getUrl());
/* 125 */method.getParams().setCredentialCharset(charset);
/* */
/* 128 */method.setQueryString(request.getQueryString());
/* */} else {
/* 130 */method = new PostMethod(request.getUrl());
/* 131 */((PostMethod) method).addParameters(request
.getParameters());
/* 132 */method.addRequestHeader("Content-Type",
"application/x-www-form-urlencoded; text/html; charset="
+ charset);
/* */}
/* */
/* 138 */method.addRequestHeader("User-Agent", "Mozilla/4.0");
/* 139 */HttpResponse response = new HttpResponse();
/* */try
/* */{
/* 142 */httpclient.executeMethod(method);
/* 143 */if (request.getResultType().equals(HttpResultType.STRING))
/* 144 */response.setStringResult(method
.getResponseBodyAsString());
/* 145 */else if (request.getResultType().equals(
HttpResultType.BYTES)) {
/* 146 */response.setByteResult(method.getResponseBody());
/* */}
/* 148 */response.setResponseHeaders(method.getResponseHeaders());
/* */}
/* */catch (UnknownHostException ex) {
/* */return null;
/* */}
/* */catch (IOException ex)
/* */{
return null;
/* */}
/* */catch (Exception ex)
/* */{
/* 157 */return null;
} finally {
method.releaseConnection();
/* */}
/* 161 */return response;
/* */}
/* */
/* */protected String toString(NameValuePair[] nameValues)
/* */{
/* 172 */if ((nameValues == null) || (nameValues.length == 0)) {
/* 173 */return "null";
/* */}
/* */
/* 176 */StringBuffer buffer = new StringBuffer();
/* */
/* 178 */for (int i = 0; i < nameValues.length; i++) {
/* 179 */NameValuePair nameValue = nameValues[i];
/* */
/* 181 */if (i == 0)
/* 182 */buffer.append(nameValue.getName() + "="
+ nameValue.getValue());
/* */else {
/* 184 */buffer.append("&" + nameValue.getName() + "="
+ nameValue.getValue());
/* */}
/* */}
/* */
/* 188 */return buffer.toString();
/* */}
/* */
}
| Java |
package com.legendshop.business.payment.alipay.util.httpclient;
import com.legendshop.business.payment.alipay.config.AlipayConfig;
import java.io.UnsupportedEncodingException;
import org.apache.commons.httpclient.Header;
public class HttpResponse {
private Header[] responseHeaders;
private String stringResult;
private byte[] byteResult;
public Header[] getResponseHeaders() {
return this.responseHeaders;
}
public void setResponseHeaders(Header[] responseHeaders) {
this.responseHeaders = responseHeaders;
}
public byte[] getByteResult() {
if (this.byteResult != null) {
return this.byteResult;
}
if (this.stringResult != null) {
return this.stringResult.getBytes();
}
return null;
}
public void setByteResult(byte[] byteResult) {
this.byteResult = byteResult;
}
public String getStringResult() throws UnsupportedEncodingException {
if (this.stringResult != null) {
return this.stringResult;
}
if (this.byteResult != null) {
return new String(this.byteResult, AlipayConfig.input_charset);
}
return null;
}
public void setStringResult(String stringResult) {
this.stringResult = stringResult;
}
}
| Java |
package com.legendshop.business.payment.alipay.util.httpclient;
import org.apache.commons.httpclient.NameValuePair;
public class HttpRequest {
public static final String METHOD_GET = "GET";
public static final String METHOD_POST = "POST";
private String url = null;
private String method = "POST";
private int timeout = 0;
private int connectionTimeout = 0;
private NameValuePair[] parameters = null;
private String queryString = null;
private String charset = "utf-8";
private String clientIp;
private HttpResultType resultType = HttpResultType.BYTES;
public HttpRequest(HttpResultType resultType) {
this.resultType = resultType;
}
public String getClientIp() {
return this.clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public NameValuePair[] getParameters() {
return this.parameters;
}
public void setParameters(NameValuePair[] parameters) {
this.parameters = parameters;
}
public String getQueryString() {
return this.queryString;
}
public void setQueryString(String queryString) {
this.queryString = queryString;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMethod() {
return this.method;
}
public void setMethod(String method) {
this.method = method;
}
public int getConnectionTimeout() {
return this.connectionTimeout;
}
public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public int getTimeout() {
return this.timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public String getCharset() {
return this.charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public HttpResultType getResultType() {
return this.resultType;
}
public void setResultType(HttpResultType resultType) {
this.resultType = resultType;
}
}
| Java |
package com.legendshop.business.payment.alipay.util.httpclient;
public enum HttpResultType {
STRING,
BYTES;
}
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.