fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java
@@ -809,7 +809,7 @@ long currentTime = java.lang.System.currentTimeMillis(); if (endDay.getTime() > currentTime && !vip) { UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null); sourceType, null); if (couponRecord == null) { orderRebateVO.setCoupon(true); orderRebateVO.setCouponType(1); fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponRecordMapper.java
@@ -25,7 +25,7 @@ * @param listCouponId * @return */ UserSystemCouponRecord getRecordByOrderNo(@Param("orderNo") String orderNo, @Param("state") Integer state); UserSystemCouponRecord getRecordByOrderNo(@Param("orderNo") String orderNo, @Param("source")Integer source, @Param("state") Integer state); /** fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponRecord.java
@@ -35,7 +35,7 @@ // 商品来源 @Column(name = "ucr_good_source") private int goodSource; private Integer goodSource; // 用户券 @Column(name = "ucr_user_coupon_id") @@ -77,11 +77,11 @@ this.goodId = goodId; } public int getGoodSource() { public Integer getGoodSource() { return goodSource; } public void setGoodSource(int goodSource) { public void setGoodSource(Integer goodSource) { this.goodSource = goodSource; } fanli/src/main/java/com/yeshi/fanli/job/UserRankingsJob.java
File was deleted fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewGoodsJob.java
File was deleted fanli/src/main/java/com/yeshi/fanli/job/goods/PullNewJob.java
New file @@ -0,0 +1,152 @@ package com.yeshi.fanli.job.goods; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.annotation.Resource; import org.apache.commons.beanutils.PropertyUtils; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.yeshi.utils.DateUtil; import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO; import com.yeshi.fanli.entity.bus.user.UserRankings; import com.yeshi.fanli.entity.goods.PullNewGoods; import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail; import com.yeshi.fanli.service.inter.goods.PullNewGoodsService; import com.yeshi.fanli.service.inter.user.UserRankingsService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.taobao.HaoDanKuApiUtil; @Component public class PullNewJob { @Resource private UserRankingsService userRankingsService; @Resource private PullNewGoodsService pullNewGoodsService; /** * 拉新商品 */ @Scheduled(cron = "0 30 1 * * ? ") private void addPullNewGoods() { if (!Constant.IS_TASK) { return; } Integer array[] = {1,2,3,4,5,6,7,8,9,10,11,12,15}; for (Integer catId: array) { Integer minId = 1; while (minId != null) { HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().getHighitems(minId, 100, catId); if (dto == null || dto.getMinId() == null) { break; } minId = dto.getMinId(); List<HDKGoodsDetail> goodsList = dto.getGoodsList(); if (goodsList == null || goodsList.size() == 0) { break; } for (HDKGoodsDetail goods : goodsList) { // 佣金比例大于50% if (goods.getTkrates() == null || goods.getTkrates() < 50) continue; // 是否存在券 if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0) continue; // 商品券后价大于9.9元 if (goods.getItemendprice() == null || goods.getItemendprice() <= 9.9) continue; PullNewGoods pullNewGoods = new PullNewGoods(); try { PropertyUtils.copyProperties(pullNewGoods, goods); } catch (Exception e) { e.printStackTrace(); continue; } pullNewGoodsService.saveGoods(pullNewGoods); } } } } // 每天00点10执行 : 更改排行榜上的奖金 @Scheduled(cron = "0 15 0 * * ? ") public void updateReward() { if (!Constant.IS_TASK) { return; } // 更新人数 int showNum = 15; // 每日增幅 double rangeAmount = 100; try { List<UserRankings> listExist = null; // 每月1号归0 int currentDate = DateUtil.getCurrentDate(); if (currentDate != 1) listExist = userRankingsService.getRankList(0, showNum); // 清理数据 userRankingsService.clearShareReward(); // 假用户数量 int count = (int) userRankingsService.queryCount(null, null, null); // 随机显示新的人 Random random = new Random(); List<Long> listId = new ArrayList<Long>(); while (listId.size() < showNum) { long id = random.nextInt(count); if (!listId.contains(id)) { listId.add(id); } } List<UserRankings> listNew = userRankingsService.listQueryByIds(listId); if (listExist == null || listExist.size() == 0) { for (UserRankings user : listNew) { // 浮动金额 double amount = Math.random() * rangeAmount; if (amount < 0.5) { amount = 0.5; } user.setShareReward(new BigDecimal(amount)); } } else { for (int i = 0; i < listNew.size(); i ++) { UserRankings user = listNew.get(i); // 浮动金额 BigDecimal shareReward = null; if (i < listExist.size()) { shareReward = listExist.get(i).getShareReward(); } if (shareReward == null) shareReward = BigDecimal.ZERO; // 浮动金额 double amount = Math.random() * rangeAmount; user.setShareReward(shareReward.add(BigDecimal.valueOf(amount))); } } // 批量更新昨日数据-移除排行榜 userRankingsService.updateBatchSelective(listNew); } catch (Exception e) { e.printStackTrace(); } } } fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponRecordMapper.xml
@@ -70,7 +70,10 @@ <select id="getRecordByOrderNo" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_system_coupon_record` cd LEFT JOIN `yeshi_ec_user_system_coupon` uc ON uc.`usc_id` = cd.`ucr_user_coupon_id` WHERE cd.`ucr_order_no` = #{orderNo} WHERE cd.`ucr_order_no` = #{orderNo} <if test="state != null"> AND cd.`ucr_good_source` = #{source} </if> <if test="state != null"> AND cd.`ucr_state` = #{state} </if> fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponRecordServiceImpl.java
@@ -44,8 +44,8 @@ } @Override public UserSystemCouponRecord getRecordByOrderNo(String orderNo, Integer state) { return userSystemCouponRecordMapper.getRecordByOrderNo(orderNo, state); public UserSystemCouponRecord getRecordByOrderNo(String orderNo, Integer source, Integer state) { return userSystemCouponRecordMapper.getRecordByOrderNo(orderNo, source, state); } @Override fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1217,7 +1217,7 @@ // 查询记录 UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, UserSystemCouponRecord.STATE_SUCCESS); sourceType, UserSystemCouponRecord.STATE_SUCCESS); if (record == null) { throw new UserSystemCouponException(1, "没有使用券记录"); } @@ -1295,7 +1295,7 @@ } // 查询记录 UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null); UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, null); if (record == null) { throw new UserSystemCouponException(1, "没有使用券记录"); } @@ -1491,18 +1491,16 @@ @Transactional(rollbackFor = Exception.class) @Override public void updateStateByDrawback(String orderNo) throws Exception { public void updateStateByDrawback(String orderNo, Integer sourceType) throws Exception { if (orderNo == null || orderNo.trim().length() == 0) { return; } UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null); UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, null); if (record == null) { return; } record.setOrderNo(orderNo); record.setUpdateTime(new Date()); record.setState(UserSystemCouponRecord.STATE_FAIL_DRAWBACK); userSystemCouponRecordService.updateByPrimaryKeySelective(record); @@ -1513,18 +1511,15 @@ @Transactional(rollbackFor = Exception.class) @Override public void updateStateByArrivalAccount(String orderNo) throws Exception { public void updateStateByArrivalAccount(String orderNo, Integer sourceType) throws Exception { if (orderNo == null || orderNo.trim().length() == 0) { return; } UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, 2); UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, 2); if (record == null) { return; } record.setOrderNo(orderNo); record.setUpdateTime(new Date()); record.setState(UserSystemCouponRecord.STATE_SUCCESS); userSystemCouponRecordService.updateByPrimaryKeySelective(record); @@ -1537,15 +1532,13 @@ @Transactional(rollbackFor = Exception.class) @Override public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId) public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long gId,Integer sourceType) throws Exception { boolean isfree = false; if (uid == null || payment == null || auctionId == null || orderNo == null || orderNo.trim().length() == 0) { if (uid == null || payment == null || gId == null || orderNo == null || orderNo.trim().length() == 0) { throw new Exception("传递参数不能为空"); } boolean isfree = false; // 查询等待匹配的券记录 List<UserSystemCouponRecord> list = userSystemCouponRecordService.getRecordByState(uid, UserSystemCouponRecord.STATE_WAIT); @@ -1559,7 +1552,11 @@ for (UserSystemCouponRecord userSystemCouponRecord : list) { Long goodId = userSystemCouponRecord.getGoodId(); if (auctionId.equals(goodId)) { Integer goodSource = userSystemCouponRecord.getGoodSource(); if (goodSource == null) continue; if (gId.equals(goodId) && goodSource == sourceType) { matching = true; // 匹配成功 record = userSystemCouponRecord; break; @@ -1568,7 +1565,7 @@ // 商品匹配成功 if (matching) { record.setGoodSource(sourceType); record.setOrderNo(orderNo); record.setUpdateTime(new Date()); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponRecordService.java
@@ -14,7 +14,7 @@ public int updateByPrimaryKey(UserSystemCouponRecord record); public UserSystemCouponRecord getRecordByOrderNo(String orderNo, Integer state); public UserSystemCouponRecord getRecordByOrderNo(String orderNo, Integer source, Integer state); public List<UserSystemCouponRecord> getRecordByOrderNoList(Integer source, List<String> list); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -138,23 +138,21 @@ * @return 免单成功 true * @throws Exception */ public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId) throws Exception; public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId , Integer sourceType) throws Exception; /** * 订单退款更新 券记录状态并退回券 * @param orderNo */ public void updateStateByDrawback(String orderNo) throws Exception; public void updateStateByDrawback(String orderNo, Integer sourceType) throws Exception; /** * 红包到账 -- 更新券使用状态 -改为使用成功 * @param orderNo * @throws Exception */ public void updateStateByArrivalAccount(String orderNo) throws Exception; public void updateStateByArrivalAccount(String orderNo, Integer sourceType) throws Exception; /** * 统计今日抽奖中的券数量