| | |
| | | import cc.mrbird.febs.mall.vo.OrderListVo; |
| | | import cc.mrbird.febs.mall.vo.OrderRefundVo; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.model.OrderStateDto; |
| | | import cc.mrbird.febs.pay.service.IPayService; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.WeixinServiceUtil; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private final IXcxPayService iXcxPayService; |
| | | private final IMallAchieveService mallAchieveService; |
| | | private final MallRefundMapper mallRefundMapper; |
| | | private final MallTeamLeaderMapper mallTeamLeaderMapper; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | orderInfo.setPhone(address.getPhone()); |
| | | orderInfo.setIsHome(addOrderDto.getIsHome()); |
| | | //订单金额大于50,且选择送货上门,订单需要选择地址信息 |
| | | if(total.compareTo(new BigDecimal(50)) > 0 && 1 == addOrderDto.getIsHome()){ |
| | | if(1 == addOrderDto.getIsHome()){ |
| | | if (StrUtil.isBlank(address.getLatitude())||StrUtil.isBlank(address.getLongitude())) { |
| | | throw new FebsException("请添加地址"); |
| | | } |
| | |
| | | orderInfo.setStatus(OrderStatusEnum.CANCEL.getValue()); |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | this.baseMapper.updateById(orderInfo); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和订单ID获取所购买商品名称 |
| | | * @return 所含商品名称(多个以","隔开) |
| | | */ |
| | | public String getProductNames(Long memberId, Long orderId) { |
| | | MallOrderInfo mallOrderInfo = this.baseMapper.selectOrderByMemberIdAndId(memberId, orderId); |
| | | List<MallOrderItem> details = mallOrderInfo.getItems(); |
| | | if (CollectionUtils.isEmpty(details)) { |
| | | return ""; |
| | | } |
| | | StringBuffer productNameBuffer = new StringBuffer(); |
| | | Integer maxLength = 30; |
| | | for (int i = 0; i< details.size(); i++) { |
| | | MallOrderItem mallOrderItem = details.get(i); |
| | | String goodsName = mallOrderItem.getGoodsName(); |
| | | if (goodsName == null) { |
| | | continue; |
| | | } |
| | | if (i == 0 && goodsName.length() > maxLength) { |
| | | productNameBuffer.append(goodsName.substring(0, maxLength) + "..."); |
| | | break; |
| | | } |
| | | if ((productNameBuffer.length() + goodsName.length()) > maxLength) { |
| | | productNameBuffer.append("等"); |
| | | break; |
| | | } |
| | | productNameBuffer.append(goodsName + ","); |
| | | } |
| | | String productNames = productNameBuffer.toString(); |
| | | if (productNames.endsWith(",")) { |
| | | productNames = productNames.substring(0, productNames.length() - 1); |
| | | } |
| | | if (productNames.endsWith(",等")) { |
| | | productNames = productNames.substring(0, productNames.length() - 2) + "等"; |
| | | } |
| | | return productNames; |
| | | } |
| | | |
| | | @Override |
| | |
| | | orderInfo.setTakeCode(takeCode); |
| | | |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | |
| | | |
| | | OrderStateDto orderStateDto = new OrderStateDto(); |
| | | orderStateDto.setOrderNo(orderInfo.getOrderNo()); |
| | | String productNames = getProductNames(orderInfo.getMemberId(), orderInfo.getId()); |
| | | orderStateDto.setGoodsName(StrUtil.isEmpty(productNames)?"商品":productNames); |
| | | orderStateDto.setOrderState("已送达自提点"); |
| | | orderStateDto.setTakeCode(orderInfo.getTakeCode()); |
| | | String takeUniqueCode = orderInfo.getTakeUniqueCode(); |
| | | MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(takeUniqueCode); |
| | | orderStateDto.setAddressArea(mallTeamLeader.getAddressArea()); |
| | | orderStateDto.setOpenId(mallMemberMapper.selectById(orderInfo.getMemberId()).getOpenId()); |
| | | DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WX_TEMPLATE_ID_ONE.getType(), DataDictionaryEnum.WX_TEMPLATE_ID_ONE.getCode()); |
| | | orderStateDto.setTemplateId(dataDictionaryCustom.getValue()); |
| | | // iXcxPayService.pushOrderToAddress(orderStateDto); |
| | | iXcxPayService.uniformMessageSend(orderStateDto); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderInfo", payResultStr); |
| | | map.put("orderNo", orderInfo.getOrderNo()); |