浏览代码

Merge branch 'master' into hcp

hechunping 1 年之前
父节点
当前提交
0f2957b319

+ 19 - 0
device-api-cloud/src/main/java/com/xy/feign/DeviceSimChargeFeign.java

@@ -0,0 +1,19 @@
+package com.xy.feign;
+
+import com.xy.FeignInterceptor;
+import com.xy.consts.ServiceConsts;
+import com.xy.service.DeviceSimChargeService;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * <p>
+ * 设备流量卡充值表 feign
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@FeignClient(value = ServiceConsts.SERVICE_NAME, configuration = FeignInterceptor.class)
+public interface DeviceSimChargeFeign extends DeviceSimChargeService {
+
+}

+ 19 - 0
device-api-cloud/src/main/java/com/xy/feign/DeviceSimFeign.java

@@ -0,0 +1,19 @@
+package com.xy.feign;
+
+import com.xy.FeignInterceptor;
+import com.xy.consts.ServiceConsts;
+import com.xy.service.DeviceSimService;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * <p>
+ * 设备流量卡 feign
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@FeignClient(value = ServiceConsts.SERVICE_NAME, configuration = FeignInterceptor.class)
+public interface DeviceSimFeign extends DeviceSimService {
+
+}

+ 28 - 0
device-api-service-merc-mini/src/main/java/com/xy/controller/DeviceSimController.java

@@ -0,0 +1,28 @@
+package com.xy.controller;
+
+import com.xy.annotate.RestMappingController;
+import com.xy.dto.DeviceSimDto;
+import com.xy.service.DeviceSimServiceImpl;
+import com.xy.utils.MercAuthUtils;
+import com.xy.utils.PageBean;
+import com.xy.utils.R;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+@AllArgsConstructor
+@Api(tags = "小程序-设备流量卡")
+@RestMappingController("merc-mini/device-sim")
+public class DeviceSimController {
+
+    private DeviceSimServiceImpl deviceSimService;
+
+    @PostMapping("page")
+    @ApiOperation("分页查询")
+    public R<PageBean<DeviceSimDto.PageVo>> page(@RequestBody DeviceSimDto.Page page) {
+        return deviceSimService.page(page.setMercId(MercAuthUtils.getMercId()));
+    }
+
+}

+ 50 - 0
device-api-service/src/main/java/com/xy/entity/DeviceSim.java

@@ -0,0 +1,50 @@
+package com.xy.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备流量卡
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="DeviceSim对象", description="设备流量卡")
+public class DeviceSim implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "id")
+    private String id;
+
+    @ApiModelProperty(value = "类型")
+    private Integer type;
+
+    @ApiModelProperty(value = "激活时间")
+    private LocalDateTime activateTime;
+
+    @ApiModelProperty(value = "过期时间")
+    private LocalDateTime timeout;
+
+    @ApiModelProperty(value = "最后续费时间")
+    private LocalDateTime lastRenewalTime;
+
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    private LocalDateTime updateTime;
+
+
+}

+ 62 - 0
device-api-service/src/main/java/com/xy/entity/DeviceSimCharge.java

@@ -0,0 +1,62 @@
+package com.xy.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备流量卡充值表
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="DeviceSimCharge对象", description="设备流量卡充值表")
+public class DeviceSimCharge implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "id")
+    private Long id;
+
+    @ApiModelProperty(value = "订单id")
+    private String orderId;
+
+    @ApiModelProperty(value = "流量卡id")
+    private String simId;
+
+    @ApiModelProperty(value = "商户id")
+    private Long mercId;
+
+    @ApiModelProperty(value = "金额")
+    private Integer money;
+
+    @ApiModelProperty(value = "数量")
+    private Integer size;
+
+    @ApiModelProperty(value = "支付方式")
+    private Integer payType;
+
+    @ApiModelProperty(value = "状态")
+    private Integer status;
+
+    @ApiModelProperty(value = "备注")
+    private String note;
+
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    private LocalDateTime updateTime;
+
+
+}

+ 16 - 0
device-api-service/src/main/java/com/xy/mapper/DeviceSimChargeMapper.java

@@ -0,0 +1,16 @@
+package com.xy.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xy.entity.DeviceSimCharge;
+
+/**
+ * <p>
+ * 设备流量卡充值表 Mapper 接口
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+public interface DeviceSimChargeMapper extends BaseMapper<DeviceSimCharge> {
+
+}

+ 27 - 0
device-api-service/src/main/java/com/xy/mapper/DeviceSimMapper.java

@@ -0,0 +1,27 @@
+package com.xy.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.xy.dto.DeviceSimDto;
+import com.xy.entity.DeviceSim;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 设备流量卡 Mapper 接口
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+public interface DeviceSimMapper extends BaseMapper<DeviceSim> {
+
+    /**
+     * 分页查询
+     *
+     * @param page
+     * @param queryPage
+     * @return
+     */
+    IPage<DeviceSimDto.PageVo> page(IPage page, @Param("queryPage") DeviceSimDto.Page queryPage);
+}

+ 71 - 0
device-api-service/src/main/java/com/xy/mapper/mapper/DeviceSimMapper.xml

@@ -0,0 +1,71 @@
+<?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.xy.mapper.DeviceSimMapper">
+
+    <resultMap id="queryPageMap" type="com.xy.dto.DeviceSimDto$PageVo">
+        <association property="deviceInfo" javaType="com.xy.dto.DeviceInfoDto$Vo">
+            <id column="device_id" property="deviceId"/>
+            <result column="device_name" property="deviceName"/>
+            <result column="lon" property="lon"/>
+            <result column="lat" property="lat"/>
+            <result column="device_type" property="deviceType"/>
+            <result column="merc_device_code" property="mercDeviceCode"/>
+            <result column="merc_id" property="mercId"/>
+            <result column="merc_code" property="mercCode"/>
+            <result column="place_id" property="placeId"/>
+            <result column="place_line_id" property="placeLineId"/>
+            <result column="district_id" property="districtId"/>
+            <result column="active_state" property="activeState"/>
+            <result column="active_time" property="activeTime"/>
+            <result column="busy_state" property="busyState"/>
+            <result column="show_status" property="showStatus"/>
+            <result column="freeze_status" property="freezeStatus"/>
+            <result column="device_img" property="deviceImg"/>
+            <result column="update_time" property="updateTime"/>
+            <result column="merc_name" property="mercName"/>
+            <result column="create_time" property="createTime"/>
+            <association property="deviceStatus" javaType="com.xy.dto.DeviceStatusDto$Vo">
+                <result column="net_state" property="netState"/>
+            </association>
+        </association>
+        <association property="sim" javaType="com.xy.dto.DeviceSimDto$Vo">
+            <id column="id" property="id"/>
+            <result column="type" property="type" />
+            <result column="activate_time" property="activateTime" />
+            <result column="timeout" property="timeout" />
+            <result column="last_renewal_time" property="lastRenewalTime" />
+        </association>
+    </resultMap>
+
+    <select id="page" resultMap="queryPageMap">
+        select di.*,
+        ds.net_state,
+        dsim.id, dsim.type, dsim.activate_time, dsim.timeout, dsim.last_renewal_time
+        from device_info di
+        join device_status ds on (di.device_id = ds.device_id)
+        join device_sysinfo dsys on(di.device_id = dsys.device_id)
+        join device_sim dsim on(dsim.id = dsys.sim_iccid)
+        where
+        1 = 1
+        <if test="queryPage.mercId != null">
+            and di.merc_id = #{queryPage.mercId}
+        </if>
+        <if test="queryPage.deviceId != null">
+            and di.device_id = #{queryPage.deviceId}
+        </if>
+        <if test="queryPage.simId != null and queryPage.simId != ''">
+            and dsim.id = #{queryPage.simId}
+        </if>
+        <if test="queryPage.chargingStatus != null and queryPage.chargingStatus != ''">
+            <!-- 即将过期 -->
+            <if test="queryPage.chargingStatus == 1">
+                and dsim.timeout >= #{queryPage.thisTime} and dsim.timeout &lt;= #{queryPage.theTime}
+            </if>
+            <!-- 已过期 -->
+            <if test="queryPage.chargingStatus == 2">
+                and dsim.timeout &lt;= #{queryPage.thisTime}
+            </if>
+        </if>
+        order by dsim.timeout asc
+    </select>
+</mapper>

+ 24 - 0
device-api-service/src/main/java/com/xy/service/DeviceSimChargeServiceImpl.java

@@ -0,0 +1,24 @@
+package com.xy.service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xy.entity.DeviceSimCharge;
+import com.xy.mapper.DeviceSimChargeMapper;
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * <p>
+ * 设备流量卡充值表 服务实现类
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@Service
+@AllArgsConstructor
+@Api(tags = "设备流量卡充值表")
+public class DeviceSimChargeServiceImpl extends ServiceImpl<DeviceSimChargeMapper, DeviceSimCharge> implements DeviceSimChargeService {
+
+}

+ 241 - 0
device-api-service/src/main/java/com/xy/service/DeviceSimServiceImpl.java

@@ -0,0 +1,241 @@
+package com.xy.service;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.read.listener.ReadListener;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.yitter.idgen.YitIdHelper;
+import com.xy.collections.list.JArrayList;
+import com.xy.collections.list.JList;
+import com.xy.collections.map.JMap;
+import com.xy.config.DeviceThreadPoolConfig;
+import com.xy.device.EnumSimConfig;
+import com.xy.dto.DeviceSimDto;
+import com.xy.entity.DeviceSim;
+import com.xy.entity.DeviceSimCharge;
+import com.xy.entity.SysDictRedis;
+import com.xy.mapper.DeviceSimMapper;
+import com.xy.utils.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static com.xy.utils.PlusBeans.toIPage;
+import static com.xy.utils.PlusBeans.toPageBean;
+
+
+/**
+ * <p>
+ * 设备流量卡 服务实现类
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@Service
+@AllArgsConstructor
+@Api(tags = "设备流量卡")
+public class DeviceSimServiceImpl extends ServiceImpl<DeviceSimMapper, DeviceSim> implements DeviceSimService {
+
+    private DeviceSimChargeServiceImpl deviceSimChargeService;
+
+    @Override
+    @ApiOperation("购买")
+    public R pay(DeviceSimDto.Pay pay) {
+        LocalDateTime now = LocalDateTime.now();
+        List<DeviceSimDto.Pay.DeviceSimCharge> deviceSimCharges = pay.getDeviceSimCharges();
+        List<DeviceSimCharge> deviceSimChargess = new ArrayList<>(deviceSimCharges.size());
+        deviceSimCharges.forEach(deviceSimCharge -> {
+            DeviceSimCharge deviceSimChargeInfo = new DeviceSimCharge()
+                    .setId(YitIdHelper.nextId())
+                    .setOrderId(pay.getOrderId())
+                    .setSimId(deviceSimCharge.getSimId())
+                    .setMercId(pay.getMercId())
+                    .setMoney(deviceSimCharge.getMoney())
+                    .setSize(deviceSimCharge.getSize())
+                    .setPayType(pay.getPayType())
+                    .setNote(pay.getNote())
+                    .setCreateTime(now)
+                    .setUpdateTime(now);
+            deviceSimChargess.add(deviceSimChargeInfo);
+        });
+        deviceSimChargeService.saveBatch(deviceSimChargess);
+        return R.ok();
+    }
+
+    @Override
+    @ApiOperation("购买回调")
+    public R payNotice(DeviceSimDto.PayNotice payNotice) {
+        //查询设备流量卡充值表
+        List<DeviceSimCharge> list = deviceSimChargeService.list(new LambdaQueryWrapper<DeviceSimCharge>().eq(DeviceSimCharge::getOrderId, payNotice.getOrderId()));
+        if (!Emptys.check(list)) {
+            return R.ok();
+        }
+        //查询设备流量卡
+        JList<DeviceSimCharge> deviceSimCharges = new JArrayList<>(list);
+        JMap<String, DeviceSimCharge> deviceSimChargesJMaps = deviceSimCharges.toMap(DeviceSimCharge::getSimId).cover();
+        List<DeviceSim> deviceSims = listByIds(deviceSimCharges.getProperty(DeviceSimCharge::getSimId));
+        //循环处理
+        LocalDateTime now = LocalDateTime.now();
+        deviceSims.forEach(deviceSim -> {
+            DeviceSimCharge deviceSimCharge = deviceSimChargesJMaps.get(deviceSim.getId());
+            String newTimeout = deviceSimCharge.getPayType() == 100 ? DataTime.getStringAround(0, 0, deviceSimCharge.getSize(), 0, 0, 0)
+                    : DataTime.getStringAround(deviceSimCharge.getSize(), 0, 0, 0, 0, 0);
+            long d = DataTime.diff(now, deviceSim.getTimeout(), "d");
+            if (d > 0) {
+                newTimeout = DataTime.getStringAround(0, 0, (int) d, 0, 0, 0, newTimeout);
+            }
+            deviceSim.setTimeout(DataTime.toLocal(newTimeout))
+                    .setLastRenewalTime(now)
+                    .setUpdateTime(now);
+        });
+        updateBatchById(deviceSims);
+        return R.ok();
+    }
+
+    @PostMapping("page")
+    @ApiOperation("分页查询")
+    public R<PageBean<DeviceSimDto.PageVo>> page(@RequestBody DeviceSimDto.Page page) {
+        Map<String, SysDictRedis> simConfig = SysDictUtils.get(EnumSimConfig.Code.CODE.getCode());
+        Integer value = Integer.valueOf(simConfig.get(EnumSimConfig.N_200.getCode()).getValue());
+        String theTime = DataTime.getStringAround(0, 0, value, 0, 0, 0);
+        page.setThisTime(LocalDateTime.now()).setTheTime(DataTime.toLocal(theTime));
+        IPage<DeviceSimDto.PageVo> iPage = baseMapper.page(toIPage(page.getPage()), page);
+        List<DeviceSimDto.PageVo> records = iPage.getRecords();
+        if (Emptys.check(records)) {
+            String name = simConfig.get(EnumSimConfig.name.getCode()).getValue();
+            Integer money = Integer.valueOf(simConfig.get(EnumSimConfig.money.getCode()).getValue());
+            records.forEach(record -> {
+                //封装过期状态说明
+                String timeoutStatus;
+                DeviceSimDto.Vo sim = record.getSim();
+                LocalDateTime timeout = sim.getTimeout();
+                long s = DataTime.diff(page.getThisTime(), timeout, "s");
+                if (s <= 0) {
+                    timeoutStatus = "欠费(" + (~(s / 86400 - 1)) + "天)";
+                } else {
+                    timeoutStatus = s <= value * 86400 ? "即将到期(" + s / 86400 + "天)" : "正常(" + s / 86400 + "天)";
+                }
+                record.getSim().setTimeoutStatus(timeoutStatus);
+                record.setChargingName(name).setChargingMoney(money);
+            });
+        }
+        return R.ok(toPageBean(iPage));
+    }
+
+    @SneakyThrows
+    @ApiOperation("下载流量卡号模板")
+    @PostMapping("downloadSimTemplet")
+    public void downloadSnTemplet(HttpServletResponse response) {
+        InputStream inputStream = IoUtils.inputStream("sim_templet.xlsx").get();
+        response.setHeader("Content-Disposition", "attachment; filename=" + "sim_templet.xlsx");
+        response.setContentType("application/xlsx");
+        byte[] buffer = new byte[1024];
+        int bytesRead;
+        OutputStream outputStream = response.getOutputStream();
+        while ((bytesRead = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, bytesRead);
+        }
+    }
+
+    @ApiOperation("导入流量卡号数据")
+    @PostMapping("uploadSim")
+    public R uploadSim(@RequestParam("file") MultipartFile file) {
+        ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, 1)
+                .execute(() -> {
+                    try {
+                        EasyExcel.read(file.getInputStream(), UploadSim.class, new UploadSimListener(this)).sheet().doRead();
+                    } catch (IOException e) {
+                        log.error("", e);
+                    }
+                });
+        return R.ok();
+    }
+
+    @Slf4j
+    @RequiredArgsConstructor
+    public static class UploadSimListener implements ReadListener<UploadSim> {
+
+        private final DeviceSimServiceImpl deviceSimService;
+
+        private JList<UploadSim> sims = new JArrayList<>();
+
+        /**
+         * 这个每一条数据解析都会来调用
+         *
+         * @param data    one row value. Is is same as {@link AnalysisContext#readRowHolder()}
+         * @param context
+         */
+        @Override
+        public void invoke(UploadSim data, AnalysisContext context) {
+            sims.add(data);
+        }
+
+        /**
+         * 所有数据解析完成了 都会来调用
+         *
+         * @param context
+         */
+        @Override
+        public void doAfterAllAnalysed(AnalysisContext context) {
+            List<DeviceSim> deviceSims = deviceSimService.listByIds(sims.getProperty(UploadSim::getSimId));
+            JMap<String, DeviceSim> deviceSimsJMaps = new JArrayList<>(deviceSims).toMap(DeviceSim::getId).cover();
+            LocalDateTime now = LocalDateTime.now();
+            JList<DeviceSim> saveDeviceSims = new JArrayList<>();
+            sims.forEach(uploadSim -> {
+                if (deviceSimsJMaps.containsKey(uploadSim.getSimId())) {
+                    return;
+                }
+                DeviceSim deviceSim = new DeviceSim()
+                        .setId(uploadSim.getSimId())
+                        .setActivateTime(DataTime.toLocal(uploadSim.getActivateTime()))
+                        .setTimeout(DataTime.toLocal(uploadSim.getTimeout()))
+                        .setCreateTime(now)
+                        .setUpdateTime(now);
+                deviceSim.setLastRenewalTime(deviceSim.getActivateTime());
+                saveDeviceSims.add(deviceSim);
+            });
+            deviceSimService.saveBatch(saveDeviceSims);
+        }
+    }
+
+    @Data
+    public static class UploadSim {
+
+        /**
+         * 流量卡号
+         */
+        private String simId;
+
+        /**
+         * 激活时间
+         */
+        private String activateTime;
+
+        /**
+         * 过期时间
+         */
+        private String timeout;
+
+    }
+}

+ 62 - 0
device-api/src/main/java/com/xy/dto/DeviceSimChargeDto.java

@@ -0,0 +1,62 @@
+package com.xy.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备流量卡充值表
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+public class DeviceSimChargeDto {
+
+    @Data
+    @Accessors(chain = true)
+    public static class Vo {
+
+        @ApiModelProperty(value = "id")
+        private Long id;
+
+        @ApiModelProperty(value = "订单id")
+        private String orderId;
+
+        @ApiModelProperty(value = "流量卡id")
+        private String simId;
+
+        @ApiModelProperty(value = "商户id")
+        private Long mercId;
+
+        @ApiModelProperty(value = "金额")
+        private Integer money;
+
+        @ApiModelProperty(value = "数量")
+        private Integer size;
+
+        @ApiModelProperty(value = "支付方式")
+        private Integer payType;
+
+        @ApiModelProperty(value = "状态")
+        private Integer status;
+
+        @ApiModelProperty(value = "备注")
+        private String note;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+
+    }
+
+}

+ 148 - 0
device-api/src/main/java/com/xy/dto/DeviceSimDto.java

@@ -0,0 +1,148 @@
+package com.xy.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.xy.utils.PageBean;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 设备流量卡
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+public class DeviceSimDto {
+
+    @Data
+    @Accessors(chain = true)
+    public static class Pay {
+
+        @NotBlank(message = "orderId不能为空")
+        @ApiModelProperty("订单号")
+        private String orderId;
+
+        @NotNull(message = "mercId不能为空")
+        @ApiModelProperty(value = "商户id")
+        private Long mercId;
+
+        @NotEmpty(message = "deviceSimCharges不能为空")
+        @ApiModelProperty("续费信息")
+        private List<DeviceSimCharge> deviceSimCharges;
+
+        @NotNull(message = "payType不能为空")
+        @ApiModelProperty(value = "支付类型 2=支付宝 3=微信 100=赠送")
+        private Integer payType;
+
+        @ApiModelProperty(value = "备注")
+        private String note;
+
+        @Data
+        @Accessors(chain = true)
+        public static class DeviceSimCharge {
+
+            @ApiModelProperty("流量卡id")
+            private String simId;
+
+            @ApiModelProperty("购买数/赠送数 单位:年/天")
+            private Integer size;
+
+            @ApiModelProperty("金额")
+            private Integer money;
+        }
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class PayNotice {
+
+        @NotBlank(message = "orderId不能为空")
+        private String orderId;
+
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Page {
+
+        @ApiModelProperty("分页对象")
+        private PageBean page;
+
+        @ApiModelProperty("流量卡id")
+        private String simId;
+
+        @ApiModelProperty("设备id")
+        private Long deviceId;
+
+        @ApiModelProperty("商户id")
+        private Long mercId;
+
+        @ApiModelProperty("状态类型 字典=device_charging_query_type")
+        private Integer chargingStatus;
+
+        @ApiModelProperty(hidden = true)
+        private LocalDateTime thisTime;
+
+        @ApiModelProperty(hidden = true)
+        private LocalDateTime theTime;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class Vo {
+
+        @ApiModelProperty(value = "id")
+        private String id;
+
+        @ApiModelProperty(value = "类型")
+        private Integer type;
+
+        @ApiModelProperty(value = "激活时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime activateTime;
+
+        @ApiModelProperty(value = "过期时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime timeout;
+
+        @ApiModelProperty(value = "最后续费时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime lastRenewalTime;
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
+        @ApiModelProperty(value = "更新时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime updateTime;
+
+        @ApiModelProperty(value = "过期状态说明")
+        private String timeoutStatus;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class PageVo {
+
+        @ApiModelProperty(value = "流量卡信息")
+        private Vo sim;
+
+        @ApiModelProperty(value = "设备信息")
+        private DeviceInfoDto.Vo deviceInfo;
+
+        @ApiModelProperty(value = "计费标准金额/年")
+        private Integer chargingMoney;
+
+        @ApiModelProperty(value = "计费标准说明")
+        private String chargingName;
+    }
+}

+ 16 - 0
device-api/src/main/java/com/xy/service/DeviceSimChargeService.java

@@ -0,0 +1,16 @@
+package com.xy.service;
+
+import com.xy.annotate.RestMappingController;
+
+/**
+ * <p>
+ * 设备流量卡充值表 服务类
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@RestMappingController("/device-sim-charge")
+public interface DeviceSimChargeService {
+
+}

+ 38 - 0
device-api/src/main/java/com/xy/service/DeviceSimService.java

@@ -0,0 +1,38 @@
+package com.xy.service;
+
+import com.xy.annotate.RestMappingController;
+import com.xy.dto.DeviceSimDto;
+import com.xy.utils.R;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * <p>
+ * 设备流量卡 服务类
+ * </p>
+ *
+ * @author lijin
+ * @since 2023-10-16
+ */
+@RestMappingController("/device-sim")
+public interface DeviceSimService {
+
+    /**
+     * 购买
+     *
+     * @param pay
+     * @return
+     */
+    @PostMapping("pay")
+    R pay(@RequestBody @Validated DeviceSimDto.Pay pay);
+
+    /**
+     * 购买回调
+     *
+     * @param payNotice
+     * @return
+     */
+    @PostMapping("payNotice")
+    R payNotice(@RequestBody @Validated DeviceSimDto.PayNotice payNotice);
+}

二进制
device-start/src/main/resources/sim_templet.xlsx