package hhtc.xin.business.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import hhtc.xin.action.GoodsAction;
import hhtc.xin.bo.Goods;
import hhtc.xin.bo.GoodsForAuction;
import hhtc.xin.bo.GoodsForList;
import hhtc.xin.bo.GoodsProp;
import hhtc.xin.bo.GoodsType;
import hhtc.xin.bo.KeyValue;
import hhtc.xin.bo.User;
import hhtc.xin.business.GoodsService;
import hhtc.xin.dao.TAuctionLogDAO;
import hhtc.xin.dao.TAuctionStateDAO;
import hhtc.xin.dao.TAuctionTypeDAO;
import hhtc.xin.dao.TGoodsDAO;
import hhtc.xin.dao.TGoodsTypeDAO;
import hhtc.xin.db.TAuctionLog;
import hhtc.xin.db.TAuctionState;
import hhtc.xin.db.TAuctionType;
import hhtc.xin.db.TGoods;
import hhtc.xin.db.TGoodsType;
import hhtc.xin.db.TUser;
public class GoodsServiceImpl implements GoodsService {
private static Logger log = Logger.getLogger(GoodsServiceImpl.class
.getSimpleName());
private TGoodsDAO goodsDao;
private TGoodsTypeDAO goodsTypeDao;
private TAuctionStateDAO auctionStateDao;
private TAuctionTypeDAO auctionTypeDao;
private TAuctionLogDAO auctionLogDao;
public List<GoodsType> getALLType() {
// TODO Auto-generated method stub
List<GoodsType> list = new ArrayList<GoodsType>();
if(goodsTypeDao==null)
{
System.out.println("空2!");
goodsTypeDao=new TGoodsTypeDAO();
}
List<TGoodsType> tgoodlist=goodsTypeDao.findAll();
for(TGoodsType tgt:tgoodlist)
{
GoodsType gt=new GoodsType();
gt.setTypeId(tgt.getGoodsTypeId());
gt.setTypeName(tgt.getTypeName());
gt.setTypeDetail(tgt.getDetail());
if(tgt.getTGoodsType()!=null)
gt.setFatherTypeId(tgt.getTGoodsType().getGoodsTypeId());
else gt.setFatherTypeId(-1);
list.add(gt);
}
return list;
}
public List<GoodsType> getRootType() {
// TODO Auto-generated method stub
return null;
}
public void saveType(GoodsType type) {
log.info("开始保存商品类型");
}
public void delete(int deleteId) {
log.info("开始删除商品类型");
goodsDao.delete(deleteId);
}
public List<KeyValue> getGoodsType(Integer typeId) {
log.info("get载入商品类型<编号=" + typeId);
// List<TGoodsType>
// list=goodsTypeDao.findByExample(goodsTypeDao.findById(typeId));
// goodsTypeDao.f
List<?> list = goodsTypeDao.getListByFather(typeId);
List<KeyValue> result = new ArrayList<KeyValue>();
for (Iterator<?> it = list.iterator(); it.hasNext();) {
Object[] item = (Object[]) it.next();
KeyValue keyValue = new KeyValue(new Integer(item[0].toString()),
item[1].toString());
result.add(keyValue);
}
return result;
}
/*
* 用于<s:doubleList>
*/
public Map<Integer, String> loadGoodsType(Integer typeId) {
log.info("载入商品类型<编号=" + typeId);
// List<TGoodsType>
// list=goodsTypeDao.findByExample(goodsTypeDao.findById(typeId));
// goodsTypeDao.f
List list = goodsTypeDao.getListByFather(typeId);
Map<Integer, String> map = new HashMap<Integer, String>();
for (Iterator<?> it = list.iterator(); it.hasNext();) {
Object[] item = (Object[]) it.next();
map.put(new Integer(item[0].toString()), item[1].toString());
}
return map;
}
public int addGoods(Goods goods, GoodsAction action) {
if (goods == null) {
action.addActionMessage("参数错误!");
return -1;
}
if (goods.getName() == null || goods.getName().trim().equals("")) {
action.addActionMessage("请输入商品名称!");
return -1;
}
if (goods.getQuantity() <= 0) {
action.addActionMessage("商品数量不合法!");
return -1;
}
TGoods tgoods = new TGoods();
tgoods.setName(goods.getName());
tgoods.setDetail(goods.getDetail());
tgoods.setQuantity(goods.getQuantity());
tgoods.setCreated(new Timestamp(System.currentTimeMillis()));
// 这样会多查询一条SQL语句
// tgoods.setTGoodsType(goodsTypeDao.findById(goods.getTypeId()));
// 设置商品的类型
TGoodsType type = new TGoodsType();
type.setGoodsTypeId(goods.getTypeId());
tgoods.setTGoodsType(type);
// 设置商品的卖方
TUser user = new TUser();
user.setUserId(goods.getOwnId());
tgoods.setTUserByOwnId(user);
return goodsDao.save(tgoods);
}
public void finishAdd(Integer id) {
// 设置拍卖状态为审核中(状态ID=1)
goodsDao.updateAuctionState(id, 1);
}
public boolean updateStyle(Goods goods, GoodsAction action) {
int typeId = goods.getAuctionTypeId();
TGoods tgoods = goodsDao.findById(goods.getId());
int sum = tgoods.getQuantity();
if (sum != 1 && typeId != 2) {
action.addActionMessage("多件商品时,选择美式拍卖!");
goods.setAuctionTypeId(2);
return false;
}
if (sum == 1 && typeId == 2) {
action.addActionMessage("美式拍卖只适合于多件相同商品!");
goods.setAuctionTypeId(1);
return false;
}
// 英式拍卖 美式拍卖 封标拍卖 速胜式拍卖
if (typeId >= 1 && typeId <= 4) {
if (goods.getInitPrice() < 0 || goods.getAddPrice() < 0
|| goods.getReservePrice() < 0) {
action.addActionMessage("价格不能为负!");
return false;
}
if (goods.getAddPrice() <= goods.getInitPrice()
&& goods.getInitPrice() <= goods.getReservePrice()) {
} else {
action.addActionMessage("请正确输入价格参数,不清楚请查看帮助!");
return false;
}
TAuctionType type = new TAuctionType();
type.setAuctionTypeId(typeId);
tgoods.setTAuctionType(type);
tgoods.setInitPrice(goods.getInitPrice());
tgoods.setAddPrice(goods.getAddPrice());
tgoods.setReservePrice(goods.getReservePrice());
tgoods.setMaxPrice(goods.getInitPrice());
goodsDao.updateAuctionType(tgoods);
return true;
} else if (typeId == 5) {
// 反向拍卖
if (goods.getInitPrice() < 0) {
action.addActionMessage("价格不能为负!");
return false;
}
TAuctionType type = new TAuctionType();
type.setAuctionTypeId(typeId);
tgoods.setTAuctionType(type);
tgoods.setInitPrice(goods.getInitPrice());
goodsDao.updateAuctionType(tgoods);
return true;
} else {
action.addActionMessage("请选择拍卖方式");
return false;
}
}
public List<Goods> getSimpleListByEnglish() {
goodsDao.listByEnglish();
return null;
}
/**
* @deprecated:商品列表
* @prop 参数列表
*/
public List<GoodsForList> getGoodsList(GoodsProp prop) {
checkProp(prop);
List<GoodsForList> list = new ArrayList<GoodsForList>();
List<?> results = goodsDao.getSimpleList(prop);
for (Iterator<?> it = results.iterator(); it.hasNext();) {
Object current = it.next();
Object[] objs = (Object[]) current;
System.out.println(objs);
System.out.println(objs[0]);
GoodsForList goods = new GoodsForList();
goods.setId(Integer.valueOf(objs[0].toString()));
goods.setName(objs[1].toString());
goods.setPrice(objs[2].toString());
goods.setUrl(objs[3].toString());
goods.setStart((Date) objs[4]);
goods.setEnd((Date) objs[5]);
goods.setAuctionState(objs[6].toString());
goods.setAuctionType(objs[7].toString());
list.add(goods);
}
return list;
}
private void checkProp(GoodsProp prop) {
if(prop==null){
prop=new GoodsProp();
}
int state=prop.getAuctionState();
if(state==0||(state>=2&&state<=5)){
//正确的拍卖状态
}else{
prop.setAuctionState(0);
}
int type=prop.getAuctionType();
if(type>=0&&type<=5){
//正确的拍卖方式
}else{
prop.setAuctionType(0);
}
int start=prop.getStart();
if(start<0){
prop.setStart(0);
}
if(prop.getTotal()>0){
if(prop.getTotal()<=start){
prop.setStart(prop.getTotal()/prop.getMaxResults()*prop.getMaxResults());
}
}
}
// 拍卖类型
public List<KeyValue> getAuctionType() {
List<?> list = auctionTypeDao.getAuctionList();
List<KeyValu
没有合适的资源?快使用搜索试试~ 我知道了~
jaee小项目 jaee网上拍卖系统
共361个文件
class:75个
java:74个
xml:57个
3星 · 超过75%的资源 需积分: 18 19 下载量 174 浏览量
2012-11-06
12:01:48
上传
评论 1
收藏 18.49MB RAR 举报
温馨提示
jaee小项目 jaee网上拍卖系统 用的mysql数据库,毕业设计
资源推荐
资源详情
资源评论
收起资源包目录
jaee小项目 jaee网上拍卖系统 (361个子文件)
.buildpath 198B
GoodsServiceImpl.class 18KB
TGoodsDAO.class 13KB
GoodsAction.class 9KB
TMessageDAO.class 7KB
TAuctionLogDAO.class 7KB
FileServiceImpl.class 7KB
TUserDAO.class 7KB
ScheduleServiceImpl.class 7KB
TFileDAO.class 6KB
UserAction.class 6KB
TGoodsTypeDAO.class 6KB
TGoods.class 6KB
TAuctionStateDAO.class 6KB
TAuctionTypeDAO.class 6KB
TFileUseTypeDAO.class 5KB
TUser.class 5KB
AuctionAction.class 5KB
TLoginLogDAO.class 5KB
TCommentDAO.class 5KB
TMessageTypeDAO.class 5KB
TStudentDAO.class 5KB
GoodsTypeAction.class 5KB
TgoodsAction.class 5KB
UploadAction.class 5KB
GoodsForAuction.class 4KB
UserServiceImpl.class 4KB
AuctionTypeAction.class 4KB
MessageServiceImpl.class 4KB
DownloadAction.class 4KB
Goods.class 3KB
CheckCode.class 3KB
FileUtil.class 3KB
MessageAction.class 3KB
GoodsServiceTest.class 3KB
TComment.class 3KB
TMessage.class 3KB
TFile.class 3KB
RightExplain.class 2KB
TAuctionLog.class 2KB
FileBO.class 2KB
GoodsForList.class 2KB
CreateTestData.class 2KB
GoodsProp.class 2KB
CheckCodeAction.class 2KB
TGoodsType.class 2KB
DownListItem.class 2KB
EmailServiceImpl.class 2KB
User.class 2KB
FileServiceTest.class 2KB
TLoginLog.class 2KB
TAuctionState.class 2KB
AuctionManagerAction.class 2KB
GoodsService.class 2KB
DownListAction.class 2KB
ClearMessageInterceptor.class 2KB
Message.class 2KB
GoodsType.class 2KB
TAuctionType.class 2KB
TFileUseType.class 1KB
TStudent.class 1KB
AdminInterceptor.class 1KB
AuthorityInterceptor.class 1KB
TMessageType.class 1KB
EmailServiceImpl$1.class 1KB
EmailServiceTest.class 1KB
MsgServiceTest.class 1KB
KeyValue.class 926B
ExistUtil.class 782B
ContentType.class 707B
FileService.class 605B
UserService.class 418B
MessageService.class 393B
EmailService.class 271B
ScheduleService.class 156B
AuctionService.class 127B
.classpath 5KB
auction.css 22KB
auction_old.css 20KB
common.css 20KB
popup.css 5KB
reg.css 1KB
index.css 964B
user.css 441B
logo.gif 36KB
class_title.gif 391B
hibernate3.jar 2.31MB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
xwork-core-2.1.6.jar 1.49MB
freemarker-2.3.15.jar 859KB
struts2-core-2.1.8.1.jar 738KB
mysql-connector-java-5.1.7-bin.jar 693KB
org.springframework.context-3.0.1.RELEASE-A.jar 642KB
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar 603KB
javassist-3.9.0.GA.jar 583KB
commons-collections-3.1.jar 546KB
org.springframework.beans-3.0.1.RELEASE-A.jar 535KB
org.springframework.web.struts-3.0.1.RELEASE-A.jar 524KB
quartz-all-1.6.1.jar 449KB
antlr-2.7.6.jar 433KB
共 361 条
- 1
- 2
- 3
- 4
资源评论
- qq261497092014-05-14虽然LS说有文档但是没找到。。不过系统是很不错
- huzhancheng2012-11-08jsp的网上拍卖系项目,有很详细的文档,mysql数据库的系统,界面也挺美观,功能也很全面,非常感谢。
weigong1989
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功