Authored by gemingdan

update

... ... @@ -59,7 +59,7 @@
#{logId,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateBrand" >
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateBrand" >
insert into union_share_rebate_brand
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ...
... ... @@ -22,7 +22,7 @@
delete from union_share_rebate_log
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
insert into union_share_rebate_log (id, rebate_id, type,
last, record, create_time
)
... ... @@ -30,7 +30,7 @@
#{last,jdbcType=INTEGER}, #{record,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
insert into union_share_rebate_log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -105,7 +105,7 @@
</update>
<update id="updateRebateIdById" parameterType="com.yoho.unions.dal.model.UnionShareRebateLog" >
update union_share_rebate_log
set rebate_id = #{rebateId,jdbcType=INTEGER},
set rebate_id = #{rebateId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -62,7 +62,7 @@
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, #{logId,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareRebateSkn" >
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareRebateSkn" >
insert into union_share_rebate_skn
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ...
... ... @@ -86,7 +86,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
@Override
public int addSkn(UnionShareRebateBo req){
logger.info("addSkn start.req is {}.",req);
UnionShareRebateSkn rebateSkn = new UnionShareRebateSkn();
UnionShareRebateSkn rebateSkn = unionShareRebateSknMapper.selectBySkn(req.getSkn());
if (rebateSkn != null) {
logger.info("addSkn end.skn exist.req is {}.",req);
return 0;
}
rebateSkn = new UnionShareRebateSkn();
BeanUtils.copyProperties(req,rebateSkn);
if (rebateSkn.getBrand() == null) {
Map<Integer,ProductBo> productBoMap=gerProductInfoMap(Arrays.asList(rebateSkn.getSkn()));
... ... @@ -117,16 +122,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
if (req.getId() == null) {
return addSkn(req);
}
UnionShareRebateSkn rebateSkn = unionShareRebateSknMapper.selectByPrimaryKey(req.getId());
if (rebateSkn == null) {
UnionShareRebateSkn shareRebateSkn = unionShareRebateSknMapper.selectByPrimaryKey(req.getId());
if (shareRebateSkn == null) {
return addSkn(req);
}
UnionShareRebateSkn rebateSkn = new UnionShareRebateSkn();
BeanUtils.copyProperties(req,rebateSkn);
if(!StringUtils.isBlank(req.getRebatePercentStr())){
rebateSkn.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
}
rebateSkn.setLastLogId(rebateSkn.getLogId());
int logid = addOptLog(req, rebateSkn.getLogId(), 1, rebateSkn.getId());
rebateSkn.setId(shareRebateSkn.getId());
rebateSkn.setLastLogId(shareRebateSkn.getLogId());
int logid = addOptLog(req, shareRebateSkn.getLogId(), 1, shareRebateSkn.getId());
rebateSkn.setLogId(logid);
rebateSkn.setUpdateTime(DateUtil.getCurrentTimeSeconds());
int result = unionShareRebateSknMapper.updateWithLogid(rebateSkn);
... ... @@ -188,7 +195,12 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
@Override
public int addBrand(UnionShareRebateBo req){
logger.info("addBrand start.req is {}.",req);
UnionShareRebateBrand rebateBrand = new UnionShareRebateBrand();
UnionShareRebateBrand rebateBrand = unionShareRebateBrandMapper.selectByBrand(req.getBrand());
if (rebateBrand != null) {
logger.info("addBrand end.brand exist.req is {}.",req);
return 0;
}
rebateBrand = new UnionShareRebateBrand();
BeanUtils.copyProperties(req,rebateBrand);
rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
int logid = addOptLog(req, 0, 2, req.getBrand());
... ... @@ -210,16 +222,18 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
if (req.getId() == null) {
return addBrand(req);
}
UnionShareRebateBrand rebateBrand = unionShareRebateBrandMapper.selectByPrimaryKey(req.getId());
if (rebateBrand == null) {
UnionShareRebateBrand shareRebateBrand = unionShareRebateBrandMapper.selectByPrimaryKey(req.getId());
if (shareRebateBrand == null) {
return addBrand(req);
}
UnionShareRebateBrand rebateBrand = new UnionShareRebateBrand();
BeanUtils.copyProperties(req,rebateBrand);
rebateBrand.setLastLogId(rebateBrand.getLogId());
rebateBrand.setId(shareRebateBrand.getId());
rebateBrand.setLastLogId(shareRebateBrand.getLogId());
if(!StringUtils.isBlank(req.getRebatePercentStr())){
rebateBrand.setRebate((new BigDecimal(req.getRebatePercentStr())).multiply(new BigDecimal(100)).intValue());
}
int logid = addOptLog(req, rebateBrand.getLogId(), 2, rebateBrand.getId());
int logid = addOptLog(req, shareRebateBrand.getLogId(), 2, shareRebateBrand.getId());
rebateBrand.setLogId(logid);
rebateBrand.setUpdateTime(DateUtil.getCurrentTimeSecond());
int result = unionShareRebateBrandMapper.updateWithLogid(rebateBrand);
... ...