|  |  |  | 
|---|
|  |  |  | 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.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.dao.*; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.CollectionUtils; | 
|---|
|  |  |  | import com.matrix.system.hive.pojo.ShoppingCarItem; | 
|---|
|  |  |  | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 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()); | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | //储值卡订单不能通过退款渠道退款 | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(sysOrder.getItems())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysUsers user = getMe(); | 
|---|
|  |  |  | sysOrder.setShopId(user.getShopId()); | 
|---|
|  |  |  | sysOrder.setStatu(Dictionary.ORDER_STATU_TK); | 
|---|
|  |  |  | sysOrder.setOrderTime(new Date()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //校验订单是否满足结算调价,新订单则保存订单,已有订单则删除后更新 | 
|---|
|  |  |  | sysOrder = orderService.checkAndSaveOrder(sysOrder); | 
|---|
|  |  |  | orderService.refundOrderMoney(sysOrder); | 
|---|
|  |  |  | //处理用户购买的产品 | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(Arrays.asList(sysOrder), "订单退款成功"); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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, "修改成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|