From 43abd4d5b172f518425e83b5ebffe3417d815dc3 Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Thu, 19 Jul 2018 11:00:53 +0800 Subject: [PATCH] add pos refund list --- .../appclient/core/RetailAppService.java | 2 + .../core/impls/RetailAppServiceImp.java | 33 +++++++--- .../appclient/web/RetailAppController.java | 62 ++++++++++--------- .../manage/mappers/payment/RefundMapper.java | 20 +++--- .../manage/tradelog/refund/RefundService.java | 5 ++ .../refund/impls/RefundServiceImpl.java | 47 +++++++++----- .../manage/mappers/payment/RefundMapper.xml | 58 +++++++++++++++++ 7 files changed, 165 insertions(+), 62 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index c3cfc669f..a6263c210 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -149,4 +149,6 @@ public interface RetailAppService { void applyToCompliance(JSONObject device); JSONObject sendVerifyEmail(JSONObject device); + + JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 5a1c6d6ec..e2878ed77 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -37,6 +37,7 @@ import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; +import au.com.royalpay.payment.manage.tradelog.refund.RefundService; import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport; import au.com.royalpay.payment.tools.device.DeviceSupport; import au.com.royalpay.payment.tools.device.message.AppMessage; @@ -163,6 +164,8 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private ClientMapper clientMapper; @Resource + private RefundService refundService; + @Resource private ClientModifySupport clientModifySupport; @Resource private ClearingLogMapper clearingLogMapper; @@ -329,11 +332,11 @@ public class RetailAppServiceImp implements RetailAppService { } tradeLogQuery.setClient_ids(appQueryBean.getApp_client_ids().split(",")); JSONObject client = clientManager.getClientInfo(Integer.parseInt(tradeLogQuery.getClient_ids()[0])); - if(client==null){ + if (client == null) { throw new NotFoundException("Client Not Exists"); } device.put("client_moniker", client.getString("client_moniker")); - device.put("client",client); + device.put("client", client); tradeLogService.exportTransFlow(tradeLogQuery, device, httpResponse); } @@ -410,6 +413,16 @@ public class RetailAppServiceImp implements RetailAppService { return result; } + @Override + public JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean) { + JSONObject appParam = appQueryBean.toParams(); + JSONObject param = new JSONObject(); + param.put("client_id",device.getIntValue("client_id")); + param.put("start_time",appParam.getDate("begin")); + param.put("end_time",appParam.getDate("end")); + return refundService.listUnionAllApply(param, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit())); + } + @Override public void updateClient(JSONObject device, AppClientBean appClientBean) { String clientType = device.getString("client_type"); @@ -554,11 +567,11 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject result = PageListUtils.buildPageListResult(logs); if (appQueryBean.getPage() == 1) { if (!logs.isEmpty() && logs.size() > 0) { - JSONObject clearingLog = clearingLogMapper.findById(logs.get(0).getIntValue("clearing_id")); - if(clearingLog.getBoolean("editable")){ - result.put("padding", true); - logs.get(0).put("padding",true); - } + JSONObject clearingLog = clearingLogMapper.findById(logs.get(0).getIntValue("clearing_id")); + if (clearingLog.getBoolean("editable")) { + result.put("padding", true); + logs.get(0).put("padding", true); + } } } return result; @@ -1160,7 +1173,7 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject unReadParams = new JSONObject(); unReadParams.put("client_id", client_id); unReadParams.put("status", 0); - unReadParams.put("is_to_app",1); + unReadParams.put("is_to_app", 1); int counts = noticePartnerMapper.countNoticePartner(unReadParams); notice.put("unReadCounts", counts); notice.put("type", "notice"); @@ -1205,7 +1218,7 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject bankInfo = clientManager.getBankAccountByClientId(device.getIntValue("client_id")); - bankInfo.put("account_no","***"+ StringUtils.substring(bankInfo.getString("account_no"), -4)); + bankInfo.put("account_no", "***" + StringUtils.substring(bankInfo.getString("account_no"), -4)); return bankInfo; } @@ -1296,7 +1309,7 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device, String app_client_ids) { try { JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); - if(client==null){ + if (client == null) { return null; } timezone = client.getString("timezone"); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 9caa888d2..b87c5e7af 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -1,34 +1,5 @@ package au.com.royalpay.payment.manage.appclient.web; -import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE; - -import java.math.BigDecimal; -import java.text.ParseException; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; - -import org.apache.commons.lang3.time.DateUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.ModelAndView; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService; @@ -55,6 +26,35 @@ import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import org.apache.commons.lang3.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE; + /** * Created by yishuqian on 28/03/2017. */ @@ -109,6 +109,10 @@ public class RetailAppController { public JSONObject getTradeCommonData(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) { return retailAppService.getTradeCommonDate(device, appQueryBean); } + @RequestMapping(value = "/trade/refund", method = RequestMethod.GET) + public JSONObject getRefunds(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) { + return retailAppService.getRefunds(device, appQueryBean); + } @RequestMapping(value = "/trade_common_new", method = RequestMethod.GET) public JSONObject getTradeCommonDataNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) { diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.java index 72ba19086..64ff2ecd8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.java @@ -1,16 +1,19 @@ package au.com.royalpay.payment.manage.mappers.payment; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; + import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.SqlType; -import com.alibaba.fastjson.JSONObject; -import com.github.miemiedev.mybatis.paginator.domain.PageBounds; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; /** * Created by yixian on 2016-06-25. @@ -55,4 +58,7 @@ public interface RefundMapper { List listRefundDate(@Param("begin") Date begin, @Param("end") Date end); List listClientRefund(JSONObject param); + + PageList listUnionAllApply(JSONObject params, PageBounds pagination); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/RefundService.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/RefundService.java index 4ebe34c71..34c68c90a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/RefundService.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/RefundService.java @@ -1,7 +1,10 @@ package au.com.royalpay.payment.manage.tradelog.refund; import au.com.royalpay.payment.manage.analysis.beans.RefundReviewBean; + import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; + import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; @@ -44,4 +47,6 @@ public interface RefundService { JSONObject findReviewOrder(String reviewId); JSONObject checkRefundAuditFlag(); + + JSONObject listUnionAllApply(JSONObject params,PageBounds pagination); } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java index f37f39041..54635f160 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java @@ -87,7 +87,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish throw new RefundExistException(); } if (apply.isEmpty()) { - order.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")).subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); + order.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")) + .subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); return order; } else { if (account != null) { @@ -118,7 +119,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish if (undoRefundOrder != null) { throw new BadRequestException("该笔订单有退款正在处理,请稍后再试!"); } - order.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")).subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); + order.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")) + .subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); return order; } @@ -143,12 +145,13 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish int clientId = order.getIntValue("client_id"); String currency = order.getString("currency"); - //增加角色审核 + // 增加角色审核 JSONObject client = clientManager.getClientInfo(clientId); Assert.notNull(client, "client not exists"); JSONObject clientConfig = clientConfigService.find(clientId); OperatorType type = account != null ? OperatorType.PARTNER : OperatorType.MANAGER; - boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER && clientConfig.getBooleanValue("enable_refund_auth"); + boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER + && clientConfig.getBooleanValue("enable_refund_auth"); logger.debug("applyer type=" + type + "; require audit=" + requireAudit); paymentApi.clientRefundBalanceCheck(clientId, orderId, currency, feeAmount); @@ -189,9 +192,9 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish BigDecimal realAmount = original ? fee : CurrencyAmountUtils.toAmount(fee, order.getString("currency")); JSONObject refundConfig = checkRefundAuditFlag(); - if (partnerAccount!=null && refundConfig != null && refundConfig.size() > 0 && refundConfig.getBoolean("refundAudit")) { + if (partnerAccount != null && refundConfig != null && refundConfig.size() > 0 && refundConfig.getBoolean("refundAudit")) { if (realAmount.compareTo(refundConfig.getBigDecimal("refundAuditAmount")) > 0) { - //订单需要审核 + // 订单需要审核 boolean casherRefund = reviewNewRefundOrder(orderId, realAmount, remark, partnerAccount, manager); if (casherRefund) { return executeRefund(orderId, realAmount, remark, partnerAccount, manager, order, client); @@ -204,7 +207,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish } - private JSONObject executeRefund(String orderId, BigDecimal amount, String remark, JSONObject partnerAccount, JSONObject manager, JSONObject order, JSONObject client) { + private JSONObject executeRefund(String orderId, BigDecimal amount, String remark, JSONObject partnerAccount, JSONObject manager, JSONObject order, + JSONObject client) { checkOrderUseCustomerCoupon(order, amount); JSONObject clientConfig = clientConfigService.find(client.getIntValue("client_id")); OperatorType type = partnerAccount != null ? OperatorType.PARTNER : OperatorType.MANAGER; @@ -220,12 +224,13 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish operator.put("operator_id", manager.getIntValue("manager_id")); operator.put("operator", manager.getString("display_name")); } - boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(partnerAccount.getIntValue("role")) == PartnerRole.CASHIER && clientConfig.getBooleanValue("enable_refund_auth"); + boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(partnerAccount.getIntValue("role")) == PartnerRole.CASHIER + && clientConfig.getBooleanValue("enable_refund_auth"); logger.debug("applyer type=" + type + "; require audit=" + requireAudit); return paymentApi.refundOrder(orderId, null, amount, remark, operator, type, requireAudit); } - //订单使用积分商城优惠券,仅支持全额退款 + // 订单使用积分商城优惠券,仅支持全额退款 private void checkOrderUseCustomerCoupon(JSONObject order, BigDecimal feeAmount) { JSONObject couponLogs = couponAccuessLogMapper.findUsedCouponByOrderId(order.getString("order_id")); if (couponLogs != null) { @@ -237,7 +242,7 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish } @Override -// @Transactional + // @Transactional public JSONObject newReviewRefundOrder(String orderId, BigDecimal fee, boolean original, String remark, JSONObject manager) { JSONObject reviewOrder = refundReviewMapper.findUnResolveByOrderId(orderId); reviewOrder.put("status", 1); @@ -338,7 +343,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish private void submitRefund(JSONObject account, JSONObject audition) { JSONObject refundLog = refundMapper.find(audition.getString("refund_id")); - boolean platformAuditFlag = auditRefundAndCommitToPlatform(refundLog.getBigDecimal("amount"), audition.getString("remark"), refundLog.getString("order_id"), account); + boolean platformAuditFlag = auditRefundAndCommitToPlatform(refundLog.getBigDecimal("amount"), audition.getString("remark"), + refundLog.getString("order_id"), account); if (!platformAuditFlag) { paymentApi.submitRefund(audition.getString("refund_id")); } @@ -347,13 +353,12 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish private boolean auditRefundAndCommitToPlatform(BigDecimal amount, String remark, String orderId, JSONObject account) { if (amount.compareTo(BigDecimal.ZERO) > 0) { JSONObject refundConfig = checkRefundAuditFlag(); - if (refundConfig != null && refundConfig.getBoolean("refundAudit") && - amount.compareTo(refundConfig.getBigDecimal("refundAuditAmount")) >= 0) { - //订单需要审核 + if (refundConfig != null && refundConfig.getBoolean("refundAudit") && amount.compareTo(refundConfig.getBigDecimal("refundAuditAmount")) >= 0) { + // 订单需要审核 reviewNewRefundOrder(orderId, amount, remark, account, null); return true; } - //退款 + // 退款 return false; } else { throw new BadRequestException("Refund amount can not be 0"); @@ -411,7 +416,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish } review.put("bd_name", bdNameStr.deleteCharAt(bdNameStr.length() - 1).toString()); JSONObject order = orderMapper.find(review.getString("order_id")); - review.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")).subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); + review.put("available", BigDecimal.valueOf(order.getDoubleValue("customer_payment_amount")) + .subtract(BigDecimal.valueOf(order.getDoubleValue("refund_fee"))).doubleValue()); review.put("create_time", order.getDate("create_time")); review.put("channel", order.getString("channel")); return review; @@ -427,6 +433,15 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish return refundConfig; } + @Override + public JSONObject listUnionAllApply(JSONObject params, PageBounds pagination) { + if(params.get("cleint_id")==null && params.get("client_ids")==null){ + return null; + } + return PageListUtils.buildPageListResult(refundMapper.listUnionAllApply(params, pagination)); + + } + @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.publisher = applicationEventPublisher; diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.xml index 1d4502713..d2c2b55de 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/RefundMapper.xml @@ -69,4 +69,62 @@ and DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(#{today},'%Y-%m-%d'); + \ No newline at end of file