|
|
@@ -76,17 +76,25 @@ public class DistributeServiceImpl implements DistributeService {
|
|
|
userDistribute.setRemark(userDistributeReq.getRemark());
|
|
|
userDistributeMapper.updateById(userDistribute);
|
|
|
for (UserPlatDistributeRate rate : userDistributeReq.getRates()) {
|
|
|
- if (rate.getRate() <0 || rate.getRate() > 100) {
|
|
|
+ if (rate.getRate() < 0 || rate.getRate() > 100) {
|
|
|
throw new BusinessRuntimeException("比例错误");
|
|
|
}
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(rate.getGoodsId());
|
|
|
+ if (rate.getId() != null) {
|
|
|
+ userPlatDistributeRateMapper.deleteById(rate.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (goodsDon == null || !goodsDon.getDeleted() || goodsDon.getType() == 3) {
|
|
|
throw new BusinessRuntimeException("平台错误");
|
|
|
}
|
|
|
rate.setDistributeId(userDistribute.getId());
|
|
|
if (rate.getId() == null) {
|
|
|
- userPlatDistributeRateMapper.insert(rate);
|
|
|
- }else {
|
|
|
+ try {
|
|
|
+ userPlatDistributeRateMapper.insert(rate);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
userPlatDistributeRateMapper.updateById(rate);
|
|
|
}
|
|
|
}
|