xiaoyong931011
2021-11-09 d6778b4c38c3c9dd70da46715efdaaafc366ab5f
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
package com.xzx.gc.order.service;
 
import cn.hutool.core.util.StrUtil;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.entity.AddressInfo;
import com.xzx.gc.entity.OtherUserInfo;
import com.xzx.gc.entity.PartnerGaode;
import com.xzx.gc.model.order.FenceDto;
import com.xzx.gc.order.mapper.AddressMapper;
import com.xzx.gc.order.mapper.PartnerGaodeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
 
import java.util.List;
 
@Service
@Transactional(rollbackFor = Exception.class)
public class PartnerGaodeService {
 
    @Autowired
    private PartnerGaodeMapper partnerGaodeMapper;
 
    @Autowired
    private AddressService addressService;
 
    @Autowired
    private OtherUserService otherUserService;
 
    @Autowired
    private FenceService fenceService;
 
 
 
 
    public PartnerGaode findByTownId(String townId){
        if(StrUtil.isBlank(townId))return null;
        Example example=new Example(PartnerGaode.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("delFlag",Constants.DEL_NOT_FLAG);
        criteria.andEqualTo("townId",townId);
        criteria.andCondition("partner_id!=partner_key");
        return partnerGaodeMapper.selectOneByExample(example);
    }
 
    /**
     * 根据用户id和类型 查询合伙人Id
     * @param userId
     * @param type
     * @return
     */
    public String findPartnerIdByUserId(String userId,int type){
        if(type==0){
            AddressInfo byUserId = addressService.findByUserId(userId);
            if(byUserId!=null){
                String townId=byUserId.getTownshipId();
                FenceDto fence = fenceService.getFence(townId, false, byUserId.getLongitude(), byUserId.getLatitude(), false);
                if(StrUtil.isNotBlank(fence.getFenceId())){
                    return fence.getPartnerId();
                }
            }
        }else if(type==1){
            OtherUserInfo byId = otherUserService.findById(userId);
            return byId.getPartnerId();
        }
        return null;
    }
 
    public String findPartnerIdByAddress(AddressInfo addressInfo){
        FenceDto fence = fenceService.getFence(addressInfo.getTownshipId(), false, addressInfo.getLongitude(), addressInfo.getLatitude(), false);
        if(StrUtil.isNotBlank(fence.getFenceId())){
            return fence.getPartnerId();
        }
        return null;
    }
 
 
    /**
     * 根据合伙人ID查找合伙人列表
     * @param partnerId
     * @return
     */
    public List<PartnerGaode> findByPartnerId(String partnerId){
        PartnerGaode partnerGaode=new PartnerGaode();
        partnerGaode.setDelFlag(Constants.DEL_NOT_FLAG);
        partnerGaode.setPartnerId(partnerId);
        List<PartnerGaode> partnerGaode1 = partnerGaodeMapper.select(partnerGaode);
        return partnerGaode1;
    }
 
 
 
}