fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelGoodsAdminController.java
@@ -7,24 +7,16 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import net.sf.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.entity.bus.lable.LabelGoods; import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.lable.LabelGoodsService; import com.yeshi.fanli.service.inter.lable.LabelService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import org.yeshi.utils.JsonUtil; @Controller @RequestMapping("admin/new/api/v1/labelGoods") @@ -32,125 +24,7 @@ @Resource private LabelGoodsService labelGoodsService; @Resource private TaoBaoGoodsBriefService taoBaoGoodsBriefService; @Resource private LabelService labelService; /** * 批量贴标签---精品库 * * @param callback * @param param * @param auctionIds * @param request * @param out */ @RequestMapping(value = "addBatch") public void addBatch(String callback, String lables, String ids, HttpServletRequest request, PrintWriter out) { // 鑾峰彇褰撳墠鎿嶄綔鐢ㄦ埛 AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); if (admin == null) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"))); } else { try { if (StringUtil.isNullOrEmpty(lables)) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未填写标签名称"))); } else { Gson gson = new Gson(); List<String> idList = gson.fromJson(ids, new TypeToken<ArrayList<String>>() { }.getType()); if (idList == null || idList.size() == 0) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择商品"))); } else { String[] arrtitle = lables.split("\\s+"); labelGoodsService.setGoodsLabel(arrtitle, idList, admin); out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("保存成功"))); } } } catch (Exception e) { // TODO Auto-generated catch block out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作失败"))); e.printStackTrace(); } } } /** * 批量添加标签 --- 精品库(随机权重) * * @param callback * @param label * @param request * @param out * @param 权重范围 大值 * @param 佣金范围 * 小值 */ @RequestMapping(value = "addBatchRandom") public void addBatchRandom(String callback, String lables, String ids, Integer weight, Integer weightSmall, Integer weightLarge, HttpServletRequest request, PrintWriter out) { // 获取当前操作用户 AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); if (admin == null) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"))); } else { try { if (StringUtil.isNullOrEmpty(lables)) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未填写标签名称"))); } else { if (StringUtil.isNullOrEmpty(ids)) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未选择需操作的商品"))); } else { Gson gson = new Gson(); List<String> idList = gson.fromJson(ids, new TypeToken<ArrayList<String>>() { }.getType()); if (idList == null || idList.size() == 0) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择需操作的商品"))); } else { String[] arrtitle = lables.split("\\s+"); labelGoodsService.addBatchRandom(arrtitle, idList, admin, weight, weightSmall, weightLarge); out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("添加成功"))); } } } } catch (Exception e) { // TODO Auto-generated catch block out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("添加异常"))); e.printStackTrace(); } } } /** * 批量商品添加标签-关联lableId @@ -165,28 +39,21 @@ public void batchGoodsAddLables(String callback, String labIds, String ids, HttpServletRequest request, PrintWriter out) { if (StringUtil.isNullOrEmpty(ids)) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的商品")); return; } Gson gson = new Gson(); List<Long> goodsIdList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType()); if (goodsIdList == null || goodsIdList.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的商品")); return; } try { // 获取当前操作用户 AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); // if (admin == null) { // out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"))); // return; // } if (StringUtil.isNullOrEmpty(ids)) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的商品")); return; } Gson gson = new Gson(); List<Long> goodsIdList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType()); if (goodsIdList == null || goodsIdList.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择需操作的商品")); return; } if (goodsIdList.size() == 1) { List<Long> labIdList = null; fanli/src/main/java/com/yeshi/fanli/controller/admin/QualityFactoryAdminController.java
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -31,6 +32,7 @@ import com.yeshi.fanli.service.inter.lable.LabelGoodsService; import com.yeshi.fanli.service.inter.lable.LabelService; import com.yeshi.fanli.service.inter.lable.QualityFactoryService; import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; @@ -38,7 +40,6 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import org.yeshi.utils.JsonUtil; @Controller @RequestMapping("admin/new/api/v1/qualityFactory") @@ -54,6 +55,9 @@ private QualityFactoryService qualityFactoryService; @Resource private TaoBaoGoodsBriefService taoBaoGoodsBriefService; @Resource private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; @Resource private AdminUserService adminUserService; @@ -619,7 +623,7 @@ lg.setCreatetime(nowTime); lg.setTaoBaoGoodsBrief(taoBaoGoodsBrief); int insert = labelGoodsService.insert(lg); int insert = labelGoodsService.insertSelective(lg); if (insert > 0) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("添加成功"))); } else { @@ -909,7 +913,6 @@ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功")); } catch (Exception e) { // TODO Auto-generated catch block JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); e.printStackTrace(); } @@ -944,7 +947,8 @@ if (!StringUtil.isNullOrEmpty(pictUrl)) taobao.setPictUrl(pictUrl); taoBaoGoodsBriefService.updateByPrimaryKeySelective(taobao); // 更新商品 taoBaoGoodsUpdateService.getUpdateTaoBaoGoodsBrief(taobao); out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("修改成功"))); fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
@@ -35,8 +35,9 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确")); return; } // 获取商品信息 JSONObject data = userShareGoodsRecordService.getGoodsGroup(shareId); JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { fanli/src/main/java/com/yeshi/fanli/dao/mybatis/share/UserShareGoodsGroupMapper.java
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum; public interface UserShareGoodsGroupMapper { @@ -47,7 +48,7 @@ * @param recordId * @return */ UserShareGoodsGroup getSingleGoods(@Param("cid") Long cid, @Param("uid") Long uid); UserShareGoodsGroup getSingleGoods(@Param("source") ShareSourceTypeEnum source, @Param("cid") Long cid, @Param("uid") Long uid); /** * 查询最新更新的商品 fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml
@@ -143,11 +143,10 @@ </select> <select id="getSingleGoods" resultMap="BaseResultMap"> SELECT *,COUNT(g.`gu_id`)AS totalGoods FROM yeshi_ec_share_goods_group g RIGHT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id` WHERE g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid} AND r.sgr_share_state = 1 GROUP BY r.`sgr_id` ORDER BY totalGoods LIMIT 1 SELECT * FROM yeshi_ec_share_goods_group g LEFT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id` WHERE r.sgr_share_state = 1 AND r.`sgr_source` = #{source} AND g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid} </select> <select id="getNewestRecord" resultMap="BaseResultMap"> fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsRecordMapper.xml
@@ -97,7 +97,7 @@ <select id="listCountTodayBrowse" resultMap="CountRecordMap" parameterType="java.util.List"> SELECT g.`gu_record_id`,SUM(g.`gu_today_browse`)AS todayBrowse FROM yeshi_ec_share_goods_group g SELECT g.`gu_record_id`AS sgr_id,SUM(g.`gu_today_browse`)AS todayBrowse FROM yeshi_ec_share_goods_group g WHERE TO_DAYS(g.`gu_browse_time`) = TO_DAYS(NOW()) AND g.`gu_record_id` IN <foreach collection="list" item="item" open="(" close=")" separator=",">#{item}</foreach> fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java
@@ -4,7 +4,6 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.transaction.Transactional; @@ -14,6 +13,7 @@ import org.hibernate.Session; import org.springframework.orm.hibernate4.HibernateCallback; import org.springframework.stereotype.Service; import org.yeshi.utils.NumberUtil; import com.yeshi.fanli.dao.config.AddEveryDayTaskDao; import com.yeshi.fanli.dao.goods.RecommendSectionGoodsDao; @@ -46,7 +46,6 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import org.yeshi.utils.NumberUtil; @Service public class TaoBaoGoodsBriefServiceImpl implements TaoBaoGoodsBriefService { @@ -336,10 +335,6 @@ return taoBaoGoodsBriefMapper.selectByPrimaryKey(id); } @Override public int updateByPrimaryKey(TaoBaoGoodsBrief taoBaoGoodsBrief) { return taoBaoGoodsBriefMapper.updateByPrimaryKey(taoBaoGoodsBrief); } @Override public void updateTBGoodsWithNewInfo(TaoBaoGoodsBrief tb) throws NotExistObjectException { @@ -356,48 +351,6 @@ } } } @Override public void updateTaoBaoGoodsByMybatis(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException { SearchFilter filter = new SearchFilter(); filter.setKey("https://item.taobao.com/item.htm?id=" + taoBaoGoodsBrief.getAuctionId()); TaoBaoGoodsBrief tb = TaoKeApiUtil.searchGoodsDetail(taoBaoGoodsBrief.getAuctionId()); if (tb == null) { return; } taoBaoGoodsBrief.setCouponLink(tb.getCouponLink()); taoBaoGoodsBrief.setCouponActivityId(tb.getCouponActivityId()); taoBaoGoodsBrief.setCouponAmount(tb.getCouponAmount()); taoBaoGoodsBrief.setCouponEffectiveStartTime(tb.getCouponEffectiveStartTime()); taoBaoGoodsBrief.setCouponEffectiveEndTime(tb.getCouponEffectiveEndTime()); taoBaoGoodsBrief.setCouponInfo(tb.getCouponInfo()); taoBaoGoodsBrief.setCouponLeftCount(tb.getCouponLeftCount()); taoBaoGoodsBrief.setCouponLinkTaoToken(tb.getCouponLinkTaoToken()); taoBaoGoodsBrief.setCouponOriLink(tb.getCouponOriLink()); taoBaoGoodsBrief.setCouponShortLink(tb.getCouponShortLink()); taoBaoGoodsBrief.setCouponStartFee(tb.getCouponStartFee()); taoBaoGoodsBrief.setCouponTotalCount(tb.getCouponTotalCount()); taoBaoGoodsBrief.setBiz30day(tb.getBiz30day()); taoBaoGoodsBrief.setTkRate(tb.getTkRate()); taoBaoGoodsBrief.setZkPrice(tb.getZkPrice()); taoBaoGoodsBrief.setEventRate(tb.getEventRate()); taoBaoGoodsBrief.setTkMktStatus(tb.getTkMktStatus()); taoBaoGoodsBrief.setReservePrice(tb.getReservePrice()); taoBaoGoodsBrief.setCreatetime(new Date()); setGoodsBriefDefault(taoBaoGoodsBrief); taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(taoBaoGoodsBrief); } @Override public void updateByPrimaryKeySelective(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException { setGoodsBriefDefault(taoBaoGoodsBrief); taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(taoBaoGoodsBrief); } @Override @@ -508,11 +461,6 @@ throw new ShareGoodsException(204, "商品详情数据为空"); return taoBaoGoodsBrief; } @Override public void updateBatchSelective(List<TaoBaoGoodsBrief> list) { taoBaoGoodsBriefMapper.updateBatchSelective(list); } } fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelGoodsServiceImpl.java
@@ -14,7 +14,6 @@ import com.yeshi.fanli.dao.mybatis.lable.QualityFactoryMapper; import com.yeshi.fanli.entity.bus.lable.Label; import com.yeshi.fanli.entity.bus.lable.LabelGoods; import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.LabelClassException; @@ -44,26 +43,12 @@ private TaoBaoGoodsBriefService taoBaoGoodsBriefService; @Override public int insert(LabelGoods record) throws LabelGoodsException{ return labelGoodsMapper.insert(record); } @Override public int updateByPrimaryKey(LabelGoods record) throws LabelGoodsException{ // TODO Auto-generated method stub return labelGoodsMapper.updateByPrimaryKey(record); } @Override public int updateByPrimaryKeySelective(LabelGoods record) throws LabelGoodsException{ // TODO Auto-generated method stub return labelGoodsMapper.updateByPrimaryKeySelective(record); public int insertSelective(LabelGoods record) throws LabelGoodsException{ return labelGoodsMapper.insertSelective(record); } @Override public int deleteByPrimaryKey(Long id) throws LabelGoodsException{ // TODO Auto-generated method stub return labelGoodsMapper.deleteByPrimaryKey(id); } @@ -101,151 +86,12 @@ @Override public LabelGoods selectByPrimaryKey(Long id) throws LabelGoodsException{ // TODO Auto-generated method stub return labelGoodsMapper.selectByPrimaryKey(id); } @Override public Long getRelationNum(Long labelId) throws LabelGoodsException{ return labelGoodsMapper.getRelationNum(labelId); } @Override @Transactional public void setGoodsLabel(String [] arrtitle, List<String> auctionIdList, AdminUser admin) throws Exception{ // TODO Auto-generated method stub Date nowTime = new Date(); for (String title: arrtitle) { /* 遍历标签名称:查询数据库中是否已存在 */ Label label = null; List<Label> labels = labelService.selectByTitle(title.trim()); if (labels == null || labels.size() == 0) { label = labels.get(0); } else { // 新增 label = new Label(); label.setTitle(title);// 名称 label.setEntrymode(Label.MODE_EXCEL); // 批量录入 label.setCreatetime(nowTime); label.setUpdatetime(nowTime); label.setCreateUser(admin); label.setIosClick(0l); label.setAndroidClick(0l); labelService.insertSelective(label); } /* 各个商品贴上标签 */ for (String id: auctionIdList) { long gid = Long.parseLong(id); TaoBaoGoodsBrief goodsBrief = taoBaoGoodsBriefService.selectByPrimaryKey(Long.parseLong(id)); if (goodsBrief != null) { /* 贴上标签 : 已贴不处理则 */ Long existence = labelGoodsMapper.isExistence(gid, label.getId()); // 该商品不存在此标签则添加, 反之不做处理 if (existence == null || existence == 0l) { // 贴上新标签 LabelGoods lg = new LabelGoods(); lg.setLabel(label); lg.setCreateUser(admin); lg.setCreatetime(nowTime); lg.setTaoBaoGoodsBrief(goodsBrief); labelGoodsMapper.insertSelective(lg); } } } } } @Override @Transactional public void addBatchRandom(String[] arrtitle, List<String> idList, AdminUser admin, Integer weight, Integer weightSmall, Integer weightLarge) throws Exception{ // 默认 50 int resultWeight = 50; if (weight != null) { resultWeight = weight; } else { if (weightSmall != null && weightLarge != null) { resultWeight = weightSmall + (int)(Math.random() * ((weightLarge - weightSmall) + 1)); } } Date nowTime = new Date(); for (String title: arrtitle) { /* 遍历标签名称:查询数据库中是否已存在 */ Label label = null; List<Label> labels = labelService.selectByTitle(title.trim()); if (labels == null || labels.size() == 0) { label = labels.get(0); } else { // 新增 label = new Label(); label.setTitle(title);// 名称 label.setEntrymode(Label.MODE_EXCEL); // 批量录入 label.setCreatetime(nowTime); label.setUpdatetime(nowTime); label.setCreateUser(admin); label.setIosClick(0l); label.setAndroidClick(0l); labelService.insertSelective(label); } for (String sid: idList) { Long selectId = Long.parseLong(sid); QualityFactory selectionGoods = selectionGoodsMapper.selectByPrimaryKey(selectId); if (selectionGoods == null ) { continue; } TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief(); if (taoBaoGoodsBrief == null ) { continue; } /* 贴上标签 : 已贴不处理则 */ Long existence = labelGoodsMapper.isExistence(taoBaoGoodsBrief.getId(), label.getId()); // 该商品不存在此标签则添加, 反之不做处理 if (existence == null || existence == 0l) { // 贴上新标签 LabelGoods lg = new LabelGoods(); lg.setLabel(label); lg.setCreateUser(admin); lg.setCreatetime(nowTime); lg.setTaoBaoGoodsBrief(taoBaoGoodsBrief); labelGoodsMapper.insertSelective(lg); } // 修改权重 selectionGoods.setUpdateUser(admin); selectionGoods.setUpdatetime(nowTime); selectionGoods.setWeight(resultWeight); selectionGoodsMapper.insertSelective(selectionGoods); } } } fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java
@@ -28,6 +28,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.QualityFactoryException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.lable.LabelService; @@ -70,25 +71,12 @@ @Resource private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; @Override public int insert(QualityFactory record) throws QualityFactoryException { return qualityFactoryMapper.insert(record); } @Override public int updateByPrimaryKey(QualityFactory record) throws QualityFactoryException { return qualityFactoryMapper.updateByPrimaryKey(record); } @Override public int updateByPrimaryKeySelective(QualityFactory record) throws QualityFactoryException { return qualityFactoryMapper.updateByPrimaryKeySelective(record); } @Override public int deleteByPrimaryKey(Long id) throws QualityFactoryException { return qualityFactoryMapper.deleteByPrimaryKey(id); } @Override public void deleteByTbAuctionId(Long auctionId) { @@ -160,16 +148,6 @@ labelGoodsMapper.deleteBatchByGoodsId(listGid); } @Override @Transactional public void deleteBatchByPrimaryKey(List<String> ids) throws QualityFactoryException { if (ids != null) { for (String id : ids) { qualityFactoryMapper.deleteByPrimaryKey(Long.parseLong(id)); } } } @Override @Transactional @@ -182,10 +160,6 @@ } } @Override public int removeStorageGoods(String doTime, Long gcids) throws QualityFactoryException { return qualityFactoryMapper.removeStorageGoods(doTime, gcids); } @Override public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException { @@ -320,10 +294,10 @@ TaoBaoGoodsBrief currentGoodsBrief = taoBaoGoodsBriefList.get(0); goodsBrief.setId(currentGoodsBrief.getId()); // 非空项 处理 setTaoBaoGoodsBriefDefault(goodsBrief); // 更新商品最新信息 taoBaoGoodsBriefService.updateByPrimaryKey(goodsBrief); taoBaoGoodsUpdateService.updateTaoBaoGoods(goodsBrief); } else { // 插入本地数据库 @@ -361,7 +335,7 @@ // 更新商品 QualityFactory selectionGoods = selectionList.get(0); selectionGoods.setUpdatetime(new Date()); qualityFactoryMapper.updateByPrimaryKey(selectionGoods); qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods); } if (listLabs.size() > 0) { @@ -419,7 +393,7 @@ } // 修改权重 // selectionGoods.setUpdateUser(admin); selectionGoods.setUpdateUser(admin); selectionGoods.setWeight(resultWeight); qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods); } @@ -443,7 +417,7 @@ @Override public List<Long> queryNeedUpdate(long start, int count, int hour) { return qualityFactoryMapper.queryNeedUpdate(0, count, hour); return qualityFactoryMapper.queryNeedUpdate(start, count, hour); } @@ -488,8 +462,11 @@ return; } // 删除精选库 List<Long> listDeleteQuality = new ArrayList<Long>(); // 删除标签 List<Long> listDeleteLabel = new ArrayList<Long>(); List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>(); @@ -567,6 +544,8 @@ /* 无券信息 移除精选库 */ listDeleteQuality.add(quality.getId()); // 移除标签 listDeleteLabel.add(goods.getId()); } else { /* 无券信息 移除精选库 */ @@ -575,13 +554,16 @@ // 移除精选库 listDeleteQuality.add(quality.getId()); // 移除标签 listDeleteLabel.add(goods.getId()); } else { /* 更新商品信息 */ TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService .getUpdateTaoBaoGoodsBrief(newGoodsBrief); TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService.getUpdateTaoBaoGoodsBrief(newGoodsBrief); updateGoods.setId(id); taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods); listUpdateGoodsBrief.add(updateGoods); /* 更新精选库 信息时间 */ @@ -619,7 +601,7 @@ // 更新商品信息 if (listUpdateGoodsBrief.size() > 0) { taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief); taoBaoGoodsUpdateService.updateTaoBaoGoods(listUpdateGoodsBrief); } // 更新精选库 @@ -630,8 +612,15 @@ // 批量删除精选库 if (listDeleteQuality.size() > 0) { qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality); // 批量删除限时抢购 qualityFlashSaleMapper.deleteBatchByQualityID(listDeleteQuality); } // 删除对应标签 if (listDeleteLabel.size() > 0) { labelGoodsMapper.deleteBatchByGoodsId(listDeleteLabel); } // 添加标签 if (listLabelAdd.size() > 0) { labelGoodsMapper.insertBatch(listLabelAdd); @@ -651,139 +640,6 @@ } } @Override @Transactional public void updateBatchQualityFactory(List<QualityFactory> listQuality, List<Long> list9Class, Map<String, Label> map) throws Exception { if (listQuality == null || listQuality.size() == 0) { return; } List<Long> listDeleteQuality = new ArrayList<Long>(); List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>(); List<Long> listGid = new ArrayList<Long>(); List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>(); List<Long> list9ClassDelete = new ArrayList<Long>(); // 添加商品标签列表 List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>(); listQuality.parallelStream().forEach(quality -> { TaoBaoGoodsBrief goods = quality.getTaoBaoGoodsBrief(); if (goods == null) { // 移除精选库 listDeleteQuality.add(quality.getId()); } else { Long id = goods.getId(); Long auctionId = goods.getAuctionId(); try { // 获取详情 TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId); if (taoBaoGoodsBrief == null) { /* 无券信息 移除精选库 */ listGid.add(id); } else { /* 无券信息 移除精选库 */ if (StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponInfo()) && StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponActivityId())) { // 无券信息 // 移除精选库 listGid.add(id); /* 更新商品信息 */ TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService .getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief); updateGoods.setId(id); taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods); listUpdateGoodsBrief.add(updateGoods); } else { /* 更新商品信息 */ TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService .getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief); updateGoods.setId(id); taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods); listUpdateGoodsBrief.add(updateGoods); /* 更新精选库 信息时间 */ Integer biz30day = updateGoods.getBiz30day(); if (biz30day < 1000) { // 销量小于1000 重新设置权重 int weight = 10 + (int) (Math.random() * 2000); quality.setWeight(weight); } quality.setUpdatetime(new Date()); listUpdateQuality.add(quality); /* 判断是否已经贴上标签 9k9标签 对应价格变化 */ if (list9Class.size() > 0) { List<LabelGoods> listGlid = labelGoodsMapper.listQuery9k9Class(id, list9Class); if (listGlid != null && listGlid.size() > 0) { /* 删除原标签 9k9 */ for (LabelGoods labelGoods : listGlid) { list9ClassDelete.add(labelGoods.getId()); } /* 贴上新标签 9k9 */ LabelGoods labelGds = screen9K9(updateGoods, map); if (labelGds != null) { listLabelAdd.add(labelGds); } } } } } } catch (TaobaoGoodsDownException e1) { // 商品下架 移除数据库 taoBaoGoodsUpdateService.deleteTaoBaoGoods(auctionId); } catch (Exception e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } }); // 更新商品信息 if (listUpdateGoodsBrief.size() > 0) { taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief); } // 更新精选库 if (listUpdateQuality.size() > 0) { qualityFactoryMapper.updateBatchSelective(listUpdateQuality); } // 批量移除精选库 if (listGid.size() > 0) { deleteBatchByTaoBaoGoodsId(listGid); } // 批量删除精选库 if (listDeleteQuality.size() > 0) { qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality); } // 添加标签 if (listLabelAdd.size() > 0) { labelGoodsMapper.insertBatch(listLabelAdd); } // 删除标签 if (list9ClassDelete.size() > 0) { labelGoodsMapper.deleteBatchByPK(list9ClassDelete); } } @Override public void autoInsertOrUpadateStorage(List<TaoBaoGoodsBrief> goodsList, List<Label> listLabs, @@ -1104,8 +960,11 @@ } } taoBaoGoodsBriefService.updateBatchSelective(listGoodsUpdate); try { taoBaoGoodsUpdateService.updateTaoBaoGoods(listGoodsUpdate); } catch (TaobaoGoodsUpdateException e) { System.out.println(e.getMsg()); } } // 淘宝商品插入数据库 fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
@@ -188,14 +188,24 @@ @Override public void updateTaoBaoGoods(List<TaoBaoGoodsBrief> goodsList) throws TaobaoGoodsUpdateException { if (goodsList == null) return; if (goodsList == null || goodsList.size() == 0) throw new TaobaoGoodsUpdateException(1, "商品列表为空"); List<TaoBaoGoodsBrief> updateList = new ArrayList<>(); for (TaoBaoGoodsBrief goods : goodsList) { if (goods.getId() == null || goods.getId() == 0L) if (goods.getId() == null || goods.getId() == 0L) { throw new TaobaoGoodsUpdateException(1, "商品主键ID为空"); updateList.add(goods); } TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods); updateGoods.setCreatetime(goods.getCreatetime()); updateList.add(updateGoods); } taoBaoGoodsBriefMapper.updateBatchSelective(updateList); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -326,12 +326,26 @@ throw new UserGoodsStorageException(1, "选品库商品不存在"); } List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>(); // 还原顺序 用于制图 for (Long sid: listStorageID) { for (UserGoodsStorage torage: listStorage) { Long id = torage.getId(); if (sid == id || sid.equals(id)) { listResult.add(torage); break; } } } BigDecimal totalMoney = new BigDecimal(0.00); List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>(); String rateStr = hongBaoManageService.get("hongbao_goods_proportion"); for (UserGoodsStorage userGoodsStorage: listStorage) { for (UserGoodsStorage userGoodsStorage: listResult) { CommonGoods commonGoods = userGoodsStorage.getCommonGoods(); TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); listGoodsBrief.add(goodsBrief); @@ -340,6 +354,10 @@ totalMoney = MoneyBigDecimalUtil.add(totalMoney, money); } String revenue = listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney; JSONObject result = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsGroupServiceImpl.java
@@ -11,6 +11,7 @@ import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper; import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum; import com.yeshi.fanli.entity.bus.user.HongBao; import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; @@ -62,7 +63,7 @@ @Override public UserShareGoodsGroup getSingleGoods(Long cid, Long uid) { return userShareGoodsGroupMapper.getSingleGoods(cid, uid); return userShareGoodsGroupMapper.getSingleGoods(ShareSourceTypeEnum.goodsDetail,cid, uid ); } @Override fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -105,11 +105,6 @@ return userShareGoodsRecordMapper.updateByPrimaryKeySelective(record); } @Override public int updateByPrimaryKey(UserShareGoodsRecord record) { return userShareGoodsRecordMapper.updateByPrimaryKey(record); } @Override public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source) { @@ -320,25 +315,20 @@ return; } UserShareGoodsGroup shareGoodsGroup = null; UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(), userShareGoodsRecord.getUid()); if (singleGoods != null && singleGoods.getTotalGoods() == 1) { // 同一个商品多次分享 shareGoodsGroup = singleGoods; } if (shareGoodsGroup != null) { if (singleGoods != null) { // 单个商品多次分享 userShareGoodsRecord.setPicture(taoBaoGoodsBrief.getPictUrl()); userShareGoodsRecord.setId(shareGoodsGroup.getRecordId()); userShareGoodsRecord.setId(singleGoods.getRecordId()); userShareGoodsRecord.setUpdateTime(new Date()); userShareGoodsRecordMapper.updateByPrimaryKey(userShareGoodsRecord); userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord); // 最新商品 shareGoodsGroup.setUpdateTime(new Date()); userShareGoodsGroupService.updateByPrimaryKeySelective(shareGoodsGroup); singleGoods.setUpdateTime(new Date()); userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods); } else { @@ -349,18 +339,17 @@ userShareGoodsRecord.setUpdateTime(date); userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord); shareGoodsGroup = new UserShareGoodsGroup(); shareGoodsGroup.setTotalOrder(0); shareGoodsGroup.setTotalBrowse(0); shareGoodsGroup.setTodayBrowse(0); shareGoodsGroup.setTotalMoney(new BigDecimal(0)); shareGoodsGroup.setCreateTime(date); shareGoodsGroup.setUpdateTime(date); shareGoodsGroup.setCommonGoods(resultCommonGoods); shareGoodsGroup.setRecordId(userShareGoodsRecord.getId()); singleGoods = new UserShareGoodsGroup(); singleGoods.setTotalOrder(0); singleGoods.setTotalBrowse(0); singleGoods.setTodayBrowse(0); singleGoods.setTotalMoney(new BigDecimal(0)); singleGoods.setCreateTime(date); singleGoods.setUpdateTime(date); singleGoods.setCommonGoods(resultCommonGoods); singleGoods.setRecordId(userShareGoodsRecord.getId()); userShareGoodsGroupService.insertSelective(shareGoodsGroup); userShareGoodsGroupService.insertSelective(singleGoods); } } catch (CommonGoodsException e) { @@ -437,7 +426,7 @@ Long uid = shareRecord.getUid(); Long shareId = shareRecord.getId(); String source = shareRecord.getSource().getDesc(); String source = shareRecord.getSource().name(); String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s", configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareRecord.getId() + "", source +""); @@ -652,6 +641,7 @@ goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId()); goodsState = 0; goodsBrief.setState(goodsState); // 在售 CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief); upadeteCommonGoods.setState(goodsState); fanli/src/main/java/com/yeshi/fanli/service/inter/goods/TaoBaoGoodsBriefService.java
@@ -89,22 +89,6 @@ public TaoBaoGoodsBrief selectByPrimaryKey(Long id); /** * 更新商品信息与淘宝信息一致 * * @param taoBaoGoodsBrief * @throws TaobaoGoodsDownException */ public void updateTaoBaoGoodsByMybatis(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException; /** * 选择性更新数据--mybatis * * @param taoBaoGoodsBrief * @throws TaobaoGoodsDownException */ public void updateByPrimaryKeySelective(TaoBaoGoodsBrief taoBaoGoodsBrief) throws TaobaoGoodsDownException; /** * 设置默认值 * * @param goodsBrief @@ -121,23 +105,12 @@ */ public TaoBaoGoodsBrief getTaoBaoGoodsDetailForShare(Long auctionId, Long uid) throws ShareGoodsException; public int updateByPrimaryKey(TaoBaoGoodsBrief taoBaoGoodsBrief); /** * 批量插入商品 * @param list * @return */ public int insertBatch(List<TaoBaoGoodsBrief> list); /** * 批量更新商品 * @param list */ public void updateBatchSelective(List<TaoBaoGoodsBrief> list); /** fanli/src/main/java/com/yeshi/fanli/service/inter/lable/LabelGoodsService.java
@@ -17,25 +17,7 @@ * @return * @throws LabelGoodsException */ public int insert(LabelGoods record) throws LabelGoodsException; /** * 更新当前对象所有数据 * * @param record * @return * @throws LabelGoodsException */ public int updateByPrimaryKey(LabelGoods record) throws LabelGoodsException; /** * 选择性更新内容——不为空则更新该字段 * * @param record * @return * @throws LabelGoodsException */ public int updateByPrimaryKeySelective(LabelGoods record) throws LabelGoodsException; public int insertSelective(LabelGoods record) throws LabelGoodsException; /** * 根据id删除当前对象 @@ -63,16 +45,6 @@ */ public int deleteBatchById(long[] ids) throws LabelGoodsException; /** * 商品贴标签 * * @param arrtitle * @param ids * @param admin * @return * @throws LabelGoodsException */ public void setGoodsLabel(String[] arrtitle, List<String> goodsIds, AdminUser admin) throws Exception; /** * 根据商品id 删除商品对应的所有标签信息 @@ -82,18 +54,6 @@ */ public void deleteByGoodsId(List<String> ids) throws LabelGoodsException; /** * 批量添加商品标签 * * @param label * @param goodsIdList * @param admin * @param weight * @param weightSmall * @param weightLarge */ public void addBatchRandom(String[] lables, List<String> idList, AdminUser admin, Integer weight, Integer weightSmall, Integer weightLarge) throws Exception; /** * 获取标签商品关联数量 fanli/src/main/java/com/yeshi/fanli/service/inter/lable/QualityFactoryService.java
@@ -14,22 +14,6 @@ public interface QualityFactoryService { /** * 插入对象 * @param record * @return * @throws QualityFactoryException */ public int insert(QualityFactory record) throws QualityFactoryException; /** * 更新当前对象所有数据 * @param record * @return * @throws QualityFactoryException */ public int updateByPrimaryKey(QualityFactory record) throws QualityFactoryException; /** * 选择性更新内容——不为空则更新该字段 * @param record * @return @@ -37,14 +21,6 @@ */ public int updateByPrimaryKeySelective(QualityFactory record) throws QualityFactoryException; /** * 根据id删除当前对象 * @param id * @return * @throws QualityFactoryException */ public int deleteByPrimaryKey(Long id) throws QualityFactoryException; /** * 根据id查找当前对象 @@ -53,14 +29,6 @@ * @throws QualityFactoryException */ public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException; /** * 根据id批量删除 * @param ids */ public void deleteBatchByPrimaryKey(List<String> ids) throws QualityFactoryException; /** @@ -75,6 +43,28 @@ * @throws QualityFactoryException */ public void deleteByGoodsId(List<String> ids) throws QualityFactoryException; /** * 根据淘宝id 删除精选库对应信息 * @param gid * @throws QualityFactoryException */ public void deleteByTaoBaoGoodsId(Long gid) throws QualityFactoryException; /** * 根据淘宝id集合 批量删除精选库对应信息 * @param listId * @throws QualityFactoryException */ public void deleteBatchByTaoBaoGoodsId(List<Long> listId) throws QualityFactoryException; /** * 根据淘宝id 删除 * @param auctionId * @throws QualityFactoryException */ public void deleteByTbAuctionId(Long auctionId); /** * 统计商品id 是存在精品库 @@ -164,16 +154,6 @@ /** * 批量更新精选库商品信息 : 无优惠券、已下架商品 移除精选库 不能超过20个 * @param list * @throws Exception */ public void updateBatchQualityFactory(List<QualityFactory> list, List<Long> list9Class, Map<String,Label> map) throws Exception; /** * 查询需要更新的精选库商品id * @param count * @param hour @@ -216,17 +196,6 @@ /** * 根据商品id删除 * @param doTime * @param gcids * @return * @throws QualityFactoryException */ public int removeStorageGoods(String doTime, Long gcids) throws QualityFactoryException; /** * AuctionId查收精选库 * @param list * @return @@ -234,27 +203,6 @@ public List<QualityFactory> listQueryByAuctionId(List<Long> list); /** * 根据淘宝id 删除精选库对应信息 * @param gid * @throws QualityFactoryException */ public void deleteByTaoBaoGoodsId(Long gid) throws QualityFactoryException; /** * 根据淘宝id集合 批量删除精选库对应信息 * @param listId * @throws QualityFactoryException */ public void deleteBatchByTaoBaoGoodsId(List<Long> listId) throws QualityFactoryException; /** * 根据淘宝id 删除 * @param auctionId * @throws QualityFactoryException */ public void deleteByTbAuctionId(Long auctionId); /** * 根据时间 获取当前时间之前创建的商品信息 * @param systemCid 系统分类id fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsGroupService.java
@@ -26,7 +26,7 @@ public List<UserShareGoodsGroup> listByRecordId(Long recordId); /** * 查询单个商品 判断是否单个商品分享 * 查询单个商品 判断是否单个商品分享 goodsDetail * @param recordId * @return */ fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java
@@ -17,8 +17,6 @@ public int updateByPrimaryKeySelective(UserShareGoodsRecord record); public int updateByPrimaryKey(UserShareGoodsRecord record); public UserShareGoodsRecord selectByPrimaryKey(Long id); /** fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java
@@ -27,11 +27,12 @@ import javax.imageio.ImageIO; import org.yeshi.utils.HttpUtil; import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import org.yeshi.utils.HttpUtil; public class ImageUtil { @@ -700,7 +701,11 @@ // 画头像 if (portrait != null) { BufferedImage portraitImg = ImageIO.read(portrait); portraitImg = zoomInImage(portraitImg, 40, 40); // 放缩大小 portraitImg = zoomInImage(portraitImg, 40,40); // 圆角 portraitImg = roundImage(portraitImg, 10); g2d.drawImage(portraitImg, 70 + (qrcodeImage.getWidth() - portraitImg.getWidth()) / 2, 1092 + (qrcodeImage.getHeight() - portraitImg.getHeight()) / 2, null); } @@ -1069,7 +1074,7 @@ gs.dispose(); return image; } public static int saveToImgByInputStream(InputStream inputStream, String imgPath, String imgName) { int stateInt = 1; try {