|
@@ -1746,15 +1746,31 @@ public class ExportServiceImpl implements ExportService {
|
|
|
|
|
|
private void parseGoodsJson(StudentPaymentOrderMallExportDto row,List<String> categoryNames,Map<Long,String> productCategoryMap){
|
|
|
if(StringUtils.isNotEmpty(row.getGoodsJson())){
|
|
|
+ if(row.getActualAmount().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
List<JSONObject> orderItemList = JSONObject.parseArray(JSONObject.parseObject(row.getGoodsJson()).getString("orderItemList"), JSONObject.class);
|
|
|
- for (JSONObject json : orderItemList) {
|
|
|
+ BigDecimal balanceAmount = row.getBalancePaymentAmount();
|
|
|
+ BigDecimal subBalanceAmount = balanceAmount;
|
|
|
+ for (int i = 0; i < orderItemList.size(); i++) {
|
|
|
+ JSONObject json = orderItemList.get(i);
|
|
|
try {
|
|
|
String category = productCategoryMap.get(Long.parseLong(json.get("productId").toString()));
|
|
|
- BigDecimal realAmount = new BigDecimal(json.get("realAmount").toString());
|
|
|
int index = categoryNames.indexOf(category) + 1;
|
|
|
if(index == 0){
|
|
|
continue;
|
|
|
}
|
|
|
+ BigDecimal realAmount = new BigDecimal(json.get("realAmount").toString());
|
|
|
+ //处理余额部分
|
|
|
+ if(balanceAmount.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ BigDecimal divide = realAmount.divide(balanceAmount, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal decimal = realAmount.multiply(divide).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ subBalanceAmount = subBalanceAmount.subtract(decimal);
|
|
|
+ realAmount = realAmount.subtract(decimal);
|
|
|
+ if(i == orderItemList.size() -1){
|
|
|
+ realAmount = realAmount.add(subBalanceAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
Method method = row.getClass().getMethod("getCategory" + index, null);
|
|
|
BigDecimal invoke = (BigDecimal)method.invoke(row);
|
|
|
invoke = invoke.add(realAmount);
|