From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java | 364 +++++++++++++++++++++++++++------------------------ 1 files changed, 194 insertions(+), 170 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java index 0f8de4a..62736ff 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java @@ -1,170 +1,194 @@ -package com.yeshi.fanli.service.impl.goods; - -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; - -import com.yeshi.fanli.dao.mybatis.goods.ScanHistoryV2Mapper; -import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; -import com.yeshi.fanli.entity.bus.user.UserInfo; -import com.yeshi.fanli.entity.goods.CommonGoods; -import com.yeshi.fanli.entity.goods.ScanHistoryV2; -import com.yeshi.fanli.entity.jd.JDGoods; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.exception.goods.CommonGoodsException; -import com.yeshi.fanli.exception.goods.ScanHistoryException; -import com.yeshi.fanli.service.inter.goods.CommonGoodsService; -import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.factory.CommonGoodsFactory; - -@Service -public class ScanHistoryV2ServiceImpl implements ScanHistoryV2Service { - - @Resource - private CommonGoodsService commonGoodsService; - - @Resource - private ScanHistoryV2Mapper scanHistoryV2Mapper; - - @Override - public void addScanHistory(Long uid, String device, TaoBaoGoodsBrief goods) - throws CommonGoodsException, ScanHistoryException { - if (uid == null && StringUtil.isNullOrEmpty(device)) - throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); - - CommonGoods commonGoods = CommonGoodsFactory.create(goods); - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - if (commonGoods == null) - throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); - - // 娣诲姞娴忚璁板綍 - ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2(); - scanHistoryV2.setCommonGoods(commonGoods); - scanHistoryV2.setCreateTime(new Date()); - scanHistoryV2.setDevice(device); - - if (uid != null) - scanHistoryV2.setUserInfo(new UserInfo(uid)); - - scanHistoryV2.setUpdateTime(new Date()); - scanHistoryV2Mapper.insertSelective(scanHistoryV2); - } - - - @Override - public void addJDScanHistory(Long uid, String device, JDGoods goods) throws CommonGoodsException, ScanHistoryException { - if (uid == null && StringUtil.isNullOrEmpty(device)) - throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); - - CommonGoods commonGoods = CommonGoodsFactory.create(goods); - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - if (commonGoods == null) - throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); - - // 娣诲姞娴忚璁板綍 - ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2(); - scanHistoryV2.setCommonGoods(commonGoods); - scanHistoryV2.setCreateTime(new Date()); - scanHistoryV2.setDevice(device); - - if (uid != null) - scanHistoryV2.setUserInfo(new UserInfo(uid)); - - scanHistoryV2.setUpdateTime(new Date()); - scanHistoryV2Mapper.insertSelective(scanHistoryV2); - } - - - @Override - public void addPDDScanHistory(Long uid, String device, PDDGoodsDetail pddGoods) throws CommonGoodsException, ScanHistoryException { - if (uid == null && StringUtil.isNullOrEmpty(device)) - throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); - - CommonGoods commonGoods = CommonGoodsFactory.create(pddGoods); - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - if (commonGoods == null) - throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); - - // 娣诲姞娴忚璁板綍 - ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2(); - scanHistoryV2.setCommonGoods(commonGoods); - scanHistoryV2.setCreateTime(new Date()); - scanHistoryV2.setDevice(device); - - if (uid != null) - scanHistoryV2.setUserInfo(new UserInfo(uid)); - - scanHistoryV2.setUpdateTime(new Date()); - scanHistoryV2Mapper.insertSelective(scanHistoryV2); - } - - @Override - public void addScanHistory(ScanHistoryV2 history) throws CommonGoodsException, ScanHistoryException { - if (history == null) - throw new ScanHistoryException(1, "娴忚淇℃伅涓嶈兘涓虹┖"); - if (history.getUserInfo() == null && StringUtil.isNullOrEmpty(history.getDevice())) - throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); - - CommonGoods commonGoods = commonGoodsService.addCommonGoods(history.getCommonGoods()); - if (commonGoods == null) - throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); - history.setCommonGoods(commonGoods); - scanHistoryV2Mapper.insertSelective(history); - } - - @Override - public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize, - Integer source, boolean notBackSuVip) { - if (uid == null && StringUtil.isNullOrEmpty(device)) - return null; - return scanHistoryV2Mapper.selectByDeviceOrUid(uid, device, (page - 1) * pageSize, pageSize, source, notBackSuVip); - } - - @Override - public long getCountByDeviceOrUid(Long uid, String device, Integer source, boolean notBackSuVip) { - if (uid == null && StringUtil.isNullOrEmpty(device)) - return 0; - Long count = scanHistoryV2Mapper.selectCountByDeviceOrUid(uid, device, source, notBackSuVip); - return count == null ? 0 : count; - } - - @Override - public void deleteByDeviceOrUid(Long uid, String device) { - if (uid == null && StringUtil.isNullOrEmpty(device)) - return; - List<ScanHistoryV2> list = scanHistoryV2Mapper.listDeviceOrUid(uid, device); - if (list != null) - for (ScanHistoryV2 sv : list) - scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); - } - - @Override - public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, Long auctionId) { - if (uid == null && StringUtil.isNullOrEmpty(device)) - return; - List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device, auctionId); - if (list != null) - for (ScanHistoryV2 sv : list) - scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); - } - - - @Override - public void deleteByCommonIdAndDeviceOrUid(Long uid, String device, Long commonId) { - if (uid == null && StringUtil.isNullOrEmpty(device)) { - return; - } - - List<ScanHistoryV2> list = scanHistoryV2Mapper.getByCommonGoodsId(uid, device, commonId); - if (list != null && list.size() > 0) { - for (ScanHistoryV2 sv : list) { - scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); - } - } - } - -} +package com.yeshi.fanli.service.impl.goods; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail; +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.dao.mybatis.goods.ScanHistoryV2Mapper; +import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; +import com.yeshi.fanli.dto.suning.SuningGoodsInfo; +import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; +import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.goods.CommonGoods; +import com.yeshi.fanli.entity.goods.ScanHistoryV2; +import com.yeshi.fanli.entity.jd.JDGoods; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.exception.goods.CommonGoodsException; +import com.yeshi.fanli.exception.goods.ScanHistoryException; +import com.yeshi.fanli.service.inter.goods.CommonGoodsService; +import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.factory.CommonGoodsFactory; + +@Service +public class ScanHistoryV2ServiceImpl implements ScanHistoryV2Service { + + @Resource + private CommonGoodsService commonGoodsService; + + @Resource + private ScanHistoryV2Mapper scanHistoryV2Mapper; + + @Override + public void addVIPScanHistory(Long uid, String device, VIPGoodsInfo goods) + throws CommonGoodsException, ScanHistoryException { + + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = CommonGoodsFactory.create(goods); + addScanHistory(commonGoods, device, uid); + } + + @Override + public void addSuningScanHistory(Long uid, String device, SuningGoodsInfo suningGoods) + throws CommonGoodsException, ScanHistoryException { + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = CommonGoodsFactory.create(suningGoods); + addScanHistory(commonGoods, device, uid); + } + + @Override + public void addDYScanHistory(Long uid, String device, DYGoodsDetail dyGoods) throws CommonGoodsException, ScanHistoryException { + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + CommonGoods commonGoods = CommonGoodsFactory.create(dyGoods); + addScanHistory(commonGoods, device, uid); + } + + private void addScanHistory(CommonGoods commonGoods, String device, Long uid) + throws CommonGoodsException, ScanHistoryException { + commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); + if (commonGoods == null) + throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); + + // 娣诲姞娴忚璁板綍 + ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2(); + scanHistoryV2.setCommonGoods(commonGoods); + scanHistoryV2.setCreateTime(new Date()); + scanHistoryV2.setDevice(device); + + if (uid != null) + scanHistoryV2.setUserInfo(new UserInfo(uid)); + + scanHistoryV2.setUpdateTime(new Date()); + scanHistoryV2Mapper.insertSelective(scanHistoryV2); + } + + @Override + public void addScanHistory(Long uid, String device, TaoBaoGoodsBrief goods) + throws CommonGoodsException, ScanHistoryException { + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = CommonGoodsFactory.create(goods); + commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); + if (commonGoods == null) + throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); + + // 娣诲姞娴忚璁板綍 + ScanHistoryV2 scanHistoryV2 = new ScanHistoryV2(); + scanHistoryV2.setCommonGoods(commonGoods); + scanHistoryV2.setCreateTime(new Date()); + scanHistoryV2.setDevice(device); + + if (uid != null) + scanHistoryV2.setUserInfo(new UserInfo(uid)); + + scanHistoryV2.setUpdateTime(new Date()); + scanHistoryV2Mapper.insertSelective(scanHistoryV2); + } + + @Override + public void addJDScanHistory(Long uid, String device, JDGoods goods) + throws CommonGoodsException, ScanHistoryException { + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = CommonGoodsFactory.create(goods); + addScanHistory(commonGoods, device, uid); + } + + @Override + public void addPDDScanHistory(Long uid, String device, PDDGoodsDetail pddGoods) + throws CommonGoodsException, ScanHistoryException { + if (uid == null && StringUtil.isNullOrEmpty(device)) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = CommonGoodsFactory.create(pddGoods); + addScanHistory(commonGoods, device, uid); + } + + @Override + public void addScanHistory(ScanHistoryV2 history) throws CommonGoodsException, ScanHistoryException { + if (history == null) + throw new ScanHistoryException(1, "娴忚淇℃伅涓嶈兘涓虹┖"); + if (history.getUserInfo() == null && StringUtil.isNullOrEmpty(history.getDevice())) + throw new ScanHistoryException(1, "璁惧鎴栫敤鎴蜂俊鎭己澶�"); + + CommonGoods commonGoods = commonGoodsService.addCommonGoods(history.getCommonGoods()); + if (commonGoods == null) + throw new CommonGoodsException(2, "鍟嗗搧淇℃伅涓嶅畬鏁�"); + history.setCommonGoods(commonGoods); + scanHistoryV2Mapper.insertSelective(history); + } + + @Override + public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize, + Integer source, boolean notBackSuVip) { + if (uid == null && StringUtil.isNullOrEmpty(device)) + return null; + return scanHistoryV2Mapper.selectByDeviceOrUid(uid, device, (page - 1) * pageSize, pageSize, source, + notBackSuVip); + } + + @Override + public long getCountByDeviceOrUid(Long uid, String device, Integer source, boolean notBackSuVip) { + if (uid == null && StringUtil.isNullOrEmpty(device)) + return 0; + Long count = scanHistoryV2Mapper.selectCountByDeviceOrUid(uid, device, source, notBackSuVip); + return count == null ? 0 : count; + } + + @Override + public void deleteByDeviceOrUid(Long uid, String device) { + if (uid == null && StringUtil.isNullOrEmpty(device)) + return; + List<ScanHistoryV2> list = scanHistoryV2Mapper.listDeviceOrUid(uid, device); + if (list != null) + for (ScanHistoryV2 sv : list) + scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); + } + + @Override + public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, String auctionId) { + if (uid == null && StringUtil.isNullOrEmpty(device)) + return; + List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device, + auctionId); + if (list != null) + for (ScanHistoryV2 sv : list) + scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); + } + + @Override + public void deleteByCommonIdAndDeviceOrUid(Long uid, String device, Long commonId) { + if (uid == null && StringUtil.isNullOrEmpty(device)) { + return; + } + + List<ScanHistoryV2> list = scanHistoryV2Mapper.getByCommonGoodsId(uid, device, commonId); + if (list != null && list.size() > 0) { + for (ScanHistoryV2 sv : list) { + scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId()); + } + } + } + +} -- Gitblit v1.8.0