| @@ -0,0 +1,6 @@ | |||||
| INSERT INTO `mallink`.`wx_msg_validationcode_model`(`id`, `type`, `name`, `signature`, `content`, `createtime`, `status`, `minutes`, `email_bg_img`, `open`, `msg_type`, `role_type`, `model_code`) VALUES (34, 34, '预约通知', '富茂', '您有新的预约订单请及时处理。', '2023-07-20 18:00:26', 1, 0, NULL, 0, 1, 2, 'SMS_461970987'); | |||||
| INSERT INTO `mallink`.`wx_msg_validationcode_model`(`id`, `type`, `name`, `signature`, `content`, `createtime`, `status`, `minutes`, `email_bg_img`, `open`, `msg_type`, `role_type`, `model_code`) VALUES (35, 35, '分账失败提醒', '富茂', '您有订单分账处理失败,请及时查看。', '2023-07-20 18:00:26', 1, 0, NULL, 0, 1, 1, 'SMS_462021018'); | |||||
| INSERT INTO `mallink`.`wx_msg_validationcode_model`(`id`, `type`, `name`, `signature`, `content`, `createtime`, `status`, `minutes`, `email_bg_img`, `open`, `msg_type`, `role_type`, `model_code`) VALUES (36, 36, '分账失败通知', '富茂', '<!DOCTYPE html>\r\n<html>\r\n\r\n<head>\r\n <meta charset=\"utf-8\">\r\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n <meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />\r\n <meta name=\"renderer\" content=\"webkit\">\r\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\r\n <title>富茂通知邮件</title>\r\n <title></title>\r\n <style>\r\n *{\r\n margin: 0;\r\n padding: 0;\r\n }\r\n </style>\r\n</head>\r\n\r\n<body>\r\n <div id=\"box\" style=\"padding:80px 20%;background:#E9E7E7;min-height:100vh;\">\r\n <header style=\"height:140px;width:100%;display:flex;background:rgba(31,47,62,1);border-radius:15px 15px 0px 0px;\">\r\n </header>\r\n <content>\r\n <div style=\"background:#fff;\">\r\n <div style=\"font-size:26px;font-family:MicrosoftYaHei-Bold;font-weight:bold;color:rgba(85,85,85,1);line-height: 32px;padding: 56px 55px 0;\">通知<span>({mallName})</span></div>\r\n <div style=\"font-size:18px;font-family:MicrosoftYaHei;font-weight:400;color:rgba(85,85,85,1);padding: 36px 55px 40px;\"><span>您有分账处理失败的订单,请电脑登录后台查看分账详情</div>\r\n </div>\r\n </content>\r\n </div>\r\n</body>\r\n\r\n</html>', '2023-07-20 18:00:26', 1, NULL, NULL, 0, 2, 1, NULL); | |||||
| @@ -1,21 +1,20 @@ | |||||
| package com.iformall.schedule; | package com.iformall.schedule; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxSharingOrderDto; | |||||
| import com.iformall.domain.po.WxMall; | |||||
| import com.iformall.domain.po.WxPayOrder; | |||||
| import com.iformall.domain.po.WxProfitSharingOrder; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumPayStatus; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.enums.EnumProfitSharingOrderStatus; | |||||
| import com.iformall.enums.EnumProfitSharingOrderType; | |||||
| import com.iformall.domain.po.msg.MailMsg; | |||||
| import com.iformall.domain.po.msg.WxMsgRecord; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.WxMallMapper; | import com.iformall.mapper.WxMallMapper; | ||||
| import com.iformall.mapper.WxMallNoticeContactMapper; | |||||
| import com.iformall.mapper.WxPayOrderMapper; | import com.iformall.mapper.WxPayOrderMapper; | ||||
| import com.iformall.mapper.WxProfitSharingOrderMapper; | import com.iformall.mapper.WxProfitSharingOrderMapper; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxProfitSharingOrderService; | import com.iformall.service.WxProfitSharingOrderService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import org.apache.commons.collections.map.HashedMap; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -23,7 +22,9 @@ import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.scheduling.annotation.Scheduled; | import org.springframework.scheduling.annotation.Scheduled; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import java.util.List; | |||||
| import java.util.*; | |||||
| import java.util.concurrent.atomic.AtomicInteger; | |||||
| import java.util.stream.Collectors; | |||||
| @Component | @Component | ||||
| public class SharingOrderRedoSchedule { | public class SharingOrderRedoSchedule { | ||||
| @@ -39,10 +40,18 @@ public class SharingOrderRedoSchedule { | |||||
| @Autowired | @Autowired | ||||
| WxPayOrderMapper wxPayOrderMapper; | WxPayOrderMapper wxPayOrderMapper; | ||||
| @Autowired | @Autowired | ||||
| WxMallMapper wxMallMapper; | WxMallMapper wxMallMapper; | ||||
| @Autowired | |||||
| WxMallNoticeContactMapper wxMallNoticeContactMapper; | |||||
| @Autowired | |||||
| MqBaseProducer mqBaseProducer; | |||||
| @Autowired | |||||
| private String fmExceptionEmails; | |||||
| private List<WxMall> getMalls() { | private List<WxMall> getMalls() { | ||||
| WxMall wxMall =new WxMall(); | WxMall wxMall =new WxMall(); | ||||
| return wxMallMapper.findList(wxMall); | return wxMallMapper.findList(wxMall); | ||||
| @@ -55,6 +64,8 @@ public class SharingOrderRedoSchedule { | |||||
| public void sharingOrderRedoSchedule() { | public void sharingOrderRedoSchedule() { | ||||
| List<WxMall> malls = getMalls(); | List<WxMall> malls = getMalls(); | ||||
| for (WxMall mall: malls) { | for (WxMall mall: malls) { | ||||
| AtomicInteger errorCount = new AtomicInteger(); | |||||
| WxProfitSharingOrder wxProfitSharingOrder = new WxProfitSharingOrder(); | WxProfitSharingOrder wxProfitSharingOrder = new WxProfitSharingOrder(); | ||||
| wxProfitSharingOrder.setTenantId(mall.getTenantId()); | wxProfitSharingOrder.setTenantId(mall.getTenantId()); | ||||
| // wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | // wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | ||||
| @@ -62,32 +73,48 @@ public class SharingOrderRedoSchedule { | |||||
| List<WxProfitSharingOrder> list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); | List<WxProfitSharingOrder> list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); | ||||
| if (null != list) { | if (null != list) { | ||||
| list.stream().forEach(sharingOrder->{ | list.stream().forEach(sharingOrder->{ | ||||
| try { | |||||
| int i = DateUtils.daysBetween(sharingOrder.getCreateTime(), new Date()); | |||||
| boolean isSuccess = true; | |||||
| try { | |||||
| // WxPayOrder wxPayOrder = new WxPayOrder(); | // WxPayOrder wxPayOrder = new WxPayOrder(); | ||||
| // wxPayOrder.updateTenantInfo(sharingOrder); | // wxPayOrder.updateTenantInfo(sharingOrder); | ||||
| // wxPayOrder.setId(sharingOrder.getOrderId()); | // wxPayOrder.setId(sharingOrder.getOrderId()); | ||||
| // wxPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper(wxPayOrder)); | // wxPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper(wxPayOrder)); | ||||
| WxPayOrder wxPayOrder = wxPayOrderMapper.selectById(sharingOrder.getOrderId(),sharingOrder.getTenantId()); | WxPayOrder wxPayOrder = wxPayOrderMapper.selectById(sharingOrder.getOrderId(),sharingOrder.getTenantId()); | ||||
| if (null == wxPayOrder) { | if (null == wxPayOrder) { | ||||
| isSuccess = false; | |||||
| logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | ||||
| + " ID:" +sharingOrder.getId() | + " ID:" +sharingOrder.getId() | ||||
| + " RES: wxPayOrder is null." ); | + " RES: wxPayOrder is null." ); | ||||
| return; | |||||
| } | } | ||||
| ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder,wxPayOrder); | ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder,wxPayOrder); | ||||
| if (result.code != ResultData.SUCCESS) { | if (result.code != ResultData.SUCCESS) { | ||||
| isSuccess = false; | |||||
| logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | ||||
| + " ID:" +sharingOrder.getId() | + " ID:" +sharingOrder.getId() | ||||
| + " RES:" + result.message); | + " RES:" + result.message); | ||||
| } | } | ||||
| } catch (Exception e){ | } catch (Exception e){ | ||||
| isSuccess = false; | |||||
| logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() | ||||
| + " ID:" +sharingOrder.getId() | + " ID:" +sharingOrder.getId() | ||||
| + " MSG:" + e.getMessage()); | + " MSG:" + e.getMessage()); | ||||
| } | } | ||||
| //分账3天失败给通知 | |||||
| if(!isSuccess && i >= 3){ | |||||
| errorCount.getAndIncrement(); | |||||
| } | |||||
| }); | }); | ||||
| } | } | ||||
| if(errorCount.get() > 0){ | |||||
| try{ | |||||
| //分账失败通知 | |||||
| sendSharingErrorMsg(mall); | |||||
| }catch(Exception e){} | |||||
| } | |||||
| // wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); | // wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); | ||||
| // wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | // wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | ||||
| @@ -134,6 +161,47 @@ public class SharingOrderRedoSchedule { | |||||
| } | } | ||||
| private void sendSharingErrorMsg(WxMall mall){ | |||||
| logger.info("分账失败通知start"); | |||||
| WxMallNoticeContact noticeContact = wxMallNoticeContactMapper.getByTenantInfo(mall); | |||||
| if(noticeContact == null){ | |||||
| return; | |||||
| } | |||||
| Map<String, String> msgReplaceMap = new HashMap(); | |||||
| msgReplaceMap.put("mallName", mall.getName()); | |||||
| if(StringUtils.isNotBlank(noticeContact.getPhone()) && EnumYesOrNo.YES.getCode().equals(noticeContact.getPhoneEnabled())){ | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.updateTenantInfo(mall); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.COUPON_ORDER_SHARING_ERROR.getCode()); | |||||
| wxMsgRecord.setReceiver(noticeContact.getPhone()); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| logger.info("分账失败短信通知end"); | |||||
| } | |||||
| String[] fmEmails = fmExceptionEmails.split(","); | |||||
| List<String> mails = new ArrayList<>(Arrays.asList(fmEmails)); | |||||
| if(StringUtils.isNotBlank(noticeContact.getEmail()) && EnumYesOrNo.YES.getCode().equals(noticeContact.getEmailEnabled())){ | |||||
| mails.add(noticeContact.getEmail()); | |||||
| } | |||||
| String[] strings = mails.toArray(new String[mails.size()]); | |||||
| MailMsg mailMsg = new MailMsg(); | |||||
| mailMsg.setSubject("分账失败通知"); | |||||
| mailMsg.setHtml(true); | |||||
| mailMsg.setMsgType(EnumMsgRecordType.EMAIL.getCode()); | |||||
| mailMsg.setModelType(EnumMailMsgModel.MAIL_SHARING_ERROR.getCode()); | |||||
| mailMsg.setTo(strings); | |||||
| mailMsg.updateTenantInfo(mall); | |||||
| mailMsg.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(mailMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| logger.info("分账失败邮件通知end"); | |||||
| } | |||||
| // @Async | // @Async | ||||
| //// @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨02:00分账重试 | //// @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨02:00分账重试 | ||||
| // @Scheduled(cron = "0 10 */1 * * ?") // 测试 | // @Scheduled(cron = "0 10 */1 * * ?") // 测试 | ||||
| @@ -37,7 +37,7 @@ public class WxMsgValidationcodeModel extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="发送开关 0开1关",name="open") | @io.swagger.annotations.ApiModelProperty(value="发送开关 0开1关",name="open") | ||||
| private Integer open; | private Integer open; | ||||
| @io.swagger.annotations.ApiModelProperty(value="消息类型 0全部 1短信 2邮箱 11阿里云短信(暂未启用)",name="msgType") | |||||
| @io.swagger.annotations.ApiModelProperty(value="消息类型 1短信 2邮箱",name="msgType") | |||||
| private Integer msgType; | private Integer msgType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="0通用1管理员2商户端3消费者",name="roleType") | @io.swagger.annotations.ApiModelProperty(value="0通用1管理员2商户端3消费者",name="roleType") | ||||
| @@ -17,6 +17,9 @@ public enum EnumMailMsgModel { | |||||
| MAIL_C_APPLY_NODIFY(25, "审批通知"), | MAIL_C_APPLY_NODIFY(25, "审批通知"), | ||||
| MAIL_C_ASSIGNEE_NODIFY(26, "代办通知"), | MAIL_C_ASSIGNEE_NODIFY(26, "代办通知"), | ||||
| MAIL_C_REJECT_NODIFY(27, "驳回通知"), | MAIL_C_REJECT_NODIFY(27, "驳回通知"), | ||||
| MAIL_SHARING_ERROR(36, "分账失败通知"), | |||||
| ; | ; | ||||
| public static EnumMailMsgModel getEnum(Integer code) { | public static EnumMailMsgModel getEnum(Integer code) { | ||||
| @@ -41,6 +41,9 @@ public enum EnumMsgModel { | |||||
| COUPON_ORDER_SUCCESS(32,"购买成功提醒"), | COUPON_ORDER_SUCCESS(32,"购买成功提醒"), | ||||
| COUPON_ORDER_REFUND(33,"提交退款提醒"), | COUPON_ORDER_REFUND(33,"提交退款提醒"), | ||||
| COUPON_ORDER_RESERVATION_SUCCESS(34,"预约成功提醒"), | |||||
| COUPON_ORDER_SHARING_ERROR(35,"分账失败提醒"), | |||||
| ; | ; | ||||
| public static EnumMsgModel getEnum(Integer code) { | public static EnumMsgModel getEnum(Integer code) { | ||||
| @@ -25,4 +25,7 @@ public interface WxMerchantBUserMapper extends CommonMapper<WxMerchantBUser, Lon | |||||
| int addOtherMerchant(@Param("tenantId")String tenantId, @Param("ids")List<Long> ids, @Param("otherId")String otherId); | int addOtherMerchant(@Param("tenantId")String tenantId, @Param("ids")List<Long> ids, @Param("otherId")String otherId); | ||||
| void deleteByMerchantId(@Param("tenantId")String tenantId, @Param("merchantId")Long merchantId); | void deleteByMerchantId(@Param("tenantId")String tenantId, @Param("merchantId")Long merchantId); | ||||
| List<String> findAdminPhone(@Param("merchantIds")List<Long> merchantIds); | |||||
| } | } | ||||
| @@ -24,5 +24,7 @@ public interface WxMerchantRelationMapper extends CommonMapper<WxMerchantRelatio | |||||
| List<Long> getRelationByRegionId(@Param("regionId") Long regionId); | List<Long> getRelationByRegionId(@Param("regionId") Long regionId); | ||||
| List<Long> getRegionMerchantId(@Param("merchantId") Long merchantId); | |||||
| List<WxMerchantRelation> getInfByRegionId(@Param("id") Long id); | List<WxMerchantRelation> getInfByRegionId(@Param("id") Long id); | ||||
| } | } | ||||
| @@ -584,10 +584,12 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| if (null != cardInfoList && cardInfoList.size() > 0 ){ | if (null != cardInfoList && cardInfoList.size() > 0 ){ | ||||
| for (int i = 0 ;i < cardInfoList.size();i++){ | for (int i = 0 ;i < cardInfoList.size();i++){ | ||||
| WxCardInfo ci = cardInfoList.get(i); | WxCardInfo ci = cardInfoList.get(i); | ||||
| if (null != ci.getCouponId() && (!couponIdList.contains(ci.getCouponId()))) { | |||||
| couponIdList.add(ci.getCouponId()) ; | |||||
| cardCouponIdMap.put(ci.getId(),ci.getCouponId()); | |||||
| } | |||||
| if (null != ci.getCouponId()){ | |||||
| cardCouponIdMap.put(ci.getId(),ci.getCouponId()); | |||||
| if(!couponIdList.contains(ci.getCouponId())){ | |||||
| couponIdList.add(ci.getCouponId()) ; | |||||
| } | |||||
| } | |||||
| cardInfoMap.put(ci.getId(), ci); | cardInfoMap.put(ci.getId(), ci); | ||||
| } | } | ||||
| } | } | ||||
| @@ -248,6 +248,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponOrderReservationMapper wxCouponOrderReservationMapper; | private WxCouponOrderReservationMapper wxCouponOrderReservationMapper; | ||||
| @Autowired | |||||
| private WxMerchantRelationMapper wxMerchantRelationMapper; | |||||
| @Override | @Override | ||||
| @@ -1519,6 +1522,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| record.setCreateDate(curr); | record.setCreateDate(curr); | ||||
| record.setUpdateDate(curr); | record.setUpdateDate(curr); | ||||
| wxCouponOrderReservationMapper.insert(record); | wxCouponOrderReservationMapper.insert(record); | ||||
| } | } | ||||
| } | } | ||||
| }catch(Exception e){ | }catch(Exception e){ | ||||
| @@ -2234,21 +2238,21 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| * @param user | * @param user | ||||
| */ | */ | ||||
| public void actionAfterCouponOrderSuccess(WxOrder order, WxCoupon coupon, WxCUserBasicInfo user) { | public void actionAfterCouponOrderSuccess(WxOrder order, WxCoupon coupon, WxCUserBasicInfo user) { | ||||
| WxCouponOrder couponOrderQ = new WxCouponOrder(); | |||||
| couponOrderQ.setOrderId(order.getId()); | |||||
| couponOrderQ.updateTenantInfo(order); | |||||
| List<WxCouponOrder> couponorderlist = wxCouponOrderMapper.findList(couponOrderQ); | |||||
| WxCouponOrder couponOrder = null; | |||||
| if (null != couponorderlist && couponorderlist.size() > 0 ) { | |||||
| couponOrder = couponorderlist.get(0); | |||||
| } | |||||
| if(EnumCouponType.COUPON_GIFT.getCode().equals(coupon.getType())){ | if(EnumCouponType.COUPON_GIFT.getCode().equals(coupon.getType())){ | ||||
| WxCouponOrder couponOrderQ = new WxCouponOrder(); | |||||
| couponOrderQ.setOrderId(order.getId()); | |||||
| couponOrderQ.setCouponId(coupon.getId()); | |||||
| couponOrderQ.updateTenantInfo(order); | |||||
| List<WxCouponOrder> couponorderlist = wxCouponOrderMapper.findList(couponOrderQ); | |||||
| if (null != couponorderlist && couponorderlist.size() > 0 ) { | |||||
| WxCouponOrder couponOrder = couponorderlist.get(0); | |||||
| try { | |||||
| wxCouponOrderService.verify(couponOrder,null,EnumCouponVerifyType.VERIFY_AUTO,null); | |||||
| } catch (Exception e) { | |||||
| logger.error("系统券包核销异常:" + e.getMessage(),e); | |||||
| } | |||||
| try { | |||||
| wxCouponOrderService.verify(couponOrder,null,EnumCouponVerifyType.VERIFY_AUTO,null); | |||||
| } catch (Exception e) { | |||||
| logger.error("系统券包核销异常:" + e.getMessage(),e); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2267,18 +2271,18 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("订单发券:" + e.getMessage(),e); | logger.error("订单发券:" + e.getMessage(),e); | ||||
| } | } | ||||
| //通知用户 | |||||
| //通知 | |||||
| try { | try { | ||||
| sendMsgAfterCouponOrderSuccess(order,coupon,user); | |||||
| sendMsgAfterCouponOrderSuccess(order,couponOrder,coupon,user); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("订单成功通知用户error:" + e.getMessage(),e); | |||||
| logger.error("订单成功通知error:" + e.getMessage(),e); | |||||
| } | } | ||||
| //同步订单 | //同步订单 | ||||
| sendInsideOrderPushMsg(order,order.getComposeOrderId(),null); | sendInsideOrderPushMsg(order,order.getComposeOrderId(),null); | ||||
| } | } | ||||
| private void sendMsgAfterCouponOrderSuccess(WxOrder order,WxCoupon coupon, WxCUserBasicInfo user) { | |||||
| // 发送短信 | |||||
| private void sendMsgAfterCouponOrderSuccess(WxOrder order,WxCouponOrder couponOrder,WxCoupon coupon, WxCUserBasicInfo user) { | |||||
| // 通知用户 | |||||
| if(EnumPayWay.PAY_WAY_TT.getCode().equals(order.getPayVendor())){ | if(EnumPayWay.PAY_WAY_TT.getCode().equals(order.getPayVendor())){ | ||||
| logger.info("订单成功短信通知start"); | logger.info("订单成功短信通知start"); | ||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(order, EnumPayWay.PAY_WAY_TT.getPlat()); | WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(order, EnumPayWay.PAY_WAY_TT.getPlat()); | ||||
| @@ -2299,6 +2303,39 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| logger.info("订单成功短信通知end"); | logger.info("订单成功短信通知end"); | ||||
| } | } | ||||
| if(EnumCouponType.COUPON_DOUYIN_GO_HOME.getCode().equals(coupon.getType())){ | |||||
| logger.info("订单预约短信通知start"); | |||||
| WxCouponOrderReservation couponOrderReservation = wxCouponOrderReservationMapper.getSortByCouponOrder(couponOrder.getId(), couponOrder.getTenantId()); | |||||
| if(couponOrderReservation == null || couponOrderReservation.getReservationMerchantId() == null){ | |||||
| return; | |||||
| } | |||||
| List<Long> merchantIds = new ArrayList(); | |||||
| merchantIds.add(couponOrderReservation.getReservationMerchantId()); | |||||
| List<Long> regionMerchantIds = wxMerchantRelationMapper.getRegionMerchantId(couponOrderReservation.getReservationMerchantId()); | |||||
| if(!regionMerchantIds.isEmpty()){ | |||||
| merchantIds.addAll(regionMerchantIds); | |||||
| } | |||||
| List<String> phones = wxMerchantBUserMapper.findAdminPhone(merchantIds); | |||||
| if(phones.isEmpty()){ | |||||
| return; | |||||
| } | |||||
| String toPhone = phones.stream().collect(Collectors.joining(",")); | |||||
| Map<String, String> msgReplaceMap = new HashMap(); | |||||
| msgReplaceMap.put("id", couponOrderReservation.getId().toString()); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.updateTenantInfo(order); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.COUPON_ORDER_RESERVATION_SUCCESS.getCode()); | |||||
| wxMsgRecord.setReceiver(toPhone); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| logger.info("订单预约短信通知end"); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -250,16 +250,18 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||||
| WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | ||||
| updSharingOrder.updateTenantInfo(sharingOrder); | updSharingOrder.updateTenantInfo(sharingOrder); | ||||
| updSharingOrder.setId(sharingOrder.getId()); | updSharingOrder.setId(sharingOrder.getId()); | ||||
| updSharingOrder.setUpdateTime(currentDate); | |||||
| if(e.getErrorCode() == ErrorCode.PROFIT_SHARING_NO_SUB_LEDGER_AMOUNT.getCode()){ | if(e.getErrorCode() == ErrorCode.PROFIT_SHARING_NO_SUB_LEDGER_AMOUNT.getCode()){ | ||||
| updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_PROCESSING.getCode()); | updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_PROCESSING.getCode()); | ||||
| updSharingOrder.setErrorMsg(e.getMessage()); | updSharingOrder.setErrorMsg(e.getMessage()); | ||||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | |||||
| return new ResultData(); | |||||
| }else{ | }else{ | ||||
| updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | ||||
| updSharingOrder.setErrorMsg(e.getMessage()); | updSharingOrder.setErrorMsg(e.getMessage()); | ||||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),e.getMessage()); | |||||
| } | } | ||||
| updSharingOrder.setUpdateTime(currentDate); | |||||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),e.getMessage()); | |||||
| }catch(Exception e){ | }catch(Exception e){ | ||||
| WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | ||||
| updSharingOrder.updateTenantInfo(sharingOrder); | updSharingOrder.updateTenantInfo(sharingOrder); | ||||
| @@ -48,26 +48,26 @@ public class SendEmailServiceImpl implements MsgSendService { | |||||
| TenantEntity tenantEntity = mailMsg.getTenantInfo(); | TenantEntity tenantEntity = mailMsg.getTenantInfo(); | ||||
| //根据模板替换动态内容 | //根据模板替换动态内容 | ||||
| if(mailMsg.getModelId() != null){ | |||||
| WxMsgValidationcodeModel msgModel = new WxMsgValidationcodeModel(); | |||||
| msgModel.setType(mailMsg.getModelType()); | |||||
| msgModel.setModelCode(String.valueOf(mailMsg.getModelId())); | |||||
| msgModel.setOpen(EnumMsgOpen.OPEN.getCode()); | |||||
| List<WxMsgValidationcodeModel> modelList = wxMsgValidationcodeModelMapper.findList(msgModel); | |||||
| if(CollectionUtils.isEmpty(modelList)){ | |||||
| throw new Exception("模板id:"+mailMsg.getModelId()+"不存在"); | |||||
| } | |||||
| WxMsgValidationcodeModel wxMsgModel = modelList.get(0); | |||||
| WxMsgValidationcodeModel msgModel = new WxMsgValidationcodeModel(); | |||||
| msgModel.setType(mailMsg.getModelType()); | |||||
| msgModel.setMsgType(2); | |||||
| // msgModel.setModelCode(String.valueOf(mailMsg.getModelId())); | |||||
| msgModel.setOpen(EnumMsgOpen.OPEN.getCode()); | |||||
| List<WxMsgValidationcodeModel> modelList = wxMsgValidationcodeModelMapper.findList(msgModel); | |||||
| if(CollectionUtils.isEmpty(modelList)){ | |||||
| throw new Exception("模板:不存在"); | |||||
| } | |||||
| WxMsgValidationcodeModel wxMsgModel = modelList.get(0); | |||||
| String msg = wxMsgModel.getContent(); | |||||
| for (Map.Entry<String, String> entry : mailMsg.getDynamicContentMap().entrySet()) { | |||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||||
| } | |||||
| String msg = wxMsgModel.getContent(); | |||||
| for (Map.Entry<String, String> entry : mailMsg.getDynamicContentMap().entrySet()) { | |||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||||
| } | |||||
| if(StringUtils.isNotBlank(wxMsgModel.getEmailBgImg())){ | |||||
| msg = msg.replace("{bg}", wxMsgModel.getEmailBgImg()); | |||||
| } | |||||
| mailMsg.setMsg(msg); | |||||
| if(StringUtils.isNotBlank(wxMsgModel.getEmailBgImg())){ | |||||
| msg = msg.replace("{bg}", wxMsgModel.getEmailBgImg()); | |||||
| } | } | ||||
| mailMsg.setMsg(msg); | |||||
| if(mailMsg.isHtml()){ //html邮件 | if(mailMsg.isHtml()){ //html邮件 | ||||
| MimeMessage message = sender.createMimeMessage(); | MimeMessage message = sender.createMimeMessage(); | ||||
| @@ -61,6 +61,7 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | ||||
| wxMsgValidationcodeModel.setType(record.getModelType()); | wxMsgValidationcodeModel.setType(record.getModelType()); | ||||
| wxMsgValidationcodeModel.setMsgType(1); | |||||
| wxMsgValidationcodeModel.setOpen(EnumMsgOpen.OPEN.getCode()); | wxMsgValidationcodeModel.setOpen(EnumMsgOpen.OPEN.getCode()); | ||||
| List<WxMsgValidationcodeModel> modelList = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel); | List<WxMsgValidationcodeModel> modelList = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel); | ||||
| if(CollectionUtils.isEmpty(modelList)){ | if(CollectionUtils.isEmpty(modelList)){ | ||||
| @@ -194,4 +194,15 @@ | |||||
| delete from wx_merchant_b_user where `tenant_id` = #{tenantId} and `merchant_id` = #{merchantId} | delete from wx_merchant_b_user where `tenant_id` = #{tenantId} and `merchant_id` = #{merchantId} | ||||
| </delete> | </delete> | ||||
| <select id="findAdminPhone" resultType="java.lang.String"> | |||||
| select phone | |||||
| from wx_merchant_b_user | |||||
| where `is_admin` = 1 | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> | |||||
| #{merchantIdItem} | |||||
| </foreach> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -76,9 +76,15 @@ | |||||
| merchant_id | merchant_id | ||||
| from wx_merchant_relation | from wx_merchant_relation | ||||
| where is_del = 0 | where is_del = 0 | ||||
| <if test="regionId != null and regionId != ''"> | |||||
| and region_merchant_id = #{regionId} | |||||
| </if> | |||||
| and region_merchant_id = #{regionId} | |||||
| </select> | |||||
| <select id="getRegionMerchantId" resultType="java.lang.Long"> | |||||
| select | |||||
| region_merchant_id | |||||
| from wx_merchant_relation | |||||
| where is_del = 0 | |||||
| and merchant_id = #{merchantId} | |||||
| </select> | </select> | ||||
| <select id="getInfByRegionId" resultType="com.iformall.domain.po.WxMerchantRelation"> | <select id="getInfByRegionId" resultType="com.iformall.domain.po.WxMerchantRelation"> | ||||