This commit is contained in:
parent
208ea2de17
commit
f3bfb8f745
|
|
@ -3,6 +3,7 @@ package live.tomey.api.express.controller;
|
|||
import live.tomey.api.express.aop.PassToken;
|
||||
import live.tomey.api.express.aop.Root;
|
||||
import live.tomey.api.express.dto.Result;
|
||||
import live.tomey.api.express.dto.ServerResult;
|
||||
import live.tomey.api.express.entity.Price;
|
||||
import live.tomey.api.express.enums.OrderEnum;
|
||||
import live.tomey.api.express.service.PriceSercie;
|
||||
|
|
@ -32,6 +33,55 @@ public class PriceController {
|
|||
@Autowired
|
||||
private PriceSercie priceSercie;
|
||||
|
||||
/**
|
||||
* 添加价格
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Root
|
||||
@RequestMapping(value = "addprice",method = RequestMethod.POST)
|
||||
private Result addPrice(HttpServletRequest request){
|
||||
try {
|
||||
Double prices = HttpServletRequestUtil.getDouble(request,"price");
|
||||
String desc = HttpServletRequestUtil.getString(request,"desc");
|
||||
Price price = new Price(prices,desc);
|
||||
ServerResult serverResult = priceSercie.addPrice(price);
|
||||
if (serverResult.isStart()){
|
||||
return new Result(true,1,serverResult.getMsg());
|
||||
}else {
|
||||
return new Result(false,-1,serverResult.getMsg());
|
||||
}
|
||||
}catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除价格
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Root
|
||||
@RequestMapping(value = "/removeprice",method = RequestMethod.POST)
|
||||
private Result removePrice(HttpServletRequest request){
|
||||
try {
|
||||
Integer id = HttpServletRequestUtil.getInteger(request,"id");
|
||||
ServerResult serverResult = priceSercie.removePrice(id);
|
||||
if (serverResult.isStart()){
|
||||
return new Result(true,1,serverResult.getMsg());
|
||||
}else {
|
||||
return new Result(false,-1,serverResult.getMsg());
|
||||
}
|
||||
}catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 快递类型和价格
|
||||
* @param request
|
||||
|
|
|
|||
|
|
@ -12,6 +12,20 @@ import java.util.List;
|
|||
* @date 2020/12/3 19:07
|
||||
*/
|
||||
public interface PriceDao {
|
||||
|
||||
/**
|
||||
* 删除价格
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Integer deletePrice(@Param("id") Integer id);
|
||||
/**
|
||||
* 新增价格表
|
||||
* @param price
|
||||
* @return
|
||||
*/
|
||||
Integer insertPrice(@Param("price") Price price);
|
||||
|
||||
/**
|
||||
* 获取快递类型
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -2,25 +2,29 @@ package live.tomey.api.express.entity;
|
|||
|
||||
public class Price {
|
||||
|
||||
private long id;
|
||||
private Integer id;
|
||||
private double price;
|
||||
private String desc;
|
||||
|
||||
public Price(long id, double price, String desc) {
|
||||
public Price(double price, String desc) {
|
||||
this.price = price;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Price(Integer id, double price, String desc) {
|
||||
this.id = id;
|
||||
this.price = price;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package live.tomey.api.express.service;
|
||||
|
||||
import live.tomey.api.express.dto.ServerResult;
|
||||
import live.tomey.api.express.entity.Price;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -11,6 +12,11 @@ import java.util.List;
|
|||
* @date 2020/12/3 19:28
|
||||
*/
|
||||
public interface PriceSercie {
|
||||
|
||||
ServerResult addPrice(Price price);
|
||||
|
||||
ServerResult removePrice(Integer id);
|
||||
|
||||
List<Price> getAllPrice();
|
||||
|
||||
Integer editPrice(Price price);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,16 @@ public class MailConfigServiceImpl implements MailConfigService {
|
|||
return new ServerResult(false,"密码为空");
|
||||
}
|
||||
String title = "测试邮件";
|
||||
String content = "你好"+mailConfig.getTestMail()+"这是一封测试邮件";
|
||||
String content = "<div class=\"text2\">\n" +
|
||||
" 尊敬的用户您好:\n" +
|
||||
" </div>\n" +
|
||||
" <div class=\"text3\">\n" +
|
||||
" 这是一封测试邮件!<br/><br/>\n" +
|
||||
" </div>\n" +
|
||||
" <div class=\"text4\">\n" +
|
||||
" <br/><br/>\n" +
|
||||
" \n" +
|
||||
" </div>";
|
||||
account.setEmail(mailConfig.getTestMail());
|
||||
boolean type = MailUnit.sendTheMail(account,mailConfig,title,content);
|
||||
if (type){
|
||||
|
|
|
|||
|
|
@ -153,19 +153,29 @@ public class OrderServiceImpl implements OrderService {
|
|||
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
||||
} else {
|
||||
Integer type = orderDao.editCourierPicks(orderModifyState);
|
||||
Account account = accountDao.queryAccountForOrderId(orderModifyState.getId());
|
||||
if (type == 1) {
|
||||
// todo 发送快递员领取任务邮件
|
||||
Date nowDate = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
|
||||
String title = "接单成功";
|
||||
String content = "您发布的订单在"+simpleDateFormat.format(nowDate.getTime())+"被配送员 "+courier.getUsername()+" 接单啦,联系电话为:"+courier.getPhone()+"邮箱为:"+courier.getEmail()+"详情在我的订单>>当前订单 查看";
|
||||
Account account = accountDao.queryAccountForOrderId(orderModifyState.getId());
|
||||
Messages messages = new Messages(account.getId(),title,content);
|
||||
String title = "校园小飞侠系统提醒您";
|
||||
String msgcontent = "您发布的订单在"+simpleDateFormat.format(nowDate.getTime())+"被配送员 "+courier.getUsername()+" 接单啦,联系电话为:"+courier.getPhone()+"邮箱为:"+courier.getEmail()+"详情在我的订单>>当前订单 查看";
|
||||
String mailcontent = "<div class=\"text2\">\n" +
|
||||
"\t\t\t尊敬的"+account.getUsername()+"您好:\n" +
|
||||
"\t\t</div>\n" +
|
||||
"\t\t<div class=\"text3\">\n" +
|
||||
"\t\t\t您的快递已被小飞侠"+simpleDateFormat.format(nowDate.getTime())+"代取!<br /><br />\n" +
|
||||
"\t\t</div>\n" +
|
||||
"\t\t<div class=\"text4\">\n" +
|
||||
"\t\t\t代取时间:"+simpleDateFormat.format(nowDate.getTime())+"<br /><br />\n" +
|
||||
"\t\t\t联系方式:"+courier.getPhone()+" \n" +
|
||||
"\t\t</div>";
|
||||
Messages messages = new Messages(account.getId(),title,msgcontent);
|
||||
Integer mtype = messagesDao.insertMessage(messages);
|
||||
if (mtype !=1 ){
|
||||
logger.error("信息发送失败");
|
||||
}
|
||||
sendMail(account,title,content);
|
||||
sendMail(account,title,mailcontent);
|
||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
||||
} else {
|
||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
||||
|
|
@ -219,16 +229,26 @@ public class OrderServiceImpl implements OrderService {
|
|||
Account account = accountDao.queryAccountForOrderId(orderModifyState.getId());
|
||||
Date nowDate = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
|
||||
String title = "快递送达";
|
||||
String content = "派送员与:"+simpleDateFormat.format(nowDate.getTime())+"申请订单完成!<br> 派送员姓名:"+courier.getUsername()+" <br>联系电话为:"+courier.getPhone()+"<br>邮箱为:"+courier.getEmail()+"<br>您是否收到快递? \n" +
|
||||
String title = "校园小飞侠系统提醒您";
|
||||
String msgcontent = "派送员与:"+simpleDateFormat.format(nowDate.getTime())+"申请订单完成!派送员姓名:"+courier.getUsername()+"联系电话为:"+courier.getPhone()+"邮箱为:"+courier.getEmail()+"您是否收到快递? \n" +
|
||||
" 收到快递则可在 我的订单>>当前订单 选择完成订单.\n" +
|
||||
" 很高兴为您服务,欢迎再次使用";
|
||||
Messages messages = new Messages(account.getId(),title,content);
|
||||
String mailcontent = "<div class=\"text2\">\n" +
|
||||
"\t\t\t尊敬的"+account.getUsername()+"您好:\n" +
|
||||
"\t\t</div>\n" +
|
||||
"\t\t<div class=\"text3\">\n" +
|
||||
"\t\t\t您的快递已被小飞侠"+simpleDateFormat.format(nowDate.getTime())+"送达!<br /><br />\n" +
|
||||
"\t\t</div>\n" +
|
||||
"\t\t<div class=\"text4\">\n" +
|
||||
"\t\t\t送达时间:"+courier.getPhone()+"<br /><br />\n" +
|
||||
"\t\t\t联系方式:"+courier.getPhone()+" \n" +
|
||||
"\t\t</div>";
|
||||
Messages messages = new Messages(account.getId(),title,msgcontent);
|
||||
Integer mtype = messagesDao.insertMessage(messages);
|
||||
if (mtype !=1 ){
|
||||
logger.error("信息发送失败");
|
||||
}
|
||||
sendMail(account,title,content);
|
||||
sendMail(account,title,mailcontent);
|
||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
||||
} else {
|
||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package live.tomey.api.express.service.impl;
|
||||
|
||||
import live.tomey.api.express.dao.PriceDao;
|
||||
import live.tomey.api.express.dto.ServerResult;
|
||||
import live.tomey.api.express.entity.Price;
|
||||
import live.tomey.api.express.service.PriceSercie;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -23,15 +24,58 @@ public class PriceSercieImpl implements PriceSercie {
|
|||
@Autowired
|
||||
private PriceDao priceDao;
|
||||
|
||||
/**
|
||||
* 添加价格
|
||||
*
|
||||
* @param price
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResult addPrice(Price price) {
|
||||
try {
|
||||
Integer count = priceDao.insertPrice(price);
|
||||
if (count>0){
|
||||
return new ServerResult(true,"添加成功!");
|
||||
}else {
|
||||
return new ServerResult(false,"操作失败!");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult(false,"操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除价格
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResult removePrice(Integer id) {
|
||||
try {
|
||||
Integer count = priceDao.deletePrice(id);
|
||||
if (count>0){
|
||||
return new ServerResult(true,"删除成功!");
|
||||
}else {
|
||||
return new ServerResult(false,"删除失败!");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult(false,"操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有快递类型列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Price> getAllPrice() {
|
||||
try {
|
||||
return priceDao.queryAllPrice();
|
||||
}catch (RuntimeException e){
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
|
@ -39,6 +83,7 @@ public class PriceSercieImpl implements PriceSercie {
|
|||
|
||||
/**
|
||||
* 修改快递类型价格
|
||||
*
|
||||
* @param price
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -46,7 +91,7 @@ public class PriceSercieImpl implements PriceSercie {
|
|||
public Integer editPrice(Price price) {
|
||||
try {
|
||||
return priceDao.upadtePrice(price);
|
||||
}catch (RuntimeException e){
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
m<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="live.tomey.api.express.dao.MessagesDao">
|
||||
|
|
|
|||
|
|
@ -3,12 +3,20 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="live.tomey.api.express.dao.PriceDao">
|
||||
|
||||
<insert id="insertPrice" parameterType="live.tomey.api.express.entity.Price" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
INSERT INTO w_price(w_price.price,w_price.desc) VALUES (#{price.price},#{desc})
|
||||
</insert>
|
||||
<select id="queryAllPrice" resultType="live.tomey.api.express.entity.Price">
|
||||
SELECT * FROM w_price
|
||||
</select>
|
||||
<select id="queryPriceById" resultType="live.tomey.api.express.entity.Price">
|
||||
SELECT * FROM w_price WHERE id = #{id}
|
||||
</select>
|
||||
<delete id="deletePrice">
|
||||
DELETE FROM w_price WHERE w_price.id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="upadtePrice" parameterType="live.tomey.api.express.entity.Price" >
|
||||
UPDATE w_price
|
||||
<set>
|
||||
|
|
|
|||
Loading…
Reference in New Issue