admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PullNewGoodsServiceImpl.java
@@ -1,88 +1,88 @@
package com.yeshi.fanli.service.impl.goods;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.goods.PullNewGoodsDao;
import com.yeshi.fanli.entity.goods.PullNewGoods;
import com.yeshi.goods.facade.entity.taobao.HDKGoodsDetail;
import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
@Service
public class PullNewGoodsServiceImpl implements PullNewGoodsService {
   @Resource
   private PullNewGoodsDao pullNewGoodsDao;
   @Resource
   private RedPackConfigService redPackConfigService;
   @Override
   public void saveGoods(PullNewGoods pullNewGoods) {
      if (pullNewGoods == null) {
         return;
      }
      pullNewGoodsDao.save(pullNewGoods);
   }
   @Override
   public List<PullNewGoods> listQuery(int start, int count) {
      return pullNewGoodsDao.listQuery(start, count);
   }
   @Override
   public long countQuery() {
      return pullNewGoodsDao.countQuery();
   }
   @Override
   public void updateGoods(HDKGoodsDetail goods) {
      if (goods == null)
         return;
      List<PullNewGoods> list = pullNewGoodsDao.getByItemid(goods.getItemid());
      if (list == null || list.size() == 0)
         return;
       double limitRate =  Double.valueOf(redPackConfigService.getValueByKey("goods_reate_limit"));
       double limitPrice =  Double.valueOf(redPackConfigService.getValueByKey("goods_pay_ment_limit"));
      // 佣金比例大于50%
      if (goods.getTkrates() == null || goods.getTkrates() < limitRate)
         return;
      // 是否存在券
      if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
         return;
      // 商品券后价大于9.9元
      if (goods.getItemendprice() == null || goods.getItemendprice() < limitPrice)
         return;
      PullNewGoods pullNewGoods = new PullNewGoods();
      try {
         PropertyUtils.copyProperties(pullNewGoods, goods);
      } catch (Exception e) {
         e.printStackTrace();
         return;
      }
      pullNewGoodsDao.save(pullNewGoods);
   }
   @Override
   public void deleteGoods(List<Long> list) {
      if (list == null || list.size() == 0)
         return;
      for (Long itemid: list) {
         pullNewGoodsDao.deleteByItemid(itemid);
      }
   }
}
package com.yeshi.fanli.service.impl.goods;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.goods.PullNewGoodsDao;
import com.yeshi.fanli.entity.goods.PullNewGoods;
import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail;
import com.yeshi.fanli.service.inter.goods.PullNewGoodsService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
@Service
public class PullNewGoodsServiceImpl implements PullNewGoodsService {
   @Resource
   private PullNewGoodsDao pullNewGoodsDao;
   @Resource
   private RedPackConfigService redPackConfigService;
   @Override
   public void saveGoods(PullNewGoods pullNewGoods) {
      if (pullNewGoods == null) {
         return;
      }
      pullNewGoodsDao.save(pullNewGoods);
   }
   @Override
   public List<PullNewGoods> listQuery(int start, int count) {
      return pullNewGoodsDao.listQuery(start, count);
   }
   @Override
   public long countQuery() {
      return pullNewGoodsDao.countQuery();
   }
   @Override
   public void updateGoods(HDKGoodsDetail goods) {
      if (goods == null)
         return;
      List<PullNewGoods> list = pullNewGoodsDao.getByItemid(goods.getItemid());
      if (list == null || list.size() == 0)
         return;
       double limitRate =  Double.valueOf(redPackConfigService.getValueByKey("goods_reate_limit"));
       double limitPrice =  Double.valueOf(redPackConfigService.getValueByKey("goods_pay_ment_limit"));
      // 佣金比例大于50%
      if (goods.getTkrates() == null || goods.getTkrates() < limitRate)
         return;
      // 是否存在券
      if (goods.getCouponmoney() == null || goods.getCouponmoney() <= 0)
         return;
      // 商品券后价大于9.9元
      if (goods.getItemendprice() == null || goods.getItemendprice() < limitPrice)
         return;
      PullNewGoods pullNewGoods = new PullNewGoods();
      try {
         PropertyUtils.copyProperties(pullNewGoods, goods);
      } catch (Exception e) {
         e.printStackTrace();
         return;
      }
      pullNewGoodsDao.save(pullNewGoods);
   }
   @Override
   public void deleteGoods(List<Long> list) {
      if (list == null || list.size() == 0)
         return;
      for (Long itemid: list) {
         pullNewGoodsDao.deleteByItemid(itemid);
      }
   }
}