package com.xzx.gc; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.xzx.gc.common.constant.Constants; import com.xzx.gc.entity.AddressInfo; import com.xzx.gc.shop.dto.QueryGoodsListDto; import com.xzx.gc.shop.dto.QueryJhyOrderListDto; import com.xzx.gc.shop.mapper.JhyOrderItemsMapper; import com.xzx.gc.shop.mapper.JhyOrderMapper; import com.xzx.gc.shop.mapper.ScoreGoodsMapper; import com.xzx.gc.shop.service.OrderService; import com.xzx.gc.shop.vo.JhyOrderItemsVo; import com.xzx.gc.shop.vo.QueryGoodsListVo; import com.xzx.gc.shop.vo.QueryJhyOrderListVo; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @Slf4j @RunWith(SpringRunner.class) @SpringBootTest(classes = {GcShopApplication.class}) @ActiveProfiles({"dev", "xc"}) public class CodeTest { @Autowired private ScoreGoodsMapper scoreGoodsMapper; @Autowired private JhyOrderMapper jhyOrderMapper; @Autowired private JhyOrderItemsMapper jhyOrderItemsMapper; @Test public void goodsList(){ QueryGoodsListDto model = new QueryGoodsListDto(); String name = model.getName() == null ? "":model.getName(); int delFlag = model.getDelFlag() == null ? 2:model.getDelFlag(); int namePx = model.getNamePx() == null ? 7:model.getNamePx(); int typePx = model.getTypePx() == null ? 2:model.getTypePx(); PageHelper.startPage(model.getPage(), model.getLimit()); List maps = scoreGoodsMapper.queryGoodsList(name,delFlag,1,1,namePx,typePx); System.out.println(maps.toString()); } @Test public void jhyOrderList(){ QueryJhyOrderListDto model = new QueryJhyOrderListDto(); List status = new ArrayList<>(); if(CollUtil.isEmpty(model.getStatus())){ status.add(1); status.add(2); status.add(3); status.add(4); status.add(5); status.add(6); model.setStatus(status); } List maps = jhyOrderMapper.queryOrderList(model); if(CollUtil.isNotEmpty(maps)){ for(QueryJhyOrderListVo queryJhyOrderListVo : maps){ Long id = queryJhyOrderListVo.getId(); List jhyOrderItemsVos = jhyOrderItemsMapper.selectByOrderId(id); queryJhyOrderListVo.setJhyOrderItemsVos(jhyOrderItemsVos); String orderAddr = queryJhyOrderListVo.getAddress(); Long userId = queryJhyOrderListVo.getUserId(); List addressInfos = jhyOrderMapper.selectAddRessInfoByUserId(userId); if(CollUtil.isNotEmpty(addressInfos)){ for(AddressInfo addressInfo : addressInfos){ StringBuffer address = new StringBuffer(); address.append(addressInfo.getDetailAddress()); if (StrUtil.isNotBlank(addressInfo.getTagName())) { address.append(StrUtil.isNotBlank(addressInfo.getHouseName()) ? addressInfo.getHouseName() : ""); if (Constants.ADDRESS_TYPE_HOME.equals(addressInfo.getTagName())) { address.append(StrUtil.isNotBlank(addressInfo.getHouseNumber()) ? addressInfo.getHouseNumber() : ""); address.append(StrUtil.isNotBlank(addressInfo.getUnitName()) ? addressInfo.getUnitName() : ""); } } if (orderAddr.equals(addressInfo.getAddressArea() + address)) { queryJhyOrderListVo.setUnitName(addressInfo.getUnitName()); System.out.println(orderAddr); queryJhyOrderListVo.setHouseNumber(addressInfo.getHouseNumber()); } } } } } } @Autowired private OrderService orderService; @Test public void autoConfirm() { orderService.autoConfirmReceipt(); } }