发表于: 2018-04-02 21:04:44

1 510


今日完成

1.模块管理的接口完成

/**
后台:查询模块详情
*
@param model
@param id
@return
@throws Exception
*/
@RequestMapping(value "/a/u/module/{id}"method RequestMethod.GET)
public String getModuleJson(ModelMap model@PathVariable Long id)
throws Exception {

log.info("get data : id= " + id);
   try {
Module module moduleService.getObjectById(id);
       log.info("get module data is " module);
       
       model.addAttribute("code"0);
       
       model.addAttribute("module"module);
       
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("get module error,id is  " + id);
       model.addAttribute("code"-100);
   }

return "/polyFinance-lgd-server/module/json/moduleDetailJson";
}


/**
后台:修改模块
*
@param module
@return
@throws Exception
*/
@RequestMapping(value "/a/u/module/{id}"method RequestMethod.PUTproduces "text/html;charset=UTF-8")
@ResponseBody
public String updateModuleJson(@PathVariable("id"Long idModule module) throws Exception {

log.info("update module : module= " + module);
   JSONObject new JSONObject();
   try {
module.setId(id);
       moduleService.update(module);
       
       a.put("code"0);
       a.put("message""success");
       a.put("data"module);
       
       
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("update module error,id is  " + module.getId());
       a.put("code"-100);
       a.put("message""Server has something wrong");
       
   }
return a.toString();
}

/**
后台:新增模块
*
@param model
@param module
@return
@throws Exception
*/
@RequestMapping(value "/a/u/module"method RequestMethod.POST)
public String addModuleJson(ModelMap modelModule module) throws Exception {

log.info("insert module : module= " + module);
   
   try {
module.setId(null);
       
       moduleService.insert(module);
       
       model.addAttribute("code"0);
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("add module error ");
       model.addAttribute("code"-6002);
   }

return "/polyFinance-lgd-server/module/json/moduleDetailJson";
}

/**
后台:删除模块
*
@param model
@param id
@return
@throws Exception
*/
@RequestMapping(value "/a/u/module/{id}"method RequestMethod.DELETE)
@ResponseBody
public String deleteModuleJson(ModelMap model@PathVariable Long id) throws Exception {
JSONObject new JSONObject();
   log.info("delete module : id= " + id);
   try {
moduleService.delete(id);
       
       log.info("add module success");
       a.put("code"0);
       a.put("message""success");
       
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("delete module error,id is  " + id);
       a.put("code"-100);
       a.put("message""Server has something wrong");
   }

return a.toString();
}


/**
后台:查询模块列表
*
@param model
@return
@throws Exception
*/
@RequestMapping(value "/a/u/module/list"method RequestMethod.GET)
public String getMultiModuleJson(ModelMap model) throws Exception {

try {

List<LongidList moduleService.getModuleIds(0Integer.MAX_VALUE);
       
       List<ModulemoduleList moduleService.getObjectsByIds(idList);
       
       log.info("get  module data is " moduleList);
       
       model.addAttribute("code"0);
       model.addAttribute("total"moduleList.size());
       
       model.addAttribute("moduleList"moduleList);
       
   catch (Throwable t) {

log.error(t.getMessage());
       log.error("get module error");
       model.addAttribute("code"-100);
   }
return "/polyFinance-lgd-server/module/json/moduleListJson";
}

2.推荐匹配与匹配接口

/**
后台:获取债权匹配列表
*
@param id               债权人id
@param productName      产品名称
@param name             用户名
@param valueDayStart    起息日起
@param valueDayEnd      起息日止
@param valueEndDayStart 到息日起
@param valueEndDayEnd   到息日止
@param page             页数
@param size             每页个数
@return
@throws Exception
*/
@RequestMapping(value "/a/u/debtorMatch/list"method RequestMethod.GET)
public String getMultiDebtorMatchJson(ModelMap modelLong idString productNameString nameLong valueDayStartLong valueDayEndLong valueEndDayStartLong valueEndDayEndInteger pageInteger size) throws Exception {

if (CommonUtil.isEmpty(id)) {
model.addAttribute("code"-200);
       return "/polyFinance-lgd-server/debtorMatch/json/debtorMatchListJson";
   }

Map<StringObjectparam DynamicUtil.getDebtorMatch(idproductNamenamevalueDayStartvalueDayEndvalueEndDayStartvalueEndDayEnd);
   
   if (page == null) {
page = 1;
   }
if (size == null) {
size = 10;
   }
int start = (page - 1) * size;
   if (start 0) {
start 0;
   }

try {
List<LongidList debtorMatchService.getIdsByDynamicCondition(DebtorMatch.class, paramstartsize);
       Integer total debtorMatchService.getIdsByDynamicCondition(DebtorMatch.class, param0Integer.MAX_VALUE).size();
       List<DebtorMatchdebtorMatchList debtorMatchService.getObjectsByIds(idList);
       log.info("get  debtorMatch data is " debtorMatchList);
       
       model.addAttribute("code"0);
       model.addAttribute("total"total);
       
       model.addAttribute("debtorMatchList"debtorMatchList);
       
   catch (Throwable t) {
log.error(t.getMessage());
       log.error("get debtorMatch error");
       model.addAttribute("code"-100);
   }

return "/polyFinance-lgd-server/debtorMatch/json/debtorMatchListJson";
}

3.因为推荐匹配的规则实在是没有搞懂怎么个规则。。所以就勉强写了一个按照时间的

/**
后台:推荐匹配
*
@param model
@param page
@param debtStartTime 出借日期
@param debtEndTime   到期日期
@param amount        出借金额
@param size
@param id
@return
@throws Exception
*/
@RequestMapping(value "a/u/debtorMatch/recommend/list"method RequestMethod.GET)
public String getDebtorMatchIdsByDebtorIdJsonList(ModelMap modelInteger pageLong debtStartTimeLong debtEndTimeBigDecimal amountInteger sizeLong id) throws Exception {

List<InvestRecordmatchedList new ArrayList<>();
   
   //金额相等的查询条件
   Map<StringObjectparam1 new HashMap<>();
   param1.put("@table""invest_record");
   param1.put("amount & ="amount);
   param1.put("invest_status & ="0);
   param1.put("matched & ="0);
   
   //投资期限匹配的
   Map<StringObjectparam2 new HashMap<>();
   param2.put("@table""invest_record");
   param2.put("value_end_day & <="debtEndTime);
   
   param2.put("invest_status & ="0);
   param2.put("matched & ="0);
   try {
//1.金额相等的投资记录
       List<LonginvestRecordIds InvestRecordService.getIdsByDynamicCondition(InvestRecord.class, param10Integer.MAX_VALUE);
       List<InvestRecordinvestRecordList1 InvestRecordService.getObjectsByIds(investRecordIds);
       if (investRecordList1 != null) {
matchedList.addAll(investRecordList1);
       }

//2.投资期限
       List<LonginvestRecordIds2 InvestRecordService.getIdsByDynamicCondition(InvestRecord.class, param20Integer.MAX_VALUE);
       List<InvestRecordinvestRecordList2 InvestRecordService.getObjectsByIds(investRecordIds2);
       if (investRecordList2 != null) {
matchedList.addAll(investRecordList2);
       }


model.addAttribute("code"0);
       
       
       model.addAttribute("total"matchedList.size());
       
       model.addAttribute("investRecordList"matchedList);
       
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("get matchedList list error");
       // for test
       model.addAttribute("code"-100);
   }

return "/polyFinance-lgd-server/investRecord/json/investRecordListJson";
}


/**
投资匹配
*
@param model
@return
@throws Exception
*/
@RequestMapping(value "/a/u/debtorMatch/{id}"method RequestMethod.POST)
public String addDebtorMatchJson(@PathVariable Long idModelMap modelLong investRecordId) throws Exception {

log.info("update debtorMatch : debtorId= " + id);
   DebtorMatch debtorMatch new DebtorMatch();
   debtorMatch.setDebtorId(id);
   try {
InvestRecord investRecord InvestRecordService.getObjectById(investRecordId);
       User user userService.getObjectById(investRecord.getUserId());
       debtorMatch.setId(null);
       debtorMatch.setComodatoNum(investRecord.getComodatoNum());
       debtorMatch.setIntercreditorAgreement(investRecord.getIntercreditorAgreement());
       debtorMatch.setProductName(investRecord.getProductName());
       debtorMatch.setName(user.getName());
       debtorMatch.setInvestAmount(investRecord.getInvestAmount());
       debtorMatch.setValueDay(investRecord.getValueDay());
       debtorMatch.setValueEndDay(investRecord.getValueEndDay());
       
       debtorMatchService.insert(debtorMatch);
       //更新该条投资记录
       investRecord.setMatched(1);
       InvestRecordService.update(investRecord);
       
       model.addAttribute("code"0);
   catch (Throwable t) {
t.printStackTrace();
       log.error(t.getMessage());
       log.error("add debtorMatch error ");
       model.addAttribute("code"-6002);
   }

return "/polyFinance-lgd-server/investRecord/json/investRecordListJson";
}

遇到问题

1.支付模块的测试有点坑啊,选啥都成功。

2.这个匹配的规则能有个人讲一下就好了

明日计划

1.支付接口的完成

收获

1.模块管理的完成



返回列表 返回列表
评论

    分享到