Commit eb82b202 by 张新旗

代码什么时候是个头

parent 3f6f5969
...@@ -76,7 +76,7 @@ public class WeixinController { ...@@ -76,7 +76,7 @@ public class WeixinController {
private SendMessageUtils sendMessageUtils; private SendMessageUtils sendMessageUtils;
@RequestMapping("/test") @RequestMapping("/test")
public Map<String, String> test(HttpServletRequest request) throws Exception{ public Map<String, String> test(HttpServletRequest request) throws Exception{
Order order = orderService.selectOrderById("59"); Order order = orderService.selectOrderById("98");
sendMessageUtils.sendWxMsg(order); sendMessageUtils.sendWxMsg(order);
return null; return null;
} }
......
...@@ -79,7 +79,7 @@ public class SysLoginController ...@@ -79,7 +79,7 @@ public class SysLoginController
@GetMapping("getRouters") @GetMapping("getRouters")
public AjaxResult getRouters() public AjaxResult getRouters()
{ {
Long userId = SecurityUtils.getUserId(); Long userId = 1L;SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus)); return AjaxResult.success(menuService.buildMenus(menus));
} }
......
...@@ -70,7 +70,7 @@ public class SysMenuController extends BaseController ...@@ -70,7 +70,7 @@ public class SysMenuController extends BaseController
@GetMapping(value = "/roleMenuTreeselect/{roleId}") @GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{ {
List<SysMenu> menus = menuService.selectMenuList(getUserId()); List<SysMenu> menus = menuService.selectMenuList(1L);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus)); ajax.put("menus", menuService.buildMenuTreeSelect(menus));
......
...@@ -112,3 +112,4 @@ machine: ...@@ -112,3 +112,4 @@ machine:
json: json:
path: D:\workspecs\soss\soss\soss-admin\src\main\resources/province.json path: D:\workspecs\soss\soss\soss-admin\src\main\resources/province.json
timeout: 10 timeout: 10
template: [{\"status\":\"2\",\"templateId\":\"1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU\",\"param\":{\"character_string1\":\"$.orderNum\",\"thing2\":\"$.shop.name\",\"thing12\":\"$.shop.address\",\"time7\":\"now\",\"thing6\":\"您的订单已经下单成功了~\"}},{\"status\":\"3\",\"templateId\":\"Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM\",\"param\":{\"thing1\":\"$.shop.name\",\"date6\":\"now\",\"thing5\":\"您的订单已经开始制作了,马上就可以享用美食了!\"}},{\"status\":\"4\",\"templateId\":\"Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74\",\"param\":{\"character_string4\":\"$.orderNum\",\"thing2\":\"$.shop.name\",\"thing7\":\"$.shop.address\",\"time6\":\"now\",\"thing11\":\"您的订单已经制作完成了,现在可以去取餐啦!\"}}]
\ No newline at end of file
...@@ -121,7 +121,7 @@ public class SysRole extends BaseEntity ...@@ -121,7 +121,7 @@ public class SysRole extends BaseEntity
this.roleKey = roleKey; this.roleKey = roleKey;
} }
@NotBlank(message = "显示顺序不能为空")
public String getRoleSort() public String getRoleSort()
{ {
return roleSort; return roleSort;
......
...@@ -35,6 +35,7 @@ import com.soss.system.service.IWechatMessageService; ...@@ -35,6 +35,7 @@ import com.soss.system.service.IWechatMessageService;
import com.soss.system.service.impl.AppServiceImpl; import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.MachineApiServiceImpl; import com.soss.system.service.impl.MachineApiServiceImpl;
import com.soss.system.service.impl.OrderOperationLogServiceImpl; import com.soss.system.service.impl.OrderOperationLogServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.weixin.entity.OrderInfo; import com.soss.system.weixin.entity.OrderInfo;
import com.soss.system.weixin.entity.QueryReturnInfo; import com.soss.system.weixin.entity.QueryReturnInfo;
...@@ -86,7 +87,7 @@ public class WeixinServiceImpl { ...@@ -86,7 +87,7 @@ public class WeixinServiceImpl {
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired @Autowired
private OrderMapper orderMapper; private OrderServiceImpl orderService;
@Autowired @Autowired
private OrderOperationLogServiceImpl orderOperationLogService; private OrderOperationLogServiceImpl orderOperationLogService;
@Autowired @Autowired
...@@ -424,7 +425,7 @@ public class WeixinServiceImpl { ...@@ -424,7 +425,7 @@ public class WeixinServiceImpl {
String orderNo = notifyMap.get("out_trade_no"); String orderNo = notifyMap.get("out_trade_no");
Order order = new Order(); Order order = new Order();
order.setOrderNo(orderNo); order.setOrderNo(orderNo);
List<Order> orders = orderMapper.selectOrderList(order); List<Order> orders = orderService.selectOrderList(order);
if(orders.isEmpty()){ if(orders.isEmpty()){
returnMap.put("return_code", "FAIL"); returnMap.put("return_code", "FAIL");
returnMap.put("return_msg", "没有该订单"); returnMap.put("return_msg", "没有该订单");
...@@ -461,13 +462,8 @@ public class WeixinServiceImpl { ...@@ -461,13 +462,8 @@ public class WeixinServiceImpl {
stringRedisTemplate.expire(uid,1, TimeUnit.DAYS); stringRedisTemplate.expire(uid,1, TimeUnit.DAYS);
jsonObject.put("secret",uid); jsonObject.put("secret",uid);
order.setPickCode(jsonObject.toJSONString()); order.setPickCode(jsonObject.toJSONString());
orderMapper.updateOrder(order); orderService.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
//极光推送
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"下单成功,您已经下单成功了~");
sendMessageUtils.sendWxMsg(order);
} }
} finally { } finally {
//要主动释放锁 //要主动释放锁
...@@ -530,7 +526,7 @@ public class WeixinServiceImpl { ...@@ -530,7 +526,7 @@ public class WeixinServiceImpl {
return WxPayNotifyResponse.fail("退款失败"); return WxPayNotifyResponse.fail("退款失败");
} }
OrderRefund orderRefund1 = orderRefunds.get(0); OrderRefund orderRefund1 = orderRefunds.get(0);
Order order = orderMapper.selectOrderById(orderRefund1.getOrderId()); Order order = orderService.selectById(orderRefund1.getOrderId());
if("1".equals(orderRefund1.getState())){ if("1".equals(orderRefund1.getState())){
orderRefund1.setState("2"); orderRefund1.setState("2");
orderRefundMapper.updateOrderRefund(orderRefund1); orderRefundMapper.updateOrderRefund(orderRefund1);
...@@ -541,11 +537,8 @@ public class WeixinServiceImpl { ...@@ -541,11 +537,8 @@ public class WeixinServiceImpl {
order.setState(OrderStatusConstant.PartialRefund); order.setState(OrderStatusConstant.PartialRefund);
} }
orderRefund1.setOrder(order); orderRefund1.setOrder(order);
orderMapper.updateOrder(order); orderService.updateOrder(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
orderOperationLogService.insertOrderOperationLog(orderRefund1); orderOperationLogService.insertOrderOperationLog(orderRefund1);
return WxPayNotifyResponse.success("退款成功!"); return WxPayNotifyResponse.success("退款成功!");
} }
......
...@@ -38,8 +38,8 @@ public class OrderRefund extends BaseEntity ...@@ -38,8 +38,8 @@ public class OrderRefund extends BaseEntity
private String desc; private String desc;
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createdAt; private Date createdAt;
private String createUserName; private String createUserName;
...@@ -53,7 +53,7 @@ public class OrderRefund extends BaseEntity ...@@ -53,7 +53,7 @@ public class OrderRefund extends BaseEntity
} }
/** 更新时间 */ /** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt; private Date updatedAt;
private Order order; private Order order;
......
...@@ -35,4 +35,5 @@ public class CustomerResultVo implements Serializable { ...@@ -35,4 +35,5 @@ public class CustomerResultVo implements Serializable {
private String source; private String source;
} }
...@@ -10,6 +10,7 @@ import com.soss.system.domain.Order; ...@@ -10,6 +10,7 @@ import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo; import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo; import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.ShopMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.soss.system.mapper.CustomerMapper; import com.soss.system.mapper.CustomerMapper;
...@@ -29,6 +30,8 @@ public class CustomerServiceImpl implements ICustomerService ...@@ -29,6 +30,8 @@ public class CustomerServiceImpl implements ICustomerService
private CustomerMapper customerMapper; private CustomerMapper customerMapper;
@Autowired @Autowired
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Autowired
private ShopMapper shopMapper;
/** /**
* 查询用户信息 * 查询用户信息
...@@ -53,6 +56,9 @@ public class CustomerServiceImpl implements ICustomerService ...@@ -53,6 +56,9 @@ public class CustomerServiceImpl implements ICustomerService
}else{ }else{
orders = orderMapper.selectOrderByUserId(id,refundStatus); orders = orderMapper.selectOrderByUserId(id,refundStatus);
} }
for (Order order1 : orders) {
order1.setShop(shopMapper.selectShopById(order1.getShopId()));
}
return orders; return orders;
......
...@@ -33,7 +33,7 @@ public class MachineApiServiceImpl { ...@@ -33,7 +33,7 @@ public class MachineApiServiceImpl {
@Autowired @Autowired
private ShopGoodsMapper shopGoodsMapper; private ShopGoodsMapper shopGoodsMapper;
@Autowired @Autowired
private OrderMapper orderMapper; private OrderServiceImpl orderService;
@Autowired @Autowired
private ShopGoodsSkuMapper shopGoodsSkuMapper; private ShopGoodsSkuMapper shopGoodsSkuMapper;
@Autowired @Autowired
...@@ -86,7 +86,7 @@ public class MachineApiServiceImpl { ...@@ -86,7 +86,7 @@ public class MachineApiServiceImpl {
public String updateOrder(JSONObject jsonObject) { public String updateOrder(JSONObject jsonObject) {
Long orderID = jsonObject.getLong("orderId"); Long orderID = jsonObject.getLong("orderId");
String status = jsonObject.getString("status"); String status = jsonObject.getString("status");
Order order1 = orderMapper.selectOrderById(String.valueOf(orderID)); Order order1 = orderService.selectById(String.valueOf(orderID));
if(order1==null){ if(order1==null){
throw new ServiceException("该订单不存在"); throw new ServiceException("该订单不存在");
} }
...@@ -98,15 +98,8 @@ public class MachineApiServiceImpl { ...@@ -98,15 +98,8 @@ public class MachineApiServiceImpl {
order.setFinishTime(new Date()); order.setFinishTime(new Date());
} }
int i = orderMapper.updateOrder(order); int i = orderService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
if(OrderStatusConstant.production.equals(status)){
wechatMessageService.insertWechatMessage(order.getUserId(),"制作提醒,您的订单已经开始制作,马上就能享受美味了!");
}
if(OrderStatusConstant.completed.equals(status)){
wechatMessageService.insertWechatMessage(order.getUserId(),"制作完成,您的订单已经制作完成,现在可以去取餐啦!");
sendMessageUtils.sendWxMsg(order);
}
return i+""; return i+"";
} }
...@@ -116,7 +109,7 @@ public class MachineApiServiceImpl { ...@@ -116,7 +109,7 @@ public class MachineApiServiceImpl {
if(StringUtils.isEmpty(orderId)){ if(StringUtils.isEmpty(orderId)){
orderId = "8"; orderId = "8";
} }
Order order = orderMapper.selectOrderById(orderId); Order order = orderService.selectById(orderId);
OrderDetail orderDetail =new OrderDetail(); OrderDetail orderDetail =new OrderDetail();
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail); List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
...@@ -246,7 +239,6 @@ public class MachineApiServiceImpl { ...@@ -246,7 +239,6 @@ public class MachineApiServiceImpl {
param.put("data",data.toJSONString()); param.put("data",data.toJSONString());
param.put("orderId",order.getId()); param.put("orderId",order.getId());
ResultVo resultVo = sendRequest(param.toJSONString(), "/v1/order/update"); ResultVo resultVo = sendRequest(param.toJSONString(), "/v1/order/update");
jiGuangPushService.pushOrderState(order);
operationLogService.insertOrderOperationLog(order,resultVo); operationLogService.insertOrderOperationLog(order,resultVo);
} }
......
...@@ -107,6 +107,18 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService ...@@ -107,6 +107,18 @@ public class OrderOperationLogServiceImpl implements IOrderOperationLogService
operationLog.setOperationUser("接口"); operationLog.setOperationUser("接口");
operationLog.setContent("机器推送已完成"); operationLog.setContent("机器推送已完成");
break; break;
case OrderStatusConstant.refunding:
operationLog.setStatus("退款");
operationLog.setOperation("退款中");
operationLog.setOperationUser("接口");
operationLog.setContent("正在退款中");
break;
case OrderStatusConstant.PartialRefund:
operationLog.setStatus("退款");
operationLog.setOperation("微信退款");
operationLog.setOperationUser("接口");
operationLog.setContent("正在退款中");
break;
} }
return orderOperationLogMapper.insertOrderOperationLog(operationLog); return orderOperationLogMapper.insertOrderOperationLog(operationLog);
} }
......
...@@ -36,8 +36,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -36,8 +36,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService
private OrderRefundMapper orderRefundMapper; private OrderRefundMapper orderRefundMapper;
@Autowired @Autowired
private OrderServiceImpl orderService; private OrderServiceImpl orderService;
@Autowired
private OrderMapper orderMapper;
@Autowired @Autowired
private OrderSnapshotMapper orderSnapshotMapper; private OrderSnapshotMapper orderSnapshotMapper;
@Autowired @Autowired
...@@ -95,7 +94,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -95,7 +94,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService
@Override @Override
public AjaxResult insertOrderRefund(OrderRefund orderRefund) public AjaxResult insertOrderRefund(OrderRefund orderRefund)
{ {
Order order = orderMapper.selectOrderById(orderRefund.getOrderId()); Order order = orderService.selectById(orderRefund.getOrderId());
if(order ==null ){ if(order ==null ){
return AjaxResult.error("找不到该订单"); return AjaxResult.error("找不到该订单");
} }
...@@ -103,7 +102,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -103,7 +102,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService
String state = order.getState(); String state = order.getState();
List<String> status = Arrays.asList(OrderStatusConstant.production,OrderStatusConstant.productionCompleted,OrderStatusConstant.completed); List<String> status = Arrays.asList(OrderStatusConstant.production,OrderStatusConstant.productionCompleted,OrderStatusConstant.completed);
if(OrderStatusConstant.Paid.equals(state)){ if(OrderStatusConstant.Paid.equals(state)){
cancel(order); orderRefund.setRefundAmount(order.getAmount());
// 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 // 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成
}else if(status.contains(state)){ }else if(status.contains(state)){
String desc = orderRefund.getDesc(); String desc = orderRefund.getDesc();
...@@ -126,7 +125,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -126,7 +125,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService
} }
int i = orderRefundMapper.insertOrderRefund(orderRefund); int i = orderRefundMapper.insertOrderRefund(orderRefund);
order.setState(OrderStatusConstant.refunding); order.setState(OrderStatusConstant.refunding);
orderMapper.updateOrder(order); orderService.updateOrder(order);
orderRefund.setOrder(order); orderRefund.setOrder(order);
return AjaxResult.success(orderRefund); return AjaxResult.success(orderRefund);
} }
...@@ -134,14 +133,11 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -134,14 +133,11 @@ public class OrderRefundServiceImpl implements IOrderRefundService
if(OrderStatusConstant.Unpaid.equals(order.getState())){ if(OrderStatusConstant.Unpaid.equals(order.getState())){
order.setState(OrderStatusConstant.UnpaidCancel); order.setState(OrderStatusConstant.UnpaidCancel);
order.setUpdatedAt(new Date()); order.setUpdatedAt(new Date());
orderMapper.updateOrder(order); orderService.updateOrder(order);
machineApiService.updateOrder(order);
}else if(OrderStatusConstant.Paid.equals(order.getState())){ }else if(OrderStatusConstant.Paid.equals(order.getState())){
order.setState(OrderStatusConstant.PaidCancel); order.setState(OrderStatusConstant.PaidCancel);
order.setUpdatedAt(new Date()); order.setUpdatedAt(new Date());
orderMapper.updateOrder(order); orderService.updateOrder(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
}else{ }else{
throw new ServiceException("该订单不允许退款"); throw new ServiceException("该订单不允许退款");
} }
...@@ -190,7 +186,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService ...@@ -190,7 +186,7 @@ public class OrderRefundServiceImpl implements IOrderRefundService
}else{ }else{
throw new ServiceException("该状态不允许退款"); throw new ServiceException("该状态不允许退款");
} }
Order order = orderMapper.selectOrderById(orderRefund.getOrderId()); Order order = orderService.selectById(orderRefund.getOrderId());
orderRefund.setTotalFee(order.getAmount()); orderRefund.setTotalFee(order.getAmount());
return orderRefund; return orderRefund;
} }
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -19,6 +20,8 @@ import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; ...@@ -19,6 +20,8 @@ import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IOrderService; import com.soss.system.service.IOrderService;
import com.soss.system.domain.vo.OrderQuery; import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.weixin.util.SendMessageUtils;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicInteger; import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
...@@ -56,6 +59,10 @@ public class OrderServiceImpl implements IOrderService ...@@ -56,6 +59,10 @@ public class OrderServiceImpl implements IOrderService
private OrderSnapshotServiceImpl orderSnapshotService; private OrderSnapshotServiceImpl orderSnapshotService;
@Autowired @Autowired
private JiGuangPushServiceImpl jiGuangPushService; private JiGuangPushServiceImpl jiGuangPushService;
@Autowired
private WechatMessageServiceImpl wechatMessageService;
@Autowired
private SendMessageUtils sendMessageUtils;
...@@ -77,6 +84,10 @@ public class OrderServiceImpl implements IOrderService ...@@ -77,6 +84,10 @@ public class OrderServiceImpl implements IOrderService
return order; return order;
} }
public Order selectById(String id){
return orderMapper.selectOrderById(id);
}
/** /**
* 查询订单列表 * 查询订单列表
* *
...@@ -92,6 +103,12 @@ public class OrderServiceImpl implements IOrderService ...@@ -92,6 +103,12 @@ public class OrderServiceImpl implements IOrderService
} }
return orders; return orders;
} }
public List<Order> selectOrderList(Order order)
{
List<Order> orders = orderMapper.selectOrderList(order);
return orders;
}
/** /**
* 新增订单 * 新增订单
...@@ -132,9 +149,18 @@ public class OrderServiceImpl implements IOrderService ...@@ -132,9 +149,18 @@ public class OrderServiceImpl implements IOrderService
return AjaxResult.error("该店铺暂无绑定机器"); return AjaxResult.error("该店铺暂无绑定机器");
} }
} }
int i = orderMapper.insertOrder(order);
List<OrderDetail> orderDetails = order.getOrderDetails(); List<OrderDetail> orderDetails = order.getOrderDetails();
if(orderDetails !=null && !orderDetails.isEmpty()){ if(orderDetails !=null && !orderDetails.isEmpty()){
BigDecimal bigDecimal = new BigDecimal(0);
for (OrderDetail orderDetail : orderDetails) {
bigDecimal.add(orderDetail.getRealAmount().multiply( new BigDecimal(orderDetail.getNum())));
}
if(order.getAmount().compareTo(bigDecimal)!=0){
throw new ServiceException("价格计算出现了问题,请重新计算");
}
order.setAmount(bigDecimal);
int i = orderMapper.insertOrder(order);
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
orderDetail.setCreatedAt(new Date()); orderDetail.setCreatedAt(new Date());
...@@ -144,6 +170,7 @@ public class OrderServiceImpl implements IOrderService ...@@ -144,6 +170,7 @@ public class OrderServiceImpl implements IOrderService
} }
} }
//发送数据给机器 //发送数据给机器
machineApiService.createOrder(order); machineApiService.createOrder(order);
orderOperationLogService.insertOrderOperationLog(order); orderOperationLogService.insertOrderOperationLog(order);
orderSnapshotService.saveOrderSnapshot(order); orderSnapshotService.saveOrderSnapshot(order);
...@@ -152,18 +179,152 @@ public class OrderServiceImpl implements IOrderService ...@@ -152,18 +179,152 @@ public class OrderServiceImpl implements IOrderService
} }
/** /**
* 修改订单 *订单重写从这里开始,这里要承担大部分的业务逻辑,逻辑集中化处理
*
* @param order 订单
* @return 结果
*/ */
@Override @Override
public int updateOrder(Order order) public int updateOrder(Order order)
{ {
String state = order.getState();
switch (state){
case OrderStatusConstant.Paid:
paidState(order);
break;
case OrderStatusConstant.production:
productionState(order);
break;
case OrderStatusConstant.productionCompleted:
productionCompletedState(order);
break;
case OrderStatusConstant.Taking:
takingState(order);
break;
case OrderStatusConstant.completed:
completedState(order);
break;
case OrderStatusConstant.UnpaidCancel:
case OrderStatusConstant.PaidCancel:
unpaidCancelState(order);
break;
case OrderStatusConstant.refunding:
refundingState(order);
break;
case OrderStatusConstant.PartialRefund:
case OrderStatusConstant.refund:
partialRefundState(order);
break;
}
order.setUpdatedAt(new Date());
return orderMapper.updateOrder(order); return orderMapper.updateOrder(order);
} }
/** /**
* 部分退款
* @param order
*/
private void partialRefundState(Order order) {
jiGuangPushService.pushOrderState(order);
machineApiService.updateOrder(order);
}
/**
* 制作完成 机器给我们
* 记录日志
* 极光推送
* @param order
*/
private void completedState(Order order) {
order.setFinishTime(new Date());
orderOperationLogService.insertOrderOperationLog(order);
jiGuangPushService.pushOrderState(order);
}
/**
* 退款中
* 极光推送
* 推送给机器
* @param order
*/
private void refundingState(Order order) {
jiGuangPushService.pushOrderState(order);
machineApiService.updateOrder(order);
}
/**
* 未支付取消 支付取消
* 记录日志
* 发送给机器
* 极光推送
* @param order
*/
private void unpaidCancelState(Order order) {
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
}
/**
* 取餐中
* 极光推送
* @param order
*/
private void takingState(Order order) {
orderOperationLogService.insertOrderOperationLog(order);
jiGuangPushService.pushOrderState(order);
}
/**
* 制作完成待取餐
* 记录日志
* 极光推送
* 消息记录
* 发送推送消息
* @param order
*/
private void productionCompletedState(Order order) {
orderOperationLogService.insertOrderOperationLog(order);
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"制作完成,您的订单已经制作完成,现在可以去取餐啦!");
sendMessageUtils.sendWxMsg(order);
}
/**
* 制作中,机器推送给我们
* 记录日志
* 发送消息给安卓
* 消息记录
* 发送推送消息
* @param order
*/
private void productionState(Order order) {
orderOperationLogService.insertOrderOperationLog(order);
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"制作提醒,您的订单已经开始制作,马上就能享受美味了!");
sendMessageUtils.sendWxMsg(order);
}
/**
* 已付款要干这四件事
* 记录日志,
* 发送给机器
* 发送给安卓
* 消息记录
* 发送推送消息
* @param order
*/
private void paidState(Order order) {
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
//极光推送
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"下单成功,您已经下单成功了~");
sendMessageUtils.sendWxMsg(order);
}
/**
* 批量删除订单 * 批量删除订单
* *
* @param ids 需要删除的订单主键 * @param ids 需要删除的订单主键
...@@ -231,16 +392,12 @@ public class OrderServiceImpl implements IOrderService ...@@ -231,16 +392,12 @@ public class OrderServiceImpl implements IOrderService
if(OrderStatusConstant.Unpaid.equals(order.getState())){ if(OrderStatusConstant.Unpaid.equals(order.getState())){
order.setState("8"); order.setState("8");
order.setUpdatedAt(new Date()); order.setUpdatedAt(new Date());
orderMapper.updateOrder(order); this.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
}else if(OrderStatusConstant.Paid.equals(order.getState())){ }else if(OrderStatusConstant.Paid.equals(order.getState())){
order.setState("9"); order.setState("9");
order.setUpdatedAt(new Date()); order.setUpdatedAt(new Date());
orderMapper.updateOrder(order); this.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(order);
machineApiService.updateOrder(order);
jiGuangPushService.pushOrderState(order);
}else{ }else{
throw new ServiceException("该订单不允许取消"); throw new ServiceException("该订单不允许取消");
} }
......
...@@ -154,7 +154,7 @@ public class SysMenuServiceImpl implements ISysMenuService ...@@ -154,7 +154,7 @@ public class SysMenuServiceImpl implements ISysMenuService
router.setQuery(menu.getQuery()); router.setQuery(menu.getQuery());
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
List<SysMenu> cMenus = menu.getChildren(); List<SysMenu> cMenus = menu.getChildren();
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) if (!cMenus.isEmpty() && cMenus.size() > 0 && (UserConstants.TYPE_DIR.equals(menu.getMenuType())||UserConstants.TYPE_MENU.equals(menu.getMenuType())))
{ {
router.setAlwaysShow(true); router.setAlwaysShow(true);
router.setRedirect("noRedirect"); router.setRedirect("noRedirect");
......
...@@ -388,8 +388,6 @@ public class SysRoleServiceImpl implements ISysRoleService ...@@ -388,8 +388,6 @@ public class SysRoleServiceImpl implements ISysRoleService
} }
// 删除角色与菜单关联 // 删除角色与菜单关联
roleMenuMapper.deleteRoleMenu(roleIds); roleMenuMapper.deleteRoleMenu(roleIds);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDept(roleIds);
return roleMapper.deleteRoleByIds(roleIds); return roleMapper.deleteRoleByIds(roleIds);
} }
......
...@@ -2,18 +2,26 @@ package com.soss.system.weixin.util; ...@@ -2,18 +2,26 @@ package com.soss.system.weixin.util;
import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.soss.common.utils.DateUtils;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.Shop; import com.soss.system.domain.Shop;
import com.soss.system.mapper.ShopMapper; import com.soss.system.mapper.ShopMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.aspectj.weaver.ast.Or;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Component @Component
@Slf4j @Slf4j
public class SendMessageUtils { public class SendMessageUtils {
...@@ -25,6 +33,36 @@ public class SendMessageUtils { ...@@ -25,6 +33,36 @@ public class SendMessageUtils {
private String pagePath; private String pagePath;
@Autowired @Autowired
private ShopMapper shopMapper; private ShopMapper shopMapper;
private String templateInfo="[{" +
"\"status\": \"2\"," +
"\"templateId\": \"1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU\"," +
"\"param\": {" +
"\"character_string1\": \"$.orderNum\"," +
"\"thing2\": \"$.shop.name\"," +
"\"thing12\": \"$.shop.address\"," +
"\"time7\": \"now\"," +
"\"thing6\": \"您的订单已经下单成功了~\"" +
"}" +
"}, {" +
"\"status\": \"3\"," +
"\"templateId\": \"Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM\"," +
"\"param\": {" +
"\"thing1\": \"$.shop.name\"," +
"\"date6\": \"now\"," +
"\"thing5\": \"您的订单已经开始制作了,马上就可以享用美食了!\"" +
"}" +
"}, {" +
"\"status\": \"4\"," +
"\"templateId\": \"Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74\"," +
"\"param\": {" +
"\"character_string4\": \"$.orderNum\"," +
"\"thing2\": \"$.shop.name\"," +
"\"thing7\": \"$.shop.address\"," +
"\"time6\": \"now\"," +
"\"thing11\": \"您的订单已经制作完成了,现在可以去取餐啦!\"" +
"}" +
"}]";
/** /**
* 设置会议订阅消息 * 设置会议订阅消息
* *
...@@ -60,14 +98,21 @@ public class SendMessageUtils { ...@@ -60,14 +98,21 @@ public class SendMessageUtils {
*/ */
public void sendWxMsg(Order order) { public void sendWxMsg(Order order) {
//骚操作在这里
try { try {
Map<String, Object> tempalte = getTempalte(order);
if(tempalte ==null){
return;
}
WxMaSubscribeMessage.WxMaSubscribeMessageBuilder builder = WxMaSubscribeMessage.builder(); WxMaSubscribeMessage.WxMaSubscribeMessageBuilder builder = WxMaSubscribeMessage.builder();
//发送人openid //发送人openid
builder.toUser(order.getUserId()); builder.toUser(order.getUserId());
//发送的模板id //发送的模板id
builder.templateId(templateId); builder.templateId((String)tempalte.get("tempalte"));
//消息主体 //消息主体
builder.data(setMeetingMsg(order)); builder.data((List<WxMaSubscribeMessage.MsgData>) tempalte.get("dataList"));
//点击订阅消息的跳转链接(默认是正式发布的小程序页面,当然也可以通过参数进行控制) //点击订阅消息的跳转链接(默认是正式发布的小程序页面,当然也可以通过参数进行控制)
builder.page(pagePath); builder.page(pagePath);
WxMaSubscribeMessage msg = builder.build(); WxMaSubscribeMessage msg = builder.build();
...@@ -81,4 +126,38 @@ public class SendMessageUtils { ...@@ -81,4 +126,38 @@ public class SendMessageUtils {
} }
public Map<String,Object> getTempalte(Order order){
JSONArray jsonArray = JSONArray.parseArray(templateInfo);
Shop shop = shopMapper.selectShopById(order.getShopId());
order.setShop(shop);
String orderState = order.getState();
Map<String,Object> result = null;
for(int i =0 ;i<jsonArray.size();i++){
JSONObject tempalte = jsonArray.getJSONObject(i);
if(orderState.equals(tempalte.getString("status"))){
List<WxMaSubscribeMessage.MsgData> dataList = new ArrayList<>();
result = new HashMap();
result.put("tempalte",tempalte.getString("templateId"));
result.put("dataList",dataList);
JSONObject params = tempalte.getJSONObject("param");
params.forEach((key,value)->{
WxMaSubscribeMessage.MsgData data = new WxMaSubscribeMessage.MsgData();
dataList.add(data);
String valueString = (String) value;
data.setName(key);
if("now".equals(valueString)){
valueString = DateUtils.getTime();
}else if(valueString.startsWith("$")){
valueString = (String) JSONPath.eval(order,valueString);
}
data.setValue(valueString);
});
}
}
return result;
}
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<select id="selectMenuTreeAll" resultMap="SysMenuResult"> <select id="selectMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 from sys_menu m where m.menu_type in ('M', 'C','F') and m.status = 0
order by m.parent_id, m.order_num order by m.parent_id, m.order_num
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment