diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/CustomerImpression.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/CustomerImpression.java index 5ec9f7006..f4e21636f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/CustomerImpression.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/CustomerImpression.java @@ -14,4 +14,6 @@ public interface CustomerImpression { JSONObject findOne(int client_id,String customer_id); void generate(int client_id); + + void modifyNameRemark(int client_id, String customer_id,String name_remark); } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java index b09d03387..034c11350 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImpl.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.apps.core.impls; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -22,6 +23,7 @@ import au.com.royalpay.payment.manage.apps.core.CustomerImpression; import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.utils.PageListUtils; /** @@ -72,9 +74,9 @@ public class CustomerImpressionImpl implements CustomerImpression { public void generate(int client_id) { JSONObject params = new JSONObject(); params.put("client_id", client_id); - PageList lastRecord = clientCustomersMapper.listCustomerInfo(params, new PageBounds(1, 1, Order.formString("create_time.desc"))); + PageList lastRecord = clientCustomersMapper.listCustomerInfo(params, new PageBounds(1, 1, Order.formString("update_time.desc"))); if (!CollectionUtils.isEmpty(lastRecord)) { - params.put("confirm_time", lastRecord.get(0).getDate("creata_time")); + params.put("confirm_time", lastRecord.get(0).getDate("update_time")); } List orders = orderMapper.listAnalysisClientCustomer(params); Date now = new Date(); @@ -97,11 +99,17 @@ public class CustomerImpressionImpl implements CustomerImpression { } client_customer.put("payment_times", order.getIntValue("payment_times")); client_customer.put("total_amount", order.getBigDecimal("total_amount")); - client_customer.put("create_time", now); + client_customer.put("update_time", now); clientCustomersMapper.insert(client_customer); } else { clientCustomerInfo.put("payment_times", clientCustomerInfo.getIntValue("payment_times") + order.getIntValue("payment_times")); - clientCustomerInfo.put("total_amount", clientCustomerInfo.getBigDecimal("total_amount").add(order.getBigDecimal("total_amount"))); + BigDecimal total_amount = clientCustomerInfo.getBigDecimal("total_amount"); + if(total_amount!=null){ + clientCustomerInfo.put("total_amount", clientCustomerInfo.getBigDecimal("total_amount").add(order.getBigDecimal("total_amount"))); + }else { + clientCustomerInfo.put("total_amount",order.getBigDecimal("total_amount")); + } + if (order.getString("alipay_headimg") == null) { clientCustomerInfo.put("headimg", order.getString("wechat_headimg")); clientCustomerInfo.put("nick_name", order.getString("wechat_nickname")); @@ -110,9 +118,20 @@ public class CustomerImpressionImpl implements CustomerImpression { clientCustomerInfo.put("nick_name", order.getString("alipay_nickname")); } clientCustomerInfo.put("channel", order.getString("channel")); + clientCustomerInfo.put("update_time",now); clientCustomersMapper.update(clientCustomerInfo); } } } + @Override + public void modifyNameRemark(int client_id, String customer_id, String name_remark) { + JSONObject clientCustomerInfo = clientCustomersMapper.getClientCustomer(client_id,customer_id); + if(clientCustomerInfo==null){ + throw new NotFoundException("customer not found"); + } + clientCustomerInfo.put("name_remak",name_remark); + clientCustomersMapper.update(clientCustomerInfo); + } + } \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/web/CustomerImpressionController.java b/src/main/java/au/com/royalpay/payment/manage/apps/web/CustomerImpressionController.java index 2035918cf..18469792a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/web/CustomerImpressionController.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/web/CustomerImpressionController.java @@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.apps.core.CustomerImpression; import com.alibaba.fastjson.JSONObject; 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.ResponseBody; @@ -31,4 +32,10 @@ public class CustomerImpressionController { public JSONObject find(@PathVariable int client_id,@PathVariable String customer_id) { return customerImpression.findOne(client_id,customer_id); } + + @RequestMapping(value = "/{client_id}/{customer_id}", method = RequestMethod.PUT) + @ResponseBody + public void modifyNameRemark(@PathVariable int client_id, @PathVariable String customer_id, @RequestBody JSONObject customerInfo) { + customerImpression.modifyNameRemark(client_id,customer_id,customerInfo.getString("name_remark")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java index 253b4799f..44c521091 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject; 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; @@ -21,4 +23,7 @@ public interface TopUpOrderMapper { @AutoSql(type = SqlType.SELECT) JSONObject findById(@Param("id") String id); + + List findOrderIdByStatus(@Param("status") String status); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiClientImpl.java b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiClientImpl.java index 597c10a2d..887ebb16d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiClientImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/ofei/core/impl/OfeiClientImpl.java @@ -33,6 +33,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; +import javafx.application.Platform; /** * Created by wangning on 2017/12/7. @@ -73,14 +74,15 @@ public class OfeiClientImpl implements OfeiClient { params.add(new BasicNameValuePair("sporder_id", orderId)); params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss"))); params.add(new BasicNameValuePair("game_userid", phoneNumber)); + params.add(new BasicNameValuePair("ret_url", "https://mpay.royalpay.com.au/ofei/notice/"+orderId)); saveOrder(orderId, now, "1", price, phoneNumber); HttpRequestGenerator req = initRequest(topUPUrl, signAndEncryptForm(params), RequestMethod.GET); Element respXml = executeRequestXML(req, "ofei phone top up fail"); - handleResponse(orderId, respXml); + handleResponse(orderId, respXml,phoneNumber); } - private void handleResponse(String orderId, Element respXml) { + private void handleResponse(String orderId, Element respXml,String phoneNumber) { JSONObject detail = new JSONObject(); if ("1".equals(respXml.elementText("retcode"))) { detail.put("cardname", respXml.elementText("cardname")); @@ -99,6 +101,8 @@ public class OfeiClientImpl implements OfeiClient { }else { detail.put("err_msg",respXml.elementText("err_msg")); updateOrder(orderId,"99",detail); + logger.debug("phone->"+phoneNumber+" top up error orderId->"+orderId); + throw new ServerErrorException("System error"); } } @@ -142,7 +146,7 @@ public class OfeiClientImpl implements OfeiClient { saveOrder(orderId, new Date(), "2", perValue, phoneNumber); HttpRequestGenerator req = initRequest(flowTopUPUrl, signAndEncryptForm(params), RequestMethod.GET); Element respXml = executeRequestXML(req, "ofei flowTopUp"); - handleResponse(orderId, respXml); + handleResponse(orderId, respXml,phoneNumber); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java b/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java new file mode 100644 index 000000000..ea161132b --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java @@ -0,0 +1,31 @@ +package au.com.royalpay.payment.manage.task; + +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper; +import au.com.royalpay.payment.manage.ofei.core.OfeiServer; + +/** + * Created by wangning on 2018/1/2. + */ +@Component +@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") +public class OfeiOrderCheckTask { + @Resource + private OfeiServer ofeiServer; + @Resource + private TopUpOrderMapper topUpOrderMapper; + @Scheduled(cron = "0 0/20 * * * ?") + public void checkGreenChannel(){ + List orderIds = topUpOrderMapper.findOrderIdByStatus("10"); + for (String orderId : orderIds) { + ofeiServer.checkOrder(orderId); + } + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index 960b56de9..6848bd064 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -6,25 +6,33 @@ import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.TransactionService; -import au.com.royalpay.payment.core.exceptions.*; +import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; +import au.com.royalpay.payment.core.exceptions.OrderNotMatchException; +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper; -import au.com.royalpay.payment.manage.mappers.payment.*; +import au.com.royalpay.payment.manage.mappers.payment.AustracDataMapper; +import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; +import au.com.royalpay.payment.manage.mappers.payment.RefundAuditionMapper; +import au.com.royalpay.payment.manage.mappers.payment.RefundMapper; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; -import au.com.royalpay.payment.tools.permission.enums.ManagerRole; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils; + import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; + import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; @@ -32,13 +40,24 @@ import net.sf.jasperreports.engine.JasperRunManager; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import net.sf.jasperreports.engine.export.JRXlsExporter; import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; -import net.sf.jasperreports.export.*; +import net.sf.jasperreports.export.ExporterInput; +import net.sf.jasperreports.export.OutputStreamExporterOutput; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; +import net.sf.jasperreports.export.SimpleXlsxReportConfiguration; + import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; -import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,8 +65,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.ui.Model; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -63,6 +80,9 @@ import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; @@ -380,7 +400,7 @@ public class TradeLogServiceImpl implements TradeLogService { obj.put("customer_id", orderLog.getString("customer_id")); obj.put("name_remak", name_remark); obj.put("channel",order.getString("channel")); - obj.put("create_time",new Date()); + obj.put("update_time",new Date()); JSONObject client_coustom = clientCustomersMapper.getClientCustomer(orderLog.getInteger("client_id"), orderLog.getString("customer_id")); if (null == client_coustom) { clientCustomersMapper.insert(obj); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml new file mode 100644 index 000000000..24d828793 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/ofei/TopUpOrderMapper.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index c6308a28f..38d86b896 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -540,8 +540,10 @@ cra.headimg alipay_headimg, cra.nickname alipay_nickname, cr.nickname wechat_nickname, - cr.headimg wechat_headimg - from pmt_orders o + cr.headimg wechat_headimg, + max( o.confirm_time) confirm_time + + from pmt_orders_copy o left join sys_customer_relation cr on cr.wepay_openid = o.customer_id left join sys_customer_relation_alipay cra on cra.alipay_uid = o.customer_id where o.customer_id is not null diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index afd850904..7e015a543 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -35,11 +35,26 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu return $http.get('/app/cms/categories/' + $stateParams.catId + '/articles/' + $stateParams.articleId); }] } + }).state('cms.phone_top_up', { + url: '/phone_top_up', + controller: 'CmsPhonetopupCtrl', + templateUrl: '/static/cms/templates/phone_top_up.html' }) }]); app.controller('cmsRootCtrl', ['$scope', function ($scope) { }]); + app.controller('CmsPhonetopupCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) { + $scope.topUp = function () { + var params = angular.copy($scope.params); + $http.get('/phone_top_up/recharge',{params: params}).then(function (resp) { + alert('ok'); + }, function (resp) { + alert(resp.data.message); + }) + } + }]); + app.controller('cmsArticleListCtrl', ['$scope', '$http', '$stateParams', function ($scope, $http, $stateParams) { $scope.pagination = {}; $scope.listArticles = function (page) { diff --git a/src/main/ui/static/cms/templates/cms_root.html b/src/main/ui/static/cms/templates/cms_root.html index aed11b63e..69e7b8911 100644 --- a/src/main/ui/static/cms/templates/cms_root.html +++ b/src/main/ui/static/cms/templates/cms_root.html @@ -26,6 +26,9 @@ + diff --git a/src/main/ui/static/cms/templates/phone_top_up.html b/src/main/ui/static/cms/templates/phone_top_up.html new file mode 100644 index 000000000..726fbca90 --- /dev/null +++ b/src/main/ui/static/cms/templates/phone_top_up.html @@ -0,0 +1,36 @@ +
+

Phone Top Up

+ +
+ +
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+
+