New file |
| | |
| | | package com.matrix.system.wechart.templateMsg.Task.messageBulderDemo; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.hive.bean.SysBeauticianState; |
| | | import com.matrix.system.hive.bean.SysProjServices; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.SysBeauticianStateDao; |
| | | import com.matrix.system.hive.dao.SysProjServicesDao; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.wechart.templateMsg.GzhTemplateMessagePojo; |
| | | import com.matrix.system.wechart.templateMsg.Task.TemplateMessageBulder; |
| | | import com.matrix.system.wechart.templateMsg.UniformMsgPojo; |
| | | 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; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 某个公司客户的定制消息模板 |
| | | */ |
| | | @Component |
| | | public class DefaultTemplateMessageBulder implements TemplateMessageBulder { |
| | | |
| | | @Autowired |
| | | SysProjServicesDao projServicesDao; |
| | | |
| | | @Autowired |
| | | SysVipInfoDao vipInfoDao; |
| | | |
| | | @Autowired |
| | | private SysBeauticianStateDao beauticianStateDao; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Map buildMsg(Map param) { |
| | | |
| | | //返回参数 |
| | | Map builParam=new HashedMap(); |
| | | |
| | | |
| | | //获取基础公共参数 |
| | | String gzhAppid= (String) param.get("gzhAppid"); |
| | | String template_id= (String) param.get("template_id"); |
| | | //触发点传送的json参数 |
| | | JSONObject messageJsonParam= (JSONObject) param.get("messageJsonParam"); |
| | | |
| | | Long serviceId= (Long) messageJsonParam.get("serviceId"); |
| | | |
| | | |
| | | //构建消息主体 |
| | | SysProjServices sysProjServices = projServicesDao.selectById(serviceId); |
| | | |
| | | |
| | | //补充服务单扩展信息=============== |
| | | List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(sysProjServices.getId()); |
| | | |
| | | SysVipInfo vipInfo=vipInfoDao.selectById(sysProjServices.getVipId()); |
| | | String touser= vipInfo.getOpenId(); |
| | | if(StringUtils.isBlank(touser)){ |
| | | builParam.put("error","未获取到"+vipInfo.getVipName()+"用户小程序openid"); |
| | | return builParam; |
| | | } |
| | | |
| | | String time= DateUtil.dateFormatStr(sysProjServices.getConsumeTime(),DateUtil.DATE_FORMAT_MM); |
| | | List msgList=new ArrayList(); |
| | | //如果一个项目存在多个护理项目则发送多次消息 |
| | | for (SysBeauticianState beauticianState:beauticianStateList){ |
| | | UniformMsgPojo uniformMsgPojo=new UniformMsgPojo(); |
| | | GzhTemplateMessagePojo messagePojo=new GzhTemplateMessagePojo(); |
| | | uniformMsgPojo.setTouser(touser); |
| | | messagePojo.setTemplate_id(template_id); |
| | | messagePojo.setAppid(gzhAppid); |
| | | |
| | | |
| | | //个性参数设置 |
| | | Integer suplerTimes= beauticianState.getProjUse().getSurplusCount(); |
| | | messagePojo.setFirst("尊敬的:"+vipInfo.getVipName(),"#453454"); |
| | | messagePojo.setKeyWord(beauticianState.getProjInfo().getName(),"#453454"); |
| | | messagePojo.setKeyWord(time,"#453454"); |
| | | messagePojo.setRemark("您的护理项目剩余"+suplerTimes+"次。","#453454"); |
| | | uniformMsgPojo.setMp_template_msg(messagePojo); |
| | | |
| | | |
| | | msgList.add(uniformMsgPojo); |
| | | } |
| | | |
| | | builParam.put("msgList",msgList); |
| | | return builParam; |
| | | } |
| | | } |