@ -0,0 +1,6 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY openapi/* /usr/share/nginx/html/
|
||||||
|
COPY default.conf /etc/nginx/conf.d/
|
||||||
|
|
||||||
|
EXPOSE 80
|
@ -0,0 +1,13 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _ default;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html/;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location =/ {
|
||||||
|
rewrite / /cn/ redirect;
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>RoyalPay Document</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
ReDoc doesn't change outer page styles
|
||||||
|
-->
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<redoc spec-url='document.yml' expand-responses="200" hide-download-button></redoc>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,420 @@
|
|||||||
|
|
||||||
|
orderBasic:
|
||||||
|
required:
|
||||||
|
- description
|
||||||
|
- currency
|
||||||
|
- price
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
maxLength: 128
|
||||||
|
description: Order title(Max 128 characters. Will cut automatically if too long.)
|
||||||
|
price:
|
||||||
|
type: integer
|
||||||
|
description: Order price. Minimal unit of currency. eg, 100 for AUD 1.00
|
||||||
|
currency:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- AUD
|
||||||
|
- CNY
|
||||||
|
notify_url:
|
||||||
|
type: string
|
||||||
|
description: payment notification url. for details please visit notify api. will not post notifications if leave it null. Recommended to call order query api to confirm order status when received notification.
|
||||||
|
operator:
|
||||||
|
type: string
|
||||||
|
description: mark of operator
|
||||||
|
orderWithChannel:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/orderBasic'
|
||||||
|
- properties:
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
description: order channel. case sensitive
|
||||||
|
enum:
|
||||||
|
- Alipay
|
||||||
|
- Wechat
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- channel
|
||||||
|
cardCustomerParam:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: customer name. will use card holder name if leave it empty
|
||||||
|
postcode:
|
||||||
|
type: string
|
||||||
|
example: 2000
|
||||||
|
address:
|
||||||
|
type: string
|
||||||
|
city:
|
||||||
|
type: string
|
||||||
|
example: Sydney
|
||||||
|
state:
|
||||||
|
type: string
|
||||||
|
example: VIC
|
||||||
|
country:
|
||||||
|
type: string
|
||||||
|
description: 2-character country code
|
||||||
|
example: AU
|
||||||
|
|
||||||
|
cardCustomerInfo:
|
||||||
|
type: object
|
||||||
|
title: Card customer info
|
||||||
|
properties:
|
||||||
|
bank:
|
||||||
|
type: string
|
||||||
|
description: bank name who issued the card. may be empty
|
||||||
|
card_type:
|
||||||
|
type: string
|
||||||
|
description: card type
|
||||||
|
example: credit/debit
|
||||||
|
card_alias:
|
||||||
|
type: string
|
||||||
|
description: part of card number. for customers to recognize which card they used
|
||||||
|
example: 424242...242
|
||||||
|
card_scheme:
|
||||||
|
description: card scheme who issued the card
|
||||||
|
type: string
|
||||||
|
example: VISA/MASTER
|
||||||
|
card_country:
|
||||||
|
description: nation code who issued the card
|
||||||
|
type: string
|
||||||
|
example: AU
|
||||||
|
customer_id:
|
||||||
|
type: string
|
||||||
|
description: customer id. if you provided customer_id param or passed tokenize=true param. it will appear
|
||||||
|
orderBasicResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
return_code:
|
||||||
|
type: string
|
||||||
|
description: execute result
|
||||||
|
result_code:
|
||||||
|
type: string
|
||||||
|
description: SUCCESS/EXISTS all means success. EXISTS means the order_id was not first time to commit
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
description: payment channel
|
||||||
|
partner_code:
|
||||||
|
type: string
|
||||||
|
description: merchant code
|
||||||
|
full_name:
|
||||||
|
type: string
|
||||||
|
description: merchant full name
|
||||||
|
partner_name:
|
||||||
|
type: string
|
||||||
|
description: merchant name
|
||||||
|
order_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay order ID, Will be channel order ID same time.
|
||||||
|
partner_order_id:
|
||||||
|
type: string
|
||||||
|
description: order id applied by merchant
|
||||||
|
orderStatus:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
return_code:
|
||||||
|
type: string
|
||||||
|
description: execute result
|
||||||
|
example:
|
||||||
|
SUCCESS
|
||||||
|
result_code:
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
order status code
|
||||||
|
- PAYING: waiting for payment
|
||||||
|
- CREATE_FAIL: creation failed(final status, can be actived again if submitted another create order with same order id)
|
||||||
|
- CLOSED: order closed(final status, can be actived again if submitted another create order with same order id)
|
||||||
|
- PAY_FAIL: payment failed(final status, can be actived again if submitted another create order with same order id)
|
||||||
|
- PAY_SUCCESS: payment success(final status)
|
||||||
|
- PARTIAL_REFUND: payment success and partial refunds happened(final status)
|
||||||
|
- FULL_REFUND: payment success and was full refunded(final status)
|
||||||
|
If necessary. you can use same order id to call create order api in same gateway. but when origin order is paid or paying status will be failure
|
||||||
|
enum:
|
||||||
|
- PAYING
|
||||||
|
- CREATE_FAIL
|
||||||
|
- CLOSED
|
||||||
|
- PAY_FAIL
|
||||||
|
- PAY_SUCCESS
|
||||||
|
- PARTIAL_REFUND
|
||||||
|
- FULL_REFUND
|
||||||
|
order_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay order ID, Will be channel order ID same time.
|
||||||
|
partner_order_id:
|
||||||
|
type: string
|
||||||
|
description: order id applied by merchant
|
||||||
|
channel_order_id:
|
||||||
|
type: string
|
||||||
|
description: transaction id from payment channel
|
||||||
|
total_fee:
|
||||||
|
type: integer
|
||||||
|
description: order amount. minimal unit of the currency.
|
||||||
|
real_fee:
|
||||||
|
type: integer
|
||||||
|
description: customer actual paid amount. minimal unit of the currency.(equals to total_fee at this moment. in case there were some discounts in the future)
|
||||||
|
currency:
|
||||||
|
type: string
|
||||||
|
rate:
|
||||||
|
type: number
|
||||||
|
description: exchange rate of trading. 1AUD=?CNY
|
||||||
|
pay_time:
|
||||||
|
type: string
|
||||||
|
format: 'date-time'
|
||||||
|
pattern: yyyy-mm-dd HH:mm:ss
|
||||||
|
description: paid time(yyyy-MM-dd HH:mm:ss, GMT+10)
|
||||||
|
create_time:
|
||||||
|
type: string
|
||||||
|
format: 'date-time'
|
||||||
|
pattern: yyyy-mm-dd HH:mm:ss
|
||||||
|
description: order creation time(yyyy-MM-dd HH:mm:ss, GMT+10)
|
||||||
|
settlement_date:
|
||||||
|
type: string
|
||||||
|
format: date
|
||||||
|
pattern: yyyy-mm-dd
|
||||||
|
description: target settlement date, maybe delay due to holidays and bank issues(yyyy-MM-dd)
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
description: payment channel
|
||||||
|
customer_info:
|
||||||
|
anyOf:
|
||||||
|
- description: Alipay User Info
|
||||||
|
title: Alipay Users
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
alipay_user_id:
|
||||||
|
type: string
|
||||||
|
description: Alipay user id
|
||||||
|
alipay_account:
|
||||||
|
type: string
|
||||||
|
description: user account
|
||||||
|
- $ref: 'components_order.yml#/cardCustomerInfo'
|
||||||
|
refundStatus:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
return_code:
|
||||||
|
type: string
|
||||||
|
description: Execute result
|
||||||
|
example:
|
||||||
|
SUCCESS
|
||||||
|
result_code:
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
Refund status
|
||||||
|
- WAITING: Submitting
|
||||||
|
- CREATE_FAILED: Submit failed
|
||||||
|
- SUCCESS: Submit success. waiting for bank processing(for Wechat, it's final status)
|
||||||
|
- FAILED: Refund failed
|
||||||
|
- FINISHED: Refund success (final status)
|
||||||
|
enum:
|
||||||
|
- WATING
|
||||||
|
- CREATE_FAILED
|
||||||
|
- SUCCESS
|
||||||
|
- FAILED
|
||||||
|
- FINISHED
|
||||||
|
refund_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay Refund ID
|
||||||
|
partner_refund_id:
|
||||||
|
type: string
|
||||||
|
description: Refund id submitted by merchant
|
||||||
|
amount:
|
||||||
|
type: integer
|
||||||
|
description: refund amount. minimal unit of the currency.
|
||||||
|
currency:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
AUD
|
||||||
|
settlement_date:
|
||||||
|
type: string
|
||||||
|
format: date
|
||||||
|
pattern: yyyy-mm-dd
|
||||||
|
description: target settlement date, maybe delay due to holidays and bank issues(yyyy-MM-dd). only exists when status is SUCCESS or FINISHED
|
||||||
|
transactionItem:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
transaction_time:
|
||||||
|
type: string
|
||||||
|
format: 'date-time'
|
||||||
|
pattern: yyyyMMddHHmmss
|
||||||
|
description: trading time, format is yyyyMMddHHmmss, GMT+10
|
||||||
|
partner_code:
|
||||||
|
type: string
|
||||||
|
description: transaction related partner code
|
||||||
|
order_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay order id
|
||||||
|
partner_order_id:
|
||||||
|
type: string
|
||||||
|
description: merchant order id
|
||||||
|
channel_order_id:
|
||||||
|
type: string
|
||||||
|
description: channel order id
|
||||||
|
refund_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay refund id (only exists on refund or refund failure payback transactions)
|
||||||
|
partner_refund_id:
|
||||||
|
type: string
|
||||||
|
description: merchant submitted refund id (only exists on refund or refund failure payback transactions)
|
||||||
|
gateway:
|
||||||
|
type: integer
|
||||||
|
description: |
|
||||||
|
gateway
|
||||||
|
- 0: RoyalPay EftPOS with payment code (scanning payment code provided by customer)
|
||||||
|
- 1: RoyalPay EftPOS with collection code (customer scan qr code provided by EftPOS)
|
||||||
|
- 2: RoyalPay Merchant's static QR Code
|
||||||
|
- 3: QRCode Gateway
|
||||||
|
- 4: JSAPI Gateway
|
||||||
|
- 5: Third EftPOS payment code gateway
|
||||||
|
- 6: Third EftPOS collection code gateway
|
||||||
|
- 7: RoyalPay Merchant's static QR Code(deprecated)
|
||||||
|
- 8: H5 Gateway
|
||||||
|
- 9: WEB Gateway
|
||||||
|
- 10: SDK order Gateway
|
||||||
|
- 11: RoyalPay Bill QR Code
|
||||||
|
- 12: Mini Program Gateway
|
||||||
|
- 13: Native QR Code Gateway
|
||||||
|
- 14: RoyalPay Bill link
|
||||||
|
- 15: Native JSAPI Gateway
|
||||||
|
- 16: Card Order(Pre order mode)
|
||||||
|
- 17: Card Order
|
||||||
|
- 18: DirectDebit
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
description: Trading channel
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
description: Transaction type
|
||||||
|
enum:
|
||||||
|
- Credit
|
||||||
|
- Debit
|
||||||
|
currency:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
AUD
|
||||||
|
total_amount:
|
||||||
|
type: integer
|
||||||
|
description: Total amount for order. minimal unit of the currency.
|
||||||
|
input_amount:
|
||||||
|
type: integer
|
||||||
|
description: Input amount for order. minimal unit of the currency.
|
||||||
|
customer_payment_amount:
|
||||||
|
type: integer
|
||||||
|
description: Customer actual paid amount. minimal unit of the currency.
|
||||||
|
settle_amount:
|
||||||
|
type: integer
|
||||||
|
description: Amount calculated to merchant. note that it did not sub surcharge and GST yet. AUD currency. minimal unit of the currency.
|
||||||
|
transfer_amount:
|
||||||
|
type: integer
|
||||||
|
description: Pay amount to merchant. settle_amount - surcharge - GST. AUD currency. minimal unit of the currency.
|
||||||
|
surcharge:
|
||||||
|
type: integer
|
||||||
|
description: surcharge for this transaction. AUD currency. minimal unit of the currency.
|
||||||
|
gst:
|
||||||
|
type: integer
|
||||||
|
description: GST. AUD currency. minimal unit of the currency.
|
||||||
|
exchange_rate:
|
||||||
|
type: number
|
||||||
|
description: used exchange rate.
|
||||||
|
remark:
|
||||||
|
type: string
|
||||||
|
description: transaction remark
|
||||||
|
customInfo:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
report_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay customs report id
|
||||||
|
client_report_id:
|
||||||
|
type: string
|
||||||
|
description: merchant submitted customs report id
|
||||||
|
report_status:
|
||||||
|
type: string
|
||||||
|
description: report status
|
||||||
|
enum:
|
||||||
|
- PROCESSING
|
||||||
|
- SUBMITED
|
||||||
|
- FAILED
|
||||||
|
- SUCCESS
|
||||||
|
channel:
|
||||||
|
type: string
|
||||||
|
description: payment channel
|
||||||
|
custom:
|
||||||
|
type: string
|
||||||
|
description: customs code
|
||||||
|
mch_custom_no:
|
||||||
|
type: string
|
||||||
|
description: merchant's customs no registered in customs system
|
||||||
|
mch_custom_name:
|
||||||
|
type: string
|
||||||
|
description: merchant's name registered in customs system
|
||||||
|
order_id:
|
||||||
|
type: string
|
||||||
|
description: RoyalPay order id
|
||||||
|
transaction_id:
|
||||||
|
type: string
|
||||||
|
description: channel transaction id
|
||||||
|
order_currency:
|
||||||
|
type: string
|
||||||
|
description: order currency
|
||||||
|
order_amount:
|
||||||
|
type: number
|
||||||
|
description: order amount
|
||||||
|
report_time:
|
||||||
|
type: string
|
||||||
|
format: 'date-time'
|
||||||
|
description: report customs time
|
||||||
|
creation_date:
|
||||||
|
format: 'date-time'
|
||||||
|
type: string
|
||||||
|
description: report create time
|
||||||
|
last_update_date:
|
||||||
|
type: string
|
||||||
|
format: 'date-time'
|
||||||
|
description: update time
|
||||||
|
error_code:
|
||||||
|
type: string
|
||||||
|
description: error code
|
||||||
|
error_msg:
|
||||||
|
type: string
|
||||||
|
description: error message
|
||||||
|
verify_department:
|
||||||
|
type: string
|
||||||
|
verify_department_trade_id:
|
||||||
|
type: string
|
||||||
|
sub_orders:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
sub_order_no:
|
||||||
|
type: string
|
||||||
|
description: merchant's sub order no
|
||||||
|
fee_type:
|
||||||
|
type: string
|
||||||
|
description: currency code
|
||||||
|
default: CNY
|
||||||
|
enum:
|
||||||
|
- CNY
|
||||||
|
order_fee:
|
||||||
|
type: number
|
||||||
|
description: sub order fee
|
||||||
|
transport_fee:
|
||||||
|
type: number
|
||||||
|
description: sub order transport fee
|
||||||
|
verify_department:
|
||||||
|
type: string
|
||||||
|
verify_department_trade_id:
|
||||||
|
type: string
|
||||||
|
report_status:
|
||||||
|
type: string
|
||||||
|
description: report status
|
||||||
|
enum:
|
||||||
|
- PROCESSING
|
||||||
|
- SUBMITED
|
||||||
|
- FAILED
|
||||||
|
- SUCCESS
|
||||||
|
error_code:
|
||||||
|
type: string
|
||||||
|
error_msg:
|
||||||
|
type: string
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>RoyalPay Document</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
ReDoc doesn't change outer page styles
|
||||||
|
-->
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<redoc spec-url='document.yml' expand-responses="200" hide-download-button></redoc>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Before Width: | Height: | Size: 12 KiB |
@ -0,0 +1,28 @@
|
|||||||
|
package au.com.royalpay.payment.manage.appclient.beans;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author taylor.dang
|
||||||
|
* @date 2020-04-20 21:26
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class AppleLoginBean {
|
||||||
|
@JSONField(name = "identityToken")
|
||||||
|
@NotEmpty
|
||||||
|
private String identityToken;
|
||||||
|
@JSONField(name = "user")
|
||||||
|
@NotEmpty
|
||||||
|
private String user;
|
||||||
|
@JSONField(name = "devId")
|
||||||
|
@NotEmpty
|
||||||
|
private String devId;
|
||||||
|
@JSONField(name = "authorizationCode")
|
||||||
|
@NotEmpty
|
||||||
|
private String authorizationCode;
|
||||||
|
}
|
@ -1,61 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.apps.events.listeners;
|
|
||||||
|
|
||||||
import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent;
|
|
||||||
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
|
|
||||||
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by wangning on 17/01/2018.
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class AfterPaymentFinishListener implements ApplicationListener<AfterPaymentFinishEvent> {
|
|
||||||
@Resource
|
|
||||||
private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper;
|
|
||||||
@Resource
|
|
||||||
private CustomerPaymentInfoService customerPaymentInfoService;
|
|
||||||
@Resource
|
|
||||||
private ClientManager clientManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onApplicationEvent(AfterPaymentFinishEvent event) {
|
|
||||||
JSONObject order = event.getFinishedEvent().getOrder();
|
|
||||||
if(!"hf".equals(order.getString("channel"))&&!"Yeepay".equals(order.getString("channel"))){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (order.getString("channel")){
|
|
||||||
case "hf":
|
|
||||||
if(StringUtils.isEmpty(order.getString("ext_params"))){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JSONObject extParam = JSONObject.parseObject(order.getString("ext_params"));
|
|
||||||
JSONObject orderInfo = sysCustomerPaymentInfoMapper.selectPaymentInfo(order.getString("customer_id"));
|
|
||||||
if (orderInfo != null) {
|
|
||||||
orderInfo.put("idcard_name", extParam.getString("payer_name"));
|
|
||||||
orderInfo.put("idcard_no", extParam.getString("payer_identity_card"));
|
|
||||||
orderInfo.put("bankcard", extParam.getString("card_number"));
|
|
||||||
orderInfo.put("bank", extParam.getString("bankId"));
|
|
||||||
sysCustomerPaymentInfoMapper.update(orderInfo);
|
|
||||||
}else {
|
|
||||||
JSONObject lastOrderInfo = new JSONObject();
|
|
||||||
lastOrderInfo.put("wechat_openid", order.getString("customer_id"));
|
|
||||||
lastOrderInfo.put("idcard_name", extParam.getString("payer_name"));
|
|
||||||
lastOrderInfo.put("idcard_no", extParam.getString("payer_identity_card"));
|
|
||||||
lastOrderInfo.put("bankcard", extParam.getString("card_number"));
|
|
||||||
lastOrderInfo.put("bank", extParam.getString("bankId"));
|
|
||||||
customerPaymentInfoService.save(lastOrderInfo);
|
|
||||||
}
|
|
||||||
clientManager.sendHfEmailNotice(order);
|
|
||||||
return;
|
|
||||||
case "Yeepay":
|
|
||||||
clientManager.sendGatewayEmailNotice(order);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.dev.core;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
public interface HfClearAmountService {
|
|
||||||
|
|
||||||
JSONObject hfjsonobject(String dateto,String datefrom);
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.dev.core;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
public interface HfUpdateService {
|
|
||||||
|
|
||||||
String updateStatus();
|
|
||||||
|
|
||||||
String rpayUpdate();
|
|
||||||
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.dev.core.impl;
|
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.dev.core.HfClearAmountService;
|
|
||||||
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
||||||
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
||||||
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class HfClearAmountServiceImpl implements HfClearAmountService {
|
|
||||||
@Resource
|
|
||||||
private TransactionMapper transactionMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JSONObject hfjsonobject(String dateto, String datefrom) {
|
|
||||||
JSONObject params = new JSONObject();
|
|
||||||
try {
|
|
||||||
params.put("datefrom", DateUtils.addMinutes(DateUtils.parseDate(datefrom, "yyyy-MM-dd"), PlatformEnvironment.getEnv().getTimeZoneOffsetMinutes()));
|
|
||||||
params.put("dateto", DateUtils.addMinutes(DateUtils.parseDate(dateto, "yyyy-MM-dd"), PlatformEnvironment.getEnv().getTimeZoneOffsetMinutes()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new ServerErrorException("时间转换异常");
|
|
||||||
}
|
|
||||||
List<JSONObject> hfClearAmountResult = transactionMapper.getHfClearAmount(params);
|
|
||||||
JSONObject result = new JSONObject();
|
|
||||||
result.put("payment_amount", BigDecimal.ZERO);
|
|
||||||
result.put("refund_amount", BigDecimal.ZERO);
|
|
||||||
result.put("gross_amount", BigDecimal.ZERO);
|
|
||||||
result.put("charge_amount", BigDecimal.ZERO);
|
|
||||||
result.put("clear_amount", BigDecimal.ZERO);
|
|
||||||
result.put("payment_surcharge", BigDecimal.ZERO);
|
|
||||||
result.put("refund_surcharge", BigDecimal.ZERO);
|
|
||||||
if (hfClearAmountResult.isEmpty()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
hfClearAmountResult.forEach(dbResult -> {
|
|
||||||
if ("Credit".equals(dbResult.getString("transaction_type"))) {
|
|
||||||
result.put("payment_amount", dbResult.getBigDecimal("clear_amount"));
|
|
||||||
result.put("payment_surcharge", dbResult.getBigDecimal("charge_amount"));
|
|
||||||
}
|
|
||||||
if ("Debit".equals(dbResult.getString("transaction_type"))) {
|
|
||||||
result.put("refund_amount", dbResult.getBigDecimal("clear_amount"));
|
|
||||||
result.put("refund_surcharge", dbResult.getBigDecimal("charge_amount"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
result.put("gross_amount", result.getBigDecimal("payment_amount").subtract(result.getBigDecimal("refund_amount")));
|
|
||||||
result.put("charge_amount", result.getBigDecimal("payment_surcharge").subtract(result.getBigDecimal("refund_surcharge")));
|
|
||||||
result.put("clear_amount", result.getBigDecimal("gross_amount").subtract(result.getBigDecimal("charge_amount")));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.dev.core.impl;
|
|
||||||
|
|
||||||
import au.com.royalpay.payment.channels.rpay.runtime.RpayApi;
|
|
||||||
import au.com.royalpay.payment.manage.dev.core.HfUpdateService;
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
||||||
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
||||||
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
||||||
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class HfUpdateImpl implements HfUpdateService {
|
|
||||||
@Resource
|
|
||||||
private ClientMapper clientMapper;
|
|
||||||
@Resource
|
|
||||||
private MpWechatApiProvider mpWechatApiProvider;
|
|
||||||
@Resource
|
|
||||||
private ClientConfigMapper clientConfigMapper;
|
|
||||||
@Resource
|
|
||||||
private RpayApi rpayApi;
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String updateStatus() {
|
|
||||||
List<JSONObject> clientIds = clientMapper.findByhfPayUrlNotNull();
|
|
||||||
clientIds.forEach(dbResult -> {
|
|
||||||
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + dbResult.getString("client_moniker") + "/jump/pc");
|
|
||||||
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
|
|
||||||
String url = api.registerShortUrl(longUrl);
|
|
||||||
dbResult.put("hf_pay_url", url);
|
|
||||||
JSONObject config = new JSONObject();
|
|
||||||
config.put("client_id",dbResult.getString("client_id"));
|
|
||||||
config.put("hf_pay_url", url);
|
|
||||||
clientConfigMapper.update(config);
|
|
||||||
clientMapper.update(dbResult);
|
|
||||||
|
|
||||||
});
|
|
||||||
return "ok";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String rpayUpdate() {
|
|
||||||
List<JSONObject> clientIds = clientMapper.findByrpayNotNull();
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
clientIds.forEach(dbResult -> {
|
|
||||||
try {
|
|
||||||
// rpayApi.modifySurchargeConfig(dbResult);
|
|
||||||
} catch (Exception e) {
|
|
||||||
sb.append("【" + dbResult.getString("client_moniker") + "】、");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
logger.info("test for update rpay clearing date,fail + " + sb.toString());
|
|
||||||
return "ok";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package au.com.royalpay.payment.manage.dev.web;
|
|
||||||
|
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.analysis.core.DashboardService;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "/dev/pine")
|
|
||||||
public class TestAPPController {
|
|
||||||
@Resource
|
|
||||||
private DashboardService dashboardService;
|
|
||||||
|
|
||||||
@GetMapping("/trade_log")
|
|
||||||
public List<JSONObject> getTradeLogs(HttpServletResponse response) {
|
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
response.addHeader("Access-Control-Allow-Credentials", "true");
|
|
||||||
response.addHeader("Access-Control-Allow-Headers", "Authorization,Origin, X-Requested-With, Content-Type, Accept");
|
|
||||||
response.addHeader("Access-Control-Allow-Methods", "*");
|
|
||||||
List<JSONObject> logs = new ArrayList<>();
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("channel", "Alipay");
|
|
||||||
json.put("order_id", "PINE-r67783ej392u38ry982");
|
|
||||||
json.put("status", "1");
|
|
||||||
json.put("amount","9.99");
|
|
||||||
logs.add(json);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("channel", "Wechat");
|
|
||||||
json.put("order_id", "PINE-r67783ej392u38ry982");
|
|
||||||
json.put("status", "2");
|
|
||||||
json.put("amount","9.99");
|
|
||||||
logs.add(json);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("channel", "Bestpay");
|
|
||||||
json.put("order_id", "PINE-r67783ej392u38ry982");
|
|
||||||
json.put("status", "3");
|
|
||||||
json.put("amount","9.99");
|
|
||||||
logs.add(json);
|
|
||||||
}
|
|
||||||
return logs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/customer",method = RequestMethod.GET)
|
|
||||||
public void generateCustomersAndOrdersStatistics(){
|
|
||||||
DateTime dt17 = new DateTime(2018,5,17,11,11);
|
|
||||||
DateTime dt18 = new DateTime(2018,5,18,11,11);
|
|
||||||
DateTime dt19 = new DateTime(2018,5,19,11,11);
|
|
||||||
dashboardService.generateCustomersAndOrdersStatistics(dt17.toDate());
|
|
||||||
dashboardService.generateCustomersAndOrdersStatistics(dt18.toDate());
|
|
||||||
dashboardService.generateCustomersAndOrdersStatistics(dt19.toDate());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,19 @@
|
|||||||
|
package au.com.royalpay.payment.manage.mappers.system;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
|
||||||
|
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
|
||||||
|
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@AutoMapper(tablename = "sys_client_upay_profile", pkName = "client_id")
|
||||||
|
public interface SysClientUpayProfileMapper {
|
||||||
|
@AutoSql(SqlType.INSERT)
|
||||||
|
void save(JSONObject info);
|
||||||
|
|
||||||
|
@AutoSql(SqlType.UPDATE)
|
||||||
|
void update(JSONObject info);
|
||||||
|
|
||||||
|
@AutoSql(SqlType.SELECT)
|
||||||
|
JSONObject findInfo(@Param("client_id") int clientId);
|
||||||
|
}
|
@ -1,19 +1,21 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.core;
|
package au.com.royalpay.payment.manage.merchants.core;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify;
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:24
|
* Create by yixian at 2018-04-12 16:24
|
||||||
*/
|
*/
|
||||||
public interface ClientModifySupport {
|
public interface ClientModifySupport {
|
||||||
|
|
||||||
|
void processModify(ClientModifyOperation modify);
|
||||||
|
|
||||||
void processClientModify(ClientModify clientModify);
|
void processClientModify(ClientModify clientModify);
|
||||||
|
|
||||||
void processClientConfigModify(ClientConfigModify clientConfigModify);
|
void processClientConfigModify(ClientModify clientConfigModify);
|
||||||
|
|
||||||
void processClientConfigModify(ClientConfigModify clientConfigModify, boolean onlyModifyConfig);
|
void processClientConfigModify(ClientModify clientConfigModify, boolean onlyModifyConfig);
|
||||||
|
|
||||||
void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify);
|
void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify);
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,39 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity;
|
package au.com.royalpay.payment.manage.merchants.entity;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper;
|
import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper;
|
||||||
import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog;
|
|
||||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
||||||
import au.com.royalpay.payment.tools.utils.id.IdUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:19
|
* Create by yixian at 2018-04-12 16:19
|
||||||
*/
|
*/
|
||||||
public abstract class ClientGatewaySignModify {
|
public abstract class ClientGatewaySignModify extends ClientModifyOperation {
|
||||||
|
|
||||||
private JSONObject account;
|
private MerchantSignInfoMapper merchantSignInfoMapper;
|
||||||
|
|
||||||
private String clientMoniker;
|
|
||||||
|
|
||||||
public ClientGatewaySignModify(JSONObject account, String clientMoniker) {
|
public ClientGatewaySignModify(JSONObject account, String clientMoniker) {
|
||||||
this.account = account;
|
super(account, clientMoniker);
|
||||||
this.clientMoniker = clientMoniker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String business();
|
protected abstract String business();
|
||||||
|
|
||||||
protected abstract JSONObject getModifyResult();
|
protected abstract JSONObject getModifyResult();
|
||||||
|
|
||||||
@Transactional
|
@Override
|
||||||
public int doModify(MerchantInfoProvider merchantInfoProvider, MerchantSignInfoMapper merchantSignInfoMapper, MongoTemplate mongoTemplate) {
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
return client -> {
|
||||||
JSONObject clientGatewaySign = merchantSignInfoMapper.findClientSign(clientMoniker);
|
|
||||||
JSONObject modifyResult = getModifyResult();
|
JSONObject modifyResult = getModifyResult();
|
||||||
try {
|
modifyResult.put("client_moniker", getClientMoniker());
|
||||||
saveModifyHistory(clientGatewaySign, modifyResult, mongoTemplate);
|
modifyResult.put("last_update_by", getAccount().getString("account_id"));
|
||||||
}catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
int clientId = client.getIntValue("client_id");
|
|
||||||
modifyResult.put("client_moniker", clientMoniker);
|
|
||||||
modifyResult.put("last_update_by", account.getString("account_id"));
|
|
||||||
modifyResult.put("last_update_date", new Date());
|
modifyResult.put("last_update_date", new Date());
|
||||||
merchantSignInfoMapper.update(modifyResult);
|
merchantSignInfoMapper.update(modifyResult);
|
||||||
return clientId;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveModifyHistory(JSONObject clientGatewaySign, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
public ClientGatewaySignModify setMerchantSignInfoMapper(MerchantSignInfoMapper merchantSignInfoMapper) {
|
||||||
if (account == null) {
|
this.merchantSignInfoMapper = merchantSignInfoMapper;
|
||||||
return;
|
return this;
|
||||||
}
|
|
||||||
ClientConfigLog clientConfigLog = new ClientConfigLog();
|
|
||||||
clientConfigLog.setId(IdUtil.getId());
|
|
||||||
clientConfigLog.setBusiness(business());
|
|
||||||
clientConfigLog.setClientId(clientGatewaySign.getIntValue("client_id"));
|
|
||||||
|
|
||||||
boolean isPartner = true;
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
|
|
||||||
isPartner = true;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
|
|
||||||
isPartner = false;
|
|
||||||
}
|
|
||||||
clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager");
|
|
||||||
clientConfigLog.setCreateTime(new Date());
|
|
||||||
clientConfigLog.setNewData(modifyResult.toJSONString());
|
|
||||||
clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id"));
|
|
||||||
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, clientGatewaySign::get));
|
|
||||||
clientConfigLog.setOriginData(JSON.toJSONString(beforeModify));
|
|
||||||
clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name"));
|
|
||||||
mongoTemplate.save(clientConfigLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,77 +1,32 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity;
|
package au.com.royalpay.payment.manage.merchants.entity;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
||||||
import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog;
|
|
||||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
||||||
import au.com.royalpay.payment.tools.utils.id.IdUtil;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import java.util.function.Consumer;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:19
|
* Create by yixian at 2018-04-12 16:19
|
||||||
*/
|
*/
|
||||||
public abstract class ClientModify {
|
public abstract class ClientModify extends ClientModifyOperation {
|
||||||
|
|
||||||
private JSONObject account;
|
|
||||||
|
|
||||||
private String clientMoniker;
|
private Consumer<JSONObject> modifyConsumer;
|
||||||
|
|
||||||
public ClientModify(JSONObject account, String clientMoniker) {
|
public ClientModify(JSONObject account, String clientMoniker) {
|
||||||
this.account = account;
|
super(account, clientMoniker);
|
||||||
this.clientMoniker = clientMoniker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String business();
|
@Override
|
||||||
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
protected abstract JSONObject getModifyResult();
|
return client -> {
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int doModify(MerchantInfoProvider merchantInfoProvider, ClientMapper clientMapper, MongoTemplate mongoTemplate) {
|
|
||||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
|
||||||
JSONObject modifyResult = getModifyResult();
|
JSONObject modifyResult = getModifyResult();
|
||||||
try {
|
|
||||||
saveModifyHistory(client, modifyResult, mongoTemplate);
|
|
||||||
}catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
int clientId = client.getIntValue("client_id");
|
int clientId = client.getIntValue("client_id");
|
||||||
modifyResult.put("client_id", clientId);
|
modifyResult.put("client_id", clientId);
|
||||||
clientMapper.update(modifyResult);
|
modifyConsumer.accept(modifyResult);
|
||||||
return clientId;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private void saveModifyHistory(JSONObject client, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
|
||||||
if (account == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
ClientConfigLog clientConfigLog = new ClientConfigLog();
|
|
||||||
clientConfigLog.setId(IdUtil.getId());
|
|
||||||
clientConfigLog.setBusiness(business());
|
|
||||||
clientConfigLog.setClientId(client.getIntValue("client_id"));
|
|
||||||
|
|
||||||
boolean isPartner = true;
|
public ClientModify setModifyConsumer(Consumer<JSONObject> modifyConsumer) {
|
||||||
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
|
this.modifyConsumer = modifyConsumer;
|
||||||
isPartner = true;
|
return this;
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
|
|
||||||
isPartner = false;
|
|
||||||
}
|
|
||||||
clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager");
|
|
||||||
clientConfigLog.setCreateTime(new Date());
|
|
||||||
clientConfigLog.setNewData(modifyResult.toJSONString());
|
|
||||||
clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id"));
|
|
||||||
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
|
|
||||||
clientConfigLog.setOriginData(JSON.toJSONString(beforeModify));
|
|
||||||
clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name"));
|
|
||||||
mongoTemplate.save(clientConfigLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:43
|
* Create by yixian at 2018-04-12 16:43
|
||||||
*/
|
*/
|
||||||
public class ClearDaysModify extends ClientConfigModify {
|
public class ClearDaysModify extends ClientModify {
|
||||||
private int settle_hour;
|
private int settleHour;
|
||||||
|
|
||||||
public ClearDaysModify(JSONObject account, String clientMoniker, int settle_hour) {
|
public ClearDaysModify(JSONObject account, String clientMoniker, int settleHour) {
|
||||||
super(account, clientMoniker);
|
super(account, clientMoniker);
|
||||||
this.settle_hour = settle_hour;
|
this.settleHour = settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String business() {
|
protected String business() {
|
||||||
|
|
||||||
return "修改商户清算截止时间为:"+settle_hour;
|
return "修改商户清算截止时间为:" + settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JSONObject getModifyResult() {
|
protected JSONObject getModifyResult() {
|
||||||
JSONObject modify = new JSONObject();
|
JSONObject modify = new JSONObject();
|
||||||
modify.put("settle_hour", settle_hour);
|
modify.put("settle_hour", settleHour);
|
||||||
return modify;
|
return modify;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2018-04-12 16:43
|
||||||
|
*/
|
||||||
|
public class CustomSwitchModify extends ClientModifyOperation {
|
||||||
|
private final String key;
|
||||||
|
private final boolean value;
|
||||||
|
private final Consumer<JSONObject> modifyProcess;
|
||||||
|
|
||||||
|
|
||||||
|
public CustomSwitchModify(JSONObject account, String clientMoniker, String key, boolean value, Consumer<JSONObject> modifyProcess) {
|
||||||
|
super(account, clientMoniker);
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
this.modifyProcess = modifyProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String business() {
|
||||||
|
|
||||||
|
return (value ? "开启 " : "关闭 ") + key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject getModifyResult() {
|
||||||
|
JSONObject modify = new JSONObject();
|
||||||
|
modify.put(key, value);
|
||||||
|
return modify;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
|
return modifyProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|