Authored by LUOXC

update

@@ -26,23 +26,12 @@ import lombok.extern.slf4j.Slf4j; @@ -26,23 +26,12 @@ import lombok.extern.slf4j.Slf4j;
26 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.stereotype.Service; 27 import org.springframework.stereotype.Service;
28 28
29 -import javax.activation.DataHandler;  
30 -import javax.activation.DataSource;  
31 -import javax.mail.Message;  
32 import javax.mail.MessagingException; 29 import javax.mail.MessagingException;
33 -import javax.mail.Session;  
34 -import javax.mail.Transport;  
35 -import javax.mail.internet.*;  
36 -import javax.mail.util.ByteArrayDataSource;  
37 -import java.io.IOException;  
38 -import java.io.UnsupportedEncodingException;  
39 import java.math.BigDecimal; 30 import java.math.BigDecimal;
40 import java.util.*; 31 import java.util.*;
41 import java.util.concurrent.TimeUnit; 32 import java.util.concurrent.TimeUnit;
42 import java.util.function.Function; 33 import java.util.function.Function;
43 -import java.util.function.Supplier;  
44 import java.util.stream.Collectors; 34 import java.util.stream.Collectors;
45 -import java.util.stream.Stream;  
46 35
47 import static com.yohoufo.order.common.BillTradeStatus.HK_AMOUNT_PAYING; 36 import static com.yohoufo.order.common.BillTradeStatus.HK_AMOUNT_PAYING;
48 import static com.yohoufo.order.common.BillTradeStatus.HK_AMOUNT_WAIT_PAYMENT; 37 import static com.yohoufo.order.common.BillTradeStatus.HK_AMOUNT_WAIT_PAYMENT;
@@ -139,16 +128,21 @@ public class HkAccountSettlement { @@ -139,16 +128,21 @@ public class HkAccountSettlement {
139 .ifPresent(buyerOrderGoods -> { 128 .ifPresent(buyerOrderGoods -> {
140 getStoragePrice(buyerOrderGoods, storagePrices).ifPresent(storagePrice -> { 129 getStoragePrice(buyerOrderGoods, storagePrices).ifPresent(storagePrice -> {
141 getProduct(storagePrice, products).ifPresent(product -> { 130 getProduct(storagePrice, products).ifPresent(product -> {
  131 + Optional<JSONObject> feesOpt = getFees(buyerOrderGoods, fees);
142 TradeBillResult billResult = TradeBillResult.builder() 132 TradeBillResult billResult = TradeBillResult.builder()
143 .uid(uid) 133 .uid(uid)
144 .orderCode(buyerOrderGoods.getOrderCode()) 134 .orderCode(buyerOrderGoods.getOrderCode())
145 .productNo(product.getProductCode()) 135 .productNo(product.getProductCode())
146 .productName(product.getProductName()) 136 .productName(product.getProductName())
147 .goodsAmount(buyerOrderGoods.getGoodsAmount()) 137 .goodsAmount(buyerOrderGoods.getGoodsAmount())
148 - .tariffAmount(buyerOrderGoods.getTariffAmount())  
149 - .platformServiceAmount(tradeBill.getSystemAmount()) 138 + .bankTransferAmount(feesOpt
  139 + .map(e -> e.getBigDecimal("bankTransferfee"))
  140 + .orElse(BigDecimal.ZERO))
150 .payAmount(tradeBill.getAmount()) 141 .payAmount(tradeBill.getAmount())
151 - .platformServiceAmount(getPlatformFee(buyerOrderGoods, fees).orElse(BigDecimal.ZERO)) 142 + .platformServiceAmount(feesOpt
  143 + .map(e -> e.getJSONObject("platformFee"))
  144 + .map(e -> e.getBigDecimal("total"))
  145 + .orElse(BigDecimal.ZERO))
152 .payType(tradeBill.getTradeType() == 1 ? "保证金" 146 .payType(tradeBill.getTradeType() == 1 ? "保证金"
153 : tradeBill.getTradeType() == 2 ? "货款" 147 : tradeBill.getTradeType() == 2 ? "货款"
154 : tradeBill.getTradeType() == 3 ? "补偿款" : "") 148 : tradeBill.getTradeType() == 3 ? "补偿款" : "")
@@ -173,8 +167,8 @@ public class HkAccountSettlement { @@ -173,8 +167,8 @@ public class HkAccountSettlement {
173 // 商品名称 167 // 商品名称
174 private String productName; 168 private String productName;
175 private BigDecimal goodsAmount; 169 private BigDecimal goodsAmount;
176 - // 税费  
177 - private BigDecimal tariffAmount; 170 + // 银行转账费
  171 + private BigDecimal bankTransferAmount;
178 //平台服务费 172 //平台服务费
179 private BigDecimal platformServiceAmount; 173 private BigDecimal platformServiceAmount;
180 // 打款金额 174 // 打款金额
@@ -189,13 +183,11 @@ public class HkAccountSettlement { @@ -189,13 +183,11 @@ public class HkAccountSettlement {
189 .findAny(); 183 .findAny();
190 } 184 }
191 185
192 - private Optional<BigDecimal> getPlatformFee(BuyerOrderGoods buyerOrderGoods, List<SellerOrderMeta> fees) { 186 + private Optional<JSONObject> getFees(BuyerOrderGoods buyerOrderGoods, List<SellerOrderMeta> fees) {
193 return fees.stream() 187 return fees.stream()
194 .filter(e -> e.getSkup().equals(buyerOrderGoods.getSkup())) 188 .filter(e -> e.getSkup().equals(buyerOrderGoods.getSkup()))
195 .map(SellerOrderMeta::getMetaValue) 189 .map(SellerOrderMeta::getMetaValue)
196 .map(JSONObject::parseObject) 190 .map(JSONObject::parseObject)
197 - .map(e -> e.getJSONObject("platformFee"))  
198 - .map(e -> e.getBigDecimal("total"))  
199 .findAny(); 191 .findAny();
200 } 192 }
201 193
@@ -251,7 +243,7 @@ public class HkAccountSettlement { @@ -251,7 +243,7 @@ public class HkAccountSettlement {
251 243
252 private String buildDate(List<TradeBillResult> tradeBillResults) { 244 private String buildDate(List<TradeBillResult> tradeBillResults) {
253 StringBuffer text = new StringBuffer(); 245 StringBuffer text = new StringBuffer();
254 - text.append("用户UID,订单编号,商品货号,商品名称,商品金额,费,平台服务费,打款金额,金额类型"); 246 + text.append("用户UID,订单编号,商品货号,商品名称,商品金额,银行转账费,平台服务费,打款金额,金额类型");
255 Function<Function<TradeBillResult, BigDecimal>, BigDecimal> total = map -> tradeBillResults.stream().map(map).reduce(BigDecimal.ZERO, BigDecimal::add); 247 Function<Function<TradeBillResult, BigDecimal>, BigDecimal> total = map -> tradeBillResults.stream().map(map).reduce(BigDecimal.ZERO, BigDecimal::add);
256 tradeBillResults.forEach(tradeBillResult -> text.append("\n") 248 tradeBillResults.forEach(tradeBillResult -> text.append("\n")
257 .append(tradeBillResult.getUid()).append(",") 249 .append(tradeBillResult.getUid()).append(",")
@@ -259,7 +251,7 @@ public class HkAccountSettlement { @@ -259,7 +251,7 @@ public class HkAccountSettlement {
259 .append(tradeBillResult.getProductNo()).append(",") 251 .append(tradeBillResult.getProductNo()).append(",")
260 .append(tradeBillResult.getProductName()).append(",") 252 .append(tradeBillResult.getProductName()).append(",")
261 .append(tradeBillResult.getGoodsAmount()).append(",") 253 .append(tradeBillResult.getGoodsAmount()).append(",")
262 - .append(tradeBillResult.getTariffAmount()).append(",") 254 + .append(tradeBillResult.getBankTransferAmount()).append(",")
263 .append(tradeBillResult.getPlatformServiceAmount()).append(",") 255 .append(tradeBillResult.getPlatformServiceAmount()).append(",")
264 .append(tradeBillResult.getPayAmount()).append(",") 256 .append(tradeBillResult.getPayAmount()).append(",")
265 .append(tradeBillResult.getPayType()) 257 .append(tradeBillResult.getPayType())
@@ -270,7 +262,7 @@ public class HkAccountSettlement { @@ -270,7 +262,7 @@ public class HkAccountSettlement {
270 .append(",")// 商品货号 262 .append(",")// 商品货号
271 .append(",")//商品名称 263 .append(",")//商品名称
272 .append(total.apply(TradeBillResult::getGoodsAmount)).append(",") 264 .append(total.apply(TradeBillResult::getGoodsAmount)).append(",")
273 - .append(total.apply(TradeBillResult::getTariffAmount)).append(",") 265 + .append(total.apply(TradeBillResult::getBankTransferAmount)).append(",")
274 .append(total.apply(TradeBillResult::getPlatformServiceAmount)).append(",") 266 .append(total.apply(TradeBillResult::getPlatformServiceAmount)).append(",")
275 .append(total.apply(TradeBillResult::getPayAmount)).append(",") 267 .append(total.apply(TradeBillResult::getPayAmount)).append(",")
276 // 金额类型 268 // 金额类型