From 18fc6be9a4340c4fcb502279a50d4232b64b51e2 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 27 Jul 2018 15:39:00 +0800 Subject: [PATCH] tmp --- .../manage/custom/beans/AddCustomVO.java | 59 ++++++++++++++++++ .../manage/custom/beans/QueryCustomVo.java | 61 +++++++++++++++++++ .../manage/custom/core/CustomService.java | 13 ++++ .../custom/core/impl/CustomServiceImpl.java | 60 ++++++++++++++++++ .../manage/custom/web/CustomController.java | 39 ++++++++++++ .../custom/CustomReportDetailsMapper.java | 23 +++++++ .../mappers/custom/CustomReportsMapper.java | 24 ++++++++ .../custom/CustomReportDetailsMapper.xml | 6 ++ .../mappers/custom/CustomReportsMapper.xml | 17 ++++++ 9 files changed, 302 insertions(+) create mode 100644 src/main/java/au/com/royalpay/payment/manage/custom/beans/AddCustomVO.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.xml create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/beans/AddCustomVO.java b/src/main/java/au/com/royalpay/payment/manage/custom/beans/AddCustomVO.java new file mode 100644 index 000000000..0b58bf576 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/custom/beans/AddCustomVO.java @@ -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 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 getSubOrders() { + return subOrders; + } + + public void setSubOrders(List subOrders) { + this.subOrders = subOrders; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java b/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java new file mode 100644 index 000000000..4c39e4ea5 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java @@ -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; + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java b/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java index 7d7708b0a..9ec90c39c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java @@ -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 subOrders); + + boolean check(int client_id, String channel); + + JSONObject query(JSONObject param, int page, int limit); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java index 4ee4cc1c8..dbeee4095 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java @@ -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 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 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))); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java b/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java new file mode 100644 index 000000000..2378dd501 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java @@ -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()); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java new file mode 100644 index 000000000..1e1f73f3f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java @@ -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); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java new file mode 100644 index 000000000..462675dd6 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java @@ -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 queryWithTrans(JSONObject param,PageBounds pagination); +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.xml new file mode 100644 index 000000000..8f3c59631 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml new file mode 100644 index 000000000..643adad9b --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file