| | |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.utils.HttpCurlUtil; |
| | | import cc.mrbird.febs.mall.conversion.MallElectronicFenceConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallTeamLeaderConversion; |
| | | import cc.mrbird.febs.mall.dto.AdminLeaderAddDto; |
| | | import cc.mrbird.febs.mall.dto.AdminLeaderAddFenceDto; |
| | | import cc.mrbird.febs.mall.dto.AdminLeaderUpdateDto; |
| | | import cc.mrbird.febs.mall.dto.ApiApplayLeaderDto; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallLeaderStock; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallTeamLeader; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IAdminMallTeamLeaderService; |
| | | import cc.mrbird.febs.mall.vo.AdminMallActSetVo; |
| | |
| | | import cc.mrbird.febs.mall.vo.AdminSelectListLeaderVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.Consts; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.utils.HttpClientUtils; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | private final MallGoodsMapper mallGoodsMapper; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final MallElectronicFenceMapper mallElectronicFenceMapper; |
| | | |
| | | @Override |
| | | public IPage<AdminMallTeamLeaderVo> getLeaderListInPage(MallTeamLeader mallTeamLeader, QueryRequest request) { |
| | |
| | | this.baseMapper.updateById(mallTeamLeader); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse addFence(AdminLeaderAddFenceDto adminLeaderAddFenceDto) { |
| | | String gdFence = createGDFence(adminLeaderAddFenceDto); |
| | | if("fail".equals(gdFence)){ |
| | | return new FebsResponse().fail().message("高德创建电子围栏失败!"); |
| | | } |
| | | MallElectronicFence mallElectronicFence = MallElectronicFenceConversion.INSTANCE.dtoToEntity(adminLeaderAddFenceDto); |
| | | mallElectronicFence.setDelFlag(1); |
| | | mallElectronicFence.setProhibit(1); |
| | | mallElectronicFence.setGid(gdFence); |
| | | mallElectronicFence.setGaodeKey(adminLeaderAddFenceDto.getGaodeKey()); |
| | | mallElectronicFenceMapper.insert(mallElectronicFence); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | public String createGDFence(AdminLeaderAddFenceDto adminLeaderAddFenceDto){ |
| | | String url = "https://restapi.amap.com/v4/geofence/meta?key="; |
| | | String gaodeKey = adminLeaderAddFenceDto.getGaodeKey(); |
| | | url =url+gaodeKey; |
| | | HttpPost httpPost = new HttpPost(url); |
| | | Map<String,String> map = new HashMap<>(); |
| | | String fenceName = adminLeaderAddFenceDto.getFenceName(); |
| | | map.put("name",fenceName); |
| | | String longlatiarr = adminLeaderAddFenceDto.getLonglatiarr(); |
| | | if(null!=longlatiarr&&!"".equals(longlatiarr)){ |
| | | map.put("points",longlatiarr); |
| | | } |
| | | map.put("enable","true"); |
| | | map.put("valid_time","2054-12-30"); |
| | | map.put("repeat","Mon,Tues,Wed,Thur,Fri,Sat,Sun"); |
| | | //map.put("time","00:00,11:59;13:00,20:59"); |
| | | map.put("desc",fenceName); |
| | | map.put("alert_condition","enter;leave"); |
| | | System.out.println(map); |
| | | String param= JSON.toJSONString(map); |
| | | String result = null; |
| | | try { |
| | | result = HttpCurlUtil.sendPostHttp(url, param); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | System.out.println("==高德返回"+result); |
| | | JSONObject maps = JSONUtil.parseObj(result); |
| | | String errmsg = maps.get("errmsg").toString(); |
| | | String str2 = maps.get("data").toString(); |
| | | JSONObject maps2 = JSONUtil.parseObj(str2); |
| | | String statusGaode = maps2.get("status").toString(); |
| | | String gid=""; |
| | | if(statusGaode.equals("0")){ |
| | | gid = maps2.get("gid").toString(); |
| | | } |
| | | if(null!=gid&&!"".equals(gid)){ |
| | | return gid; |
| | | }else{ |
| | | return "fail"; |
| | | } |
| | | } |
| | | |
| | | } |