use of cn.lili.modules.order.order.entity.dos.Order in project lilishop by lilishop.
the class MemberEvaluationServiceImpl method addMemberEvaluation.
@Override
@Transactional(rollbackFor = Exception.class)
public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf) {
// 获取子订单信息
OrderItem orderItem = orderItemService.getBySn(memberEvaluationDTO.getOrderItemSn());
// 获取订单信息
Order order = orderService.getBySn(orderItem.getOrderSn());
// 检测是否可以添加会员评价
Member member;
checkMemberEvaluation(orderItem, order);
if (Boolean.TRUE.equals(isSelf)) {
// 自我评价商品时,获取当前登录用户信息
member = memberService.getUserInfo();
} else {
// 获取用户信息 非自己评价时,读取数据库
member = memberService.getById(order.getMemberId());
}
// 获取商品信息
GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(memberEvaluationDTO.getSkuId());
// 新增用户评价
MemberEvaluation memberEvaluation = new MemberEvaluation(memberEvaluationDTO, goodsSku, member, order);
// 过滤商品咨询敏感词
memberEvaluation.setContent(SensitiveWordsFilter.filter(memberEvaluation.getContent()));
// 添加评价
this.save(memberEvaluation);
// 修改订单货物评价状态为已评价
orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
// 发送商品评价消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name();
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberEvaluation), RocketmqSendCallbackBuilder.commonCallback());
return memberEvaluationDTO;
}
use of cn.lili.modules.order.order.entity.dos.Order in project lilishop by lilishop.
the class WechatMessageUtil method wechatMpMessage.
/**
* 发送微信消息
*
* @param sn
*/
public void wechatMpMessage(String sn) {
log.info("发送消息订阅");
Order order = orderService.getBySn(sn);
if (order == null) {
throw new ServiceException("订单" + sn + "不存在,发送订阅消息错误");
}
// 获取微信消息
LambdaQueryWrapper<WechatMPMessage> wechatMPMessageQueryWrapper = new LambdaQueryWrapper();
wechatMPMessageQueryWrapper.eq(WechatMPMessage::getOrderStatus, order.getOrderStatus());
WechatMPMessage wechatMPMessage = wechatMPMessageService.getOne(wechatMPMessageQueryWrapper);
if (wechatMPMessage == null) {
log.info("未配置微信消息订阅");
return;
}
Connect connect = connectService.queryConnect(ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(ConnectEnum.WECHAT_MP_OPEN_ID.name()).build());
if (connect == null) {
return;
}
log.info("微信消息订阅消息发送:{}", order.getMemberId() + "-" + sn);
// 获取token
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
// 发送url
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token;
Map<String, Object> map = new HashMap<>(4);
// 用户id
map.put("touser", connect.getUnionId());
// 模版id
map.put("template_id", wechatMPMessage.getCode());
// 模版中所需数据
Map<String, Map<String, String>> postParams = createData(order, wechatMPMessage);
map.put("data", postParams);
map.put("page", "pages/order/orderDetail?sn=" + order.getSn());
log.info("参数内容:" + JSONUtil.toJsonStr(map));
String content = null;
try {
content = HttpUtil.post(url, JSONUtil.toJsonStr(map));
} catch (Exception e) {
log.error("微信消息发送错误", e);
}
JSONObject json = new JSONObject(content);
log.info("微信消息发送结果:" + content);
String errorMessage = json.getStr("errmsg");
String errcode = json.getStr("errcode");
// 发送失败
if (!"0".equals(errcode)) {
log.error("消息发送失败:" + errorMessage);
log.error("消息发送请求token:" + token);
log.error("消息发送请求:" + postParams);
}
}
use of cn.lili.modules.order.order.entity.dos.Order in project lilishop by lilishop.
the class WechatMessageUtil method wechatMessage.
/**
* 发送微信消息
*
* @param sn
*/
public void wechatMessage(String sn) {
Order order = orderService.getBySn(sn);
if (order == null) {
throw new ServiceException("订单" + sn + "不存在,发送微信公众号消息错误");
}
// 获取微信消息
LambdaQueryWrapper<WechatMessage> wechatMessageQueryWrapper = new LambdaQueryWrapper();
wechatMessageQueryWrapper.eq(WechatMessage::getOrderStatus, order.getOrderStatus());
WechatMessage wechatMessage = wechatMessageService.getOne(wechatMessageQueryWrapper);
if (wechatMessage == null) {
return;
}
Connect connect = connectService.queryConnect(ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(ConnectEnum.WECHAT.name()).build());
if (connect == null) {
return;
}
log.info("微信消息发送消息:{}", order.getMemberId() + "-" + sn);
// 获取token
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
// 发送url
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
Map<String, String> map = new HashMap<>(4);
// 用户id
map.put("touser", connect.getUnionId());
// 模版id
map.put("template_id", wechatMessage.getCode());
// 模版中所需数据
String postParams = createData(order, wechatMessage);
map.put("data", postParams);
log.info("参数内容:" + JSONUtil.toJsonStr(map));
String content = HttpUtils.doPostWithJson(url, map);
JSONObject json = new JSONObject(content);
log.info("微信消息发送结果:" + content);
String errorMessage = json.getStr("errmsg");
String errcode = json.getStr("errcode");
// 发送失败
if (!"0".equals(errcode)) {
log.error("消息发送失败:" + errorMessage);
log.error("消息发送请求token:" + token);
log.error("消息发送请求:" + postParams);
}
}
use of cn.lili.modules.order.order.entity.dos.Order in project lilishop by lilishop.
the class VerificationOrderExecute method orderChange.
@Override
public void orderChange(OrderMessage orderMessage) {
// 订单状态为待核验,添加订单添加核验码
if (orderMessage.getNewStatus().equals(OrderStatusEnum.TAKE)) {
// 获取订单信息
Order order = orderService.getBySn(orderMessage.getOrderSn());
// 获取随机数,判定是否存在
String code = getCode(order.getStoreId());
// 设置订单验证码
orderService.update(new LambdaUpdateWrapper<Order>().set(Order::getVerificationCode, code).eq(Order::getSn, orderMessage.getOrderSn()));
// 修改虚拟订单货物可以进行售后、投诉
orderItemService.update(new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getOrderSn, orderMessage.getOrderSn()).set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED).set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY));
}
}
use of cn.lili.modules.order.order.entity.dos.Order in project lilishop by lilishop.
the class VerificationOrderExecute method getCode.
/**
* 获取随机数
* 判断当前店铺下是否使用验证码,如果已使用则重新获取
*
* @param storeId 店铺ID
* @return
*/
private String getCode(String storeId) {
// 获取八位验证码
String code = Long.toString(RandomUtil.randomLong(10000000, 99999999));
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<Order>().eq(Order::getVerificationCode, code).eq(Order::getStoreId, storeId);
if (orderService.getOne(lambdaQueryWrapper) == null) {
return code;
} else {
return this.getCode(storeId);
}
}
Aggregations