# Conflicts: # src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.javamaster
commit
43c020d4e3
@ -0,0 +1,94 @@
|
||||
package au.com.royalpay.payment.manage.process.alipay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-08-14 21:41
|
||||
*/
|
||||
@SpringBootTest
|
||||
@ActiveProfiles({"proxy"})
|
||||
@RunWith(SpringRunner.class)
|
||||
public class FixAlipayData {
|
||||
@Resource
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
private String fileLocation = "C:\\Users\\yixian\\Documents\\royalpay\\2018\\alipayfix\\2088721525235246_20180815110000000032102003900557154_result - 副本.xls";
|
||||
private String fileTarget = "C:\\Users\\yixian\\Documents\\royalpay\\2018\\alipayfix\\fixed_2088721525235246_20180815110000000032102003900557154_result.xls";
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Test
|
||||
public void fix() throws IOException, InvalidFormatException {
|
||||
Workbook wb = WorkbookFactory.create(new File(fileLocation));
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
final int startRow = 6;
|
||||
int rowNum = startRow;
|
||||
String compName;
|
||||
while ((compName = mchCompName(sheet, rowNum)) != null) {
|
||||
logger.info("row:" + rowNum + ",company name=" + compName);
|
||||
final String corpName = compName;
|
||||
Row row = sheet.getRow(rowNum++);
|
||||
String shortName = row.getCell(2).getStringCellValue();
|
||||
List<Map<String, Object>> clients = jdbcTemplate.queryForList("select c.company_name,c.short_name,c.ali_sub_merchant_id,c.alipayindustry,c.country,c.address,c.state,l.latitude,l.longitude from sys_clients c" +
|
||||
" left join sys_clients_locations l on l.client_id=c.client_id where c.short_name=?", shortName);
|
||||
if (clients.isEmpty()) {
|
||||
clients = jdbcTemplate.queryForList("select c.company_name,c.short_name,c.ali_sub_merchant_id,c.alipayindustry,c.country,c.address,c.state,l.latitude,l.longitude from sys_clients c" +
|
||||
" left join sys_clients_locations l on l.client_id=c.client_id where c.company_name=?", corpName);
|
||||
if (clients.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Optional<Map<String, Object>> cliOpts = clients.stream()
|
||||
.filter(cli -> new JSONObject(cli).getString("company_name").equals(corpName))
|
||||
.findFirst();
|
||||
JSONObject client = new JSONObject(cliOpts.isPresent() ? cliOpts.get() : clients.get(0));
|
||||
|
||||
String moniker = client.getString("ali_sub_merchant_id");
|
||||
logger.info("updating to xlsx:" + moniker);
|
||||
row.getCell(4).setCellValue(moniker);
|
||||
row.getCell(5).setCellValue(moniker);
|
||||
String mcc = client.getString("alipayindustry");
|
||||
row.getCell(7).setCellValue(StringUtils.isEmpty(mcc) ? "5311" : mcc);
|
||||
row.getCell(8).setCellValue("Australia");
|
||||
if (StringUtils.isNoneEmpty(client.getString("address"), client.getString("state"))) {
|
||||
row.getCell(9).setCellValue(client.getString("address") + "," + client.getString("state"));
|
||||
}
|
||||
if (client.getString("latitude") != null) {
|
||||
row.getCell(29).setCellValue(client.getBigDecimal("latitude").setScale(8, BigDecimal.ROUND_DOWN).toPlainString());
|
||||
row.getCell(30).setCellValue(client.getBigDecimal("longitude").setScale(8, BigDecimal.ROUND_DOWN).toPlainString());
|
||||
}
|
||||
logger.info("finished update row:" + (rowNum - 1));
|
||||
}
|
||||
wb.write(new FileOutputStream(fileTarget));
|
||||
}
|
||||
|
||||
private String mchCompName(Sheet sheet, int rowNum) {
|
||||
Row row = sheet.getRow(rowNum);
|
||||
if (row == null) {
|
||||
return null;
|
||||
}
|
||||
Cell cell = row.getCell(1);
|
||||
if (cell == null) {
|
||||
return null;
|
||||
}
|
||||
return cell.getStringCellValue();
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package au.com.royalpay.payment.manage.process.custom;
|
||||
|
||||
import au.com.royalpay.payment.channels.alipay.runtime.impls.AlipayCustomDeclaringTaskProcessor;
|
||||
import au.com.royalpay.payment.core.mappers.PmtCustomReportsDetailMapper;
|
||||
import au.com.royalpay.payment.core.mappers.PmtCustomReportsMapper;
|
||||
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.custom.CustomReportDetailsMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.custom.CustomReportsMapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-08-14 20:28
|
||||
*/
|
||||
@SpringBootTest
|
||||
@ActiveProfiles({"proxy", "alipay"})
|
||||
@TestPropertySource(properties = {"spring.datasource.username=root", "spring.datasource.password=ZOIBhellor0yalpay"})
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ManualReportCustom {
|
||||
|
||||
@Autowired
|
||||
private AlipayCustomDeclaringTaskProcessor processor;
|
||||
@Resource
|
||||
private PmtCustomReportsMapper pmtCustomReportsMapper;
|
||||
@Resource
|
||||
private PmtOrderMapper pmtOrderMapper;
|
||||
@Resource
|
||||
private PmtCustomReportsDetailMapper pmtCustomReportsDetailMapper;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String reportId = "05482201808142036430702208";
|
||||
List<JSONObject> customs = pmtCustomReportsMapper.findReport(reportId);
|
||||
List<JSONObject> sub = pmtCustomReportsDetailMapper.listSubReports(reportId);
|
||||
JSONObject order = pmtOrderMapper.find(reportId);
|
||||
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("channel", order.getString("channel"));
|
||||
task.put("merchant_id", order.getString("merchant_id"));
|
||||
task.put("sub_orders", sub);
|
||||
task.put("report", customs.stream().filter(rep -> rep.getIntValue("report_status") == 2)
|
||||
.findFirst().orElseThrow(() -> new RuntimeException("No Failure Reports")));
|
||||
processor.process(task);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue