diff --git a/pom.xml b/pom.xml index 609b911f7..0ad4332e7 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.3.5 + 1.3.6 UTF-8 1.4.0 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 5836b9e72..2cc22a4c9 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 @@ -57,6 +57,8 @@ public interface RetailAppService { void sendTransactionDailyMessage(JSONObject tradeInfo, int clientId); + void sendRServicesApplyMessage(JSONObject applyInfo, JSONObject client); + void updateReadStatus(JSONObject device, String noticeId); JSONObject getDevTokenByDevId(String devId); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java index 96e0295d9..a734f73b8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailRSvcService.java @@ -11,4 +11,6 @@ public interface RetailRSvcService { * @return */ JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode); + + JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params); } 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 f09c96da7..abe949cde 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 @@ -79,7 +79,6 @@ import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; -import org.joda.time.DateTime; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.slf4j.LoggerFactory; @@ -1389,6 +1388,51 @@ public class RetailAppServiceImp implements RetailAppService { } } + @Override + public void sendRServicesApplyMessage(JSONObject applyInfo, JSONObject client) { + String amount = applyInfo.getBigDecimal("amount").setScale(2, RoundingMode.HALF_DOWN).toString(); + String title = applyInfo.getString("title"); + String remark = title + "已扣款成功!" + ",$" + amount + ".感谢您的使用,如有疑问或需帮助,请拨打我们的客服电话:1300 107 750或添加RoyalPay官方客服号:royalpay_1详询."; + String operatorTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + logger.debug("sendRServicesMessage-{}-{} {}({}}-{}})", + client.getString("client_moniker"), + PlatformEnvironment.getEnv().getForeignCurrency(), + amount, + title, + operatorTime); + List tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id")); + for (JSONObject devToken : tokens) { + String token = devToken.getString("token"); + if (token == null) { + continue; + } + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token,remark); + try { + JSONObject type = new JSONObject(); + type.put("send_type", "notice"); + type.put("id", applyInfo.getString("apply_id")); + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.notice")); + managerMsg.put("body", LocaleSupport.localeMessage("app.message.rservices.body", title, amount)); + managerMsg.put("type", type); + managerMsg.put("data", type); + managerMsg.put("msgType", "notice"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); + log.put("status", 2); + appMessageLogMapper.update(log); + } catch (Exception e) { + logger.error("出错了:", e); + appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); + throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); + } + } + } + @Override public void updateReadStatus(JSONObject device, String noticeId) { String clientType = device.getString("client_type"); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java index 12fc1dd4e..535275a01 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java @@ -1,7 +1,9 @@ package au.com.royalpay.payment.manage.appclient.core.impls; +import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean; import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService; +import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.tools.codec.AESCrypt; import au.com.royalpay.payment.tools.device.DeviceSupport; @@ -18,6 +20,8 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.nio.charset.StandardCharsets; import java.security.Key; +import java.util.Date; +import java.util.UUID; @Service public class RetailRSvcServiceImpl implements RetailRSvcService { @@ -28,6 +32,8 @@ public class RetailRSvcServiceImpl implements RetailRSvcService { private DeviceSupport deviceSupport; @Resource private CommonIncrementalChannelMapper commonIncrementalChannelMapper; + @Resource + private ClientServicesApplyMapper clientServicesApplyMapper; @Override public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) { @@ -46,7 +52,6 @@ public class RetailRSvcServiceImpl implements RetailRSvcService { result.put("enc_data", new JSONObject() { { put("credentialCode", encData(svcMchBean.getCredentialCode(), key, svcInfo.getString("channel_pub_key"))); - put("payHost", encData(svcMchBean.getPayHost(), key, svcInfo.getString("channel_pub_key"))); put("partnerCode", encData(svcMchBean.getPartnerCode(), key, svcInfo.getString("channel_pub_key"))); put("merchantNumber", encData(svcMchBean.getMerchantNumber(), key, svcInfo.getString("channel_pub_key"))); @@ -63,8 +68,56 @@ public class RetailRSvcServiceImpl implements RetailRSvcService { return result; } + @Override + public JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params) { + JSONObject result = new JSONObject(); + JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode); + try { + if (svcInfo == null || StringUtils.isEmpty(svcInfo.getString("channel_pub_key")) + || StringUtils.isEmpty(svcInfo.getString("platform_pub_key")) || StringUtils.isEmpty("platform_pri_key")) { + throw new BadRequestException("this channel config is wrong"); + } + String signa = params.getString("sign"); + params.remove(signa); + params = JSONObject.parseObject(JSON.toJSONString(params), Feature.OrderedField); + boolean checkSign = SignUtils.validSign(params.toJSONString(), signa, svcInfo.getString("channel_pub_key")); + if (!checkSign) { + throw new BadRequestException("sign is wrong"); + } + JSONObject client = clientManager.getClientInfoByMoniker(params.getString("signClient")); + if (client == null) { + throw new InvalidShortIdException(); + } + String aesKeyStr = Base64.encodeBase64String(AESCrypt.randomKey().getEncoded()); + Key key = AESCrypt.fromKeyString(Base64.decodeBase64(aesKeyStr)); + JSONObject serviceApply = new JSONObject(); + serviceApply.put("apply_id", UUID.randomUUID().toString()); + serviceApply.put("service_code", sourceCode); + serviceApply.put("client_id", client.getIntValue("client_id")); + serviceApply.put("title", params.getString("signData")); + serviceApply.put("amount", decData(params.getString("signPrice"), key, svcInfo.getString("platform_pri_key"))); + serviceApply.put("apply_username", params.getString("signName")); + serviceApply.put("status", 0); + serviceApply.put("is_valid", 1); + serviceApply.put("create_time", new Date()); + clientServicesApplyMapper.save(serviceApply); + result.put("result_code", "SUCCESS"); + result.put("result_status", "PROCESSING"); + } catch (Exception e) { + result.put("result_code", "SUCCESS"); + result.put("result_status", "SYSTEMERROR"); + result.put("result_msg", e.getMessage()); + } + return result; + } + private String encData(String data, Key key, String publicKey) { String pubKeyEncData = SignUtils.encData(data, publicKey); return org.apache.commons.codec.binary.Base64.encodeBase64String(AESCrypt.encrypt(pubKeyEncData.getBytes(StandardCharsets.UTF_8), key)); } + + private String decData(String data, Key key, String privateKey) { + String priKeyDecData = SignUtils.decData(data, privateKey); + return org.apache.commons.codec.binary.Base64.encodeBase64String(AESCrypt.encrypt(priKeyDecData.getBytes(StandardCharsets.UTF_8), key)); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailRSvcController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailRSvcController.java index f4debc8cf..248e263b8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailRSvcController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailRSvcController.java @@ -4,10 +4,7 @@ import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.device.advise.AppClientController; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -23,4 +20,9 @@ public class RetailRSvcController { return retailRSvcService.findMchInfoBySourceCode(device, source_code); } + @PostMapping(value = "/{source_code}/enterService") + public JSONObject enterIntoServiceBySourceCode(@PathVariable String source_code, @RequestBody JSONObject params) { + return retailRSvcService.enterIntoServiceBySourceCode(source_code, params); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 4e5c35787..7f6b6806d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -5,7 +5,6 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.tasksupport.SettlementSupport; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.mappers.log.*; -import au.com.royalpay.payment.manage.mappers.payment.SysClientIncrementalMapper; import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.*; @@ -135,9 +134,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider @Resource private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper; @Resource - private SysClientIncrementalMapper sysClientIncrementalMapper; - @Resource private Locker locker; + @Resource + private ClientIncrementalMapper clientIncrementalMapper; @Resource private ClientDeviceMapper clientDeviceMapper; @@ -733,7 +732,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider new PageBounds(Order.formString("order_id.asc"))); for (JSONObject transaction : transactions) { - transaction.put("rate_value",StringUtils.defaultString(sysClientIncrementalMapper.findByChannelAndClientId(transaction.getString("client_id"),transaction.getString("source")) ,"0")); + transaction.put("rate_value",StringUtils.defaultString(clientIncrementalMapper.findByChannelAndClientId(transaction.getIntValue("client_id"),transaction.getString("source")) ,"0")); } String timezone_client = client.getString("timezone"); if (timezone_client != null) { diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/SysClientIncrementalMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/SysClientIncrementalMapper.java deleted file mode 100644 index 4b1f2990d..000000000 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/SysClientIncrementalMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package au.com.royalpay.payment.manage.mappers.payment; - -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 org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; - -/** - * Created by liuxinxin on 2019-11-12. - */ -@AutoMapper(tablename = "sys_client_incremental", pkName = "incremental_id") -public interface SysClientIncrementalMapper { - - @Select("SELECT incremental_rate_value FROM sys_client_incremental WHERE channel = #{channel} AND client_id = #{client_id} ") - String findByChannelAndClientId(@Param("client_id") String clientId,@Param("channel") String channel); - - @AutoSql(type = SqlType.SELECT) - List find(@Param("client_id") String clientId); - - -} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java index c66c1003a..1e70b0185 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientIncrementalMapper.java @@ -1,13 +1,12 @@ package au.com.royalpay.payment.manage.mappers.system; -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 org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator; -import org.springframework.beans.factory.annotation.Autowired; import java.util.List; @@ -34,4 +33,14 @@ public interface ClientIncrementalMapper { @AutoSql(type = SqlType.UPDATE) void update(JSONObject saveIncrementalService); + + @Select("SELECT incremental_rate_value FROM sys_client_incremental WHERE channel = #{channel} AND client_id = #{client_id} ") + String findByChannelAndClientId(@Param("client_id") int clientId,@Param("channel") String channel); + + @AutoSql(type = SqlType.SELECT) + List find(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.SELECT) + JSONObject findBySourceCodeAndClientId(@Param("client_id") int clientId, @Param("source_code") String sourceCode); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.java new file mode 100644 index 000000000..b7f205a11 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.java @@ -0,0 +1,32 @@ +package au.com.royalpay.payment.manage.mappers.system; + +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 com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.ibatis.annotations.Param; + +/** + * Created by yishuqian on 06/03/2017. + */ +@AutoMapper(tablename = "sys_client_services_apply", pkName = "apply_id") +public interface ClientServicesApplyMapper { + @AutoSql(type = SqlType.INSERT) + void save(JSONObject partner); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject partner); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 1") + JSONObject findApplyByApplyId(@Param("apply_id") String applyId); + + @AutoSql(type = SqlType.SELECT) + JSONObject findApplyByClientId(@Param("client_id") int clientId); + + PageList listServicesApply(JSONObject params, PageBounds pageBounds); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/rservices/bean/RServicesApplyQuery.java b/src/main/java/au/com/royalpay/payment/manage/rservices/bean/RServicesApplyQuery.java new file mode 100644 index 000000000..c53647952 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/rservices/bean/RServicesApplyQuery.java @@ -0,0 +1,70 @@ +package au.com.royalpay.payment.manage.rservices.bean; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + + +/** + * Created by yixian on 2016-07-01. + */ +public class RServicesApplyQuery { + private int limit = 10; + private int page = 1; + private String clientMoniker; + private String serviceName; + private String status; + + public JSONObject toJson(){ + JSONObject json = new JSONObject(); + if(StringUtils.isNotEmpty(clientMoniker)){ + json.put("client_moniker",clientMoniker); + } + if(StringUtils.isNotEmpty(serviceName)){ + json.put("service_name",serviceName); + } + if(StringUtils.isNotEmpty(status)){ + json.put("status",status); + } + return json; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getClientMoniker() { + return clientMoniker; + } + + public void setClientMoniker(String clientMoniker) { + this.clientMoniker = clientMoniker; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/rservices/core/RServicesApplyService.java b/src/main/java/au/com/royalpay/payment/manage/rservices/core/RServicesApplyService.java new file mode 100644 index 000000000..15418afcf --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/rservices/core/RServicesApplyService.java @@ -0,0 +1,13 @@ +package au.com.royalpay.payment.manage.rservices.core; + +import au.com.royalpay.payment.manage.rservices.bean.RServicesApplyQuery; +import com.alibaba.fastjson.JSONObject; + +public interface RServicesApplyService { + + JSONObject getServicesApply(RServicesApplyQuery applyQuery); + + void passServicesApply(String applyId, JSONObject manager); + + void refuseServicesApply(String applyId, JSONObject manager); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/rservices/core/impl/RServicesApplyServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/rservices/core/impl/RServicesApplyServiceImpl.java new file mode 100644 index 000000000..ae5c52abd --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/rservices/core/impl/RServicesApplyServiceImpl.java @@ -0,0 +1,207 @@ +package au.com.royalpay.payment.manage.rservices.core.impl; + +import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.manage.appclient.core.RetailAppService; +import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientIncrementalMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.manage.notice.core.MailService; +import au.com.royalpay.payment.manage.rservices.bean.RServicesApplyQuery; +import au.com.royalpay.payment.manage.rservices.core.RServicesApplyService; +import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; +import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; +import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.ServerErrorException; +import au.com.royalpay.payment.tools.lock.Locker; +import au.com.royalpay.payment.tools.mappers.CommonIncrementalChannelMapper; +import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor; +import au.com.royalpay.payment.tools.utils.PageListUtils; +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 org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.thymeleaf.context.Context; +import org.thymeleaf.spring5.SpringTemplateEngine; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.UUID; + +@Service +public class RServicesApplyServiceImpl implements RServicesApplyService { + private Logger logger = LoggerFactory.getLogger(getClass()); + @Resource + private MpWechatApiProvider mpWechatApiProvider; + @Resource + private ClientAccountMapper clientAccountMapper; + @Resource + private ClientManager clientManager; + @Resource + private ClientServicesApplyMapper clientServicesApplyMapper; + @Resource + private TransactionService transactionService; + @Resource + private RetailAppService retailAppService; + @Resource + private Locker locker; + @Resource + private RoyalThreadPoolExecutor royalThreadPoolExecutor; + @Resource + private SpringTemplateEngine thymeleaf; + @Resource + private CommonIncrementalChannelMapper commonIncrementalChannelMapper; + @Resource + private MailService mailService; + @Resource + private ClientIncrementalMapper clientIncrementalMapper; + + @Override + public JSONObject getServicesApply(RServicesApplyQuery applyQuery) { + JSONObject params = applyQuery.toJson(); + PageList apply = clientServicesApplyMapper.listServicesApply(params, new PageBounds(applyQuery.getPage(), applyQuery.getLimit(), Order.formString("create_time.desc"))); + return PageListUtils.buildPageListResult(apply); + } + + @Override + public void passServicesApply(String applyId, JSONObject manager) { + JSONObject applyInfo = clientServicesApplyMapper.findApplyByApplyId(applyId); + if (applyInfo == null) { + throw new BadRequestException("签约服务申请不存在"); + } + String lockKey = applyInfo.getIntValue("client_id") + "_processing_RServices_" + applyInfo.getString("service_code"); + if (!locker.lock(lockKey, 120_000)) { + throw new ServerErrorException("Processing task, wait for a moment"); + } + try { + applyInfo.put("operator", manager.getString("manager_id")); + applyInfo.put("operator_time", new Date()); + applyInfo.put("status", 1); + clientServicesApplyMapper.update(applyInfo); + JSONObject clientServices = clientIncrementalMapper.findBySourceCodeAndClientId(applyInfo.getIntValue("client_id"), applyInfo.getString("service_code")); + JSONObject increment = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(applyInfo.getString("service_code")); + if (clientServices == null) { + clientServices = new JSONObject(); + clientServices.put("incremental_id", UUID.randomUUID().toString()); + clientServices.put("client_id", applyInfo.getIntValue("client_id")); + clientServices.put("channel", increment.getIntValue("channel")); + clientServices.put("incremental_mode", 2); + clientServices.put("incremental_rate_value", 0); + clientServices.put("total_incremental_amount", applyInfo.getBigDecimal("amount")); + clientServices.put("create_time", applyInfo.getDate("create_time")); + clientServices.put("update_time", applyInfo.getDate("operator_time")); + clientServices.put("operator", applyInfo.getString("operator")); + clientServices.put("is_valid", 1); + clientIncrementalMapper.save(clientServices); + }else { + clientServices.put("incremental_mode", 2); + clientServices.put("incremental_rate_value", 0); + clientServices.put("total_incremental_amount", applyInfo.getBigDecimal("amount")); + clientServices.put("create_time", applyInfo.getDate("create_time")); + clientServices.put("update_time", applyInfo.getDate("operator_time")); + clientServices.put("operator", applyInfo.getString("operator")); + clientServices.put("is_valid", 1); + clientIncrementalMapper.update(clientServices); + } + afterPassProcessingApply(applyInfo); + } finally { + locker.unlock(lockKey); + } + } + + @Override + public void refuseServicesApply(String applyId, JSONObject manager) { + JSONObject applyInfo = clientServicesApplyMapper.findApplyByApplyId(applyId); + if (applyInfo == null) { + throw new BadRequestException("签约服务申请不存在"); + } + applyInfo.put("operator", manager.getString("manager_id")); + applyInfo.put("operator_time", new Date()); + applyInfo.put("status", 2); + clientServicesApplyMapper.update(applyInfo); + } + + private void afterPassProcessingApply(JSONObject applyInfo) { + JSONObject client = clientManager.getClientInfo(applyInfo.getIntValue("client_id")); + String orderId = "R-" + client.getString("client_moniker") + "-" + applyInfo.getString("service_code") + "-" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS") + "-" + RandomStringUtils.random(3, true, false).toUpperCase(); + JSONObject transaction = new JSONObject(); + transaction.put("org_id", client.getIntValue("org_id")); + transaction.put("system_transaction_id", orderId); + transaction.put("order_id", orderId); + transaction.put("client_id", applyInfo.getIntValue("client_id")); + transaction.put("transaction_currency", PlatformEnvironment.getEnv().getForeignCurrency()); + transaction.put("transaction_amount", applyInfo.getBigDecimal("amount")); + transaction.put("clearing_currency", PlatformEnvironment.getEnv().getForeignCurrency()); + transaction.put("clearing_amount", applyInfo.getBigDecimal("amount")); + transaction.put("exchange_rate", 1); + transaction.put("channel", "System"); + transaction.put("transaction_type", "Debit"); + transaction.put("transaction_time", new Date()); + transaction.put("clearing_status", 0); + transaction.put("remark", applyInfo.getString("service_code") + ":" + applyInfo.getString("title")); + transaction.put("system_generate", 1); + transactionService.saveTransaction(transaction); + sendNotify(applyInfo, client); + } + + private void sendNotify(JSONObject applyInfo, JSONObject client) { + try { + retailAppService.sendRServicesApplyMessage(applyInfo, client); + } catch (Exception e) { + logger.error("R-services-{}付费成功app推送发送失败 - {}",client.getIntValue("client_id"), e); + } + JSONObject increment = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(applyInfo.getString("service_code")); + JSONObject account = clientAccountMapper.findByUsernameForDuplicate(applyInfo.getString("apply_username")); + if (increment == null || account == null) { + return; + } + if (StringUtils.isNotBlank(account.getString("contact_email"))) { + Context ctx = new Context(); + ctx.setVariable("img_url", PlatformEnvironment.getEnv().concatUrl("/static/images/royalpay_logo.png")); + ctx.setVariable("name", account.getString("display_name")); + ctx.setVariable("service_name", increment.getString("channel")); + ctx.setVariable("title", applyInfo.getString("title")); + ctx.setVariable("currency", "AUD"); + ctx.setVariable("amount", applyInfo.getBigDecimal("amount").toPlainString()); + ctx.setVariable("create_time", DateFormatUtils.format(applyInfo.getDate("create_time"),"yyyy-MM-dd HH:mm:ss")); + final String content = thymeleaf.process("mail/rservices_email_notice", ctx); + royalThreadPoolExecutor.execute(() -> { + try { + mailService.sendEmail("[RoyalPay]" + increment.getString("channel") + "付费成功通知", account.getString("contact_email"), "", content); + } catch (Exception e) { + logger.error("R-services-{}付费成功邮件发送失败 - {}",client.getIntValue("client_id"),account.getString("contact_email"), e); + } + }); + } + if (StringUtils.isNotBlank(account.getString("wechat_openid"))) { + try { + MpWechatApi mpWechatApi = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid")); + if (mpWechatApi == null) { + return; + } + String templateId = mpWechatApi.getTemplateId("payment-success-cashier"); + if (templateId == null) { + return; + } + TemplateMessage message = new TemplateMessage(account.getString("wechat_openid"), templateId, null); + message.put("first", "[RoyalPay]" + increment.getString("channel") + "付费成功通知", "#ff0000"); + message.put("keyword1", applyInfo.getString("title"), "#0000ff"); + message.put("keyword2", "支付金额: $" + applyInfo.getString("amount"), "#000000"); + message.put("keyword3", "签约时间" + DateFormatUtils.format(applyInfo.getDate("create_time"),"yyyy-MM-dd HH:mm:ss"), "#000000"); + message.put("keyword4", "申请人:" + account.getString("display_name"), "#000000"); + message.put("remark", "感谢您的使用,如有疑问或需帮助,请拨打我们的客服电话:1300 107 750或添加RoyalPay官方客服号:royalpay_1详询.", "#ff0000"); + mpWechatApi.sendTemplateMessage(message); + } catch (Exception e) { + logger.error("R-services-{}付费成功微信模版发送失败 - {}",client.getIntValue("client_id"),account.getString("wechat_openid"), e); + } + } + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/rservices/web/RServicesApplyController.java b/src/main/java/au/com/royalpay/payment/manage/rservices/web/RServicesApplyController.java new file mode 100644 index 000000000..f8a91879c --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/rservices/web/RServicesApplyController.java @@ -0,0 +1,36 @@ +package au.com.royalpay.payment.manage.rservices.web; + + +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.rservices.bean.RServicesApplyQuery; +import au.com.royalpay.payment.manage.rservices.core.RServicesApplyService; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping(value = "/sys/rservices") +public class RServicesApplyController { + @Resource + private RServicesApplyService rServicesApplyService; + + @ManagerMapping(value = "/apply", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF, ManagerRole.DIRECTOR}) + @GetMapping(value = "/apply") + public JSONObject getServicesApply(RServicesApplyQuery applyQuery) { + return rServicesApplyService.getServicesApply(applyQuery); + } + + @ManagerMapping(value = "/apply/{applyId}/pass", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR}) + public void passServicesApply(@PathVariable String applyId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + rServicesApplyService.passServicesApply(applyId, manager); + } + + @ManagerMapping(value = "/apply/{applyId}/refuse", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR}) + public void refuseServicesApply(@PathVariable String applyId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + rServicesApplyService.refuseServicesApply(applyId, manager); + } + +} 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 e09a749e1..760daebd6 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 @@ -109,7 +109,7 @@ public class TradeLogServiceImpl implements TradeLogService { @Resource private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper; @Resource - private SysClientIncrementalMapper sysClientIncrementalMapper; + private ClientIncrementalMapper clientIncrementalMapper; @Resource private ClientCustomersMapper clientCustomersMapper; @Resource @@ -251,7 +251,7 @@ public class TradeLogServiceImpl implements TradeLogService { } PageList logs = orderMapper.listIncrementalOrders(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); for (JSONObject log : logs) { - log.put("rate_value",sysClientIncrementalMapper.findByChannelAndClientId(log.getString("client_id"),log.getString("source"))); + log.put("rate_value",clientIncrementalMapper.findByChannelAndClientId(log.getIntValue("client_id"),log.getString("source"))); } JSONObject result = PageListUtils.buildPageListResult(logs); JSONObject analysis = orderMapper.analysisOrders(params); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.xml new file mode 100644 index 000000000..69fba1de3 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientServicesApplyMapper.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/src/main/resources/i18n/msg_en.properties b/src/main/resources/i18n/msg_en.properties index 976d5a28c..7aeb8480e 100644 --- a/src/main/resources/i18n/msg_en.properties +++ b/src/main/resources/i18n/msg_en.properties @@ -97,6 +97,7 @@ app.message.body.clean=Today's clearing has been completed,settlement count is app.message.title.daily_notice=Daily Transaction Report app.message.title.annual_bill=Royal Pay thanks for your company in 2018 app.message.body.annual_bill=Come and check your annual bill +app.message.rservices.body={0}has been successfully payment!,${0}.Thank you for your use. If you have any questions or issues related to this adjustment, please don’t hesitate to call 1300 107 750 or email info@royalpay.com.au. app.label.pay=Pay diff --git a/src/main/resources/i18n/msg_zh.properties b/src/main/resources/i18n/msg_zh.properties index ec1482ac6..d2e4ec130 100644 --- a/src/main/resources/i18n/msg_zh.properties +++ b/src/main/resources/i18n/msg_zh.properties @@ -93,6 +93,7 @@ app.message.body.clean=您今日的清算已完成,共 app.message.title.daily_notice=每日交易汇总提醒 app.message.title.annual_bill=2018年RoyalPay感谢有你 app.message.body.annual_bill=快来查收你的年度账单 +app.message.rservices.body={0}已付款成功!,${0}.感谢您的使用,如有疑问或需帮助,请拨打我们的客服电话:1300 107 750或添加RoyalPay官方客服号:royalpay_1详询. app.label.pay=支付 app.label.remark=备注 diff --git a/src/main/resources/templates/mail/rservices_email_notice.html b/src/main/resources/templates/mail/rservices_email_notice.html new file mode 100644 index 000000000..28597723d --- /dev/null +++ b/src/main/resources/templates/mail/rservices_email_notice.html @@ -0,0 +1,33 @@ + + + + + + +
+
+
+ +
+
+

您好,

+

您申请的已付费成功:

+
+

RoyalPay付费成功通知:

+
    +
  • 签约内容:<
  • +
  • 支付金额: 
  • +
  • 签约时间:
  • +
  • 申请人:
  • +
+
+ RoyalPay客服与技术支持在此期间将竭诚为您服务,如有疑问或需帮助,请拨打我们的客服电话:1300 107 750或添加RoyalPay官方客服号:royalpay_1详询。
+ 此致
+ RoyalPay +
+
+ +
+ + + diff --git a/src/main/ui/manage.html b/src/main/ui/manage.html index f698cc064..1bf1269be 100644 --- a/src/main/ui/manage.html +++ b/src/main/ui/manage.html @@ -482,6 +482,11 @@ margin-bottom: 10%;"/> 合规文件审核 +
  • + + R-Services签约付费申请 + +
  • 合同签约情况 diff --git a/src/main/ui/static/boot/manager-bootv2.js b/src/main/ui/static/boot/manager-bootv2.js index 6d350f1d8..c592cbe37 100644 --- a/src/main/ui/static/boot/manager-bootv2.js +++ b/src/main/ui/static/boot/manager-bootv2.js @@ -87,4 +87,4 @@ require(['angular', 'jquery'], function (angular, $) { angular.bootstrap(document.body, moduleNames) }) } -}); \ No newline at end of file +}); diff --git a/src/main/ui/static/cashback/templates/partner_cashback_records.html b/src/main/ui/static/cashback/templates/partner_cashback_records.html index 0157c9dd2..28d8dcf9e 100644 --- a/src/main/ui/static/cashback/templates/partner_cashback_records.html +++ b/src/main/ui/static/cashback/templates/partner_cashback_records.html @@ -84,7 +84,7 @@ + uib-tooltip="RP跨境商城" ng-if="record.source=='RP跨境商城'"/> {{record.order_id}} @@ -122,4 +122,4 @@ - \ No newline at end of file + diff --git a/src/main/ui/static/incrementalService/templates/partner_incremental_service.html b/src/main/ui/static/incrementalService/templates/partner_incremental_service.html index e9fe85b1d..51148c7ee 100644 --- a/src/main/ui/static/incrementalService/templates/partner_incremental_service.html +++ b/src/main/ui/static/incrementalService/templates/partner_incremental_service.html @@ -118,7 +118,7 @@ -
    +
    @@ -158,4 +158,4 @@
    -
    \ No newline at end of file + diff --git a/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html b/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html index e441d0ec1..ef679aa65 100644 --- a/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html +++ b/src/main/ui/static/incrementalService/templates/partner_incremental_service_info.html @@ -139,8 +139,8 @@ ng-click="params.source='ALL';loadTradeLogs(1)">All
    | System | - R跨境商城 + RP跨境商城

    --> @@ -368,7 +368,7 @@ - + BestPay diff --git a/src/main/ui/static/invoice/templates/invoice_assistant.html b/src/main/ui/static/invoice/templates/invoice_assistant.html index db2d8efe6..1ffab462b 100644 --- a/src/main/ui/static/invoice/templates/invoice_assistant.html +++ b/src/main/ui/static/invoice/templates/invoice_assistant.html @@ -197,7 +197,7 @@ + uib-tooltip="RP跨境商城" ng-if="trade.source=='RP跨境商城'"/> +
    diff --git a/src/main/ui/static/payment/tradelog/templates/balance_report.html b/src/main/ui/static/payment/tradelog/templates/balance_report.html index 535443102..b10512781 100644 --- a/src/main/ui/static/payment/tradelog/templates/balance_report.html +++ b/src/main/ui/static/payment/tradelog/templates/balance_report.html @@ -325,7 +325,7 @@ + uib-tooltip="RP跨境商城" ng-if="trade.source=='RP跨境商城'"/> Input Amount System Rate System Profit - R跨境商城 Rate - R跨境商城 Profit + RP跨境商城 Rate + RP跨境商城 Profit Status Create Time Operation @@ -366,7 +366,7 @@ + uib-tooltip="RP跨境商城" ng-if="trade.source=='RP跨境商城'"/> All | System | - R跨境商城 + RP跨境商城

    --> @@ -330,7 +330,7 @@ - + BestPay diff --git a/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html b/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html index cf039c65d..af3dcc95c 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_settlement_dialog.html @@ -177,7 +177,7 @@ - + {{tr.order_id}} diff --git a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html index aec8049bd..3e66ada1a 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html @@ -117,8 +117,8 @@ ng-click="params.source='ALL';loadTradeLogs(1)">All | System | - R跨境商城 + RP跨境商城

    @@ -431,7 +431,7 @@ - + BestPay diff --git a/src/main/ui/static/payment/tradelog/templates/trade_logs.html b/src/main/ui/static/payment/tradelog/templates/trade_logs.html index f9c13b131..e22dea465 100644 --- a/src/main/ui/static/payment/tradelog/templates/trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/trade_logs.html @@ -150,8 +150,8 @@ ng-click="params.source='ALL';loadTradeLogs(1)">All | System | - R跨境商城 + RP跨境商城

    @@ -465,7 +465,7 @@ + uib-tooltip="RP跨境商城" ng-if="trade.source=='RP跨境商城'"/> ' + '
    手续费组成
    '+'
    '+ '

    system:'+ system_surcharge +'

    ' + - '

    R跨境商城:'+ incremental_surcharge +'

    ' + + '

    RP跨境商城:'+ incremental_surcharge +'

    ' + '

    tax amount:'+ tax_amount +'

    ' + ''); } @@ -326,7 +326,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { app.controller('IncrementalTradeLogCtrl', ['$scope', '$http', '$filter', '$timeout', 'partnerRefunder', 'orderService', 'commonDialog', function ($scope, $http, $filter, $timeout, partnerRefunder, orderService, commonDialog) { - $scope.params = {source: 'R跨境商城',status: 'PAID', channel :'ALL' ,textType: 'all', datefrom: new Date(), dateto: new Date()}; + $scope.params = {source: 'RP跨境商城',status: 'PAID', channel :'ALL' ,textType: 'all', datefrom: new Date(), dateto: new Date()}; $scope.pagination = {}; $scope.today = new Date(); $scope.isAll = true; diff --git a/src/main/ui/static/rservicesapply/r-services-apply.js b/src/main/ui/static/rservicesapply/r-services-apply.js new file mode 100644 index 000000000..ecd54e797 --- /dev/null +++ b/src/main/ui/static/rservicesapply/r-services-apply.js @@ -0,0 +1,81 @@ +/** + * Created by kira on 01/06/2017. + */ +define(['angular'], function (angular) { + 'use strict'; + var app = angular.module('RServicesApplyApp', ['ui.router']); + app.config(['$stateProvider', function ($stateProvider) { + $stateProvider.state('r_services_apply', { + url: '/r_services_apply', + templateUrl: '/static/rservicesapply/templates/r-services-apply.html', + controller: 'RServicesApplyCtrl' + }); + }]); + app.controller('RServicesApplyCtrl', ['$scope', '$http', 'commonDialog', '$sce', '$state', + function ($scope, $http, commonDialog, $sce, $state) { + $scope.pagination = {}; + $scope.params = {}; + $scope.loadServicesApply = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/rservices/apply', {params: params}).then(function (resp) { + $scope.apply = resp.data; + $scope.pagination = resp.data.pagination; + }); + }; + $scope.loadServicesApply(1); + $scope.statusSelected = function (arr) { + return $scope.params.status != null && $scope.params.status.filter(function (status) { + return arr.indexOf(status) >= 0 + }).length > 0 + }; + $scope.serviceTypeSelected = function (arr) { + return $scope.params.serviceName != null && $scope.params.serviceName.filter(function (status) { + return arr.indexOf(status) >= 0 + }).length > 0 + }; + $scope.passApply = function (apply) { + var contentHtml = $sce.trustAsHtml( + '[' + apply.client_moniker + ']即将签约[' + + '' + apply.channel + ']服务
    服务内容:[' + + '' + apply.title + ']
    需要扣款[' + + 'AUD ' + apply.amount + ']
    申请人[' + + ' ' + apply.apply_username + ']' + + '
    请确认扣款信息是否正确' + ); + commonDialog.confirm({ + title: '请确认扣款信息', + contentHtml: contentHtml + }).then(function () { + $http.put('/sys/rservices/apply/'+ apply.apply_id +'/pass').then(function () { + commonDialog.alert({type: 'success', title: 'Success', content: '扣款成功!'}); + $state.reload(); + }, function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}); + }) + }) + }; + $scope.refuseApply = function (apply) { + var contentHtml = $sce.trustAsHtml( + '[' + apply.client_moniker + ']签约[' + + '' + apply.channel + ']服务服务内容:[' + + '' + apply.title + ']需要扣款[' + + 'AUD ' + apply.amount + ']申请人[' + + ' ' + apply.apply_username + ']' + + '
    请确认是否拒绝申请' + ); + commonDialog.confirm({ + title: '拒绝R-Services扣款申请', + contentHtml: contentHtml + }).then(function () { + $http.put('/sys/rservices/apply/'+ apply.apply_id +'/refuse').then(function () { + commonDialog.alert({type: 'success', title: 'Success', content: '拒绝成功!'}); + $state.reload(); + }, function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}); + }) + }) + }; + }]); + return app; +}); diff --git a/src/main/ui/static/rservicesapply/templates/r-services-apply.html b/src/main/ui/static/rservicesapply/templates/r-services-apply.html new file mode 100644 index 000000000..624689fe4 --- /dev/null +++ b/src/main/ui/static/rservicesapply/templates/r-services-apply.html @@ -0,0 +1,145 @@ +
    +

    R-Services服务扣费申请

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

    + All | + + 待审核| + 通过| + 打回 +

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