zq-erp/src/main/java/com/matrix/system/hive/action/OrderController.java
@@ -1,5 +1,6 @@ package com.matrix.system.hive.action; import com.matrix.component.rabbitmq.RabiitMqTemplate; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; @@ -24,7 +25,10 @@ import com.matrix.system.hive.pojo.ShoppingCarItem; import com.matrix.system.hive.pojo.ShoppingCarItemsVo; 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; @@ -84,6 +88,10 @@ @Autowired private SysOrderFlowService sysOrderFlowService; @Autowired RabiitMqTemplate rabiitMqTemplate; @Value("${evn}") private String evn; /** * 计算订单金额 @@ -121,6 +129,13 @@ //校验订单是否满足结算调价,新订单则保存订单,已有订单则删除后更新 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), "订单结算成功"); } zq-erp/src/main/java/com/matrix/system/hive/action/ProjServiceController.java
@@ -495,6 +495,7 @@ if (balanceverifyResult.isError()) { return new AjaxResult(AjaxResult.STATUS_FAIL, balanceverifyResult.getMsg()); } sysProjServices.setState(Dictionary.SERVICE_STATU_YYCG); SysProjServices newSysProjServices = sysProjServicesService.addSysProjServices(sysProjServices); if (newSysProjServices != null) { return AjaxResult.buildSuccessInstance(Arrays.asList(newSysProjServices)); zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/VipCreateTask.java
@@ -5,6 +5,7 @@ import com.matrix.biz.service.BizUserService; import com.matrix.component.rabbitmq.MqTask; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.bean.SysVipInfo; @@ -45,12 +46,21 @@ SysVipInfo vip = vipDap.selectByPhone(userInfo.getPhoneNumber()); if (vip != null) { LogUtil.warn("会员{}已经存在", userInfo.getPhoneNumber()); //更新信息 vip.setOpenId(userInfo.getOpenId()); if(StringUtils.isBlank(vip.getPhoto())){ vip.setPhoto(userInfo.getAvatarUrl()); } vipDap.update(vip); } else { SysVipInfo vipInfo = new SysVipInfo(); //在备注记下微商城的用户id vipInfo.setOpenId(userInfo.getOpenId()); vipInfo.setAddr(userInfo.getProvince() + " " + userInfo.getCity()); vipInfo.setPhone(userInfo.getPhoneNumber()); if(StringUtils.isBlank(vipInfo.getPhoto())){ vipInfo.setPhoto(userInfo.getAvatarUrl()); } if (userInfo.getGender() != null) { vipInfo.setSex(userInfo.getGender().equals("1") ? "男" : "女"); } zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/GzhTemplateMessagePojo.java
@@ -18,19 +18,11 @@ private Miniprogram miniprogram; public static class Miniprogram{ private String appid; private String path; private String pagepath; public Miniprogram(String appid, String path) { public Miniprogram(String appid, String pagepath) { this.appid = appid; this.path = path; } public String getPath() { return path; } public void setPath(String path) { this.path = path; this.pagepath = pagepath; } public String getAppid() { @@ -41,7 +33,13 @@ this.appid = appid; } public String getPagepath() { return pagepath; } public void setPagepath(String pagepath) { this.pagepath = pagepath; } } public Map<String ,Item> data=new HashedMap(); public static class Item{ zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/Task/messageBulderDemo/GmcgTemplateMessageBulder.java
New file @@ -0,0 +1,106 @@ package com.matrix.system.wechart.templateMsg.Task.messageBulderDemo; import com.alibaba.fastjson.JSONObject; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo; import com.matrix.system.wechart.templateMsg.Task.TemplateMessageBulder; import com.matrix.system.wechart.templateMsg.UniformMsgPojo; import org.apache.commons.collections.map.HashedMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * 购买成功提醒 */ @Component public class GmcgTemplateMessageBulder implements TemplateMessageBulder { @Autowired SysOrderDao orderDao; @Autowired SysVipInfoDao vipInfoDao; @Autowired private SysBeauticianStateDao beauticianStateDao; @Autowired private SysShopInfoDao shopInfoDao; @Autowired private SysOrderItemDao orderItemDao; @Override public Map buildMsg(Map param) { //返回参数 Map builParam=new HashedMap(); //获取基础公共参数 String gzhAppid= (String) param.get("gzhAppid"); String template_id= (String) param.get("template_id"); String xcxAppId= (String) param.get("xcxAppId"); //模板消息列表 List msgList=new ArrayList(); //触发点传送的json参数 JSONObject messageJsonParam= (JSONObject) param.get("messageJsonParam"); //构建消息主体 Long orderId= (Long) messageJsonParam.get("orderId"); SysOrder sysOrder = orderDao.selectById(orderId); List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(orderId); //校验客户openId (必须) SysVipInfo vipInfo=vipInfoDao.selectById(sysOrder.getVipId()); String touser= vipInfo.getOpenId(); if(StringUtils.isBlank(touser)){ builParam.put("error","未获取到"+vipInfo.getVipName()+"用户小程序openid"); return builParam; } //自定义信息区START========================================================================================================= SysShopInfo sysShopInfo = shopInfoDao.selectById(sysOrder.getShopId()); String time= DateUtil.dateFormatStr(sysOrder.getPayTime(),DateUtil.DATE_FORMAT_MM); //如果一个项目存在多个护理项目则发送多次消息 String first="您好!您购买了"; for (SysOrderItem orderItem:sysOrderItems){ first+=orderItem.getShoppingGoods().getName()+"x"+orderItem.getCount()+","; } first=first.substring(0,first.length()); UniformMsgPojo uniformMsgPojo=new UniformMsgPojo(); GzhTemplateMessagePojo messagePojo=new GzhTemplateMessagePojo(); uniformMsgPojo.setTouser(touser); messagePojo.setTemplate_id(template_id); messagePojo.setAppid(gzhAppid); //个性参数设置 messagePojo.setFirst(first,"#453454"); messagePojo.setKeyWord(sysShopInfo.getShopName(),"#453454"); messagePojo.setKeyWord(vipInfo.getVipNo(),"#453454"); messagePojo.setKeyWord(time,"#453454"); messagePojo.setRemark("点击【详情】可查询订单明细,若非本人或授权操作,请及时与门店联系","#453454"); //小程序配置 GzhTemplateMessagePojo.Miniprogram miniprogram=new GzhTemplateMessagePojo.Miniprogram(xcxAppId, "pages/purchaseRecords/detail?id="+orderId); messagePojo.setMiniprogram(miniprogram); uniformMsgPojo.setMp_template_msg(messagePojo); //自定义信息区END========================================================================================================= //返回调用者使用的参数(必须) msgList.add(uniformMsgPojo); builParam.put("msgList",msgList); return builParam; } }