| | |
| | | import cn.lili.common.utils.CurrencyUtil; |
| | | import cn.lili.common.utils.SnowFlake; |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.common.vo.ResultMessage; |
| | | import cn.lili.modules.goods.entity.dos.Goods; |
| | | import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; |
| | | import cn.lili.modules.goods.service.GoodsService; |
| | | import cn.lili.modules.lmk.enums.general.AdminRoleEnum; |
| | | import cn.lili.modules.member.entity.dos.Member; |
| | | import cn.lili.modules.member.entity.dto.MemberAddressDTO; |
| | | import cn.lili.modules.member.mapper.MemberMapper; |
| | | import cn.lili.modules.order.cart.entity.dto.TradeDTO; |
| | | import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; |
| | | import cn.lili.modules.order.order.aop.OrderLogPoint; |
| | |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.rocketmq.spring.core.RocketMQTemplate; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import cn.lili.modules.permission.entity.dos.Role; |
| | | /** |
| | |
| | | |
| | | private static final String ORDER_SN_COLUMN = "order_sn"; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapperMapper; |
| | | /** |
| | | * 延时任务 |
| | | */ |
| | |
| | | private COSUtil cosUtil; |
| | | @Autowired |
| | | private AdminUserService adminUserService; |
| | | @Autowired |
| | | private RoleService roleService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<Object,Object> redisTemplate; |
| | | |
| | | private final static String LOCK_ORDER_NO_MQ="lock_order_no_mq:"; |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void intoDB(TradeDTO tradeDTO) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<OrderSimpleVO> queryByParams(OrderSearchParams orderSearchParams) { |
| | | public IPage<OrderSimpleVO> queryByParams(OrderSearchParams orderSearchParams,Boolean needHide) { |
| | | QueryWrapper queryWrapper = orderSearchParams.queryWrapper(); |
| | | queryWrapper.groupBy("o.id"); |
| | | queryWrapper.orderByDesc("o.id"); |
| | | IPage<OrderSimpleVO> page = this.baseMapper.queryByParams(PageUtil.initPage(orderSearchParams), queryWrapper); |
| | | if (needHide){ |
| | | if (!adminUserService.havePermissionRole(AdminRoleEnum.ORDER_INFO_PERMISSION)){ |
| | | for (OrderSimpleVO vo : page.getRecords()){ |
| | | vo.setConsigneeName(CommonUtil.maskName(vo.getConsigneeName())); |
| | | vo.setConsigneeMobile(CommonUtil.maskMobile(vo.getConsigneeMobile())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!adminUserService.havePermissionRole(AdminRoleEnum.ORDER_INFO_PERMISSION)){ |
| | | for (OrderSimpleVO vo : page.getRecords()){ |
| | | vo.setConsigneeName(CommonUtil.maskName(vo.getConsigneeName())); |
| | | vo.setConsigneeMobile(CommonUtil.maskMobile(vo.getConsigneeMobile())); |
| | | for (OrderSimpleVO vo : page.getRecords()){ |
| | | Member member = memberMapperMapper.selectById(vo.getMemberId()); |
| | | if (member != null){ |
| | | vo.setNickName(member.getNickName()); |
| | | } |
| | | } |
| | | return page; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public String sendMqMessage(String snNo) { |
| | | //限制30秒只能请求一次避免出现重新提交问题 |
| | | Boolean b = redisTemplate.opsForValue().setIfAbsent(LOCK_ORDER_NO_MQ + snNo, snNo,30, TimeUnit.SECONDS); |
| | | if ( Boolean.FALSE.equals(b)){ |
| | | throw new ServiceException("请在30秒后重试"); |
| | | } |
| | | Order order = this.getBySn(snNo); |
| | | if (order == null) { |
| | | throw new ServiceException(ResultCode.ORDER_NOT_EXIST); |
| | | } |
| | | if (!OrderStatusEnum.PAID.name().equals(order.getOrderStatus())) { |
| | | throw new ServiceException("订单状态不是已支付状态"); |
| | | } |
| | | OrderMessage orderMessage = new OrderMessage(); |
| | | //发送订单已付款消息 |
| | | orderMessage.setOrderSn(order.getSn()); |
| | | orderMessage.setPaymentMethod(order.getPaymentMethod()); |
| | | orderMessage.setNewStatus(OrderStatusEnum.PAID); |
| | | this.sendUpdateStatusMessage(orderMessage); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | @OrderLogPoint(description = "'订单['+#orderSn+']取消,原因为:'+#reason", orderSn = "#orderSn") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Order cancel(String orderSn, String reason) { |