| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.mall.dto.ApiLeaderOrderConfirmDto; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderItemMapper; |
| | |
| | | import cc.mrbird.febs.rabbit.consumer.AgentConsumer; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | |
| | | |
| | | @Test |
| | | public void confirm(){ |
| | | ApiLeaderOrderConfirmDto apiLeaderOrderConfirmDto = new ApiLeaderOrderConfirmDto(); |
| | | apiLeaderOrderConfirmDto.setIds("90"); |
| | | iApiMallTeamLeaderService.leaderOrderConfirm(apiLeaderOrderConfirmDto); |
| | | // ApiLeaderOrderConfirmDto apiLeaderOrderConfirmDto = new ApiLeaderOrderConfirmDto(); |
| | | // apiLeaderOrderConfirmDto.setIds("90"); |
| | | // iApiMallTeamLeaderService.leaderOrderConfirm(apiLeaderOrderConfirmDto); |
| | | String productNames = getProductNames(38L, 104L); |
| | | System.out.println(productNames); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和订单ID获取所购买商品名称 |
| | | * @return 所含商品名称(多个以","隔开) |
| | | */ |
| | | public String getProductNames(Long memberId, Long orderId) { |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.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; |
| | | } |
| | | } |