导出同事特权,增加和修正表字段
This commit is contained in:
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -139,6 +140,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
||||
Integer current,
|
||||
Integer size,
|
||||
String isResell,
|
||||
String dataType,
|
||||
String orderSn,
|
||||
Long buyerId,
|
||||
Long sellerId,
|
||||
@@ -157,6 +159,9 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
||||
if (isResell != null && !isResell.trim().isEmpty()) {
|
||||
w.eq(LbOrderRow::getIsResell, isResell.trim());
|
||||
}
|
||||
if (dataType != null && !dataType.trim().isEmpty()) {
|
||||
w.eq(LbOrderRow::getDataType, dataType.trim());
|
||||
}
|
||||
if (orderSn != null && !orderSn.trim().isEmpty()) {
|
||||
w.like(LbOrderRow::getOrderSn, orderSn.trim());
|
||||
}
|
||||
@@ -193,7 +198,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> syncFromHxrAdmin(
|
||||
String buyTimeStart, String buyTimeEnd, String tenantId, Integer isResell) {
|
||||
String buyTimeStart, String buyTimeEnd, String tenantId, Integer isResell, String dataType) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
if (tenantId == null || tenantId.trim().isEmpty()) {
|
||||
@@ -223,12 +228,18 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
||||
}
|
||||
|
||||
String tid = tenantId.trim();
|
||||
String rowDataType = resolveSyncDataType(dataType, isResell);
|
||||
BigDecimal todayTotalMoneySum = parseMoney(body.allMoney());
|
||||
int todayOrderCount = body.count();
|
||||
int todayUnresellCount = countUnresell(rows);
|
||||
List<LbOrderRow> entities = new ArrayList<>(rows.size());
|
||||
for (HxrOrderRow row : rows) {
|
||||
entities.add(toLbOrderRow(row, tid));
|
||||
entities.add(toLbOrderRow(
|
||||
row, tid, rowDataType, todayTotalMoneySum, todayOrderCount, todayUnresellCount));
|
||||
}
|
||||
|
||||
boolean ok = this.saveOrUpdateBatch(entities);
|
||||
// boolean ok = this.saveBatch(entities);
|
||||
result.put("success", ok);
|
||||
result.put("message", ok ? "同步完成" : "批量保存失败");
|
||||
result.put("synced", ok ? entities.size() : 0);
|
||||
@@ -243,15 +254,54 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
||||
}
|
||||
}
|
||||
|
||||
private static LbOrderRow toLbOrderRow(HxrOrderRow row, String tenantId) {
|
||||
private static String resolveSyncDataType(String dataType, Integer isResell) {
|
||||
if (dataType != null && !dataType.trim().isEmpty()) {
|
||||
return dataType.trim();
|
||||
}
|
||||
return isResell == null ? null : String.valueOf(isResell);
|
||||
}
|
||||
|
||||
private static int countUnresell(List<HxrOrderRow> rows) {
|
||||
int n = 0;
|
||||
for (HxrOrderRow row : rows) {
|
||||
if (row.isResell() == 0) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private static BigDecimal parseMoney(String money) {
|
||||
if (money == null || money.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(money.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static LbOrderRow toLbOrderRow(
|
||||
HxrOrderRow row,
|
||||
String tenantId,
|
||||
String dataType,
|
||||
BigDecimal todayTotalMoneySum,
|
||||
Integer todayOrderCount,
|
||||
Integer todayUnresellCount) {
|
||||
LbOrderRow e = new LbOrderRow();
|
||||
e.setId(row.id());
|
||||
e.setDataType("detail_data");
|
||||
e.setOldId(row.oldId());
|
||||
e.setTenantId(tenantId);
|
||||
e.setDataType(dataType);
|
||||
e.setTodayTotalMoneySum(todayTotalMoneySum);
|
||||
e.setTodayOrderCount(todayOrderCount);
|
||||
e.setTodayUnresellCount(todayUnresellCount);
|
||||
e.setSellerId(row.sellerId());
|
||||
e.setBuyerId(row.buyerId());
|
||||
e.setOrderSn(row.orderSn());
|
||||
e.setTotalMoney(row.totalMoney());
|
||||
e.setTotalMoney(parseMoney(row.totalMoney()));
|
||||
e.setPayTime(row.payTime());
|
||||
e.setPayImg(row.payImg());
|
||||
e.setStatus(row.status());
|
||||
|
||||
Reference in New Issue
Block a user