xiaoyong931011
2022-09-22 cf0f93a4c122121b205ab52bb5fc3b3b93682670
src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -5,8 +5,10 @@
import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
import cc.mrbird.febs.common.utils.HttpCurlUtil;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.mall.dto.AdminLeaderAddFenceDto;
import cc.mrbird.febs.mall.dto.ApiLeaderRefundOrderDto;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
@@ -19,6 +21,7 @@
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -197,15 +200,111 @@
    }
    @Autowired
    private IXcxPayService iXcxPayService;
    @Autowired
    private MallGoodsMapper mallGoodsMapper;
    @Autowired
    private IAdminMallTeamLeaderService iAdminMallTeamLeaderService;
    @Test
    public void qrcodeBase64(){
        WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto();
        wxGenerateQrCodeDto.setPage("pages/index/index");
        wxGenerateQrCodeDto.setScene("15");
        FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto);
        String data = febsResponse.get("data").toString();
        System.out.println(data);
//        Integer integer = mallGoodsMapper.upDateStockAndVolumeByGoodsId(35L, 3);
//        System.out.println(integer);
//        WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto();
//        wxGenerateQrCodeDto.setPage("pages/product/details");
//        wxGenerateQrCodeDto.setScene("35");
//        FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto);
//        String data = febsResponse.get("data").toString();
//        System.out.println(data);
//        trackServiceInfo("e024c63342930addc57189c8608cdb01",null);
//        String e024c63342930addc57189c8608cdb01 = trackServiceDel("e024c63342930addc57189c8608cdb01", "792477");
//        System.out.println(e024c63342930addc57189c8608cdb01);
        String ss = fenceDel("95ede7157929f5f6b6c758971be924b1", "795278","795554");
        System.out.println(ss);
    }
    //电子围栏删除
    public String fenceDel(String gaodeKey, String sid,String fenceId) {
        String url = "https://tsapi.amap.com/v1/track/geofence/delete?key="+gaodeKey+"&sid="+sid+"&gfids="+fenceId;
        HttpPost httpPost = new HttpPost(url);
        Map<String,String> map = new HashMap<>();
        map.put("key",gaodeKey);
        map.put("sid",sid);
        map.put("gfids",fenceId);
        String  param= JSON.toJSONString(map);
        String result = null;
        try {
            result = HttpCurlUtil.sendPostHttp(url, param);
        } catch (IOException e) {
            e.printStackTrace();
        }
        cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
        System.out.println(maps);
        String errcode = maps.get("errcode").toString();
        if(!"10000".equals(errcode)){
            return "fail";
        }else{
            return maps.toString();
        }
    }
    //服务删除
    public String trackServiceDel(String gaodeKey, String sid) {
        String url = "https://tsapi.amap.com/v1/track/service/delete?key="+gaodeKey+"&sid="+sid;
        HttpPost httpPost = new HttpPost(url);
        Map<String,String> map = new HashMap<>();
        map.put("key",gaodeKey);
        map.put("sid",sid);
        String  param= JSON.toJSONString(map);
        String result = null;
        try {
            result = HttpCurlUtil.sendPostHttp(url, param);
        } catch (IOException e) {
            e.printStackTrace();
        }
        cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result);
        System.out.println(maps);
        String errcode = maps.get("errcode").toString();
        if(!"10000".equals(errcode)){
            return "fail";
        }else{
            return maps.toString();
        }
//        String str2 = maps.get("data").toString();
//        cn.hutool.json.JSONObject maps2 = JSONUtil.parseObj(str2);
//        String serviceId = maps2.get("sid").toString();
//        if(null!=serviceId&&!"".equals(serviceId)){
//            return serviceId;
//        }else{
//            return "fail";
//        }
    }
    public String trackServiceInfo(String gaodeKey, String serviceName) {
        String url = "https://tsapi.amap.com/v1/track/service/list";
        HttpPost httpPost = new HttpPost(url);
        Map<String,String> map = new HashMap<>();
        //高德Key
        //用户在高德地图官网申请Web服务API类型Key
        map.put("key",gaodeKey);
        System.out.println("==高德返回"+map);
        String result = null;
        try {
            result = HttpCurlUtil.sendGetHttp(url, map);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("==高德返回"+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();
            return resultsStr;
        }else{
            return "fail";
        }
    }
@@ -390,7 +489,6 @@
            String json = JSON.toJSONString(param);
            ByteArrayInputStream inputStream = sendPost(url, json);
            System.out.println(inputStream);
            //这里判断的是返回的图片还是错误信息,一般错误信息不会大于200
            if (inputStream.available() <= 200){
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@@ -400,7 +498,6 @@
                    byteArrayOutputStream.write(buffer,0,i);
                }
                String str = new String(byteArrayOutputStream.toByteArray());
                System.out.println(str);
                //错误信息的格式在官方文档里有
                JSONObject jsonObject = JSONObject.parseObject(str);
                if ("41030".equals(jsonObject.getString("errcode"))){
@@ -414,13 +511,13 @@
            //输出到本地的代码
            FileOutputStream fileOutputStream = new FileOutputStream("D:/123.png");
            int i;
            byte[] buffer = new byte[200];
            byte[] buffer = new byte[10240000];
            while ((i = inputStream.read(buffer)) != -1){
                fileOutputStream.write(buffer,0,i);
            }
            fileOutputStream.flush();
            fileOutputStream.close();
            inputStream.close();
        }catch (Exception e){
        }
@@ -459,6 +556,10 @@
                inputStream.close();
                // 把outStream里的数据写入内存
                byteArrayInputStream = new ByteArrayInputStream(outStream.toByteArray());
                byte[] data = outStream.toByteArray();
                String result = new String(Base64.getEncoder().encode(data));
                result = "data:image/jpeg;base64," + result;
                System.out.println(result);
            }
        } catch (Exception e) {
            e.printStackTrace();