kira 6 years ago
parent 448aa422f0
commit 18fc6be9a4

@ -0,0 +1,59 @@
package au.com.royalpay.payment.manage.custom.beans;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
/**
* @author kira
* @date 2018/7/27
*/
public class AddCustomVO {
private String order_id;
private String custom;
private String mch_custom_no;
private boolean has_sub;
private List<JSONObject> subOrders;
public String getOrder_id() {
return order_id;
}
public void setOrder_id(String order_id) {
this.order_id = order_id;
}
public String getCustom() {
return custom;
}
public void setCustom(String custom) {
this.custom = custom;
}
public String getMch_custom_no() {
return mch_custom_no;
}
public void setMch_custom_no(String mch_custom_no) {
this.mch_custom_no = mch_custom_no;
}
public boolean isHas_sub() {
return has_sub;
}
public void setHas_sub(boolean has_sub) {
this.has_sub = has_sub;
}
public List<JSONObject> getSubOrders() {
return subOrders;
}
public void setSubOrders(List<JSONObject> subOrders) {
this.subOrders = subOrders;
}
}

@ -0,0 +1,61 @@
package au.com.royalpay.payment.manage.custom.beans;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
/**
* @author kira
* @date 2018/7/27
*/
public class QueryCustomVo {
private String date;
private String channel;
private int page = 1;
private int limit = 10;
public JSONObject toParam() {
JSONObject result = new JSONObject();
if (StringUtils.isNotEmpty(date)) {
result.put("data", date);
}
if (StringUtils.isNotEmpty(channel)) {
result.put("channel", channel);
}
return result;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
}

@ -1,8 +1,21 @@
package au.com.royalpay.payment.manage.custom.core;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
/**
* @author kira
* @date 2018/7/27
*/
public interface CustomService {
JSONObject findOneWithDetail(String report_id);
void add(String orderId, String mchCustomId, String custom, List<JSONObject> subOrders);
boolean check(int client_id, String channel);
JSONObject query(JSONObject param, int page, int limit);
}

@ -1,10 +1,70 @@
package au.com.royalpay.payment.manage.custom.core.impl;
import au.com.royalpay.payment.core.CustomSupport;
import au.com.royalpay.payment.core.beans.CustomReport;
import au.com.royalpay.payment.manage.custom.core.CustomService;
import au.com.royalpay.payment.manage.mappers.custom.CustomReportDetailsMapper;
import au.com.royalpay.payment.manage.mappers.custom.CustomReportsMapper;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/7/27
*/
@Service
public class CustomServiceImpl implements CustomService {
@Resource
private CustomSupport customSupport;
@Resource
private CustomReportsMapper customReportsMapper;
@Resource
private CustomReportDetailsMapper customReportDetailsMapper;
@Override
public JSONObject findOneWithDetail(String report_id) {
JSONObject result = customReportsMapper.findOne(report_id);
result.put("sub_orders", customReportDetailsMapper.findByReportId(report_id));
return result;
}
@Override
public void add(String orderId, String mchCustomId, String custom, List<JSONObject> subOrders) {
CustomReport customReport = new CustomReport(orderId, mchCustomId, custom);
if (!CollectionUtils.isEmpty(subOrders)) {
subOrders.forEach(p -> {
customReport.addSubOrder(p.getBigDecimal("order_fee"), p.getBigDecimal("product_fee"));
});
}
JSONObject result = customSupport.saveCustom(customReport);
customSupport.sendCustom(result.getString("report_id"));
}
@Override
public boolean check(int client_id, String channel) {
List<String> supportChannel = customSupport.customSupportedChannels(client_id);
boolean result = false;
for (String p : supportChannel) {
if (p.equals(channel)) {
result = true;
break;
}
}
return result;
}
@Override
public JSONObject query(JSONObject param, int page, int limit) {
return PageListUtils.buildPageListResult(customReportsMapper.queryWithTrans(param, new PageBounds(page, limit)));
}
}

@ -0,0 +1,39 @@
package au.com.royalpay.payment.manage.custom.web;
import au.com.royalpay.payment.manage.custom.beans.AddCustomVO;
import au.com.royalpay.payment.manage.custom.beans.QueryCustomVo;
import au.com.royalpay.payment.manage.custom.core.CustomService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping(value = "/custom")
public class CustomController {
@Resource
private CustomService customService;
@RequestMapping(value = "/{report_id}",method = RequestMethod.GET)
public JSONObject findOne(@PathVariable String report_id) {
return customService.findOneWithDetail(report_id);
}
@RequestMapping(value = "/query",method = RequestMethod.GET)
public JSONObject queryWithTran( QueryCustomVo queryCustomVo) {
return customService.query(queryCustomVo.toParam(),queryCustomVo.getPage(),queryCustomVo.getLimit());
}
@RequestMapping(value = "",method = RequestMethod.POST)
@ResponseBody
public void add(AddCustomVO addCustomVO) {
customService.add(addCustomVO.getOrder_id(),addCustomVO.getMch_custom_no(),addCustomVO.getCustom(),addCustomVO.getSubOrders());
}
}

@ -0,0 +1,23 @@
package au.com.royalpay.payment.manage.mappers.custom;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yishuqian on 9/1/16.
*/
@AutoMapper(tablename = "pmt_custom_report_details", pkName = "sub_order_no")
public interface CustomReportDetailsMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findByReportId(@Param("report_id") String report_id);
}

@ -0,0 +1,24 @@
package au.com.royalpay.payment.manage.mappers.custom;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yishuqian on 9/1/16.
*/
@AutoMapper(tablename = "pmt_custom_reports", pkName = "report_id")
public interface CustomReportsMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findOne(@Param("report_id") String report_id);
PageList<JSONObject> queryWithTrans(JSONObject param,PageBounds pagination);
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.custom.CustomReportDetailsMapper">
</mapper>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.custom.CustomReportsMapper">
<select id="queryWithTrans" resultType="com.alibaba.fastjson.JSONObject">
select * from
pmt_custom_reports r
left join
pmt_transactions t
on r.order_id = t.order_id
<where>
</where>
</select>
</mapper>
Loading…
Cancel
Save