package com.byc.service.serviceImpls;
import com.byc.bean.CommodityList;
import com.byc.bean.OrderList;
import com.byc.bean.User;
import com.byc.mapper.CommodityListMapper;
import com.byc.mapper.OrderListMapper;
import com.byc.mapper.UserMapper;
import com.byc.service.IOrderService;
import com.byc.vo.OrderShow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Transactional
public class OrderService implements IOrderService, Serializable {
@Autowired
OrderListMapper orderMapper;
@Autowired
CommodityListMapper commodityListMapper;
@Autowired
UserMapper userMapper;
//生成订单
// public boolean addOrder(float payment, String orderItemList, String userId, String cycleId){
// OrderList orderList = new OrderList();
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// //订单号
// orderList.setId(UUID.randomUUID().toString());
// orderList.setPayment(payment);
// orderList.setOrderItemList(orderItemList);
// orderList.setUserid(userId);
// orderList.setCycleid(cycleId);
// orderList.setCreationTime(simpleDateFormat.format(new Date()));
// orderList.setEndTime(simpleDateFormat.format(new Date()));
// int i = orderMapper.addOrder(orderList);
// return i>0?true:false;
// }
//通过订单号id来查询订单信息
public OrderList selectOrderById(String id){
OrderList orderList = orderMapper.selectOrderById(id);
return orderList;
}
//用户根据相关的用户id来查找与自己相关的订单信息
public List<OrderList> selectOrderByUserId(String userId){
List<OrderList> orderLists = orderMapper.selectOrderByUserId(userId);
return orderLists;
}
//回收人员来查询相关的订单
public List<OrderList> SelectOrderByCycleId(String cycleId){
List<OrderList> orderLists = orderMapper.selectOrderByCycleId(cycleId);
return orderLists;
}
//生成订单
public int generateOrderService(String userInfoAddress,String userInfoId,List<Map> maps){
String orderId = UUID.randomUUID().toString();
String address = userInfoAddress;
String userId = userInfoId;
int orderStatus = 0;
float payment = 0;
// float v = Float.parseFloat(amount);
// float payment = gPrice*v;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String creationTime = simpleDateFormat.format(new Date());
// int i = orderMapper.generateOrder(orderId, payment, address, creationTime, userId, orderStatus);
// if(i==0){
// //代表插入失败
// return 0;
// }
for (Map p: maps
) {
payment = payment + ((Float.parseFloat(p.get("amount").toString()))*(Float.parseFloat(p.get("gPrice").toString())));
int i1 = commodityListMapper.insertCommodity(UUID.randomUUID().toString(), p.get("gName").toString(), Float.parseFloat(p.get("amount").toString()), orderId,Float.parseFloat(p.get("gPrice").toString()));
if (i1==0){
//代表插入失败
return 0;
}
}
int i = orderMapper.generateOrder(orderId, payment, address, creationTime, userId, orderStatus);
if(i==0){
//代表插入失败
return 0;
}
return 1;
}
//根据用户id来获取订单页面的展示数据
public List<OrderShow> getOrderShowService(String userId){
// float total=0;
ArrayList<OrderShow> orderShows = new ArrayList<>();
List<OrderList> orderLists = orderMapper.selectOrderByUserId(userId);
// OrderShow orderShow = new OrderShow();
for (OrderList orderList:orderLists
) {
OrderShow orderShow = new OrderShow();
// //筛选出没有接单的订单
// if(orderList.getOrderStatus()==1)
// continue;
// total+=orderList.getPayment();
orderShow.setAddress(orderList.getAddress());
orderShow.setCreationTime(orderList.getCreationTime());
orderShow.setOrderStatus(orderList.getOrderStatus());
orderShow.setTotal(orderList.getPayment());
orderShow.setOrderId(orderList.getId());
List<CommodityList> commodityLists = commodityListMapper.selectOrderListInfo(orderList.getId());
orderShow.setCommodityLists(commodityLists);
orderShows.add(orderShow);
}
return orderShows;
}
// 根据订单id来搜索订单
public Map<String,Object> getOrderByOrderId(String orderId){
OrderList orderList = orderMapper.selectOrderById(orderId);
Map<String, Object> stringObjectMap = new HashMap<>();
stringObjectMap.put("garbageOrder",orderList);
List<CommodityList> commodityLists = commodityListMapper.selectOrderListInfo(orderId);
stringObjectMap.put("commodityList",commodityLists);
User userInfoById = userMapper.getUserInfoById(orderList.getUserid());
stringObjectMap.put("user",userInfoById);
User cycleInfoById = userMapper.getUserInfoById(orderList.getCycleid());
stringObjectMap.put("cycle",cycleInfoById);
return stringObjectMap;
}
//根据订单的状态来获取订单
public List<Map<String,Object>> getOrderInfoByOrderStatus(int status){
// HashMap<String, Object> stringObjectHashMap = new HashMap<>();
ArrayList<Map<String, Object>> lists = new ArrayList<>();
List<OrderList> orderInfoByOrderStatus = orderMapper.getOrderInfoByOrderStatus(status);
// 没有接单的订单
// stringObjectHashMap.put("garbageOrder",orderInfoByOrderStatus);
//
for (OrderList orderList:orderInfoByOrderStatus
) {
User userInfoById = userMapper.getUserInfoById(orderList.getUserid());
List<CommodityList> commodityLists = commodityListMapper.selectOrderListInfo(orderList.getId());
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
stringObjectHashMap.put("garbageOrder",orderList);
stringObjectHashMap.put("user",userInfoById);
stringObjectHashMap.put("commodity",commodityLists);
lists.add(stringObjectHashMap);
}
return lists;
}
/*
* 改变订单的状态,将回收金额加到订单用户账户的金额上
* */
public int receiveOrderService(String orderId,String userId){
OrderList orderList = orderMapper.selectOrderById(orderId);
//订单的金额加上已有的金额
float newAmount= userMapper.getUserInfoById(orderList.getUserid()).getMoney()+orderList.getPayment();
int i = userMapper.updateUserMoney(orderList.getUserid(), newAmount);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String endTime = simpleDateFormat.format(new Date());
int i1 = orderMapper.changeOrderStatus(orderId, endTime,userId,2);
if (i==1&&i1==1){
return 1;
}
return 0;
}
//根据回收人员id来获取订单
public List<Map<String,Object>> getOrderInfoByCycleId(String cycleId){
// HashMap<String, Object> stringObjectHashMap = new HashMap<>();
ArrayList<Map<String, Object>> lists = new ArrayList<>();
List<OrderList> orderLists = orderMapper.selectOrderByCycleId(cycleId);
for (OrderList orderList:orderLists
) {
// 通过订单的用户id获取用户的信息
User userInfoById = userMapper.getUserInfoById(orderList.getUserid());
HashMap<St
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java基于javaweb的垃圾分类管理系统源码+数据库+运行文档(高分课程设计)该项目是个人大作业项目源码,项目中的源码都是经过本地编译过可运行的,都经过严格调试,确保可以运行!!!评审分达到95分以上。资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。 Java基于javaweb的垃圾分类管理系统源码+数据库+运行文档(高分课程设计)该项目是个人大作业项目源码,项目中的源码都是经过本地编译过可运行的,都经过严格调试,确保可以运行!!!评审分达到95分以上。资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。 Java基于javaweb的垃圾分类管理系统源码+数据库+运行文档(高分课程设计)该项目是个人大作业项目源码,项目中的源码都是经过本地编译过可运行的,都经过严格调试,确保可以运行!!!评审分达到95分以上。资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。Java基于javaweb的垃圾分类管理系统。
资源推荐
资源详情
资源评论
收起资源包目录
Java基于javaweb的垃圾分类管理系统源码+数据库+运行文档(高分课程设计) (104个子文件)
.browserslistrc 21B
mvnw.cmd 6KB
global.css 203B
.editorconfig 121B
.gitignore 333B
.gitignore 214B
index.html 613B
favicon.ico 4KB
maven-wrapper.jar 50KB
OrderService.java 8KB
GarbageService.java 6KB
GarbageController.java 5KB
MavenWrapperDownloader.java 5KB
OrderController.java 4KB
FtpUtil.java 4KB
UserController.java 4KB
WebSocketServerController.java 4KB
UserService.java 4KB
User.java 3KB
ServerResponse.java 2KB
OrderList.java 2KB
Garbage.java 2KB
OrderShow.java 2KB
GarbageMapper.java 1KB
UserMapper.java 1KB
Commodity.java 1KB
ImageServerConfig.java 1KB
ApplicationContextUtil.java 1KB
CommodityList.java 1KB
SwaggerConfig.java 1KB
CrosFilter.java 1KB
EncodingFilter.java 1021B
OrderListMapper.java 1014B
GcRouterController.java 914B
gcSystemRouter.java 860B
IGarbageService.java 630B
ResponseCodeEnum.java 499B
CommodityListMapper.java 498B
MsgVO.java 487B
GarbagecollectionApplication.java 422B
WebSocketConfig.java 387B
IUserService.java 320B
IOrderService.java 317B
GcSystemRouterMapper.java 263B
GarbagecollectionApplicationTests.java 237B
garbagePropaganda3.jpeg 102KB
beauty.jpg 2.41MB
sight.jpg 1.23MB
3.jpg 1.12MB
garbagePropaganda2.jpg 235KB
garbagePropaganda.jpg 94KB
virusjpg.jpg 14KB
2.jpg 14KB
index.js 4KB
quill-config.js 3KB
element.js 1KB
login.js 842B
request.js 734B
vue.config.js 729B
main.js 590B
index.js 368B
.eslintrc.js 346B
babel.config.js 213B
getters.js 88B
package-lock.json 484KB
package.json 1KB
mvnw 10KB
login.png 44KB
logo.png 7KB
application.properties 1KB
maven-wrapper.properties 218B
gc.sql 31KB
Cart.vue 10KB
AddGarbage.vue 7KB
Home.vue 7KB
Chat.vue 6KB
UserPage.vue 5KB
UserManage.vue 5KB
ImageIdentify.vue 5KB
CharacterAnimation.vue 4KB
Login.vue 4KB
Register.vue 4KB
BrowseOrder.vue 4KB
AlterPrice.vue 4KB
Manage.vue 4KB
Search.vue 3KB
MapGeo.vue 3KB
UploadImage.vue 2KB
ManageOrder.vue 2KB
Recycle.vue 2KB
Wet.vue 2KB
Harmful.vue 2KB
Dry.vue 2KB
WatchOrder.vue 2KB
MapSearch.vue 2KB
App.vue 180B
pom.xml 9KB
mybatis-generator.xml 3KB
GarbageMapper.xml 2KB
UserMapper.xml 2KB
共 104 条
- 1
- 2
资源评论
盈梓的博客
- 粉丝: 9341
- 资源: 2248
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Muse Vue Ant Design 仪表板 - 免费且开源的 Ant Design Vue 仪表板.zip
- Laravel-Vue SPA 入门套件 .zip
- 非机动车未带安全帽检测数据集VOC+YOLO格式1000张4类别.zip
- Geist 的 Vue 实现.zip
- Electron + Vue仿网易云音乐windows客户端.zip
- Dropzone.js 的 Vue.js 组件 - 带有图像预览的拖放文件上传实用程序.zip
- vue框架开发,如何在vue框架下编写代码介绍
- 移动机器人路径规划实战,入门教程实验代码
- Chart.js 的 Vue.js 包装器.zip
- BootstrapVue 为 Vue.js 提供了最全面的 Bootstrap v4 实现之一 具有广泛且自动化的 WAI-ARIA 可访问性标记 .zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功