fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -55,6 +55,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.TaoBaoShop; import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; @@ -89,6 +90,7 @@ import com.yeshi.fanli.service.inter.order.OrderService; import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService; import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.user.ShamUserService; import com.yeshi.fanli.service.inter.user.TBPidService; @@ -218,6 +220,9 @@ @Resource private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; @Resource private TaoBaoShopService taoBaoShopService; @RequestMapping(value = "getHonestList") public void getHonestList(AcceptData acceptData, PrintWriter out) { @@ -2037,7 +2042,14 @@ } } // 店铺 goodsJson.put("shopInfo", tbShopInfo); if ("android".equalsIgnoreCase(acceptData.getPlatform())&&Integer.parseInt(acceptData.getVersion()) >= 40) { TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); if (shop != null) goodsJson.put("shopInfo", shop); } else { goodsJson.put("shopInfo", tbShopInfo); } goodsJson.put("fanliValid", true);// 是否有返利 // 分享路径 fanli/src/main/java/com/yeshi/fanli/dto/money/UserMoneyChangeDTO.java
@@ -10,15 +10,15 @@ */ public class UserMoneyChangeDTO { private Long uid; private BigDecimal chnageMoney;// 变化的资金金额 private BigDecimal changeMoney;// 变化的资金金额 public UserMoneyChangeDTO() { } public UserMoneyChangeDTO(Long uid, BigDecimal chnageMoney) { public UserMoneyChangeDTO(Long uid, BigDecimal changeMoney) { this.uid = uid; this.chnageMoney = chnageMoney; this.changeMoney = changeMoney; } public Long getUid() { @@ -29,11 +29,12 @@ this.uid = uid; } public BigDecimal getChnageMoney() { return chnageMoney; public BigDecimal getChangeMoney() { return changeMoney; } public void setChnageMoney(BigDecimal chnageMoney) { this.chnageMoney = chnageMoney; public void setChangeMoney(BigDecimal changeMoney) { this.changeMoney = changeMoney; } } fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java
@@ -421,7 +421,7 @@ List<TaoBaoOrder> taoBaoOrderList = taoBaoOrderService.getTaoBaoOrderByOrderId(lo.getOrderId()); // 清除频率限制 if (taoBaoOrderList != null && taoBaoOrderList.size() > 0) { String key = "addorder-" + lo.getOrderId(); String key = "addorderqueue-" + lo.getOrderId(); redisManager.removeCommonString(key); addOrder(taoBaoOrderList); LogHelper.test("自动处理淘宝订单:" + lo.getOrderId()); fanli/src/main/java/com/yeshi/fanli/service/impl/money/UserMoneyDebtServiceImpl.java
@@ -209,4 +209,12 @@ } } @Override public boolean isHaveDebtToRepay(Long uid) { List<UserMoneyDebt> debtList = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 1); if (debtList != null && debtList.size() > 0) return true; return false; } } fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoShopServiceImpl.java
@@ -19,6 +19,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.db.MongoDBManager; import com.yeshi.fanli.util.taobao.TaoBaoShopUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.vo.brand.TaoBaoShopVO; @Service @@ -26,7 +27,7 @@ @Resource private MongoDBManager mongoDBManager; @Resource private TaoBaoShopMapper taoBaoShopMapper; @@ -55,32 +56,29 @@ LogHelper.test("获取店铺信息耗时:" + (System.currentTimeMillis() - startTime)); return shopInfo; } @Override public TaoBaoShop selectByPrimaryKey(Long id) { return taoBaoShopMapper.selectByPrimaryKey(id); } @Override public int insertSelective(TaoBaoShop record) { return taoBaoShopMapper.insertSelective(record); } @Override public int updateByPrimaryKeySelective(TaoBaoShop record) { return taoBaoShopMapper.updateByPrimaryKeySelective(record); } @Override public void changeInfo(MultipartFile file, Long id, String shopName) { TaoBaoShop taoBaoShop = taoBaoShopMapper.selectByPrimaryKey(id); if (taoBaoShop == null) { return; } String fileLink = null; if (file != null) { try { @@ -89,61 +87,67 @@ e.printStackTrace(); } } TaoBaoShop updateShop = new TaoBaoShop(); if (!StringUtil.isNullOrEmpty(fileLink)) { updateShop.setShopIconCustom(fileLink); // 删除图片 String shopIconCustom = taoBaoShop.getShopIconCustom(); if (!StringUtil.isNullOrEmpty(shopIconCustom)) { COSManager.getInstance().deleteFile(shopIconCustom); } } if (StringUtil.isNullOrEmpty(shopName) || "null".equalsIgnoreCase(shopName)) { shopName = null; } updateShop.setId(id); updateShop.setShopNameCustom(shopName); taoBaoShopMapper.updateByPrimaryKeySelective(updateShop); } /** * 上传图片 * * @param file * @return * @throws Exception */ public String uploadPicture(MultipartFile file) throws Exception { // 文件解析 // 文件解析 InputStream inputStream = file.getInputStream(); String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); // 文件路径 String filePath="/img/TaoBaoShop/"+UUID.randomUUID().toString().replace("-", "") + "." + type; String filePath = "/img/TaoBaoShop/" + UUID.randomUUID().toString().replace("-", "") + "." + type; // 执行上传 String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); return fileLink; } @Override public List<TaoBaoShopVO> listBrandShopinfo(long start, int count, Long cid) { return taoBaoShopMapper.listBrandShopinfo(start, count, cid); } @Override public long countBrandShopinfo(Long cid) { return taoBaoShopMapper.countBrandShopinfo(cid); } @Override public TaoBaoShop getTaoBaoShop(Long auctionId, Long sellerId) { TaoBaoShop shop = taoBaoShopMapper.selectByPrimaryKey(sellerId); if (shop != null) return shop; shop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(auctionId); if (shop != null) taoBaoShopMapper.insert(shop); return shop; } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractServiceImpl.java
@@ -47,6 +47,7 @@ import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SystemConfigService; import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service; import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService; import com.yeshi.fanli.service.inter.push.PushService; import com.yeshi.fanli.service.inter.user.ExtractRecordService; @@ -123,6 +124,9 @@ @Resource private UserAccountBindingHistoryService userAccountBindingHistoryService; @Resource private UserMoneyDebtService userMoneyDebtService; @Transactional public Integer addExtract(Extract extract) { @@ -506,6 +510,10 @@ Long count = hongBaoV2Mapper.countByUidAndState(uid, HongBao.STATE_YILINGQU); if (count == null || count == 0) throw new ExtractException(1, "没有已到账的红包"); // 查询是否有欠账 boolean isDebt = userMoneyDebtService.isHaveDebtToRepay(uid); if (isDebt) throw new ExtractException(3, "有欠账未还"); // 获取所有收入所得 BigDecimal hongBaoMoney = hongBaoV2Service.computeMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU); fanli/src/main/java/com/yeshi/fanli/service/inter/money/UserMoneyDebtService.java
@@ -30,12 +30,21 @@ * @param debt * @throws UserMoneyDebtException */ public void repayDebt(UserMoneyDebt debt,BigDecimal money) throws UserMoneyDebtException; public void repayDebt(UserMoneyDebt debt, BigDecimal money) throws UserMoneyDebtException; /** * 偿还 * * @param uid */ public void repayDebt(Long uid); /** * 是否有账务待还 * * @param uid * @return */ public boolean isHaveDebtToRepay(Long uid); } fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoShopService.java
@@ -21,35 +21,43 @@ /** * 店铺信息 * * @param id * @return */ public TaoBaoShop selectByPrimaryKey(Long id); /** * 获取店铺信息 * * @param auctionId * @param sellerId * @return */ public TaoBaoShop getTaoBaoShop(Long auctionId, Long sellerId); public int insertSelective(TaoBaoShop record); public int updateByPrimaryKeySelective(TaoBaoShop record); /** * 修改店铺信息 * * @param file * @param id * @param shopName */ public void changeInfo(MultipartFile file, Long id, String shopName); /** * 查询店铺信息、并返回钱3个商品数量 * * @param start * @param count * @param cid * @return */ public List<TaoBaoShopVO> listBrandShopinfo(long start, int count, Long cid); long countBrandShopinfo(Long cid); } fanli/src/main/java/com/yeshi/fanli/util/RedisManager.java
@@ -253,7 +253,7 @@ long count = jedis.incr(key); if (count == 1) jedis.expire(key, 5); if (count >= 100) if (count >= 10) return true; else return false; fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -1,5 +1,6 @@ package com.yeshi.fanli.util; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -15,6 +16,7 @@ import org.yeshi.utils.tencentcloud.COSManager; import org.yeshi.utils.tencentcloud.entity.COSInitParams; import com.yeshi.fanli.dto.money.UserMoneyChangeDTO; import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo; import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.ThreeSale; @@ -27,6 +29,7 @@ import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService; import com.yeshi.fanli.service.inter.lable.LabelService; import com.yeshi.fanli.service.inter.lable.QualityFactoryService; import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; import com.yeshi.fanli.service.inter.order.OrderProcessService; import com.yeshi.fanli.service.inter.push.IOSPushService; import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService; @@ -34,6 +37,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager; import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager; /** * 系统初始化 @@ -80,6 +84,9 @@ @Resource private RedisManager redisManager; @Resource private UserMoneyDebtService userMoneyDebtService; private static boolean isInited = false; public void onApplicationEvent(ContextRefreshedEvent arg0) { @@ -108,6 +115,7 @@ doPushIOS();// 处理发送IOS消息 doThreeSaleUserCouponJob();// 处理邀请队列 doUpdateGoodsJob(); doUserMoneyDebtJob();// 债务偿还 } else if (!Constant.IS_TEST) { initScheduler();// 启动定时任务 // @@ -481,4 +489,45 @@ }); } /** * 用户借贷处理 */ public void doUserMoneyDebtJob() { executor.execute(new Runnable() { @Override public void run() { while (true) { try { Map<String, UserMoneyChangeDTO> map = UserMoneyChangeCMQManager.getInstance() .consumeQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, 16); if (map != null) { Iterator<String> its = map.keySet().iterator(); while (its.hasNext()) { String key = its.next(); try { UserMoneyChangeDTO dto = map.get(key); if (dto != null && dto.getChangeMoney().compareTo(new BigDecimal(0)) > 0) { userMoneyDebtService.repayDebt(dto.getUid()); } UserMoneyChangeCMQManager.getInstance() .deleteQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, key); } catch (Exception e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } } } catch (Exception e) { LogHelper.error("还款出错:" + e.getMessage()); } } } }); } } fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1329,9 +1329,9 @@ * @return */ public static String getGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) { if (goodsBrief != null && goodsBrief.getMaterialLibType() != null && goodsBrief.getMaterialLibType() == 0) return "¥0.00"; else // if (goodsBrief != null && goodsBrief.getMaterialLibType() != null && goodsBrief.getMaterialLibType() == 0) // return "¥0.00"; // else return "¥" + getGoodsHongBaoMoney(goodsBrief, rate).toString(); } @@ -1806,19 +1806,19 @@ shop.setUserType(0); shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); return shop; } /** * 根据卖家id获取店铺链接 * * @param sellerId * @return */ public static String getShopLink(Long sellerId) { return "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + sellerId; return "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + sellerId; } public static void main(String[] args) { String s = channelMap.get("3");