|
|
@@ -10,10 +10,6 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.TradeLog;
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.common.base.service.SendMessageService;
|
|
|
-import com.uas.platform.b2c.common.message.model.MessageModel;
|
|
|
-import com.uas.platform.b2c.common.message.type.ConsumerApp;
|
|
|
-import com.uas.platform.b2c.common.message.type.ConsumerType;
|
|
|
-import com.uas.platform.b2c.common.message.type.SMSType;
|
|
|
import com.uas.platform.b2c.common.search.rpc.service.OrderSearchService;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.constant.ShortConstant;
|
|
|
@@ -34,13 +30,17 @@ import com.uas.platform.b2c.fa.settlement.dao.BillDao;
|
|
|
import com.uas.platform.b2c.fa.settlement.dao.BillInfoDao;
|
|
|
import com.uas.platform.b2c.fa.settlement.model.Bill;
|
|
|
import com.uas.platform.b2c.fa.settlement.model.BillInfo;
|
|
|
+import com.uas.platform.b2c.fa.settlement.model.ExchangeRate;
|
|
|
import com.uas.platform.b2c.fa.settlement.service.BillSubmitService;
|
|
|
+import com.uas.platform.b2c.fa.settlement.service.ExchangeRateService;
|
|
|
import com.uas.platform.b2c.logistics.dao.AddressDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.InvoiceFOrderDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.InvoiceFPurchaseDao;
|
|
|
import com.uas.platform.b2c.logistics.dao.PickUpAddressDao;
|
|
|
import com.uas.platform.b2c.logistics.model.*;
|
|
|
import com.uas.platform.b2c.logistics.service.InvoiceFPurchaseService;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsHistoryDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
@@ -61,7 +61,6 @@ import com.uas.platform.b2c.trade.deprecated.model.UserInfoForOrder;
|
|
|
import com.uas.platform.b2c.trade.inquiry.dao.TradeChargeDao;
|
|
|
import com.uas.platform.b2c.trade.inquiry.model.TradeCharge;
|
|
|
import com.uas.platform.b2c.trade.order.StringConstant.Currency;
|
|
|
-import com.uas.platform.b2c.trade.order.StringConstant.StringFormat;
|
|
|
import com.uas.platform.b2c.trade.order.dao.OrderDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.OrderDetailDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.OrderIndexDetailDao;
|
|
|
@@ -214,11 +213,14 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private MessageNotifyPersonalManagementService messageNotifyPersonalManagementService;
|
|
|
|
|
|
+ private final ExchangeRateService exchangeRateService;
|
|
|
+
|
|
|
private final BoundedExecutor executor;
|
|
|
|
|
|
@Autowired
|
|
|
- public OrderServiceImpl(OrderDao orderDao) {
|
|
|
+ public OrderServiceImpl(OrderDao orderDao, ExchangeRateService exchangeRateService) {
|
|
|
this.orderDao = orderDao;
|
|
|
+ this.exchangeRateService = exchangeRateService;
|
|
|
ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
executor = new BoundedExecutor(executorService, 1600);
|
|
|
}
|
|
|
@@ -3471,4 +3473,102 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
return ResultMap.success(bool);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计个人交易额
|
|
|
+ *
|
|
|
+ * @param useruu 个人useruu
|
|
|
+ * @param enuu 企业的enuu
|
|
|
+ * @param starttime 开始时间
|
|
|
+ * @param endtime 结束时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap statisticsPersonTradingVolume(Long useruu, Long enuu, Long starttime, Long endtime) {
|
|
|
+ if (useruu == null) {
|
|
|
+ return ResultMap.success(0);
|
|
|
+ }
|
|
|
+ List<Order> orders = new ArrayList<>();
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(Status.COMPLETED.value());
|
|
|
+ status.add(Status.RECEIVED.value());
|
|
|
+ if (starttime == null || endtime == null) {
|
|
|
+ if (enuu == null) {
|
|
|
+ List<Order> orderList = orderDao.getOrderByUseruuAndDissociativeAndStatus(useruu, Type.PERSONAL.value(), status);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ } else {
|
|
|
+ List<Order> orderList = orderDao.getOrderByUseruuAndEnuuAndstatus(useruu, enuu, status);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Date start = new Date(starttime);
|
|
|
+ Date end = new Date(endtime);
|
|
|
+ if (enuu == null) {
|
|
|
+ List<Order> orderList = orderDao.getOrderByUseruuAndDissociativeAndstatusAndStartTimeAndEndTime(useruu, Type.PERSONAL.value(), status, start, end);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ } else {
|
|
|
+ List<Order> orderList = orderDao.getOrderByUseruuAndEnuuAndstatusAndStartTimeAndEndTime(useruu, enuu, status, start, end);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Double orderTotal = statisticsOrderTotal(orders);
|
|
|
+ return ResultMap.success(orderTotal);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计个人的订单总计
|
|
|
+ *
|
|
|
+ * @param enuu 企业enuu
|
|
|
+ * @param starttime 开始时间
|
|
|
+ * @param endtime 结束时间
|
|
|
+ * @return ResultMap 返回值
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap statisticsEnterpriseTradingVolume(Long enuu, Long starttime, Long endtime) {
|
|
|
+ if (enuu == null) {
|
|
|
+ return ResultMap.success(0);
|
|
|
+ }
|
|
|
+ List<Order> orders = new ArrayList<>();
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(Status.COMPLETED.value());
|
|
|
+ status.add(Status.RECEIVED.value());
|
|
|
+ if (starttime == null || endtime == null) {
|
|
|
+ //统计历史所有的买家金额
|
|
|
+ List<Order> orderList = orderDao.getOrderByEnuuAndstatus(enuu, status);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ } else {
|
|
|
+ Date start = new Date(starttime);
|
|
|
+ Date end = new Date(endtime);
|
|
|
+ List<Order> orderList = orderDao.getOrderByEnuuAndstatusAndStartTimeAndEndTime(enuu, status, start, end);
|
|
|
+ orders.addAll(orderList);
|
|
|
+ }
|
|
|
+ Double orderTotal = statisticsOrderTotal(orders);
|
|
|
+ return ResultMap.success(orderTotal);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计订单的总金额
|
|
|
+ * @param orders 订单
|
|
|
+ * @return 返回总金额,USD 用汇率转
|
|
|
+ */
|
|
|
+ private Double statisticsOrderTotal(List<Order> orders) {
|
|
|
+ Double usdTotal = 0.0d;
|
|
|
+ Double rmbTotal = 0.0d;
|
|
|
+ for (Order order : orders) {
|
|
|
+ if (StringConstant.RMB.equals(order.getCurrency())) {
|
|
|
+ rmbTotal = NumberUtil.add(order.getEnsurePrice(), rmbTotal);
|
|
|
+ } else {
|
|
|
+ usdTotal = NumberUtil.add(order.getEnsurePrice(), usdTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (NumberUtil.compare(usdTotal, DoubleConstant.zero) > 0) {
|
|
|
+ List<ExchangeRate> exchangeRates = exchangeRateService.findByFromCurrencyAndToCurrency(StringConstant.USD, StringConstant.RMB);
|
|
|
+ if (org.apache.commons.collections.CollectionUtils.isEmpty(exchangeRates)) {
|
|
|
+ throw new IllegalOperatorException("美金兑人民币的汇率还未设置");
|
|
|
+ }
|
|
|
+ rmbTotal = NumberUtil.add(rmbTotal, NumberUtil.mul(usdTotal, exchangeRates.get(0).getRate()));
|
|
|
+ }
|
|
|
+ return rmbTotal;
|
|
|
+ }
|
|
|
}
|