| | |
| | | package com.matrix.system.hive.action; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | |
| | | import com.matrix.system.common.tools.ResponseHeadUtil; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.constance.SystemConstance; |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.AchieveNew; |
| | | import com.matrix.system.hive.bean.MoneyCardUse; |
| | | import com.matrix.system.hive.bean.SysOrder; |
| | | import com.matrix.system.hive.bean.SysOrderItem; |
| | | import com.matrix.system.hive.dao.MoneyCardUseDao; |
| | | import com.matrix.system.hive.dao.SysOrderDao; |
| | | import com.matrix.system.hive.dao.SysOrderItemDao; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItem; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | | import com.matrix.system.hive.service.AchieveNewService; |
| | | import com.matrix.system.hive.service.MoneyCardUseService; |
| | | import com.matrix.system.hive.service.SysOrderItemService; |
| | | import com.matrix.system.hive.service.SysOrderService; |
| | | import com.matrix.system.hive.service.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.ModelMap; |
| | |
| | | public class OrderController extends BaseController { |
| | | @Resource |
| | | private SysOrderService orderService; |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | private CodeService codeService; |
| | | |
| | | @Autowired |
| | | private SysOrderItemDao orderItemDao; |
| | |
| | | @Autowired |
| | | SysShopInfoDao shopInfoDao; |
| | | |
| | | @Autowired |
| | | private SysVipInfoService sysVipInfoService; |
| | | |
| | | @Autowired |
| | | private SysOrderFlowService sysOrderFlowService; |
| | | |
| | | @Autowired |
| | | private SysOrderFlowDao sysOrderFlowDao; |
| | | |
| | | @Autowired |
| | | RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | @Autowired |
| | | private SysProjServicesDao sysProjServicesDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | /** |
| | | * 计算订单金额 |
| | |
| | | AjaxResult payOrder(@RequestBody SysOrder sysOrder) { |
| | | SysUsers user = getMe(); |
| | | sysOrder.setShopId(user.getShopId()); |
| | | sysOrder.setOrderType(SysOrder.ORDER_TYPE_SEAL); |
| | | sysOrder.setIsHasRefund(SysOrder.IS_HAS_REFUND_N); |
| | | //校验订单是否满足结算调价,新订单则保存订单,已有订单则删除后更新 |
| | | sysOrder = orderService.checkAndSaveOrder(sysOrder); |
| | | orderService.updateReceiptMoney(sysOrder); |
| | | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam=new UniformMsgParam(user.getCompanyId(),UniformMsgParam.GZH_GMCG); |
| | | uniformMsgParam.put("orderId",sysOrder.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); |
| | | |
| | | |
| | | //处理用户购买的产品 |
| | | return AjaxResult.buildSuccessInstance(Arrays.asList(sysOrder), "订单结算成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 退款 |
| | | * |
| | | * @param sysOrder |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/refundOrder") |
| | | @ResponseBody |
| | | public AjaxResult refundOrder(@RequestBody SysOrder sysOrder) { |
| | | //储值卡订单不能通过退款渠道退款 |
| | | if(CollectionUtils.isNotEmpty(sysOrder.getItems())){ |
| | | List<SysOrderItem> orderItem = orderItemService.findByOrderId(sysOrder.getItems().get(0).getOrderId()); |
| | | if(orderItem.size()==1){ |
| | | if(orderItem.get(0).getShoppingGoods().getCode().equals("vipCzk")){ |
| | | return AjaxResult.buildFailInstance("充值订单请直接冲负数金额退款!"); |
| | | } |
| | | } |
| | | } |
| | | orderService.refundOrderMoney(sysOrder); |
| | | //处理用户购买的产品 |
| | | return AjaxResult.buildSuccessInstance(Arrays.asList(sysOrder), "订单退款成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | //处理用户购买的产品 |
| | | return AjaxResult.buildSuccessInstance(Arrays.asList(sysOrder), "订单保存成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新建订单 |
| | |
| | | } |
| | | //设置过滤后的购物车条目 |
| | | car.setCarItems(carItems); |
| | | |
| | | SysVipInfo info = (SysVipInfo) WebUtil.getSession().getAttribute(SystemConstance.CURRENT_CUSTOMER); |
| | | car.setVipId(info.getId()); |
| | | |
| | | // 添加新订单 |
| | | int i = orderService.createOrder(WebUtil.getSession(), car); |
| | |
| | | public @ResponseBody |
| | | AjaxResult updateOrderTime(SysOrder sysOrder) { |
| | | |
| | | sysOrderDao.updateOrderTime(sysOrder.getOrderTime(), sysOrder.getId()); |
| | | sysOrderDao.updateOrderTime(sysOrder.getPayTime(), sysOrder.getId()); |
| | | // 修改业绩时间 |
| | | // 更新业绩时间 |
| | | AchieveNew achieveNew = new AchieveNew(); |
| | | achieveNew.setOrderId(sysOrder.getId()); |
| | | achieveNew.setDatatime(sysOrder.getOrderTime()); |
| | | achieveNew.setDatatime(sysOrder.getPayTime()); |
| | | achieveNewService.modifyAchieveTime(achieveNew); |
| | | //更新收款流水时间 |
| | | sysOrderFlowDao.updateTimeByOrderId(sysOrder.getId(),sysOrder.getPayTime()); |
| | | |
| | | |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功"); |
| | | } |
| | | |
| | |
| | | MoneyCardUse cardUseInfo = cardUseService.findByVipId(order.getVipId()); |
| | | |
| | | if (cardUseInfo == null) { |
| | | cardUseInfo = new MoneyCardUse(); |
| | | cardUseInfo.setVipId(order.getVipId()); |
| | | cardUseInfo.setCardName("储值卡"); |
| | | cardUseInfo.setIsVipCar(Dictionary.FLAG_YES_Y); |
| | | cardUseInfo.setRealMoney(0D); |
| | | cardUseInfo.setGiftMoney(0D); |
| | | cardUseInfo.setSource("-"); |
| | | cardUseInfo.setStatus(Dictionary.MONEYCARD_STATUS_YX); |
| | | cardUseInfo.setFailTime(DateUtil.stringToDate("2050-01-01 00:00",DateUtil.DATE_FORMAT_MM)); |
| | | moneyCardUseDao.insert(cardUseInfo); |
| | | cardUseInfo=sysVipInfoService.addVipDefaultCard(order.getVipId()); |
| | | } |
| | | |
| | | //打印需求加入门店信息 |
| | |
| | | return "admin/hive/beautySalon/point-order"; |
| | | } |
| | | |
| | | @RequestMapping(value = "/findOrderDetailByIdOrNo") |
| | | @ResponseBody |
| | | public AjaxResult findOrderDetailByIdOrNo(SysOrder orderVo) { |
| | | // 根据id查到对应的订单信息 |
| | | SysOrder order=null; |
| | | if(orderVo.getId()!=null){ |
| | | order = orderService.findById(orderVo.getId()); |
| | | }else if(StringUtils.isNotBlank(orderVo.getOrderNo())){ |
| | | List<SysOrder> byModel = orderService.findByModel(orderVo); |
| | | if(byModel.size()==1){ |
| | | order=orderService.findById(byModel.get(0).getId()); |
| | | } |
| | | } |
| | | List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(order.getId()); |
| | | order.setItems(sysOrderItems); |
| | | |
| | | SysVipInfo vipInfo = sysVipInfoService.findById(order.getVipId()); |
| | | // 根据会员Id查到会员有效的会员卡 |
| | | // 根据订单号查找订单条目 |
| | | List<SysOrderItem> orderItems = orderItemService.findByOrderId(order.getId()); |
| | | |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setVipId(order.getVipId()); |
| | | List<MoneyCardUse> cards = cardUseService.findByModel(moneyCardUse); |
| | | |
| | | List<SysOrderFlow> flows = sysOrderFlowService.findByOrderId(order.getId()); |
| | | order.setFlows(flows); |
| | | |
| | | List<SysOrderFlow> payMethods = sysOrderFlowService.findPayMethodsAmount(order.getId()); |
| | | |
| | | List<AchieveNew> achieveList = achieveNewService.findOrderItemAchieve(order.getId()); |
| | | |
| | | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); |
| | | ajaxResult.putInMap("orderItems", orderItems); |
| | | ajaxResult.putInMap("order", order); |
| | | ajaxResult.putInMap("cards", cards); |
| | | ajaxResult.putInMap("vipInfo", vipInfo); |
| | | ajaxResult.putInMap("payMethods", payMethods); |
| | | ajaxResult.putInMap("achieveList", achieveList); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | | * 跳转 消费流水详情页面 |
| | | * |
| | |
| | | */ |
| | | @RequestMapping(value = "/orderItem") |
| | | public String orderItem(SysOrder orderVo) { |
| | | // 根据id查到对应的订单信息 |
| | | SysOrder order=null; |
| | | if(orderVo.getId()!=null){ |
| | | order = orderService.findById(orderVo.getId()); |
| | | }else if(StringUtils.isNotBlank(orderVo.getOrderNo())){ |
| | | List<SysOrder> byModel = orderService.findByModel(orderVo); |
| | | if(byModel.size()==1){ |
| | | order=orderService.findById(byModel.get(0).getId()); |
| | | } |
| | | } |
| | | List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(order.getId()); |
| | | order.setItems(sysOrderItems); |
| | | |
| | | WebUtil.getRequest().setAttribute("order", order); |
| | | // 根据会员Id查到会员有效的会员卡 |
| | | // 根据订单号查找订单条目 |
| | | SysOrderItem orderItem = new SysOrderItem(); |
| | | orderItem.setOrderId(order.getId()); |
| | | List<SysOrderItem> orderItems = orderItemService.findByModel(orderItem); |
| | | WebUtil.getRequest().setAttribute("orderItems", orderItems); |
| | | |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setVipId(order.getVipId()); |
| | | List<MoneyCardUse> cards = cardUseService.findByModel(moneyCardUse); |
| | | |
| | | WebUtil.getRequest().setAttribute("cards", cards); |
| | | if(orderVo.getId()!=null){ |
| | | WebUtil.getRequest().setAttribute("orderParam", orderVo.getId()); |
| | | }else if(StringUtils.isNotBlank(orderVo.getOrderNo())){ |
| | | WebUtil.getRequest().setAttribute("orderParam", orderVo.getOrderNo()); |
| | | } |
| | | return "admin/hive/beautySalon/orderXq-form"; |
| | | } |
| | | |
| | |
| | | if (order == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "订单不存在!"); |
| | | } |
| | | orderService.cancelOrder(id); |
| | | if (del > 0) { |
| | | orderService.removeById(id); |
| | | result.setInfo("删除成功!"); |
| | | } else { |
| | | result.setInfo("取消成功!"); |
| | | |
| | | List<SysOrderItem> items = orderItemDao.selectByOrderId(id); |
| | | for (SysOrderItem item : items) { |
| | | List<SysProjServices> sysProjServices = sysProjServicesDao.selectProjServicesByOrderItemId(item.getId()); |
| | | if (CollUtil.isNotEmpty(sysProjServices)) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "订单存在进行中的服务单无法取消/删除"); |
| | | } |
| | | } |
| | | |
| | | orderService.cancelOrder(id); |
| | | // if (del > 0) { |
| | | // orderService.removeById(id); |
| | | // result.setInfo("删除成功!"); |
| | | // } else { |
| | | result.setInfo("取消成功!"); |
| | | // } |
| | | result.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | |
| | | return result; |