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); } } src/main/java/com/ks/tool/bkz/dao/mybatis/sdlj/SDLJDocTemplateMapper.java
New file @@ -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); } 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; src/main/java/com/ks/tool/bkz/entity/sdlj/SDLJDocTemplate.java
New file @@ -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; } } src/main/java/com/ks/tool/bkz/exception/SDLJDocTemplateException.java
New file @@ -0,0 +1,9 @@ package com.ks.tool.bkz.exception; public class SDLJDocTemplateException extends BaseException{ public SDLJDocTemplateException(int code, String msg) { super(code, msg); } } 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天更新淘口令 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); } } src/main/java/com/ks/tool/bkz/service/impl/sdlj/SDLJDocTemplateServiceImpl.java
New file @@ -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, "参数不完整"); //验证格式是否正确 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()); } } } 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; } src/main/java/com/ks/tool/bkz/service/sdlj/SDLJDocTemplateService.java
New file @@ -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); } 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 { /** src/main/java/com/ks/tool/bkz/util/sdlj/DocTemplateUtil.java
New file @@ -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; } } src/main/java/com/ks/tool/bkz/util/tb/ZheTaoKeApiUtil.java
New file @@ -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; } } 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; src/main/java/com/ks/tool/bkz/vo/tb/ZheTaoKeConvertResult.java
New file @@ -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; } } 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:是否让schema作为包的后缀 --> <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> </context> </generatorConfiguration> 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> src/main/resources/mapper/sdlj/SDLJDocTemplateMapper.xml
New file @@ -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> 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` 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); } }