| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getTrackAccuracyRate")
|
| | | public void getTrackAccuracyRate(String callback, Integer dateType, String year, String startTime, String endTime,
|
| | | public void getTrackAccuracyRate(String callback, Integer dateType, String year, String startTime, String endTime,int sourceType,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | |
| | | JSONArray line_list = new JSONArray();
|
| | |
|
| | | List<Map<String, Object>> list = commonOrderCountService.getTrackAccuracyRate(dateType, year, startTime,
|
| | | endTime);
|
| | | endTime,sourceType);
|
| | |
|
| | | JSONObject innerList = new JSONObject();
|
| | | innerList.put("name", "总计");
|
| | |
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | Matcher matcher = p.matcher(text);
|
| | | if (!matcher.find()) {// 不包含链接
|
| | | String pattern = "^[A-Za-z0-9-]+$";
|
| | | if (Pattern.matches(pattern, text)) {
|
| | | if (Pattern.matches(pattern, text.replace(" ", ""))) {//删除空格
|
| | | out.println(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | |
| | | package com.yeshi.fanli.dao.mybatis.jd; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.jd.JDOrderItem; |
| | |
| | | |
| | | /** |
| | | * 根据订单号查询 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | List<JDOrderItem> listByOrderId(Long orderId); |
| | | |
| | | /** |
| | | * 统计所有订单 |
| | | * |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countOrderNumber(@Param("dateType") Integer dateType, @Param("year") String year, |
| | | @Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countOrderNumber( @Param("dateType") Integer dateType, @Param("year") String year, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime,@Param("sourceType") int sourceType); |
| | | |
| | | |
| | | /** |
| | |
| | | package com.yeshi.fanli.dao.mybatis.pdd; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | PDDOrder selectByOrderSN(String orderSn); |
| | | |
| | | /** |
| | | * 数量统计 |
| | | * @param dateType |
| | | * @param year |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countOrderNumber(@Param("dateType") Integer dateType, @Param("year") String year, |
| | | @Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.taobao;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.mongodb.BasicDBObject;
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
|
| | | @Repository
|
| | | public class TaoBaoGoodsUpdateDao extends MongodbBaseDao<TaoBaoGoodsBrief> {
|
| | |
|
| | | /**
|
| | | * 根据商品ID删除
|
| | | * |
| | | * @param auctionid
|
| | | */
|
| | | public void deleteByAuctionId(Long auctionid) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("auctionId").is(auctionid);
|
| | | query.addCriteria(ca);
|
| | | mongoTemplate.remove(query, TaoBaoGoodsBrief.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据商品ID获取
|
| | | * |
| | | * @param auctionid
|
| | | * @return
|
| | | */
|
| | | public TaoBaoGoodsBrief selectByAuctionId(Long auctionid) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("auctionId").is(auctionid);
|
| | | query.addCriteria(ca);
|
| | | return mongoTemplate.findOne(query, TaoBaoGoodsBrief.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 批量查询
|
| | | * |
| | | * @param auctionIds
|
| | | * @return
|
| | | */
|
| | | public List<TaoBaoGoodsBrief> listByAuctionIds(List<Long> auctionIds) {
|
| | | if (auctionIds == null || auctionIds.size() == 0)
|
| | | return null;
|
| | | Query query = new Query();
|
| | | Criteria ca = new Criteria();
|
| | | Criteria[] cas = new Criteria[auctionIds.size()];
|
| | | for (int i = 0; i < auctionIds.size(); i++) {
|
| | | cas[i] = Criteria.where("auctionId").is(auctionIds.get(i));
|
| | | }
|
| | | query.addCriteria(ca.orOperator(cas));
|
| | | return mongoTemplate.find(query, TaoBaoGoodsBrief.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询删除数据
|
| | | * |
| | | * @param date
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public int listAndRemoveByMaxUpdateTime(Date date, int start, int count) {
|
| | | BasicDBObject fieldsObject = new BasicDBObject();
|
| | | fieldsObject.put("auctionId", 1);
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("updatetime").lt(date);
|
| | | query.skip(start);
|
| | | query.limit(count);
|
| | | query.addCriteria(ca);
|
| | | List<TaoBaoGoodsBrief> goodsList = mongoTemplate.findAllAndRemove(query, TaoBaoGoodsBrief.class);
|
| | | return goodsList.size();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据最大更新时间获取数据条数
|
| | | * |
| | | * @param date
|
| | | * @return
|
| | | */
|
| | | public long countByMaxUpdateTime(Date date) {
|
| | | Query query = new Query();
|
| | | Criteria ca = Criteria.where("updatetime").lt(date);
|
| | | query.addCriteria(ca);
|
| | | return mongoTemplate.count(query, TaoBaoGoodsBrief.class);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | |
|
| | | // 1个小时更新一次
|
| | | @Scheduled(cron = "0 0 0/1 * * ? ")
|
| | | public void doSyncJob() {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 每天早上同步一次
|
| | | @Scheduled(cron = "0 0 6 * * ? ")
|
| | | // 每天早晚同步一次
|
| | | @Scheduled(cron = "0 0 6,18 * * ? ")
|
| | | public void doSyncJobNew() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | |
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | daTaoKeGoodsDetailV2Service.updateNewGoods();
|
| | | daTaoKeGoodsDetailV2Service.updateNewGoods();// 获取新上架的商品
|
| | | }
|
| | | }).start();
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 每天的8点,11点,19点,23点执行一次
|
| | | // 更新商品数据 每天的8点,11点,19点,23点执行一次
|
| | | @Scheduled(cron = "0 0 8,11,19,23 * * ? ")
|
| | | public void doUpdateInfoJobNew() {
|
| | | if (!Constant.IS_TASK)
|
| | |
| | | </set> |
| | | where joi_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!-- 统计相关方法 --> |
| | | <sql id="Column_DateType"> |
| | | <if test="dateType == 1">FROM_UNIXTIME(jo_order_time/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="dateType == 2">FROM_UNIXTIME(jo_order_time/1000,'%m') AS 'showDate'</if> |
| | | <if test="dateType == 3">FROM_UNIXTIME(jo_order_time/1000,'%Y') AS 'showDate'</if> |
| | | </sql> |
| | | <sql id="Count_Select_DateType"> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(jo_order_time/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(jo_order_time/1000,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}' |
| | | </if> |
| | | <if test="year != null and year != '' ">AND FROM_UNIXTIME(jo_order_time/1000,'%Y') = '${year}'</if> |
| | | </sql> |
| | | <sql id="Count_Group_DateType"> |
| | | <if test="dateType == 1">GROUP BY FROM_UNIXTIME(jo_order_time/1000,'%Y-%m-%d')</if> |
| | | <if test="dateType == 2">GROUP BY FROM_UNIXTIME(jo_order_time/1000,'%Y-%m')</if> |
| | | <if test="dateType == 3">GROUP BY FROM_UNIXTIME(jo_order_time/1000,'%Y')</if> |
| | | </sql> |
| | | |
| | | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(`joi_id`),0) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id WHERE jo_order_time IS NOT NULL |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY jo_order_time |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(t.`co_id`),0) AS showValue,<include refid="Column_DateType"/> |
| | | FROM `yeshi_ec_common_order` t |
| | | WHERE t.`co_third_create_time` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | WHERE t.co_source_type=#{sourceType} and t.`co_third_create_time` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`co_third_create_time` |
| | | </select> |
| | |
| | | </set> |
| | | where po_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <!-- 统计 --> |
| | | <sql id="Column_DateType"> |
| | | <if test="dateType == 1">FROM_UNIXTIME(po_order_create_time,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="dateType == 2">FROM_UNIXTIME(po_order_create_time,'%m') AS 'showDate'</if> |
| | | <if test="dateType == 3">FROM_UNIXTIME(po_order_create_time,'%Y') AS 'showDate'</if> |
| | | </sql> |
| | | <sql id="Count_Select_DateType"> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(po_order_create_time,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(po_order_create_time,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}' |
| | | </if> |
| | | <if test="year != null and year != '' ">AND FROM_UNIXTIME(po_order_create_time,'%Y') = '${year}'</if> |
| | | </sql> |
| | | <sql id="Count_Group_DateType"> |
| | | <if test="dateType == 1">GROUP BY FROM_UNIXTIME(po_order_create_time,'%Y-%m-%d')</if> |
| | | <if test="dateType == 2">GROUP BY FROM_UNIXTIME(po_order_create_time,'%Y-%m')</if> |
| | | <if test="dateType == 3">GROUP BY FROM_UNIXTIME(po_order_create_time,'%Y')</if> |
| | | </sql> |
| | | |
| | | |
| | | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(`po_id`),0) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM `yeshi_ec_pdd_order` t WHERE po_order_create_time IS NOT NULL |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY po_order_create_time |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.jd.JDOrderItemMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderCountMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.pdd.PDDOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class CommonOrderCountServiceImpl implements CommonOrderCountService {
|
| | |
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
| | | private TaoBaoOrderMapper taoBaoOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderCountMapper commonOrderCountMapper;
|
| | | private JDOrderItemMapper jdOrderItemMapper;
|
| | |
|
| | | @Resource
|
| | | private PDDOrderMapper pddOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderCountMapper commonOrderCountMapper;
|
| | |
|
| | | @Override
|
| | | public Long countByState(Integer state) {
|
| | | return commonOrderCountMapper.countByState(state);
|
| | | }
|
| | |
|
| | | public List<Map<String, Object>> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
|
| | | public List<Map<String, Object>> dayFactory(String startTime, String endTime, List<Map<String, Object>> list)
|
| | | throws Exception {
|
| | |
|
| | | List<Map<String, Object>> listObject = new ArrayList<Map<String, Object>>();
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getTrackAccuracyRate(Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception{
|
| | | String endTime, int sourceType) throws Exception {
|
| | |
|
| | | List<Map<String, Object>> result_list = null;
|
| | |
|
| | | // 用户订单
|
| | | List<Map<String, Object>> listTotal = commonOrderCountMapper.countOrderNumber(dateType, year,
|
| | | startTime, endTime);
|
| | | List<Map<String, Object>> listTotal = commonOrderCountMapper.countOrderNumber(dateType, year, startTime,
|
| | | endTime, sourceType);
|
| | | if (listTotal == null || listTotal.size() == 0) {
|
| | | return result_list;
|
| | | }
|
| | |
|
| | | // 淘宝联盟
|
| | | List<Map<String, Object>> type_list = taoBaoOrderMapper.countOrderNumber(dateType, year, |
| | | startTime, endTime);
|
| | | |
| | | List<Map<String, Object>> type_list = null;
|
| | | switch (sourceType) {
|
| | | case Constant.SOURCE_TYPE_TAOBAO:
|
| | | type_list = taoBaoOrderMapper.countOrderNumber(dateType, year, startTime, endTime);
|
| | | break;
|
| | | case Constant.SOURCE_TYPE_JD:
|
| | | type_list = jdOrderItemMapper.countOrderNumber(dateType, year, startTime, endTime);
|
| | | break;
|
| | | case Constant.SOURCE_TYPE_PDD:
|
| | | type_list = pddOrderMapper.countOrderNumber(dateType, year, startTime, endTime);
|
| | | break;
|
| | | }
|
| | | if (type_list == null || type_list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | | return taoBaoWeiQuanOrderMapper.countWeiQaunOrderMoney(dateType, year, startTime, endTime);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<Map<String, Object>> countWeiQaunOrderNumber(Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception{
|
| | |
| | | return commonOrderCountMapper.countOrderNumberBySettleTime(uid, state, day);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 根据结算时间筛选 上个月已结算的订订单数量
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | |
| | | public BigDecimal getMoneyByOrderNo(String orderNo) {
|
| | | return commonOrderCountMapper.getMoneyByOrderNo(orderNo);
|
| | | }
|
| | | |
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.lable;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.lable.LabelGoodsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.lable.QualityFactoryMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.lable.QualityFlashSaleMapper;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryGoodsUpdateService;
|
| | |
|
| | | @Service
|
| | | public class QualityFactoryGoodsUpdateServiceImpl implements QualityFactoryGoodsUpdateService {
|
| | |
|
| | | @Resource
|
| | | private QualityFactoryMapper qualityFactoryMapper;
|
| | | @Resource
|
| | | private QualityFlashSaleMapper qualityFlashSaleMapper;
|
| | | @Resource
|
| | | private LabelGoodsMapper labelGoodsMapper;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void deleteByTaoBaoGoodsId(Long auctionId) {
|
| | | if (auctionId == null)
|
| | | return;
|
| | |
|
| | | // 移除精选库
|
| | | qualityFactoryMapper.deleteByGoodsId(auctionId);
|
| | | // 删除限时抢购
|
| | | qualityFlashSaleMapper.deleteByGoodsId(auctionId);
|
| | | // 删除对应标签
|
| | | labelGoodsMapper.deleteByGoodsId(auctionId);
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content, String versions) throws PushException {
|
| | | public void pushGoods(Long uid, Long auctionId, String title, String content, String versions)
|
| | | throws PushException {
|
| | | if (1 > 0)
|
| | | return;
|
| | | String gid = auctionId + "";
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", "");
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushUrl(Long uid, String url, String title, String content, String versions) throws PushException {
|
| | | if (1 > 0)
|
| | | return;
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("url", url);
|
| | | json.put("type", "url");
|
| | |
| | | }
|
| | | }
|
| | | try {
|
| | | HWPushUtil.pushWeb(deviceTokens, title, content, url);
|
| | | HWPushUtil.pushUrl(deviceTokens, title, content, url);
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.hwError(e);
|
| | | }
|
| | |
| | | for (DeviceTokenHW dt : hwDeviceList)
|
| | | deviceList.add(dt.getDeviceToken());
|
| | | try {
|
| | | HWPushUtil.pushWeb(deviceList, title, content, url);
|
| | | HWPushUtil.pushUrl(deviceList, title, content, url);
|
| | | } catch (Exception e) {
|
| | | PushLogHelper.hwError(e);
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushZNX(Long uid, AccountMessage msg, SystemZnx systemZNX, String versions) throws PushException {
|
| | |
|
| | | if (1 > 0)
|
| | | return;
|
| | | JSONObject contentJson = new JSONObject();
|
| | | contentJson.put("isOpen", 0);
|
| | | contentJson.put("createTime", java.lang.System.currentTimeMillis());
|
| | |
| | |
|
| | | @Async("pushExecutor")
|
| | | @Override
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, String versions) throws PushException {
|
| | | public void pushBaiChuanUrl(Long uid, String title, String content, String url, String versions)
|
| | | throws PushException {
|
| | | // TODO 推送淘客百川链接
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 加入更新队列
|
| | |
|
| | | //
|
| | | try {
|
| | | for (TLJBuyGoods tljGoods : list)
|
| | | if (tljGoods != null && tljGoods.getGoods() != null && tljGoods.getGoods().getAuctionId() != null)
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.taobao;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Service
|
| | | public class TLJBuyGoodsUpdateServiceImpl implements TLJBuyGoodsUpdateService {
|
| | | @Resource
|
| | | private TLJBuyGoodsDao tljBuyGoodsDao;
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Override
|
| | | public void updateGoods(TaoBaoGoodsBrief goods) {
|
| | | if (goods == null)
|
| | | return;
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByAuctionId(goods.getAuctionId());
|
| | | // 查询自购立减是否小于1元
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | // if (money.compareTo(new BigDecimal(1)) < 0) {// 删除商品
|
| | | // if (list != null)
|
| | | // for (TLJBuyGoods tljGoods : list) {
|
| | | // tljBuyGoodsDao.delete(tljGoods.getId());
|
| | | // }
|
| | | // }
|
| | |
|
| | | if (list != null)
|
| | | for (TLJBuyGoods TLJBuyGoods : list) {
|
| | |
|
| | | if (goods.getCouponInfo() == null)
|
| | | goods.setCouponInfo("");
|
| | | if (goods.getCouponAmount() == null)
|
| | | goods.setCouponAmount(new BigDecimal(0));
|
| | |
|
| | | // 判断 券信息 价格信息 返利比例信息是否改变
|
| | | boolean change = false;
|
| | | if (goods.getZkPrice().compareTo(TLJBuyGoods.getGoods().getZkPrice()) != 0)
|
| | | change = true;
|
| | | if (goods.getCouponAmount().compareTo(TLJBuyGoods.getGoods().getCouponAmount()) != 0)
|
| | | change = true;
|
| | | if (!goods.getCouponInfo().equalsIgnoreCase(TLJBuyGoods.getGoods().getCouponInfo()))
|
| | | change = true;
|
| | | if (goods.getTkRate().compareTo(TLJBuyGoods.getGoods().getTkRate()) != 0)
|
| | | change = true;
|
| | |
|
| | | if (change) {
|
| | | // 清除列表缓存
|
| | | ehCacheCacheManager.getCache("commonContentCache").evict(
|
| | | "tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | }
|
| | |
|
| | | // 更新券信息 ,价格信息,销量信息
|
| | | TLJBuyGoods.getGoods().setZkPrice(goods.getZkPrice());
|
| | | TLJBuyGoods.getGoods().setCouponAmount(goods.getCouponAmount());
|
| | | TLJBuyGoods.getGoods().setCouponInfo(goods.getCouponInfo());
|
| | | TLJBuyGoods.getGoods().setCouponEffectiveEndTime(goods.getCouponEffectiveEndTime());
|
| | | TLJBuyGoods.getGoods().setCouponEffectiveStartTime(goods.getCouponEffectiveStartTime());
|
| | | TLJBuyGoods.getGoods().setCouponLeftCount(goods.getCouponLeftCount());
|
| | | TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee());
|
| | | TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount());
|
| | | TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day());
|
| | | TLJBuyGoods.getGoods().setTkRate(goods.getTkRate());
|
| | | TLJBuyGoods.getGoods().setId(goods.getId());
|
| | | TLJBuyGoods.getGoods().setAuctionId(goods.getAuctionId());
|
| | | tljBuyGoodsDao.save(TLJBuyGoods);
|
| | | }
|
| | | }
|
| | | } |
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @Resource
|
| | | private ActivityService activityService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private QualityFactoryService qualityFactoryService;
|
| | | private QualityFactoryGoodsUpdateService qualityFactoryGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
|
| | |
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | | private TLJBuyGoodsUpdateService tljBuyGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
| | | @Override
|
| | | public void deleteTaoBaoGoods(Long auctionId) {
|
| | | // 删除精选库相关的数据
|
| | | qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
|
| | | qualityFactoryGoodsUpdateService.deleteByTaoBaoGoodsId(auctionId);
|
| | |
|
| | | // 删除商品本身数据
|
| | | taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
|
| | |
| | | activityService.downTaoBaoGoods(auctionId);
|
| | |
|
| | | // 删除精选库相关的数据
|
| | | qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
|
| | | qualityFactoryGoodsUpdateService.deleteByTaoBaoGoodsId(auctionId);
|
| | |
|
| | | // 删除商品本身数据
|
| | | taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
|
| | |
| | | shareHotGoodsService.updateShareGoods(goods);
|
| | |
|
| | | // 更新自购立减库商品
|
| | | tljBuyGoodsService.updateGoods(goods);
|
| | | tljBuyGoodsUpdateService.updateGoods(goods);
|
| | |
|
| | | // 总要商品更新
|
| | | // updateImplTBGoods(goods);
|
| | | updateImplTBGoods(goods);
|
| | | }
|
| | |
|
| | | @Override
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.lable;
|
| | |
|
| | | public interface QualityFactoryGoodsUpdateService {
|
| | |
|
| | | /**
|
| | | * 商品更新
|
| | | * |
| | | * @param goodsList
|
| | | */
|
| | | public void deleteByTaoBaoGoodsId(Long auctionId);
|
| | |
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public List<Map<String, Object>> getTrackAccuracyRate(Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception;
|
| | | String endTime,int sourceType) throws Exception;
|
| | |
|
| | | /**
|
| | | * 统计总金额
|
| | |
| | | package com.yeshi.fanli.service.inter.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.system.SystemZnx;
|
| | | import com.yeshi.fanli.exception.PushException;
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.taobao;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
|
| | | /**
|
| | | * 自购立减商品更新
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface TLJBuyGoodsUpdateService {
|
| | |
|
| | | /**
|
| | | * 更新商品
|
| | | * |
| | | * @param goods
|
| | | */
|
| | | public void updateGoods(TaoBaoGoodsBrief goods);
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.push.PushQueueRecord;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
|
| | |
| | | import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | /**
|
| | | * 系统初始化
|
| | |
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | | doJDOrderJob();// 京东订单处理
|
| | | doPDDOrderJob();// 拼多多订单处理
|
| | | doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 重要的淘宝商品信息更新
|
| | | */
|
| | | public void doImportantTaoBaoGoodsUpdateJob() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | Map<String, Long> map = CMQManager.getInstance().consumeTBImpGoodsUpdateMsg(16);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(map.get(key));
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } finally {
|
| | | CMQManager.getInstance().deleteTBImpGoodsUpdateMsg(key);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.OutputStream;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.HttpURLConnection;
|
| | | import java.net.URL;
|
| | | import java.net.URLDecoder;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.MessageFormat;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Properties;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | |
| | | appSecret = config.getAppSecret();
|
| | | }
|
| | |
|
| | | private static String getIntent(String type, String activity, String url, String webUrl, Long id) {
|
| | | net.sf.json.JSONObject data = new net.sf.json.JSONObject();
|
| | | if (type != null)
|
| | | data.put("type", type);
|
| | | if (activity != null)
|
| | | data.put("activity", activity);
|
| | | if (url != null)
|
| | | data.put("url", url);
|
| | | if (webUrl != null)
|
| | | data.put("webUrl", webUrl);
|
| | | if (id != null)
|
| | | data.put("id", id);
|
| | |
|
| | | try {
|
| | | return String.format(
|
| | | "intent://flq/selfbuyandreductionactivity?data=%s#Intent;scheme=banliapp;launchFlags=0x4000000;end",
|
| | | URLDecoder.decode(data.toString(), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 推送商品
|
| | | *
|
| | |
| | | */
|
| | | public static void pushGoods(List<String> deviceTokens, String title, String content, int goodsType, Long goodsId)
|
| | | throws PushException {
|
| | | if (deviceTokens != null && deviceTokens.size() > 1000)
|
| | | throw new PushException(1, "设备数不能超过1000个");
|
| | | if (deviceTokens != null && deviceTokens.size() > 100)
|
| | | throw new PushException(1, "设备数不能超过100个");
|
| | |
|
| | | String activity = Constant.systemCommonConfig.getAndroidBaseactivityName()
|
| | | + ".ui.recommend.GoodsBrowserActivity";
|
| | | activity = activity.replace(Constant.systemCommonConfig.getAndroidPackageName(),
|
| | | Constant.systemCommonConfig.getAndroidPackageName() + "/");
|
| | | String intent = getIntent("goodsdetail", activity, null, null, goodsId);
|
| | |
|
| | | String intent = "intent:#Intent;launchFlags=0x4000000;component=" + activity + ";S.id=" + goodsId + ";end";
|
| | | try {
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent, null);
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | |
| | | * -网页链接
|
| | | * @throws PushException
|
| | | */
|
| | | public static void pushWeb(List<String> deviceTokens, String title, String content, String url)
|
| | | public static void pushUrl(List<String> deviceTokens, String title, String content, String url)
|
| | | throws PushException {
|
| | | if (deviceTokens != null && deviceTokens.size() > 1000)
|
| | | if (deviceTokens != null && deviceTokens.size() > 100)
|
| | | throw new PushException(1, "设备数不能超过1000个");
|
| | |
|
| | | String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.invite.ShareBrowserActivity";
|
| | | activity = activity.replace(Constant.systemCommonConfig.getAndroidPackageName(),
|
| | | Constant.systemCommonConfig.getAndroidPackageName() + "/");
|
| | |
|
| | | String intent = "intent:#Intent;launchFlags=0x4000000;component=" + activity + ";S.url="
|
| | | + URLEncoder.encode(url) + ";end";
|
| | | String intent = getIntent("url", activity, null, url, null);
|
| | | try {
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent, null);
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | |
| | | public static void pushZNX(List<String> deviceTokens, String title, String content) throws PushException {
|
| | | if (deviceTokens != null && deviceTokens.size() > 100)
|
| | | throw new PushException(1, "设备数不能超过100个");
|
| | |
|
| | | // String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.MainActivity";
|
| | | // activity = activity.replace(Constant.systemCommonConfig.getAndroidPackageName(),
|
| | | // Constant.systemCommonConfig.getAndroidPackageName() + "/");
|
| | | //
|
| | | // Map<String, String> custom = new HashMap<String, String>();
|
| | | // custom.put("type", "ZNX");
|
| | | // custom.put("type1", "ZNX");
|
| | | // String intent = "intent:#Intent;launchFlags=0x4000000;component=" + activity + ";end";
|
| | | // try {
|
| | | // String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent, custom);
|
| | | // net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | // if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | // throw new PushException(2, result);
|
| | | // } catch (IOException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | String intent = getIntent("ZNX", null, null, null, null);
|
| | | if (intent == null)
|
| | | return;
|
| | |
|
| | | try {
|
| | | sendMsg(deviceTokens,title,content, null);
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * 推送简单文字
|
| | | * |
| | | * @param deviceTokens
|
| | | * @param title
|
| | | * @param content
|
| | | * @throws PushException
|
| | | */
|
| | | public static void pushWEEX(List<String> deviceTokens, String title, String content, String weexUrl)
|
| | | throws PushException {
|
| | | String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.weex.WeexApplicationActivity";
|
| | | String intent = getIntent("weex", activity, weexUrl, weexUrl, null);
|
| | | if (intent == null)
|
| | | return;
|
| | |
|
| | | public static void pushSimpleText(List<String> deviceTokens, String title, String content) throws PushException {
|
| | | if (deviceTokens != null && deviceTokens.size() > 1000)
|
| | | throw new PushException(1, "设备数不能超过1000个");
|
| | | try {
|
| | | String result = sendPushHWMessageForOpenApp(deviceTokens, title, content);
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | public static void pushBaiChuanUrl(List<String> deviceTokens, String title, String content, String url)
|
| | | throws PushException {
|
| | | String intent = getIntent("baichuan", null, url, null, null);
|
| | | if (intent == null)
|
| | | return;
|
| | |
|
| | | try {
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | public static void pushWelfareCenter(List<String> deviceTokens, String title, String content) throws PushException {
|
| | | String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.WelfareCenterActivity";
|
| | | String intent = getIntent("welfare", activity, null, null, null);
|
| | | if (intent == null)
|
| | | return;
|
| | |
|
| | | try {
|
| | | String result = sendPushHWMessageForIntent(deviceTokens, title, content, intent);
|
| | | net.sf.json.JSONObject data = net.sf.json.JSONObject.fromObject(result);
|
| | | if (!"success".equalsIgnoreCase(data.optString("msg")))
|
| | | throw new PushException(2, result);
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | private static String sendPushHWMessageForIntent(List<String> deviceTokens, String title, String content,
|
| | | String intent, Map<String, String> customizeMap) throws IOException {
|
| | | String intent) throws IOException {
|
| | | if (tokenExpiredTime <= System.currentTimeMillis()) {
|
| | | refreshToken();
|
| | | }
|
| | |
| | |
|
| | | // 定义需要打开的appPkgName
|
| | | JSONObject param = new JSONObject();
|
| | | // param.put("url", "http://www.baidu.com");
|
| | |
|
| | | // param.put("intent", intent);
|
| | | param.put("appPkgName", "com.yeshi.ec.rebate");
|
| | | param.put("intent", intent);
|
| | | // param.put("appPkgName", "com.yeshi.ec.rebate");
|
| | |
|
| | | JSONObject action = new JSONObject();
|
| | | action.put("type", 3);// (1 自定义行为:行为由参数intent定义;2 打开URL:URL地址由参数url定义;3
|
| | | action.put("type", 1);// (1 自定义行为:行为由参数intent定义;2 打开URL:URL地址由参数url定义;3
|
| | | // 打开APP:默认值,打开App的首页)
|
| | | action.put("param", param);// 消息点击动作参数
|
| | |
|
| | |
| | |
|
| | | // 扩展信息,含BI消息统计,特定展示风格,消息折叠。
|
| | | JSONObject ext = new JSONObject();
|
| | | ext.put("biTag", "Trump");
|
| | | if (customizeMap != null) {// 传递自定义参数
|
| | | JSONArray array = new JSONArray();
|
| | | for (Iterator<String> its = customizeMap.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put(key, customizeMap.get(key));
|
| | | array.add(json);
|
| | | }
|
| | | ext.put("customize", array);
|
| | | }
|
| | |
|
| | | // ext.put("icon",
|
| | | // "http://pic.qiantucdn.com/58pic/12/38/18/13758PIC4GV.jpg");//
|
| | |
| | | JSONObject payload = new JSONObject();
|
| | | payload.put("hps", hps);
|
| | |
|
| | | System.out.println(payload.toJSONString());
|
| | |
|
| | | String postBody = MessageFormat.format(
|
| | | "access_token={0}&nsp_svc={1}&nsp_ts={2}&device_token_list={3}&payload={4}",
|
| | | URLEncoder.encode(accessToken, "UTF-8"), URLEncoder.encode("openpush.message.api.send", "UTF-8"),
|
| | | URLEncoder.encode(String.valueOf(System.currentTimeMillis() / 1000), "UTF-8"),
|
| | | URLEncoder.encode(deviceTokenList.toString(), "UTF-8"), URLEncoder.encode(payload.toString(), "UTF-8"));
|
| | |
|
| | | String postUrl = apiUrl + "?nsp_ctx="
|
| | | + URLEncoder.encode("{\"ver\":\"1\", \"appId\":\"" + appId + "\"}", "UTF-8");
|
| | | String result = httpPost(postUrl, postBody, 5000, 5000);
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | private static String sendMsg(List<String> deviceTokens,String title,String content, Map<String, String> customizeMap) throws IOException {
|
| | | if (tokenExpiredTime <= System.currentTimeMillis()) {
|
| | | refreshToken();
|
| | | }
|
| | |
|
| | | /* PushManager.requestToken为客户端申请token的方法,可以调用多次以防止申请token失败 */
|
| | | /* PushToken不支持手动编写,需使用客户端的onToken方法获取 */
|
| | | JSONArray deviceTokenList = new JSONArray();// 目标设备Token
|
| | | for (String deviceToken : deviceTokens) {
|
| | | deviceTokenList.add(deviceToken);
|
| | | }
|
| | |
|
| | | // 仅通知栏消息需要设置标题和内容,透传消息key和value为用户自定义
|
| | | JSONObject body = new JSONObject();
|
| | | body.put("type", "ZNX");// 消息标题
|
| | | body.put("title", title);// 消息标题
|
| | | body.put("content",content);// 消息标题
|
| | |
|
| | | JSONObject msg = new JSONObject();
|
| | | msg.put("type", 1);// 3: 通知栏消息,异步透传消息请根据接口文档设置
|
| | |
|
| | | msg.put("body", body);// 通知栏消息body内容
|
| | |
|
| | | JSONObject hps = new JSONObject();
|
| | | hps.put("msg", msg);
|
| | | JSONObject payload = new JSONObject();
|
| | | payload.put("hps", hps);
|
| | | System.out.println(payload.toJSONString());
|
| | |
|
| | | String postBody = MessageFormat.format(
|