Commit c9b75fef authored by jianhua.zhang's avatar jianhua.zhang

账户余额接口:提供所有账户余额总额

parent 4824a339
......@@ -11,6 +11,7 @@ import com.wuban.tron.explore.entity.example.TransactionExample;
import com.wuban.tron.explore.param.response.*;
import com.wuban.tron.explore.service.*;
import com.wuban.tron.explore.util.ApiResponse;
import com.wuban.tron.explore.util.BigDecimalUtil;
import com.wuban.tron.explore.util.DateUtil;
import com.wuban.tron.explore.util.ResponseKit;
import lombok.RequiredArgsConstructor;
......@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
......@@ -383,12 +385,29 @@ public class TransactionControllerV1 {
modelList.add(infoModel);
});
}
BigDecimal bg = this.totalBalance();
resDataModel.setSum(bg.toPlainString());
resDataModel.setData(modelList);
return ResponseKit.success(resDataModel);
}
private BigDecimal totalBalance() {
AddressExample example = new AddressExample();
example.createCriteria().andBalanceGreaterThan(0L);
List<Address> list = this.addressService.selectByExample(example);
BigDecimal totalBalance = new BigDecimal(0);
if (!CollectionUtils.isEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getBalance() != null) {
totalBalance = BigDecimalUtil.getAdd(totalBalance, new BigDecimal(list.get(i).getBalance()));
}
}
}
return totalBalance;
}
/**
* 首页图表
*
......
......@@ -47,4 +47,6 @@ public interface AddressRepository {
*/
List<Address> selectByPager(@Param("example") AddressExample example);
List<Address> selectByExample(@Param("example") AddressExample example);
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import lombok.Data;
public class ResDataModel<T> {
private int total;
private int sum;
private String sum;
private int t;
private long total_balance;
private Object data;
......
......@@ -47,4 +47,6 @@ public interface AddressService {
*/
PageInfo<Address> selectByPager(Integer startIndex, Integer pageSize, AddressExample example);
List<Address> selectByExample(@Param("example") AddressExample example);
}
......@@ -59,4 +59,9 @@ public class AddressServiceImpl implements AddressService {
return pageInfo;
}
@Override
public List<Address> selectByExample(AddressExample example) {
return this.addressRepository.selectByExample(example);
}
}
......@@ -153,7 +153,7 @@
<if test="example != null and example.distinct">
distinct
</if>
<include refid="Base_Column_List"/>
address,balance
from <include refid="Table_Name"/>
<if test="example != null">
<include refid="Example_Where_Clause"/>
......
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