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;
|
}
|
|
|
|
}
|