Commit 95eeb137 by yinyong

提现明细

parent 99fa01c5
...@@ -26,6 +26,7 @@ public class Application { ...@@ -26,6 +26,7 @@ public class Application {
private static final String EVENT_RDB_STORAGE_PASSWORD = propertiesUtil.getPropertyAsString("EVENT_RDB_STORAGE_PASSWORD"); private static final String EVENT_RDB_STORAGE_PASSWORD = propertiesUtil.getPropertyAsString("EVENT_RDB_STORAGE_PASSWORD");
public static void main(String[] args) { public static void main(String[] args) {
new JobScheduler(createRegistryCenter(), createJobConfiguration(),createJobEventConfiguration(), new CashierJobListener()).init(); new JobScheduler(createRegistryCenter(), createJobConfiguration(),createJobEventConfiguration(), new CashierJobListener()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration1(),createJobEventConfiguration()).init();
} }
private static CoordinatorRegistryCenter createRegistryCenter() { private static CoordinatorRegistryCenter createRegistryCenter() {
...@@ -41,6 +42,13 @@ public class Application { ...@@ -41,6 +42,13 @@ public class Application {
return simpleJobRootConfig; return simpleJobRootConfig;
} }
private static LiteJobConfiguration createJobConfiguration1() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(propertiesUtil.getPropertyAsString("WITHDRAW_JOB_NAME"), propertiesUtil.getPropertyAsString("WITHDRAW_JOB_CRON"), propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, CashierJob.class.getCanonicalName());
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static JobEventConfiguration createJobEventConfiguration() { private static JobEventConfiguration createJobEventConfiguration() {
JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource()); JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
return jobEventRdbConfig; return jobEventRdbConfig;
......
package com.bailuntec.domain;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class FinanceCashierdetail {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.cw_id
*
* @mbg.generated
*/
@JSONField(name = "Id")
private Integer cwId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.data_type
*
* @mbg.generated
*/
private Integer dataType;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.from_account
*
* @mbg.generated
*/
private String fromAccount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.from_currency
*
* @mbg.generated
*/
private Integer fromCurrency;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.exchange_currency
*
* @mbg.generated
*/
private String exchangeCurrency;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.exchange_money
*
* @mbg.generated
*/
private BigDecimal exchangeMoney;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.to_account
*
* @mbg.generated
*/
private String toAccount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.to_currency
*
* @mbg.generated
*/
private Integer toCurrency;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.money
*
* @mbg.generated
*/
private BigDecimal money;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.service_charge
*
* @mbg.generated
*/
private BigDecimal serviceCharge;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.daozhang_time
*
* @mbg.generated
*/
private Date daozhangTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.daozhang_money
*
* @mbg.generated
*/
private BigDecimal daozhangMoney;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.confirm_name
*
* @mbg.generated
*/
private String confirmName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.status
*
* @mbg.generated
*/
private Integer status;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.create_name
*
* @mbg.generated
*/
private String createName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.createTime
*
* @mbg.generated
*/
private Date createtime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.update_name
*
* @mbg.generated
*/
private String updateName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.update_time
*
* @mbg.generated
*/
private Date updateTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.remark
*
* @mbg.generated
*/
private String remark;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.from_currency_name
*
* @mbg.generated
*/
private String fromCurrencyName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.to_currency_name
*
* @mbg.generated
*/
private String toCurrencyName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.collection_platform
*
* @mbg.generated
*/
private Integer collectionPlatform;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.bank
*
* @mbg.generated
*/
private String bank;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.salesl_platform
*
* @mbg.generated
*/
private Integer saleslPlatform;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.sales_account
*
* @mbg.generated
*/
private String salesAccount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.other_to_cny_exchange_rate
*
* @mbg.generated
*/
private BigDecimal otherToCnyExchangeRate;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.gmt_create_time
*
* @mbg.generated
*/
private Date gmtCreateTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_cashierdetail.gmt_modify_time
*
* @mbg.generated
*/
private Date gmtModifyTime;
}
\ No newline at end of file
package com.bailuntec.domain;
import lombok.Data;
import java.util.List;
@Data
public class WithdrawInfo {
private Integer total;
private List<FinanceCashierdetail> list;
}
package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.bailuntec.domain.DcBaseFinanceCashierInfo;
import com.bailuntec.domain.FinanceCashierdetail;
import com.bailuntec.domain.WithdrawInfo;
import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.entity.DcBaseFinanceCashier;
import com.bailuntec.domain.entity.DcBaseFinanceCashierdetail;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.mapper.DcBaseFinanceCashierMapper;
import com.bailuntec.mapper.DcBaseFinanceCashierdetailMapper;
import com.bailuntec.support.CallBailunSystem;
import com.bailuntec.support.PointJob;
import com.bailuntec.utils.OkHttpUtil;
import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.List;
@Slf4j
public class CashWithdrawDetail extends PointJob {
private OkHttpClient okHttpClient = OkHttpUtil.getInstance();
private PropertiesUtil propertiesUtil = PropertiesUtil.getInstance("const");
@Override
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
LinkedHashMap<String, String> map = new LinkedHashMap<>(4);
map.put("pagesize", jobPointLog.getPageSize().toString());
map.put("begintime", DateTimeFormatter.ofPattern(CommonConstant.TIME_FORMAT).format(jobPointLog.getStartTime()));
map.put("endtime", DateTimeFormatter.ofPattern(CommonConstant.TIME_FORMAT).format(jobPointLog.getEndTime()));
do {
map.put("pageindex", jobPointLog.getPageIndex().equals(0) ? "1" : jobPointLog.getPageIndex().toString());
Response response = null;
String palResultStr = null;
try {
Request request = new Request.Builder()
.get()
.url(OkHttpUtil.attachHttpGetParams(propertiesUtil.getPropertyAsString("WITHDRAW_DETAIL"), map))
.addHeader("Content-Type", "application/json")
.build();
response = okHttpClient.newCall(request).execute();
palResultStr = response.body().string();
} catch (IOException e) {
throw new RuntimeException(map + "请求流水接口同步百伦接口失败" + response, e);
} finally {
if (response != null) {
response.close();
}
}
if (StringUtils.isNoneBlank(palResultStr)) {
WithdrawInfo withdrawInfo = JSON.parseObject(palResultStr, WithdrawInfo.class);
if (withdrawInfo != null && withdrawInfo.getList() != null && withdrawInfo.getList().size() > 0) {
DcBaseFinanceCashierdetail dcBaseFinanceCashierdetail = new DcBaseFinanceCashierdetail();
for(FinanceCashierdetail financeCashierdetail : withdrawInfo.getList()) {
DcBaseFinanceCashierdetailMapper dcBaseFinanceCashierdetailMapper = SessionUtil.getSession().getMapper(DcBaseFinanceCashierdetailMapper.class);
try {
BeanUtils.copyProperties(dcBaseFinanceCashierdetail, financeCashierdetail);
BigDecimal exchangeRate = CallBailunSystem.getExchangeRate((dcBaseFinanceCashierdetail.getToCurrencyName() == null ? "CNY" : dcBaseFinanceCashierdetail.getToCurrencyName()), "CNY", LocalDateTime.now());
dcBaseFinanceCashierdetail.setOtherToCnyExchangeRate(exchangeRate);
dcBaseFinanceCashierdetail.setOtherToCnyMoney(exchangeRate.multiply(dcBaseFinanceCashierdetail.getDaozhangMoney()));
} catch (Exception e) {
throw new RuntimeException("BeanUtils.copyProperties失败");
}
dcBaseFinanceCashierdetailMapper.upsertSelective(dcBaseFinanceCashierdetail);
}
} else {
break;
}
} else {
throw new RuntimeException("调用流水接口同步百伦流水失败, 响应为null, 请求参数" + map.toString());
}
jobPointLog.setPageIndex(jobPointLog.getPageIndex() + 1);
} while (true);
jobPointLog.setPageIndex(0);
jobPointLog.setStartTime(jobPointLog.getEndTime());
jobPointLog.setEndTime(jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()).isAfter(LocalDateTime.now()) ? LocalDateTime.now() : jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()));
}
}
CASHIER_URL=http://cw.bailuntec.com/API/API/GetCashiers CASHIER_URL=http://cw.bailuntec.com/API/API/GetCashiers
WITHDRAW_DETAIL=http://cw.bailuntec.com/API/API/GetWithdrawDetailPages
...@@ -11,4 +11,6 @@ ZOOKEEPER_SERVER=172.31.255.120:2181 ...@@ -11,4 +11,6 @@ ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE=data-center NAME_SPACE=data-center
JOB_NAME=base-sync-cashier JOB_NAME=base-sync-cashier
JOB_CRON=0/1 * * * * ? * JOB_CRON=0/1 * * * * ? *
WITHDRAW_JOB_NAME=base_sync-withdraw
WITHDRAW_JOB_CRON=0/1 * * * * ? *
SHARDING_TOTAL_COUNT=1 SHARDING_TOTAL_COUNT=1
\ No newline at end of file
package com.bailuntec; package com.bailuntec;
import com.bailuntec.domain.entity.JobPointLog; import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.job.CashWithdrawDetail;
import com.bailuntec.job.CashierJob; import com.bailuntec.job.CashierJob;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -15,4 +16,12 @@ public class CashierTest { ...@@ -15,4 +16,12 @@ public class CashierTest {
LocalDateTime.of(2019,8,02,0,0))); LocalDateTime.of(2019,8,02,0,0)));
} }
@Test
public void test1() {
CashWithdrawDetail cashWithdrawDetail = new CashWithdrawDetail();
cashWithdrawDetail.executeJob(null, new JobPointLog("base-withdraw-details", 1,100,0,1,
LocalDateTime.of(2019,10,01,0,0),
LocalDateTime.of(2019,10,05,0,0)));
}
} }
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcBaseFinanceCashierdetail;
import com.bailuntec.domain.example.DcBaseFinanceCashierdetailExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseFinanceCashierdetailMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
long countByExample(DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int deleteByExample(DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int insert(DcBaseFinanceCashierdetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int insertSelective(DcBaseFinanceCashierdetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseFinanceCashierdetail selectOneByExample(DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
List<DcBaseFinanceCashierdetail> selectByExample(DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
DcBaseFinanceCashierdetail selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcBaseFinanceCashierdetail record, @Param("example") DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcBaseFinanceCashierdetail record, @Param("example") DcBaseFinanceCashierdetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcBaseFinanceCashierdetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
*/
int updateByPrimaryKey(DcBaseFinanceCashierdetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcBaseFinanceCashierdetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_cashierdetail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcBaseFinanceCashierdetail record);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment