xiaoyong931011
2022-09-15 a721f2949a80666751ed7390a9ecba97454f140e
20220902
11 files modified
187 ■■■■ changed files
src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java 4 ●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/IMallElectronicFenceService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java 30 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/IMallElectronicFenceServiceImpl.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/vo/AdminMallTeamLeaderVo.java 2 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/MallTeamLeaderMapper.xml 2 ●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/leader/leaderFenceAdd.html 40 ●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/leader/leaderList.html 31 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/AdminMallTeamLeaderController.java
@@ -144,4 +144,22 @@
        return iAdminMallTeamLeaderService.addFence(adminLeaderAddFenceDto);
    }
    /**
     * 团长--在线
     */
    @GetMapping("startOnline/{id}")
    @ControllerEndpoint(operation = "团长--在线", exceptionMessage = "操作失败")
    public FebsResponse startOnline(@NotNull(message = "{required}") @PathVariable Long id) {
        return iAdminMallTeamLeaderService.startOnline(id);
    }
    /**
     * 团长--离线
     */
    @GetMapping("closeOnline/{id}")
    @ControllerEndpoint(operation = "团长--离线", exceptionMessage = "操作失败")
    public FebsResponse closeOnline(@NotNull(message = "{required}") @PathVariable Long id) {
        return iAdminMallTeamLeaderService.closeOnline(id);
    }
}
src/main/java/cc/mrbird/febs/mall/entity/MallTeamLeader.java
@@ -55,6 +55,8 @@
    private String bonusPercent;
    @TableField(exist = false)
    private int isOk;
    private Integer isOk;
    //在线状态 1:在线 2:离线
    private Integer onlineState;
}
src/main/java/cc/mrbird/febs/mall/service/IAdminMallTeamLeaderService.java
@@ -35,4 +35,8 @@
    FebsResponse closeProfit(Long id);
    FebsResponse addFence(AdminLeaderAddFenceDto adminLeaderAddFenceDto);
    FebsResponse startOnline(Long id);
    FebsResponse closeOnline(Long id);
}
src/main/java/cc/mrbird/febs/mall/service/IMallElectronicFenceService.java
@@ -15,4 +15,6 @@
    String fenceList(String gaodeKey,String serviceId,String fenceIds);
    String fenceDelete(String gaodeKey,String serviceId,String fenceId);
    String fenceToLocation(String gaodeKey,String serviceId,String locationLonglat,String fenceId);
}
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallTeamLeaderServiceImpl.java
@@ -318,4 +318,34 @@
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse startOnline(Long id) {
        MallTeamLeader mallTeamLeader = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallTeamLeader)){
            return new FebsResponse().fail().message("团长信息不存在,刷新重试");
        }
        Integer state = mallTeamLeader.getState();
        if(1!=state){
            return new FebsResponse().fail().message("目前还不是团长,无法操作");
        }
        MallElectronicFence mallElectronicFence = mallElectronicFenceMapper.selectByTeamLeaderCode(mallTeamLeader.getUniqueCode());
        if(ObjectUtil.isEmpty(mallElectronicFence)){
            return new FebsResponse().fail().message("请先设置配送范围");
        }
        mallTeamLeader.setOnlineState(1);
        this.baseMapper.updateById(mallTeamLeader);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse closeOnline(Long id) {
        MallTeamLeader mallTeamLeader = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallTeamLeader)){
            return new FebsResponse().fail().message("团长信息不存在,刷新重试");
        }
        mallTeamLeader.setOnlineState(2);
        this.baseMapper.updateById(mallTeamLeader);
        return new FebsResponse().success();
    }
}
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -76,6 +76,8 @@
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final MallLeaderAchieveMapper mallLeaderAchieveMapper;
    private final IApiMallTeamLeaderService iApiMallTeamLeaderService;
    private final IMallElectronicFenceService iMallElectronicFenceService;
    private final MallElectronicFenceMapper mallElectronicFenceMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -90,6 +92,17 @@
        MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(takeUniqueCode);
        if(ObjectUtil.isEmpty(mallTeamLeader)){
            throw new FebsException("请重新选择团长");
        }
        //订单范围内才允许下单
        MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId());
        MallElectronicFence mallElectronicFence = mallElectronicFenceMapper.selectByTeamLeaderCode(mallTeamLeader.getUniqueCode());
        if(ObjectUtil.isNotEmpty(mallElectronicFence)){
            String inStr = iMallElectronicFenceService.fenceToLocation(mallElectronicFence.getGKey(),
                    mallElectronicFence.getServiceId(), address.getLongitude() + "," + address.getLatitude(), mallElectronicFence.getGid());
            if("1".equals(inStr)){
                throw new FebsException("不在当前团长的配送范围内");
            }
        }
        String orderNo = MallUtils.getOrderNum();
@@ -207,7 +220,6 @@
        }
        orderInfo.setAmount(total);
        MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId());
        orderInfo.setName(address.getName());
        orderInfo.setPhone(address.getPhone());
        orderInfo.setIsHome(addOrderDto.getIsHome());
src/main/java/cc/mrbird/febs/mall/service/impl/IMallElectronicFenceServiceImpl.java
@@ -241,4 +241,44 @@
            return "fail";
        }
    }
    @Override
    public String fenceToLocation(String gaodeKey, String serviceId, String locationLonglat, String fenceId) {
        String url = "https://tsapi.amap.com/v1/track/geofence/status/location";
        HttpPost httpPost = new HttpPost(url);
        Map<String,String> map = new HashMap<>();
        //高德Key
        //用户在高德地图官网申请Web服务API类型Key
        map.put("key",gaodeKey);
        //服务唯一编号
        //sid为猎鹰service唯一编号
        map.put("sid",serviceId);
        //指定坐标
        //格式:x,y
        map.put("location",locationLonglat);
        //围栏的唯一标识
        //支持一次传入多个,以","分割;
        //单次最多支持100个,如超出将只截取前100个作为输入。
        map.put("gfids",fenceId);
        log.info("查询指定坐标与围栏关系"+JSON.toJSONString(map));
        String result = null;
        try {
            result = HttpCurlUtil.sendGetHttp(url, map);
        } catch (IOException e) {
            e.printStackTrace();
        }
        log.info("查询指定坐标与围栏关系"+result);
        cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
        String errCode = maps.get("errcode").toString();
        if("10000".equals(errCode)){
            String dataStr = maps.get("data").toString();
            cn.hutool.json.JSONObject dataResults = JSONUtil.parseObj(dataStr);
            String resultsStr = dataResults.get("results").toString();
            cn.hutool.json.JSONObject resultsStrJson = JSONUtil.parseObj(resultsStr);
            String in = resultsStrJson.get("in").toString();
            return in;
        }else{
            return "fail";
        }
    }
}
src/main/java/cc/mrbird/febs/mall/vo/AdminMallTeamLeaderVo.java
@@ -47,4 +47,6 @@
    private String bonusPercent;
    private String longlatiarr;
    private Integer onlineState;
}
src/main/resources/mapper/modules/MallTeamLeaderMapper.xml
@@ -33,7 +33,7 @@
        ) AS distance
        from mall_team_leader a
        <where>
            a.state = 1
            a.state = 1 and a.online_state = 1
            <if test="record.query != null and record.query != ''">
                and (a.name like CONCAT('%', CONCAT(#{record.query}, '%'))
                    or a.phone like CONCAT('%', CONCAT(#{record.query}, '%'))
src/main/resources/templates/febs/views/modules/leader/leaderFenceAdd.html
@@ -204,27 +204,29 @@
            //配送范围回显
            // var pathPolygon = [];
            let fenceLongLat = leaderInfo.longlatiarr;
            let splitList = [];
            splitList = fenceLongLat.split(';');
            if(splitList.length > 0){
                for(let splitIndex = 0;splitIndex < splitList.length-1;splitIndex++){
                    let splitLngLat = splitList[splitIndex].split(',');
                    console.log(splitLngLat[0]);
                    console.log(splitLngLat[1]);
                    let lngLat = new AMap.LngLat(splitLngLat[0],splitLngLat[1]);
                    pathPolygon.push(lngLat)
            if(fenceLongLat != '' && fenceLongLat != null){
                let splitList = [];
                splitList = fenceLongLat.split(';');
                if(splitList.length > 0){
                    for(let splitIndex = 0;splitIndex < splitList.length-1;splitIndex++){
                        let splitLngLat = splitList[splitIndex].split(',');
                        console.log(splitLngLat[0]);
                        console.log(splitLngLat[1]);
                        let lngLat = new AMap.LngLat(splitLngLat[0],splitLngLat[1]);
                        pathPolygon.push(lngLat)
                    }
                }
                var polygon = new AMap.Polygon({
                    path: pathPolygon,
                    fillColor: '#00B2D5', // 多边形填充颜色
                    fillOpacity : 0.5, // 多边形填充透明度,取值范围 [0,1] ,0表示完全透明,1表示不透明。默认为0.5
                    strokeStyle : 'dashed', // 轮廓线样式,实线:solid,虚线:dashed
                    borderWeight: 2, // 线条宽度,默认为 1
                    strokeColor: 'green', // 线条颜色
                });
                polygonClear = polygon;
                map.add(polygon);
            }
            var polygon = new AMap.Polygon({
                path: pathPolygon,
                fillColor: '#00B2D5', // 多边形填充颜色
                fillOpacity : 0.5, // 多边形填充透明度,取值范围 [0,1] ,0表示完全透明,1表示不透明。默认为0.5
                strokeStyle : 'dashed', // 轮廓线样式,实线:solid,虚线:dashed
                borderWeight: 2, // 线条宽度,默认为 1
                strokeColor: 'green', // 线条颜色
            });
            polygonClear = polygon;
            map.add(polygon);
            form.val("user-addLeaderFence-form", {
                "id": leaderInfo.id,
src/main/resources/templates/febs/views/modules/leader/leaderList.html
@@ -62,6 +62,13 @@
    <a lay-event="edit" shiro:hasPermission="user:update"><i
            class="layui-icon febs-edit-area febs-blue">&#xe7a5;</i></a>
</script>
<script type="text/html" id="onlineStateSwitch">
    {{# if(d.onlineState === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="在线|离线" checked lay-skin="switch" lay-filter="onlineStateSwitch">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="在线|离线" lay-skin="switch" lay-filter="onlineStateSwitch">
    {{# } }}
</script>
<script type="text/html" id="upOrDownSwitch">
    {{# if(d.profitSwitch === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="开启|关闭" checked lay-skin="switch" lay-filter="upOrDownSwitch">
@@ -187,6 +194,7 @@
                    {field: 'addressArea', title: '自提点名称', minWidth: 150,align:'left'},
                    {field: 'detailAddress', title: '自提点地址', minWidth: 150,align:'left'},
                    {field: 'totalProfit', title: '收益', minWidth: 150,align:'left'},
                    {field: 'onlineState', title: '在线状态', templet: '#onlineStateSwitch', minWidth: 100,align:'center'},
                    {field: 'profitSwitch', title: '是否返利', templet: '#upOrDownSwitch', minWidth: 100,align:'center'},
                    {field: 'bonusPercent', title: '返利比例', minWidth: 150,align:'left'},
                    // {field: 'phone', title: '电话', minWidth: 150,align:'left'},
@@ -223,6 +231,29 @@
            });
        }
        form.on('switch(onlineStateSwitch)', function (data) {
            if (data.elem.checked) {
                startOnline(data.value);
            } else {
                closeOnline(data.value);
            }
            $query.click();
        })
        function startOnline(id) {
            febs.get(ctx + 'admin/leader/startOnline/' + id, null, function () {
                febs.alert.success('在线成功');
                $query.click();
            });
        }
        function closeOnline(id) {
            febs.get(ctx + 'admin/leader/closeOnline/' + id, null, function () {
                febs.alert.success('离线成功');
                $query.click();
            });
        }
        form.on('switch(upOrDownSwitch)', function (data) {
            if (data.elem.checked) {
                startProfit(data.value);