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();
|
}
|
}
|
|
}
|