Kaynağa Gözat

支付+优惠码

李天标 2 yıl önce
ebeveyn
işleme
8681accb0d

+ 30 - 0
src/main/java/com/szwl/controller/ScheduledService.java

@@ -0,0 +1,30 @@
+package com.szwl.controller;
+
+
+import com.szwl.service.TSzsmWxService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+
+
+@Configuration //1.主要用于标记配置类,兼备Component的效果。
+@Component
+@EnableScheduling // 2.开启定时任务
+public class ScheduledService {
+    @Autowired
+    private TSzsmWxService szsmWxService;
+
+    //在每小时的20分执行一次
+    @Scheduled(cron = "0 20 * * * ?")
+    public void getAccessToken() throws ParseException {
+        szsmWxService.getAccessToken();
+    }
+
+
+
+
+}

+ 62 - 0
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -0,0 +1,62 @@
+package com.szwl.controller;
+
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.feign.bean.SzwlFeign;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TEquipment;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * <p>
+ * 设备表 前端控制器
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-19
+ */
+@Api(value = "/tEquipment", tags = {"设备控制器"})
+@RestController
+@RequestMapping("/tEquipment")
+public class TEquipmentController {
+    @Autowired
+    SzwlFeign szwlFeign;
+    @ApiOperation(value = "获取机器开关机状态")
+    @GetMapping("/onoffStatus")
+    public ResponseModel<?> onoffStatus(String clientId) {
+        if(StringUtils.isEmpty(clientId)){
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
+        if(equipment==null||equipment.getId()==null){
+            return R.fail("设备不存在");
+        }
+//        JSONObject kindData = new JSONObject();
+//        kindData.put("status", equipment.getEqeStatus());
+//        kindData.put("contactName", equipment.getContactName());
+//        kindData.put("contactPhone", equipment.getContactPhone());
+        Map<String,String> map = new HashMap<>();
+        map.put("status", equipment.getEqeStatus().toString());
+        map.put("contactName", equipment.getContactName());
+        map.put("contactPhone", equipment.getContactPhone());
+        map.put("name", equipment.getName());
+        return R.ok(map);
+    }
+
+
+
+}
+

+ 61 - 0
src/main/java/com/szwl/controller/TProductController.java

@@ -0,0 +1,61 @@
+package com.szwl.controller;
+
+
+
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.feign.bean.SzwlFeign;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TProduct;
+
+import com.szwl.model.page.TProductPageable;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
+/**
+ * <p>
+ * 商品价格表 前端控制器
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-23
+ */
+@Api(value = "/tProduct", tags = {"商品"})
+@RestController
+@RequestMapping("/tProduct")
+public class TProductController {
+    @Autowired
+    SzwlFeign szwlFeign;
+
+
+    @ApiOperation(value = "查询商品列表信息")
+    @PostMapping("/selectProducts")
+    public ResponseModel<?> selectProducts(String clientId,int size,int current){
+        if(StringUtils.isEmpty(clientId)){
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
+        if(equipment==null||equipment.getId()==null){
+            return R.fail("设备不存在");
+        }
+        List<TProduct> productList = R.getDataIfSuccess(szwlFeign.selectProductList(clientId, size, current));
+//        TProductPageable productIPage = szwlFeign.selectProductList(clientId, size, current);
+//        IPage<TProduct> productIPage = R.getDataIfSuccess(szwlFeign.selectProductList(clientId, size, current));
+//        List<TProduct> productList = productIPage.getRecords();
+        if(productList==null){
+            return R.fail("设备不存在");
+        }
+        if(productList.size()>0){
+            return R.ok(productList);
+        }else {
+            return R.fail("商品不存在");
+        }
+    }
+
+}
+

+ 144 - 0
src/main/java/com/szwl/controller/TSzsmWxController.java

@@ -0,0 +1,144 @@
+package com.szwl.controller;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TSzsmWx;
+import com.szwl.model.utils.HttpClientSslUtils;
+import com.szwl.model.utils.JsonUtil;
+import com.szwl.model.utils.WeChatUtil;
+import com.szwl.service.TSzsmWxService;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-10-20
+ */
+@RestController
+@RequestMapping("/tSzsmWx")
+public class TSzsmWxController {
+    @Autowired
+    TSzsmWxService szsmWxService;
+    /**
+     * 获取微信openid
+     * @param
+     * @return
+     */
+    @GetMapping("/getOpenid")
+    public ResponseModel<?> getOpenid(String code) {
+        // 微信小程序ID
+        String appid = "wx5071443e63295c29";
+        // 微信小程序秘钥
+        String secret = "191b2fb5ad897c53aff19d2b40d677da";
+
+        // 根据小程序穿过来的code想这个url发送请求
+        String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appid + "&secret=" + secret + "&js_code=" + code + "&grant_type=authorization_code";
+        // 发送请求,返回Json字符串
+        String str = WeChatUtil.httpRequest(url, "GET", null);
+        // 转成Json对象 获取openid
+        JSONObject jsonObject = JSONObject.parseObject(str);
+
+        // 我们需要的openid,在一个小程序中,openid是唯一的
+        String openid = jsonObject.get("openid").toString();
+        //根据openid去创建账户
+        if(StringUtils.isNotEmpty(openid)){
+            //查找是否已注册
+            LambdaQueryWrapper<TSzsmWx> query = Wrappers.lambdaQuery();
+            query.eq(TSzsmWx::getOpenId,openid);
+            List<TSzsmWx> list = szsmWxService.list(query);
+            if(list.size()>0){
+                return R.ok(list.get(0));
+            }else {
+                TSzsmWx wx = new TSzsmWx();
+                wx.setCreateDate(new Date());
+                wx.setModifyDate(new Date());
+                wx.setOpenId(openid);
+                szsmWxService.save(wx);
+                return R.ok(wx);
+            }
+        }
+        return R.ok();
+    }
+    /**
+     * 获取微信openid
+     * @param
+     * @return
+     */
+    @GetMapping("/getPhone")
+    public ResponseModel<?> getPhone(String code,String id) {
+        // 微信小程序ID
+        String appid = "wx5071443e63295c29";
+        // 微信小程序秘钥
+        String secret = "191b2fb5ad897c53aff19d2b40d677da";
+
+//        //1,获取获取token
+//        String token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+secret;
+//        JSONObject token = null;
+//        try {
+//            token = JSON.parseObject(HttpClientSslUtils.doGet(token_url));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        if (token == null) {
+//            return R.ok("获取token失败");
+//        }
+//        String accessToken = token.getString("access_token");
+//        if (StringUtils.isEmpty(accessToken)) {
+//            return R.ok("获取token失败");
+//        }
+        String accessToken =null;
+        TSzsmWx wx = szsmWxService.getById(1);
+        accessToken = wx.getAvatarUrl();
+        //获取phone
+        String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber"
+                + "?access_token=" + accessToken;
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("code", code);
+        String reqJsonStr = JsonUtil.objToString(jsonObject);
+        JSONObject  phoneObject = null;
+        try {
+            phoneObject = JSON.parseObject(HttpClientSslUtils.doPost(url, reqJsonStr));
+            if (phoneObject != null) {
+                String errmsg = phoneObject.getString("errmsg");
+                if(errmsg.equals("ok")){
+                    String phone_info = phoneObject.getString("phone_info");
+                    JSONObject phoneInfo = JSONObject.parseObject(phone_info);
+                    String phoneNumber = phoneInfo.getString("phoneNumber");
+                    if(StringUtils.isNotEmpty(phoneNumber)){
+                        TSzsmWx szsmWx = szsmWxService.getById(id);
+                        szsmWx.setPhone(phoneNumber);
+                        szsmWxService.save(szsmWx);
+                        return R.ok(szsmWx);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if (phoneObject == null) {
+            return R.ok("获取手机号失败");
+        }
+        return R.ok();
+    }
+}
+

+ 56 - 0
src/main/java/com/szwl/feign/bean/SzwlFeign.java

@@ -0,0 +1,56 @@
+package com.szwl.feign.bean;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TAdmin;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TProduct;
+import com.szwl.model.entity.TPromoCode;
+import com.szwl.model.page.TProductPageable;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.Date;
+import java.util.List;
+
+
+@FeignClient(name = "szwl-server")
+public interface SzwlFeign {
+
+    @GetMapping("/test/testGetAdmin")
+    ResponseModel<?> testGetAdmin(@RequestParam String id);
+
+    @GetMapping("/tEquipment/findEquipmentByClientId")
+    ResponseModel<TEquipment> findEquipmentByClientId(@RequestParam String clientId);
+    @GetMapping("/tEquipment/updateByEquipment")
+    ResponseModel<TEquipment> updateByEquipment(@RequestBody TEquipment equipment);
+    @GetMapping("/tPromoCode/getTPromoCode")
+    ResponseModel<IPage<TPromoCode>> getTPromoCode(@RequestParam String code);
+    @GetMapping("/tPromoCode/selectTPromoCode")
+    ResponseModel<TPromoCode> selectTPromoCode(@RequestParam(value = "code") String code, @RequestParam(value = "adminId") String adminId);
+    @GetMapping("/tPromoCode/updatePromoCode")
+    void updatePromoCode(@RequestParam(value = "id") String id, @RequestParam(value = "type") String type);
+    @GetMapping("/tProduct/getProduct")
+    ResponseModel<TProduct> getProduct(@RequestParam(value = "equipmentId") String equipmentId, @RequestParam(value = "productName") String productName);
+    @GetMapping("/tProduct/selectProductList")
+//    TProductPageable selectProductList(@RequestParam(value = "clientId")String clientId, @RequestParam(value = "current") long current, @RequestParam(value = "size") long size);
+    ResponseModel<List<TProduct>> selectProductList(@RequestParam(value = "clientId")String clientId, @RequestParam(value = "current") long current, @RequestParam(value = "size") long size);
+    //    @GetMapping("/tProportion/getProportion")
+//    ResponseModel<TProportion> getProportion(@RequestParam String equipmentId);
+    @GetMapping("/tAdmin/getAdmin")
+    ResponseModel<TAdmin> getAdmin(@RequestParam String id);
+//    @GetMapping("/tJoinpayMch/getMch")
+//    ResponseModel<TJoinpayMch> getMch(@RequestParam String id);
+//    @GetMapping("/tShandeMch/getShandeMch")
+//    ResponseModel<TShandeMch> getShandeMch(@RequestParam String id);
+//    @GetMapping("/tShandeMch/updateShandeMch")
+//    void updateShandeMch(@RequestBody TShandeMch shandeMch);
+//    @GetMapping("/tEquipmentDesc/findEquipmentById")
+//    ResponseModel<TEquipmentDesc> findEquipmentById(@RequestParam Long id);
+//    @GetMapping("/tPrice/getPrice")
+//    ResponseModel<TPrice> getPrice(@RequestParam String name);
+    @GetMapping("/tPromoCode/addPromoCode")
+    void addPromoCode(@RequestParam(value = "adminId") String adminId, @RequestParam(value = "lastUseDate") Date lastUseDate, @RequestParam(value = "number") int number);
+}

+ 16 - 0
src/main/java/com/szwl/mapper/TSzsmWxMapper.java

@@ -0,0 +1,16 @@
+package com.szwl.mapper;
+
+import com.szwl.model.entity.TSzsmWx;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-10-20
+ */
+public interface TSzsmWxMapper extends BaseMapper<TSzsmWx> {
+
+}

+ 22 - 0
src/main/java/com/szwl/mapper/xml/TSzsmWxMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.szwl.mapper.TSzsmWxMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.szwl.model.entity.TSzsmWx">
+        <id column="id" property="id" />
+        <result column="open_id" property="openId" />
+        <result column="create_date" property="createDate" />
+        <result column="modify_date" property="modifyDate" />
+        <result column="phone" property="phone" />
+        <result column="nick_name" property="nickName" />
+        <result column="avatar_url" property="avatarUrl" />
+        <result column="integral" property="integral" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, open_id, create_date, modify_date, phone, nick_name, avatar_url,integral
+    </sql>
+
+</mapper>

+ 176 - 0
src/main/java/com/szwl/model/entity/TEquipment.java

@@ -0,0 +1,176 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 设备表
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TEquipment对象", description="设备表")
+public class TEquipment implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    @ApiModelProperty(value = "用户id;")
+    private Long adminId;
+
+    @ApiModelProperty(value = "用户等级;")
+    private String adminLevel;
+
+    @ApiModelProperty(value = "机器超级管理员admin密码;")
+    private String adminPwd;
+
+    private Long areaId;
+
+    @ApiModelProperty(value = "柜内湿度;")
+    private String cabinetHd;
+
+    @ApiModelProperty(value = "炉头温度;")
+    private String cabinetTm;
+
+    @ApiModelProperty(value = "设备编号;")
+    private String clientId;
+
+    @ApiModelProperty(value = "机器联系人名称;")
+    private String contactName;
+
+    @ApiModelProperty(value = "联系人电话;")
+    private String contactPhone;
+
+    @ApiModelProperty(value = "运营者电话;")
+    private String operationalPhone;
+
+    @ApiModelProperty(value = "机器运营者")
+    private String operationalName;
+
+    @ApiModelProperty(value = "炉头转速;")
+    private String furnaceSp;
+
+    @ApiModelProperty(value = "炉头温度;")
+    private String furnaceTm;
+
+    @ApiModelProperty(value = "机器guest密码;")
+    private String guestPwd;
+
+    @ApiModelProperty(value = "true 代表 强制联网使用 ,false 代表 可不联网使用;")
+    private Boolean isNetWork;
+
+    @ApiModelProperty(value = "机器启用状态,true:启用;")
+    private Boolean isUsing;
+
+    @ApiModelProperty(value = "最近刷新时间;")
+    private Date lastUpdateTime;
+
+    @ApiModelProperty(value = "经度;")
+    private Double latitude;
+
+    @ApiModelProperty(value = "纬度;")
+    private Double longitude;
+
+    @ApiModelProperty(value = "管理系统ID;")
+    private String managerId;
+
+    @ApiModelProperty(value = "客户自命名")
+    private String selfName;
+
+    @ApiModelProperty(value = "通信方式; 1:个推,2:Mq 如果为null,那么用个推")
+    private String channel;
+
+    @ApiModelProperty(value = "机器名称;")
+    private String name;
+
+    @ApiModelProperty(value = "联网方式;")
+    private String netWorkingMode;
+
+    @ApiModelProperty(value = "运营商;")
+    private String operator;
+
+    @ApiModelProperty(value = "支付方式;")
+    private Integer payType;
+
+    @ApiModelProperty(value = "销售总数;")
+    private Integer productTotal;
+
+    @ApiModelProperty(value = "SIM卡卡号;")
+    private String simNo;
+
+    @ApiModelProperty(value = "设备编号自命名;")
+    private String sn;
+
+    @ApiModelProperty(value = "所属商家;")
+    private String adminUserName;
+
+    @ApiModelProperty(value = "公司电话;")
+    private String companyPhone;
+
+    @ApiModelProperty(value = "0:分账方2个,1:分账方3个,3:分账方4个,3:分账方超4个;")
+    private Integer type;
+
+    @ApiModelProperty(value = "地址全名;")
+    private String fullName;
+
+    @ApiModelProperty(value = "最后推送时间;")
+    private Date pushUpdateTime;
+
+    @ApiModelProperty(value = "广告规则id;")
+    private Long timeRuleId;
+
+    @ApiModelProperty(value = "实际上的设备id;")
+    private String gtClientId;
+
+    @ApiModelProperty(value = "设备状态 开机为1,关机为0;")
+    private Integer eqeStatus;
+
+    @ApiModelProperty(value = "锁机状态;")
+    private Boolean isBlocked;
+
+    @ApiModelProperty(value = "短信接收者;")
+    private String messageReceiver;
+
+    @ApiModelProperty(value = "睡眠状态,睡眠为true,不睡眠false;")
+    private Boolean isSleep;
+
+    @ApiModelProperty(value = "音量;")
+    private String volume;
+
+    @ApiModelProperty(value = "远程开关机的时间戳")
+    private String network;
+
+    @ApiModelProperty(value = "PLC版本;")
+    private String plcVersion;
+
+    @ApiModelProperty(value = "棉花糖机器类型,mg320,mg301;")
+    private String equimentType;
+
+    @ApiModelProperty(value = "mg280机器到期时间;")
+    private Date endDate;
+
+    @ApiModelProperty(value = "花型数量;")
+    private String flowers;
+
+    @ApiModelProperty(value = "设备类型,0:棉花糖,1,爆米花")
+    private String machineType;
+
+
+}

+ 62 - 0
src/main/java/com/szwl/model/entity/TProduct.java

@@ -0,0 +1,62 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * <p>
+ * 商品价格表
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-23
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TProduct对象", description="商品价格表")
+@NoArgsConstructor
+@ToString
+public class TProduct implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    @ApiModelProperty(value = "投币价格;")
+    private BigDecimal codePrice;
+
+    @ApiModelProperty(value = "机器id;")
+    private Long equipmentId;
+
+    @ApiModelProperty(value = "产品名称;")
+    private String productName;
+
+    @ApiModelProperty(value = "人名币价格;")
+    private BigDecimal rmbPrice;
+
+    @ApiModelProperty(value = "销售状态;")
+    private Boolean sellStatus;
+
+    @ApiModelProperty(value = "是否显示,null和0:显示,1:不显示")
+    private String showType;
+
+    @ApiModelProperty(value = "编号")
+    private String no;
+
+
+}

+ 62 - 0
src/main/java/com/szwl/model/entity/TPromoCode.java

@@ -0,0 +1,62 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 优惠码列表
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-06-17
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TPromoCode对象", description="优惠码列表")
+public class TPromoCode implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "所属商家;")
+    private String adminId;
+
+    private Date createDate;
+
+    private String userName;
+
+    private Date modifyDate;
+
+    @ApiModelProperty(value = "优惠码编号;")
+    private Long code;
+
+    @ApiModelProperty(value = "是否使用;")
+    private String isUse;
+
+    @ApiModelProperty(value = "使用时间;")
+    private String useDate;
+
+    @ApiModelProperty(value = "被那个机器使用;")
+    private String useBy;
+
+    @ApiModelProperty(value = "到期时间;")
+    private Date lastUseDate;
+
+    @ApiModelProperty(value = "优惠码折扣;")
+    private Float discount;
+
+    @ApiModelProperty(value = "类型,0或null:折扣优惠码;1:抵扣价优惠码")
+    private String type;
+
+
+}

+ 47 - 0
src/main/java/com/szwl/model/entity/TSzsmWx.java

@@ -0,0 +1,47 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-10-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TSzsmWx对象", description="")
+public class TSzsmWx implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String openId;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    private String phone;
+
+    private String nickName;
+
+    private String avatarUrl;
+
+    private BigDecimal integral;
+
+
+}

+ 34 - 0
src/main/java/com/szwl/model/page/TProductPageable.java

@@ -0,0 +1,34 @@
+package com.szwl.model.page;
+
+import com.szwl.model.entity.TProduct;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 商品价格表
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-23
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@NoArgsConstructor
+@ToString
+@Getter
+@Setter
+@Accessors(chain = true)
+public class TProductPageable  {
+
+
+    private List<TProduct> records;
+    private long total;
+    private long size;
+    private long current;
+    private long pages;
+
+
+}

+ 248 - 0
src/main/java/com/szwl/model/utils/HttpClientSslUtils.java

@@ -0,0 +1,248 @@
+package com.szwl.model.utils;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.jboss.logging.MDC;
+import org.springframework.http.HttpStatus;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * HTTP/HTTPS 请求封装: GET / POST
+ * 默认失败重试3次
+ * @author admin
+ */
+@Slf4j
+public class HttpClientSslUtils {
+
+    /**
+     * 默认的字符编码格式
+     */
+    private static final String DEFAULT_CHAR_SET = "UTF-8";
+    /**
+     * 默认连接超时时间 (毫秒)
+     */
+    private static final Integer DEFAULT_CONNECTION_TIME_OUT = 2000;
+    /**
+     * 默认socket超时时间 (毫秒)
+     */
+    private static final Integer DEFAULT_SOCKET_TIME_OUT = 3000;
+
+    /** socketTimeOut上限 */
+    private static final Integer SOCKET_TIME_OUT_UPPER_LIMIT = 10000;
+
+    /** socketTimeOut下限 */
+    private static final Integer SOCKET_TIME_OUT_LOWER_LIMIT = 1000;
+
+    private static CloseableHttpClient getHttpClient() {
+        RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(DEFAULT_SOCKET_TIME_OUT)
+                .setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT).build();
+        return HttpClients.custom().setDefaultRequestConfig(requestConfig)
+                .setRetryHandler(new DefaultHttpRequestRetryHandler()).build();
+    }
+
+    private static CloseableHttpClient getHttpClient(Integer socketTimeOut) {
+        RequestConfig requestConfig =
+                RequestConfig.custom().setSocketTimeout(socketTimeOut).setConnectTimeout(DEFAULT_CONNECTION_TIME_OUT)
+                        .build();
+        return HttpClients.custom().setDefaultRequestConfig(requestConfig)
+                .setRetryHandler(new DefaultHttpRequestRetryHandler()).build();
+    }
+
+    public static String doPost(String url, String requestBody) throws Exception {
+        return doPost(url, requestBody, ContentType.APPLICATION_JSON);
+    }
+
+    public static String doPost(String url, String requestBody, Integer socketTimeOut) throws Exception {
+        return doPost(url, requestBody, ContentType.APPLICATION_JSON, null, socketTimeOut);
+    }
+
+    public static String doPost(String url, String requestBody, ContentType contentType) throws Exception {
+        return doPost(url, requestBody, contentType, null);
+    }
+
+    public static String doPost(String url, String requestBody, List<BasicHeader> headers) throws Exception {
+        return doPost(url, requestBody, ContentType.APPLICATION_JSON, headers);
+    }
+
+    public static String doPost(String url, String requestBody, ContentType contentType, List<BasicHeader> headers)
+            throws Exception {
+        return doPost(url, requestBody, contentType, headers, getHttpClient());
+    }
+
+    public static String doPost(String url, String requestBody, ContentType contentType, List<BasicHeader> headers,
+                                Integer socketTimeOut) throws Exception {
+        if (socketTimeOut < SOCKET_TIME_OUT_LOWER_LIMIT || socketTimeOut > SOCKET_TIME_OUT_UPPER_LIMIT) {
+            log.error("socketTimeOut非法");
+            throw new Exception();
+        }
+        return doPost(url, requestBody, contentType, headers, getHttpClient(socketTimeOut));
+    }
+
+
+    /**
+     * 通用Post远程服务请求
+     * @param url
+     * 	请求url地址
+     * @param requestBody
+     * 	请求体body
+     * @param contentType
+     * 	内容类型
+     * @param headers
+     * 	请求头
+     * @return String 业务自行解析
+     * @throws Exception
+     */
+    public static String doPost(String url, String requestBody, ContentType contentType, List<BasicHeader> headers,
+                                CloseableHttpClient client) throws Exception {
+
+        // 构造http方法,设置请求和传输超时时间,重试3次
+        CloseableHttpResponse response = null;
+        long startTime = System.currentTimeMillis();
+        try {
+            HttpPost post = new HttpPost(url);
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (BasicHeader header : headers) {
+                    post.setHeader(header);
+                }
+            }
+            StringEntity entity =
+                    new StringEntity(requestBody, ContentType.create(contentType.getMimeType(), DEFAULT_CHAR_SET));
+            post.setEntity(entity);
+            response = client.execute(post);
+            if (response.getStatusLine().getStatusCode() != HttpStatus.OK.value()) {
+                log.error("业务请求返回失败:{}", EntityUtils.toString(response.getEntity()));
+                throw new Exception();
+            }
+            String result = EntityUtils.toString(response.getEntity());
+            return result;
+        } finally {
+            releaseResourceAndLog(url, requestBody, response, startTime);
+        }
+    }
+
+    /**
+     * 暂时用于智慧园区业务联调方式
+     * @param url 业务请求url
+     * @param param 业务参数
+     * @return
+     * @throws Exception
+     */
+    public static String doPostWithUrlEncoded(String url,
+                                              Map<String, String> param) throws Exception {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = getHttpClient();
+        CloseableHttpResponse response = null;
+        long startTime = System.currentTimeMillis();
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建参数列表
+            if (param != null) {
+                List<org.apache.http.NameValuePair> paramList = new ArrayList<>();
+                for (String key : param.keySet()) {
+                    paramList.add(new BasicNameValuePair(key, param.get(key)));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList, DEFAULT_CHAR_SET);
+                httpPost.setEntity(entity);
+            }
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            if (response.getStatusLine().getStatusCode() != HttpStatus.OK.value()) {
+                log.error("业务请求返回失败:{}" , EntityUtils.toString(response.getEntity()));
+                throw new Exception();
+            }
+            String resultString = EntityUtils.toString(response.getEntity(), DEFAULT_CHAR_SET);
+            return resultString;
+        } finally {
+            releaseResourceAndLog(url, param == null ? null : param.toString(), response, startTime);
+        }
+    }
+
+    private static void releaseResourceAndLog(String url, String request, CloseableHttpResponse response, long startTime) {
+        if (null != response) {
+            try {
+                response.close();
+                recordInterfaceLog(startTime, url, request);
+            } catch (IOException e) {
+                log.error(e.getMessage());
+            }
+        }
+    }
+
+    public static String doGet(String url) throws Exception {
+        return doGet(url, ContentType.DEFAULT_TEXT);
+    }
+
+    public static String doGet(String url, ContentType contentType) throws Exception {
+        return doGet(url, contentType, null);
+    }
+
+    public static String doGet(String url, List<BasicHeader> headers) throws Exception {
+        return doGet(url, ContentType.DEFAULT_TEXT, headers);
+    }
+
+    /**
+     * 通用Get远程服务请求
+     * @param url
+     * 	请求参数
+     * @param contentType
+     * 	请求参数类型
+     * @param headers
+     * 	请求头可以填充
+     * @return String 业务自行解析数据
+     * @throws Exception
+     */
+    public static String doGet(String url, ContentType contentType, List<BasicHeader> headers) throws Exception {
+        CloseableHttpResponse response = null;
+        long startTime = System.currentTimeMillis();
+        try {
+            CloseableHttpClient client = getHttpClient();
+            HttpGet httpGet = new HttpGet(url);
+            if (!CollectionUtils.isEmpty(headers)) {
+                for (BasicHeader header : headers) {
+                    httpGet.setHeader(header);
+                }
+            }
+            if(contentType != null){
+                httpGet.setHeader("Content-Type", contentType.getMimeType());
+            }
+            response = client.execute(httpGet);
+            if (response.getStatusLine().getStatusCode() != HttpStatus.OK.value()) {
+                log.error("业务请求返回失败:{}", EntityUtils.toString(response.getEntity()));
+                throw new Exception();
+            }
+            String result = EntityUtils.toString(response.getEntity());
+            return result;
+        } finally {
+            releaseResourceAndLog(url, null, response, startTime);
+        }
+    }
+
+    private static void recordInterfaceLog(long startTime, String url, String request) {
+        long endTime = System.currentTimeMillis();
+        long timeCost = endTime - startTime;
+        MDC.put("totalTime", String.valueOf(timeCost));
+        MDC.put("url", url);
+        MDC.put("logType", "third-platform-service");
+        log.info("HttpClientSslUtils 远程请求:{} 参数:{} 耗时:{}ms", url, request, timeCost);
+    }
+}
+

+ 0 - 332
src/main/java/com/szwl/model/utils/HttpClientUtils.java

@@ -1,332 +0,0 @@
-package com.szwl.model.utils;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-import org.apache.log4j.Logger;
-import org.dom4j.Document;
-import org.dom4j.io.SAXReader;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-
-import javax.net.ssl.SSLContext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by study on 6/26/2015 11:30.
- */
-public final class HttpClientUtils {
-    private static Logger logger = Logger.getLogger("HttpClientUtils");
-    public final static String Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
-    public final static String Update_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateOrder";
-//    public final static String Es_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
-    public final static String CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
-//    public final static String Es_CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
-public final static String Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getEquipment";
-    public final static String Update_Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateEquipment";
-    private HttpClientUtils() {
-    }
-
-    /**
-     * post xml
-     *
-     * @param url
-     * @param xml
-     * @return
-     */
-    public static String postXml(String url, String xml) throws IOException {
-        HttpClient client = HttpClientBuilder.create().build();
-        client = WebClientDevWrapper.wrapClient(client);
-        HttpPost post = new HttpPost(url);
-        String response = null;
-        InputStream instream = null;
-        try {
-            StringEntity s = new StringEntity(xml, "UTF-8");
-            s.setContentEncoding("UTF-8");
-            s.setContentType("application/xml");
-            post.setEntity(s);
-            HttpResponse res = null;
-            if (client != null) {
-                res = client.execute(post);
-            }
-            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                HttpEntity entity = res.getEntity();
-                SAXReader reader = new SAXReader();
-                instream = entity.getContent();
-                Document document = reader.read(new InputStreamReader(instream, "utf-8"));
-                response = document.asXML();
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (instream != null) {
-                instream.close();
-            }
-        }
-        return response;
-    }
-
-    /**
-     * post json
-     *
-     * @param url
-     * @param json
-     * @return
-     */
-    public static JSONObject postJson(String url, String json) throws IOException {
-        HttpClient client = HttpClientBuilder.create().build();
-        client = WebClientDevWrapper.wrapClient(client);
-        HttpPost post = new HttpPost(url);
-        JSONObject response = null;
-        InputStream instream = null;
-        try {
-            StringEntity s = new StringEntity(json, "UTF-8");
-            s.setContentEncoding("UTF-8");
-            s.setContentType("application/json");
-            post.setEntity(s);
-            HttpResponse res = null;
-            if (client != null) {
-                res = client.execute(post);
-            }
-            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                HttpEntity entity = res.getEntity();
-                String charset = "utf-8";
-                instream = entity.getContent();
-                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, charset)));
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (instream != null) {
-                instream.close();
-            }
-        }
-        return response;
-    }
-
-
-    /**
-     * java httpClient4.5 post请求
-     */
-    @SuppressWarnings("unchecked")
-    public static String sendPost(String sendMsg, String sendUrl) {
-        HttpPost httpPost = new HttpPost(sendUrl);
-        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
-        CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
-        StringEntity entity;
-        String status = "false";
-        Map<String,Object> mres = new HashMap<String, Object>();
-        try {
-            entity = new StringEntity(sendMsg, "UTF-8"); //解决参数中文乱码问题
-            entity.setContentEncoding("UTF-8");//设置编码格式
-            entity.setContentType("application/json");
-            httpPost.setEntity(entity);
-            // 发起请求
-            HttpResponse httpResponse = closeableHttpClient.execute(httpPost);
-            // 请求结束,返回结果。并解析json。
-            String resData = EntityUtils.toString(httpResponse.getEntity(),"UTF-8");
-            status = resData;
-//            Map map = JSON.parseObject(JSON.toJSONString(resData), Map.class);
-//            mres = (Map<String, Object>) JSON.parseObject(JSON.toJSONString(resData), Map.class);
-//            mres = (Map<String, Object>) JSONObject.toBean(JSONObject.fromObject(resData), Map.class);
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (null != closeableHttpClient) {
-                try {
-                    closeableHttpClient.close();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return status;
-//        return mres;
-    }
-    /**
-     * post 键值对
-     *
-     * @param url
-     * @param data 键值对内容
-     * @return
-     */
-    public static String sentData(String url, String data) {
-        if(!StringUtils.isEmpty(url)&&!StringUtils.isEmpty(data)){
-            String result = sendPost(data, url);
-            return result;
-        }
-        return "400";
-    }
-
-    /**
-     * post 键值对
-     *
-     * @param url
-     * @param data 键值对内容
-     * @return
-     */
-    public static String postKeyValue(String url, List<BasicNameValuePair> data) {
-
-
-        CloseableHttpClient httpClient = getHttpClient();
-        try {
-            HttpPost post = new HttpPost(url);
-
-
-            //url格式编码
-            UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(data, "UTF-8");
-            post.setEntity(uefEntity);
-            CloseableHttpResponse httpResponse = httpClient.execute(post);
-            HttpEntity entity = httpResponse.getEntity();
-            try {
-                if (null != entity) {
-                    String result = EntityUtils.toString(entity);
-                    return result;
-                }
-            } finally {
-                httpResponse.close();
-            }
-
-
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (ClientProtocolException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                closeHttpClient(httpClient);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-        return null;
-    }
-
-
-    /**
-     * get json
-     *
-     * @param url
-     * @return
-     */
-    public static JSONObject get(String url) throws IOException {
-        HttpClient client = HttpClientBuilder.create().build();
-        client = WebClientDevWrapper.wrapClient(client);
-        HttpGet get = new HttpGet(url);
-        JSONObject response = null;
-        InputStream instream = null;
-        try {
-            HttpResponse res = null;
-            if (client != null) {
-                res = client.execute(get);
-            }
-            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                HttpEntity entity = res.getEntity();
-                instream = entity.getContent();
-                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, "utf-8")));
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            if (instream != null) {
-                instream.close();
-            }
-        }
-        return response;
-    }
-
-    private static class WebClientDevWrapper {
-        public static HttpClient wrapClient(HttpClient base) {
-            try {
-                RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
-                ConnectionSocketFactory plainSF = new PlainConnectionSocketFactory();
-                registryBuilder.register("http", plainSF);
-                //指定信任密钥存储对象和连接套接字工厂
-                try {
-                    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
-                    SSLContext sslContext = SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, new AnyTrustStrategy()).build();
-                    LayeredConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-                    registryBuilder.register("https", sslSF);
-                } catch (KeyStoreException e) {
-                    throw new RuntimeException(e);
-                } catch (KeyManagementException e) {
-                    throw new RuntimeException(e);
-                } catch (NoSuchAlgorithmException e) {
-                    throw new RuntimeException(e);
-                }
-                Registry<ConnectionSocketFactory> registry = registryBuilder.build();
-                //设置连接管理器
-                PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry);
-                connManager.setDefaultConnectionConfig(ConnectionConfig.custom().setCharset(Charset.forName("UTF-8")).build());
-                connManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(100000).build());
-                //构建客户端
-                return HttpClientBuilder.create().setConnectionManager(connManager).build();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-
-            return null;
-        }
-
-        private static class AnyTrustStrategy implements TrustStrategy {
-            @Override
-            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
-                return true;
-            }
-        }
-
-
-    }
-
-
-    private static CloseableHttpClient getHttpClient() {
-        return HttpClients.createDefault();
-    }
-
-    private static void closeHttpClient(CloseableHttpClient client) throws IOException {
-        if (client != null) {
-            client.close();
-        }
-    }
-
-}

+ 131 - 0
src/main/java/com/szwl/model/utils/JsonUtil.java

@@ -0,0 +1,131 @@
+package com.szwl.model.utils;
+
+import cn.hutool.core.lang.TypeReference;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+
+import java.text.SimpleDateFormat;
+
+@Slf4j
+public class JsonUtil {
+
+    /**
+     * 定义映射对象
+     */
+    public static ObjectMapper objectMapper = new ObjectMapper();
+
+    /**
+     * 日期格式化
+     */
+    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+    static {
+        //对象的所有字段全部列入
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+        //取消默认转换timestamps形式
+        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+        //忽略空Bean转json的错误
+        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+        //所有的日期格式都统一为以下的样式,即yyyy-MM-dd HH:mm:ss
+        objectMapper.setDateFormat(new SimpleDateFormat(DATE_FORMAT));
+        //忽略 在json字符串中存在,但是在java对象中不存在对应属性的情况。防止错误
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+    }
+
+    /**
+     * string转JsonNode
+     *
+     * @param jsonString
+     * @return com.fasterxml.jackson.databind.JsonNode
+     */
+    public static JsonNode stringToJsonNode(String jsonString) throws JsonProcessingException {
+
+        return objectMapper.readTree(jsonString);
+
+    }
+
+    /**
+     * 对象转json字符串
+     *
+     * @param obj
+     * @param <T>
+     */
+    public static <T> String objToString(T obj) {
+
+        if (obj == null) {
+            return null;
+        }
+        try {
+            return obj instanceof String ? (String) obj : objectMapper.writeValueAsString(obj);
+        } catch (JsonProcessingException e) {
+            log.warn("Parse Object to String error : {}", e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * 对象转格式化的字符串字符串
+     *
+     * @param obj
+     * @param <T>
+     * @return
+     */
+    public static <T> String objToPrettyString(T obj) {
+        if (obj == null) {
+            return null;
+        }
+        try {
+            return obj instanceof String ? (String) obj : objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
+        } catch (JsonProcessingException e) {
+            log.warn("Parse Object to String error : {}", e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * json字符串转对象
+     *
+     * @param jsonString
+     * @param cls
+     * @param <T>
+     */
+    public static <T> T stringToObj(String jsonString, Class<T> cls) {
+        if (StringUtils.isEmpty(jsonString) || cls == null) {
+            return null;
+        }
+        try {
+            return cls.equals(String.class) ? (T) jsonString : objectMapper.readValue(jsonString, cls);
+        } catch (JsonProcessingException e) {
+            log.warn("Parse String to Object error : {}", e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * json字符串转对象(复杂泛型类型)
+     *
+     * @param jsonString
+     * @param typeReference
+     * @param <T>
+     * @return
+     */
+    public static <T> T stringToObj(String jsonString, TypeReference<T> typeReference) {
+        if (StringUtils.isEmpty(jsonString) || typeReference == null) {
+            return null;
+        }
+        try {
+//            return typeReference.getType().equals(String.class) ? (T) jsonString : objectMapper.readValue(jsonString, typeReference);
+            return null;
+        } catch (Exception e) {
+            log.warn("Parse String to Object error : {}", e.getMessage());
+            return null;
+        }
+    }
+}

+ 0 - 136
src/main/java/com/szwl/model/utils/JsonUtils.java

@@ -1,136 +0,0 @@
-/*
- * 
- * 
- * 
- */
-package com.szwl.model.utils;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.gexin.fastjson.JSONObject;
-import com.gexin.fastjson.serializer.SimplePropertyPreFilter;
-import org.springframework.util.Assert;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * Utils - JSON
- */
-public final class JsonUtils {
-
-    /**
-     * ObjectMapper
-     */
-    private static ObjectMapper mapper = new ObjectMapper();
-
-    /**
-     * 不可实例化
-     */
-    private JsonUtils() {
-    }
-
-    /**
-     * 将对象转换为JSON字符串
-     *
-     * @param value 对象
-     * @return JSOn字符串
-     */
-    public static String toJson(Object value) {
-        try {
-            return mapper.writeValueAsString(value);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    /**
-     * 将JSON字符串转换为对象
-     *
-     * @param json      JSON字符串
-     * @param valueType 对象类型
-     * @return 对象
-     */
-    public static <T> T toObject(String json, Class<T> valueType) {
-        Assert.hasText(json);
-        Assert.notNull(valueType);
-        try {
-            return mapper.readValue(json, valueType);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    /**
-     * 将对象转成JSON
-     *
-     * @param object 对象
-     * @param attrs  包含的属性值
-     * @return 对象
-     */
-    public static String toString(Object object, String... attrs) {
-        SimplePropertyPreFilter filter = new SimplePropertyPreFilter(object.getClass(), attrs);
-        return JSONObject.toJSONString(object, filter);
-    }
-
-    /**
-     * 将JSON字符串转换为对象
-     *
-     * @param json          JSON字符串
-     * @param typeReference 对象类型
-     * @return 对象
-     */
-//    public static <T> T toObject(String json, TypeReference<?> typeReference) {
-//        Assert.hasText(json);
-//        Assert.notNull(typeReference);
-//        try {
-//            return mapper.readValue(json, typeReference);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        return null;
-//    }
-
-    /**
-     * 将JSON字符串转换为对象
-     *
-     * @param json     JSON字符串
-     * @param javaType 对象类型
-     * @return 对象
-     */
-    public static <T> T toObject(String json, JavaType javaType) {
-        Assert.hasText(json);
-        Assert.notNull(javaType);
-        try {
-            return mapper.readValue(json, javaType);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    /**
-     * 将对象转换为JSON流
-     *
-     * @param writer writer
-     * @param value  对象
-     */
-    public static void writeValue(Writer writer, Object value) {
-        try {
-            mapper.writeValue(writer, value);
-        } catch (JsonGenerationException e) {
-            e.printStackTrace();
-        } catch (JsonMappingException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-
-}

+ 0 - 293
src/main/java/com/szwl/model/utils/PushUtils.java

@@ -1,293 +0,0 @@
-package com.szwl.model.utils;
-
-import com.gexin.rp.sdk.base.impl.SingleMessage;
-import com.gexin.rp.sdk.base.impl.Target;
-import com.gexin.rp.sdk.base.payload.APNPayload;
-import com.gexin.rp.sdk.exceptions.RequestException;
-import com.gexin.rp.sdk.http.IGtPush;
-import com.gexin.rp.sdk.template.TransmissionTemplate;
-import org.json.JSONObject;
-
-import java.util.List;
-
-/**
- * Created by dinfeng on 2017/12/21
- * 个推工具类
- */
-public class PushUtils {
-
-
-    public final static String appId = "GKa6qa12heALjEXZlAn1U3";
-
-    public final static String appKey = "fLvPjR8hni7VFMkgjh8lx2";
-
-    public final static String masterSecret = "KjxrC6vTLr5wiZu55cCnS8";
-
-    public final static String host = "http://sdk.open.api.igexin.com/apiex.htm";
-
-//    public  static IPushResult rets =null;
-
-    public static String test_clientId = "c69869085580f3b77f2972403fbdd5b3";
-    public static String test_clientId2 = "200cb24ae7af3c4096cc2c46569ed530";
-
-
-    final static IGtPush push = new IGtPush(host, appKey, masterSecret);
-
-//    private static EquipmentService equipmentService;
-//
-//    @Autowired
-//    public PushUtils(EquipmentService equipmentService) {
-//        PushUtils.equipmentService = equipmentService;
-//    }
-//    private static RabbitTemplate rabbitTemplate;
-//
-//    @Autowired
-//    public PushUtils(RabbitTemplate rabbitTemplate) {
-//        PushUtils.rabbitTemplate = rabbitTemplate;
-//    }
-
-    /**
-     * 个推发送信息
-     *
-     * @param clientIds   设备号数组
-     * @param title
-     * @param information 信息
-     * @param json        业务id
-     */
-    public static void push(List<String> clientIds, String title, String information, String json) {
-
-
-        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
-        //推送ios
-        final SingleMessage iMessage = new SingleMessage();
-        iMessage.setOffline(true);
-        // 离线有效时间,单位为毫秒,可选
-        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
-        iMessage.setData(transmissionTemplate);
-        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
-        iMessage.setPushNetWorkType(0);
-
-        //个推
-        for (String clientId : clientIds) {
-            final Target target = new Target();
-            target.setAppId(appId);
-            target.setClientId(clientId);
-
-            try {
-
-                new Thread(new Runnable() {
-//                    IPushResult ret = null;
-                    @Override
-                    public void run() {
-//                        ret = push.pushMessageToSingle(iMessage, target);
-                         push.pushMessageToSingle(iMessage, target);
-//                        rets = ret;
-                    }
-
-
-                }).start();
-
-            } catch (RequestException e) {
-                e.printStackTrace();
-                push.pushMessageToSingle(iMessage, target, e.getRequestId());
-            }
-        }
-    }
-
-
-    /**
-     * 个推发送信息
-     *
-     * @param clientId    设备号数组
-     * @param information 信息
-     * @param json        业务id
-     */
-    public static void push(String clientId, String title, String information, String json) {
-//        String type = "1";
-//        if(StringUtils.isNotEmpty(title)){
-//            type = title;
-//        }
-////        List<Filter> filters = new ArrayList<>();
-////        filters.add(Filter.eq("gtClientId", clientId));
-////        List<Equipment> list = equipmentService.findList(null, filters, null);
-////        if(list.size()>0){
-////            for(Equipment equipment:list){
-////                String channel = equipment.getChannel();
-////                String equimentType = equipment.getEquimentType();
-////                String client = equipment.getClientId();
-////                String substring = client.substring(client.length() - 1);
-////                if(substring.equals("x")){
-////                    break;
-////                }
-////                if(StringUtils.isEmpty(channel)||channel.equals("1")||StringUtils.isEmpty(equimentType)){
-////                    //用个推
-////                    type = "1";
-////                }
-////                if(channel.equals("2")||StringUtils.isNotEmpty(equimentType)){
-////                    //用mq
-////                    type = "2";
-////                    //1 创建消息
-////                    MessageProperties messageProperties = new MessageProperties();
-////                    messageProperties.setContentType("text/plain");
-////                    //设置消息的过期时间,60秒
-//////        messageProperties.setExpiration("60000");
-////                    Message message = new Message(json.getBytes(), messageProperties);
-////
-////                    rabbitTemplate.send(equimentType, client, message);
-////                }
-////            }
-////        }
-//        if(type.equals("2")){
-//            String[] split = information.split(":");
-//            String equimentType = split[0];
-//            String client = split[1];
-//            //1 创建消息
-//            MessageProperties messageProperties = new MessageProperties();
-//            messageProperties.setContentType("text/plain");
-//            //设置消息的过期时间,60秒
-////        messageProperties.setExpiration("60000");
-//            Message message = new Message(json.getBytes(), messageProperties);
-//            rabbitTemplate.convertAndSend(equimentType, client, message);
-////            rabbitTemplate.send(equimentType, client, message);
-//        }
-//
-//        if(type.equals("1")){
-//            TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
-//            //推送ios
-//            final SingleMessage iMessage = new SingleMessage();
-//            iMessage.setOffline(true);
-//            // 离线有效时间,单位为毫秒,可选
-//            iMessage.setOfflineExpireTime(24 * 3600 * 1000);
-//            iMessage.setData(transmissionTemplate);
-//            // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
-//            iMessage.setPushNetWorkType(0);
-//
-//
-//            //个推
-//            final Target target = new Target();
-//            target.setAppId(appId);
-//            target.setClientId(clientId);
-//            try {
-//
-//                new Thread(new Runnable() {
-//
-//                    @Override
-//                    public void run() {
-//                        push.pushMessageToSingle(iMessage, target);
-//                    }
-//
-//
-//                }).start();
-//
-//            } catch (RequestException e) {
-//                e.printStackTrace();
-//                push.pushMessageToSingle(iMessage, target, e.getRequestId());
-//            }
-//        }
-        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
-        //推送ios
-        final SingleMessage iMessage = new SingleMessage();
-        iMessage.setOffline(true);
-        // 离线有效时间,单位为毫秒,可选
-        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
-        iMessage.setData(transmissionTemplate);
-        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
-        iMessage.setPushNetWorkType(0);
-
-
-        //个推
-        final Target target = new Target();
-        target.setAppId(appId);
-        target.setClientId(clientId);
-        try {
-
-            new Thread(new Runnable() {
-
-                @Override
-                public void run() {
-                    push.pushMessageToSingle(iMessage, target);
-                }
-
-
-            }).start();
-
-        } catch (RequestException e) {
-            e.printStackTrace();
-            push.pushMessageToSingle(iMessage, target, e.getRequestId());
-        }
-    }
-
-    /**
-     * 苹果使用透传消息,通过设置payload信息,实现待机时的推送提醒;
-     * 对安卓来说就是没有payload的概念,所以需要去解析透传的消息,把title和body放在透传消息中
-     */
-    private static TransmissionTemplate getTemplate(String title, String msg, String json) {
-        title = title == null ? "" : title;
-        msg = msg == null ? "" : msg;
-        TransmissionTemplate template = new TransmissionTemplate();
-        template.setAppId(appId);
-        template.setAppkey(appKey);
-        template.setTransmissionContent(json);
-        template.setTransmissionType(2);
-        APNPayload payload = new APNPayload();
-        //在已有数字基础上加1显示,设置为-1时,在已有数字上减1显示,设置为数字时,显示指定数字
-        payload.setAutoBadge("+1");
-        payload.setContentAvailable(0);
-        payload.setSound("default");
-        payload.setCategory("$由客户端定义");
-        payload.addCustomMsg("payload",json);//好假
-
-        //字典模式使用APNPayload.DictionaryAlertMsg
-        //payload.setAlertMsg(getDictionaryAlertMsg(msg, title));
-
-        template.setAPNInfo(payload);
-        return template;
-    }
-
-    private static APNPayload.DictionaryAlertMsg getDictionaryAlertMsg(String msg, String title) {
-        APNPayload.DictionaryAlertMsg alertMsg = new APNPayload.DictionaryAlertMsg();
-        alertMsg.setBody(msg);//通知小内容
-        alertMsg.setActionLocKey("ActionLockey");
-        alertMsg.setLocKey("LocKey");
-        alertMsg.addLocArg("loc-args");
-        alertMsg.setLaunchImage("launch-image");
-
-        // iOS8.2以上版本支持
-        alertMsg.setTitle(title);//通知标题
-        alertMsg.setTitleLocKey("");
-        alertMsg.addTitleLocArg("");
-        return alertMsg;
-    }
-
-
-    public static JSONObject buildJson(String kind, String kindData) {
-        JSONObject jsonObject = new JSONObject();
-        if (kind != null) {
-            jsonObject.put("kind", kind);
-            jsonObject.put("kind_data", kindData);
-        }else{
-            jsonObject.put("kind", "");
-            jsonObject.put("kind_data", "");
-        }
-        return jsonObject;
-    }
-    public static JSONObject buildJson(String kind, String kindData,String netTime,String webTime) {
-        JSONObject jsonObject = new JSONObject();
-        if (kind != null) {
-            jsonObject.put("kind", kind);
-            jsonObject.put("kind_data", kindData);
-            jsonObject.put("netTime", netTime);
-            jsonObject.put("webTime", webTime);
-        }else{
-            jsonObject.put("kind", "");
-            jsonObject.put("kind_data", "");
-            jsonObject.put("netTime", "");
-            jsonObject.put("webTime", "");
-        }
-        return jsonObject;
-    }
-
-//    public static void main(String[] args) {
-//        push("71963777bd63e0f0a5b6490f04bf1ae4", "niai", "123", buildJson("editNo", "123456789").toString());
-//    }
-}

+ 44 - 0
src/main/java/com/szwl/model/utils/WeChatUtil.java

@@ -0,0 +1,44 @@
+package com.szwl.model.utils;
+
+import javax.net.ssl.HttpsURLConnection;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.URL;
+
+public class WeChatUtil {
+
+    public static String httpRequest(String requestUrl,String requestMethod,String output){
+        try{
+            URL url = new URL(requestUrl);
+            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
+            connection.setDoOutput(true);
+            connection.setDoInput(true);
+            connection.setUseCaches(false);
+            if(null != output){
+                OutputStream outputStream = connection.getOutputStream();
+                outputStream.write(output.getBytes("utf-8"));
+                outputStream.close();
+            }
+            // 从输入流读取返回内容
+            InputStream inputStream = connection.getInputStream();
+            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
+            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+            String str = null;
+            StringBuffer buffer = new StringBuffer();
+            while ((str = bufferedReader.readLine()) != null){
+                buffer.append(str);
+            }
+            bufferedReader.close();
+            inputStreamReader.close();
+            inputStream.close();
+            inputStream = null;
+            connection.disconnect();
+            return buffer.toString();
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+        return "";
+    }
+}

+ 18 - 0
src/main/java/com/szwl/service/TSzsmWxService.java

@@ -0,0 +1,18 @@
+package com.szwl.service;
+
+import com.szwl.model.entity.TSzsmWx;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-10-20
+ */
+public interface TSzsmWxService extends IService<TSzsmWx> {
+
+    void getAccessToken();
+
+}

+ 49 - 0
src/main/java/com/szwl/service/impl/TSzsmWxServiceImpl.java

@@ -0,0 +1,49 @@
+package com.szwl.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.szwl.model.bo.R;
+import com.szwl.model.entity.TSzsmWx;
+import com.szwl.mapper.TSzsmWxMapper;
+import com.szwl.model.utils.HttpClientSslUtils;
+import com.szwl.service.TSzsmWxService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-10-20
+ */
+@Service
+public class TSzsmWxServiceImpl extends ServiceImpl<TSzsmWxMapper, TSzsmWx> implements TSzsmWxService {
+
+    @Override
+    public void getAccessToken() {
+        // 微信小程序ID
+        String appid = "wx5071443e63295c29";
+        // 微信小程序秘钥
+        String secret = "191b2fb5ad897c53aff19d2b40d677da";
+
+        //1,获取获取token
+        String token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+secret;
+        JSONObject token = null;
+        try {
+            token = JSON.parseObject(HttpClientSslUtils.doGet(token_url));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if (token != null) {
+            String accessToken = token.getString("access_token");
+            if (StringUtils.isNotEmpty(accessToken)) {
+                TSzsmWx wx = getById(1l);
+                wx.setAvatarUrl(accessToken);
+                updateById(wx);
+            }
+        }
+    }
+}

+ 1 - 1
src/test/java/com/szwl/AutoGeneratorTests.java

@@ -39,7 +39,7 @@ class AutoGeneratorTests {
 		//配置数据源
 		DataSourceConfig dataSourceConfig = new DataSourceConfig();
 		dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver")
-				.setUrl("jdbc:mysql://rm-wz995mu26a1479kz0so.mysql.rds.aliyuncs.com:3306/orderdb")
+				.setUrl("jdbc:mysql://rm-wz995mu26a1479kz0so.mysql.rds.aliyuncs.com:3306/orderdb-test")
 				.setUsername("root").setPassword("sunzee@020");
 
 		//策略配置