Merge remote-tracking branch 'origin/div' into div
| | |
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | /**
|
| | | * 活跃用户处理
|
| | |
| | | String key = "useractive-" + uidStr;
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | if (jedis.setnx(key, "1") > 0) {
|
| | | jedis.expire(key, 60 * 5);// 5分钟内不处理
|
| | | if (!StringUtil.isNullOrEmpty(jedis.set(key, "1", new SetParams().nx().ex(300)))) {
|
| | | try {
|
| | | // TODO 用户活跃处理
|
| | | Long uid = Long.parseLong(uidStr);
|
| | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | @Component
|
| | | @Aspect
|
| | |
| | | LogHelper.test("进入拦截:"+cacheKey+"-"+threadId);
|
| | | try {
|
| | | Constant.waitingThreadSet.add(threadId);
|
| | | long result = 0;
|
| | | String result = null;
|
| | | long startTime = System.currentTimeMillis();
|
| | | // 等待响应
|
| | | while (result <= 0) {
|
| | | result = jedis.setnx(cacheKey, "1");
|
| | | while (StringUtil.isNullOrEmpty(result)) {
|
| | | |
| | | result = jedis.set(cacheKey, "1", new SetParams().nx().ex(30));
|
| | | LogHelper.error("触发并发锁:" + cacheAlias);
|
| | | LogHelper.error("redis键:" + cacheKey);
|
| | | if (result <= 0) {
|
| | | if (StringUtil.isNullOrEmpty(result)) {
|
| | | LogHelper.test("等待:"+threadId);
|
| | | try {
|
| | | Thread.sleep(50);
|
| | |
| | | return null;
|
| | | }
|
| | | } else {
|
| | | // 设置30秒处理时间
|
| | | jedis.expire(cacheKey, 30);
|
| | | LogHelper.test("获取到锁:"+threadId);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (result > 0) {
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | try {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e) {
|
| | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {// 原子性保护出错
|
| | |
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | @Component
|
| | | @Aspect
|
| | |
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | Constant.waitingThreadSet.add(Thread.currentThread().getId());
|
| | | long result = 0;
|
| | | String result = null;
|
| | | long startTime = System.currentTimeMillis();
|
| | | // 等待响应
|
| | | while (result <= 0) {
|
| | | result = jedis.setnx(cacheKey, "1");
|
| | | if (result <= 0) {
|
| | | while (StringUtil.isNullOrEmpty(result)) {
|
| | | result = jedis.set(cacheKey, "1", new SetParams().nx().ex(30));
|
| | | if (StringUtil.isNullOrEmpty(result)) {
|
| | | try {
|
| | | Thread.sleep(50);
|
| | | } catch (InterruptedException e) {
|
| | |
| | | Constant.waitingThreadSet.remove(Thread.currentThread().getId());
|
| | | return null;
|
| | | }
|
| | | } else {
|
| | | // 设置30秒处理时间
|
| | | jedis.expire(cacheKey, 30);
|
| | | }
|
| | | }
|
| | |
|
| | | if (result > 0) {
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | try {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e) {
|
| | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {// 原子性保护出错
|
| | |
| | | } finally {
|
| | | }
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | | } catch (NoSuchMethodException e) {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 6);
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6);
|
| | | if (goodsList == null)
|
| | | goodsList = new ArrayList<>();
|
| | |
|
| | |
| | |
|
| | | try {
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10);
|
| | | // 初始化
|
| | | if (goodsList == null) {
|
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate,
|
| | | Constant.MAX_REWARD_RATE);
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10);
|
| | | // 初始化
|
| | | if (goodsList == null) {
|
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | | |
| | |
|
| | | goodsList.parallelStream().forEach(goods -> {
|
| | | if (goods != null) {
|
| | | // 获取详情
|
| | |
| | | }
|
| | |
|
| | | if (taoBaoGoodsBrief != null) {
|
| | | listExtra.add(
|
| | | GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO));
|
| | | listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO));
|
| | | }
|
| | | }
|
| | | });
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.integral; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord; |
| | | |
| | | public interface UserGetIntegralFromOrderRecordMapper extends BaseMapper<UserGetIntegralFromOrderRecord> { |
| | | |
| | | /** |
| | | * 根据用户,事件类型,订单信息计数 |
| | | * |
| | | * @param eventType |
| | | * @param uid |
| | | * @param orderNo |
| | | * @param orderSourceType |
| | | * @return |
| | | */ |
| | | long countByRecordInfo(@Param("record") UserGetIntegralFromOrderRecord record); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.integral;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | /**
|
| | | * 用户因为订单获取到金币
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Table("yeshi_ec_integral_get_from_order")
|
| | | public class UserGetIntegralFromOrderRecord {
|
| | | public static int TYPE_PLACE_ORDER = 1;// 下单
|
| | | public static int TYPE_RECIEVE_MONEY = 2;// 到账
|
| | |
|
| | | @Column(name = "fo_id")
|
| | | private Long id;
|
| | | @Column(name = "fo_event_type")
|
| | | private Integer eventType;// 事件类型
|
| | | @Column(name = "fo_uid")
|
| | | private Long uid;// 用户ID
|
| | | @Column(name = "fo_order_no")
|
| | | private String orderNo;// 订单号
|
| | | @Column(name = "fo_order_source_type")
|
| | | private Integer orderSourceType;// 订单来源类型
|
| | | @Column(name = "fo_integral_count")
|
| | | private Integer integralCount;// 金币数量
|
| | | @Column(name = "fo_create_time")
|
| | | private Date createTime;// 创建时间
|
| | | @Column(name = "fo_update_time")
|
| | | private Date updateTime;// 更新时间
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Integer getEventType() {
|
| | | return eventType;
|
| | | }
|
| | |
|
| | | public void setEventType(Integer eventType) {
|
| | | this.eventType = eventType;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getOrderNo() {
|
| | | return orderNo;
|
| | | }
|
| | |
|
| | | public void setOrderNo(String orderNo) {
|
| | | this.orderNo = orderNo;
|
| | | }
|
| | |
|
| | | public Integer getOrderSourceType() {
|
| | | return orderSourceType;
|
| | | }
|
| | |
|
| | | public void setOrderSourceType(Integer orderSourceType) {
|
| | | this.orderSourceType = orderSourceType;
|
| | | }
|
| | |
|
| | | public Integer getIntegralCount() {
|
| | | return integralCount;
|
| | | }
|
| | |
|
| | | public void setIntegralCount(Integer integralCount) {
|
| | | this.integralCount = integralCount;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.integral;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class UserGetIntegralFromOrderRecordException extends BaseException {
|
| | | |
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | public UserGetIntegralFromOrderRecordException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | public UserGetIntegralFromOrderRecordException() {
|
| | | super();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.job.order.elme;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.elme.ElmeOrder;
|
| | | import com.yeshi.fanli.exception.elme.ElmeOrderException;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.elme.ElmeOrderUtil;
|
| | |
|
| | | //饿了么爬单,到账
|
| | | @Component
|
| | | public class UpdateElmeOrderJob {
|
| | |
|
| | | @Resource
|
| | | private ElmeOrderProcessService elmeOrderProcessService;
|
| | |
|
| | | @Resource
|
| | | private OrderProcessService orderProcessService;
|
| | |
|
| | | /**
|
| | | * 更新订单(每天早上凌晨0点,下午4点)
|
| | | */
|
| | | @Scheduled(cron = "0 0 0,16 * * ? ")
|
| | | public void updateOrder() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | try {
|
| | | List<ElmeOrder> orderList = ElmeOrderUtil.pullLatest5DayOrder();
|
| | | try {
|
| | | for (ElmeOrder order : orderList)
|
| | | elmeOrderProcessService.processOrder(order);
|
| | | } catch (ElmeOrderException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 每天凌晨过2分到账
|
| | | @Scheduled(cron = "0 2 0 * * ? ")
|
| | | public void fanli() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | List<HongBaoV2> hongBaoList = orderProcessService.getCanBalanceElmeFanliHongBao();
|
| | | for (HongBaoV2 v2 : hongBaoList)
|
| | | orderProcessService.elmeFanli(v2.getId());
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.manager.util;
|
| | |
|
| | | public interface AtomMethodCallInterface {
|
| | | public void excute();
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.manager.util;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | @Component
|
| | | public class AtomMethodCallManager {
|
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | /**
|
| | | * 事件执行
|
| | | * |
| | | * @param key
|
| | | * 事件唯一标识,要与具体的业务逻辑相结合
|
| | | * @param call
|
| | | */
|
| | | public void excute(String key, AtomMethodCallInterface call) {
|
| | | String redisKey = "atom-" + StringUtil.Md5(key);
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(jedis.set(redisKey, "1", new SetParams().nx().ex(60)))) {
|
| | | System.out.println("请稍后再试");
|
| | | return;
|
| | | }
|
| | | call.excute();
|
| | | } finally {
|
| | | jedis.del(redisKey);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | <?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.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord"> |
| | | <id column="fo_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="fo_event_type" property="eventType" jdbcType="INTEGER" /> |
| | | <result column="fo_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="fo_order_no" property="orderNo" jdbcType="VARCHAR" /> |
| | | <result column="fo_order_source_type" property="orderSourceType" |
| | | jdbcType="INTEGER" /> |
| | | <result column="fo_integral_count" property="integralCount" |
| | | jdbcType="INTEGER" /> |
| | | <result column="fo_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="fo_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">fo_id,fo_event_type,fo_uid,fo_order_no,fo_order_source_type,fo_integral_count,fo_create_time,fo_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_integral_get_from_order where fo_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_integral_get_from_order where fo_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_integral_get_from_order |
| | | (fo_id,fo_event_type,fo_uid,fo_order_no,fo_order_source_type,fo_integral_count,fo_create_time,fo_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{eventType,jdbcType=INTEGER},#{uid,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{orderSourceType,jdbcType=INTEGER},#{integralCount,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_integral_get_from_order |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">fo_id,</if> |
| | | <if test="eventType != null">fo_event_type,</if> |
| | | <if test="uid != null">fo_uid,</if> |
| | | <if test="orderNo != null">fo_order_no,</if> |
| | | <if test="orderSourceType != null">fo_order_source_type,</if> |
| | | <if test="integralCount != null">fo_integral_count,</if> |
| | | <if test="createTime != null">fo_create_time,</if> |
| | | <if test="updateTime != null">fo_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="eventType != null">#{eventType,jdbcType=INTEGER},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="orderSourceType != null">#{orderSourceType,jdbcType=INTEGER},</if> |
| | | <if test="integralCount != null">#{integralCount,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord">update yeshi_ec_integral_get_from_order set |
| | | fo_event_type = #{eventType,jdbcType=INTEGER},fo_uid = |
| | | #{uid,jdbcType=BIGINT},fo_order_no = |
| | | #{orderNo,jdbcType=VARCHAR},fo_order_source_type = |
| | | #{orderSourceType,jdbcType=INTEGER},fo_integral_count = |
| | | #{integralCount,jdbcType=INTEGER},fo_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},fo_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where fo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord"> |
| | | update yeshi_ec_integral_get_from_order |
| | | <set> |
| | | <if test="eventType != null">fo_event_type=#{eventType,jdbcType=INTEGER},</if> |
| | | <if test="uid != null">fo_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="orderNo != null">fo_order_no=#{orderNo,jdbcType=VARCHAR},</if> |
| | | <if test="orderSourceType != null">fo_order_source_type=#{orderSourceType,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="integralCount != null">fo_integral_count=#{integralCount,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">fo_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">fo_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where fo_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | |
| | | <select id="countByRecordInfo" resultType="java.lang.Long" useCache="false" flushCache="true"> |
| | | select |
| | | count(*) |
| | | from yeshi_ec_integral_get_from_order where 1=1 |
| | | |
| | | <if test="record!=null"> |
| | | <if test="record.eventType!=null"> |
| | | and fo_event_type=#{record.eventType} |
| | | </if> |
| | | |
| | | <if test="record.uid!=null"> |
| | | and fo_uid=#{record.uid} |
| | | </if> |
| | | |
| | | <if test="record.orderNo!=null"> |
| | | and fo_order_no=#{record.orderNo} |
| | | </if> |
| | | |
| | | <if test="record.orderSourceType!=null"> |
| | | and fo_order_source_type=#{record.orderSourceType} |
| | | </if> |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.ShareGoodsActivityOrderException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | |
| | | return hongBaoV2Mapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
|
| | | public int addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException, UserAccountException {
|
| | | Set<Integer> stateSet = new HashSet<>();// 订单状态Set
|
| | | if (commonOrderList != null && commonOrderList.size() > 0) {
|
| | | int orderType = commonOrderList.get(0).getSourceType();
|
| | |
| | | hasUpdate = true;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 通知用户的返利情况
|
| | | */
|
| | |
| | |
|
| | | @Transactional
|
| | | private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
|
| | | Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException {
|
| | | Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException {
|
| | | System.out.println(commonOrder.getOrderNo());
|
| | | // 锁行
|
| | | HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
|
| | | if (oldHongBao == null)
|
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO||oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | return false;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | |
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | if (mianDan)
|
| | | hongBao.setMoney(commonOrder.getPayment());
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS||commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | |
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
|
| | | }else if(hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | {
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
|
| | | firstHongbao.setMoney(new BigDecimal(0));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(firstHongbao);
|
| | | // 用户通知
|
| | | if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
|
| | | HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
|
| | | tempHongBao.setUserInfo(firstHongbao.getUserInfo());
|
| | | tempHongBao.setMoney(firstHongbao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
|
| | | tempHongBaoOrder.getCommonOrder().setPayment(
|
| | | tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
|
| | | tempHongBaoOrder.getHongBaoV2()
|
| | | .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
|
| | | notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
|
| | |
|
| | | if (firstHongbao.getMoney() != null
|
| | | && firstHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | hongBaoV2Mapper.insertSelective(firstHongbao);
|
| | | // 用户通知
|
| | | if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
|
| | | HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
|
| | | tempHongBao.setUserInfo(firstHongbao.getUserInfo());
|
| | | tempHongBao.setMoney(firstHongbao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | notificationMap.put(HongBaoV2.TYPE_YIJI,
|
| | | new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
|
| | | tempHongBaoOrder.getCommonOrder().setPayment(
|
| | | tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
|
| | | tempHongBaoOrder.getHongBaoV2().setMoney(
|
| | | tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
|
| | | notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
|
| | | }
|
| | | }
|
| | |
|
| | | // 插入二级子红包
|
| | |
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(secondHongbao);
|
| | |
|
| | | // 用户通知
|
| | | if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
|
| | | HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
|
| | | tempHongBao.setUserInfo(secondHongbao.getUserInfo());
|
| | | tempHongBao.setMoney(secondHongbao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | notificationMap.put(HongBaoV2.TYPE_ERJI,
|
| | | new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
|
| | | tempHongBaoOrder.getCommonOrder().setPayment(
|
| | | tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
|
| | | tempHongBaoOrder.getHongBaoV2().setMoney(
|
| | | tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
|
| | | notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | secondHongbao.setMoney(new BigDecimal(0));
|
| | | if (secondHongbao.getMoney() != null
|
| | | && secondHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | hongBaoV2Mapper.insertSelective(secondHongbao);
|
| | | // 用户通知
|
| | | if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
|
| | | HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
|
| | | tempHongBao.setUserInfo(secondHongbao.getUserInfo());
|
| | | tempHongBao.setMoney(secondHongbao.getMoney());
|
| | | CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
|
| | | tempCommonOrder.setPayment(commonOrder.getPayment());
|
| | | notificationMap.put(HongBaoV2.TYPE_ERJI,
|
| | | new HongBaoOrder(tempCommonOrder, tempHongBao));
|
| | | } else {
|
| | | // 增加付款金额与资金
|
| | | HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
|
| | | tempHongBaoOrder.getCommonOrder().setPayment(tempHongBaoOrder.getCommonOrder()
|
| | | .getPayment().add(commonOrder.getPayment()));
|
| | | tempHongBaoOrder.getHongBaoV2().setMoney(
|
| | | tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
|
| | | notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS||commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | |
| | | }
|
| | |
|
| | | // 以实际收入为准计算预估收益
|
| | | if (CommonOrder.STATE_JS == commonOrder.getState()||CommonOrder.STATE_WQ == commonOrder.getState()) {
|
| | | if (CommonOrder.STATE_JS == commonOrder.getState()
|
| | | || CommonOrder.STATE_WQ == commonOrder.getState()) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
|
| | | if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
|
| | |
| | |
|
| | | @Transactional
|
| | | private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
|
| | | throws HongBaoException {
|
| | | throws HongBaoException, UserAccountException {
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | // 查询是否有免单计划
|
| | |
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS||CommonOrder.STATE_WQ == commonOrder.getState()) {
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || CommonOrder.STATE_WQ == commonOrder.getState()) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | |
| | | hongBao.setMoney(mianDanMoney);
|
| | |
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | | hongBaoV2Mapper.insertSelective(hongBao);
|
| | |
| | | hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS||commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
|
| | |
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
|
| | | }
|
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUserInfo(user);
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | |
| | | child.setState(HongBaoV2.STATE_BUKELINGQU);
|
| | | child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
|
| | | firstLevelRate.divide(new BigDecimal(100))));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS||commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_JS
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | child.setState(HongBaoV2.STATE_KELINGQU);
|
| | | child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
|
| | | firstLevelRate.divide(new BigDecimal(100))));
|
| | |
| | | child.setVersion(2);
|
| | | child.setCreateTime(new Date());
|
| | | child.setOrderType(commonOrder.getSourceType());
|
| | | if (child.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | if (child.getMoney() != null && child.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | hongBaoV2Mapper.insertSelective(child);
|
| | | // 添加通知
|
| | | if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) {
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | | }
|
| | |
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.OrderItemException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
|
| | |
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (UserAccountException e) {
|
| | |
|
| | | }
|
| | | if (resultCode == 1) {// 只发送新增消息
|
| | | OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
|
| | |
| | | }
|
| | |
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | } finally {
|
| | | jedis.del(watchKey);
|
| | | jedis.unwatch();
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | }
|
| | |
| | | } finally {
|
| | | jedis.del(watchKey);
|
| | | jedis.unwatch();
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | }
|
| | |
| | | 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.dao.mybatis.ThreeSaleMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRank;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRankService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | | import com.yeshi.fanli.util.annotation.integral.IntegralGetFrequencyLimit;
|
| | | import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit;
|
| | | import com.yeshi.fanli.util.factory.integral.UserGetIntegralFromOrderRecordFactory;
|
| | |
|
| | | @Lazy
|
| | | @Service
|
| | |
| | |
|
| | | @Resource
|
| | | private IntegralTaskRankService integralTaskRankService;
|
| | |
|
| | | @Resource
|
| | | private UserGetIntegralFromOrderRecordService userGetIntegralFromOrderRecordService;
|
| | |
|
| | | private UserInfo getBossByUid(Long uid) {
|
| | | return threeSaleMapper.selectBoss(uid);
|
| | |
| | |
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | @IntegralGetFrequencyLimit(key = "'addShareInvite-'+#uid", time = 30)
|
| | | @Override
|
| | | public IntegralTaskRecord addShareInvite(Long uid) {
|
| | |
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inShopLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.taoLiJinBuy.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareSingleGoods.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareMultipleGoods.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareTLJGoods.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveRebateCoupon.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveFreeCoupon.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.giveTaoLiJin.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.closeRecommendGoods.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebate.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelOne.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.couponRebateLevelTwo.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Async()
|
| | | @Transactional
|
| | | @Override
|
| | | public void addRebateOrder(Long uid) {
|
| | | public void addRebateOrder(Long uid, String orderNo, int sourceType) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.rebateOrder.name());
|
| | | IntegralTaskRecord record = addEventStatistic(uid, TaskUniqueKeyEnum.rebateOrder.name());
|
| | | if (record != null) {
|
| | | userGetIntegralFromOrderRecordService.addRecord(
|
| | | UserGetIntegralFromOrderRecordFactory.create(UserGetIntegralFromOrderRecord.TYPE_RECIEVE_MONEY,
|
| | | uid, orderNo, sourceType, record.getGoldCoin()));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Async()
|
| | | @Transactional
|
| | | @Override
|
| | | public void addInviteOrderLevelOne(Long uid) {
|
| | | public void addInviteOrderLevelOne(Long uid, String orderNo, int sourceType) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelOne.name());
|
| | | IntegralTaskRecord record = addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelOne.name());
|
| | | if (record != null) {
|
| | | userGetIntegralFromOrderRecordService.addRecord(
|
| | | UserGetIntegralFromOrderRecordFactory.create(UserGetIntegralFromOrderRecord.TYPE_RECIEVE_MONEY,
|
| | | uid, orderNo, sourceType, record.getGoldCoin()));
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Async()
|
| | | @Transactional
|
| | | @Override
|
| | | public void addInviteOrderLevelTwo(Long uid) {
|
| | | public void addInviteOrderLevelTwo(Long uid, String orderNo, int sourceType) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelTwo.name());
|
| | | IntegralTaskRecord record = addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelTwo.name());
|
| | | if (record != null) {
|
| | | userGetIntegralFromOrderRecordService.addRecord(
|
| | | UserGetIntegralFromOrderRecordFactory.create(UserGetIntegralFromOrderRecord.TYPE_RECIEVE_MONEY,
|
| | | uid, orderNo, sourceType, record.getGoldCoin()));
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @IntegralGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Async()
|
| | | @Transactional
|
| | | @Override
|
| | | public void addShareOrder(Long uid) {
|
| | | public void addShareOrder(Long uid, String orderNo, int sourceType) {
|
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.shareOrder.name());
|
| | | IntegralTaskRecord record = addEventStatistic(uid, TaskUniqueKeyEnum.shareOrder.name());
|
| | | if (record != null) {
|
| | | userGetIntegralFromOrderRecordService.addRecord(
|
| | | UserGetIntegralFromOrderRecordFactory.create(UserGetIntegralFromOrderRecord.TYPE_RECIEVE_MONEY,
|
| | | uid, orderNo, sourceType, record.getGoldCoin()));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindWeiXin.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindPhone.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindTaoBao.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setWeiXinNum.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setGender.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setPortrait.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.setNickName.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.bindAlipay.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | addEventStatistic(uid, TaskUniqueKeyEnum.inviteActivate.name());
|
| | | } catch (Exception e) {
|
| | | //LogHelper.errorDetailInfo(e);
|
| | | // LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper;
|
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
|
| | | import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
|
| | | import com.yeshi.fanli.manager.util.AtomMethodCallInterface;
|
| | | import com.yeshi.fanli.manager.util.AtomMethodCallManager;
|
| | | import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Service
|
| | | public class UserGetIntegralFromOrderRecordServiceImpl implements UserGetIntegralFromOrderRecordService {
|
| | |
|
| | | @Resource
|
| | | private UserGetIntegralFromOrderRecordMapper userGetIntegralFromOrderRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private AtomMethodCallManager atomMethodCallManager;
|
| | |
|
| | | @Override
|
| | | public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType) {
|
| | | UserGetIntegralFromOrderRecord record = new UserGetIntegralFromOrderRecord();
|
| | | record.setEventType(eventType);
|
| | | record.setOrderNo(orderNo);
|
| | | record.setOrderSourceType(orderSourceType);
|
| | | record.setUid(uid);
|
| | | return userGetIntegralFromOrderRecordMapper.countByRecordInfo(record);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addRecord(UserGetIntegralFromOrderRecord record) throws UserGetIntegralFromOrderRecordException {
|
| | | if (record == null || record.getUid() == null || record.getEventType() == null
|
| | | || StringUtil.isNullOrEmpty(record.getOrderNo()) || record.getOrderSourceType() == null)
|
| | | throw new UserGetIntegralFromOrderRecordException(1, "信息不完整");
|
| | |
|
| | | String key = String.format("rs-%s",
|
| | | StringUtil.Md5(String.format("UserGetIntegralFromOrderRecord-addRecord-%s-%s-%s-%s", record.getUid(),
|
| | | record.getEventType(), record.getOrderNo(), record.getOrderSourceType())));
|
| | |
|
| | | atomMethodCallManager.excute(key, new AtomMethodCallInterface() {
|
| | |
|
| | | @Override
|
| | | public void excute() {
|
| | | long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(),
|
| | | record.getOrderNo(), record.getOrderSourceType());
|
| | | if (count > 0)
|
| | | return;
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | userGetIntegralFromOrderRecordMapper.insertSelective(record);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | |
|
| | | public interface HongBaoV2Service {
|
| | |
|
| | |
| | | * @return 0-未添加也未更新 1-只添加 2-只更新 12-有添加也有更新
|
| | | * @throws HongBaoException
|
| | | */
|
| | | public int addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException;
|
| | | public int addHongBao(List<CommonOrder> commonOrder, int type) throws HongBaoException,UserAccountException ;
|
| | |
|
| | | /**
|
| | | * 奖金列表(1.4.9之前的版本)
|
| | |
| | | * 返利订单
|
| | | * @param uid
|
| | | */
|
| | | public void addRebateOrder(Long uid);
|
| | | public void addRebateOrder(Long uid,String orderNo,int sourceType);
|
| | |
|
| | | /**
|
| | | * 一级邀请订单
|
| | | * @param uid
|
| | | */
|
| | | public void addInviteOrderLevelOne(Long uid);
|
| | | public void addInviteOrderLevelOne(Long uid,String orderNo,int sourceType);
|
| | |
|
| | | /**
|
| | | * 二级邀请订单
|
| | | * @param uid
|
| | | */
|
| | | public void addInviteOrderLevelTwo(Long uid);
|
| | | public void addInviteOrderLevelTwo(Long uid,String orderNo,int sourceType);
|
| | |
|
| | |
|
| | | /**
|
| | | * 分享订单
|
| | | * @param uid
|
| | | */
|
| | | public void addShareOrder(Long uid);
|
| | | public void addShareOrder(Long uid,String orderNo,int sourceType);
|
| | |
|
| | | /**
|
| | | * 微信授权
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user.integral;
|
| | |
|
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
|
| | | import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
|
| | |
|
| | | public interface UserGetIntegralFromOrderRecordService {
|
| | |
|
| | | /**
|
| | | * 根据事件类型,用户,订单信息检索
|
| | | * @param eventType
|
| | | * @param uid
|
| | | * @param orderNo
|
| | | * @param orderSourceType
|
| | | * @return
|
| | | */
|
| | | public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType);
|
| | |
|
| | | /**
|
| | | * |
| | | * @param record
|
| | | */
|
| | | public void addRecord(UserGetIntegralFromOrderRecord record) throws UserGetIntegralFromOrderRecordException;
|
| | |
|
| | | }
|
| | |
| | | import net.sf.json.JSONArray;
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | | import redis.clients.jedis.params.SetParams;
|
| | |
|
| | | //抢红包采用的redis
|
| | | @Component
|
| | |
| | | */
|
| | | private void setString(String key, String value) {
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | SetParams params=new SetParams().nx().ex(60);
|
| | | jedis.set(key, value, params);
|
| | | try {
|
| | | jedis.set(key, value);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | try {
|
| | | jedis.del(key);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | try {
|
| | | jedis.setex(key, seconds, value);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | return jedis.get(key);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | jedis.incr(key);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | jedis.expire(key, seconds);
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | else
|
| | | return false;
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | else
|
| | | return false;
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | jedis.close();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | // 查询对应的订单号
|
| | | Long mainHongBaoId = hongBaoV2.getId();
|
| | | if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null)
|
| | | mainHongBaoId = hongBaoV2.getParent().getId();
|
| | |
|
| | | HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId);
|
| | | if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null)
|
| | | return;
|
| | | CommonOrder commonOrder = hongbaoOrder.getCommonOrder();
|
| | |
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单
|
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
|
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单
|
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
|
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请
|
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId());
|
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public static boolean greaterThan_2_1(String platform, String versionCode) {
|
| | | if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 52))
|
| | | || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 71)))
|
| | | || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 75)))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | public static DaTaoKeDetailV2 getGoodsDetailByGoodsId(Long goodsId) {
|
| | | TaoKeAppInfo app = getRandomApp();
|
| | | Map<String, String> params = new TreeMap<>();
|
| | | params.put("version", "v1.1.1");
|
| | | params.put("appKey", app.getAppKey());
|
| | | params.put("goodsId", goodsId + "");
|
| | | params.put("sign", getSign(params, app.getAppSecret()));
|
| | | String result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-goods-details", params,
|
| | | new HashMap<>());
|
| | | System.out.println(result);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject dataJson = json.optJSONObject("data");
|
| | | if (dataJson != null) {
|
| | | return parseDaTaoKeDetailV2(dataJson);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static DaTaoKeGoodsResult search(String key, List<Integer> cidList, BigDecimal priceLowerLimit,
|
| | | BigDecimal priceUpperLimit, int page, int pageSize, Integer sort) {
|
New file |
| | |
| | | package com.yeshi.fanli.util.factory.integral;
|
| | |
|
| | | import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
|
| | |
|
| | | public class UserGetIntegralFromOrderRecordFactory {
|
| | |
|
| | | public static UserGetIntegralFromOrderRecord create(int eventType, Long uid, String orderNo, int sourceType,int integralCount) {
|
| | | UserGetIntegralFromOrderRecord record=new UserGetIntegralFromOrderRecord();
|
| | | record.setEventType(eventType);
|
| | | record.setIntegralCount(integralCount);
|
| | | record.setUid(uid);
|
| | | record.setOrderSourceType(sourceType);
|
| | | record.setOrderNo(orderNo);
|
| | | return record;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return url;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取淘宝的商品详情
|
| | | * |
| | | * @param actionId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoGoodsBrief getSimpleGoodsBrief(Long actionId) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("itemNumId", actionId + "");
|
| | |
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | GetMethod gm = new GetMethod(url);
|
| | | String result = null;
|
| | |
| | | JSONObject resultOBJ = JSONObject.fromObject(result);
|
| | | if (resultOBJ.optJSONObject("data") != null) {
|
| | | data = resultOBJ.optJSONObject("data");
|
| | | JSONObject item = data.optJSONObject("item");
|
| | | JSONObject seller = data.optJSONObject("seller");
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setTitle(item.optString("title"));
|
| | | goods.setAuctionId(item.optLong("itemId"));
|
| | | goods.setTitle(item.optString("title"));
|
| | | if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) {
|
| | | String picture = item.optJSONArray("images").optString(0);
|
| | | goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture);
|
| | | if (data != null) {
|
| | | JSONObject item = data.optJSONObject("item");
|
| | | if (item != null) {
|
| | | JSONObject seller = data.optJSONObject("seller");
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setTitle(item.optString("title"));
|
| | | goods.setAuctionId(item.optLong("itemId"));
|
| | | goods.setTitle(item.optString("title"));
|
| | | if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) {
|
| | | String picture = item.optJSONArray("images").optString(0);
|
| | | goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture);
|
| | | }
|
| | | if (seller != null) {
|
| | | goods.setSellerId(seller.optLong("shopId"));
|
| | | String shopType = seller.optString("shopType");
|
| | | if ("B".equalsIgnoreCase(shopType)) {
|
| | | goods.setUserType(1);
|
| | | } else
|
| | | goods.setUserType(0);
|
| | | goods.setShopTitle(seller.optString("shopName"));
|
| | | }
|
| | | return goods;
|
| | | }
|
| | | }
|
| | | goods.setSellerId(seller.optLong("shopId"));
|
| | | String shopType = seller.optString("shopType");
|
| | | if ("B".equalsIgnoreCase(shopType)) {
|
| | | goods.setUserType(1);
|
| | | } else
|
| | | goods.setUserType(0);
|
| | |
|
| | | goods.setShopTitle(seller.optString("shopName"));
|
| | | return goods;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | |
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.taobao.api.ApiException;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO;
|
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport;
|
| | | import com.yeshi.fanli.entity.taobao.RelateGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.SearchShopFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<RelateGoods> getRelateGoodsList(long auctionId) throws ApiException {
|
| | | List<RelateGoods> resultList = new ArrayList<>();
|
| | | List<TaoBaoGoodsBrief> list = getRelationGoodsRecommend(auctionId, 9);
|
| | | for (TaoBaoGoodsBrief goods : list) {
|
| | | if (goods != null) {
|
| | | RelateGoods rg = new RelateGoods();
|
| | | rg.setId(goods.getAuctionId() + "");
|
| | | rg.setPicUrl(goods.getPictUrl());
|
| | | rg.setTitle(goods.getTitle());
|
| | | rg.setZkPrice(goods.getZkPrice().toString());
|
| | | rg.setUrl(goods.getAuctionUrl());
|
| | | resultList.add(rg);
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取券详细信息
|
| | | *
|
| | |
| | | } else
|
| | | return null;
|
| | | return info;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取关联商品推荐
|
| | | * |
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoGoodsBrief> getRelationGoodsRecommend(long auctionId, int count) {
|
| | | List<TaoBaoGoodsBrief> list = new ArrayList<>();
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.item.recommend.get");
|
| | | map.put("num_iid", auctionId + "");
|
| | | map.put("count", count + "");
|
| | | map.put("platform", 2 + "");
|
| | | map.put("fields",
|
| | | "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url");
|
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
|
| | | JSONObject data = JSONObject.fromObject(resultStr);
|
| | | if (data.optJSONObject("tbk_item_recommend_get_response") != null) {
|
| | | if (data.optJSONObject("tbk_item_recommend_get_response").optJSONObject("results") == null)
|
| | | return list;
|
| | | JSONArray array = data.optJSONObject("tbk_item_recommend_get_response").optJSONObject("results")
|
| | | .optJSONArray("n_tbk_item");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setAuctionId(item.optLong("num_iid"));
|
| | | goods.setTitle(item.optString("title"));
|
| | | goods.setZkPrice(new BigDecimal(item.optString("zk_final_price")));
|
| | | goods.setAuctionUrl(item.optString("item_url"));
|
| | | goods.setPictUrl(item.optString("pict_url"));
|
| | | goods.setSalesCount(item.optString("volume"));
|
| | | goods.setUserType(item.optInt("user_type"));
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | public static void taoQiangGou() {
|
| | |
| | | if (response != null && response.optJSONObject("result_list") != null) {
|
| | | JSONArray array = response.optJSONObject("result_list").optJSONArray("map_data");
|
| | | if (array != null) {
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoGoodsBrief goods = parseWuLiaoItemFromMaterialId(item);
|
| | | if (goods != null)
|
| | | goodsList.add(goods);
|
| | | }
|
| | |
|
| | | pageSize = array.size();
|
| | | }
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static void guessLikeByAuctionId(Long auctionId) {
|
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId,int count) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.optimus.material");
|
| | | map.put("item_id", auctionId + "");
|
| | | map.put("page_size", 20 + "");
|
| | | map.put("page_size", count + "");
|
| | | map.put("page_no", 1 + "");
|
| | | map.put("material_id", 13256 + "");
|
| | | |
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | JSONObject resultJSON = null;
|
| | | try {
|
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, true);
|
| | | System.out.println(resultJSON);
|
| | |
|
| | | JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response");
|
| | | if (response != null && response.optJSONObject("result_list") != null) {
|
| | | JSONArray array = response.optJSONObject("result_list").optJSONArray("map_data");
|
| | | if (array != null) {
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoGoodsBrief goods = parseWuLiaoItemFromMaterialId(item);
|
| | | if (goods != null)
|
| | | goodsList.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return goodsList;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | redis.addr=192.168.1.253
|
| | | redis.port=6379
|
| | | redis.auth=123456
|
| | | redis.max_active=1024
|
| | | redis.max_total=1024
|
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | | redis.timeout=5000
|
| | |
| | | redis.addr=127.0.0.1
|
| | | redis.port=6379
|
| | | redis.auth=Yeshi2016@
|
| | | redis.max_active=1024
|
| | | redis.max_total=1024
|
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | | redis.timeout=5000
|
| | |
| | | redis.addr=172.16.16.15
|
| | | redis.port=6379
|
| | | redis.auth=crs-43yhgz0i:Yeshi2016@
|
| | | redis.max_active=1024
|
| | | redis.max_total=1024
|
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | | redis.timeout=5000
|
| | |
| | | redis.addr=172.16.16.15
|
| | | redis.port=6379
|
| | | redis.auth=crs-43yhgz0i:Yeshi2016@
|
| | | redis.max_active=1024
|
| | | redis.max_total=1024
|
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | | redis.timeout=5000
|
| | |
| | |
|
| | |
|
| | | <!-- redis连接池 -->
|
| | | <bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig">
|
| | | <property name="maxActive" value="${redis.max_active}"></property>
|
| | | <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
|
| | | <property name="maxTotal" value="${redis.max_total}"></property>
|
| | | <property name="maxIdle" value="${redis.max_idle}"></property>
|
| | | <property name="maxWait" value="${redis.max_wait}"></property>
|
| | | <property name="testOnBorrow" value="${redis.test_on_borrow}"></property>
|
| | | </bean>
|
| | |
|
| | | <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
|
| | | <constructor-arg name="poolConfig" ref="jedisConfig"></constructor-arg>
|
| | | <constructor-arg name="poolConfig" ref="jedisPoolConfig"></constructor-arg>
|
| | | <constructor-arg name="host" value="${redis.addr}"></constructor-arg>
|
| | | <constructor-arg name="port" value="${redis.port}"></constructor-arg>
|
| | | <constructor-arg name="timeout" value="${redis.timeout}"></constructor-arg>
|
| | | <constructor-arg name="password" value="${redis.auth}"></constructor-arg>
|
| | | </bean>
|
| | |
|
| | | <!-- redis连接工厂 -->
|
| | | <bean id="connectionFactory"
|
| | | class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
| | | <property name="hostName" value="${redis.addr}"></property>
|
| | | <property name="port" value="${redis.port}"></property>
|
| | | <property name="password" value="${redis.auth}"></property>
|
| | | <property name="poolConfig" ref="jedisConfig"></property>
|
| | | </bean>
|
| | |
|
| | | <!-- redis操作模板,这里采用尽量面向对象的模板 -->
|
| | | <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
|
| | | <property name="connectionFactory" ref="connectionFactory" />
|
| | | <property name="keySerializer">
|
| | | <bean
|
| | | class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
| | | </property>
|
| | | <property name="valueSerializer">
|
| | | <bean
|
| | | class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
|
| | | </property>
|
| | | </bean>
|
| | |
|
| | |
|
| | |
| | | <dependency>
|
| | | <groupId>redis.clients</groupId>
|
| | | <artifactId>jedis</artifactId>
|
| | | <version>2.1.0</version>
|
| | | <version>3.1.0</version>
|
| | | <type>jar</type>
|
| | | <scope>compile</scope>
|
| | | </dependency>
|
| | |
| | | <groupId>com.aliyun.openservices</groupId>
|
| | | <artifactId>ons-client</artifactId>
|
| | | <version>1.8.0.Final</version>
|
| | | </dependency>
|
| | |
|
| | | <dependency>
|
| | | <groupId>org.apache.rocketmq</groupId>
|
| | | <artifactId>rocketmq-client</artifactId>
|
| | | <version>4.5.1</version>
|
| | | </dependency>
|
| | | <dependency>
|
| | | <groupId>org.apache.rocketmq</groupId>
|
| | | <artifactId>rocketmq-acl</artifactId>
|
| | | <version>4.5.1</version>
|
| | | </dependency>
|
| | |
|
| | | <!-- 分步式任务 -->
|