Commit efb19673 by 吕明尚

团购劵管理一个美团优惠券应该只能绑定一个规则

parent 84a49b51
......@@ -66,4 +66,6 @@ public interface SCouponMapper
List<SCoupon> listDuration(SCoupon sCoupon);
List<SCoupon> selectSCouponByDealgroupId(Long dealgroupId);
SCoupon selectByDealgroupId(Long dealgroupId);
}
......@@ -95,8 +95,12 @@ public class SCouponServiceImpl implements ISCouponService {
sCoupon.setMaxDuration(DEFAULT_MAX_DURATION);
sCoupon.setMinPrice(new BigDecimal("0.00"));
sCoupon.setCreateTime(DateUtils.getNowDate());
return sCouponMapper.insertSCoupon(sCoupon);
SCoupon sCouponList = sCouponMapper.selectByDealgroupId(sCoupon.getDealgroupId());
if (ObjectUtils.isEmpty(sCouponList)) {
return sCouponMapper.insertSCoupon(sCoupon);
} else {
throw new RuntimeException("该团购已存在");
}
}
/**
......@@ -108,7 +112,12 @@ public class SCouponServiceImpl implements ISCouponService {
@Override
public int updateSCoupon(SCoupon sCoupon) {
sCoupon.setUpdateTime(DateUtils.getNowDate());
return sCouponMapper.updateSCoupon(sCoupon);
SCoupon sCouponList = sCouponMapper.selectByDealgroupId(sCoupon.getDealgroupId());
if (ObjectUtils.isEmpty(sCouponList)) {
return sCouponMapper.updateSCoupon(sCoupon);
} else {
throw new RuntimeException("该团购已存在");
}
}
/**
......
......@@ -105,6 +105,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSCouponVo"/>
where dealgroup_id = #{dealgroupId}
</select>
<select id="selectByDealgroupId" resultMap="SCouponResult">
<include refid="selectSCouponVo"/>
where dealgroup_id = #{dealgroupId}
</select>
<insert id="insertSCoupon" parameterType="SCoupon" useGeneratedKeys="true" keyProperty="id">
insert into s_coupon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment