admin
2019-01-12 1078f312802cb233ca52aad4586542cdc11afeed
增加推送的版本控制
5个文件已修改
91 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/AppVersionInfoMapper.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/AppVersionInfoMapper.xml 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5RecommendController.java
@@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -373,7 +374,7 @@
        data.put("title", goods.getTitle());
        if (goods.getImgList() == null)
            goods.setImgList(new ArrayList<>());
        goods.getImgList().add(0, goods.getPictUrl());
        goods.getImgList().add(0, TbImgUtil.getTBSizeImg(goods.getPictUrl(), 300));
        data.put("imgs", goods.getImgList());
        data.put("quanPrice", afterCouponPrice);
        data.put("zkPrice", goods.getZkPrice());
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/AppVersionInfoMapper.java
@@ -38,4 +38,24 @@
    int updateByPrimaryKey(AppVersionInfo record);
    /**
     * 根据平台和最小版本获取版本列表
     *
     * @param platform
     * @param minVersionCode
     * @return
     */
    List<AppVersionInfo> listByPlatformAndMinVersionCode(@Param("platform") String platform,
            @Param("minVersionCode") int minVersionCode);
    /**
     * 根据平台和最大版本号获取版本列表
     *
     * @param platform
     * @param minVersionCode
     * @return
     */
    List<AppVersionInfo> listByPlatformAndMaxVersionCode(@Param("platform") String platform,
            @Param("maxVersionCode") int maxVersionCode);
}
fanli/src/main/java/com/yeshi/fanli/mapping/AppVersionInfoMapper.xml
@@ -13,7 +13,8 @@
        <result column="avcm_updatetime" property="updateTime"
            jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">avcm_id,avcm_platform,avcm_version,avcm_version_code,avcm_createtime,avcm_updatetime</sql>
    <sql id="Base_Column_List">avcm_id,avcm_platform,avcm_version,avcm_version_code,avcm_createtime,avcm_updatetime
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
@@ -39,14 +40,39 @@
        and avcm_version_code=#{versionCode}
    </select>
    <select id="listByPlatformAndMinVersionCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_app_version_code_map where avcm_platform =
        #{platform}
        and avcm_version_code>=#{minVersionCode}
    </select>
    <select id="listByPlatformAndMaxVersionCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_app_version_code_map where avcm_platform =
        #{platform}
        and #{maxVersionCode}> avcm_version_code
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_app_version_code_map where avcm_id = #{id,jdbcType=BIGINT}</delete>
        yeshi_ec_app_version_code_map where avcm_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.AppVersionInfo"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_app_version_code_map
        (avcm_id,avcm_platform,avcm_version,avcm_version_code,avcm_createtime,avcm_updatetime)
        values
        (#{id,jdbcType=BIGINT},#{platform,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},#{versionCode,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
        (#{id,jdbcType=BIGINT},#{platform,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},#{versionCode,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.AppVersionInfo"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_app_version_code_map
@@ -74,7 +100,8 @@
        #{version,jdbcType=VARCHAR},avcm_version_code =
        #{versionCode,jdbcType=INTEGER},avcm_createtime =
        #{createTime,jdbcType=TIMESTAMP},avcm_updatetime =
        #{updateTime,jdbcType=TIMESTAMP} where avcm_id = #{id,jdbcType=BIGINT}</update>
        #{updateTime,jdbcType=TIMESTAMP} where avcm_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.AppVersionInfo">
        update yeshi_ec_app_version_code_map
        <set>
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -181,7 +181,7 @@
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
        iosPushService.pushBaiChuanUrl(uid, title, content, url);
//        iosPushService.pushBaiChuanUrl(uid, title, content, url);
        xmPushService.pushBaiChuanUrl(uid, title, content, url);
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/push/XMPushServiceImpl.java
@@ -1,7 +1,13 @@
package com.yeshi.fanli.service.impl.push;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.AppVersionInfoMapper;
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.user.AccountMessage;
import com.yeshi.fanli.entity.system.SystemZnx;
import com.yeshi.fanli.entity.xinge.MessageInfo;
@@ -16,6 +22,9 @@
@Service
public class XMPushServiceImpl implements XMPushService {
    @Resource
    private AppVersionInfoMapper appVersionInfoMapper;
    @Override
    public void pushGoods(Long uid, Long auctionId, String title, String content) throws PushException {
@@ -155,6 +164,8 @@
        JSONObject json = new JSONObject();
        json.put("url", weexUrl);
        json.put("type", "weex");
        // 设置可推送版本,1.4.8以后的版本可推送
        json.put("app_version", getVersionByMinVersionCode(31));
        MessageInfo info = new MessageInfo();
        info.setTitle(title);
        info.setContent(content);
@@ -179,11 +190,29 @@
        }
    }
    private String getVersionByMinVersionCode(int versionCode) {
        List<AppVersionInfo> list = appVersionInfoMapper
                .listByPlatformAndMinVersionCode(AppVersionInfo.PLATFORM_ANDROID, versionCode);
        String versions = "";
        if (list != null)
            for (AppVersionInfo appVersion : list) {
                versions += appVersion.getVersion() + ",";
            }
        if (versions.endsWith(","))
            versions = versions.substring(0, versions.length() - 1);
        return versions;
    }
    @Override
    public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
        JSONObject json = new JSONObject();
        json.put("url", url);
        json.put("type", "baichuan");
        // 设置可推送版本,1.4.8以后的版本可推送
        json.put("app_version", getVersionByMinVersionCode(31));
        MessageInfo info = new MessageInfo();
        info.setTitle(title);
        info.setContent(content);
@@ -204,7 +233,7 @@
            info.setAlias(uid + "");
            PushUtils.singlePushXiaoMi(info, json, pushRecord);
        }
    }
}