|
|
|
@ -19,6 +19,7 @@ import javax.persistence.Query;
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -35,25 +36,21 @@ public class TradeJpa {
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
|
|
public List<TopTrade> getConfirmReceipt(@RequestBody AppSetting appSetting, String tradeStatus) {
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
|
StringBuilder sql;
|
|
|
|
|
if (appSetting.getType().equals(AppSettingTypeEnum.MESSAGE_RETURN_REMINDER.getType())) {
|
|
|
|
|
//退款
|
|
|
|
|
sql = getRefundSql();
|
|
|
|
|
} else {
|
|
|
|
|
sql = getSql();
|
|
|
|
|
}
|
|
|
|
|
//实际付款 限定的范围
|
|
|
|
|
//实付最小金额
|
|
|
|
|
Double minPayment = appSetting.getPaymentFloor();
|
|
|
|
|
//实付最大金额
|
|
|
|
|
Double maxPayment = appSetting.getPaymentCeiling();
|
|
|
|
|
if (minPayment != null && minPayment > 0) {
|
|
|
|
|
sql.append("and t.payment >= :minPayment ");
|
|
|
|
|
}
|
|
|
|
|
if (maxPayment != null) {
|
|
|
|
|
if (maxPayment != null && maxPayment > 0) {
|
|
|
|
|
sql.append("and t.payment <= :maxPayment ");
|
|
|
|
|
}
|
|
|
|
|
//订单状态
|
|
|
|
|
if (StrUtil.isNotEmpty(tradeStatus)) {
|
|
|
|
|
if (appSetting.getType().equals(AppSettingTypeEnum.MESSAGE_RETURN_REMINDER.getType())) {
|
|
|
|
|
sql.append("and o.status = :tradeStatus ");
|
|
|
|
@ -61,8 +58,6 @@ public class TradeJpa {
|
|
|
|
|
sql.append("and t.status = :tradeStatus ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是催评,需要订单未进行过评价
|
|
|
|
|
if (AppSettingTypeEnum.MESSAGE_REMINDER.getType() == appSetting.getType()) {
|
|
|
|
|
sql.append("and t.buyer_rate = :buyerRate ");
|
|
|
|
@ -91,24 +86,21 @@ public class TradeJpa {
|
|
|
|
|
day = DateUtil.offset(DateUtil.date(), DateField.MINUTE, -limitMinute);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != day) {
|
|
|
|
|
sql.append("and t.created < :offDay ");
|
|
|
|
|
}
|
|
|
|
|
//卖家昵称
|
|
|
|
|
String sellerNick = appSetting.getSellerNick();
|
|
|
|
|
if (StrUtil.isNotEmpty(sellerNick)) {
|
|
|
|
|
sql.append("and t.seller_nick = :sellerNick ");
|
|
|
|
|
}
|
|
|
|
|
Query query = entityManager.createNativeQuery(sql.toString());
|
|
|
|
|
//设置参数
|
|
|
|
|
if (null != minPayment) {
|
|
|
|
|
if (null != minPayment && minPayment > 0) {
|
|
|
|
|
query.setParameter("minPayment", minPayment);
|
|
|
|
|
}
|
|
|
|
|
if (null != maxPayment) {
|
|
|
|
|
if (null != maxPayment && maxPayment > 0) {
|
|
|
|
|
query.setParameter("maxPayment", maxPayment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != tradeStatus) {
|
|
|
|
|
query.setParameter("tradeStatus", tradeStatus);
|
|
|
|
|
}
|
|
|
|
@ -123,7 +115,6 @@ public class TradeJpa {
|
|
|
|
|
if (null != sellerNick) {
|
|
|
|
|
query.setParameter("sellerNick", sellerNick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
|
|
|
|
List list = query.getResultList();
|
|
|
|
|
return getTradeInfo(list);
|
|
|
|
@ -131,14 +122,13 @@ public class TradeJpa {
|
|
|
|
|
|
|
|
|
|
private List<TopTrade> getTradeInfo(List list) {
|
|
|
|
|
List<TopTrade> tradeList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Object obj : list) {
|
|
|
|
|
Map row = (Map) obj;
|
|
|
|
|
TopTrade trade = new TopTrade();
|
|
|
|
|
trade.setBuyerNick((String) row.get("buyerNick"));
|
|
|
|
|
BigInteger tid = (BigInteger) row.get("tid");
|
|
|
|
|
trade.setTid(tid.longValue());
|
|
|
|
|
trade.setPayment((String) row.get("payTime"));
|
|
|
|
|
trade.setPayTime((Date) row.get("payTime"));
|
|
|
|
|
trade.setTitle((String) row.get("title"));
|
|
|
|
|
trade.setPayment((String) row.get("payment"));
|
|
|
|
|
trade.setReceiverName((String) row.get("receiverName"));
|
|
|
|
|