| | |
| | | package com.yeshi.fanli.service.impl.order.msg;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.push.PushContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory;
|
| | | import com.yeshi.fanli.exception.msg.MsgOrderDetailException;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.service.inter.order.msg.MsgOrderDetailService;
|
| | | import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.util.factory.msg.MsgOrderDetailFactory;
|
| | |
|
| | | @Service
|
| | | public class UserOrderMsgNotificationServiceImpl implements UserOrderMsgNotificationService {
|
| | |
|
| | | @Resource
|
| | | private MsgOrderDetailService msgOrderDetailService;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Override
|
| | | public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int goodsCount, int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createFanLiOrder(uid, orderId, orderType, goodsCount, orderState,
|
| | | payMoney, money, null);
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail,
|
| | | (payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money);
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderFanLiStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createFanLiOrder(uid, orderId, orderType, 0, orderState, payMoney,
|
| | | money, null);
|
| | | // 暂时不推送
|
| | | try {
|
| | | msgOrderDetailService.updateMsgOrderDetail(detail, false);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int goodsCount, int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createShareOrder(uid, orderId, orderType, goodsCount, orderState,
|
| | | payMoney, money, null);
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail,
|
| | | (payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | PushContentDTO dto = PushMsgFactory.createShareOrderStatisticed(orderType, orderId, money);
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderShareStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createShareOrder(uid, orderId, orderType, 0, orderState, payMoney,
|
| | | money, null);
|
| | | // 暂时不推送
|
| | | // try {
|
| | | // msgOrderDetailService.updateMsgOrderDetail(detail, false);
|
| | | // } catch (MsgOrderDetailException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int goodsCount, int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, goodsCount, orderState,
|
| | | payMoney, money, null);
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail,
|
| | | (money == null || money.compareTo(new BigDecimal(0)) <= 0) ? false : true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderInviteStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, 0, orderState,
|
| | | payMoney, money, null);
|
| | | // 暂时不推送
|
| | | // try {
|
| | | // msgOrderDetailService.updateMsgOrderDetail(detail, false);
|
| | | // } catch (MsgOrderDetailException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | |
|
| | | }
|
| | |
|
| | | private String getShortName(String name) {
|
| | | if (name != null && name.length() > 2) {
|
| | | return name.charAt(0) + "**" + name.charAt(name.length() - 1);
|
| | | }
|
| | | return name;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderShareFirstLevelStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney,
|
| | | BigDecimal money, int goodsCount, int orderState, String sourceUserName) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, goodsCount, orderState,
|
| | | payMoney, money, String.format("由直接粉丝【%s】分享", getShortName(sourceUserName)));
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail,
|
| | | (money == null || money.compareTo(new BigDecimal(0)) <= 0) ? false : true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderShareFirstLevelStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney,
|
| | | BigDecimal money, int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, 0, orderState,
|
| | | payMoney, money, null);
|
| | | // 暂时不推送
|
| | | // try {
|
| | | // msgOrderDetailService.updateMsgOrderDetail(detail, false);
|
| | | // } catch (MsgOrderDetailException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderFoundSuccess(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createFoundOrder(uid, orderId, true, payMoney, orderType,
|
| | | happendDate, "如有疑问请联系人工客服");
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail, true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderFoundFail(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createFoundOrder(uid, orderId, false, payMoney, orderType,
|
| | | happendDate, "如有疑问请联系人工客服");
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail, true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderElmeStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
|
| | | money, null);
|
| | | try {
|
| | | msgOrderDetailService.addMsgOrderDetail(detail,
|
| | | (payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void orderElmeStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
|
| | | int orderState) {
|
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
|
| | | money, null);
|
| | | // 暂时不推送
|
| | | try {
|
| | | msgOrderDetailService.updateMsgOrderDetail(detail, false);
|
| | | } catch (MsgOrderDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.order.msg; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.yeshi.fanli.dto.push.PushContentDTO; |
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail; |
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory; |
| | | import com.yeshi.fanli.exception.msg.MsgOrderDetailException; |
| | | import com.yeshi.fanli.exception.push.PushException; |
| | | import com.yeshi.fanli.service.inter.order.msg.MsgOrderDetailService; |
| | | import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService; |
| | | import com.yeshi.fanli.service.inter.push.PushService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.factory.msg.MsgOrderDetailFactory; |
| | | |
| | | @Service |
| | | public class UserOrderMsgNotificationServiceImpl implements UserOrderMsgNotificationService { |
| | | |
| | | @Resource |
| | | private MsgOrderDetailService msgOrderDetailService; |
| | | |
| | | @Resource |
| | | private PushService pushService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | @Override |
| | | public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money, |
| | | int goodsCount, int orderState, Date downTime) { |
| | | // 是否通知 |
| | | boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false; |
| | | // 保存消息明细消息 |
| | | addOrderStatistics(uid, orderId, orderType, Constant.TYPE_REBATE, goodsCount, payMoney, money, downTime, null, needNotify); |
| | | |
| | | SystemEnum system = userInfoService.getUserSystem(uid); |
| | | if (needNotify) { |
| | | PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money); |
| | | try { |
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (PushException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money, |
| | | int goodsCount, int orderState, Date downTime) { |
| | | // 是否通知 |
| | | boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false; |
| | | // 保存消息明细消息 |
| | | addOrderStatistics(uid, orderId, orderType, Constant.TYPE_SHAER, goodsCount, payMoney, money, downTime, null, needNotify); |
| | | |
| | | SystemEnum system = userInfoService.getUserSystem(uid); |
| | | |
| | | PushContentDTO dto = PushMsgFactory.createShareOrderStatisticed(orderType, orderId, money); |
| | | try { |
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (PushException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money, |
| | | BigDecimal subsidy, int goodsCount, int orderState, Date downTime) { |
| | | BigDecimal totalMoney = new BigDecimal(0); |
| | | if (money != null) { |
| | | totalMoney = totalMoney.add(money); |
| | | } |
| | | if (subsidy != null) { |
| | | totalMoney = totalMoney.add(subsidy); |
| | | } |
| | | |
| | | if (totalMoney.compareTo(new BigDecimal(0)) <= 0) { |
| | | return; |
| | | } |
| | | |
| | | SystemEnum system = userInfoService.getUserSystem(uid); |
| | | |
| | | // 保存消息明细消息 |
| | | addOrderStatistics(uid, orderId, orderType, Constant.TYPE_INVITE, goodsCount, payMoney, totalMoney, downTime, null, true); |
| | | |
| | | PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money); |
| | | try { |
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null, system); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (PushException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建订单被统计消息 |
| | | * |
| | | * @param uid |
| | | * @param orderId 订单号 |
| | | * @param source 订单来源:淘宝、京东、天猫 |
| | | * @param type 订单类型:自购、分享、团队 |
| | | * @param goodsCount 商品数量 |
| | | * @param payMoney 付款金额 |
| | | * @param money 返利金额 |
| | | * @param downTime 下单时间 |
| | | * @param beiZhu 备注信息 - 非必填 |
| | | * @return |
| | | */ |
| | | private void addOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount, |
| | | BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu, boolean needNotify) { |
| | | try { |
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createOrderStatistics(uid, orderId, source, type, goodsCount, payMoney, money, downTime, beiZhu); |
| | | // 消息 |
| | | msgOrderDetailService.addMsgOrderDetail(detail, needNotify); |
| | | } catch (MsgOrderDetailException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void orderFoundSuccess(Long uid, String orderId, int orderSource, int type, BigDecimal payMoney, BigDecimal money, int goodsCount, Date submitTime) { |
| | | try { |
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundSuccess(uid, orderId, orderSource, type, goodsCount, payMoney, money, submitTime, ""); |
| | | // 消息 |
| | | msgOrderDetailService.addMsgOrderDetail(detail, true); |
| | | } catch (MsgOrderDetailException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void orderFoundFail(Long uid, String orderId) { |
| | | try { |
| | | MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundFail(uid, orderId, ""); |
| | | // 消息 |
| | | msgOrderDetailService.addMsgOrderDetail(detail, true); |
| | | } catch (MsgOrderDetailException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void orderInvalidToBusinessRunning(Long uid, String orderId, int orderSource, int type) { |
| | | try { |
| | | MsgOrderDetail detail = MsgOrderDetailFactory.orderInvalidToBusinessRunning(uid, orderId, orderSource, type); |
| | | // 消息 |
| | | msgOrderDetailService.addMsgOrderDetail(detail, true); |
| | | } catch (MsgOrderDetailException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |