| | |
| | | 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.tools.excl.ExcelSheetPO; |
| | | import com.matrix.core.tools.excl.ExcelUtil; |
| | | import com.matrix.core.tools.excl.ExcelVersion; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysCompanyDao; |
| | | import com.matrix.system.common.tools.DataAuthUtil; |
| | | 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.*; |
| | | 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.pojo.ShoppingCarItem; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.hive.service.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class OrderController extends BaseController { |
| | | @Resource |
| | | private SysOrderService orderService; |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | private CodeService codeService; |
| | | |
| | | @Autowired |
| | | private SysOrderItemDao orderItemDao; |
| | |
| | | private SysOrderFlowService sysOrderFlowService; |
| | | |
| | | @Autowired |
| | | private SysOrderFlowDao sysOrderFlowDao; |
| | | |
| | | @Autowired |
| | | RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | @Autowired |
| | | private BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | @Autowired |
| | | private SysProjServicesDao sysProjServicesDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | |
| | | total = total.add(new BigDecimal(item.getPrice() * item.getCount())); |
| | | } |
| | | SysOrder sysOrderResult = new SysOrder(); |
| | | sysOrderResult.setZkTotal(zkTotal.doubleValue()); |
| | | sysOrderResult.setZkTotal(zkTotal.setScale(2, BigDecimal.ROUND_DOWN).doubleValue()); |
| | | sysOrderResult.setTotal(total.doubleValue()); |
| | | |
| | | return AjaxResult.buildSuccessInstance(Arrays.asList(sysOrderResult)); |
| | |
| | | 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()); |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(user.getCompanyId(), UniformMsgParam.GZH_GMCG); |
| | | uniformMsgParam.put("orderId", sysOrder.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); |
| | | |
| | | |
| | | //处理用户购买的产品 |
| | |
| | | */ |
| | | @RequestMapping(value = "/refundOrder") |
| | | @ResponseBody |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult refundOrder(@RequestBody SysOrder sysOrder) { |
| | | SysUsers user = getMe(); |
| | | sysOrder.setShopId(user.getShopId()); |
| | | sysOrder.setStatu(Dictionary.ORDER_STATU_TK); |
| | | sysOrder.setOrderTime(new Date()); |
| | | //校验订单是否满足结算调价,新订单则保存订单,已有订单则删除后更新 |
| | | sysOrder = orderService.checkAndSaveOrder(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), "订单保存成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新建订单 |
| | | * |
| | | * @author jiangyouyao |
| | | */ |
| | | @RequestMapping(value = "/addOrder") |
| | | public @ResponseBody |
| | | AjaxResult addOrder(ShoppingCarItemsVo car) { |
| | | |
| | | List<ShoppingCarItem> sessionCarItems = (List<ShoppingCarItem>) WebUtil.getSession().getAttribute( |
| | | SystemConstance.SHOPPING_CAR); |
| | | |
| | | List<ShoppingCarItem> carItems = new ArrayList<>(); |
| | | |
| | | // 设置购车中的具体类型信息,过滤没有被选中的商品 |
| | | for (ShoppingCarItem carItem : car.getCarItems()) { |
| | | |
| | | for (ShoppingCarItem sessionCar : sessionCarItems) { |
| | | |
| | | if (carItem.getId().equals(sessionCar.getId())) { |
| | | //已最后提交的数量为准 |
| | | sessionCar.setCount(carItem.getCount()); |
| | | carItems.add(sessionCar); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //设置过滤后的购物车条目 |
| | | car.setCarItems(carItems); |
| | | |
| | | SysVipInfo info = (SysVipInfo) WebUtil.getSession().getAttribute(SystemConstance.CURRENT_CUSTOMER); |
| | | car.setVipId(info.getId()); |
| | | |
| | | // 添加新订单 |
| | | int i = orderService.createOrder(WebUtil.getSession(), car); |
| | | |
| | | if (i > 0) { |
| | | WebUtil.getSession().removeAttribute(SystemConstance.SHOPPING_CAR); |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "下单成功"); |
| | | } else { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "下单添加失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 列表显示 |
| | |
| | | if (StringUtils.isBlank(pageVo.getOrder())) { |
| | | pageVo.setOrder("desc"); |
| | | } |
| | | sysOrder.setShopId(getMe().getShopId()); |
| | | if (!DataAuthUtil.hasAllShopAuth()) { |
| | | sysOrder.setShopId(getMe().getShopId()); |
| | | } |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, orderService.findInPage(sysOrder, pageVo), |
| | | orderService.findTotal(sysOrder)); |
| | | } |
| | |
| | | return showList(sysOrder, pageVo); |
| | | } |
| | | |
| | | @Resource |
| | | SysCompanyDao companyDao; |
| | | |
| | | /** |
| | | * 收款 |
| | | */ |
| | | @RequestMapping(value = "sk") |
| | | @RequestMapping(value = "/printOrder") |
| | | public @ResponseBody |
| | | ModelAndView printOrder(SysOrder order) throws GlobleException { |
| | | ModelAndView mv = new ModelAndView("admin/hive/beautySalon/print-order"); |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | String comRegisterCode = companyDao.selectById(user.getCompanyId()).getComRegisterCode(); |
| | | if (StringUtils.isNotBlank(comRegisterCode)) { |
| | | mv.addObject("page", comRegisterCode); |
| | | } else { |
| | | mv.addObject("page", "taiyan"); |
| | | } |
| | | return mv; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 收款 |
| | | */ |
| | | @RequestMapping(value = "/sk") |
| | | public @ResponseBody |
| | | AjaxResult sk(SysOrder order) throws GlobleException { |
| | | orderService.updateReceiptMoney(order); |
| | |
| | | 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()); |
| | | } |
| | | |
| | | //打印需求加入门店信息 |
| | |
| | | |
| | | //查询会有所有有效的会员卡 |
| | | result.putInMap("totalMoney", moneyCardUseDao.selectVipCardTotalMoney(order.getVipId())); |
| | | |
| | | |
| | | |
| | | return result; |
| | |
| | | @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())){ |
| | | 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()); |
| | | if (byModel.size() == 1) { |
| | | order = orderService.findById(byModel.get(0).getId()); |
| | | } |
| | | } |
| | | List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(order.getId()); |
| | |
| | | @RequestMapping(value = "/orderItem") |
| | | public String orderItem(SysOrder orderVo) { |
| | | |
| | | if(orderVo.getId()!=null){ |
| | | if (orderVo.getId() != null) { |
| | | WebUtil.getRequest().setAttribute("orderParam", orderVo.getId()); |
| | | }else if(StringUtils.isNotBlank(orderVo.getOrderNo())){ |
| | | WebUtil.getRequest().setAttribute("orderId", orderVo.getId()); |
| | | } else if (StringUtils.isNotBlank(orderVo.getOrderNo())) { |
| | | WebUtil.getRequest().setAttribute("orderParam", orderVo.getOrderNo()); |
| | | WebUtil.getRequest().setAttribute("orderNo", orderVo.getOrderNo()); |
| | | } |
| | | return "admin/hive/beautySalon/orderXq-form"; |
| | | } |
| | |
| | | } |
| | | //=======================================页面转发END================================== |
| | | |
| | | /** |
| | | * 2021-08-20 新增:erp系统取消订单接口,不做订单状态校验 |
| | | * 取消订单 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @RequestMapping(value = "/erpCancelOrder") |
| | | public @ResponseBody |
| | | AjaxResult erpCancelOrder(Long id) { |
| | | |
| | | AjaxResult result = new AjaxResult(); |
| | | SysOrder order = orderService.findById(id); |
| | | if (order == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "订单不存在!"); |
| | | } |
| | | |
| | | 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); |
| | | |
| | | result.setInfo("取消成功!"); |
| | | |
| | | result.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消订单 |
| | |
| | | public @ResponseBody |
| | | AjaxResult cancelOrder(Long id, Integer del) { |
| | | |
| | | AjaxResult result = new AjaxResult(); |
| | | SysOrder order = orderService.findById(id); |
| | | if (order == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "订单不存在!"); |
| | | BusParameterSettings shopManageAbleCancelDfkOrder = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SHOP_MANAGE_ABLE_CANCEL_DFK_ORDER, order.getCompanyId()); |
| | | if (StringUtils.isNotBlank(shopManageAbleCancelDfkOrder.getParamValue()) |
| | | && shopManageAbleCancelDfkOrder.getParamValue().equals(Dictionary.FLAG_YES)) { |
| | | if (!Dictionary.ORDER_STATU_DFK.equals(order.getStatu())) { |
| | | 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; |
| | | return erpCancelOrder(id); |
| | | } |
| | | |
| | | @RequestMapping(value = "/exportExcel") |
| | |
| | | */ |
| | | @RequestMapping(value = "/erpExportExcel") |
| | | public void erpExportExcel(ModelMap model, HttpServletRequest request, HttpServletResponse response, |
| | | SysOrder sysOrder) throws Exception { |
| | | SysOrder sysOrder) throws Exception { |
| | | doExportOrder(response, sysOrder); |
| | | return; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 执行订单导出,总部和门店共用,但是搜索条件不一样 |
| | | * |
| | | * @param response |
| | | * @param sysOrder |
| | | * @throws IOException |