| @@ -29,6 +29,15 @@ public class WxBillAllController extends BaseController | |||||
| private Logger logger = LoggerFactory.getLogger(WxBillAllController.class); | private Logger logger = LoggerFactory.getLogger(WxBillAllController.class); | ||||
| @GetMapping("hasOweBill") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="contractId",value="合同id",dataType="long", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="type",value="类型1租赁合同2物业合同",dataType="int", paramType = "query",required=true)}) | |||||
| public ResultData hasOweBill(Long contractId,Integer type) { | |||||
| Long count = wxBillAllService.hasOweBill(contractId,type); | |||||
| return new ResultData(count); | |||||
| } | |||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | ||||
| @@ -1,11 +1,16 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * @author luozukai | * @author luozukai | ||||
| * @date 2019/3/7 10:05 | * @date 2019/3/7 10:05 | ||||
| */ | */ | ||||
| public class MailMsg extends BaseMsg { | public class MailMsg extends BaseMsg { | ||||
| private static final long serialVersionUID = 923764283760321L; | private static final long serialVersionUID = 923764283760321L; | ||||
| // 模板id | |||||
| private Integer modelId; | |||||
| private String tenantId; | |||||
| private String[] to; | private String[] to; | ||||
| private String from; | private String from; | ||||
| @@ -21,6 +26,33 @@ public class MailMsg extends BaseMsg { | |||||
| private String rscPath; | private String rscPath; | ||||
| private String rscI; | private String rscI; | ||||
| //动态替换内容 | |||||
| private Map<String,String> dynamicContentMap; | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String tenantId) { | |||||
| this.tenantId = tenantId; | |||||
| } | |||||
| public Map<String, String> getDynamicContentMap() { | |||||
| return dynamicContentMap; | |||||
| } | |||||
| public void setDynamicContentMap(Map<String, String> dynamicContentMap) { | |||||
| this.dynamicContentMap = dynamicContentMap; | |||||
| } | |||||
| public Integer getModelId() { | |||||
| return modelId; | |||||
| } | |||||
| public void setModelId(Integer modelId) { | |||||
| this.modelId = modelId; | |||||
| } | |||||
| public String[] getTo() { | public String[] getTo() { | ||||
| return to; | return to; | ||||
| } | } | ||||
| @@ -33,4 +33,6 @@ public interface WxBillPropertyMapper extends CommonMapper<WxBillProperty, Long> | |||||
| void update(WxBillProperty wxBillProperty); | void update(WxBillProperty wxBillProperty); | ||||
| void updatePreviewStatus(WxBillProperty record); | void updatePreviewStatus(WxBillProperty record); | ||||
| Long oweBillCount(Long contractId); | |||||
| } | } | ||||
| @@ -29,4 +29,6 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, Long> { | |||||
| void update(WxBillRent record); | void update(WxBillRent record); | ||||
| void updatePreviewStatus(WxBillRent record); | void updatePreviewStatus(WxBillRent record); | ||||
| Long oweBillCount(Long contractId); | |||||
| } | } | ||||
| @@ -7,9 +7,9 @@ import com.iformall.domain.po.WxMsgModel; | |||||
| public interface WxMsgModelMapper extends CommonMapper<WxMsgModel, String> { | public interface WxMsgModelMapper extends CommonMapper<WxMsgModel, String> { | ||||
| List<WxMsgModel> findList(WxMsgModel wxMsgModel); | List<WxMsgModel> findList(WxMsgModel wxMsgModel); | ||||
| WxMsgModel findOneByModelId(WxMsgModel wxMsgModel); | |||||
| @@ -24,4 +24,6 @@ public interface WxBillAllService { | |||||
| void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillAll wxBillAll); | void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillAll wxBillAll); | ||||
| Object getBillInfo(WxBillAll wxBillAll); | Object getBillInfo(WxBillAll wxBillAll); | ||||
| Long hasOweBill(Long contractId,Integer type); | |||||
| } | } | ||||
| @@ -2,6 +2,8 @@ package com.iformall.service.impl; | |||||
| import com.iformall.domain.po.BaseMsg; | import com.iformall.domain.po.BaseMsg; | ||||
| import com.iformall.domain.po.MailMsg; | import com.iformall.domain.po.MailMsg; | ||||
| import com.iformall.domain.po.WxMsgModel; | |||||
| import com.iformall.mapper.WxMsgModelMapper; | |||||
| import com.iformall.service.MsgSendService; | import com.iformall.service.MsgSendService; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -15,6 +17,7 @@ import org.springframework.mail.javamail.MimeMessageHelper; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import javax.mail.internet.MimeMessage; | import javax.mail.internet.MimeMessage; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * 发送邮件 | * 发送邮件 | ||||
| @@ -31,9 +34,28 @@ public class SendEmailServiceImpl implements MsgSendService { | |||||
| @Value("${spring.mail.username}") | @Value("${spring.mail.username}") | ||||
| private String from; | private String from; | ||||
| @Autowired | |||||
| private WxMsgModelMapper wxMsgModelMapper; | |||||
| @Override | @Override | ||||
| public void send(BaseMsg baseMsg) throws Exception{ | public void send(BaseMsg baseMsg) throws Exception{ | ||||
| MailMsg mailMsg = (MailMsg)baseMsg; | MailMsg mailMsg = (MailMsg)baseMsg; | ||||
| //根据模板替换动态内容 | |||||
| if(mailMsg.getModelId() != null){ | |||||
| WxMsgModel msgModel = new WxMsgModel(); | |||||
| msgModel.setTenantId(mailMsg.getTenantId()); | |||||
| msgModel.setModelId(mailMsg.getModelId()); | |||||
| WxMsgModel wxMsgModel = wxMsgModelMapper.findOneByModelId(msgModel); | |||||
| if(wxMsgModel == null){ | |||||
| throw new Exception("模板id:"+mailMsg.getModelId()+"不存在"); | |||||
| } | |||||
| String msg = wxMsgModel.getContent(); | |||||
| for (Map.Entry<String, String> entry : mailMsg.getDynamicContentMap().entrySet()) { | |||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||||
| } | |||||
| mailMsg.setMsg(msg); | |||||
| } | |||||
| if(mailMsg.isHtml()){ //html邮件 | if(mailMsg.isHtml()){ //html邮件 | ||||
| MimeMessage message = sender.createMimeMessage(); | MimeMessage message = sender.createMimeMessage(); | ||||
| @@ -515,4 +515,14 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| result.put("paidInfoForPoint", paidInfoForPoint); | result.put("paidInfoForPoint", paidInfoForPoint); | ||||
| return result; | return result; | ||||
| } | } | ||||
| @Override | |||||
| public Long hasOweBill(Long contractId, Integer type) { | |||||
| if(type.intValue() == 1){ | |||||
| return wxBillRentMapper.oweBillCount(contractId); | |||||
| }else if(type.intValue() == 2){ | |||||
| return wxBillPropertyMapper.oweBillCount(contractId); | |||||
| } | |||||
| return 0l; | |||||
| } | |||||
| } | } | ||||
| @@ -131,7 +131,7 @@ | |||||
| <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract"> | <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| update wx_bill_property set status = 6 where property_contract_id in | update wx_bill_property set status = 6 where property_contract_id in | ||||
| (select id from wx_property_contract where rent_contract_id = #{id}) | (select id from wx_property_contract where rent_contract_id = #{id}) | ||||
| and status in(4,2) | |||||
| and status != 3 | |||||
| </update> | </update> | ||||
| <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract"> | <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract"> | ||||
| @@ -148,4 +148,10 @@ | |||||
| update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId} | update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId} | ||||
| where property_contract_id = #{propertyContractId} | where property_contract_id = #{propertyContractId} | ||||
| </update> | </update> | ||||
| <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long"> | |||||
| select count(br.id) from wx_bill_property br,wx_property_contract c | |||||
| where c.id = br.property_contract_id and br.status = 1 and c.id = #{contractId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -127,7 +127,7 @@ | |||||
| <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillRent"> | <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillRent"> | ||||
| update wx_bill_rent set status = 6 where rent_contract_id = #{rentContractId} | update wx_bill_rent set status = 6 where rent_contract_id = #{rentContractId} | ||||
| and status in(4,2) | |||||
| and status != 3 | |||||
| </update> | </update> | ||||
| <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxRentContract"> | <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| @@ -144,4 +144,10 @@ | |||||
| update wx_bill_rent set is_preview = #{isPreview},merchant_id = #{merchantId} | update wx_bill_rent set is_preview = #{isPreview},merchant_id = #{merchantId} | ||||
| where rent_contract_id = #{rentContractId} | where rent_contract_id = #{rentContractId} | ||||
| </update> | </update> | ||||
| <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long"> | |||||
| select count(br.id) from wx_bill_rent br,wx_rent_contract c where c.id = br.rent_contract_id | |||||
| and br.status = 1 and c.id = #{contractId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -72,10 +72,20 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findOneByModelId" parameterType="com.iformall.domain.po.WxMsgModel" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_msg_model | |||||
| where 1=1 | |||||
| <if test=" null != modelId"> | |||||
| and `model_id` = #{modelId} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id`=#{tenantId} | |||||
| </if> | |||||
| limit 1 | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||