From 0ab8a2ea521a838124f517daf4e61dee971a6d4c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 20 六月 2020 19:04:37 +0800 Subject: [PATCH] 商品系统完善 --- src/main/java/com/ks/tool/bkz/exception/SDLJDocTemplateException.java | 9 src/main/java/com/ks/tool/bkz/util/UserUtil.java | 2 src/main/resources/mapper/sdlj/SDLJDocTemplateMapper.xml | 117 +++++++++ src/main/java/com/ks/tool/bkz/controller/SDLJGoodsController.java | 60 ++++ src/main/java/com/ks/tool/bkz/service/impl/TBGoodsServiceImpl.java | 16 + src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJDocTemplateServiceImpl.java | 60 ++++ src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJUserGoodsServiceImpl.java | 5 src/main/resources/generatorConfig.xml | 24 + src/main/java/com/ks/tool/bkz/service/sdlj/SDLJDocTemplateService.java | 14 + src/main/java/com/ks/tool/bkz/entity/TBGoodsInfo.java | 36 +- src/main/resources/mapper/TBGoodsInfoMapper.xml | 212 +++++++++------- src/main/java/com/ks/tool/bkz/vo/sdlj/SDLJGoodsInfoVO.java | 18 + src/main/java/com/ks/tool/bkz/util/tb/ZheTaoKeApiUtil.java | 43 +++ src/main/java/com/ks/tool/bkz/entity/sdlj/SDLJDocTemplate.java | 55 ++++ src/main/java/com/ks/tool/bkz/util/sdlj/DocTemplateUtil.java | 32 ++ src/main/resources/mapper/sdlj/SDLJUserGoodsMapper.xml | 3 src/main/java/com/ks/tool/bkz/vo/tb/ZheTaoKeConvertResult.java | 37 ++ src/main/java/com/ks/tool/bkz/dao/mybatis/sdlj/SDLJDocTemplateMapper.java | 11 src/test/java/com/ks/tool/bkz/GoodsTest.java | 12 19 files changed, 639 insertions(+), 127 deletions(-) diff --git a/src/main/java/com/ks/tool/bkz/controller/SDLJGoodsController.java b/src/main/java/com/ks/tool/bkz/controller/SDLJGoodsController.java index 297a9b2..6066786 100644 --- a/src/main/java/com/ks/tool/bkz/controller/SDLJGoodsController.java +++ b/src/main/java/com/ks/tool/bkz/controller/SDLJGoodsController.java @@ -1,7 +1,10 @@ package com.ks.tool.bkz.controller; import com.google.gson.Gson; +import com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate; +import com.ks.tool.bkz.exception.SDLJDocTemplateException; import com.ks.tool.bkz.service.manager.RedisManager; +import com.ks.tool.bkz.service.sdlj.SDLJDocTemplateService; import com.ks.tool.bkz.service.sdlj.SDLJUserGoodsService; import com.ks.tool.bkz.service.user.SDLJShareOpenHistoryService; import com.ks.tool.bkz.service.user.UserService; @@ -13,13 +16,13 @@ import com.ks.tool.bkz.vo.sdlj.SDLJGoodsSearchVO; import net.sf.json.JSONObject; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; +import java.util.Map; @Controller @RequestMapping("sdlj/goods") @@ -37,6 +40,9 @@ @Resource private UserService userService; + @Resource + private SDLJDocTemplateService sdljDocTemplateService; + @Login @RequestMapping("searchGoods") @ResponseBody @@ -50,8 +56,8 @@ Long uid = userService.selectByAccount(account).getId(); //鏌ヨ鏄惁鍙互鎼滅储鍏ㄩ儴 - if(sdljShareOpenHistoryService.isOpen(uid)) - uid=null; + if (sdljShareOpenHistoryService.isOpen(uid)) + uid = null; List<SDLJGoodsInfoVO> list = sdljUserGoodsService.query(sf, uid, page, pageSize); List<SDLJGoodsInfoVO> goodsList = new ArrayList<>(); @@ -78,4 +84,50 @@ } + /** + * 璁剧疆妯℃澘 + * + * @param request + * @return + */ + @Login + @PostMapping("setTemplate") + @ResponseBody + public String setTemplate(@RequestParam Map<String, String> params, HttpServletRequest request) { + int type= Integer.parseInt(params.get("type")); + String template=params.get("template"); + String account = UserUtil.getAccountFromToken(request.getHeader("token")); + Long uid = userService.selectByAccount(account).getId(); + if (type == 0) {//淇濆瓨妯℃澘 + SDLJDocTemplate t = new SDLJDocTemplate(); + t.setTemplate(template); + t.setUid(uid); + try { + sdljDocTemplateService.addTemplate(t); + } catch (SDLJDocTemplateException e) { + return JsonUtil.loadFalseResult(e.getCode(), e.getMsg()); + } + } else {//杩樺師妯℃澘 + sdljDocTemplateService.deleteByUid(uid); + } + return JsonUtil.loadTrueResult(""); + } + + //鑾峰彇妯℃澘 + @Login + @RequestMapping("getTemplate") + @ResponseBody + public String getTemplate(HttpServletRequest request) { + String account = UserUtil.getAccountFromToken(request.getHeader("token")); + Long uid = userService.selectByAccount(account).getId(); + SDLJDocTemplate template= sdljDocTemplateService.selectByUid(uid); + if(template==null) + return JsonUtil.loadFalseResult(1,"鏃犺嚜瀹氫箟妯℃澘"); + JSONObject data=new JSONObject(); + data.put("template",template.getTemplate()); + return JsonUtil.loadTrueResult(data); + } + + + } diff --git a/src/main/java/com/ks/tool/bkz/dao/mybatis/sdlj/SDLJDocTemplateMapper.java b/src/main/java/com/ks/tool/bkz/dao/mybatis/sdlj/SDLJDocTemplateMapper.java new file mode 100644 index 0000000..327f4a9 --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/dao/mybatis/sdlj/SDLJDocTemplateMapper.java @@ -0,0 +1,11 @@ +package com.ks.tool.bkz.dao.mybatis.sdlj; + +import com.ks.tool.bkz.dao.BaseMapper; +import com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate; + +import java.util.List; + +public interface SDLJDocTemplateMapper extends BaseMapper<SDLJDocTemplate> { + + List<SDLJDocTemplate> listByUid(Long uid); +} \ No newline at end of file diff --git a/src/main/java/com/ks/tool/bkz/entity/TBGoodsInfo.java b/src/main/java/com/ks/tool/bkz/entity/TBGoodsInfo.java index ac23da9..8fc10ca 100644 --- a/src/main/java/com/ks/tool/bkz/entity/TBGoodsInfo.java +++ b/src/main/java/com/ks/tool/bkz/entity/TBGoodsInfo.java @@ -5,42 +5,42 @@ public class TBGoodsInfo { private Long id; - private Long goodsId; - private String title; - private String imgs; - private BigDecimal zkPrice; - private String couponInfo; - private BigDecimal couponAmount; - private BigDecimal couponStartPrice; - private Integer couponTotalCount; - private Integer couponLeftCount; - private String couponStartTime; - private String couponEndTime; - private BigDecimal couponPrice; - private Integer salesNum; - private BigDecimal commissionRate; - private Date createTime; - private Date updateTime; - private Integer cid;//娣樺疂鍒嗙被ID - private Integer tmall;//鏄惁涓哄ぉ鐚� 1-鏄� + private String tkl; + private Date tklUpdateTime; + + public String getTkl() { + return tkl; + } + + public void setTkl(String tkl) { + this.tkl = tkl; + } + + public Date getTklUpdateTime() { + return tklUpdateTime; + } + + public void setTklUpdateTime(Date tklUpdateTime) { + this.tklUpdateTime = tklUpdateTime; + } public Integer getTmall() { return tmall; diff --git a/src/main/java/com/ks/tool/bkz/entity/sdlj/SDLJDocTemplate.java b/src/main/java/com/ks/tool/bkz/entity/sdlj/SDLJDocTemplate.java new file mode 100644 index 0000000..e488181 --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/entity/sdlj/SDLJDocTemplate.java @@ -0,0 +1,55 @@ +package com.ks.tool.bkz.entity.sdlj; + +import java.util.Date; + +public class SDLJDocTemplate { + private Long id; + + private Long uid; + + private Date createTime; + + private Date updateTime; + + private String template; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUid() { + return uid; + } + + public void setUid(Long uid) { + this.uid = uid; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } +} \ No newline at end of file diff --git a/src/main/java/com/ks/tool/bkz/exception/SDLJDocTemplateException.java b/src/main/java/com/ks/tool/bkz/exception/SDLJDocTemplateException.java new file mode 100644 index 0000000..11f5d27 --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/exception/SDLJDocTemplateException.java @@ -0,0 +1,9 @@ +package com.ks.tool.bkz.exception; + +public class SDLJDocTemplateException extends BaseException{ + + + public SDLJDocTemplateException(int code, String msg) { + super(code, msg); + } +} diff --git a/src/main/java/com/ks/tool/bkz/service/impl/TBGoodsServiceImpl.java b/src/main/java/com/ks/tool/bkz/service/impl/TBGoodsServiceImpl.java index 5f77984..8996107 100644 --- a/src/main/java/com/ks/tool/bkz/service/impl/TBGoodsServiceImpl.java +++ b/src/main/java/com/ks/tool/bkz/service/impl/TBGoodsServiceImpl.java @@ -6,6 +6,8 @@ import com.ks.tool.bkz.service.TBGoodsService; import com.ks.tool.bkz.util.factory.TBGoodsInfoFactory; import com.ks.tool.bkz.util.tb.DaTaoKeApiUtil; +import com.ks.tool.bkz.util.tb.ZheTaoKeApiUtil; +import com.ks.tool.bkz.vo.tb.ZheTaoKeConvertResult; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,11 +39,25 @@ if (old == null) { if (goodsInfo.getCreateTime() == null) goodsInfo.setCreateTime(new Date()); + //鑾峰彇娣樺彛浠� + ZheTaoKeConvertResult result= ZheTaoKeApiUtil.getTkl(goodsInfo.getGoodsId()); + if(result!=null){ + goodsInfo.setTkl(result.getTkl()); + goodsInfo.setTklUpdateTime(new Date()); + } tbGoodsInfoMapper.insertSelective(goodsInfo); } else { goodsInfo.setId(old.getId()); if (goodsInfo.getUpdateTime() == null) goodsInfo.setUpdateTime(new Date()); + //25澶╂洿鏂版窐鍙d护 + if(old.getTklUpdateTime()==null||System.currentTimeMillis()- old.getTklUpdateTime().getTime()>1000*60*60*24*25L){ + ZheTaoKeConvertResult result= ZheTaoKeApiUtil.getTkl(goodsInfo.getGoodsId()); + if(result!=null){ + goodsInfo.setTkl(result.getTkl()); + goodsInfo.setTklUpdateTime(new Date()); + } + } tbGoodsInfoMapper.updateByPrimaryKeySelective(goodsInfo); } } diff --git a/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJDocTemplateServiceImpl.java b/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJDocTemplateServiceImpl.java new file mode 100644 index 0000000..52794bd --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJDocTemplateServiceImpl.java @@ -0,0 +1,60 @@ +package com.ks.tool.bkz.service.impl.sdlj; + +import com.ks.tool.bkz.dao.mybatis.sdlj.SDLJDocTemplateMapper; +import com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate; +import com.ks.tool.bkz.exception.SDLJDocTemplateException; +import com.ks.tool.bkz.service.sdlj.SDLJDocTemplateService; +import com.ks.tool.bkz.util.StringUtil; +import com.ks.tool.bkz.util.sdlj.DocTemplateUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +@Service +public class SDLJDocTemplateServiceImpl implements SDLJDocTemplateService { + + @Resource + private SDLJDocTemplateMapper sdljDocTemplateMapper; + + @Transactional + @Override + public void addTemplate(SDLJDocTemplate template) throws SDLJDocTemplateException { + if (template == null || StringUtil.isNullOrEmpty(template.getTemplate()) || template.getUid() == null) + throw new SDLJDocTemplateException(1, "鍙傛暟涓嶅畬鏁�"); + //楠岃瘉鏍煎紡鏄惁姝g‘ + if (!DocTemplateUtil.IsRight(template.getTemplate())) { + throw new SDLJDocTemplateException(2, "妯℃澘鏍煎紡鏈夎"); + } + SDLJDocTemplate old = selectByUid(template.getUid()); + if (old == null) { + if (template.getCreateTime() == null) + template.setCreateTime(new Date()); + sdljDocTemplateMapper.updateByPrimaryKeySelective(template); + }else{//鏇存柊 + template.setId(old.getId()); + template.setUpdateTime(new Date()); + sdljDocTemplateMapper.updateByPrimaryKeySelective(template); + } + } + + @Override + public SDLJDocTemplate selectByUid(Long uid) { + List<SDLJDocTemplate> list= sdljDocTemplateMapper.listByUid(uid); + if(list!=null&&list.size()>0) + return list.get(0); + return null; + } + + @Transactional + @Override + public void deleteByUid(Long uid) { + List<SDLJDocTemplate> list= sdljDocTemplateMapper.listByUid(uid); + if(list!=null) + for(SDLJDocTemplate template:list){ + sdljDocTemplateMapper.deleteByPrimaryKey(template.getId()); + } + } +} diff --git a/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJUserGoodsServiceImpl.java b/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJUserGoodsServiceImpl.java index 7d60924..199f36f 100644 --- a/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJUserGoodsServiceImpl.java +++ b/src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJUserGoodsServiceImpl.java @@ -64,6 +64,11 @@ for (String st : vo.getImgs().split(",")) imgList.add(st); vo.setImgList(imgList); + if(vo.getTmall()==1){ + vo.setItemUrl("https://detail.tmall.com/item.htm?id="+vo.getGoodsId()); + }else{ + vo.setItemUrl("https://item.taobao.com/item.htm?id="+vo.getGoodsId()); + } } return goodsList; } diff --git a/src/main/java/com/ks/tool/bkz/service/sdlj/SDLJDocTemplateService.java b/src/main/java/com/ks/tool/bkz/service/sdlj/SDLJDocTemplateService.java new file mode 100644 index 0000000..97f0c4a --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/service/sdlj/SDLJDocTemplateService.java @@ -0,0 +1,14 @@ +package com.ks.tool.bkz.service.sdlj; + +import com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate; +import com.ks.tool.bkz.exception.SDLJDocTemplateException; + +public interface SDLJDocTemplateService { + + public void addTemplate(SDLJDocTemplate template) throws SDLJDocTemplateException; + + public SDLJDocTemplate selectByUid(Long uid); + + public void deleteByUid(Long uid); + +} diff --git a/src/main/java/com/ks/tool/bkz/util/UserUtil.java b/src/main/java/com/ks/tool/bkz/util/UserUtil.java index a52e22f..75486f3 100644 --- a/src/main/java/com/ks/tool/bkz/util/UserUtil.java +++ b/src/main/java/com/ks/tool/bkz/util/UserUtil.java @@ -1,5 +1,7 @@ package com.ks.tool.bkz.util; +import javax.servlet.http.HttpServletRequest; + public class UserUtil { /** diff --git a/src/main/java/com/ks/tool/bkz/util/sdlj/DocTemplateUtil.java b/src/main/java/com/ks/tool/bkz/util/sdlj/DocTemplateUtil.java new file mode 100644 index 0000000..65635df --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/util/sdlj/DocTemplateUtil.java @@ -0,0 +1,32 @@ +package com.ks.tool.bkz.util.sdlj; + +public class DocTemplateUtil { + + public static boolean IsRight(String doc) { + //鍖归厤涓や釜涓嫭鍙� + int start1= doc.indexOf("["); + if (start1 <= -1) { + return false; + } + + int end1 = doc.indexOf("]", start1); + if (end1 <= -1) { + return false; + } + + int start2 = doc.indexOf("[", end1); + if (start2 <= -1) + { + return false; + } + + int end2 = doc.indexOf("]", start2); + if (end2 <= -1) + { + return false; + } + + return true; + } + +} diff --git a/src/main/java/com/ks/tool/bkz/util/tb/ZheTaoKeApiUtil.java b/src/main/java/com/ks/tool/bkz/util/tb/ZheTaoKeApiUtil.java new file mode 100644 index 0000000..7d8c450 --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/util/tb/ZheTaoKeApiUtil.java @@ -0,0 +1,43 @@ +package com.ks.tool.bkz.util.tb; + +import com.ks.tool.bkz.util.HttpUtil; +import com.ks.tool.bkz.vo.tb.ZheTaoKeConvertResult; +import net.sf.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +public class ZheTaoKeApiUtil { + + private static String baseRequest(String baseUrl, Map<String, String> params) { + params.put("appkey", "fe65b15d74d84c75b99578543da75264"); + String result = HttpUtil.get(baseUrl, params, null); + return result; + } + + /** + * 鑾峰彇娣樺彛浠� + * @param auctionId + * @return + */ + public static ZheTaoKeConvertResult getTkl(Long auctionId) { + try { + Map<String, String> params = new HashMap<>(); + params.put("sid", "34116"); + params.put("pid", "mm_106929643_20324269_81478350"); + params.put("num_iid", auctionId + ""); + params.put("signurl", 5 + ""); + String result = baseRequest("https://api.zhetaoke.com:10001/api/open_gaoyongzhuanlian.ashx", params); + JSONObject resultJson = JSONObject.fromObject(result); + if (resultJson.optInt("status") == 200) { + JSONObject item= resultJson.optJSONArray("content").optJSONObject(0); + return new ZheTaoKeConvertResult(item.optString("taobao_url"),item.optString("tkl"),item.optLong("tao_id")); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + +} diff --git a/src/main/java/com/ks/tool/bkz/vo/sdlj/SDLJGoodsInfoVO.java b/src/main/java/com/ks/tool/bkz/vo/sdlj/SDLJGoodsInfoVO.java index 6474700..653a9b7 100644 --- a/src/main/java/com/ks/tool/bkz/vo/sdlj/SDLJGoodsInfoVO.java +++ b/src/main/java/com/ks/tool/bkz/vo/sdlj/SDLJGoodsInfoVO.java @@ -19,6 +19,24 @@ private BigDecimal couponAmount;//鍒搁潰棰� private Integer tmall;//澶╃尗 private Boolean mark; + private String tkl;//娣樺彛浠� + private String itemUrl;//鍟嗗搧閾炬帴 + + public String getItemUrl() { + return itemUrl; + } + + public void setItemUrl(String itemUrl) { + this.itemUrl = itemUrl; + } + + public String getTkl() { + return tkl; + } + + public void setTkl(String tkl) { + this.tkl = tkl; + } public Boolean getMark() { return mark; diff --git a/src/main/java/com/ks/tool/bkz/vo/tb/ZheTaoKeConvertResult.java b/src/main/java/com/ks/tool/bkz/vo/tb/ZheTaoKeConvertResult.java new file mode 100644 index 0000000..e8747b5 --- /dev/null +++ b/src/main/java/com/ks/tool/bkz/vo/tb/ZheTaoKeConvertResult.java @@ -0,0 +1,37 @@ +package com.ks.tool.bkz.vo.tb; + +public class ZheTaoKeConvertResult { + private String taoBaoUrl; + private String tkl; + private Long goodsId; + + public ZheTaoKeConvertResult(String taoBaoUrl, String tkl, Long goodsId) { + this.taoBaoUrl = taoBaoUrl; + this.tkl = tkl; + this.goodsId = goodsId; + } + + public String getTaoBaoUrl() { + return taoBaoUrl; + } + + public void setTaoBaoUrl(String taoBaoUrl) { + this.taoBaoUrl = taoBaoUrl; + } + + public String getTkl() { + return tkl; + } + + public void setTkl(String tkl) { + this.tkl = tkl; + } + + public Long getGoodsId() { + return goodsId; + } + + public void setGoodsId(Long goodsId) { + this.goodsId = goodsId; + } +} diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 8b8093d..2e07e58 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -1,5 +1,6 @@ <!DOCTYPE generatorConfiguration - PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> + PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" + "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <!-- 鏁版嵁搴撻┍鍔�:閫夋嫨浣犵殑鏈湴纭洏涓婇潰鐨勬暟鎹簱椹卞姩鍖�--> <classPathEntry @@ -29,9 +30,9 @@ <!-- enableSubPackages:鏄惁璁﹕chema浣滀负鍖呯殑鍚庣紑 --> <property name="enableSubPackages" value="true"/> - <!-- 浠庢暟鎹簱杩斿洖鐨勫�艰娓呯悊鍓嶅悗鐨勭┖鏍� --> - <property name="trimStrings" value="false"/> - </javaModelGenerator> + <!-- 浠庢暟鎹簱杩斿洖鐨勫�艰娓呯悊鍓嶅悗鐨勭┖鏍� --> + <property name="trimStrings" value="false"/> + </javaModelGenerator> <!-- 鐢熸垚鏄犲皠鏂囦欢鐨勫寘鍚嶅拰浣嶇疆--> @@ -86,13 +87,22 @@ <table tableName="tt_tb_goods_info" domainObjectName="TBGoodsInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> - --> +--> + + <!-- <table tableName="tt_config" domainObjectName="Config" enableCountByExample="false" + enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" + selectByExampleQueryId="false"/> +--> + + + <table tableName="tt_sdlj_doc_template" domainObjectName="SDLJDocTemplate" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> - </context> - </generatorConfiguration> \ No newline at end of file + </context> + +</generatorConfiguration> \ No newline at end of file diff --git a/src/main/resources/mapper/TBGoodsInfoMapper.xml b/src/main/resources/mapper/TBGoodsInfoMapper.xml index 5d84146..2ee8489 100644 --- a/src/main/resources/mapper/TBGoodsInfoMapper.xml +++ b/src/main/resources/mapper/TBGoodsInfoMapper.xml @@ -1,33 +1,35 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.ks.tool.bkz.dao.mybatis.TBGoodsInfoMapper"> - <resultMap id="BaseResultMap" type="com.ks.tool.bkz.entity.TBGoodsInfo"> - <id column="id" jdbcType="BIGINT" property="id" /> - <result column="goods_id" jdbcType="BIGINT" property="goodsId" /> - <result column="title" jdbcType="VARCHAR" property="title" /> - <result column="imgs" jdbcType="VARCHAR" property="imgs" /> - <result column="zk_price" jdbcType="DECIMAL" property="zkPrice" /> - <result column="coupon_info" jdbcType="VARCHAR" property="couponInfo" /> - <result column="coupon_amount" jdbcType="DECIMAL" property="couponAmount" /> - <result column="coupon_start_price" jdbcType="DECIMAL" property="couponStartPrice" /> - <result column="coupon_total_count" jdbcType="INTEGER" property="couponTotalCount" /> - <result column="coupon_left_count" jdbcType="INTEGER" property="couponLeftCount" /> - <result column="coupon_start_time" jdbcType="VARCHAR" property="couponStartTime" /> - <result column="coupon_end_time" jdbcType="VARCHAR" property="couponEndTime" /> - <result column="coupon_price" jdbcType="DECIMAL" property="couponPrice" /> - <result column="sales_num" jdbcType="INTEGER" property="salesNum" /> - <result column="commission_rate" jdbcType="DECIMAL" property="commissionRate" /> - <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> - <result column="tmall" jdbcType="INTEGER" property="tmall" /> - <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> - <result column="cid" jdbcType="INTEGER" property="cid" /> +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ks.tool.bkz.dao.mybatis.TBGoodsInfoMapper" > + <resultMap id="BaseResultMap" type="com.ks.tool.bkz.entity.TBGoodsInfo" > + <id column="id" property="id" jdbcType="BIGINT" /> + <result column="goods_id" property="goodsId" jdbcType="BIGINT" /> + <result column="title" property="title" jdbcType="VARCHAR" /> + <result column="imgs" property="imgs" jdbcType="VARCHAR" /> + <result column="zk_price" property="zkPrice" jdbcType="DECIMAL" /> + <result column="coupon_info" property="couponInfo" jdbcType="VARCHAR" /> + <result column="coupon_amount" property="couponAmount" jdbcType="DECIMAL" /> + <result column="coupon_start_price" property="couponStartPrice" jdbcType="DECIMAL" /> + <result column="coupon_total_count" property="couponTotalCount" jdbcType="INTEGER" /> + <result column="coupon_left_count" property="couponLeftCount" jdbcType="INTEGER" /> + <result column="coupon_start_time" property="couponStartTime" jdbcType="VARCHAR" /> + <result column="coupon_end_time" property="couponEndTime" jdbcType="VARCHAR" /> + <result column="coupon_price" property="couponPrice" jdbcType="DECIMAL" /> + <result column="sales_num" property="salesNum" jdbcType="INTEGER" /> + <result column="commission_rate" property="commissionRate" jdbcType="DECIMAL" /> + <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> + <result column="tmall" property="tmall" jdbcType="INTEGER" /> + <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> + <result column="cid" property="cid" jdbcType="INTEGER" /> + <result column="tkl" property="tkl" jdbcType="VARCHAR" /> + <result column="tkl_update_time" property="tklUpdateTime" jdbcType="TIMESTAMP" /> </resultMap> - <sql id="Base_Column_List"> + <sql id="Base_Column_List" > id, goods_id, title, imgs, zk_price, coupon_info, coupon_amount, coupon_start_price, coupon_total_count, coupon_left_count, coupon_start_time, coupon_end_time, coupon_price, - sales_num, commission_rate, create_time, tmall, update_time, cid + sales_num, commission_rate, create_time, tmall, update_time, cid, tkl, tkl_update_time </sql> - <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > select <include refid="Base_Column_List" /> from tt_tb_goods_info @@ -40,210 +42,228 @@ from tt_tb_goods_info where goods_id = #{0} </select> - - - <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > delete from tt_tb_goods_info where id = #{id,jdbcType=BIGINT} </delete> - <insert id="insert" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo"> + <insert id="insert" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo" > insert into tt_tb_goods_info (id, goods_id, title, imgs, zk_price, coupon_info, coupon_amount, coupon_start_price, coupon_total_count, coupon_left_count, coupon_start_time, coupon_end_time, coupon_price, sales_num, commission_rate, create_time, tmall, update_time, - cid) + cid, tkl, tkl_update_time + ) values (#{id,jdbcType=BIGINT}, #{goodsId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{imgs,jdbcType=VARCHAR}, #{zkPrice,jdbcType=DECIMAL}, #{couponInfo,jdbcType=VARCHAR}, #{couponAmount,jdbcType=DECIMAL}, #{couponStartPrice,jdbcType=DECIMAL}, #{couponTotalCount,jdbcType=INTEGER}, #{couponLeftCount,jdbcType=INTEGER}, #{couponStartTime,jdbcType=VARCHAR}, #{couponEndTime,jdbcType=VARCHAR}, #{couponPrice,jdbcType=DECIMAL}, #{salesNum,jdbcType=INTEGER}, #{commissionRate,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{tmall,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, - #{cid,jdbcType=INTEGER}) + #{cid,jdbcType=INTEGER}, #{tkl,jdbcType=VARCHAR}, #{tklUpdateTime,jdbcType=TIMESTAMP} + ) </insert> - <insert id="insertSelective" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo"> + <insert id="insertSelective" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo" > insert into tt_tb_goods_info - <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null"> + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="id != null" > id, </if> - <if test="goodsId != null"> + <if test="goodsId != null" > goods_id, </if> - <if test="title != null"> + <if test="title != null" > title, </if> - <if test="imgs != null"> + <if test="imgs != null" > imgs, </if> - <if test="zkPrice != null"> + <if test="zkPrice != null" > zk_price, </if> - <if test="couponInfo != null"> + <if test="couponInfo != null" > coupon_info, </if> - <if test="couponAmount != null"> + <if test="couponAmount != null" > coupon_amount, </if> - <if test="couponStartPrice != null"> + <if test="couponStartPrice != null" > coupon_start_price, </if> - <if test="couponTotalCount != null"> + <if test="couponTotalCount != null" > coupon_total_count, </if> - <if test="couponLeftCount != null"> + <if test="couponLeftCount != null" > coupon_left_count, </if> - <if test="couponStartTime != null"> + <if test="couponStartTime != null" > coupon_start_time, </if> - <if test="couponEndTime != null"> + <if test="couponEndTime != null" > coupon_end_time, </if> - <if test="couponPrice != null"> + <if test="couponPrice != null" > coupon_price, </if> - <if test="salesNum != null"> + <if test="salesNum != null" > sales_num, </if> - <if test="commissionRate != null"> + <if test="commissionRate != null" > commission_rate, </if> - <if test="createTime != null"> + <if test="createTime != null" > create_time, </if> - <if test="tmall != null"> + <if test="tmall != null" > tmall, </if> - <if test="updateTime != null"> + <if test="updateTime != null" > update_time, </if> - <if test="cid != null"> + <if test="cid != null" > cid, </if> + <if test="tkl != null" > + tkl, + </if> + <if test="tklUpdateTime != null" > + tkl_update_time, + </if> </trim> - <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null"> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="id != null" > #{id,jdbcType=BIGINT}, </if> - <if test="goodsId != null"> + <if test="goodsId != null" > #{goodsId,jdbcType=BIGINT}, </if> - <if test="title != null"> + <if test="title != null" > #{title,jdbcType=VARCHAR}, </if> - <if test="imgs != null"> + <if test="imgs != null" > #{imgs,jdbcType=VARCHAR}, </if> - <if test="zkPrice != null"> + <if test="zkPrice != null" > #{zkPrice,jdbcType=DECIMAL}, </if> - <if test="couponInfo != null"> + <if test="couponInfo != null" > #{couponInfo,jdbcType=VARCHAR}, </if> - <if test="couponAmount != null"> + <if test="couponAmount != null" > #{couponAmount,jdbcType=DECIMAL}, </if> - <if test="couponStartPrice != null"> + <if test="couponStartPrice != null" > #{couponStartPrice,jdbcType=DECIMAL}, </if> - <if test="couponTotalCount != null"> + <if test="couponTotalCount != null" > #{couponTotalCount,jdbcType=INTEGER}, </if> - <if test="couponLeftCount != null"> + <if test="couponLeftCount != null" > #{couponLeftCount,jdbcType=INTEGER}, </if> - <if test="couponStartTime != null"> + <if test="couponStartTime != null" > #{couponStartTime,jdbcType=VARCHAR}, </if> - <if test="couponEndTime != null"> + <if test="couponEndTime != null" > #{couponEndTime,jdbcType=VARCHAR}, </if> - <if test="couponPrice != null"> + <if test="couponPrice != null" > #{couponPrice,jdbcType=DECIMAL}, </if> - <if test="salesNum != null"> + <if test="salesNum != null" > #{salesNum,jdbcType=INTEGER}, </if> - <if test="commissionRate != null"> + <if test="commissionRate != null" > #{commissionRate,jdbcType=DECIMAL}, </if> - <if test="createTime != null"> + <if test="createTime != null" > #{createTime,jdbcType=TIMESTAMP}, </if> - <if test="tmall != null"> + <if test="tmall != null" > #{tmall,jdbcType=INTEGER}, </if> - <if test="updateTime != null"> + <if test="updateTime != null" > #{updateTime,jdbcType=TIMESTAMP}, </if> - <if test="cid != null"> + <if test="cid != null" > #{cid,jdbcType=INTEGER}, + </if> + <if test="tkl != null" > + #{tkl,jdbcType=VARCHAR}, + </if> + <if test="tklUpdateTime != null" > + #{tklUpdateTime,jdbcType=TIMESTAMP}, </if> </trim> </insert> - <update id="updateByPrimaryKeySelective" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo"> + <update id="updateByPrimaryKeySelective" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo" > update tt_tb_goods_info - <set> - <if test="goodsId != null"> + <set > + <if test="goodsId != null" > goods_id = #{goodsId,jdbcType=BIGINT}, </if> - <if test="title != null"> + <if test="title != null" > title = #{title,jdbcType=VARCHAR}, </if> - <if test="imgs != null"> + <if test="imgs != null" > imgs = #{imgs,jdbcType=VARCHAR}, </if> - <if test="zkPrice != null"> + <if test="zkPrice != null" > zk_price = #{zkPrice,jdbcType=DECIMAL}, </if> - <if test="couponInfo != null"> + <if test="couponInfo != null" > coupon_info = #{couponInfo,jdbcType=VARCHAR}, </if> - <if test="couponAmount != null"> + <if test="couponAmount != null" > coupon_amount = #{couponAmount,jdbcType=DECIMAL}, </if> - <if test="couponStartPrice != null"> + <if test="couponStartPrice != null" > coupon_start_price = #{couponStartPrice,jdbcType=DECIMAL}, </if> - <if test="couponTotalCount != null"> + <if test="couponTotalCount != null" > coupon_total_count = #{couponTotalCount,jdbcType=INTEGER}, </if> - <if test="couponLeftCount != null"> + <if test="couponLeftCount != null" > coupon_left_count = #{couponLeftCount,jdbcType=INTEGER}, </if> - <if test="couponStartTime != null"> + <if test="couponStartTime != null" > coupon_start_time = #{couponStartTime,jdbcType=VARCHAR}, </if> - <if test="couponEndTime != null"> + <if test="couponEndTime != null" > coupon_end_time = #{couponEndTime,jdbcType=VARCHAR}, </if> - <if test="couponPrice != null"> + <if test="couponPrice != null" > coupon_price = #{couponPrice,jdbcType=DECIMAL}, </if> - <if test="salesNum != null"> + <if test="salesNum != null" > sales_num = #{salesNum,jdbcType=INTEGER}, </if> - <if test="commissionRate != null"> + <if test="commissionRate != null" > commission_rate = #{commissionRate,jdbcType=DECIMAL}, </if> - <if test="createTime != null"> + <if test="createTime != null" > create_time = #{createTime,jdbcType=TIMESTAMP}, </if> - <if test="tmall != null"> + <if test="tmall != null" > tmall = #{tmall,jdbcType=INTEGER}, </if> - <if test="updateTime != null"> + <if test="updateTime != null" > update_time = #{updateTime,jdbcType=TIMESTAMP}, </if> - <if test="cid != null"> + <if test="cid != null" > cid = #{cid,jdbcType=INTEGER}, + </if> + <if test="tkl != null" > + tkl = #{tkl,jdbcType=VARCHAR}, + </if> + <if test="tklUpdateTime != null" > + tkl_update_time = #{tklUpdateTime,jdbcType=TIMESTAMP}, </if> </set> where id = #{id,jdbcType=BIGINT} </update> - <update id="updateByPrimaryKey" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo"> + <update id="updateByPrimaryKey" parameterType="com.ks.tool.bkz.entity.TBGoodsInfo" > update tt_tb_goods_info set goods_id = #{goodsId,jdbcType=BIGINT}, title = #{title,jdbcType=VARCHAR}, @@ -262,7 +282,9 @@ create_time = #{createTime,jdbcType=TIMESTAMP}, tmall = #{tmall,jdbcType=INTEGER}, update_time = #{updateTime,jdbcType=TIMESTAMP}, - cid = #{cid,jdbcType=INTEGER} + cid = #{cid,jdbcType=INTEGER}, + tkl = #{tkl,jdbcType=VARCHAR}, + tkl_update_time = #{tklUpdateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} </update> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/sdlj/SDLJDocTemplateMapper.xml b/src/main/resources/mapper/sdlj/SDLJDocTemplateMapper.xml new file mode 100644 index 0000000..00a3c18 --- /dev/null +++ b/src/main/resources/mapper/sdlj/SDLJDocTemplateMapper.xml @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.ks.tool.bkz.dao.mybatis.sdlj.SDLJDocTemplateMapper" > + <resultMap id="BaseResultMap" type="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + <id column="id" property="id" jdbcType="BIGINT" /> + <result column="uid" property="uid" jdbcType="BIGINT" /> + <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> + <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> + </resultMap> + <resultMap id="ResultMapWithBLOBs" type="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" extends="BaseResultMap" > + <result column="template" property="template" jdbcType="LONGVARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + id, uid, create_time, update_time + </sql> + <sql id="Blob_Column_List" > + template + </sql> + <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" > + select + <include refid="Base_Column_List" /> + , + <include refid="Blob_Column_List" /> + from tt_sdlj_doc_template + where id = #{id,jdbcType=BIGINT} + </select> + + <select id="listByUid" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" > + select + <include refid="Base_Column_List" /> + , + <include refid="Blob_Column_List" /> + from tt_sdlj_doc_template + where uid = #{0} + </select> + + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" > + delete from tt_sdlj_doc_template + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + insert into tt_sdlj_doc_template (id, uid, create_time, + update_time, template) + values (#{id,jdbcType=BIGINT}, #{uid,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}, #{template,jdbcType=LONGVARCHAR}) + </insert> + <insert id="insertSelective" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + insert into tt_sdlj_doc_template + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="id != null" > + id, + </if> + <if test="uid != null" > + uid, + </if> + <if test="createTime != null" > + create_time, + </if> + <if test="updateTime != null" > + update_time, + </if> + <if test="template != null" > + template, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="id != null" > + #{id,jdbcType=BIGINT}, + </if> + <if test="uid != null" > + #{uid,jdbcType=BIGINT}, + </if> + <if test="createTime != null" > + #{createTime,jdbcType=TIMESTAMP}, + </if> + <if test="updateTime != null" > + #{updateTime,jdbcType=TIMESTAMP}, + </if> + <if test="template != null" > + #{template,jdbcType=LONGVARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + update tt_sdlj_doc_template + <set > + <if test="uid != null" > + uid = #{uid,jdbcType=BIGINT}, + </if> + <if test="createTime != null" > + create_time = #{createTime,jdbcType=TIMESTAMP}, + </if> + <if test="updateTime != null" > + update_time = #{updateTime,jdbcType=TIMESTAMP}, + </if> + <if test="template != null" > + template = #{template,jdbcType=LONGVARCHAR}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + update tt_sdlj_doc_template + set uid = #{uid,jdbcType=BIGINT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + template = #{template,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJDocTemplate" > + update tt_sdlj_doc_template + set uid = #{uid,jdbcType=BIGINT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + </update> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/sdlj/SDLJUserGoodsMapper.xml b/src/main/resources/mapper/sdlj/SDLJUserGoodsMapper.xml index a2aaa7c..eb43d6a 100644 --- a/src/main/resources/mapper/sdlj/SDLJUserGoodsMapper.xml +++ b/src/main/resources/mapper/sdlj/SDLJUserGoodsMapper.xml @@ -18,6 +18,7 @@ <result column="actualPrice" property="actualPrice" jdbcType="DECIMAL"/> <result column="commissionRate" property="commissionRate" jdbcType="DECIMAL"/> <result column="imgs" property="imgs" jdbcType="VARCHAR"/> + <result column="tkl" property="tkl" jdbcType="VARCHAR"/> </resultMap> <sql id="Base_Column_List"> @@ -180,7 +181,7 @@ <select id="query" resultMap="QueryResultMap"> SELECT tg.`title` AS title,tg.`zk_price` AS zkPrice,tg.`coupon_price` AS couponPrice,s.`promotion_amount` AS lijinAmount,tg.`goods_id` AS goodsId,(tg.`coupon_price`-s.`promotion_amount`) AS actualPrice, - tg.`commission_rate` AS commissionRate,tg.`imgs` AS imgs,tg.sales_num as salesNum,tg.coupon_amount as couponAmount,tg.tmall + tg.`commission_rate` AS commissionRate,tg.`imgs` AS imgs,tg.sales_num as salesNum,tg.coupon_amount as couponAmount,tg.tmall,tg.tkl FROM `tt_user_goods` t LEFT JOIN `tt_sdlj_goods_info` s ON s.`goods_id`=t.`goods_id` LEFT JOIN `tt_tb_goods_info` tg ON tg.`goods_id`=t.`goods_id` diff --git a/src/test/java/com/ks/tool/bkz/GoodsTest.java b/src/test/java/com/ks/tool/bkz/GoodsTest.java index b6854fc..25ed59e 100644 --- a/src/test/java/com/ks/tool/bkz/GoodsTest.java +++ b/src/test/java/com/ks/tool/bkz/GoodsTest.java @@ -3,17 +3,25 @@ import com.ks.tool.bkz.dto.DaTaoKeDetailV2; import com.ks.tool.bkz.util.factory.TBGoodsInfoFactory; import com.ks.tool.bkz.util.tb.DaTaoKeApiUtil; +import com.ks.tool.bkz.util.tb.ZheTaoKeApiUtil; +import com.ks.tool.bkz.vo.tb.ZheTaoKeConvertResult; import org.junit.jupiter.api.Test; public class GoodsTest { @Test - public void daTaoKe(){ - DaTaoKeDetailV2 dg= DaTaoKeApiUtil.getGoodsDetailByGoodsId(568984817165L); + public void daTaoKe() { + DaTaoKeDetailV2 dg = DaTaoKeApiUtil.getGoodsDetailByGoodsId(568984817165L); TBGoodsInfoFactory.create(dg); } + @Test + public void zheTaoKe() { + ZheTaoKeConvertResult token = ZheTaoKeApiUtil.getTkl(596804372243L); + System.out.println(token); + } + } -- Gitblit v1.8.0