Authored by gemingdan

update

@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 #{logId,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER} 59 #{logId,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}
60 ) 60 )
61 </insert> 61 </insert>
62 - <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateBrand" > 62 + <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateBrand" >
63 insert into union_share_rebate_brand 63 insert into union_share_rebate_brand
64 <trim prefix="(" suffix=")" suffixOverrides="," > 64 <trim prefix="(" suffix=")" suffixOverrides="," >
65 <if test="id != null" > 65 <if test="id != null" >
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 delete from union_share_rebate_log 22 delete from union_share_rebate_log
23 where id = #{id,jdbcType=INTEGER} 23 where id = #{id,jdbcType=INTEGER}
24 </delete> 24 </delete>
25 - <insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" > 25 + <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
26 insert into union_share_rebate_log (id, rebate_id, type, 26 insert into union_share_rebate_log (id, rebate_id, type,
27 last, record, create_time 27 last, record, create_time
28 ) 28 )
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 #{last,jdbcType=INTEGER}, #{record,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER} 30 #{last,jdbcType=INTEGER}, #{record,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}
31 ) 31 )
32 </insert> 32 </insert>
33 - <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" > 33 + <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
34 insert into union_share_rebate_log 34 insert into union_share_rebate_log
35 <trim prefix="(" suffix=")" suffixOverrides="," > 35 <trim prefix="(" suffix=")" suffixOverrides="," >
36 <if test="id != null" > 36 <if test="id != null" >
@@ -105,7 +105,7 @@ @@ -105,7 +105,7 @@
105 </update> 105 </update>
106 <update id="updateRebateIdById" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" > 106 <update id="updateRebateIdById" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
107 update union_share_rebate_log 107 update union_share_rebate_log
108 - set rebate_id = #{rebateId,jdbcType=INTEGER}, 108 + set rebate_id = #{rebateId,jdbcType=INTEGER}
109 where id = #{id,jdbcType=INTEGER} 109 where id = #{id,jdbcType=INTEGER}
110 </update> 110 </update>
111 </mapper> 111 </mapper>
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{logId,jdbcType=INTEGER} 62 #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{logId,jdbcType=INTEGER}
63 ) 63 )
64 </insert> 64 </insert>
65 - <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateSkn" > 65 + <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateSkn" >
66 insert into union_share_rebate_skn 66 insert into union_share_rebate_skn
67 <trim prefix="(" suffix=")" suffixOverrides="," > 67 <trim prefix="(" suffix=")" suffixOverrides="," >
68 <if test="id != null" > 68 <if test="id != null" >
@@ -86,7 +86,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -86,7 +86,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
86 @Override 86 @Override
87 public int addSkn(UnionShareRebateBo req){ 87 public int addSkn(UnionShareRebateBo req){
88 logger.info("addSkn start.req is {}.",req); 88 logger.info("addSkn start.req is {}.",req);
89 - UnionShareRebateSkn rebateSkn = new UnionShareRebateSkn(); 89 + UnionShareRebateSkn rebateSkn = unionShareRebateSknMapper.selectBySkn(req.getSkn());
  90 + if (rebateSkn != null) {
  91 + logger.info("addSkn end.skn exist.req is {}.",req);
  92 + return 0;
  93 + }
  94 + rebateSkn = new UnionShareRebateSkn();
90 BeanUtils.copyProperties(req,rebateSkn); 95 BeanUtils.copyProperties(req,rebateSkn);
91 if (rebateSkn.getBrand() == null) { 96 if (rebateSkn.getBrand() == null) {
92 Map<Integer,ProductBo> productBoMap=gerProductInfoMap(Arrays.asList(rebateSkn.getSkn())); 97 Map<Integer,ProductBo> productBoMap=gerProductInfoMap(Arrays.asList(rebateSkn.getSkn()));
@@ -117,16 +122,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -117,16 +122,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
117 if (req.getId() == null) { 122 if (req.getId() == null) {
118 return addSkn(req); 123 return addSkn(req);
119 } 124 }
120 - UnionShareRebateSkn rebateSkn = unionShareRebateSknMapper.selectByPrimaryKey(req.getId());  
121 - if (rebateSkn == null) { 125 + UnionShareRebateSkn shareRebateSkn = unionShareRebateSknMapper.selectByPrimaryKey(req.getId());
  126 + if (shareRebateSkn == null) {
122 return addSkn(req); 127 return addSkn(req);
123 } 128 }
  129 + UnionShareRebateSkn rebateSkn = new UnionShareRebateSkn();
124 BeanUtils.copyProperties(req,rebateSkn); 130 BeanUtils.copyProperties(req,rebateSkn);
125 if(!StringUtils.isBlank(req.getRebatePercentStr())){ 131 if(!StringUtils.isBlank(req.getRebatePercentStr())){
126 rebateSkn.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue()); 132 rebateSkn.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
127 } 133 }
128 - rebateSkn.setLastLogId(rebateSkn.getLogId());  
129 - int logid = addOptLog(req, rebateSkn.getLogId(), 1, rebateSkn.getId()); 134 + rebateSkn.setId(shareRebateSkn.getId());
  135 + rebateSkn.setLastLogId(shareRebateSkn.getLogId());
  136 + int logid = addOptLog(req, shareRebateSkn.getLogId(), 1, shareRebateSkn.getId());
130 rebateSkn.setLogId(logid); 137 rebateSkn.setLogId(logid);
131 rebateSkn.setUpdateTime(DateUtil.getCurrentTimeSeconds()); 138 rebateSkn.setUpdateTime(DateUtil.getCurrentTimeSeconds());
132 int result = unionShareRebateSknMapper.updateWithLogid(rebateSkn); 139 int result = unionShareRebateSknMapper.updateWithLogid(rebateSkn);
@@ -188,7 +195,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -188,7 +195,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
188 @Override 195 @Override
189 public int addBrand(UnionShareRebateBo req){ 196 public int addBrand(UnionShareRebateBo req){
190 logger.info("addBrand start.req is {}.",req); 197 logger.info("addBrand start.req is {}.",req);
191 - UnionShareRebateBrand rebateBrand = new UnionShareRebateBrand(); 198 + UnionShareRebateBrand rebateBrand = unionShareRebateBrandMapper.selectByBrand(req.getBrand());
  199 + if (rebateBrand != null) {
  200 + logger.info("addBrand end.brand exist.req is {}.",req);
  201 + return 0;
  202 + }
  203 + rebateBrand = new UnionShareRebateBrand();
192 BeanUtils.copyProperties(req,rebateBrand); 204 BeanUtils.copyProperties(req,rebateBrand);
193 rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue()); 205 rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
194 int logid = addOptLog(req, 0, 2, req.getBrand()); 206 int logid = addOptLog(req, 0, 2, req.getBrand());
@@ -210,16 +222,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -210,16 +222,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
210 if (req.getId() == null) { 222 if (req.getId() == null) {
211 return addBrand(req); 223 return addBrand(req);
212 } 224 }
213 - UnionShareRebateBrand rebateBrand = unionShareRebateBrandMapper.selectByPrimaryKey(req.getId());  
214 - if (rebateBrand == null) { 225 + UnionShareRebateBrand shareRebateBrand = unionShareRebateBrandMapper.selectByPrimaryKey(req.getId());
  226 + if (shareRebateBrand == null) {
215 return addBrand(req); 227 return addBrand(req);
216 } 228 }
  229 + UnionShareRebateBrand rebateBrand = new UnionShareRebateBrand();
217 BeanUtils.copyProperties(req,rebateBrand); 230 BeanUtils.copyProperties(req,rebateBrand);
218 - rebateBrand.setLastLogId(rebateBrand.getLogId()); 231 + rebateBrand.setId(shareRebateBrand.getId());
  232 + rebateBrand.setLastLogId(shareRebateBrand.getLogId());
219 if(!StringUtils.isBlank(req.getRebatePercentStr())){ 233 if(!StringUtils.isBlank(req.getRebatePercentStr())){
220 rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue()); 234 rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
221 } 235 }
222 - int logid = addOptLog(req, rebateBrand.getLogId(), 2, rebateBrand.getId()); 236 + int logid = addOptLog(req, shareRebateBrand.getLogId(), 2, shareRebateBrand.getId());
223 rebateBrand.setLogId(logid); 237 rebateBrand.setLogId(logid);
224 rebateBrand.setUpdateTime(DateUtil.getCurrentTimeSecond()); 238 rebateBrand.setUpdateTime(DateUtil.getCurrentTimeSecond());
225 int result = unionShareRebateBrandMapper.updateWithLogid(rebateBrand); 239 int result = unionShareRebateBrandMapper.updateWithLogid(rebateBrand);