mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-17 00:08:35 +08:00
update 分成功能
This commit is contained in:
@@ -2,6 +2,8 @@ package com.jsowell.pile.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参与分账的用户详情
|
* 参与分账的用户详情
|
||||||
*/
|
*/
|
||||||
@@ -11,10 +13,10 @@ public class SplitUserDetailDTO {
|
|||||||
private String adapayMemberId;
|
private String adapayMemberId;
|
||||||
|
|
||||||
// 电量分成比例
|
// 电量分成比例
|
||||||
private String electricitySplitRatio;
|
private BigDecimal electricitySplitRatio;
|
||||||
|
|
||||||
// 服务费分成比例
|
// 服务费分成比例
|
||||||
private String serviceSplitRatio;
|
private BigDecimal serviceSplitRatio;
|
||||||
|
|
||||||
// 是否手续费承担方,N-否,Y-是,手续费承担方有且只能有一个
|
// 是否手续费承担方,N-否,Y-是,手续费承担方有且只能有一个
|
||||||
private String feeFlag;
|
private String feeFlag;
|
||||||
|
|||||||
@@ -12,4 +12,9 @@ public interface StationSplitConfigMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<StationSplitConfig> queryByStationId(String stationId);
|
List<StationSplitConfig> queryByStationId(String stationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入站点分账配置
|
||||||
|
*/
|
||||||
|
int batchInsert(List<StationSplitConfig> splitConfigList);
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.jsowell.pile.domain.StationSplitConfig;
|
import com.jsowell.pile.domain.StationSplitConfig;
|
||||||
import com.jsowell.pile.dto.SplitConfigDTO;
|
import com.jsowell.pile.dto.SplitConfigDTO;
|
||||||
|
import com.jsowell.pile.dto.SplitUserDetailDTO;
|
||||||
import com.jsowell.pile.mapper.StationSplitConfigMapper;
|
import com.jsowell.pile.mapper.StationSplitConfigMapper;
|
||||||
import com.jsowell.pile.service.StationSplitConfigService;
|
import com.jsowell.pile.service.StationSplitConfigService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -22,6 +25,34 @@ public class StationSplitConfigServiceImpl implements StationSplitConfigService{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertSplitConfig(SplitConfigDTO splitConfigDTO) {
|
public int insertSplitConfig(SplitConfigDTO splitConfigDTO) {
|
||||||
return 0;
|
// 参与分成的用户不能超过7位
|
||||||
|
if (splitConfigDTO.getSplitUserDetailList().size() > 7) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// 校验分成比例相加是否为100.0%
|
||||||
|
List<SplitUserDetailDTO> splitUserDetailList = splitConfigDTO.getSplitUserDetailList();
|
||||||
|
BigDecimal totalElectricitySplitRatio = BigDecimal.ZERO;
|
||||||
|
BigDecimal totalServiceSplitRatio = BigDecimal.ZERO;
|
||||||
|
for (SplitUserDetailDTO splitUserDetailDTO : splitUserDetailList) {
|
||||||
|
totalElectricitySplitRatio = totalElectricitySplitRatio.add(splitUserDetailDTO.getElectricitySplitRatio());
|
||||||
|
totalServiceSplitRatio = totalServiceSplitRatio.add(splitUserDetailDTO.getServiceSplitRatio());
|
||||||
|
}
|
||||||
|
if (totalElectricitySplitRatio.compareTo(BigDecimal.valueOf(100)) != 0 || totalServiceSplitRatio.compareTo(BigDecimal.valueOf(100)) != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存到数据库
|
||||||
|
List<StationSplitConfig> splitConfigList = Lists.newArrayList();
|
||||||
|
for (SplitUserDetailDTO splitUserDetailDTO : splitUserDetailList) {
|
||||||
|
StationSplitConfig splitConfig = StationSplitConfig.builder()
|
||||||
|
.merchantId(splitConfigDTO.getMerchantId())
|
||||||
|
.stationId(splitConfigDTO.getStationId())
|
||||||
|
.adapayMemberId(splitUserDetailDTO.getAdapayMemberId())
|
||||||
|
.electricitySplitRatio(splitUserDetailDTO.getElectricitySplitRatio())
|
||||||
|
.serviceSplitRatio(splitUserDetailDTO.getServiceSplitRatio())
|
||||||
|
.build();
|
||||||
|
splitConfigList.add(splitConfig);
|
||||||
|
}
|
||||||
|
return stationSplitConfigMapper.batchInsert(splitConfigList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,19 @@
|
|||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
and station_id = #{stationId}
|
and station_id = #{stationId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="map">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
insert into station_split_config
|
||||||
|
(id, merchant_id, station_id, adapay_member_id, electricity_split_ratio, service_split_ratio,
|
||||||
|
create_by, create_time, update_by, update_time, del_flag)
|
||||||
|
values
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.id,jdbcType=INTEGER}, #{item.merchantId,jdbcType=VARCHAR}, #{item.stationId,jdbcType=VARCHAR},
|
||||||
|
#{item.adapayMemberId,jdbcType=VARCHAR}, #{item.electricitySplitRatio,jdbcType=DECIMAL},
|
||||||
|
#{item.serviceSplitRatio,jdbcType=DECIMAL}, #{item.createBy,jdbcType=VARCHAR},
|
||||||
|
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
|
||||||
|
#{item.delFlag,jdbcType=CHAR})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user