6 files added
28 files modified
| | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | |
| | | /** |
| | | * spring boot入口 |
| | |
| | | */ |
| | | @SpringBootApplication |
| | | @ComponentScan(basePackages = {"com.matrix.**"}) |
| | | @EnableAsync |
| | | public class ZqErpApplication { |
| | | |
| | | public static void main(String[] args) { |
New file |
| | |
| | | /** |
| | | * projectName: zq-erp |
| | | * fileName: MessageManager.java |
| | | * packageName: com.matrix.component.asyncmessage |
| | | * date: 2021-10-18 14:01 |
| | | * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved. |
| | | */ |
| | | package com.matrix.component.asyncmessage; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentLinkedQueue; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @version: V1.0 |
| | | * @author: JiangYouYao |
| | | * @className: AsyncMessageManager |
| | | * @packageName: com.matrix.component.asyncmessage |
| | | * @description: 异步消息管理者 |
| | | * @data: 2021-10-18 14:01 |
| | | **/ |
| | | @Component |
| | | @Order(Ordered.HIGHEST_PRECEDENCE) |
| | | public class AsyncMessageManager implements ApplicationRunner { |
| | | |
| | | @Autowired |
| | | private List<MessageHandler> obs; |
| | | |
| | | private Map<String, List<MessageHandler>> routes; |
| | | |
| | | private Map<String, ReentrantLock> lockMap = new HashMap<>(); |
| | | |
| | | private Map<String, ConcurrentLinkedQueue> messageQueue = new HashMap<>(); |
| | | |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | if (CollectionUtil.isNotEmpty(obs)) { |
| | | routes = obs.stream().collect(Collectors.groupingBy(MessageHandler::getRouteKey)); |
| | | LogUtil.info("异步消息绑定成功,检测到{} 个消费者,共计{}组", obs.size(), routes.size()); |
| | | } else { |
| | | LogUtil.info("未检测到异步消息处理类"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * map 参数的字符串表示,方便快速拼装消息参数 |
| | | * @param routeKey |
| | | * @param mapStr |
| | | */ |
| | | public void sendMsg(String routeKey, String mapStr,Object... args){ |
| | | |
| | | if(StringUtils.isBlank(mapStr)){ |
| | | throw new IllegalArgumentException("mapStr格式错误:例如:\\\"orderId=123,price=88\\\",mapStr="+mapStr); |
| | | } |
| | | mapStr=String.format(mapStr,args); |
| | | |
| | | Map<String, Object> param =new HashMap<>(); |
| | | String[] paramStr = mapStr.split(","); |
| | | Arrays.asList(paramStr).forEach(item->{ |
| | | String[] keyValueArr = item.split("="); |
| | | param.put(keyValueArr[0],keyValueArr[1]); |
| | | }); |
| | | sendMsg(routeKey,param); |
| | | } |
| | | |
| | | /** |
| | | * 根据route 发送消息到对应的消费者 |
| | | * 这个方法本质上还是同步执行,没有完成效率上的异步解耦,这里做观察者模式主要是为了扩展业务,减少对第三方消息组件的依赖 |
| | | * 而不是解决性能问题,如果后续需要解决性能问题,在加一个消息队列,然后启动线程从队列中进行消息的消费。 |
| | | * @param routeKey |
| | | * @param param |
| | | */ |
| | | public void sendMsg(String routeKey, Map<String, Object> param) { |
| | | |
| | | if(StringUtils.isBlank(routeKey)){ |
| | | LogUtil.warn("发送异步消息失败:routeKey为空"); |
| | | return; |
| | | } |
| | | |
| | | //匹配观察者 |
| | | List<MessageHandler> lisener = new ArrayList<>(); |
| | | for (Map.Entry<String, List<MessageHandler>> routesEntry : routes.entrySet()) { |
| | | if (Pattern.matches(routesEntry.getKey(), routeKey)) { |
| | | lisener.addAll(routesEntry.getValue()); |
| | | } |
| | | } |
| | | |
| | | //通知观察者 |
| | | if (CollectionUtil.isNotEmpty(lisener)) { |
| | | LogUtil.info("发送异步消息,routeKey={},匹配观察者{}个",routeKey,lisener.size()); |
| | | for (MessageHandler messageHandler : lisener) { |
| | | try{ |
| | | messageHandler.handle(param); |
| | | }catch (Throwable t){ |
| | | LogUtil.error("{},处理类执行异常:routeKey={},message={}", messageHandler.getName(),routeKey,t.getMessage()); |
| | | } |
| | | } |
| | | }else{ |
| | | LogUtil.warn("未匹配到routeKey={},的消费者",routeKey); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | /** |
| | | * projectName: zq-erp |
| | | * fileName: MessageHandler.java |
| | | * packageName: com.matrix.component.asyncmessage |
| | | * date: 2021-10-18 13:59 |
| | | * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved. |
| | | */ |
| | | package com.matrix.component.asyncmessage; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @version: V1.0 |
| | | * @author: JiangYouYao |
| | | * @className: MessageHandler |
| | | * @packageName: com.matrix.component.asyncmessage |
| | | * @description: 异步消息处理接口 |
| | | * @data: 2021-10-18 13:59 |
| | | **/ |
| | | public interface MessageHandler { |
| | | |
| | | /** |
| | | * 处理类的名字 |
| | | * @return |
| | | */ |
| | | String getName(); |
| | | |
| | | /** |
| | | * 返回任务的路由key |
| | | * @return |
| | | */ |
| | | String getRouteKey(); |
| | | |
| | | /** |
| | | * 实际任务处理方法 |
| | | * @param param |
| | | */ |
| | | void handle(Map<String,Object> param); |
| | | |
| | | } |
New file |
| | |
| | | /** |
| | | * projectName: zq-erp |
| | | * fileName: TestMessageHander.java |
| | | * packageName: com.matrix.component.asyncmessage |
| | | * date: 2021-10-18 16:05 |
| | | * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved. |
| | | */ |
| | | package com.matrix.component.asyncmessage; |
| | | |
| | | import com.matrix.core.tools.LogUtil; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @version: V1.0 |
| | | * @author: JiangYouYao |
| | | * @className: TestMessageHander |
| | | * @packageName: com.matrix.component.asyncmessage |
| | | * @description: 测试观察者 |
| | | * @data: 2021-10-18 16:05 |
| | | **/ |
| | | @Component |
| | | public class TestMessageHander implements MessageHandler{ |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "测试观察者"; |
| | | } |
| | | |
| | | @Override |
| | | public String getRouteKey() { |
| | | return "testkey"; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String, Object> param) { |
| | | try { |
| | | Thread.sleep(1000*5); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | LogUtil.debug(param.toString()); |
| | | } |
| | | } |
New file |
| | |
| | | /** |
| | | * projectName: zq-erp |
| | | * fileName: TestMessageHander.java |
| | | * packageName: com.matrix.component.asyncmessage |
| | | * date: 2021-10-18 16:05 |
| | | * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved. |
| | | */ |
| | | package com.matrix.component.asyncmessage; |
| | | |
| | | import com.matrix.core.tools.LogUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @version: V1.0 |
| | | * @author: JiangYouYao |
| | | * @className: TestMessageHander |
| | | * @packageName: com.matrix.component.asyncmessage |
| | | * @description: 测试观察者 |
| | | * @data: 2021-10-18 16:05 |
| | | **/ |
| | | @Component |
| | | public class TestMessageHander2 implements MessageHandler{ |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "测试观察者"; |
| | | } |
| | | |
| | | @Override |
| | | public String getRouteKey() { |
| | | return "55y"; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String, Object> param) { |
| | | try { |
| | | Thread.sleep(1000*5); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | LogUtil.debug(param.toString()); |
| | | } |
| | | } |
| | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplateFactory; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.shopXcx.mqTask.*; |
| | | import com.matrix.system.shopXcx.mqTask.OrderOutSotoreTask; |
| | | import com.matrix.system.shopXcx.mqTask.SalesOrderRefundTask; |
| | | import com.matrix.system.shopXcx.mqTask.SalesOrderTask; |
| | | import com.matrix.system.shopXcx.mqTask.TemplateMsgTask; |
| | | import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask; |
| | | import com.rabbitmq.client.DeliverCallback; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | //订阅模式 |
| | | public static final String MQ_EXCHANGE_TOPIC = "hive_exchange_fanout"; |
| | | |
| | | @Bean |
| | | ScoreOrderTask ScoreOrderTask() { |
| | | return new ScoreOrderTask(); |
| | | } |
| | | |
| | | @Bean |
| | | DeliverCallback OrderDingDingNoticeTask() { |
| | | return new OrderDingDingNoticeTask(); |
| | | } |
| | | |
| | | |
| | | OrderTask OrderrCreateTask() { |
| | | return new OrderTask(); |
| | | } |
| | | |
| | | |
| | | @Bean |
| | | SalesOrderTask SalesOrderTask() { |
| | | return new SalesOrderTask(); |
| | |
| | | List<MqTask> taskList = new ArrayList<>(); |
| | | |
| | | //注册RabbitMq任务 |
| | | taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_TEMPLATE_MSG + evn,MQTaskRouting.SEND_TEMPLATE_MSG + evn, TemplateMsgTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.ORDER_OUT_SOTORE + evn,MQTaskRouting.ORDER_OUT_SOTORE + evn, OrderOutSotoreTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn,MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, UniformMsgSentTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SHOP_ORDER_REFUND + evn,MQTaskRouting.SHOP_ORDER_REFUND + evn, SalesOrderRefundTask())); |
| | | |
| | | //不同任务在不同的队列,但是routingKey一样则可以收到生产者消息 |
| | | taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.CREATE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,OrderrCreateTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.SALES_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,SalesOrderTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.SCORE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,ScoreOrderTask())); |
| | | taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.DINGDING_NOTICE + evn,MQTaskRouting.CREATE_ORDER + evn, OrderDingDingNoticeTask())); |
| | | |
| | | |
| | | rabiitMqTemplate.binding(taskList); |
| | |
| | | return message; |
| | | } |
| | | |
| | | public static RuntimeException instance(String msg) { |
| | | return new GlobleException(msg); |
| | | } |
| | | |
| | | public String getErrorCode() { |
| | | return errorCode; |
| | | } |
| | |
| | | targetDate = calendar.getTime(); |
| | | break; |
| | | default: |
| | | targetDate = stringToDate("9999-12-31", DATE_FORMAT_DD); |
| | | targetDate = stringToDate("2099-12-31", DATE_FORMAT_DD); |
| | | |
| | | } |
| | | |
| | |
| | | package com.matrix.system.app.action; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | |
| | | import com.matrix.system.hive.service.SysProjServicesService; |
| | | import com.matrix.system.hive.service.SysProjUseService; |
| | | import com.matrix.system.hive.service.SysVipInfoService; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | |
| | | services=projServicesService.findById(services.getId()); |
| | | UniformMsgParam uniformMsgParam=new UniformMsgParam(services.getCompanyId(),UniformMsgParam.GZH_YYCG); |
| | | uniformMsgParam.put("serviceId",services.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | |
| | | return AjaxResult.buildSuccessInstance("确认成功"); |
| | | } |
| | |
| | | package com.matrix.system.hive.action; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | |
| | | import com.matrix.system.hive.dao.MoneyCardUseFlowDao; |
| | | import com.matrix.system.hive.pojo.CzXkVo; |
| | | import com.matrix.system.hive.service.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | |
| | | private AsyncMessageManager asyncMessageManager; |
| | | /** |
| | | * 跳转 充值页面 |
| | | * |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam=new UniformMsgParam(order.getCompanyId(),UniformMsgParam.GZH_CZCG); |
| | | uniformMsgParam.put("orderId",order.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | |
| | | result.putInMap("orderId",order.getId()); |
| | | return result; |
| | |
| | | package com.matrix.system.hive.action; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | |
| | | 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.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | private SysProjServicesDao sysProjServicesDao; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(user.getCompanyId(), UniformMsgParam.GZH_GMCG); |
| | | uniformMsgParam.put("orderId", sysOrder.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | |
| | | |
| | | //处理用户购买的产品 |
| | |
| | | private void setShoppingGoodsInvalidTime(ShoppingGoods shoppingGoods) { |
| | | // 若未设置购买有效期和消耗有效期,则默认永久有效 |
| | | // if (shoppingGoods.getBuyDateNum() == null && shoppingGoods.getUseDateNum() == null) { |
| | | // shoppingGoods.setInvalidTime(DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD)); |
| | | // shoppingGoods.setInvalidTime(DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD)); |
| | | // } else { |
| | | // // 计算失效日期,判断购买有效期和消耗有效期哪个先失效,则为失效日期 |
| | | // Date buyValidDate = DateUtil.calDate(shoppingGoods.getBuyDateNum(), shoppingGoods.getBuyDateUnit()); |
| | |
| | | @Override |
| | | public Date calInvalidTime(ShoppingGoods shoppingGoods, @NotNull Integer type, Date buyDate) { |
| | | if (StringUtils.isBlank(shoppingGoods.getBuyValid()) && StringUtils.isBlank(shoppingGoods.getUseValid()) && shoppingGoods.getInvalidTime() == null) { |
| | | return DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD); |
| | | return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD); |
| | | } |
| | | |
| | | if (type == 2 && shoppingGoods.getUseDateNum() == null && StringUtils.isNotBlank(shoppingGoods.getBuyDateUnit())) { |
| | | return DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD); |
| | | return DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD); |
| | | } |
| | | |
| | | if (type == 2 && buyDate == null) { |
| | |
| | | buyValidDate = buyDate; |
| | | } |
| | | |
| | | Date useValidDate = DateUtil.stringToDate("9999-12-31", DateUtil.DATE_FORMAT_DD); |
| | | Date useValidDate = DateUtil.stringToDate("2099-12-31", DateUtil.DATE_FORMAT_DD); |
| | | if (type == 2) { |
| | | useValidDate = DateUtil.calDate(shoppingGoods.getUseDateNum(), shoppingGoods.getUseDateUnit()); |
| | | } |
| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | |
| | | import com.matrix.system.score.constant.ScoreSettingConstant; |
| | | import com.matrix.system.score.entity.ScoreVipDetail; |
| | | import com.matrix.system.score.service.ScoreVipDetailService; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @date 2016-07-03 20:53 |
| | |
| | | @Autowired |
| | | BusParameterSettingsDao parameterSettingsDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(order.getCompanyId(), UniformMsgParam.GZH_DDQX); |
| | | uniformMsgParam.put("orderId", order.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | |
| | | return sysOrderDao.update(order); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * jyy 收款 |
| | | */ |
| | |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | |
| | | //检查交易限制调整 |
| | | checkSealLimit(pageOrder); |
| | | |
| | | checkOrder(pageOrder); |
| | | |
| | | |
| | | // 更新收款时间 |
| | |
| | | |
| | | //设置会员积分 |
| | | addVipScore(pageOrder); |
| | | |
| | | } |
| | | |
| | | private void checkOrder(SysOrder pageOrder) { |
| | | //检查交易限制调整 |
| | | checkSealLimit(pageOrder); |
| | | //检查业绩设置 |
| | | checkOrderAchieve(pageOrder); |
| | | } |
| | | |
| | | /** |
| | | * 检查业绩设置是否合理 |
| | | * 1、每个订单明细都要有至少一个对应的业绩 |
| | | * 2、每个订单明细的同类型业绩金额之和不能大于明细支付金额 |
| | | * |
| | | * @param pageOrder |
| | | */ |
| | | private void checkOrderAchieve(SysOrder pageOrder) { |
| | | |
| | | pageOrder.getItems().forEach(item -> { |
| | | |
| | | if (CollectionUtil.isEmpty(item.getAchieveList())) { |
| | | ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId()); |
| | | throw GlobleException.instance(shopGoods.getName() + "缺少设置业绩"); |
| | | } |
| | | |
| | | //按业绩类型分组后比较支付金额与业绩金额是否相等 |
| | | Map<String, List<AchieveNew>> achieveTypeMap = item.getAchieveList().stream().collect(Collectors.groupingBy(AchieveNew::getAchieveType)); |
| | | Set<Map.Entry<String, List<AchieveNew>>> entries = achieveTypeMap.entrySet(); |
| | | entries.forEach(entrie -> { |
| | | double sum = entrie.getValue().stream().mapToDouble(AchieveNew::getGoodsCash).sum(); |
| | | //todo 目前使用js计算金额可能存在精度的误差展示用0.1屏蔽 |
| | | if (Math.abs(sum- (item.getZkPrice()*item.getCount()) )>0.1) { |
| | | ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId()); |
| | | throw GlobleException.instance(shopGoods.getName() + "," + entrie.getKey() + "业绩金额与收款金额不一致"); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 设置会员消费积分 |
| | | * |
| | | * @param pageOrder |
| | | */ |
| | | private void addVipScore(SysOrder pageOrder) { |
| | |
| | | sysOrderFlowDao.insert(flow); |
| | | flowCount++; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | sourceOrder.setCashPay(sourceOrder.getCashPay()==null?0:sourceOrder.getCashPay() + cashPayTotal); |
| | | sysOrderDao.update(sourceOrder); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 全是赠送金额,且配置了赠送金额购买计算为赠送 |
| | | * |
| | | * @param order |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 退款退项目,套餐,卡项 |
| | | * |
| | | * @param sysOrder |
| | | */ |
| | | private void refundProjUse(SysOrder sysOrder) { |
| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | |
| | | import com.matrix.system.score.constant.ScoreSettingConstant; |
| | | import com.matrix.system.score.entity.ScoreVipDetail; |
| | | import com.matrix.system.score.service.ScoreVipDetailService; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private ShoppingGoodsService shoppingGoodsService; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | SysVipInfoDao sysVipInfoDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | |
| | | /** |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(projServices.getCompanyId(), UniformMsgParam.GZH_FWWC); |
| | | uniformMsgParam.put("serviceId", projServices.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); |
| | | |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | |
| | | return result; |
| | | } |
| | |
| | | freeze.setOrderItemId(taocan.getId().toString()); |
| | | freeze.setVipId(taocan.getVipId()); |
| | | SysProjuseFreeze freezeProj = sysProjuseFreezeDao.selectByOrderItemId(freeze); |
| | | // todo 因为目前没有在冻结的时候插入冻结记录,所以这里暂时这样处理 |
| | | if(freezeProj!=null){ |
| | | Date dateAfter = DateUtil.nextNDate(taocan.getFailTime(), freezeProj.getGapDays()); |
| | | |
| | | taocan.setFailTime(dateAfter); |
| | | } |
| | | break; |
| | | default: |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "请选择无效或者冻结的套餐"); |
| | |
| | | package com.matrix.system.job; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.hive.bean.SysProjServices; |
| | | import com.matrix.system.hive.dao.SysProjServicesDao; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | /** |
| | | * 每分钟执行一次 |
| | | */ |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam=new UniformMsgParam(projServices.getCompanyId(),UniformMsgParam.GZH_YYDS); |
| | | uniformMsgParam.put("serviceId",projServices.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | } |
| | | List<Long> noticedIds = needNoticeService.stream().map(SysProjServices::getId).collect(Collectors.toList()); |
| | | projServicesDao.updateNoticeTimes(noticedIds); |
| | |
| | | package com.matrix.system.shopXcx.action; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.anotations.RemoveRequestToken; |
| | | import com.matrix.core.anotations.SaveRequestToken; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDao; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | SystemDictionaryDao systemDictionaryDao; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Autowired |
| | | private WxShopOrderUtil wxShopOrderUtil; |
| | |
| | | shopOrderDao.updateByMap(modifyMap); |
| | | |
| | | //发送创建订单的消息 |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.ORDER_OUT_SOTORE+evn, shopOrderDao.selectById(deliveryInfo.getOrderId()).getOrderNo()); |
| | | |
| | | String orderNo = shopOrderDao.selectById(deliveryInfo.getOrderId()).getOrderNo(); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.ORDER_OUT_SOTORE ,"orderNo=%s",orderNo); |
| | | |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "发货成功"); |
| | | } |
| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.google.gson.Gson; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.core.anotations.RemoveRequestToken; |
| | | import com.matrix.core.anotations.SaveRequestToken; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | |
| | | import com.matrix.system.shopXcx.bean.*; |
| | | import com.matrix.system.shopXcx.dao.*; |
| | | import com.matrix.system.shopXcx.dto.DiscountExplain; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.shopXcx.pojo.ShopOrderQueryPOJO; |
| | | import com.matrix.system.shopXcx.shopEnum.OrderStatusEnum; |
| | | import com.matrix.system.shopXcx.vo.LogisticsImportVo; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | 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.web.bind.annotation.RequestMapping; |
| | |
| | | private SysShopInfoDao sysShopInfoDao; |
| | | @Autowired |
| | | private SysVipInfoService vipInfoService; |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | //记录编辑前的值Before_Edit_Value |
| | | public static final String BEV = "ShopOrder_BEV"; |
| | | |
| | | public static final List<LogisticsImportVo> logisticsImportVoLists = new ArrayList<>(); |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | /** |
| | | * 导入快递单 |
| | |
| | | shopOrderDao.updateByMap(modifyMap); |
| | | |
| | | //发送创建订单的消息 |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.ORDER_OUT_SOTORE+evn, orderNo); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.ORDER_OUT_SOTORE ,"orderNo=%s"); |
| | | |
| | | } |
| | | }else{ |
| | | if(ObjectUtil.isEmpty(shopOrder)){ |
| | |
| | | package com.matrix.system.shopXcx.action; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDao; |
| | | import com.matrix.system.shopXcx.dao.ShopRefundRecordDao; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private ShopDeliveryInfoDao shopDeliveryInfoDao; |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | @Autowired |
| | | private ShopCouponRecordDao shopCouponRecordDao; |
| | | |
| | |
| | | modifyMap.put("refundCharge", shopRefundRecord.getRefundMoney()); |
| | | shopOrderDao.updateByMap(modifyMap); |
| | | |
| | | |
| | | |
| | | |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SHOP_ORDER_REFUND+evn,shopRefundRecord.getOrderId()+""); |
| | | |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SHOP_ORDER_REFUND ,"orderId=%s", shopRefundRecord.getOrderId()); |
| | | |
| | | }catch (Exception e){ |
| | | LogUtil.debug("退款成功,修改退款表和订单表状态出错。。。", id); |
| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.component.wechat.externalInterface.protocol.paramProtocol.BrandWCPayRequestData; |
| | | import com.matrix.config.RabbitMqConfig; |
| | | import com.matrix.core.constance.SystemErrorCode; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | |
| | | import com.matrix.system.shopXcx.bean.ShopOrder; |
| | | import com.matrix.system.shopXcx.bean.ShopPayLog; |
| | | import com.matrix.system.shopXcx.dao.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | private ShopActivitiesGroupJoinDao shopActivitiesGroupJoinDao; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | |
| | | } |
| | | |
| | | // 根据订单类型创建不同的处理任务 |
| | | rabiitMqTemplate.sendTopicMsg(RabbitMqConfig.MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.CREATE_ORDER + evn, orderId + ""); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.CREATE_ORDER ,"orderId=%s",orderId); |
| | | |
| | | //支付记录 |
| | | recordPayLog(Integer.valueOf(orderId), 1, order.getOrderNo(), order.getOrderMoney(), "会员卡余额支付成功", ShopOrder.ORDER_PAY_STATUS_SUCCESS); |
| | | |
| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.wechat.externalInterface.common.Signature; |
| | | import com.matrix.component.wechat.externalInterface.common.Util; |
| | | import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData; |
| | | import com.matrix.config.RabbitMqConfig; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopActivitiesGroupJoinUserDao; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDao; |
| | | import com.matrix.system.shopXcx.dao.ShopPayLogDao; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | ScoreVipDetailService scoreVipDetailService; |
| | | |
| | | @Autowired |
| | | AsyncMessageManager asyncMessageManager; |
| | | |
| | | |
| | | @Value("${evn}") |
| | |
| | | } |
| | | |
| | | // 根据订单类型创建不同的处理任务 |
| | | rabiitMqTemplate.sendTopicMsg(RabbitMqConfig.MQ_EXCHANGE_TOPIC +evn, MQTaskRouting.CREATE_ORDER+evn, orderId); |
| | | |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.CREATE_ORDER,"orderId=%s",orderId); |
| | | |
| | | |
| | | threadResult.putInMap("status", "success"); |
| | |
| | | package com.matrix.system.shopXcx.api.service.impl; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.tools.DingDingRobotUtil; |
| | |
| | | import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; |
| | | import com.matrix.system.shopXcx.bean.*; |
| | | import com.matrix.system.shopXcx.dao.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | private BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Value("${wx_pay_debug_onoff}") |
| | | private boolean isDebug; |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | |
| | | @Override |
| | |
| | | modifyMap.put("refundCharge", shopRefundRecord.getRefundMoney()); |
| | | shopOrderDao.updateByMap(modifyMap); |
| | | |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SHOP_ORDER_REFUND+evn,shopRefundRecord.getOrderId()+""); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SHOP_ORDER_REFUND ,"orderId=%s" , shopRefundRecord.getOrderId()); |
| | | |
| | | |
| | | //发送退款通知 |
| | | BusParameterSettings wxOrderNoticeDingdingToken = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WX_ORDER_NOTICE_DINGDING_TOKEN, shopOrder.getCompanyId()); |
New file |
| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | /** |
| | | * 异步任务名称 |
| | | */ |
| | | public interface AsyncMessageRouting { |
| | | |
| | | String CREATE_VIP = "CREATE_VIP"; |
| | | |
| | | String CREATE_ORDER = "CREATE_ORDER"; |
| | | String SALES_ORDER = "SALES_ORDER"; |
| | | String SCORE_ORDER = "SCORE_ORDER"; |
| | | String DINGDING_NOTICE = "DINGDING_NOTICE" ; |
| | | /** |
| | | * 发送微信消息 |
| | | */ |
| | | String SEND_TEMPLATE_MSG = "SEND_TEMPLATE_MSG"; |
| | | |
| | | /** |
| | | * 发送小程序统一模板消息 |
| | | */ |
| | | String SEND_UNIFORM_TEMPLATE_MSG = "SEND_UNIFORM_TEMPLATE_MSG"; |
| | | /** |
| | | * 订单退款 |
| | | */ |
| | | String SHOP_ORDER_REFUND = "SHOP_ORDER_REFUND"; |
| | | |
| | | /** |
| | | * 订单出库 |
| | | */ |
| | | String ORDER_OUT_SOTORE = "ORDER_OUT_SOTORE"; |
| | | } |
| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.DingDingRobotUtil; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 微商城订单同步到erp系统 |
| | | */ |
| | | @Component |
| | | public class OrderDingDingNoticeTask implements DeliverCallback { |
| | | public class OrderDingDingNoticeTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | ShopDeliveryInfoDao shopDeliveryInfoDao; |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | String orderIdStr = new String(message.getBody(), "UTF-8"); |
| | | public String getName() { |
| | | return "创建订单通知任务"; |
| | | } |
| | | |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.CREATE_ORDER; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void handle(Map<String,Object> param){ |
| | | String orderIdStr = (String) param.get("orderId"); |
| | | Integer orderId=Integer.valueOf(orderIdStr); |
| | | //获取订单信息 |
| | | ShopOrder order = shopOrderDao.selectById(orderId); |
| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.hive.bean.SysOrder; |
| | | import com.matrix.system.hive.dao.SysOrderDao; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 微商城发货后erp出库 |
| | | */ |
| | | public class OrderOutSotoreTask implements DeliverCallback { |
| | | public class OrderOutSotoreTask implements MessageHandler { |
| | | |
| | | @Autowired |
| | | SysOrderDao sysOrderDao; |
| | |
| | | SysOrderService orderService; |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getName() { |
| | | return "微商城发货后erp出库"; |
| | | } |
| | | |
| | | String orderNo = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.ORDER_OUT_SOTORE; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String,Object> param){ |
| | | |
| | | String orderNo = (String) param.get("orderNo"); |
| | | LogUtil.debug("收到出库订单orderNo={}", orderNo); |
| | | //获取订单信息 |
| | | SysOrder sourceOrder = new SysOrder(); |
| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | |
| | | import com.matrix.system.shopXcx.dao.ShopSkuDao; |
| | | import com.rabbitmq.client.DeliverCallback; |
| | | import com.rabbitmq.client.Delivery; |
| | | import org.apache.logging.log4j.message.Message; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 微商城订单同步到erp系统 |
| | | */ |
| | | @Component |
| | | public class OrderTask implements DeliverCallback { |
| | | public class OrderTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "微商城订单同步到erp系统"; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.CREATE_ORDER; |
| | | } |
| | | |
| | | String orderId = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public void handle(Map<String,Object> param) { |
| | | |
| | | String orderId = (String) param.get("orderId"); |
| | | LogUtil.debug("收到创建订单任务orderId={}", orderId); |
| | | //获取订单信息 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; |
| | | import com.matrix.system.fenxiao.entity.ShopSalesmanOrder; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 分销订单退款 |
| | | */ |
| | | @Component |
| | | public class SalesOrderRefundTask implements DeliverCallback { |
| | | public class SalesOrderRefundTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getName() { |
| | | return "分销订单退款"; |
| | | } |
| | | |
| | | String orderId = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.SHOP_ORDER_REFUND; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String,Object> param){ |
| | | |
| | | String orderId = (String) param.get("orderId"); |
| | | LogUtil.debug("收到分销订单退款任务orderId={}", orderId); |
| | | QueryWrapper queryWrapper=new QueryWrapper(); |
| | | queryWrapper.eq("order_id",orderId); |
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 分销订单创建 |
| | | */ |
| | | @Component |
| | | public class SalesOrderTask implements DeliverCallback { |
| | | public class SalesOrderTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | private ShopSalesmanGradeDao shopSalesmanGradeDao; |
| | | |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "分销订单创建事件"; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.CREATE_ORDER; |
| | | } |
| | | |
| | | String orderId = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public void handle(Map<String,Object> param){ |
| | | |
| | | String orderId = (String) param.get("orderId"); |
| | | LogUtil.debug("收到分销订单任务orderId={}", orderId); |
| | | //获取订单信息 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 订单创建积分事件处理 |
| | | */ |
| | | @Component |
| | | public class ScoreOrderTask implements DeliverCallback { |
| | | public class ScoreOrderTask implements MessageHandler { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | SysVipInfoDao sysVipInfoDao; |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getName() { |
| | | return "订单创建积分事件"; |
| | | } |
| | | |
| | | String orderId = new String(message.getBody(), "UTF-8"); |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.CREATE_ORDER; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String,Object> param) { |
| | | |
| | | String orderId = (String) param.get("orderId"); |
| | | LogUtil.debug("收到订单积分任务orderId={}", orderId); |
| | | //获取订单信息 |
| | | ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); |
| | |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.system.hive.dao.OnlinebookingDao; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.system.shopXcx.dao.ShopProductDao; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 发送预约成功提醒消息 |
| | | */ |
| | | public class TemplateMsgTask implements DeliverCallback { |
| | | public class TemplateMsgTask implements MessageHandler { |
| | | |
| | | @Autowired |
| | | OnlinebookingDao onlinebookingDao; |
| | |
| | | |
| | | |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public String getName() { |
| | | return "发送预约成功提醒消息"; |
| | | } |
| | | |
| | | String msg = new String(message.getBody(), "UTF-8"); |
| | | JSONObject object = JSONObject.parseObject(msg); |
| | | Integer templateMsgType = (Integer) object.get("templateMsgType"); |
| | | String content = object.get("content") + ""; |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.ORDER_OUT_SOTORE; |
| | | } |
| | | |
| | | @Override |
| | | public void handle(Map<String,Object> param){ |
| | | |
| | | Integer templateMsgType = (Integer) param.get("templateMsgType"); |
| | | String content = param.get("content") + ""; |
| | | |
| | | if (TemplateMsgType.APPOINTMENT_SUCCESS.getCode().equals(templateMsgType)) { |
| | | appointmentSuccess.sendTemplateMsg(content); |
| | |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.service.SysVipInfoService; |
| | | import com.matrix.component.asyncmessage.MessageHandler; |
| | | import com.matrix.component.tools.HttpClientUtil; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.rr.GlueFactory; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.SysProjServices; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.SysProjServicesDao; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.shopXcx.api.WeChatGzhApiTools; |
| | | import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg; |
| | | import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao; |
| | | import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgPojo; |
| | | import com.rabbitmq.client.DeliverCallback; |
| | | import com.rabbitmq.client.Delivery; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.collections.map.HashedMap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | * @author jyy |
| | | */ |
| | | @Component |
| | | public class UniformMsgSentTask implements DeliverCallback { |
| | | public class UniformMsgSentTask implements MessageHandler { |
| | | |
| | | @Autowired |
| | | private ShopWxtemplateMsgDao shopWxtemplateMsgDao; |
| | |
| | | @Autowired |
| | | private BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return "小程序统一消息模板消息发送提醒"; |
| | | } |
| | | |
| | | @Override |
| | | public String getRouteKey() { |
| | | return AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG; |
| | | } |
| | | |
| | | /** |
| | | * 发送模板消息需要传JSONO字符串作为格式 |
| | | * 例如:{"companyId":17} |
| | | * companyId 是必须属性 |
| | | * @param consumerTag |
| | | * @param message |
| | | * @throws IOException |
| | | */ |
| | | @Override |
| | | public void handle(String consumerTag, Delivery message) throws IOException { |
| | | public void handle(Map<String,Object> param){ |
| | | try { |
| | | String messages = new String(message.getBody(), "UTF-8"); |
| | | JSONObject messageJsonParam=JSONObject.parseObject(messages); |
| | | |
| | | JSONObject messageJsonParam=JSONObject.parseObject(param.get("messages").toString()); |
| | | |
| | | if(!messageJsonParam.containsKey("companyId")||(!messageJsonParam.containsKey("templateCode"))){ |
| | | LogUtil.error("小程序消息推送参数格式异常发送模板消息需要传JSONO字符串作为格式 例如:{\"companyId\":17,\"templateCode\":10000} companyId 、templateCode 是必须属性"); |
| | |
| | | package com.matrix.system.wechart.templateMsg.demo; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.component.tools.HttpClientUtil; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.system.hive.plugin.util.HttpUtils; |
| | | import com.matrix.system.shopXcx.api.WeChatGzhApiTools; |
| | | import com.matrix.system.wechart.templateMsg.Task.UniformMsgSentTask; |
| | | import com.rabbitmq.client.Delivery; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | @ResponseBody |
| | | public AjaxResult template() throws IOException { |
| | | |
| | | uniformMsgSentTask.handle(null,null); |
| | | return AjaxResult.buildSuccessInstance("1"); |
| | | |
| | | } |
| | |
| | | #spring.datasource.password=hive123!@# |
| | | #spring.datasource.url=jdbc:mysql://124.70.222.34/hive_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 |
| | | |
| | | spring.datasource.username=meidu_data |
| | | spring.datasource.password=meidu_4321#&@ |
| | | spring.datasource.url=jdbc:mysql://47.111.134.136/db_meidu_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 |
| | | #spring.datasource.username=meidu_data |
| | | #spring.datasource.password=meidu_4321#&@ |
| | | #spring.datasource.url=jdbc:mysql://47.111.134.136/db_meidu_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 |
| | | |
| | | |
| | | spring.datasource.username=root |
| | | spring.datasource.password=root |
| | | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/md_test_local?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 |
| | | |
| | | |
| | | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource |
New file |
| | |
| | | package com.matrix; |
| | | |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 测试类示例 |
| | | * |
| | | * @author jiangyouyao |
| | | * @email 512061637@qq.com |
| | | * @date 2019年2月25日 |
| | | */ |
| | | @RunWith(SpringRunner.class) |
| | | @SpringBootTest(classes = {ZqErpApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) |
| | | public class TesatAsyncMessage { |
| | | |
| | | |
| | | @Autowired |
| | | AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Test |
| | | public void test() throws IOException { |
| | | |
| | | Map<String, Object> param =new HashMap<>(); |
| | | param.put("test","123"); |
| | | asyncMessageManager.sendMsg("testkey",param); |
| | | asyncMessageManager.sendMsg("testkey","test=%s","123456"); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |