Commit 7224b785 authored by licc's avatar licc

新增版本表,获取下载包接口

parent 7ceffae5
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.ShopVersion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 86187
*/
public interface ShopVersionMapper extends BaseMapper<ShopVersion> {
/**
* 添加
*
* @param shopVersion 版本信息
* @return 1
*/
int add(ShopVersion shopVersion);
/**
* 编辑
*
* @param shopVersion 版本信息
* @return 1
*/
int edit(ShopVersion shopVersion);
/**
* 根据类型获取版本信息
*
* @param type 1:ios 2:安卓
* @return
*/
ShopVersion getByType(@Param("type") Integer type);
List<ShopVersion> getList();
}
......@@ -105,26 +105,22 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
* @param map 入参
* @return 结果
*/
int count( Map<String, Object> map);
int count(Map<String, Object> map);
/**
* 获取交易流水列表
*
* @param map 入参
* @return 结果集
*/
List<TradeRecord> getList(Map<String, Object> map);
/**
* 获取版本信息
* @return 版本信息
*/
TradeRecord getVersion();
/**
* 根据类型和用户id,获取用户本月该类型最新数据
* @param userId 用户id
*
* @param userId 用户id
* @param tradeType 类型
* @param yearMonth 时间
* @param yearMonth 时间
* @return 交易记录
*/
TradeRecord getByUserIdAndType(@Param("userId") String userId, @Param("tradeType") Integer tradeType,
......@@ -132,10 +128,11 @@ public interface TradeRecordMapper extends BaseMapper<TradeRecord> {
/**
* 获取本月返佣列表
* @param userId 用户id
*
* @param userId 用户id
* @param yearMonth 时间
* @return 返佣交易记录列表
*/
List<TradeRecord> getRebateList(@Param("userId") String userId,@Param("yearMonth") Date yearMonth);
List<TradeRecord> getRebateList(@Param("userId") String userId, @Param("yearMonth") Date yearMonth);
}
<?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="cn.wisenergy.mapper.ShopVersionMapper">
<resultMap id="versionMap" type="cn.wisenergy.model.app.ShopVersion">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="type" property="type"/>
<result column="url" property="url"/>
<result column="version" property="version"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
shop_version
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
name,type,url,version,create_time,update_time
</sql>
<sql id="vals">
#{name},#{type},#{url},#{version},now(),now()
</sql>
<sql id="updateCondition">
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="url != null">url =#{url},</if>
<if test="version != null">version =#{version},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="name != null">and name = #{name}</if>
<if test="type != null">and type = #{type}</if>
<if test="url != null">and url =#{url}</if>
<if test="version != null">and version =#{version}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.ShopVersion" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.ShopVersion">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<select id="getByType" resultType="cn.wisenergy.model.app.ShopVersion">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where type=#{type}
</select>
<select id="getList" resultType="cn.wisenergy.model.app.ShopVersion">
select
<include refid="cols_all"/>
from
<include refid="table"/>
</select>
</mapper>
\ No newline at end of file
......@@ -92,7 +92,7 @@
<select id="getSixMonthIncome" resultType="cn.wisenergy.model.vo.AccumulatedIncomeVo">
select a.user_id as userId,a.money as income,date_format(a.create_time,'%Y-%m') as yearMonth
FROM trade_record as a right join (SELECT user_id ,trade_type,
FROM trade_record as a right join (SELECT user_id ,trade_type,
date_format(create_time,'%Y-%m'),max(create_time) as time
FROM
<include refid="table"/>
......@@ -215,14 +215,6 @@
limit #{startNum},#{endNum}
</select>
<select id="getVersion" resultType="cn.wisenergy.model.app.TradeRecord">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where trade_type=9
</select>
<select id="getByUserIdAndType" resultType="cn.wisenergy.model.app.TradeRecord">
select
<include refid="cols_all"/>
......
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author 86187
* @ Description: 商城版本实体类
* @ Author : 86187
* @ Date : 2021/3/30 15:59
*/
@Data
@ApiModel("ShopVersion")
public class ShopVersion {
/**
* 主键id
*/
@ApiModelProperty(value = "主键id", name = "id")
private Integer id;
/**
* 名称
*/
@ApiModelProperty(value = "名称", name = "name")
private String name;
/**
* 类型 1:ios 2:安卓
*/
@ApiModelProperty(value = "类型 1:ios 2:安卓", name = "type")
private Integer type;
/**
* 下载路径
*/
@ApiModelProperty(value = "下载路径", name = "url")
private String url;
/**
* 版本
*/
@ApiModelProperty(value = "版本", name = "version")
private String version;
private Date createTime;
private Date updateTime;
}
......@@ -3,9 +3,12 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.ShopVersion;
import cn.wisenergy.model.dto.AccountInfoQuery;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @author 86187
......@@ -32,7 +35,14 @@ public interface AccountService {
* 版本更新
*
* @param version 版本号
* @param type 类型 ios :1 安卓:2
* @return 安装包下载地址
*/
R<String> updateVersion(String version);
R<String> updateVersion(String version,Integer type);
/**
* 获取版本信息
* @return 版本集合
*/
R<List<ShopVersion>> getVersion();
}
......@@ -41,13 +41,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
private AccountMapper accountMapper;
@Autowired
private TradeRecordMapper tradeRecordMapper;
/**
* 测试安卓包路径:https://www.xitiansen.com/upload/app-debug.apk
* 线上安卓包路径:http://app.xitiansen.com/upload/xitiansen.apk
*/
private static final String DOWNLOAD_URL = "https://www.xitiansen.com/upload/app-debug.apk";
private ShopVersionMapper shopVersionMapper;
@Override
public R<AccountInfo> getByUserId(String userId) {
......@@ -79,25 +73,32 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
@Override
public R<String> updateVersion(String version) {
log.info("shop-mall[]AccountServiceImpl[]updateVersion[]input.param.version:" + version);
if (StringUtils.isBlank(version)) {
public R<String> updateVersion(String version, Integer type) {
log.info("shop-mall[]AccountServiceImpl[]updateVersion[]input.param.version,type:" + version, type);
if (StringUtils.isBlank(version) || null == type) {
return R.error("入参不能为空!");
}
//获取版本号信息
TradeRecord tradeRecord = tradeRecordMapper.getVersion();
if (null == tradeRecord) {
ShopVersion shopVersion = shopVersionMapper.getByType(type);
if (null == shopVersion) {
return R.error("版本号信息不存在,请联系管理员!");
}
//版本号不相等
if (!tradeRecord.getTradeNo().equals(version)) {
return R.ok(DOWNLOAD_URL);
if (!shopVersion.getVersion().equals(version)) {
return R.ok(shopVersion.getUrl());
}
return R.error(1, "当前已是最新版本!");
}
@Override
public R<List<ShopVersion>> getVersion() {
log.info("shop-mall[]AccountServiceImpl[]getVersion[]input.param.method");
List<ShopVersion> list = shopVersionMapper.getList();
return R.ok(list);
}
/**
* 分页处理方法
*
......
......@@ -2,12 +2,14 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.ShopVersion;
import cn.wisenergy.model.dto.AccountInfoQuery;
import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.web.common.BaseController;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -15,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author 86187
*/
......@@ -42,13 +46,22 @@ public class AccountController extends BaseController {
@ApiOperation(value = "设置页-版本更新", notes = "设置页-版本更新", httpMethod = "GET")
@ApiImplicitParam(name = "version", value = "版本号", dataType = "string")
@ApiImplicitParams({
@ApiImplicitParam(name = "version", value = "版本号", dataType = "string", required = true),
@ApiImplicitParam(name = "type", value = "类型 ios :1 安卓:2", dataType = "int", required = true)
})
@GetMapping("/account/version")
public R<String> version(String version) {
if(StringUtils.isBlank(version)){
public R<String> version(String version, Integer type) {
if (StringUtils.isBlank(version) || null == type) {
return R.error("入参不能为空!");
}
return accountService.updateVersion(version);
return accountService.updateVersion(version, type);
}
@ApiOperation(value = "ios/安卓包下载信息", notes = "ios/安卓包下载信息", httpMethod = "GET")
@GetMapping("/account/download")
public R<List<ShopVersion>> download() {
return accountService.getVersion();
}
}
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.MonthAward;
import cn.wisenergy.model.app.ProgressPrize;
import cn.wisenergy.model.dto.MonthAwardQuery;
import cn.wisenergy.model.dto.ProgressPrizeQuery;
import cn.wisenergy.service.app.ProgressPrizeService;
import com.github.pagehelper.PageInfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment