|
@@ -1,7 +1,7 @@
|
|
|
package com.hcloud.microserver.h5.service.impl;
|
|
|
|
|
|
-import com.hcloud.microserver.commoncore.util.string.StringUtils;
|
|
|
import com.hcloud.microserver.commoncore.util.UUIDUtils;
|
|
|
+import com.hcloud.microserver.commoncore.util.string.StringUtils;
|
|
|
import com.hcloud.microserver.h5.bo.ContributionBO;
|
|
|
import com.hcloud.microserver.h5.bo.MyCarbonValBO;
|
|
|
import com.hcloud.microserver.h5.bo.MyCarbonValInfoBO;
|
|
@@ -31,9 +31,9 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
|
|
|
public CustomerCarbonValRankVO getCustomerCarbonValRankList(CustomerCarbonValRankForm form) {
|
|
|
List<CustomerCarbonValRankForm> list = customerCarbonValMapper.getCustomerCarbonValRankList(form);
|
|
|
CustomerCarbonValRankVO vo = new CustomerCarbonValRankVO();
|
|
|
- if (list != null && list.size() > 0 && StringUtils.isNotEmpty(form.getCustomerId())){
|
|
|
+ if (list != null && list.size() > 0 && StringUtils.isNotEmpty(form.getCustomerId())) {
|
|
|
if ((form.getType() == 1 && form.getCustomerType() == 1) //查询当前客户排名
|
|
|
- || (form.getType() == 2 && form.getCustomerType() > 1)){
|
|
|
+ || (form.getType() == 2 && form.getCustomerType() > 1)) {
|
|
|
form.setCurrCustomerRank(true);
|
|
|
List<CustomerCarbonValRankForm> currCustomerRankList = customerCarbonValMapper.getCustomerCarbonValRankList(form);
|
|
|
if (currCustomerRankList != null && currCustomerRankList.size() > 0)
|
|
@@ -45,8 +45,8 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BigDecimal selectCarbonAmountByCustomerId(String guid){
|
|
|
- return customerCarbonValMapper.selectCarbonAmountByCustomerId(guid);
|
|
|
+ public BigDecimal selectCarbonAmountByCustomerId(String guid) {
|
|
|
+ return customerCarbonValMapper.selectCarbonAmountByCustomerId(guid);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@@ -60,42 +60,54 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
|
|
|
//获取消去碳汇量
|
|
|
Map<String, ContributionBO> subcarbonVal = customerCarbonValMapper.subcarbonVal(newYear);
|
|
|
|
|
|
- List<CustomerCarbonVal> customerCarbonValList=new ArrayList<>();
|
|
|
+ List<CustomerCarbonVal> customerCarbonValList = new ArrayList<>();
|
|
|
for (String tCustomerId : sumCarbonAmount.keySet()) {
|
|
|
- //获取单独一个人的总碳汇量
|
|
|
- BigDecimal totalcarbonAmount =new BigDecimal(0);
|
|
|
- ContributionBO contributionRe = sumCarbonAmount.get(tCustomerId);
|
|
|
- totalcarbonAmount = contributionRe.getCarbonAmount();
|
|
|
- //获取使用的碳汇量
|
|
|
- BigDecimal subCarbonAmount = new BigDecimal(0);
|
|
|
- ContributionBO subcarbonValRe = subcarbonVal.get(tCustomerId);
|
|
|
- //获取不到不赋值
|
|
|
- if(!org.springframework.util.StringUtils.isEmpty(subcarbonValRe)){
|
|
|
- subCarbonAmount = subcarbonValRe.getCarbonAmount();
|
|
|
+
|
|
|
+ ContributionBO contribution = customerCarbonValMapper.contribution(tCustomerId, newYear);
|
|
|
+ //如果以及贡献过了就不贡献了
|
|
|
+ if(org.springframework.util.StringUtils.isEmpty(contribution)){
|
|
|
+ //获取单独一个人的总碳汇量
|
|
|
+ BigDecimal totalcarbonAmount = new BigDecimal(0);
|
|
|
+ ContributionBO contributionRe = sumCarbonAmount.get(tCustomerId);
|
|
|
+ totalcarbonAmount = contributionRe.getCarbonAmount();
|
|
|
+ //获取使用的碳汇量
|
|
|
+ BigDecimal subCarbonAmount = new BigDecimal(0);
|
|
|
+ ContributionBO subcarbonValRe = subcarbonVal.get(tCustomerId);
|
|
|
+ //获取不到不赋值
|
|
|
+ if (!org.springframework.util.StringUtils.isEmpty(subcarbonValRe)) {
|
|
|
+ subCarbonAmount = subcarbonValRe.getCarbonAmount();
|
|
|
+ }
|
|
|
+ //得到剩余碳汇量
|
|
|
+ BigDecimal subtract = totalcarbonAmount.subtract(subCarbonAmount);
|
|
|
+ //还剩余0就不做共享
|
|
|
+ int i = subtract.compareTo(BigDecimal.ZERO);
|
|
|
+ if (i != 0) {
|
|
|
+ CustomerCarbonVal customerCarbonVal = new CustomerCarbonVal();
|
|
|
+ BeanUtils.copyProperties(contributionRe, customerCarbonVal);
|
|
|
+ String guid = UUIDUtils.randomUUID();
|
|
|
+ customerCarbonVal.setGuid(guid);
|
|
|
+ customerCarbonVal.setCarbonVal(subtract);
|
|
|
+ //使用碳汇量
|
|
|
+ customerCarbonVal.setStatus(0);
|
|
|
+ //类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约 5为重庆市碳排放量做贡献
|
|
|
+ customerCarbonVal.setType(5);
|
|
|
+ //来源表
|
|
|
+ customerCarbonVal.setTbGuid(guid);
|
|
|
+ //
|
|
|
+ customerCarbonVal.setYearTime(newYear);
|
|
|
+ customerCarbonVal.setTbName("t_customer_carbon_val");
|
|
|
+ //为重庆排放做贡献
|
|
|
+ customerCarbonVal.setRemarks("为重庆市碳排放量做贡献");
|
|
|
+ customerCarbonVal.setCreateUser(customerCarbonVal.gettCustomerId());
|
|
|
+ customerCarbonVal.setCreateTime(new Date());
|
|
|
+ customerCarbonValList.add(customerCarbonVal);
|
|
|
+ }
|
|
|
}
|
|
|
- //得到剩余碳汇量
|
|
|
- BigDecimal subtract = totalcarbonAmount.subtract(subCarbonAmount);
|
|
|
-
|
|
|
- CustomerCarbonVal customerCarbonVal=new CustomerCarbonVal();
|
|
|
- BeanUtils.copyProperties(contributionRe,customerCarbonVal);
|
|
|
- String guid = UUIDUtils.randomUUID();
|
|
|
- customerCarbonVal.setGuid(guid);
|
|
|
- customerCarbonVal.setCarbonVal(subtract);
|
|
|
- //使用碳汇量
|
|
|
- customerCarbonVal.setStatus(0);
|
|
|
- //类型 1购买碳汇 2企业碳中和 3大型活动碳中和 4碳履约 5为重庆市碳排放量做贡献
|
|
|
- customerCarbonVal.setType(5);
|
|
|
- //来源表
|
|
|
- customerCarbonVal.setTbGuid(guid);
|
|
|
- //
|
|
|
- customerCarbonVal.setYearTime(newYear);
|
|
|
- customerCarbonVal.setTbName("t_customer_carbon_val");
|
|
|
- //为重庆排放做贡献
|
|
|
- customerCarbonVal.setRemarks("为重庆市碳排放量做贡献");
|
|
|
- customerCarbonVal.setCreateUser(customerCarbonVal.gettCustomerId());
|
|
|
- customerCarbonVal.setCreateTime(new Date());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- if(customerCarbonValList.size()!=0){
|
|
|
+ if (customerCarbonValList.size() != 0) {
|
|
|
customerCarbonValMapper.insertSelectiveList(customerCarbonValList);
|
|
|
}
|
|
|
}
|
|
@@ -105,18 +117,19 @@ public class CustomerCarbonValServiceImpl implements CustomerCarbonValService {
|
|
|
calendar.setTime(new Date());
|
|
|
return calendar.get(Calendar.YEAR);
|
|
|
}
|
|
|
+
|
|
|
@Autowired
|
|
|
private CustomerService customerService;
|
|
|
|
|
|
@Override
|
|
|
- public MyCarbonValInfoBO myCarbonVal(Integer year){
|
|
|
- MyCarbonValInfoBO myCarbonValInfoBO=new MyCarbonValInfoBO();
|
|
|
+ public MyCarbonValInfoBO myCarbonVal(Integer year) {
|
|
|
+ MyCarbonValInfoBO myCarbonValInfoBO = new MyCarbonValInfoBO();
|
|
|
//获取登陆人信息
|
|
|
CustomerInfoForm customerInfo = customerService.getCurrentMember();
|
|
|
String guid = customerInfo.getGuid();
|
|
|
|
|
|
List<MyCarbonValBO> myCarbonValBOS = customerCarbonValMapper.myCarbonVal(year, guid);
|
|
|
- BigDecimal totalCarbonVal=new BigDecimal(0);
|
|
|
+ BigDecimal totalCarbonVal = new BigDecimal(0);
|
|
|
for (MyCarbonValBO myCarbonValBO : myCarbonValBOS) {
|
|
|
totalCarbonVal = totalCarbonVal.add(myCarbonValBO.getTotalCarbonVal());
|
|
|
}
|