xiaoyong931011
2021-11-10 66b02aac92f89c9d5df3e75d6d342634092f0dd4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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.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")
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<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(name,delFlag,1,1,namePx,typePx);
        System.out.println(maps.toString());
 
    }
    @Test
    public void jhyOrderList(){
        QueryJhyOrderListDto model = new QueryJhyOrderListDto();
        List<Integer> 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<QueryJhyOrderListVo> maps = jhyOrderMapper.queryOrderList(model);
        if(CollUtil.isNotEmpty(maps)){
            for(QueryJhyOrderListVo queryJhyOrderListVo : maps){
                Long id = queryJhyOrderListVo.getId();
                List<JhyOrderItemsVo> jhyOrderItemsVos = jhyOrderItemsMapper.selectByOrderId(id);
                queryJhyOrderListVo.setJhyOrderItemsVos(jhyOrderItemsVos);
 
                String orderAddr = queryJhyOrderListVo.getAddress();
                Long userId = queryJhyOrderListVo.getUserId();
                List<AddressInfo> 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());
                        }
                    }
                }
            }
        }
 
    }
 
}