shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
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
package com.ishop.merchant.service;
 
import com.ishop.merchant.util.VoUtils;
import com.ishop.model.po.EbProductGuarantee;
import com.ishop.model.po.EbProductGuaranteeGroup;
import com.ishop.model.vo.GuaranteeGroupVo;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.jdbc.service.BaseServiceImpl;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class ProductGuaranteeServiceImpl extends BaseServiceImpl {
 
    /**
     * 根据保障ID集合,查询集合。
     * @param idList
     * @return
     * @date 2023-07-04
     */
    public List<EbProductGuarantee> queryListByIds(List<Integer> idList){
        Map<String, Object> parameter = new HashMap<>(2);
        parameter.put("ids", idList);
        return this.select("select * from eb_product_guarantee where id in (:ids)", parameter, new EbProductGuarantee());
    }
 
    /**
     * 获得商户保障服务列表(分组)
     * @param merId
     * @return
     * @date 2023-06-21
     */
    public List<GuaranteeGroupVo> queryMerchantGroupGuaranteeList(int merId){
        EbProductGuaranteeGroup guaranteeGroup = new EbProductGuaranteeGroup();
        guaranteeGroup.setMerId(merId);
        guaranteeGroup.setIsDel(0);
        List<EbProductGuaranteeGroup> productGuaranteeGroups = this.select(guaranteeGroup);
        if(StringUtils.isEmptyList(productGuaranteeGroups)){
            return new ArrayList(1);
        }
 
        List<Integer> groupIds = new ArrayList<>(8);
        for(EbProductGuaranteeGroup e : productGuaranteeGroups){
            groupIds.add(e.getId());
        }
 
        MapSqlParameterSource parameterSource = new MapSqlParameterSource();
        parameterSource.addValue("groupIds", groupIds);
        List<Map<String, Object>> list = this.queryListObjectWhereIn("select * from eb_merchant_product_guarantee_group where group_id in (:groupIds)", parameterSource);
 
        List<GuaranteeGroupVo> groupVoList = new ArrayList<>(productGuaranteeGroups.size());
        for(EbProductGuaranteeGroup group : productGuaranteeGroups){
            groupVoList.add(VoUtils.transferTo(group));
        }
        if(!StringUtils.isEmptyList(list)){
            for(GuaranteeGroupVo vo : groupVoList){
                int groupId = 0;
                for(Map<String, Object> map : list){
                    groupId = Integer.parseInt(map.get("group_id").toString());
                    if(groupId == vo.getId()){
                        vo.add(VoUtils.acquireMerProdGuaranteeGroup(map));
                    }
                }
            }
        }
        return groupVoList;
    }
 
    public List<EbProductGuarantee> queryProductGuaranteeList(Integer isShow){
        if(isShow == null){
            return this.select("select * from eb_product_guarantee where is_del=0 order by sort desc", new Object[]{}, new EbProductGuarantee());
        } else {
            return this.select("select * from eb_product_guarantee where is_del=0 and is_show=? order by sort desc", new Object[]{isShow}, new EbProductGuarantee());
        }
    }
}