diff --git a/pom.xml b/pom.xml index 79bbe2b41..b336d2178 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ au.com.royalpay.payment payment-parent - 2.2.31 + 2.3.1 4.0.0 manage @@ -266,7 +266,7 @@ ${jib-maven-plugin.version} - 192.168.0.84:5000/royalpay/serverjre:openj9 + 192.168.0.84:5000/royalpay/openjdk:11.0.8 192.168.0.84:5000/royalpay/manage-dev @@ -304,7 +304,7 @@ ${jib-maven-plugin.version} - hkccr.ccs.tencentyun.com/rpay/serverjre:openj9 + 192.168.0.84:5000/royalpay/openjdk:11.0.8 hkccr.ccs.tencentyun.com/cross-payment-dev/manage-dev:${project.version} @@ -339,7 +339,7 @@ ${jib-maven-plugin.version} - hkccr.ccs.tencentyun.com/rpay/serverjre:openj9 + 192.168.0.84:5000/royalpay/openjdk:11.0.8 hkccr.ccs.tencentyun.com/rpay/manage:${project.version} diff --git a/src/db/20210916/log_mch_alipay_aps_register.sql b/src/db/20210916/log_mch_alipay_aps_register.sql new file mode 100644 index 000000000..eddcf2db4 --- /dev/null +++ b/src/db/20210916/log_mch_alipay_aps_register.sql @@ -0,0 +1,20 @@ + +CREATE TABLE `log_mch_alipay_aps_register` ( + `request_id` varchar(50) NOT NULL, + `client_id` int(11) NOT NULL, + `pid` varchar(50) NOT NULL, + `mid` varchar(50) NOT NULL, + `store_id` varchar(50) DEFAULT NULL, + `merchant_type` varchar(20) DEFAULT NULL COMMENT ' 支付类型 ONLINE,RETAIL', + `request_time` datetime DEFAULT NULL, + `confirm_time` datetime DEFAULT NULL, + `result_code` varchar(50) DEFAULT NULL COMMENT '返回的状态码', + `result_status` varchar(10) DEFAULT NULL COMMENT '返回的状态 F, S', + `is_valid` tinyint(1) DEFAULT '1' COMMENT '记录是否有效,1有效 0无效', + `registration_status` varchar(30) DEFAULT NULL, + PRIMARY KEY (`request_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='AlipayPlus商户注册记录表'; + +// +ALTER TABLE sys_client_legal_person add legal_representative_id varchar(50) DEFAULT NULL COMMENT '法人身份ID' + diff --git a/src/document/openapi/cn/components_order.yml b/src/document/openapi/cn/components_order.yml index ea511b3ea..b142a74b4 100644 --- a/src/document/openapi/cn/components_order.yml +++ b/src/document/openapi/cn/components_order.yml @@ -38,74 +38,8 @@ orderBasic: properties: pay_type: type: string - description: 钱包类型,AlipayPlus 线上订单必填,默认是alipay_cn - enum: - - alipay_cn - - alipay_hk - - gcash - - dana - - bkash - - kakaopay - - easy_paisa - - tng - - truemoney - flights: - type: array - description: 航班信息,如果有多个航班需分开填入,如果商户业务类型是航班类型且钱包类型为alipay_cn时必填 - items: - type: object - properties: - flight_no: - type: string - description: 航班号 - departure_time: - type: string - format: date-time - example: '202103011203' - pattern: yyyyMMddHHmm - description: 起飞时间(当地时区) - hotels: - type: array - description: 酒店预订信息,如果有多个酒店则分开录入,如果商户类型为旅游且钱包类型为alipay_cn时必填 - items: - type: object - properties: - name: - type: string - description: 酒店名称 - check_in_time: - type: string - format: date - example: '20210301' - pattern: yyyyMMdd - description: 入住日期 - check_out_time: - type: string - format: date - example: '20210302' - pattern: yyyyMMdd - description: 离店日期 - schools: - type: array - description: 留学信息,如果存在多个则分开录入,如果商户类型为留学且钱包类型为alipay_cn时必填 - items: - type: object - properties: - admission_notice_url: - type: string - description: 学校AdmissionNotice网页地址 - goods: - type: array - description: 商品信息,如果存在多个则分开录入,如果商户类型为贸易且钱包类型为alipay_cn时必填 - items: - type: object - properties: - name: - type: string - description: 商品名称 - quantity: - type: number - description: 数量 + description: | + 指定钱包类型。对于AlipayPlus线上订单,如果提供具体钱包类型,可直接进入对应钱包收银台,否则将进入钱包选择界面让消费者选择支付。参数来源于【查询可用子渠道】 orderWithChannel: allOf: - $ref: '#/orderBasic' @@ -407,6 +341,58 @@ transactionItem: remark: type: string description: 备注 +consultPaymentRequest: + type: object + required: + - currency + - amount + - terminal_type + properties: + currency: + type: string + description: | + 即将下单的币种,[ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) 标准3字母币种编码,如AUD + amount: + type: integer + description: 即将下单的金额,单位是货币最小单位 + terminal_type: + type: string + enum: + - WEB + - H5 + - APP + description: 下单类型,是PC端WEB页面还是移动端的H5页面,大小写敏感 + user_region: + type: string + description: | + [ISO-3166](https://www.iso.org/obp/ui/#iso:pub:PUB500001:en) 标准双字符国家编码,消费者所在国家,影响推荐的钱包优先级,如韩国顾客会优先返回KAKAOPAY + os_type: + type: string + description: 消费者支付场景操作系统类型,通常用于APP支付场景,大小写敏感 + enum: + - IOS + - ANDROID + client_ip: + type: string + description: 消费者所在ip + user_agent: + type: string + description: 如果是移动端支付,可提供User-Agent信息,用于判断当前消费者可用的钱包 +consultResultItemAlipayPlus: + type: object + required: + - sub_channel + - sub_channel_name + properties: + sub_channel: + type: string + description: 钱包名称,用于作为pay_type参数传递给下单api + sub_channel_name: + type: string + description: 钱包品牌名称,用于展示 + logo: + type: string + description: 钱包logo图片地址 customInfo: type: object properties: diff --git a/src/document/openapi/cn/document.yml b/src/document/openapi/cn/document.yml index 8ab722850..ae0fb5768 100644 --- a/src/document/openapi/cn/document.yml +++ b/src/document/openapi/cn/document.yml @@ -166,6 +166,39 @@ security: nonce_str: [] time: [] paths: + /gateway/partners/{partner_code}/consult_payment: + post: + tags: + - ChannelGateway + - MobileH5 + - SDK Payment + summary: 查询可用子渠道 + description: | + 用于AlipayPlus渠道查询可用子渠道。 + 可调用当前接口获取消费者可用的钱包列表,并展示给消费者自主选择。 + parameters: + - in: path + name: partner_code + required: true + requestBody: + content: + application/json: + schema: + $ref: 'components_order.yml#/consultPaymentRequest' + responses: + 200: + description: 查询结果 + content: + application/json: + schema: + type: object + required: + - sub_channels + properties: + sub_channels: + type: array + items: + $ref: 'components_order.yml#/consultResultItemAlipayPlus' /gateway/partners/{partner_code}/orders/{partner_order_id}: put: tags: @@ -479,16 +512,7 @@ paths: content: application/json: schema: - type: object - allOf: - - $ref: 'components_order.yml#/orderBasic' - - type: object - properties: - channel: - type: string - description: 支付渠道,大小写敏感 - enum: - - Alipay + $ref: 'components_order.yml#/orderWithChannel' responses: 200: description: Order @@ -938,27 +962,19 @@ paths: application/json: schema: allOf: - - $ref: 'components_order.yml#/orderBasic' + - $ref: 'components_order.yml#/orderWithChannel' - type: object - required: - - channel properties: - channel: - type: string - description: 支付渠道,大小写敏感 - enum: - - Wechat - - Alipay system: type: string - description: 客户端操作类型,支付宝选填,微信不需要 + description: 客户端操作类型,Alipay选填,Wechat不需要,AlipayPlus必填 enum: - android - iphone - ipad version: type: string - description: 客户端版本号,支付宝选填,微信不需要 + description: 客户端版本号,Alipay选填,其他渠道不需要 appid: type: string description: 微信必填,开发者平台appid diff --git a/src/document/openapi/en/components_order.yml b/src/document/openapi/en/components_order.yml index f48c6916d..682cd86f2 100644 --- a/src/document/openapi/en/components_order.yml +++ b/src/document/openapi/en/components_order.yml @@ -1,4 +1,3 @@ - orderBasic: required: - description @@ -32,6 +31,16 @@ orderBasic: or in format: digits with 'm' or 'h' tail. m=minutes, h=hours. default is 5m. if merchants has a global configuration in our backend, it will take the configuration. no shorter than 1m and no longer than 24h + extra: + type: object + properties: + pay_type: + type: string + description: | + Determine wallet type. For AlipayPlus orders, merchant can determine which wallet to use so that it will directly go into cashier page. + Otherwise a wallet choice page will be shown to customers to determine which wallet they want to use. + + value comes from ConsultPayment API orderWithChannel: allOf: - $ref: '#/orderBasic' @@ -328,6 +337,59 @@ transactionItem: remark: type: string description: transaction remark +consultPaymentRequest: + type: object + required: + - currency + - amount + - terminal_type + properties: + currency: + type: string + description: | + Currency of the incoming payment. Should be 3-character code in [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html). For example, AUD + amount: + type: integer + description: Order amount of the incoming payment. Should be minimal unit of the currency. + terminal_type: + type: string + enum: + - WEB + - H5 + - APP + description: Web is for pc browser paying, H5 is for mobile browser or inner webview in wallet apps. APP is for merchant's App. case-sensitive + user_region: + type: string + description: | + Standard 2-character code in [ISO-3166](https://www.iso.org/obp/ui/#iso:pub:PUB500001:en). Which country is your customer in. + This will help to determine which wallet is suggested. For example, a South-Korea customer will be recommended to use KakaoPay + os_type: + type: string + description: For App payment. Pass this os is customer using. Case-sensitive + enum: + - IOS + - ANDROID + client_ip: + type: string + description: customer ip address + user_agent: + type: string + description: If customer is in the inner webview of wallet. this will help to determine which wallet should be recommended +consultResultItemAlipayPlus: + type: object + required: + - sub_channel + - sub_channel_name + properties: + sub_channel: + type: string + description: wallet name. should be passed as pay_type parameter in new order requests + sub_channel_name: + type: string + description: wallet brand name which can be display to customers + logo: + type: string + description: wallet logo customInfo: type: object properties: diff --git a/src/document/openapi/en/document.yml b/src/document/openapi/en/document.yml index 206c3d5ce..93d9d0aa5 100644 --- a/src/document/openapi/en/document.yml +++ b/src/document/openapi/en/document.yml @@ -161,7 +161,7 @@ tags: Call this api to create order and get param string for SDK calling. Call SDK api with the param to start payment and get payment result from Wechat app *It is strongly advised to request RoyalPay order query Api to confirm that the order has been paid in order to cancelling order by system at the same time.* More information for integration with Alipay: [Alipay SDK Document](https://global.alipay.com/doc/app/intro) - More information for integration with Alipay: [Wechat SDK Document](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=11_1) + More information for integration with Wechat: [Wechat SDK Document](https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=11_1) [Alipay SDK for Android](resources/api/alipaySdk-20160825.jar) [Alipay SDK for iOS](resources/api/AlipaySDKForiOS.zip) [Wechat SDK for Android](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319167&token=&lang=zh_CN) @@ -174,6 +174,39 @@ security: nonce_str: [] time: [] paths: + /gateway/partners/{partner_code}/consult_payment: + post: + tags: + - ChannelGateway + - MobileH5 + - SDK Payment + summary: ConsultPayment + description: | + Used for check which pay_type is available for AlipayPlus channel. + You can call this api to get available wallets and ask customers to choose. + parameters: + - in: path + name: partner_code + required: true + requestBody: + content: + application/json: + schema: + $ref: 'components_order.yml#/consultPaymentRequest' + responses: + 200: + description: 查询结果 + content: + application/json: + schema: + type: object + required: + - sub_channels + properties: + sub_channels: + type: array + items: + $ref: 'components_order.yml#/consultResultItemAlipayPlus' /gateway/partners/{partner_code}/orders/{partner_order_id}: put: tags: @@ -489,16 +522,7 @@ paths: content: application/json: schema: - type: object - allOf: - - $ref: 'components_order.yml#/orderBasic' - - type: object - properties: - channel: - type: string - description: channel. case sensitive - enum: - - Alipay + $ref: 'components_order.yml#/orderWithChannel' responses: 200: description: Order @@ -960,30 +984,22 @@ paths: application/json: schema: allOf: - - $ref: 'components_order.yml#/orderBasic' + - $ref: 'components_order.yml#/orderWithChannel' - type: object - required: - - channel properties: - channel: - type: string - description: Payment channel, required, case sensitive - enum: - - Wechat - - Alipay system: type: string - description: OS type of client app, optional for Alipay, not required for Wechat + description: OS type of client app, optional for Alipay, required for AlipayPlus, not required for Wechat enum: - android - iphone - ipad version: type: string - description: client app version, optional for Alipay, not required for Wechat + description: client app version, optional only for Alipay appid: type: string - description: wechat appid, required for Wechat, not required for Alipay + description: wechat appid, only required for Wechat responses: 200: description: Order diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/diet/core/impls/OneDollarDayActivitySupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/activities/diet/core/impls/OneDollarDayActivitySupportImpl.java index 6a46ae9d3..80a0b2490 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/diet/core/impls/OneDollarDayActivitySupportImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/diet/core/impls/OneDollarDayActivitySupportImpl.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; import au.com.royalpay.payment.core.TransactionService; import au.com.royalpay.payment.core.beans.PaymentQueryResult; import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.TransactionBizSubType; import au.com.royalpay.payment.core.beans.coupon.CashCouponInfo; import au.com.royalpay.payment.core.beans.coupon.CouponInfo; import au.com.royalpay.payment.core.events.PaymentFinishedEvent; @@ -163,7 +164,7 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa log.put("transaction_time", format.format(paymentQueryResult.getPayTime())); log.put("clearing_status", 0); log.put("remark", "Activity: Day Of One Dollar"); - transactionService.saveTransaction(log); + transactionService.saveTransaction(log, TransactionBizSubType.COUPON_PAY); String transactionId = log.getString("transaction_id"); actDietOrderMapper.setTransactionId(orderId, transactionId, log.getDate("transaction_time")); } @@ -214,7 +215,7 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa log.put("transaction_time", new Date()); log.put("clearing_status", 0); log.put("remark", "Activity Refund: Day Of One Dollar"); - transactionService.saveTransaction(log); + transactionService.saveTransaction(log,TransactionBizSubType.COUPON_REFUND); actDietOrderMapper.updateRefund(orderId, log.getString("transaction_id"), log.getDate("transaction_time")); } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java index 748c33efa..232339e9f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/PlatformClearService.java @@ -10,10 +10,9 @@ public interface PlatformClearService { JSONObject getChannelSettleLog(String channel); - void verifySettleLogByDate(String start_date, String end_date, String channel) throws ParseException; + void verifySettleLogByDate(String startDate, String endDate, String channel) throws ParseException; void generateSettleLogs(); - void generateAliPaySettleLogs(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ChannelsAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ChannelsAnalysisServiceImpl.java index 9878e525f..1c38e76fd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ChannelsAnalysisServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ChannelsAnalysisServiceImpl.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.analysis.core.impls; +import au.com.royalpay.payment.core.mappers.MchChannelContractMapper; import au.com.royalpay.payment.manage.analysis.core.ChannelsAnalysisService; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import com.alibaba.fastjson.JSONObject; @@ -28,6 +29,9 @@ public class ChannelsAnalysisServiceImpl implements ChannelsAnalysisService { @Resource private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper; + @Resource + private MchChannelContractMapper mchChannelContractMapper; + @Override public List getChannelMount(JSONObject params) { /*if (!params.containsKey("client_ids") && !params.containsKey("org_id")){ @@ -37,6 +41,8 @@ public class ChannelsAnalysisServiceImpl implements ChannelsAnalysisService { listChannel.add(putParam(params,"Wechat")); listChannel.add(putParam(params,"Alipay")); listChannel.add(putParam(params,"AlipayOnline")); + listChannel.add(putParam(params,"ApsInStore")); + listChannel.add(putParam(params,"ApsCashier")); listChannel.add(putParam(params,"Rpay")); listChannel.add(putParam(params,"rpaypmt_card")); listChannel.add(putParam(params,"rpaypmt_dd")); @@ -50,7 +56,7 @@ public class ChannelsAnalysisServiceImpl implements ChannelsAnalysisService { } List list = new ArrayList<>(); Map analysisMap = new TreeMap<>(); - String[] channels = {"Wechat","Alipay","AlipayOnline","Rpay","rpaypmt_card","rpaypmt_dd"}; + String[] channels = {"Wechat","Alipay","AlipayOnline","Rpay","rpaypmt_card","rpaypmt_dd","ApsCashier","ApsInStore"}; for (String channel:channels){ analysisChannelCustomers(params, analysisMap, channel); } @@ -76,7 +82,7 @@ public class ChannelsAnalysisServiceImpl implements ChannelsAnalysisService { @Override public void exportData(JSONObject params, HttpServletResponse resp) { - params.put("channels", new String []{"Alipay", "AlipayOnline"}); + params.put("channels", new String []{"Alipay", "AlipayOnline","AlipayAps"}); String[] title = {"Channel", "Total Amount(AUD)", "Total orders", "Transaction Partners", "Enable Partners"}; JSONObject count = customerAndOrdersStatisticsMapper.countChannel(params); int enablePartners = customerAndOrdersStatisticsMapper.countEnableAlipay(params); @@ -136,7 +142,14 @@ public class ChannelsAnalysisServiceImpl implements ChannelsAnalysisService { params.put("gateway_alipay_online", 1); enablePartners = customerAndOrdersStatisticsMapper.countEnableChannel(params); params.remove("gateway_alipay_online"); - } else { + } + else if("ApsInStore".equals(name)){ + enablePartners=mchChannelContractMapper.sumEnablePartners(name); + } + else if("ApsCashier".equals(name)){ + enablePartners=mchChannelContractMapper.sumEnablePartners(name); + } + else { params.put("enable_" + name.toLowerCase(), 1); enablePartners = customerAndOrdersStatisticsMapper.countEnableChannel(params); params.remove("enable_" + name.toLowerCase()); diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index 0ef0aa84b..bd85f1609 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -621,7 +621,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } } private JSONObject getTodayChannelCount(JSONObject params){ - String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"}; + String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd","ApsInStore","ApsCashier"}; JSONObject resp = new JSONObject(); for(String channel:channels) { params.put("channel", channel); diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/EstimateAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/EstimateAnalysisServiceImpl.java index 8e6d9641a..12a699447 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/EstimateAnalysisServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/EstimateAnalysisServiceImpl.java @@ -3,7 +3,7 @@ package au.com.royalpay.payment.manage.analysis.core.impls; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; +import au.com.royalpay.payment.core.beans.SettlementLog; import au.com.royalpay.payment.manage.analysis.core.EstimateAnalysisService; import au.com.royalpay.payment.manage.analysis.core.EstimateCacheSupport; import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper; diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java index 32ce78bd2..c68b25b11 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PlatformClearAnalysisServiceImpl.java @@ -1,34 +1,30 @@ package au.com.royalpay.payment.manage.analysis.core.impls; -import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient; -import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; -import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; -import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; -import au.com.royalpay.payment.core.exceptions.ChannelNetworkException; +import au.com.royalpay.payment.core.ChannelSettleVerify; +import au.com.royalpay.payment.core.beans.SettlementLog; import au.com.royalpay.payment.manage.analysis.core.PlatformClearService; -import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.PlatformSettlementMapper; -import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient; +import au.com.royalpay.payment.tools.defines.PayChannel; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils; -import com.alibaba.fastjson.JSONArray; 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.StringUtils; import org.apache.commons.lang3.time.DateUtils; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.List; @Service public class PlatformClearAnalysisServiceImpl implements PlatformClearService { @@ -37,16 +33,10 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { public static final SimpleDateFormat sdfClear = new SimpleDateFormat("yyyy-MM-dd"); public static final SimpleDateFormat sdfNormal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - @Resource - private MpPaymentApi mpPaymentApi; - @Resource - private AlipayClient alipayClient; + @Autowired(required = false) + private ChannelSettleVerify[] channelSettleVerifys; @Resource private PlatformSettlementMapper platformSettlementMapper; - @Resource - private EstimateAnalysisMapper estimateAnalysisMapper; - @Resource - private AttachmentClient attachmentClient; @Override public JSONObject getPlatformSettleLog(String channel, int page, int limit) { @@ -58,10 +48,11 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { @Override public JSONObject getChannelSettleLog(String channel) { JSONObject sysLogs = new JSONObject(); - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Credit"); + Date fromDate = DateTime.parse("2018-04-05T02:00:00+10:00").toDate(); + JSONObject creditLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Credit"); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("rmb_amount")); - JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Debit"); + JSONObject debitLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Debit"); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("rmb_amount")); sysLogs.put("surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); @@ -74,121 +65,41 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { } @Override - public void verifySettleLogByDate(String start_date, String end_date, String channel) { - if (StringUtils.equals("Alipay", channel)) { - try { - doVerifyAlipaySettleLog(sdfClear.parse(end_date)); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝到账失败:", e); - } - } - if (StringUtils.equals("AlipayOnline", channel)) { - try { - doVerifyAlipayOnlineSettleLog(sdfClear.parse(end_date)); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝Online到账失败:", e); - throw new ChannelNetworkException("校验失败:", e); - } - } - if (StringUtils.equals("Wechat", channel)) { - try { - Map settleDate = new HashMap<>(); - settleDate.put("from", sdfClear.parse(start_date)); - settleDate.put("to", sdfClear.parse(end_date)); - doVerifyWechatSettleLog(settleDate); - } catch (Exception e) { - logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "微信到账失败:", e); - } - - } - } - - @Override - // @Transactional - public void generateSettleLogs() { - // deleteSettleLogs(); - generateWechatSettleLogs(); - generateAlipaySettleLogs(); - generateAlipayOnlineSettleLogs(); - } - - @Override - @Transactional - public void generateAliPaySettleLogs() { - generateAlipaySettleLogs(); - generateAlipayOnlineSettleLogs(); - } - - @Transactional - public void generateWechatSettleLogs() { - try { - Map settleDate = TimeZoneUtils.getStatetimeDays(); - logger.info("开始查询" + settleDate.get("from") + "到" + settleDate.get("to") + "的微信清算记录"); - doVerifyWechatSettleLog(settleDate); - } catch (ParseException e) { - e.printStackTrace(); + public void verifySettleLogByDate(String startDate, String endDate, String channel) { + if (channelSettleVerifys == null) { + return; } - } - - private void generateAlipaySettleLogs() { - try { - List dateList = TimeZoneUtils.getStatetime(); - for (Date dateStr : dateList) { - try { - doVerifyAlipaySettleLog(dateStr); - } catch (Exception e) { - logger.error("获取" + dateStr + "Alipay清算记录失败", e); - } - } - } catch (Exception e) { - logger.error("获取Alipay清算记录时间失败", e); - } - - } - - private void generateAlipayOnlineSettleLogs() { - try { - List dateList = TimeZoneUtils.getStatetime(); - for (Date dateStr : dateList) { - try { - doVerifyAlipayOnlineSettleLog(dateStr); - } catch (Exception e) { - logger.error("获取" + dateStr + "AlipayOnline清算记录失败", e); - } - } - } catch (Exception e) { - logger.error("获取AlipayOnline清算记录时间失败", e); - } - - } - - @Transactional - public void doVerifyAlipaySettleLog(Date dateStr) throws Exception { - JSONObject aliSettleLog = alipayClient.oldDownloadRetailSettlements(dateStr); - saveAlipaySettleLog(dateStr, aliSettleLog, "Alipay"); - } + Arrays.stream(channelSettleVerifys).filter(verify -> verify.payChannel().getChannelCode().equalsIgnoreCase(channel)) + .findFirst().ifPresent(verify -> { + try { + Date currentDate = sdfClear.parse(startDate); + Date end = sdfClear.parse(endDate); + while (!end.before(currentDate)) { + saveVerifyResults(currentDate, verify); + currentDate = DateUtils.addDays(currentDate, 1); + } + } catch (ParseException e) { + throw new BadRequestException("Invalid Date Format"); + } - @Transactional - public void doVerifyAlipayOnlineSettleLog(Date dateStr) throws Exception { - JSONObject aliOnlineSettleLog = alipayClient.downloadOnlineSettlements(dateStr); - saveAlipaySettleLog(dateStr, aliOnlineSettleLog, "AlipayOnline"); + }); } - private void saveAlipaySettleLog(Date dateStr, JSONObject aliSettleLog, String channel) throws Exception { - if (aliSettleLog != null) { - JSONObject settleFee = getAliSettle(aliSettleLog); + private void saveVerifyResults(Date date, ChannelSettleVerify verify) { + logger.info("starting verify for channel {} on {}", verify.payChannel(), date); + List logs = verify.verifyResults(date); + logger.info("loaded {} settle logs for channel {} on {}", logs.size(), verify.payChannel(), date); + for (SettlementLog settle : logs) { JSONObject params = new JSONObject(); - params.put("settle_date", dateStr); - params.put("start_date", dateStr); - params.put("end_date", dateStr); - params.put("pay_fee", settleFee.getBigDecimal("credit")); - params.put("refund_fee", settleFee.getBigDecimal("debit")); - params.put("net_fee", settleFee.getBigDecimal("net_fee")); - params.put("surcharge", settleFee.getBigDecimal("surcharge")); - params.put("settlement_fee", settleFee.getBigDecimal("settlement_fee")); - params.put("channel", channel); + params.put("settle_date", settle.getSettlementDate()); + params.put("start_date", TimeZoneUtils.formatTime(settle.getStart(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + params.put("end_date", TimeZoneUtils.formatTime(settle.getEnd(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + if (verify.payChannel() == PayChannel.WECHAT) { + params.put("settle_date", TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai")); + } + params.put("channel", verify.payChannel().getChannelCode()); params.put("last_update_date", new Date()); - JSONObject sysClearData = getSystemClearingAmount(dateStr, aliSettleLog, channel); + JSONObject sysClearData = getSystemClearingAmount(settle, verify.payChannel().getChannelCode()); if (sysClearData != null && !sysClearData.isEmpty()) { params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee")); params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee")); @@ -196,173 +107,74 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService { params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge")); params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee")); } - JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), channel, "All"); - if (check != null) { - params.put("log_id", check.getString("log_id")); - platformSettlementMapper.update(params); - } else { - platformSettlementMapper.save(params); + params.put("merchants", settle.getMerchantId()); + params.put("pay_fee", settle.getPayFee()); + params.put("refund_fee", settle.getRefundFee()); + params.put("net_fee", settle.getPayNetFee()); + if (verify.payChannel() != PayChannel.WECHAT) { + params.put("net_fee", settle.getPayFee().subtract(settle.getRefundFee())); } - } - } - - public void doVerifyWechatSettleLog(Map settleDate) { - List tencentSettle = new ArrayList<>(); - for (WeChatPayConfig.Merchant mch : WechatPayEnvironment.getEnv().getWechatMerchantConfigs()) { + params.put("settlement_fee", settle.getSettlementFee()); + params.put("surcharge", settle.getPoundageFee()); + params.put("unsettle_fee", settle.getUnsettlementFee()); try { - tencentSettle = mpPaymentApi.settlementLogs(settleDate.get("from"), settleDate.get("to"), mch.getMerchantId()); - if (tencentSettle == null) { - logger.info("【" + mch.getMerchantId() + "】下没有清算记录"); + if (("1500474722".equals(settle.getMerchantId()) && settle.getSettlementDate().before(DateTime.parse("2018-06-02").toDate())) || + ("1492874492".equals(settle.getMerchantId()) && settle.getSettlementDate().after(DateTime.parse("2018-06-05").toDate()))) { + return; + } + JSONObject check = platformSettlementMapper.findByDateMerchant(verify.payChannel() == PayChannel.WECHAT ? TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai") : sdfClear.format(settle.getSettlementDate()), verify.payChannel().getChannelCode(), settle.getMerchantId()); + if (check != null) { + params.put("log_id", check.getString("log_id")); + platformSettlementMapper.update(params); } else { - for (SettlementLog settle : tencentSettle) { - JSONObject params = new JSONObject(); - params.put("settle_date", settle.getSettlementDate()); - params.put("start_date", settle.getStart()); - params.put("end_date", settle.getEnd()); - params.put("channel", "Wechat"); - params.put("last_update_date", new Date()); - JSONObject sysClearData = getSystemClearingAmount(null, settle, "Wechat"); - if (sysClearData != null && !sysClearData.isEmpty()) { - params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee")); - params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee")); - params.put("sys_net_fee", sysClearData.getBigDecimal("sys_net_fee")); - params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge")); - params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee")); - } - params.put("merchants", mch.getMerchantId()); - params.put("pay_fee", settle.getPayFee()); - params.put("refund_fee", settle.getRefundFee()); - params.put("net_fee", settle.getPayNetFee()); - params.put("settlement_fee", settle.getSettlementFee()); - params.put("surcharge", settle.getPoundageFee()); - params.put("unsettle_fee", settle.getUnsettlementFee()); - - JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(settle.getSettlementDate()), "Wechat", - mch.getMerchantId()); - if (check != null) { - params.put("log_id", check.getString("log_id")); - platformSettlementMapper.update(params); - } else { - platformSettlementMapper.save(params); - } - params.clear(); - logger.info(mch.getMerchantId() + "的微信清算记录查询完成"); - } + platformSettlementMapper.save(params); } + params.clear(); } catch (Exception e) { - logger.error("【" + mch.getMerchantId() + "】下没有清算记录", e); + logger.error(e.getMessage(), e); } } } - public JSONObject getAliSettle(JSONObject aliSettleLog) { - JSONObject alipaySettleLog = new JSONObject(); - JSONArray payments = aliSettleLog.getJSONArray("payments"); - BigDecimal credit = BigDecimal.ZERO; - BigDecimal creditFee = BigDecimal.ZERO; - BigDecimal creditSettle = BigDecimal.ZERO; - if (payments != null) { - for (int i = 0; i < payments.size(); i++) { - JSONObject json = payments.getJSONObject(i); - BigDecimal transactionAmount = json.getBigDecimal("transaction_amount"); - BigDecimal chargeFee = json.getBigDecimal("charge_fee"); - credit = credit.add(transactionAmount); - creditFee = creditFee.add(chargeFee); - if (json.containsKey("settle_amount")) { - creditSettle = creditSettle.add(json.getBigDecimal("settle_amount")); - } else { - creditSettle = creditSettle.add(transactionAmount.subtract(chargeFee)); + @Override + // @Transactional + public void generateSettleLogs() { + if (channelSettleVerifys != null) { + try { + List dateList = TimeZoneUtils.getStatetime(); + for (Date date : dateList) { + for (ChannelSettleVerify verify : channelSettleVerifys) { + try { + saveVerifyResults(date, verify); + } catch (Exception e) { + logger.error("[{}]{} failed to download settle file", date, verify.payChannel(), e); + } + } } + } catch (ParseException ignored) { } - } - alipaySettleLog.put("credit", credit); - JSONArray refunds = aliSettleLog.getJSONArray("refunds"); - logger.info("alipay的refunds清算总信息" + refunds.toJSONString()); - BigDecimal debit = BigDecimal.ZERO; - BigDecimal debitFee = BigDecimal.ZERO; - BigDecimal debitSettle = BigDecimal.ZERO; - for (int i = 0; i < refunds.size(); i++) { - JSONObject json = refunds.getJSONObject(i); - BigDecimal transactionAmount = json.getBigDecimal("transaction_amount"); - BigDecimal chargeFee = json.getBigDecimal("charge_fee"); - debit = debit.add(transactionAmount); - debitFee = debitFee.add(chargeFee); - if (json.containsKey("settle_amount")) { - debitSettle = debitSettle.add(json.getBigDecimal("settle_amount")); - } else { - debitSettle = debitSettle.add(transactionAmount.subtract(chargeFee)); - } } - alipaySettleLog.put("debit", debit); - alipaySettleLog.put("net_fee", credit.subtract(debit)); - alipaySettleLog.put("surcharge", creditFee.subtract(debitFee)); - alipaySettleLog.put("settlement_fee", creditSettle.subtract(debitSettle)); - logger.info("阿里清算日志:" + alipaySettleLog.toJSONString()); - return alipaySettleLog; } - public JSONObject getSystemClearingAmount(Date settle_date, Object settlementLog, String channel) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00"); + private JSONObject getSystemClearingAmount(SettlementLog settlementLog, String channel) { JSONObject sysLogs = new JSONObject(); - String start_date = null; - String end_date = null; - if (StringUtils.equals("Alipay", channel)) { - JSONObject lastClearDay = estimateAnalysisMapper.findLastCleanDays(sdfClear.format(settle_date), 1); - start_date = sdf.format(lastClearDay.getDate("date_str")); - end_date = sdf.format(settle_date); - logger.info("Alipay System Settle Logs:" + start_date + "<====>" + end_date); - } else if (StringUtils.equals("Wechat", channel)) { - SettlementLog wechatSettleLog = (SettlementLog) settlementLog; - start_date = sdf.format(wechatSettleLog.getStart()); - end_date = sdf.format(wechatSettleLog.getEnd()); - logger.info("Wechat System Settle Logs:" + start_date + "<====>" + end_date); - } else if (StringUtils.equals("AlipayOnline", channel)) { - JSONObject alipayOnlineSettleLog = (JSONObject) settlementLog; - logger.info("AlipayOnline System Settle Logs:" + alipayOnlineSettleLog.getDate("min_time") + "<====>" + alipayOnlineSettleLog.getDate("max_time")); - start_date = sdf.format(alipayOnlineSettleLog.getDate("min_time")); - end_date = sdf.format(DateUtils.addDays(alipayOnlineSettleLog.getDate("max_time"), 1)); - } else { - return null; - } - - // 2017-11-01后微信手续费0.5 - BigDecimal wechat_rate; - if (end_date.compareTo("2017-11-01 03:00:00") <= 0) { - wechat_rate = new BigDecimal("0.006"); - } else { - wechat_rate = new BigDecimal("0.005"); - } - - // 2018-09-01后Alipay_Online手续费0.006 - BigDecimal alipay_online_rate; - if (end_date.compareTo("2018-09-01 02:00:00") <= 0) { - alipay_online_rate = new BigDecimal("0.018"); - } else { - alipay_online_rate = new BigDecimal("0.006"); - } + logger.info("{} System Settle Logs:{}<====>{}", channel, settlementLog.getStart(), settlementLog.getEnd()); try { - JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate); + JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Credit"); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount")); - - JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit", wechat_rate); + JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Debit"); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount")); - sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount"))); - if (StringUtils.equals("Alipay", channel)) { - sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, BigDecimal.valueOf(0.006))); - } else if (StringUtils.equals("AlipayOnline", channel)) { - sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, alipay_online_rate)); - } else { - sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); - } + sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); sysLogs.put("sys_settle_fee", sysLogs.getBigDecimal("sys_net_fee").subtract(sysLogs.getBigDecimal("sys_surcharge"))); + logger.info("calculated system result[{}|{}~{}]:{}", channel, settlementLog.getStart(), settlementLog.getEnd(), sysLogs); return sysLogs; } catch (Exception e) { - // do nothing - e.printStackTrace(); + //do nothing + logger.error("Error caught on analysising {}", channel, e); } return null; } 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 f1dcb0933..567a8ca1b 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 @@ -985,11 +985,13 @@ public class RetailAppServiceImp implements RetailAppService { for (JSONObject order : orders) { order.put("geek_apply_deduction", order.getBooleanValue("geek_apply_deduction")); Calendar calendar = (Calendar) order.get("transaction_time"); - if (timezone != null) { + String tradeDate=null; + String tradeTime=null; + if (calendar!=null&&timezone != null) { calendar.setTimeZone(TimeZone.getTimeZone(timezone)); + tradeDate = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone()); + tradeTime = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone()); } - String tradeDate = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone()); - String tradeTime = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone()); order.put("trade_date", tradeDate); order.put("trade_time", tradeTime); // todo @@ -999,6 +1001,12 @@ public class RetailAppServiceImp implements RetailAppService { if ("CNY".equals(order.getString("currency"))) { order.put("clearing_amount", order.getBigDecimal("total_amount")); } + if("ApsInStore".equalsIgnoreCase(order.getString("channel"))){ + order.put("channel", "Alipay+"); + } + if("ApsCashier".equalsIgnoreCase(order.getString("channel"))){ + order.put("channel", "Alipay+(Online)"); + } if (!dateContains.contains(tradeDate)) { String reDate = tradeDate.replace("-", ""); AppQueryBean dateQuery = new AppQueryBean(); @@ -3114,6 +3122,18 @@ public class RetailAppServiceImp implements RetailAppService { if (cardPaymentPay.containsKey("channel")) { channels.add(cardPaymentPay); } + + JSONObject apsInStore = getChannel(clientId, now, "ApsInStore"); + if (apsInStore.containsKey("channel")) { + apsInStore.put("channel","Alipay+"); + channels.add(apsInStore); + } + JSONObject apsCashier = getChannel(clientId, now, "ApsCashier"); + if (apsCashier.containsKey("channel")) { + apsCashier.put("channel","Alipay+(Online)"); + + channels.add(apsCashier); + } res.put("channels", channels); if (res.containsKey("rate_value")) { BigDecimal minRate = res.getBigDecimal("rate_value").add(BigDecimal.valueOf(0.01)).setScale(2, RoundingMode.DOWN); diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java index ebbd06d7c..2b3cea4bd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java @@ -1,5 +1,7 @@ package au.com.royalpay.payment.manage.citypartner.core.impls; +import au.com.royalpay.payment.channels.alipay.config.AlipayConfig; +import au.com.royalpay.payment.channels.alipay.runtime.alipayplus.AlipayPlusRuleManager; import au.com.royalpay.payment.manage.citypartner.beans.AgentCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis; @@ -8,6 +10,8 @@ import au.com.royalpay.payment.manage.mappers.financial.*; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.defines.PayChannel; +import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; @@ -357,6 +361,11 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { BigDecimal wechatChargeRate = new BigDecimal("0.6"); BigDecimal jdChargeRate = new BigDecimal("0.9"); BigDecimal alipayonlineChargeRate = new BigDecimal("0.6"); + BigDecimal retailInterchangeChargeRate = new BigDecimal("0.5"); + BigDecimal retailServiceChargeRate = new BigDecimal("0.5"); + BigDecimal onlineInterchangeChargeRate = new BigDecimal("0.5"); + BigDecimal onlineServiceChargeRate = new BigDecimal("0.5"); + if (sysConfig.getBigDecimal("Alipay_charge_rate") != null) { alipayChargeRate = sysConfig.getBigDecimal("Alipay_charge_rate"); } @@ -369,11 +378,28 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { if (sysConfig.getBigDecimal("alipayonline_charge_rate") != null) { alipayonlineChargeRate = sysConfig.getBigDecimal("alipayonline_charge_rate"); } + if (sysConfig.getBigDecimal("retail_interchange_charge_rate") != null) { + retailInterchangeChargeRate = sysConfig.getBigDecimal("retail_interchange_charge_rate"); + } + if (sysConfig.getBigDecimal("retail_service_charge_rate") != null) { + retailServiceChargeRate = sysConfig.getBigDecimal("retail_service_charge_rate"); + } + if (sysConfig.getBigDecimal("online_interchange_charge_rate") != null) { + onlineInterchangeChargeRate = sysConfig.getBigDecimal("online_interchange_charge_rate"); + } + if (sysConfig.getBigDecimal("online_service_charge_rate") != null) { + onlineServiceChargeRate = sysConfig.getBigDecimal("online_service_charge_rate"); + } + JSONObject channelCharge = new JSONObject(); channelCharge.put("alipayChargeRate", alipayChargeRate); channelCharge.put("wechatChargeRate", wechatChargeRate); channelCharge.put("jdChargeRate", jdChargeRate); channelCharge.put("alipayonlineChargeRate", alipayonlineChargeRate); + channelCharge.put("retailInterchangeChargeRate", retailInterchangeChargeRate); + channelCharge.put("retailServiceChargeRate", retailServiceChargeRate); + channelCharge.put("onlineInterchangeChargeRate", onlineInterchangeChargeRate); + channelCharge.put("onlineServiceChargeRate", onlineServiceChargeRate); List transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month); transactionDetail.forEach(item -> { @@ -451,13 +477,28 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { if (orgInfo.get("alipayonlinecn_rate_value") == null) { throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); } + } else if (StringUtils.equals(channel.toLowerCase(), "apsinstore")) { + if (orgInfo.get("retail_interchange_fee_value") == null) { + throw new ServerErrorException(orgInfo.getString("name") + "组织下A+(Retail)的 Interchange Fee 成本手续费未设置"); + } + if (orgInfo.get("retail_service_fee_value") == null) { + throw new ServerErrorException(orgInfo.getString("name") + "组织下A+(Retail)的 Service Fee 成本手续费未设置"); + } + } else if (StringUtils.equals(channel.toLowerCase(), "apscashier")) { + if (orgInfo.get("online_interchange_fee_value") == null) { + throw new ServerErrorException(orgInfo.getString("name") + "组织下A+(Online)的 Interchange Fee 成本手续费未设置"); + } + if (orgInfo.get("online_service_fee_value") == null) { + throw new ServerErrorException(orgInfo.getString("name") + "组织下A+(Online)的 Service Fee 成本手续费未设置"); + } } else { throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); } } + PayChannel payChannel = PayChannel.fromChannelCode(channel); for (JSONObject params : oneChannel.getValue()) { - if (StringUtils.equals("rpaypmt_card", channel.toLowerCase())) { + if (payChannel == PayChannel.RPAY_CHANNEL_CARD) { //rpaypmt_domestic_card BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_domestic_card" + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); @@ -489,7 +530,22 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } else { BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); - BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + BigDecimal channelRate = null; + if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) { + if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) { + if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } //增加transaction_fee为null异常 if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) { params.put("transaction_fee", BigDecimal.ZERO); @@ -514,7 +570,13 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { json.put("total_charge", total_surage); json.put("transaction_fee", transaction_fee); json.put("net_charge", net_surage); - json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) { + json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value")))); + } else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) { + json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value")))); + } else { + json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + } json.put("royalpay_charge", royalpay_surage); json.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge); json.put("commission_type", "1"); @@ -539,7 +601,21 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { String channel = oneChannel.getKey(); for (JSONObject params : oneChannel.getValue()) { BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); - BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + BigDecimal channelRate; + if (StringUtils.equals("alipayaps", channel.toLowerCase())) { + if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) { + AlipayConfig.BizType bizType = AlipayPlusRuleManager.getRules().determineAmsBizType(TradeType.fromGatewayNumber(params.getInteger("gateway"))); + if (bizType == AlipayConfig.BizType.RETAIL) { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("interchange_fee_value").add(orgInfo.getBigDecimal("service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } //增加transaction_fee为null异常 if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) { params.put("transaction_fee", BigDecimal.ZERO); @@ -565,7 +641,11 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { json.put("gross_amount", total); json.put("total_charge", total_surage); json.put("net_charge", net_surage); - json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + if (StringUtils.equals("alipayaps", channel.toLowerCase())) { + json.put("org_rate", (orgInfo.getBigDecimal("interchange_fee_value").add(orgInfo.getBigDecimal("service_fee_value")))); + } else { + json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + } json.put("partner_charge", royalpay_surage); json.put("share_charge", share_surage); json.put("org_charge", org_charge); @@ -611,6 +691,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { rateChannel); } catch (Exception e) { } + PayChannel payChannel = PayChannel.fromChannelCode(channel); for (JSONObject params : oneChannel.getValue()) { BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount"); if (StringUtils.equals(channel.toLowerCase() + "_rate_value", "rpaypmt_card_rate_value")) { @@ -659,7 +740,22 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } else { - BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + BigDecimal channelRate; + if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) { + if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) { + if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } + } else { + channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); + } BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge") .subtract(params.getBigDecimal("surcharge_cashback")) .subtract(params.getBigDecimal("transaction_fee")); @@ -705,7 +801,13 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { } json.put("gross_amount", total); json.put("total_charge", total_surage); - json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) { + json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value")))); + } else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) { + json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value")))); + } else { + json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); + } json.put("royalpay_charge", royalpay_surage); if (type == 1) { json.put("net_charge", net_surage); diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java index 27d1a9919..db7ca8c13 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/TestController.java @@ -220,7 +220,7 @@ public class TestController { client.put("located_country", "Australia"); if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ // clean_1 clean_1_friday clean_1_saturday - // second, third or fourth + // first, second, third or fourth client.put("clean_1", weChatRate.getString("clean_days")); client.put("clean_1_friday", "first"); client.put("clean_1_saturday", "second"); diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/WxSettleLogController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/WxSettleLogController.java index ae8f95583..f8da2d798 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/WxSettleLogController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/WxSettleLogController.java @@ -1,7 +1,7 @@ package au.com.royalpay.payment.manage.dev.web; import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; +import au.com.royalpay.payment.core.beans.SettlementLog; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import org.apache.commons.lang3.time.DateUtils; diff --git a/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundProcessorImpl.java b/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundProcessorImpl.java index 324d2fde2..4d0d719ec 100644 --- a/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundProcessorImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundProcessorImpl.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.fund.core.impls; import au.com.royalpay.payment.core.SettlementDetailCalculator; import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.core.beans.TransactionBizSubType; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.manage.fund.beans.XPlanFundConfig; import au.com.royalpay.payment.manage.fund.core.XPlanFundConfigService; @@ -303,7 +304,7 @@ public class XPlanFundProcessorImpl implements XPlanFundProcesor { tradeTransaction.put("channel", "System"); tradeTransaction.put("system_generate", 1); tradeTransaction.put("remark", remark); - transactionService.saveTransaction(tradeTransaction); + transactionService.saveTransaction(tradeTransaction, TransactionBizSubType.DEPOSIT); return tradeTransaction; } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java index 0581a03e7..315f36874 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java @@ -100,7 +100,7 @@ public interface CleanService { List findLogSettleByDate(Date date); - JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1); + JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1,boolean isSendMessage); void distributeBank(Date date, int clearingId, JSONObject bankDistribution); 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 478b3ef5d..2d989d1c6 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 @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.management.clearing.core.impl; import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.beans.OrderValidationChannelResult; import au.com.royalpay.payment.core.beans.OrderValidationResult; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; @@ -1577,7 +1578,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } @Override - public JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1) { + public JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1, boolean isSendMessage) { if (!b) { JSONObject reportItem = validationLogMapper.findByDate(dt); if (reportItem != null) { @@ -1591,6 +1592,22 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider log.put("result", report.getReport().toJSONString()); validationLogMapper.removeByDate(dt); validationLogMapper.save(log); + // 是否发送消息通知 + if (isSendMessage) { + List developers = managerMapper.listDetailsByRole(null, ManagerRole.DEVELOPER.getMask()); + List channelResults = report.getChannelResults(); + boolean valid = channelResults.stream().map(OrderValidationChannelResult::isSuccess).reduce(Boolean::logicalAnd).orElse(true); + StringBuilder statusString = new StringBuilder("订单校对已完成,状态:" + (valid ? "🌤️【成功】" : "🌨️【失败】")); + statusString.append("\r\n"); + for (OrderValidationChannelResult info : channelResults) { + if (info.isSuccess()) { + continue; + } + statusString.append(info.getChannel().getChannelCode()).append(": [ ").append(info.isSuccess() ? "成功" : "失败") + .append(StringUtils.defaultIfBlank(info.getErrorMsg(), "")).append(" ]").append("\r\n"); + } + publisher.publishEvent(new TaskFinishNotifyEvent(this, PlatformEnvironment.getEnv().getCompany() + " 订单校对", statusString.toString(), developers, valid)); + } return JSON.parseObject(log.getString("result")); } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java index dd7de3bc3..961caefda 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java @@ -59,10 +59,11 @@ public class FinancialController { @GetMapping("/order_validations/{date}") public JSONObject getCheckReport(@PathVariable String date, @RequestParam(defaultValue = "false") boolean fix, - @RequestParam(name = "use_cache", defaultValue = "true") boolean useCache) { + @RequestParam(name = "use_cache", defaultValue = "true") boolean useCache, + @RequestParam(name = "is_send_message", defaultValue = "false") boolean isSendMessage) { try { Date dt = DateUtils.parseDate(date, new String[]{"yyyyMMdd"}); - return cleanService.validTransactions(dt, fix, !useCache, false); + return cleanService.validTransactions(dt, fix, !useCache, false,isSendMessage); } catch (ParseException e) { throw new ParamInvalidException("date", "error.payment.valid.invalid_date_format"); } @@ -97,8 +98,8 @@ public class FinancialController { @GetMapping("/get/transaction/status/{transactionId}") public TransactionStatus getTransactionStatus(@PathVariable String transactionId) { - if(transactionId.isEmpty()){ - throw new ParamInvalidException("date","Transaction flow is empty"); + if (transactionId.isEmpty()) { + throw new ParamInvalidException("date", "Transaction flow is empty"); } return cleanService.getTransactionStatus(transactionId); } @@ -109,12 +110,11 @@ public class FinancialController { @RequestParam(value = "noCache") boolean noCache, @RequestParam(value = "billType", required = false) String billType, @RequestParam(value = "channel") String channel, - HttpServletResponse response) { + HttpServletResponse response) { ChannelReconciliationFileContent file = cleanService.downloadChannelReconciliationFile(pid, au.com.royalpay.payment.tools.utils.DateUtils.parseDate(billDate) , noCache, channel, billType); - try (InputStream in = new ByteArrayInputStream(file.content())) { response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.name(), Charsets.UTF_8.name())); response.setContentLength(file.length()); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java index f609a7fa1..bc3b6ae69 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.java @@ -32,12 +32,14 @@ public interface PlatformSettlementMapper { PageList findSettleLogsAllMerchant(@Param("channel") String channel, PageBounds pageBounds); - JSONObject calculateSysSettleLog(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type, @Param("wechat_rate") BigDecimal wechat_rate); + JSONObject calculateSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel, + @Param("pid") String pid, @Param("transaction_type") String type); - JSONObject calculateSysSettleLog5(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type); - - BigDecimal calculateRmbCharge(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel,@Param("ali_rate") BigDecimal ali_rate); + BigDecimal calculateRmbCharge(@Param("start_date") Date start_date, @Param("end_date") Date end_date, @Param("channel") String channel); @AutoSql(SqlType.DELETE) void delete(JSONObject params); + + JSONObject calculateChannelSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel, + @Param("transaction_type") String type); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java new file mode 100644 index 000000000..e819edb63 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java @@ -0,0 +1,20 @@ +package au.com.royalpay.payment.manage.mappers.system.aps; + +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +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_aps_config", pkName = "id") +public interface ApsConfigMapper { + + @AutoSql(SqlType.SELECT) + ApsConfigData findByClientId(@Param("client_id") String clientId); + + @AutoSql(SqlType.INSERT) + void saveApsConfigClientId(ApsConfigData apsConfigData); + + void updateApsConfigClientId(JSONObject apsConfigData); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java index a2db2971f..a593580db 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRegisterInfo.java @@ -68,6 +68,8 @@ public class ClientRegisterInfo { private String representativeEmail; @JSONField(name = "legal_representative_job") private String representativeJobTitle; + @JSONField(name = "legal_representative_id") + private String representativeId; @JSONField(name = "marketing_person") private String marketingPerson; @JSONField(name = "marketing_phone") @@ -690,4 +692,12 @@ public class ClientRegisterInfo { public void setMccode(String mc_code) { this.mc_code = mc_code; } + + public String getRepresentativeId() { + return representativeId; + } + + public void setRepresentativeId(String representativeId) { + this.representativeId = representativeId; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java new file mode 100644 index 000000000..3441146e0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java @@ -0,0 +1,13 @@ +package au.com.royalpay.payment.manage.merchants.core; + +import au.com.royalpay.payment.manage.merchants.deacriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import com.alibaba.fastjson.JSONObject; + +public interface ApsConfigService { + ApsConfigData getApsConfigByClientId(String clientId); + + ApsConfigData saveApsConfigClientId(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor); + + ApsConfigData updateApsConfigClientId(String managerId,String clientId, JSONObject apsConfig); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index f93d9ace8..cc2c54d13 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -1,7 +1,9 @@ package au.com.royalpay.payment.manage.merchants.core; +import au.com.royalpay.payment.channels.alipay.beans.plus.ApsMerchantApplication; import au.com.royalpay.payment.channels.rpaypaymentsvc.runtime.request.entities.RPayMerchantEntity; import au.com.royalpay.payment.core.beans.ChannelMerchantInfo; +import au.com.royalpay.payment.core.beans.MerchantApplicationResult; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean; @@ -604,4 +606,11 @@ public interface ClientManager { void selectBillCodeVersion(JSONObject manager, String clientMoniker, String version); + + MerchantApplicationResult alipayPlusRegisterMerchant(String clientMoniker, ApsMerchantApplication apsMerchantApplication, JSONObject manager);//alipayplus 注册商户 + + String queryAlipayPlusOnlineStatus(boolean isOffline,String clientMoniker, JSONObject manager); + + String queryAlipayPlusOfflineStatus(String clientMoniker, JSONObject manager); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java new file mode 100644 index 000000000..d06b65bb6 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java @@ -0,0 +1,38 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.aps.ApsConfigMapper; +import au.com.royalpay.payment.manage.merchants.core.ApsConfigService; +import au.com.royalpay.payment.manage.merchants.deacriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + + +@Service +public class ApsConfigServiceImpl implements ApsConfigService { + + @Resource + private ApsConfigMapper apsConfigMapper; + + @Override + public ApsConfigData getApsConfigByClientId(String clientId) { + return apsConfigMapper.findByClientId(clientId); + } + + @Override + public ApsConfigData saveApsConfigClientId(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor) { + ApsConfigData apsConfigData = ApsConfigData.saveData(managerId, clientId, apsConfigDescriptor); + apsConfigMapper.saveApsConfigClientId(apsConfigData); + return apsConfigMapper.findByClientId(clientId); + } + + @Override + public ApsConfigData updateApsConfigClientId(String managerId, String clientId, JSONObject apsConfig) { + apsConfig.put("clientId", clientId); + apsConfig.put("modifier", managerId); + apsConfigMapper.updateApsConfigClientId(apsConfig); + return apsConfigMapper.findByClientId(clientId); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 699e40147..74d68875f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,9 +1,12 @@ package au.com.royalpay.payment.manage.merchants.core.impls; +import au.com.royalpay.payment.channels.alipay.beans.plus.AlipayPlusRegisterResult; +import au.com.royalpay.payment.channels.alipay.beans.plus.ApsMerchantApplication; import au.com.royalpay.payment.channels.alipay.config.AlipayConfig; import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment; import au.com.royalpay.payment.channels.alipay.runtime.AlipayOnlineApi; import au.com.royalpay.payment.channels.alipay.runtime.AlipayRetailApi; +import au.com.royalpay.payment.channels.alipay.runtime.alipayplus.AlipayApsMerchantRegister; import au.com.royalpay.payment.channels.alipay.runtime.entity.AlipayMerchantEntity; import au.com.royalpay.payment.channels.rpay.runtime.beans.SubRpayMerchantInfo; import au.com.royalpay.payment.channels.rpay.runtime.impls.RPayMerchantRegister; @@ -55,13 +58,12 @@ import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMap import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper; import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.merchants.beans.*; -import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; -import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; -import au.com.royalpay.payment.manage.merchants.core.ClientManager; -import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; +import au.com.royalpay.payment.manage.merchants.core.*; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBank; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBankClientNullException; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBankInfo; +import au.com.royalpay.payment.manage.merchants.deacriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; import au.com.royalpay.payment.manage.merchants.entity.impls.*; import au.com.royalpay.payment.manage.merchants.enums.UPayAuthFileEnum; import au.com.royalpay.payment.manage.notice.core.MailService; @@ -113,6 +115,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; +import com.alipay.global.api.model.aps.ProductCodeType; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; @@ -280,10 +283,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private MailGunService mailGunService; @Resource - private ClearingDetailMapper clearingDetailMapper; - @Resource - private ClearingLogMapper clearingLogMapper; - @Resource private ClientConfigMapper clientConfigMapper; @Resource private PermissionPartnerManagerImpl permissionPartnerManagerImpl; @@ -328,7 +327,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private PaymentApi paymentApi; @Resource - private MerchantChannelPermissionManager merchantChannelPermissionManager; + private ApsConfigService apsConfigService; DateTimeFormatter formatter = DateTimeFormat.forPattern("dd MMM yyyy"); @@ -356,7 +355,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private String agreetemplatePdfPath; @Value("${app.agreetemplate.aggregate.path}") private String aggregateAgreetemplatePdfPath; -// private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf"; + // private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf"; private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2021/09/07/1630997571126_fqWcLQ5Rx0wFm8pVwpKuI1gjf6FmwX.pdf"; @@ -554,7 +553,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid resolver.newOrderEnabled(client, null, PlatformEnvironment.getEnv().getForeignCurrency())) { client.put("enable_alipayplus", true); } - + client.put("enable_alipayaps", false); + MerchantChannelPermissionResolver resolverApsInStore = this.paymentApi.channelApi(PayChannel.ALIPAY_APS_IN_STORE.getChannelCode()).getChannelPermissionResolver(); + MerchantChannelPermissionResolver resolverApsCashier = this.paymentApi.channelApi(PayChannel.ALIPAY_APS_CASHIER.getChannelCode()).getChannelPermissionResolver(); + if(!Objects.isNull(resolverApsInStore) && !Objects.isNull(resolverApsCashier) && + (resolverApsInStore.newOrderEnabled(client, null, PlatformEnvironment.getEnv().getForeignCurrency()) || + resolverApsCashier.newOrderEnabled(client, null, PlatformEnvironment.getEnv().getForeignCurrency()))){ + client.put("enable_alipayaps", true); + } + ApsConfigData apsConfig = apsConfigService.getApsConfigByClientId(client.getString("client_id")); + if (apsConfig == null) { + apsConfig = apsConfigService.saveApsConfigClientId(manager.getString("manager_id"), client.getString("client_id"), new ApsConfigDescriptor()); + } + client.put("aps_config_id", apsConfig.getId()); + client.put("alipay_cn_switch", apsConfig.getAlipayCnSwitch()); return client; } @@ -934,6 +946,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject representativeInfo = new JSONObject(); representativeInfo.put("client_id", clientId); representativeInfo.put("representative_person", info.getRepresentativePerson()); + representativeInfo.put("legal_representative_id", info.getRepresentativeId()); representativeInfo.put("phone", info.getRepresentativePhone()); representativeInfo.put("email", info.getRepresentativeEmail()); representativeInfo.put("job_title", info.getRepresentativeJobTitle()); @@ -1577,17 +1590,30 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) { + PayChannel payChannel = PayChannel.fromChannelCode(channel); + if(payChannel == PayChannel.ALIPAY_APS){ + ArrayList apsChannels = new ArrayList<>(); + apsChannels.add(PayChannel.ALIPAY_APS_IN_STORE.getChannelCode()); + apsChannels.add(PayChannel.ALIPAY_APS_CASHIER.getChannelCode()); + apsChannels.forEach(apsChannel->{ + extracted(manager, clientMoniker, apsChannel, allow); + }); + }else { + extracted(manager, clientMoniker, channel, allow); + } + } + + private void extracted(JSONObject manager, String clientMoniker, String channel, boolean allow) { for (PaymentChannelApi channelApi : paymentApi.channels()) { if (channelApi.channel().equalsIgnoreCase(channel)) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new NotFoundException("Client Not Exists"); } - merchantChannelPermissionManager.switchMerchantChannelPermission(channelApi.getMetadata().payChannel(), client.getIntValue("client_id"), allow); try { - clientModifySupport.processModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow)); + clientModifySupport.processModify(new SwitchChannelPermissionModify(manager, clientMoniker, merchantInfoProvider, channelApi.getChannelPermissionResolver(), allow)); } catch (Exception e) { - logger.error("Failed to change channel switch:{}", channel); + logger.error("Failed to change channel switch:{}", channel,e); } logger.info("{}({}) switched client {} channel {} to {}", manager.getString("display_name"), manager.getString("manager_id"), clientMoniker, channel, allow); if (allow && (StringUtils.equalsAnyIgnoreCase("Wechat", channel) || StringUtils.equalsAnyIgnoreCase("Alipay", channel))) { @@ -2004,12 +2030,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkAddRate(config, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); checkAddRate(config, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); checkAddRate(config, "CB_BankPay", "min_cb_bankpay_value", org, "min_cb_bankpay_rate"); + checkAddRate(config, "AlipayAps Retail Interchange Fee", "retail_interchange_fee_value", org, "min_retail_interchange_fee_rate"); + checkAddRate(config, "AlipayAps Retail Serivce Fee", "retail_service_fee_value", org, "min_retail_service_fee_rate"); + checkAddRate(config, "AlipayAps Online Interchange Fee", "online_interchange_fee_value", org, "min_online_interchange_fee_rate"); + checkAddRate(config, "AlipayAps Online Serivce Fee", "online_service_fee_value", org, "min_online_service_fee_rate"); configNewClientRate(config, clientId, "Wechat", "wechat_rate_value", org, "min_wechat_rate"); configNewClientRate(config, clientId, "Alipay", "alipay_rate_value", org, "min_alipay_rate"); configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); + configNewClientRate(config, clientId, "ApsInStore", "retail_interchange_fee_value", null, ""); + configNewClientRate(config, clientId, "ApsCashier", "online_interchange_fee_value", null, ""); addAlipayPlusRateConfig(config, clientId, PayChannel.ALIPAY_PLUS.getChannelCode()); } @@ -2050,12 +2082,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } else { List existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); existRate.stream().filter(existConfig -> { - if (existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time"))) { - return false; - } - return true; - } - ) + if (existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time"))) { + return false; + } + return true; + } + ) .forEach((rateLog) -> { rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1)); clientRateMapper.updateConfig(rateLog); @@ -2065,6 +2097,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (newConfig.getBigDecimal("cb_bankpay_rate_value") != null) { clientRateMapper.saveRate(newConfig); } + } else if ("ApsInStore".equalsIgnoreCase(channel)) { + newConfig.put("transaction_fee", newConfig.getFloatValue("retail_service_fee_value")); + clientRateMapper.saveRate(newConfig); + } else if ("ApsCashier".equalsIgnoreCase(channel)) { + newConfig.put("transaction_fee", newConfig.getFloatValue("online_service_fee_value")); + clientRateMapper.saveRate(newConfig); } else { clientRateMapper.saveRate(newConfig); } @@ -2130,7 +2168,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (config.containsKey(rateKey)) { if (org.containsKey(rateValueKey)) { if (config.getBigDecimal(rateKey).compareTo(org.getBigDecimal(rateValueKey)) < 0) { - throw new ForbiddenException("费率参数小于旗下商户最低" + channel + "费率,请重新输入"); } } @@ -2494,7 +2531,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject client = clientDetail(manager, clientMoniker); try { JSONObject qrboardConfig = new JSONObject(); - qrboardConfig.put("src", PlatformEnvironment.getEnv().concatUrl("/static/images/aggregate_qr_board.png")); + qrboardConfig.put("src", PlatformEnvironment.getEnv().concatUrl("/static/images/aggretage_aps_board.jpg")); qrboardConfig.put("type", "royalpay"); qrboardConfig.put("x", "835"); qrboardConfig.put("y", "1290"); @@ -2980,24 +3017,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("The Partner's Rate is not config!"); } client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); - client.put("clean", "T+"+weChatRate.getString("clean_days")); + client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } try { JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay"); @@ -3116,19 +3153,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); client.put("clean", "T+" + p.getString("clean_days")); client.put("clean_days", p.getString("clean_days")); - if("1".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + if ("1".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } } else if ("Alipay".equals(rate_name)) { client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); @@ -3205,21 +3242,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } try { @@ -4106,21 +4143,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } String rateConfig = sysConfigManager.getSysConfig().getString("sys_rates"); JSONObject sysConfigRate = JSON.parseObject(rateConfig); @@ -4201,7 +4238,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); JSONObject result = PageListUtils.buildPageListResult(logs); - result.put("padding", logs.stream().anyMatch(log->log.getBooleanValue("editable"))); + result.put("padding", logs.stream().anyMatch(log -> log.getBooleanValue("editable"))); logger.info("##editable{}", result.getBooleanValue("padding")); return result; } @@ -7066,6 +7103,57 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } + /** + * alipayplus(aps) 注册商户 + * + * @param clientMoniker + * @param apsMerchantApplication + * @param manager + * @return + */ + @Override + public MerchantApplicationResult alipayPlusRegisterMerchant(String clientMoniker, ApsMerchantApplication apsMerchantApplication, JSONObject manager) { + logger.info("====>getWebsiteType:" + apsMerchantApplication.getWebsiteType()); + logger.info("====>getProductCodes:" + apsMerchantApplication.getProductCodes().toString()); + boolean offline = apsMerchantApplication.getProductCodes().stream().allMatch(s -> s.equalsIgnoreCase(ProductCodeType.IN_STORE_PAYMENT.toString())); + logger.info("====>offline:" + offline); + if (offline) { + apsMerchantApplication.setPid(AlipayEnvironment.getEnv().getAlipayPlusApsRetailConfig().getPid()); + } else { + apsMerchantApplication.setPid(AlipayEnvironment.getEnv().getAlipayPlusApsOnlineConfig().getPid()); + } + apsMerchantApplication.setRegion("AU"); + + JSONObject client = sysClientMapper.findClientByMoniker(clientMoniker); + AlipayApsMerchantRegister alipayApsMerchantRegister = Optional.ofNullable(merchantChannelApplicationManager.getRegister(AlipayApsMerchantRegister.class)).orElseThrow(() -> new ServerErrorException("No AlipayAps registry found")); + + MerchantApplicationResult result = alipayApsMerchantRegister.apply(client, apsMerchantApplication, manager); + return result; + } + + @Override + public String queryAlipayPlusOnlineStatus(boolean isRetail, String clientMoniker, JSONObject manager) { + JSONObject client = sysClientMapper.findClientByMoniker(clientMoniker); + client.put("isRetail", isRetail); + String pid = ""; + if (isRetail) { + //todo 测试需要 先都改成线上,上线此处需要改成线下 + pid = AlipayEnvironment.getEnv().getAlipayPlusApsRetailConfig().getPid(); + } else { + pid = AlipayEnvironment.getEnv().getAlipayPlusApsOnlineConfig().getPid(); + + } + client.put("pid", pid); + AlipayApsMerchantRegister alipayApsMerchantRegister = Optional.ofNullable(merchantChannelApplicationManager.getRegister(AlipayApsMerchantRegister.class)).orElseThrow(() -> new ServerErrorException("No AlipayAps registry found")); + AlipayPlusRegisterResult alipayPlusRegisterResult = alipayApsMerchantRegister.findMerchant(client); + return alipayPlusRegisterResult.getRawResponse(); + } + + @Override + public String queryAlipayPlusOfflineStatus(String clientMoniker, JSONObject manager) { + return null; + } + private void exportLetterOfferPDF(String clientMoniker, JSONObject manage) { JSONObject info = convertClientLetterOfferInfo(clientMoniker); String pdfPath = this.getClass().getClassLoader().getResource("").getPath() + "/templates/pdf/letter_of_offer.pdf"; @@ -7261,6 +7349,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid representativeInfo.put("postcode", partner.getString("registered_postcode")); representativeInfo.put("state", partner.getString("registered_state")); representativeInfo.put("legal_representative_wechatid", partner.getString("legal_representative_wechatid")); + representativeInfo.put("legal_representative_id", partner.getString("legal_representative_id")); representativeInfo.put("marketing_person", partner.getString("marketing_person")); representativeInfo.put("marketing_phone", partner.getString("marketing_phone")); representativeInfo.put("marketing_email", partner.getString("marketing_email")); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/deacriptor/ApsConfigDescriptor.java b/src/main/java/au/com/royalpay/payment/manage/merchants/deacriptor/ApsConfigDescriptor.java new file mode 100644 index 000000000..cd63687e2 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/deacriptor/ApsConfigDescriptor.java @@ -0,0 +1,15 @@ +package au.com.royalpay.payment.manage.merchants.deacriptor; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class ApsConfigDescriptor { + + private Boolean alipayCnSwitch = false; +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java new file mode 100644 index 000000000..aca1c3bf3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java @@ -0,0 +1,44 @@ +package au.com.royalpay.payment.manage.merchants.entity; + + +import au.com.royalpay.payment.manage.merchants.deacriptor.ApsConfigDescriptor; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; +import java.util.UUID; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class ApsConfigData implements Serializable { + + private String id; + + private String creator; + + private Date createTime; + + private String modifier; + + private Date modifyTime; + + private String clientId; + + private Boolean enableAlipayAps; + + private Boolean alipayCnSwitch; + + public static ApsConfigData saveData(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor) { + return new ApsConfigData() + .setClientId(clientId) + .setId(UUID.randomUUID().toString().replace("-", "")) + .setAlipayCnSwitch(apsConfigDescriptor.getAlipayCnSwitch()) + .setCreator(managerId) + .setCreateTime(new Date()); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchChannelPermissionModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchChannelPermissionModify.java new file mode 100644 index 000000000..5328c3074 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchChannelPermissionModify.java @@ -0,0 +1,37 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation; +import au.com.royalpay.payment.tools.merchants.core.MerchantChannelPermissionResolver; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.JsonUtils; +import com.alibaba.fastjson.JSONObject; + +import java.util.function.Consumer; + +public class SwitchChannelPermissionModify extends ClientModifyOperation { + private final MerchantInfoProvider mchInfoProvider; + private final MerchantChannelPermissionResolver channelResolver; + private final boolean enableFlag; + + public SwitchChannelPermissionModify(JSONObject account, String clientMoniker, MerchantInfoProvider mchInfoProvider, MerchantChannelPermissionResolver channelResolver, boolean enableFlag) { + super(account, clientMoniker); + this.mchInfoProvider = mchInfoProvider; + this.channelResolver = channelResolver; + this.enableFlag = enableFlag; + } + + @Override + protected String business() { + return (enableFlag ? "开启 " : "关闭 ") + "渠道[" + channelResolver.payChannel().getChannelCode() + "]"; + } + + @Override + protected JSONObject getModifyResult() { + return JsonUtils.newJson(json -> json.put("enable_" + channelResolver.payChannel().getChannelCode(), enableFlag + "")); + } + + @Override + protected Consumer getModifyProcess() { + return client -> channelResolver.switchPermission(mchInfoProvider, client.getIntValue("client_id"), enableFlag); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java new file mode 100644 index 000000000..a67e25f67 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java @@ -0,0 +1,55 @@ +package au.com.royalpay.payment.manage.merchants.web; + +import au.com.royalpay.payment.manage.merchants.core.ApsConfigService; +import au.com.royalpay.payment.manage.merchants.deacriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +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("/sys/partners/aps") +public class ApsConfigController { + + @Resource + private ApsConfigService apsConfigService; + + /** + * 获取aps配置信息 + * + * @param clientId + * @return + */ + @GetMapping("/{clientId}") + public ApsConfigData getApsConfigByClientId(@PathVariable("clientId") String clientId) { + return apsConfigService.getApsConfigByClientId(clientId); + } + + /** + * 初始化aps配置 + * + * @param clientId + * @param apsConfigDescriptor + * @return + */ + @ManagerMapping(value = "/{clientId}", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SITE_MANAGER}) + public ApsConfigData saveApsConfigClientId(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable("clientId") String clientId, @RequestBody ApsConfigDescriptor apsConfigDescriptor) { + return apsConfigService.saveApsConfigClientId(manager.getString("managerId"), clientId, apsConfigDescriptor); + } + + /** + * 修改aps配置 + * + * @param clientId + * @param apsConfig + * @return + */ + @ManagerMapping(value = "/{clientId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SITE_MANAGER}) + public ApsConfigData updateApsConfigClientId(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable("clientId") String clientId, @RequestBody JSONObject apsConfig) { + return apsConfigService.updateApsConfigClientId(manager.getString("managerId"), clientId, apsConfig); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 4d9179838..0902ddb03 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -1,7 +1,9 @@ package au.com.royalpay.payment.manage.merchants.web; +import au.com.royalpay.payment.channels.alipay.beans.plus.ApsMerchantApplication; import au.com.royalpay.payment.channels.rpaypaymentsvc.runtime.request.entities.RPayMerchantEntity; import au.com.royalpay.payment.core.beans.ChannelMerchantInfo; +import au.com.royalpay.payment.core.beans.MerchantApplicationResult; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; import au.com.royalpay.payment.manage.merchants.beans.*; @@ -129,8 +131,10 @@ public class PartnerManageController { HttpServletResponse response) throws IOException { response.setContentType("application/octet-stream;"); response.addHeader("Content-Disposition", "attachment; filename=qr_board.jpg"); - OutputStream ous = response.getOutputStream(); - clientManager.writeAggregateQrCodeBoard(manager, clientMoniker, config, ous, "PC"); + try(OutputStream ous = response.getOutputStream()) { + clientManager.writeAggregateQrCodeBoard(manager, clientMoniker, config, ous, "PC"); + ous.flush(); + } } @ManagerMapping(value = "/{clientMoniker}/qrcode_board/CBBankAggregate", method = RequestMethod.GET) @@ -1057,4 +1061,34 @@ public class PartnerManageController { clientManager.modifyUPayProfile(manager, clientMoniker, pass.getString("key"), pass.getBooleanValue("allow")); } + /** + * alipayplus 商户注册 + * @param clientMoniker + * @param manager + * @return + */ + @ManagerMapping(value = "/{clientMoniker}/apply_alipayplus", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + public JSONObject applyAlipayPlusMerchant(@PathVariable String clientMoniker, @RequestBody ApsMerchantApplication apsMerchantApplication, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + MerchantApplicationResult result= clientManager.alipayPlusRegisterMerchant(clientMoniker,apsMerchantApplication,manager); + JSONObject jsonObject=new JSONObject(); + if(result.isSuccess()){ + jsonObject.put("result",true); + }else{ + jsonObject.put("result",false); + } + return jsonObject; + } + + @ManagerMapping(value = "/{clientMoniker}/query/alipay_aps_online", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + public JSONObject queryAlipayApsOnlineStatus(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + JSONObject result = new JSONObject(); + result.put("response_str", clientManager.queryAlipayPlusOnlineStatus(false,clientMoniker, manager)); + return result; + } + @ManagerMapping(value = "/{clientMoniker}/query/alipay_aps_retail", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + public JSONObject queryAlipayApsOfflineStatus(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + JSONObject result = new JSONObject(); + result.put("response_str", clientManager.queryAlipayPlusOnlineStatus(true,clientMoniker, manager)); + return result; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java index 6664a2dda..0b9b73f7b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java @@ -31,7 +31,7 @@ public class OrgInfo { private Double alipayonline_rate_value; private Double alipayplus_rate_value; private Double cb_bankpay_rate_value; -// private Double rpaypmt_card_rate_value; + // private Double rpaypmt_card_rate_value; //卡支付-国内卡费率配置 private Double rpaypmt_domestic_card_rate_value; //卡支付-国际卡费率配置 @@ -57,6 +57,14 @@ public class OrgInfo { private Double min_rpaypmt_dd_rate; private String state; private String senior_parent_org_id; + private Double retail_interchange_fee_value; + private Double min_retail_interchange_fee_value; + private Double retail_service_fee_value; + private Double min_retail_service_fee_value; + private Double online_interchange_fee_value; + private Double min_online_interchange_fee_value; + private Double online_service_fee_value; + private Double min_online_service_fee_value; public JSONObject toJsonParam() { @@ -328,6 +336,7 @@ public class OrgInfo { public void setState(String state) { this.state = state; } + public String getSenior_parent_org_id() { return senior_parent_org_id; } @@ -417,4 +426,67 @@ public class OrgInfo { this.min_rpaypmt_overseas_card_rate = min_rpaypmt_overseas_card_rate; } + public Double getRetail_interchange_fee_value() { + return retail_interchange_fee_value; + } + + public void setRetail_interchange_fee_value(Double retail_interchange_fee_value) { + this.retail_interchange_fee_value = retail_interchange_fee_value; + } + + public Double getMin_retail_interchange_fee_value() { + return min_retail_interchange_fee_value; + } + + public void setMin_retail_interchange_fee_value(Double min_retail_interchange_fee_value) { + this.min_retail_interchange_fee_value = min_retail_interchange_fee_value; + } + + public Double getRetail_service_fee_value() { + return retail_service_fee_value; + } + + public void setRetail_service_fee_value(Double retail_service_fee_value) { + this.retail_service_fee_value = retail_service_fee_value; + } + + public Double getMin_retail_service_fee_value() { + return min_retail_service_fee_value; + } + + public void setMin_retail_service_fee_value(Double min_retail_service_fee_value) { + this.min_retail_service_fee_value = min_retail_service_fee_value; + } + + public Double getOnline_interchange_fee_value() { + return online_interchange_fee_value; + } + + public void setOnline_interchange_fee_value(Double online_interchange_fee_value) { + this.online_interchange_fee_value = online_interchange_fee_value; + } + + public Double getMin_online_interchange_fee_value() { + return min_online_interchange_fee_value; + } + + public void setMin_online_interchange_fee_value(Double min_online_interchange_fee_value) { + this.min_online_interchange_fee_value = min_online_interchange_fee_value; + } + + public Double getOnline_service_fee_value() { + return online_service_fee_value; + } + + public void setOnline_service_fee_value(Double online_service_fee_value) { + this.online_service_fee_value = online_service_fee_value; + } + + public Double getMin_online_service_fee_value() { + return min_online_service_fee_value; + } + + public void setMin_online_service_fee_value(Double min_online_service_fee_value) { + this.min_online_service_fee_value = min_online_service_fee_value; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java index e77fcba6b..85bd6b282 100644 --- a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.TransactionService; import au.com.royalpay.payment.core.beans.PaymentQueryResult; import au.com.royalpay.payment.core.beans.PreOrderRequest; +import au.com.royalpay.payment.core.beans.TransactionBizSubType; import au.com.royalpay.payment.core.beans.coupon.CouponInfo; import au.com.royalpay.payment.core.events.PaymentFinishedEvent; import au.com.royalpay.payment.core.events.RefundSendEvent; @@ -66,6 +67,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { private PmtOrderMapper pmtOrderMapper; @Resource private TransactionService transactionService; + @Override public String processorId() { return COUPON_ID + "_USE"; @@ -102,11 +104,11 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { return; } JSONObject couponAccuessLog = new JSONObject(); - couponAccuessLog.put("client_id",order.getIntValue("client_id")); - couponAccuessLog.put("customer_openid","创建订单时无"); - couponAccuessLog.put("creation_date",new Date()); - couponAccuessLog.put("order_id",order.getString("order_id")); - couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id")); + couponAccuessLog.put("client_id", order.getIntValue("client_id")); + couponAccuessLog.put("customer_openid", "创建订单时无"); + couponAccuessLog.put("creation_date", new Date()); + couponAccuessLog.put("order_id", order.getString("order_id")); + couponAccuessLog.put("coupon_id", "CTRIP_" + tmpEle.getString("ctrip_coupon_id")); BigDecimal currentDiscount = paymentInfo.getDiscount(); //携程满减 if (StringUtils.equals(couponInfo.getString("type"), "31")) { @@ -178,13 +180,13 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { useCoupontrans.put("clearing_status", 0); useCoupontrans.put("system_generate", 1); useCoupontrans.put("remark", "Ctrip Coupon from Customer:" + couponLogId); - accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId,new PageBounds(Order.formString("last_update_date.desc"))).get(0); + accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))).get(0); if (accuessCouponLog != null) { - transactionService.saveTransaction(useCoupontrans); + transactionService.saveTransaction(useCoupontrans, TransactionBizSubType.COUPON_PAY); accuessCouponLog.put("is_valid", 1); accuessCouponLog.put("last_update_date", new Date()); accuessCouponLog.put("transaction_id", useCoupontrans.getString("transaction_id")); - accuessCouponLog.put("customer_openid",order.getString("customer_id")); + accuessCouponLog.put("customer_openid", order.getString("customer_id")); payCouponAccuessLogMapper.update(accuessCouponLog); } @@ -221,7 +223,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { trans.put("transaction_time", new Date()); trans.put("remark", "Refund for Customer Ctrip Coupon:" + coupon_id); logger.info("正在退款的券的信息" + trans.toJSONString()); - transactionService.saveTransaction(trans); + transactionService.saveTransaction(trans, TransactionBizSubType.COUPON_REFUND); logger.error("订单[" + orderId + "]发送全额退款,携程优惠券【" + coupon_id + "】转为Debit"); accuessCouponLog.put("transaction_refund_id", trans.getString("transaction_id")); accuessCouponLog.put("refund_id", refundOrder.getString("refund_id")); @@ -238,7 +240,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { } // 使用券的信息 - private JSONObject getPreOrderCoupon(String couponLogId,int clientId) { + private JSONObject getPreOrderCoupon(String couponLogId, int clientId) { JSONObject client = merchantInfoProvider.getClientInfo(clientId); String timestamp = System.currentTimeMillis() + ""; String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE; diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index f6994b403..bcf04c06c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -15,7 +15,6 @@ import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper; import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskOrdersMapper; import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.notice.core.MailService; -import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskMaterialService; @@ -143,8 +142,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo private final Map senderMap = new HashMap<>(); - @Resource - private APNSMessageHelper apnsMessageHelper; @Resource private CardSecureService cardSecureService; @Resource 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 index eaff387e0..8bf35a179 100644 --- 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 @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.rservices.core.impl; import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.core.beans.TransactionBizSubType; import au.com.royalpay.payment.core.mappers.PmtOrderMapper; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; @@ -166,7 +167,7 @@ public class RServicesApplyServiceImpl implements RServicesApplyService { transaction.put("clearing_status", 0); transaction.put("remark", applyInfo.getString("service_code") + ":" + applyInfo.getString("title")); transaction.put("system_generate", 1); - transactionService.saveTransaction(transaction); + transactionService.saveTransaction(transaction, TransactionBizSubType.OTHER); JSONObject order = new JSONObject(); order.put("order_id", orderId); order.put("org_id", client.getIntValue("org_id")); diff --git a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java index d1b69b508..802553c7e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java @@ -40,8 +40,4 @@ public class SettleEstimateTaskManger { synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs()); } - @Scheduled(cron = "0 0 10 * * ?") - public void generateSettleLogs2() { - synchronizedScheduler.executeProcess("manage_task:generateAliPaySettleLog", 120_000, () -> platformClearService.generateAliPaySettleLogs()); - } } 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 46ffd3ea3..f12d777cd 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 @@ -3,9 +3,9 @@ package au.com.royalpay.payment.manage.tradelog.core.impls; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog; import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.TransactionService; +import au.com.royalpay.payment.core.beans.SettlementLog; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.OrderNotMatchException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; diff --git a/src/main/resources/application-alipay.yml b/src/main/resources/application-alipay.yml index a9ddd3791..5214a7459 100644 --- a/src/main/resources/application-alipay.yml +++ b/src/main/resources/application-alipay.yml @@ -2,16 +2,68 @@ app: alipay: host: https://mapi-hk.alipay.com/gateway.do merchants: - online: - key: hmwjrganlzb4aqgggdgdlod7l3lsjkn6 + - key: hmwjrganlzb4aqgggdgdlod7l3lsjkn6 pid: 2088821643021586 + pid-type: ONLINE + biz-type: ONLINE private-key: classpath:data/crypt/alipay_private.pem public-key: classpath:data/crypt/alipay_public.pem sftp-password: XNBB3S sftp-username: openvisePTY - retail: - key: jb5mt4vhtlzg1xlc0k967sib7v81sba6 + - key: jb5mt4vhtlzg1xlc0k967sib7v81sba6 pid: 2088721525235246 + pid-type: RETAIL + biz-type: RETAIL sftp-password: XNBB3S sftp-username: openvisePTY - sftp-host: sftp.alipay.com + - pid: SANDBOX_5Y2Z6G2Y6CD006426 + bill-pid: '' + pid-type: CONNECT + biz-type: RETAIL + api-prefix: /ams + private-key-string: |- + MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC7Q56Mi0ESd7lIImLl/qvoHry8M1pg6qMyzzsMsHe6kMMculI7B7G2/fGpSS2JC46jZrVRb/fYf1NLehhAh1MK51md/7dEgqjkowtXIjhEQTPXwTWWkxtnb/l+KoqWtBrkOfMIef+O6QbqvveneLlCq9wMnvKNsj0p9GtUKxYUyxY8Nwuc2tf2wG2zKuh0JoRMLMRMayr7WdhAy4jatJS5pDjJqoIxyhD6X7fPleoeJgzyYSZAPgnH01TSO5ePFQZ/7SxDRC8+D5rAnefsridaabmeBQG2QWf4Gz7qPuavnZfwKzkjptj390+D0PAR3f3JCvYXTrRRUGKdVpiuuFAbAgMBAAECggEBAJrmxUjWi9494Kq1nv9HGWYpvs8i33jZvmNyHhNSCcfupSanTQv9QljvWK5ClQMO509sz0FtECQqtnjxpwwBpISZeH0EoNFwD0sJP4E1EjwLf1nSPYSvbPS0IDnn8LnWg4QUF2AEoovRYGJf0zXZ2801ohFijZr+PC/vObTm6x4IsVasse+urTpAKb1XBnkOF2eKFTM4JdRHFSl4Uk0npdPtULUEvACpsORrBVjJz1dWjIkvHeOrqv5rKR1bxuRlhiDcVoDb7oDD3KIqR93YljOI0mdXLm2DuboGEpj0yKZYU+RaPWxMOErRT99UIAAVpPDVjGKZdt95K6BrWoqxq7kCgYEA5bzUMCM6/0jLt/kmuwkOF+zckz4DLtWFlosGrf658of9PQIvjkZbun3TcpJ2aQ8g7k2qFAUvwc5Uy5G0lW+uCIRA7zcKd2Rz4Rb4Q8qgI+9bIOuDjmvg36zOvqg3xuepoYq/2jcFGR+cBFGpbEu0VWESW3vytDsMosDp4xYkvt0CgYEA0KvSnx9ZqNHINQJCTgLd+mWbEv4lTSDXwi/OBtS8O7tTQRw73OkpOXobXv/vhTV4KimPOWTFFSEZcY7Rl0eyFV7rQD+gIioTCpt4m/ez/zImCv11tQWBqa/GoqZ0d0P9HPgmVjMh8Be0CVTEzGgXeOD2mcP+0WJCns/Js2s2j1cCgYEAk6EOMYjSJq4eyzA+JT6iYdmBvNTCstvfJmhceH8R+rpMj2HSMXkhBOxKbnuTv9tK7BfYTVkv4Ti34MDW7JiBm1NxbsdN4H8av/BExTt2QOFVDAiL13+XV+TyTi5G+Xhw1zAULSPiEMzxMw1O9BqJ3butUkCKLCst6YBSS+0027kCgYEAn+BFiyzV4QZ5wkNs0aBYupRGcBLQOXvEUz+VNp6faZRogSZEp0jtEOCBQBQPS5xf6M3Wsj6G0V1+xQaLhsCjrMQAskUNR5+83w+nJLhv7EJb62euW3dQlNXb9ppZ+VbaAuwNU1Xx1qYShmOwNHw8H50c00rbXUlPiaXh/9lRABkCgYBC9cIcIEutg3hmOlGrRVSSNnuYVO2MuLAIK1KnQftpZHZ+euuCnhPaoC3ZOtenWoBwgS6qV4Mpxq30qcc/mUouErpqUcrNxawlVgWjTSwNd6rT2MBg1lcOxpqsR9ZWolBp4nHvnbLxhI+2KiXpRV9Y8Gbkw1jI8/tMYcSEJsOfEA== + public-key-string: |- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqME6KAPZcMlFuy19J+RAj34PaS6iuyjINzQvdjR808IeVQAcLdUULMEgCTSQLshC606GFoGkN5nOouoMCZQmPv9hbZSWcDHMrPNNVYuAqwk0N80FSnASNPtlucoqzVjAaqgXD88hqjODCIS/b9LWrprCA3q3aAfVQu3eQLoFM1nn9EdznCp0uVClHgLtwj1rMRkjN+4CSwOW66/RNzsgnDJMkrTlRDeJCrbdXAs0Q3MWQEQv2z1fd34U1yyY2StkHbfKAVp2cCzhSl26K3LcCooDv9VDSv3BDH58sBQ8TIprIW0EsDA4jbLXEDEKXIjqIOaC/+x8jXyRpci17ZvRowIDAQAB + pid-host: https://open-sea.alipay.com + - pid: SANDBOX_5Y372Y2YBKQN02382 + bill-pid: 'Z02TE1650000000A' + pid-type: APS + biz-types: + - ONLINE + - RETAIL + api-prefix: /aps + private-key-string: |- + MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDWXsXs+dZPb/cd + BSmffOCjjoXLBQmAtrr9etHQBRUARP2jROppMYlvpfHkBvDlSs8mkz5dNeFF9L0z + QblRWxgW2658nq6u833CjPgTROsLEQZIrJuGCWwQuNslv8ACoKW/FippMDLnDUfk + /41TfzIiMhVrAUuy7P14pa/O8fIrDXMU/G1jknhPfvpLqkPfAB9N2Bf/F61XZsNN + 3Xco8X/wW8EdGaw1NdS2hjNvAvuxlcVexqPwXoECJgPQNip/9G/a+8NmKn7hLL1V + 8eXyC2J5pBMGq+H52Z2Su/jTyK9h5Qs9j42rQaBp06PHxfK4PhziIVaskLSqNO+j + IrONpumzAgMBAAECggEAEepHtj9G5sqfp0A4M0j3aRPPIKFiIuyige6SvETAdY5O + eCeZQ4NNThRbO8hMt4zh9QJXMuj+057ZdQAoIaFwSPDBC08joCFfQDQRw2J+FiWt + FcO/F5uP+XHJdsUooc+VKnwKvVG231Jf0MZ+pBy8Ltlqqs+n6OMfZ8bJA416xJgq + 35tfzKA1orpXtMk8YF7RrCnUlAxYWG5t30kqS/i7k0XtnaG26f0x/TllA+bT8G0I + Sv6JHlJYUh7GwjRmvt9DWnCIWCfr0HnIfDG28Hj1ZrIgpCULiM9/0JHB0DYj7xWn + kIYnN8M+aPi0uc10GPKpf6Z9d6BfKlTjkwjSSBADGQKBgQD9lPqEBUuYQYrG+mqJ + 3eQQ/ydt7LJ+q9k2Nv0v0yxp2VeZfGHy3IpJzL3tg38+YXY+BpUa30QjyEjD+TCz + +9Q/DR/d0chR+2+ZKB69RA39GjLNvebS6IogAzZi0+a4h48iB+4o9E39vJNZEfZt + ICa+QYBdfJuJ/hYfmmeVafTixwKBgQDYahML6Oj14qw+8ymEXToPwdYRs7+bikiw + BKU3t5jj+74kYGMBA5i1AdYA9pl7QZaLUPToPOyfG+YWzWKes1VrAq55h3h44S1S + REBK7pct9EmeXBajAmYJf+4smamWgmNvfOB1f6K4Bvz/wr/eSiOAXBtt2OMKe1H/ + kr0E85XVtQKBgCftYDCPYOK9VyuTXFkO3g0rD7tILKazSkU2DVGNb43PEfLx2b5S + qVeLbFBMhyl8URDdGncbtm/n5kUtJFUCjt3KpDzZ/i+iZmT4Izbr00QJ7vvkLccB + pFX8C4EuGkLt3USfeQlrxifwnEbHBEUUbeVBDQQrTZZBspwRRMQK5esbAoGAT7bi + xSRJiyivYZCX3lWoqV0wyNx424YYOB297cQG4RM9epC2Zw04FpRSi5BKAIisNyze + yRyH3COeoQ+OH/7Wm9AlDEbGLWBkHUVemTtBHIA7DcXF4M1lYGJrDKqdOP9WOR66 + Xw1gloCceGj3251bblB/GfslxhqenZEjZsuCiXECgYAYSe9ZS2pK06NG/0qqEK2t + LktRAEZLMZNKoCfTZ73Tv/3RbIKOTih/0u1esAz8ZNDba1rCY/Yk7tEnn7TdBmh6 + tZ2ioys08F2bZingLcTGes1s86/ideNGeoKT2e+071dD/AfdTqchaFRZdYlyPrF7 + Geg8LExk9alI9NEyoD7cKA== + public-key-string: |- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkuBPpcDeFpO12FUgi4UGHWCJ6OdPp0GVvYFUSJzJ+KNUodFpmgw306rNA+0Q5Bn/mw9aaqGCCmZYPpF4TnzGqQcLrAFABW+tpUfGj3WwNndhLyCBnqvp740iufsCaLvzlZyQplL8CBQ4AQPdIVa4YlCiX+AxJNq+kXsNvgUKK0iDLujYE6XzgjOCSq03tFfY3ry58DoEvf86WmS+fP7zAl77kmDf1CmJa5V06aviUlzmuyo/p8m3fUucB1Fv3WNF7qRpNPkMuL6jjHenb9LzWr1tieRTd7mZxOd9KOq75CJiX4XiTHhWbvd2pW/NIkDPZ9dAJPSK57mrh+e7zgT2pQIDAQAB + pid-host: https://open-sea.alipayplus.com + enabled: true + sftp-username: test_upload + sftp-password: 123456 + sftp-host: sftp-dev.alipay.com diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8be115e3d..82aa7edc2 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,15 +4,65 @@ spring: host: 192.168.0.92:3306 jdbc-url: jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false password: SuTUUxyvzS0cLETi6Rzm - schema-name: royalpay_payment + schema-name: royalpay username: rpaydev slave: - host: 192.168.0.84:3306 + host: 192.168.0.92:3306 jdbc-url: jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false - password: rpayplus123 + password: SuTUUxyvzS0cLETi6Rzm schema-name: royalpay - username: root + username: rpaydev type: com.zaxxer.hikari.HikariDataSource +#spring: +# datasource: +# master: +# host: office.geekforbest.com:33306 +# jdbc-url: jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# username: rpaydev_out +# schema-name: royalpay +# password: SuTUUxyvzS0cLETi6Rzm +# slave: +# host: office.geekforbest.com:33306 +# jdbc-url: jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# username: rpaydev_out +# schema-name: royalpay +# password: SuTUUxyvzS0cLETi6Rzm + + +#spring: +# datasource: +# master: +# host: 127.0.0.1:3306 +# jdbc-url: jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# password: dalong +# schema-name: royalpay_payment +# username: root +# slave: +# host: 127.0.0.1:3306 +# jdbc-url: jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# password: dalong +# schema-name: royalpay_payment +# username: root +# type: com.zaxxer.hikari.HikariDataSource +#spring: +# datasource: +# master: +# host: 119.28.3.196:3310 +# jdbc-url: jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# password: read0nly +# schema-name: royalpay_production +# username: readonly +# slave: +# host: 119.28.3.196:3310 +# jdbc-url: jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +# password: read0nly +# schema-name: royalpay_production +# username: readonly +# type: com.zaxxer.hikari.HikariDataSource +# redis: +# database: 1 +# host: 127.0.0.1 +# port: 6379 redis: database: 1 host: 192.168.0.84 @@ -23,10 +73,10 @@ spring: app: run-tasks: false host: - main: http://192.168.0.38:5000/ + main: http://dalong-au.dev.rpaygroup.com/ regions: - au: http://192.168.0.38:5000/ - cn: http://192.168.0.38:5000/ + au: http://dalong-au.dev.rpaygroup.com/ + cn: http://dalong-au.dev.rpaygroup.com/ mail: appid: 1 host: https://dev.mailsupport.hcqtech.com diff --git a/src/main/resources/application-wechat.yml b/src/main/resources/application-wechat.yml index 81e6528c4..e78baaea7 100644 --- a/src/main/resources/application-wechat.yml +++ b/src/main/resources/application-wechat.yml @@ -1,23 +1,23 @@ app: wechatpay: - api-host: https://apihk.mch.weixin.qq.com + api-host: https://api.mch.weixin.qq.com merchants: '1307485301': app-id: wx703febcbd34dae38 example-sub-merchant-id: 11755174 - key-file: classpath:apiclient_cert.p12 + key-file: /Users/qingjiaoxuan/extra/apiclient_cert.p12 mch-key: 7e2d8c4aab15e4cabec1207ba79086b1 merchant-id: 1307485301 '1431999902': app-id: wx703febcbd34dae38 example-sub-merchant-id: 42991963 - key-file: classpath:apiclient_new_cert.p12 + key-file: /Users/qingjiaoxuan/extra/apiclient_new_cert.p12 mch-key: p3tgzrAJbe6eQrunbv8jb8gz5yXxvJdE merchant-id: 1431999902 '1487387142': app-id: wx3e14d1144d898197 example-sub-merchant-id: 117551742 - key-file: classpath:napclient_cert.p12 + key-file: /Users/qingjiaoxuan/extra/napclient_cert.p12 mch-key: OuvLIL93STqFhTngNaBGT8751ZJn4FKL merchant-id: 1487387142 mp-id: globalpay diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 07c32bfb3..8e4176c97 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,7 +2,7 @@ server: port: 5555 spring: profiles: - active: dev,alipay,bestpay,jd,wechat,rpay,yeepay,rppaysvc,common + active: dev,alipay,bestpay,jd,wechat,rpay,yeepay,rppaysvc,common,alipayplusaps mail: host: '' port: '' @@ -90,7 +90,7 @@ android: apple: message: apns: - file: src/main/resources/dev.p12 + file: classpath:dev.p12 password: HQeYblIajOb0 saneboxMode: true customer: diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml index 24eea92c2..dea1108de 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml @@ -344,6 +344,12 @@ ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount, ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count, ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'AlipayOnline',TRUE,NULL)),0) alipayonline_client_count, + ifnull(sum(CASE WHEN s.channel = 'ApsInStore' THEN s.total ELSE 0 END),0) apsinstoreamount, + ifnull(sum(CASE WHEN s.channel = 'ApsInStore' THEN s.orders ELSE 0 END),0) apsinstore_order_count, + ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'ApsInStore',TRUE,NULL)),0) apsinstore_client_count, + ifnull(sum(CASE WHEN s.channel = 'ApsCashier' THEN s.total ELSE 0 END),0) apscashieramount, + ifnull(sum(CASE WHEN s.channel = 'ApsCashier' THEN s.orders ELSE 0 END),0) apscashier_order_count, + ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'ApsCashier',TRUE,NULL)),0) apscashier_client_count, ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.total ELSE 0 END),0) hfamount, ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.orders ELSE 0 END),0) hf_order_count, ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'hf',TRUE,NULL)),0) hf_client_count, diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml index 98529f116..a9ed6893d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/PlatformSettlementMapper.xml @@ -11,18 +11,17 @@ - - + SELECT sum(t.cny_amount) rmb_amount, + ifnull(sum(t.clearing_amount), 0.00) aud_amount, + ifnull(sum(t.channel_surcharge), 0.00) charge_amount + FROM pmt_transactions t + WHERE order_channel = #{channel} + AND transaction_type = #{transaction_type} + AND transaction_time >= #{start_date} + AND #{end_date} > transaction_time + and system_generate = 0 \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index e0f911fc8..46631b45b 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -18,6 +18,7 @@ o.client_order_id, o.gateway, o.channel, + o.pay_type, o.pre_authorization, p.client_moniker, p.short_name, @@ -48,6 +49,7 @@ o.confirm_time pay_time, o.pre_authorization, o.source, + o.pay_type, CASE o.status WHEN 0 THEN 'SUBMITTING' @@ -159,7 +161,7 @@ select oo.order_id,oo.client_id,oo.total_amount,oo.display_amount, oo.customer_payment_amount,oo.coupon_payment_amount,oo.currency, oo.create_time,oo.confirm_time,oo.status,oo.order_description,oo.order_detail, - oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id,oo.source + oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id,oo.source,oo.pay_type from pmt_orders oo @@ -301,7 +303,7 @@ select oo.order_id,oo.client_id,oo.total_amount,oo.display_amount, oo.customer_payment_amount,oo.coupon_payment_amount,oo.currency, oo.create_time,oo.confirm_time,oo.status,oo.order_description,oo.order_detail, - oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id,oo.source + oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id,oo.source,oo.pay_type from pmt_orders oo diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml new file mode 100644 index 000000000..3c0630c8f --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + UPDATE sys_client_aps_config SET modify_time = now(), modifier = #{modifier} + , alipay_cn_switch = #{alipayCnSwitch} + , enable_alipayaps = #{enableAlipayAps} + WHERE client_id = #{clientId} + + + \ No newline at end of file diff --git a/src/main/ui/static/analysis/channels_analysis.js b/src/main/ui/static/analysis/channels_analysis.js index 3a14cdab3..8f00f77fb 100644 --- a/src/main/ui/static/analysis/channels_analysis.js +++ b/src/main/ui/static/analysis/channels_analysis.js @@ -173,7 +173,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' trigger: 'axis' }, legend: { - data: ['Alipay交易金额','AlipayOnline交易金额', 'Bestpay交易金额','Wechat交易金额',"JD Pay交易金额","HF Pay交易金额","Yeepay交易金额","LakalaPay交易金额","Card Payment交易金额","Direct Debit交易金额"], + data: ['Alipay交易金额','AlipayOnline交易金额', 'Bestpay交易金额','Wechat交易金额',"JD Pay交易金额","HF Pay交易金额","Yeepay交易金额","LakalaPay交易金额","Card Payment交易金额","Direct Debit交易金额","Alipay+交易金额","Alipay+(Online)交易金额"], bottom: 0, height: '15%', width: '80%', @@ -185,7 +185,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' type: 'value' } ], - color: ['#00a0e9','#00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec"] + color: ['#00a0e9','#00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec","#8f4b2e","#87843b","#f8aba6"] }, xAxis: { basic: {type: 'category', boundaryGap: false}, @@ -301,6 +301,28 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' yAxisIndex: 0 }, column: {key: 'rpaypmt_dd.total'} + }, + { + basic: { + name: 'Alipay+交易金额', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsInStore.total'} + }, + { + basic: { + name: 'Alipay+(Online)交易金额', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsCashier.total'} } ] }; @@ -311,7 +333,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' trigger: 'axis' }, legend: { - data: ['Alipay交易订单','AlipayOnline交易订单', 'Bestpay交易订单','Wechat交易订单',"JD Pay交易订单","HF Pay交易订单","Yeepay交易订单","LakalaPay交易订单","Card Payment交易订单","Direct Debit交易订单"], + data: ['Alipay交易订单','AlipayOnline交易订单', 'Bestpay交易订单','Wechat交易订单',"JD Pay交易订单","HF Pay交易订单","Yeepay交易订单","LakalaPay交易订单","Card Payment交易订单","Direct Debit交易订单","Alipay+交易订单","Alipay+(Online)交易订单"], bottom: 0, height: '15%', width: '80%', @@ -323,7 +345,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' type: 'value' } ], - color: ['#00a0e9','00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec"] + color: ['#00a0e9','00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec","#8f4b2e","#87843b","#f8aba6"] }, xAxis: { basic: {type: 'category', boundaryGap: false}, @@ -439,6 +461,28 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' yAxisIndex: 0 }, column: {key: 'rpaypmt_dd.orders'} + }, + { + basic: { + name: 'Alipay+交易订单', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsInStore.orders'} + }, + { + basic: { + name: 'Alipay+(Online)交易订单', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsCashier.orders'} } ] }; @@ -448,7 +492,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' trigger: 'axis' }, legend: { - data: ['Alipay交易客单价','AlipayOnline交易客单价', 'Bestpay交易客单价','Wechat交易客单价',"JD Pay交易客单价","HF Pay交易客单价","Yeepay交易客单价","LakalaPay交易客单价","Card Payment交易客单价","Direct Debit交易客单价"], + data: ['Alipay交易客单价','AlipayOnline交易客单价', 'Bestpay交易客单价','Wechat交易客单价',"JD Pay交易客单价","HF Pay交易客单价","Yeepay交易客单价","LakalaPay交易客单价","Card Payment交易客单价","Direct Debit交易客单价","Alipay+交易客单价","Alipay+(Online)交易客单价"], bottom: 0, }, yAxis: [ @@ -457,7 +501,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' type: 'value' } ], - color: ['#00a0e9','#00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec"] + color: ['#00a0e9','#00a0e9','#FF2D96','#09bb07','#DC0808',"#FFFF33","#66ff00","#00b0ec","#8f4b2e","#87843b","#f8aba6"] }, xAxis: { basic: {type: 'category', boundaryGap: false}, @@ -573,6 +617,28 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' yAxisIndex: 0 }, column: {key: 'rpaypmt_dd.single_amount'} + }, + { + basic: { + name: 'Alipay+交易客单价', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsInStore.single_amount'} + }, + { + basic: { + name: 'Alipay+(Online)交易客单价', + type: 'line', + label: {normal: {show: true}}, + showAllSymbols: true, + showSymbol: true, + yAxisIndex: 0 + }, + column: {key: 'ApsCashier.single_amount'} } ] }; diff --git a/src/main/ui/static/analysis/templates/channels_analysis.html b/src/main/ui/static/analysis/templates/channels_analysis.html index d709513bc..021044d45 100644 --- a/src/main/ui/static/analysis/templates/channels_analysis.html +++ b/src/main/ui/static/analysis/templates/channels_analysis.html @@ -140,8 +140,12 @@ - + Alipay+ + Alipay+(Online) @@ -159,21 +163,21 @@
交易总金额变化趋势
-
订单数变化趋势
-
客单价变化趋势
-
diff --git a/src/main/ui/static/analysis/templates/manage_customers_orders.html b/src/main/ui/static/analysis/templates/manage_customers_orders.html index 3b58fe431..db3d77c35 100644 --- a/src/main/ui/static/analysis/templates/manage_customers_orders.html +++ b/src/main/ui/static/analysis/templates/manage_customers_orders.html @@ -85,22 +85,18 @@ Ye
-

- +

+
-
-
- - -
-
-
- -
- -
-
-
- -
-

- - - -

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - - - -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
- - % -
-
-
-
-
-
- -
- - % -
-
-
-
-
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
-
- -
- - % -
-
- + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ + % +
+
+
+
+
+
+
- + %
-
--> - - -
- -
- - % -
-
- - -
- -
- - % -
-
+
+
+
-
- -
- - % -
-
-
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
-
-
- -
- - % -
-
-
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
+
+
+
China Wallets Rate
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+ +
+
+
+ +
+
+ - -
- - % -
-
-
- -
- - % -
-
-
-
--> +
+
- -
- -
- - % -
-
+
+
Card Payment Rate
+
+
+ +
+ +
+
+ + % +
+
+
+ +
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+ +
+ +
+
+ + % +
+
+
+ +
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
- -
- -
- - % -
-
+
+
Alipay+ Rate
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
-
- -
- - % -
-
-
-
+
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - Back -
- - -
-
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
UsernameDisplay NameWechatCreate TimeEmailRolesOperation
- {{manager.nickname}} - - - - - - - - - - - - - Modify - | - Disable -
-
- -
-
-
-
- - -
-
- -
-

- {{org.gateway_short_id||'初始化'}} - -

-
-
-
- -
- View -
-
-
- - -
-
-
- -
-
- -
- -
-
-
-
- -
-
-
- 禁用 -   超期提醒   -   等待合规   -   绿色通道   -   通过   -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Partner CodePartner NameSub Mch IDRegister TimeCompliance StatusOrganizationBDOperation
- - - - (已禁用) - - - - - 通过({{partner.approve_time}}) - 资料完善中 - (自助开通)资料完善中 - 自助开通试用中({{partner.approve_time}}~{{partner.expiry_time}}) - 不通过({{partner.approve_time}}) - 申请打回({{partner.refuse_remark|limitTo:15}}) - 等待合规 - 自助开通(等待合规) - 合同制作完成 - 等待BD上传材料审核 - 绿色通道申请中 - 等待合规 - - - Detail - -
-
- -
-
- -
-
-
-
商户新增趋势
-
-
-
-
-
-
-
-
-
-
交易额趋势
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
- -
- ~ -
- -
+
+
+
+
+
+
+ +
+
+
+ +
+ ~ +
+ +
-
- Today -
-
- Yesterday -
- - - -
- This Year -
- +
+ Today +
+
+ Yesterday +
+ + + +
+ This Year +
+ +
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- -
交易分布
-
-
-
-

组织总交易额

-
- - - - - - - - - - - - - -
OrganizationAmount ($)
- -
+
+
+
+ +
交易分布
+
+
+
+

组织总交易额

+
+ + + + + + + + + + + + + +
OrganizationAmount ($)
+ +
+
+
+

{{chooseOrg}} 合伙人商户交易量排名

+
+ + + + + + + + + + + + + + + + + + + + + +
RankingPartnerAUD AmountRankingPartnerAmount
+ + {{sale[0].client_moniker}} + + + + {{sale[1].client_moniker}} + +
+ +
+
+
+
+ +
+
-
-

{{chooseOrg}} 合伙人商户交易量排名

-
- - - - - - - - - - - - - - - - - - - - - -
RankingPartnerAUD AmountRankingPartnerAmount
- - {{sale[0].client_moniker}} - - - - {{sale[1].client_moniker}} - -
- -
+ + +
+
合伙人提成
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
名称时间交易金额商户总手续费Royalpay手续费合伙人提成提成分润支付渠道
{{clientExtracts.year | limitTo:10}} - {{clientExtracts.month | limitTo:10}} + + + + + {{clientExtracts.channel}} +
+
+
-
-
- -
-
-
- - -
-
合伙人提成
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
名称时间交易金额商户总手续费Royalpay手续费合伙人提成提成分润支付渠道
{{clientExtracts.year|limitTo:10}} - {{clientExtracts.month|limitTo:10}} - - - - {{clientExtracts.channel}} -
-
- -
-
- -
-
- -
- -

-
-
-
- - -
- + + +
+
+ +
+ +

+
+
+
+ + +
+ +
-
diff --git a/src/main/ui/static/config/organizations/templates/org_detail_parent.html b/src/main/ui/static/config/organizations/templates/org_detail_parent.html index 2da1eb371..eb6ece584 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail_parent.html +++ b/src/main/ui/static/config/organizations/templates/org_detail_parent.html @@ -104,115 +104,6 @@ -
-
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
-
- -
- - % -
-
-
- -
-
- -
- - % -
-
-
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
- -
- -
- - % -
-
-
@@ -286,6 +177,533 @@ id="remark-input" maxlength="500"> + +
+
+
China Wallets Rate
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+ +
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+ +
+
+
+ +
+
Card Payment Rate
+
+
+ +
+ +
+
+ + % +
+
+
+ +
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+ +
+ +
+
+ + % +
+
+
+ +
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
+ +
+
Alipay+ Rate
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+ +
+
+ + % +
+
+
+
+
+
+ +
+
+ +
+
+

Alipay+ Logs

+
+
+

No Data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date StartDate EndSettle DatePay FeeRefund FeeNet FeePoundageSettlement FeeUnsettledValidation
{{log.net_fee}} +   (System:{{log.sys_net_fee}}) +   (System:{{log.sys_net_fee}}) + {{log.surcharge}} +   (System:{{log.sys_surcharge}}) +   (System:{{log.sys_surcharge}}) + {{log.settlement_fee}} +   (System:{{log.sys_settlement_fee}}) +   (System:{{log.sys_settlement_fee}}) +
+ +
+
+ + +
+
+

Alipay+(Online) Logs

+
+
+

No Data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date StartDate EndSettle DatePay FeeRefund FeeNet FeePoundageSettlement FeeUnsettledValidation
{{log.net_fee}} +   (System:{{log.sys_net_fee}}) +   (System:{{log.sys_net_fee}}) + {{log.surcharge}} +   (System:{{log.sys_surcharge}}) +   (System:{{log.sys_surcharge}}) + {{log.settlement_fee}} +   (System:{{log.sys_settlement_fee}}) +   (System:{{log.sys_settlement_fee}}) +
+ +
+
+ diff --git a/src/main/ui/static/dashboard/templates/dashboard.html b/src/main/ui/static/dashboard/templates/dashboard.html index a548a0776..f49afb786 100644 --- a/src/main/ui/static/dashboard/templates/dashboard.html +++ b/src/main/ui/static/dashboard/templates/dashboard.html @@ -170,6 +170,34 @@ +
+
+
交易额: + +
+
订单数: + +
+
Alipay+ +
+
+
+
+
+
交易额: + +
+
订单数: + +
+
Alipay+(Online) +
+
+
diff --git a/src/main/ui/static/data/alipayMcc.json b/src/main/ui/static/data/alipayMcc.json index 5519f1527..0d98e594f 100644 --- a/src/main/ui/static/data/alipayMcc.json +++ b/src/main/ui/static/data/alipayMcc.json @@ -143,6 +143,12 @@ "label": "Trailer Parks and Campgrounds", "mccCode": "7033", "value": "{\"category\":\"SERVICE\",\"code\":\"7033\",\"description\":\"Trailer Parks and Campgrounds\",\"parentCode\":\"A04\"}" + }, + { + "children": [], + "label": "Timeshares", + "mccCode": "7012", + "value": "{\"category\":\"SERVICE\",\"code\":\"7012\",\"description\":\"Timeshares\",\"parentCode\":\"A04\"}" } ], "label": "Travel & Accommodation", @@ -242,6 +248,13 @@ "label": "Chemicals and Allied Products - Not Elsewhere Classified ", "mccCode": "5169", "value": "{\"category\":\"SHOPPING\",\"code\":\"5169\",\"description\":\"Chemicals and Allied Products - Not Elsewhere Classified \",\"parentCode\":\"B02\"}" + } + , + { + "children": [], + "label": "Petroleum and Petroleum Products ", + "mccCode": "5172", + "value": "{\"category\":\"SHOPPING\",\"code\":\"5172\",\"description\":\"Petroleum and Petroleum Products\",\"parentCode\":\"B02\"}" }, { "children": [], @@ -945,6 +958,12 @@ "label": "Video Amusement Game Supplies ", "mccCode": "7993", "value": "{\"category\":\"SHOPPING\",\"code\":\"7993\",\"description\":\"Video Amusement Game Supplies \",\"parentCode\":\"C10\"}" + }, + { + "children": [], + "label": "Antique Shops", + "mccCode": "5932", + "value": "{\"category\":\"SHOPPING\",\"code\":\"5932\",\"description\":\"Antique Shops\",\"parentCode\":\"C10\"}" } ], "label": "Culture, Amusement & Pets", @@ -1055,6 +1074,12 @@ "label": "Recreation Services - Not Elsewhere Classified", "mccCode": "7999", "value": "{\"category\":\"SERVICE\",\"code\":\"7999\",\"description\":\"Recreation Services - Not Elsewhere Classified\",\"parentCode\":\"D01\"}" + }, + { + "children": [], + "label": "Betting (including Lottery Tickets, Casino Gaming Chips, Off-track Betting and Wagers at Race Tracks)", + "mccCode": "7995", + "value": "{\"category\":\"SERVICE\",\"code\":\"7995\",\"description\":\"Betting (including Lottery Tickets, Casino Gaming Chips, Off-track Betting and Wagers at Race Tracks)\",\"parentCode\":\"D01\"}" } ], "label": "Entertainment & Tickets Services", @@ -1295,6 +1320,24 @@ "label": "Membership Organizations - Not Elsewhere Classified", "mccCode": "8699", "value": "{\"category\":\"OTHER\",\"code\":\"8699\",\"description\":\"Membership Organizations - Not Elsewhere Classified\",\"parentCode\":\"P03\"}" + }, + { + "children": [], + "label": "Religious Organizations", + "mccCode": "8661", + "value": "{\"category\":\"OTHER\",\"code\":\"8661\",\"description\":\"Religious Organization\",\"parentCode\":\"P03\"}" + }, + { + "children": [], + "label": "Political Organizations", + "mccCode": "8651", + "value": "{\"category\":\"OTHER\",\"code\":\"8651\",\"description\":\"Political Organizations\",\"parentCode\":\"P03\"}" + }, + { + "children": [], + "label": "Charitable and Social Service Organizations", + "mccCode": "8398", + "value": "{\"category\":\"OTHER\",\"code\":\"8398\",\"description\":\"Charitable and Social Service Organizations\",\"parentCode\":\"P03\"}" } ], "label": "Associations", @@ -1337,6 +1380,49 @@ "label": "Professional Consulting", "mccCode": "P04", "value": "Professional Consulting" + }, + { + "children": [ + { + "children": [], + "label": "Postal Services – Government Only", + "mccCode": "9402", + "value": "{\"category\":\"SERVICE\",\"code\":\"9402\",\"description\":\"Postal Services – Government Only\",\"parentCode\":\"P05\"}" + }, + { + "children": [], + "label": "Government Services ( Not Elsewhere Classified)", + "mccCode": "9399", + "value": "{\"category\":\"SERVICE\",\"code\":\"9399\",\"description\":\"Government Services ( Not Elsewhere Classified)\",\"parentCode\":\"P05\"}" + }, + { + "children": [], + "label": "Tax Payments", + "mccCode": "9311", + "value": "{\"category\":\"SERVICE\",\"code\":\"9311\",\"description\":\"Tax Payments\",\"parentCode\":\"P05\"}" + }, + { + "children": [], + "label": "Bail and Bond Payments", + "mccCode": "9223", + "value": "{\"category\":\"SERVICE\",\"code\":\"9223\",\"description\":\"Bail and Bond Payments\",\"parentCode\":\"P05\"}" + }, + { + "children": [], + "label": "Fines", + "mccCode": "9222", + "value": "{\"category\":\"SERVICE\",\"code\":\"9222\",\"description\":\"Fines\",\"parentCode\":\"P05\"}" + }, + { + "children": [], + "label": "Court Costs, including Alimony and Child Support", + "mccCode": "9211", + "value": "{\"category\":\"SERVICE\",\"code\":\"9211\",\"description\":\"Court Costs, including Alimony and Child Support\",\"parentCode\":\"P05\"}" + } + ], + "label": "Government Services", + "mccCode": "P05", + "value": "Government Services" } ], "label": "Professional Services", @@ -1467,6 +1553,12 @@ "label": "Direct Marketing - Not Elsewhere Classified", "mccCode": "5969", "value": "{\"category\":\"OTHER\",\"code\":\"5969\",\"description\":\"Direct Marketing - Not Elsewhere Classified\",\"parentCode\":\"S03\"}" + }, + { + "children": [], + "label": "Direct Marketing- Insurance Service", + "mccCode": "5960", + "value": "{\"category\":\"OTHER\",\"code\":\"5960\",\"description\":\"Direct Marketing- Insurance Service\",\"parentCode\":\"S03\"}" } ], "label": "Direct Marketing", @@ -1570,6 +1662,18 @@ "label": "Business Services Not Elsewhere Classified", "mccCode": "7399", "value": "{\"category\":\"SERVICE\",\"code\":\"7399\",\"description\":\"Business Services Not Elsewhere Classified\",\"parentCode\":\"S05\"}" + }, + { + "children": [], + "label": "Debt Collection Agencies", + "mccCode": "7322", + "value": "{\"category\":\"SERVICE\",\"code\":\"7322\",\"description\":\"Debt Collection Agencies\",\"parentCode\":\"S05\"}" + }, + { + "children": [], + "label": "Consumer Credit Reporting Agencies", + "mccCode": "7321", + "value": "{\"category\":\"SERVICE\",\"code\":\"7321\",\"description\":\"Consumer Credit Reporting Agencies\",\"parentCode\":\"S05\"}" } ], "label": "Business Services", @@ -1690,20 +1794,32 @@ }, { "children": [], - "label": "Personal Services - Not Elsewhere Classified", + "label": "Miscellaneous Personal Services ( not elsewhere classifies)", "mccCode": "7299", - "value": "{\"category\":\"SERVICE\",\"code\":\"7299\",\"description\":\"Personal Services - Not Elsewhere Classified\",\"parentCode\":\"S08\"}" + "value": "{\"category\":\"SERVICE\",\"code\":\"7299\",\"description\":\"Miscellaneous Personal Services ( not elsewhere classifies)\",\"parentCode\":\"S08\"}" }, { "children": [], "label": "Truck Stops", "mccCode": "7511", - "value": "{\"category\":\"OTHER\",\"code\":\"7511\",\"description\":\"Truck Stops\",\"parentCode\":\"S08\"}" + "value": "{\"category\":\"SERVICE\",\"code\":\"7511\",\"description\":\"Truck Stops\",\"parentCode\":\"S08\"}" + }, + { + "children": [], + "label": "Counselling Service – Debt, Marriage, Personal", + "mccCode": "7277", + "value": "{\"category\":\"SERVICE\",\"code\":\"7277\",\"description\":\"Counselling Service – Debt, Marriage, Personal\",\"parentCode\":\"S08\"}" + }, + { + "children": [], + "label": "Tax Preparation Service", + "mccCode": "7276", + "value": "{\"category\":\"SERVICE\",\"code\":\"7276\",\"description\":\"Tax Preparation Service\",\"parentCode\":\"S08\"}" } ], - "label": "Personal Services", + "label": "Miscellaneous Services", "mccCode": "S08", - "value": "Personal Services" + "value": "Miscellaneous Services" }, { "children": [ @@ -1820,7 +1936,63 @@ "label": "Automobile Rental & Services", "mccCode": "S10", "value": "Automobile Rental & Services" + }, + { + "children": [ + { + "children": [], + "label": "Money Orders – Wire Transfer", + "mccCode": "4829", + "value": "{\"category\":\"SERVICE\",\"code\":\"4829\",\"description\":\"Money Orders – Wire Transfer\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Pawn Shops and Salvage Yards", + "mccCode": "5933", + "value": "{\"category\":\"SERVICE\",\"code\":\"5933\",\"description\":\"Pawn Shops and Salvage Yards\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "nsurance Sales, Underwriting, and Premiums", + "mccCode": "6300", + "value": "{\"category\":\"SERVICE\",\"code\":\"6300\",\"description\":\"nsurance Sales, Underwriting, and Premiums\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Security Brokers/Dealers", + "mccCode": "6211", + "value": "{\"category\":\"SERVICE\",\"code\":\"6211\",\"description\":\"Security Brokers/Dealers\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Non-Financial Institutions – Foreign Currency, Money Orders (not wire transfer) and Travelers Cheques", + "mccCode": "6051", + "value": "{\"category\":\"SERVICE\",\"code\":\"6051\",\"description\":\"Non-Financial Institutions – Foreign Currency, Money Orders (not wire transfer) and Travelers Cheques\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Financial Institutions – Merchandise and Services", + "mccCode": "6012", + "value": "{\"category\":\"SERVICE\",\"code\":\"6012\",\"description\":\"Financial Institutions – Merchandise and Services\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Financial Institutions – Automated Cash Disbursements", + "mccCode": "6011", + "value": "{\"category\":\"SERVICE\",\"code\":\"6011\",\"description\":\"Financial Institutions – Automated Cash Disbursements\",\"parentCode\":\"S11\"}" + }, + { + "children": [], + "label": "Financial Institutions – Manual Cash Disbursements", + "mccCode": "6010", + "value": "{\"category\":\"SERVICE\",\"code\":\"6010\",\"description\":\"Financial Institutions – Manual Cash Disbursements\",\"parentCode\":\"S11\"}" + } + ], + "label": "Financial Services", + "mccCode": "S11", + "value": "Financial Services" } + ], "label": "Business & Miscellaneous Services", "mccCode": "S", diff --git a/src/main/ui/static/images/A+APS.png b/src/main/ui/static/images/A+APS.png new file mode 100644 index 000000000..a1aa74baa Binary files /dev/null and b/src/main/ui/static/images/A+APS.png differ diff --git a/src/main/ui/static/images/APS.png b/src/main/ui/static/images/APS.png new file mode 100644 index 000000000..8317f251e Binary files /dev/null and b/src/main/ui/static/images/APS.png differ diff --git a/src/main/ui/static/images/CONNECT_WALLET.png b/src/main/ui/static/images/CONNECT_WALLET.png new file mode 100644 index 000000000..e49499492 Binary files /dev/null and b/src/main/ui/static/images/CONNECT_WALLET.png differ diff --git a/src/main/ui/static/images/aggretage_aps_board.jpg b/src/main/ui/static/images/aggretage_aps_board.jpg new file mode 100644 index 000000000..cbb3499b3 Binary files /dev/null and b/src/main/ui/static/images/aggretage_aps_board.jpg differ diff --git a/src/main/ui/static/images/alipay_aps.jpg b/src/main/ui/static/images/alipay_aps.jpg new file mode 100644 index 000000000..e050cf959 Binary files /dev/null and b/src/main/ui/static/images/alipay_aps.jpg differ diff --git a/src/main/ui/static/images/alipay_aps_big.svg b/src/main/ui/static/images/alipay_aps_big.svg new file mode 100644 index 000000000..a3fb65da3 --- /dev/null +++ b/src/main/ui/static/images/alipay_aps_big.svg @@ -0,0 +1,24 @@ + + + A+Partner-200X80-竖版 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/ui/static/images/aps_tip.png b/src/main/ui/static/images/aps_tip.png new file mode 100644 index 000000000..9b352eae7 Binary files /dev/null and b/src/main/ui/static/images/aps_tip.png differ diff --git a/src/main/ui/static/images/royalpay_logo_02.png b/src/main/ui/static/images/royalpay_logo_02.png new file mode 100644 index 000000000..34a307cd5 Binary files /dev/null and b/src/main/ui/static/images/royalpay_logo_02.png differ diff --git a/src/main/ui/static/images/wechat_sacn.png b/src/main/ui/static/images/wechat_sacn.png new file mode 100644 index 000000000..605009788 Binary files /dev/null and b/src/main/ui/static/images/wechat_sacn.png differ diff --git a/src/main/ui/static/payment/partner/add-partner.js b/src/main/ui/static/payment/partner/add-partner.js index 18d2c8318..92de58e30 100644 --- a/src/main/ui/static/payment/partner/add-partner.js +++ b/src/main/ui/static/payment/partner/add-partner.js @@ -525,6 +525,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode; $scope.partner.registered_state = $scope.partner.representativeInfo.state; $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person; + $scope.partner.legal_representative_id = $scope.partner.representativeInfo.legal_representative_id; $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone; $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email; $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title; diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 2475ecc50..d73fc661b 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2,459 +2,459 @@ * Created by yixian on 2016-06-29. */ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload', 'uiSelect'], function (angular, Decimal) { - 'use strict' - var clean_days_map = [ - { - label: 'T+1', - value: '1', - }, - { - label: 'T+2', - value: '2', - }, - { - label: 'T+3', - value: '3', - }, - ] - var bd_city_map = [ - { - label: 'Sydney', - value: 'Sydney', - }, - { - label: 'Melbourne', - value: 'Melbourne', - }, - ] - var partnerRoles = [ - { code: 1, label: 'Admin' }, - { code: 2, label: 'Manager' }, - { code: 3, label: 'Cashier' }, - ] - // var wxMerchantIndustries = [ - // { - // "label": "鞋包服饰|Shoes&Garments", - // "value": "343" - // }, - // { - // "label": "机票行业|Air Ticket", - // "value": "493" - // }, - // { - // "label": "文具/办公用品|Stationery/office supplies", - // "value": "492" - // }, - // { - // "label": "酒店行业|Hotel Industry", - // "value": "491" - // }, - // { - // "label": "教育行业|Education Industry", - // "value": "490" - // }, - // { - // "label": "国际物流|Logistics", - // "value": "489" - // }, - // { - // "label": "数码电器|Digital appliance", - // "value": "488" - // }, - // { - // "label": "母婴|Maternal and infant", - // "value": "487" - // }, - // { - // "label": "化妆品|Cosmetics", - // "value": "486" - // }, - // { - // "label": "食品|Food", - // "value": "485" - // }, - // { - // "label": "综合商城|Comprehensive mall", - // "value": "484" - // }, - // { - // "label": "其它货物贸易行业|Other trade industry", - // "value": "494" - // } - // ]; - - var wxMerchantIndustries = [ - { - label: 'Shoes&Garments', - value: '343', - }, - { - label: 'Comprehensive mall', - value: '484', - }, - { - label: 'Food', - value: '485', - }, - { - label: 'Cosmetics', - value: '486', - }, - { - label: 'Maternal and infant', - value: '487', - }, - { - label: 'Digital appliance', - value: '488', - }, - { - label: 'Logistics', - value: '489', - }, - { - label: 'Education Industry', - value: '490', - }, - { - label: 'Hotel Industry', - value: '491', - }, - { - label: 'Stationery/office supplies', - value: '492', - }, - { - label: 'Air Ticket', - value: '493', - }, - { - label: 'Other trade industry', - value: '494', - }, - { - label: 'Overseas Education', - value: '528', - }, - { - label: 'Travel ticket', - value: '529', - }, - { - label: 'Car rental', - value: '530', - }, - { - label: 'International Conference', - value: '531', - }, - { - label: 'Software', - value: '532', - }, - { - label: 'Medical Service', - value: '533', - }, - { - label: 'Online games (Top-up)', - value: '644', - }, - { - label: 'Online Shopping Mall', - value: '648', - }, - { - label: 'Supermarket', - value: '649', - }, - { - label: 'Convenience Store', - value: '651', - }, - { - label: 'Duty-free Shop', - value: '652', - }, - { - label: 'Pharmacy', - value: '653', - }, - { - label: 'Vending Machine', - value: '654', - }, - { - label: 'Department Store /Shopping Centre', - value: '655', - }, - { - label: 'Food/Beverages', - value: '656', - }, - { - label: 'Catering Services', - value: '657', - }, - { - label: 'Furniture/Household Products', - value: '658', - }, - { - label: 'Home Appliances/Camera Equipment/Office Equipment', - value: '659', - }, - { - label: 'Beauty/Personal Care Products', - value: '660', - }, - { - label: 'Flowers/Plants/Interior Decorations/Decorations', - value: '661', - }, - { - label: 'Nursery Products/Toys', - value: '662', - }, - { - label: 'Clothing/Shoes/Other Accessories', - value: '663', - }, - { - label: 'Sports/Fitness Equipment/Security', - value: '664', - }, - { - label: 'Watches/Eyewear/Jewellery', - value: '665', - }, - { - label: 'Outdoor Products /Travel Products', - value: '666', - }, - { - label: 'Books / Records / Stationery / Musical Instruments', - value: '667', - }, - { - label: 'Flight ticket/ticketing agent', - value: '668', - }, - { - label: 'Sightseeing Passes', - value: '669', - }, - { - label: 'Hotel/Resort', - value: '670', - }, - { - label: 'Online Books/Video/Music', - value: '671', - }, - { - label: 'Online games (Download)', - value: '672', - }, - { - label: 'University Education', - value: '677', - }, - { - label: 'Public hospitals/Medical Institutions', - value: '679', - }, - { - label: 'Private hospitals/Clinics/Medical institutions', - value: '678', - }, - { - label: 'Public transit', - value: '680', - }, - { - label: 'Logistics/ Courier Service', - value: '684', - }, - ] - var removeClientPayDesc = function (items, key) { - for (var i = 0; i < items.length; i++) { - var item = items[i] - if (item.indexOf(key) >= 0) { - items.splice(items.indexOf(item), 1) - i = i - 1 - } + 'use strict' + var clean_days_map = [ + { + label: 'T+1', + value: '1', + }, + { + label: 'T+2', + value: '2', + }, + { + label: 'T+3', + value: '3', + }, + ] + var bd_city_map = [ + { + label: 'Sydney', + value: 'Sydney', + }, + { + label: 'Melbourne', + value: 'Melbourne', + }, + ] + var partnerRoles = [ + {code: 1, label: 'Admin'}, + {code: 2, label: 'Manager'}, + {code: 3, label: 'Cashier'}, + ] + // var wxMerchantIndustries = [ + // { + // "label": "鞋包服饰|Shoes&Garments", + // "value": "343" + // }, + // { + // "label": "机票行业|Air Ticket", + // "value": "493" + // }, + // { + // "label": "文具/办公用品|Stationery/office supplies", + // "value": "492" + // }, + // { + // "label": "酒店行业|Hotel Industry", + // "value": "491" + // }, + // { + // "label": "教育行业|Education Industry", + // "value": "490" + // }, + // { + // "label": "国际物流|Logistics", + // "value": "489" + // }, + // { + // "label": "数码电器|Digital appliance", + // "value": "488" + // }, + // { + // "label": "母婴|Maternal and infant", + // "value": "487" + // }, + // { + // "label": "化妆品|Cosmetics", + // "value": "486" + // }, + // { + // "label": "食品|Food", + // "value": "485" + // }, + // { + // "label": "综合商城|Comprehensive mall", + // "value": "484" + // }, + // { + // "label": "其它货物贸易行业|Other trade industry", + // "value": "494" + // } + // ]; + + var wxMerchantIndustries = [ + { + label: 'Shoes&Garments', + value: '343', + }, + { + label: 'Comprehensive mall', + value: '484', + }, + { + label: 'Food', + value: '485', + }, + { + label: 'Cosmetics', + value: '486', + }, + { + label: 'Maternal and infant', + value: '487', + }, + { + label: 'Digital appliance', + value: '488', + }, + { + label: 'Logistics', + value: '489', + }, + { + label: 'Education Industry', + value: '490', + }, + { + label: 'Hotel Industry', + value: '491', + }, + { + label: 'Stationery/office supplies', + value: '492', + }, + { + label: 'Air Ticket', + value: '493', + }, + { + label: 'Other trade industry', + value: '494', + }, + { + label: 'Overseas Education', + value: '528', + }, + { + label: 'Travel ticket', + value: '529', + }, + { + label: 'Car rental', + value: '530', + }, + { + label: 'International Conference', + value: '531', + }, + { + label: 'Software', + value: '532', + }, + { + label: 'Medical Service', + value: '533', + }, + { + label: 'Online games (Top-up)', + value: '644', + }, + { + label: 'Online Shopping Mall', + value: '648', + }, + { + label: 'Supermarket', + value: '649', + }, + { + label: 'Convenience Store', + value: '651', + }, + { + label: 'Duty-free Shop', + value: '652', + }, + { + label: 'Pharmacy', + value: '653', + }, + { + label: 'Vending Machine', + value: '654', + }, + { + label: 'Department Store /Shopping Centre', + value: '655', + }, + { + label: 'Food/Beverages', + value: '656', + }, + { + label: 'Catering Services', + value: '657', + }, + { + label: 'Furniture/Household Products', + value: '658', + }, + { + label: 'Home Appliances/Camera Equipment/Office Equipment', + value: '659', + }, + { + label: 'Beauty/Personal Care Products', + value: '660', + }, + { + label: 'Flowers/Plants/Interior Decorations/Decorations', + value: '661', + }, + { + label: 'Nursery Products/Toys', + value: '662', + }, + { + label: 'Clothing/Shoes/Other Accessories', + value: '663', + }, + { + label: 'Sports/Fitness Equipment/Security', + value: '664', + }, + { + label: 'Watches/Eyewear/Jewellery', + value: '665', + }, + { + label: 'Outdoor Products /Travel Products', + value: '666', + }, + { + label: 'Books / Records / Stationery / Musical Instruments', + value: '667', + }, + { + label: 'Flight ticket/ticketing agent', + value: '668', + }, + { + label: 'Sightseeing Passes', + value: '669', + }, + { + label: 'Hotel/Resort', + value: '670', + }, + { + label: 'Online Books/Video/Music', + value: '671', + }, + { + label: 'Online games (Download)', + value: '672', + }, + { + label: 'University Education', + value: '677', + }, + { + label: 'Public hospitals/Medical Institutions', + value: '679', + }, + { + label: 'Private hospitals/Clinics/Medical institutions', + value: '678', + }, + { + label: 'Public transit', + value: '680', + }, + { + label: 'Logistics/ Courier Service', + value: '684', + }, + ] + var removeClientPayDesc = function (items, key) { + for (var i = 0; i < items.length; i++) { + var item = items[i] + if (item.indexOf(key) >= 0) { + items.splice(items.indexOf(item), 1) + i = i - 1 + } + } } - } - var app = angular.module('partnerManageApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ui.select', 'ngFileUpload']) - app.config([ - '$stateProvider', - function ($stateProvider) { - $stateProvider - .state('partners', { - url: '/partners', - templateUrl: '/static/payment/partner/templates/partners.html', - controller: 'partnerListCtrl', - data: { label: '商户列表' }, - }) - .state('businessCompliance', { - url: '/partners/compliance', - templateUrl: '/static/payment/partner/templates/partner_compliance.html', - controller: 'compliancePartnerCtrl', - }) - .state('complianceDocumentAudit', { - url: '/partners/compliance', - templateUrl: '/static/payment/partner/templates/partner_compliance.html', - controller: 'compliancePartnerCtrl', - }) - .state('partners.detail', { - url: '/{clientMoniker}/detail', - templateUrl: '/static/payment/partner/templates/partner_detail.html', - controller: 'partnerDetailCtrl', - resolve: { - partner: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker) - }, - ], - }, - }) - .state('partners.detail.payment_info', { - url: '/payment', - templateUrl: '/static/payment/partner/templates/partner_payment_info.html', - controller: 'partnerPaymentInfoCtrl', - }) - .state('partners.detail.payment_info_invalid', { - url: '/payment_invalid', - templateUrl: '/static/payment/partner/templates/partner_payment_info_invalid.html', - controller: 'partnerPaymentInfoCtrl', - }) - .state('partners.detail.subpartners', { - url: '/sub_partners', - templateUrl: '/static/payment/partner/templates/sub_partners.html', - controller: 'partnerSubCtrl', - }) - .state('partners.detail.accounts', { - url: '/accounts', - templateUrl: '/static/payment/partner/templates/partner_accounts.html', - controller: 'partnerAccountsCtrl', - }) - .state('partners.detail.paylogs', { - url: '/pay_logs', - templateUrl: '/static/payment/partner/templates/partner_pay_logs.html', - controller: 'partnerPayLogCtrl', - }) - .state('partners.detail.rates', { - url: '/rates', - templateUrl: '/static/payment/partner/templates/partner_bankaccounts.html', - controller: 'partnerRatesCtrl', - }) - .state('partners.detail.plugins', { - url: '/plugins', - templateUrl: '/static/payment/partner/templates/partner_plugins.html', - controller: 'partnerPluginsCtrl', - }) - .state('partners.detail.devices', { - url: '/devices', - templateUrl: '/static/payment/partner/templates/partner_devices.html', - controller: 'partnerDeviceCtrl', - }) - .state('partners.detail.files', { - url: '/files', - params: { commitType: 'cross-border' }, - templateUrl: '/static/payment/partner/templates/partner_auth_files.html', - controller: 'partnerAuthFileCtrl', - }) - .state('partners.detail.files.CP_files', { - url: '/cp_files', - templateUrl: '/static/payment/partner/templates/partner_cp_auth_files.html', - controller: 'partnerCPAuthFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/file') - }, - ], - }, - }) - .state('partners.detail.files.MW_files', { - url: '/mw_files', - templateUrl: '/static/payment/partner/templates/partner_mw_auth_files.html', - controller: 'partnerMWAuthFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/mw_file') - }, - ], - }, - }) - .state('partners.detail.kyc_files', { - url: '/kyc_files', - templateUrl: '/static/payment/kyc/templates/partner_kyc_files.html', - controller: 'partnerKycFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/kycFile') - }, - ], - }, - }) - .state('partners.detail.settlement', { - url: '/settlement', - templateUrl: '/static/payment/partner/templates/partner_settlement.html', - controller: 'partnerSettlementCtrl', - resolve: { - clientMoniker: [ - '$stateParams', - function ($stateParams) { - return $stateParams.clientMoniker - }, - ], - }, - }) - .state('partners.detail.surcharge_account', { - url: '/surcharge_account', - templateUrl: '/static/payment/partner/templates/partner_surcharge_account.html', - controller: 'partnerSurchargeAccountCtrl', - resolve: { - clientMoniker: [ - '$stateParams', - function ($stateParams) { - return $stateParams.clientMoniker - }, - ], - }, - }) - .state('partners.detail.product', { - url: '/partner_product', - templateUrl: 'static/payment/product/templates/partner_product.html', - controller: 'productCtrl', - }) - .state('partners.detail.sub_merchant_applicaitons', { - url: '/sub_merchant_applicaitons', - templateUrl: 'static/payment/partner/templates/sub_merchant_id_apply.html', - controller: 'subMerchantIdApplicaitonsCtrl', - }) - .state('partners.detail.permission_client', { - url: '/permission_client', - templateUrl: 'static/payment/partner/templates/partner_permission.html', - controller: 'permissionClientCtrl', - }) - .state('partners.detail.incremental_service', { - url: '/incremental_service', - templateUrl: 'static/payment/partner/templates/incremental_service.html', - controller: 'incrementalServiceCtrl', - }) /*.state('partners.edit', { + var app = angular.module('partnerManageApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ui.select', 'ngFileUpload']) + app.config([ + '$stateProvider', + function ($stateProvider) { + $stateProvider + .state('partners', { + url: '/partners', + templateUrl: '/static/payment/partner/templates/partners.html', + controller: 'partnerListCtrl', + data: {label: '商户列表'}, + }) + .state('businessCompliance', { + url: '/partners/compliance', + templateUrl: '/static/payment/partner/templates/partner_compliance.html', + controller: 'compliancePartnerCtrl', + }) + .state('complianceDocumentAudit', { + url: '/partners/compliance', + templateUrl: '/static/payment/partner/templates/partner_compliance.html', + controller: 'compliancePartnerCtrl', + }) + .state('partners.detail', { + url: '/{clientMoniker}/detail', + templateUrl: '/static/payment/partner/templates/partner_detail.html', + controller: 'partnerDetailCtrl', + resolve: { + partner: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker) + }, + ], + }, + }) + .state('partners.detail.payment_info', { + url: '/payment', + templateUrl: '/static/payment/partner/templates/partner_payment_info.html', + controller: 'partnerPaymentInfoCtrl', + }) + .state('partners.detail.payment_info_invalid', { + url: '/payment_invalid', + templateUrl: '/static/payment/partner/templates/partner_payment_info_invalid.html', + controller: 'partnerPaymentInfoCtrl', + }) + .state('partners.detail.subpartners', { + url: '/sub_partners', + templateUrl: '/static/payment/partner/templates/sub_partners.html', + controller: 'partnerSubCtrl', + }) + .state('partners.detail.accounts', { + url: '/accounts', + templateUrl: '/static/payment/partner/templates/partner_accounts.html', + controller: 'partnerAccountsCtrl', + }) + .state('partners.detail.paylogs', { + url: '/pay_logs', + templateUrl: '/static/payment/partner/templates/partner_pay_logs.html', + controller: 'partnerPayLogCtrl', + }) + .state('partners.detail.rates', { + url: '/rates', + templateUrl: '/static/payment/partner/templates/partner_bankaccounts.html', + controller: 'partnerRatesCtrl', + }) + .state('partners.detail.plugins', { + url: '/plugins', + templateUrl: '/static/payment/partner/templates/partner_plugins.html', + controller: 'partnerPluginsCtrl', + }) + .state('partners.detail.devices', { + url: '/devices', + templateUrl: '/static/payment/partner/templates/partner_devices.html', + controller: 'partnerDeviceCtrl', + }) + .state('partners.detail.files', { + url: '/files', + params: {commitType: 'cross-border'}, + templateUrl: '/static/payment/partner/templates/partner_auth_files.html', + controller: 'partnerAuthFileCtrl', + }) + .state('partners.detail.files.CP_files', { + url: '/cp_files', + templateUrl: '/static/payment/partner/templates/partner_cp_auth_files.html', + controller: 'partnerCPAuthFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/file') + }, + ], + }, + }) + .state('partners.detail.files.MW_files', { + url: '/mw_files', + templateUrl: '/static/payment/partner/templates/partner_mw_auth_files.html', + controller: 'partnerMWAuthFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/mw_file') + }, + ], + }, + }) + .state('partners.detail.kyc_files', { + url: '/kyc_files', + templateUrl: '/static/payment/kyc/templates/partner_kyc_files.html', + controller: 'partnerKycFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/kycFile') + }, + ], + }, + }) + .state('partners.detail.settlement', { + url: '/settlement', + templateUrl: '/static/payment/partner/templates/partner_settlement.html', + controller: 'partnerSettlementCtrl', + resolve: { + clientMoniker: [ + '$stateParams', + function ($stateParams) { + return $stateParams.clientMoniker + }, + ], + }, + }) + .state('partners.detail.surcharge_account', { + url: '/surcharge_account', + templateUrl: '/static/payment/partner/templates/partner_surcharge_account.html', + controller: 'partnerSurchargeAccountCtrl', + resolve: { + clientMoniker: [ + '$stateParams', + function ($stateParams) { + return $stateParams.clientMoniker + }, + ], + }, + }) + .state('partners.detail.product', { + url: '/partner_product', + templateUrl: 'static/payment/product/templates/partner_product.html', + controller: 'productCtrl', + }) + .state('partners.detail.sub_merchant_applicaitons', { + url: '/sub_merchant_applicaitons', + templateUrl: 'static/payment/partner/templates/sub_merchant_id_apply.html', + controller: 'subMerchantIdApplicaitonsCtrl', + }) + .state('partners.detail.permission_client', { + url: '/permission_client', + templateUrl: 'static/payment/partner/templates/partner_permission.html', + controller: 'permissionClientCtrl', + }) + .state('partners.detail.incremental_service', { + url: '/incremental_service', + templateUrl: 'static/payment/partner/templates/incremental_service.html', + controller: 'incrementalServiceCtrl', + }) /*.state('partners.edit', { url: '/{clientMoniker}/edit', params: {"commitCardPayment": false, "commitCrossBorderPayment": false}, templateUrl: 'static/payment/partner/templates/partner_edit.html', @@ -465,5074 +465,5229 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }] } })*/ - }, - ]) - app.controller('partnerEditCtrl', [ - '$scope', - '$http', - '$state', - 'Upload', - 'commonDialog', - 'timezone', - 'partner', - 'upayIndustryMap', - function ($scope, $http, $state, Upload, commonDialog, timezone, partner, upayIndustryMap) { - $scope.upayIndustrys = upayIndustryMap.configs() - $scope.timezones = timezone.configs() - $scope.partner = partner.data - if (!$scope.partner.client_type) { - $scope.partner.client_type = 'cross-border' - } - if ($scope.partner.representativeInfo != null) { - $scope.partner.registered_address = $scope.partner.representativeInfo.address - $scope.partner.registered_suburb = $scope.partner.representativeInfo.suburb - $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode - $scope.partner.registered_state = $scope.partner.representativeInfo.state - $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person - $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone - $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email - $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title - - $scope.partner.marketing_person = $scope.partner.representativeInfo.marketing_person - $scope.partner.marketing_phone = $scope.partner.representativeInfo.marketing_phone - $scope.partner.marketing_email = $scope.partner.representativeInfo.marketing_email - $scope.partner.marketing_job = $scope.partner.representativeInfo.marketing_job_title - - $scope.partner.legal_representative_wechatid = $scope.partner.representativeInfo.legal_representative_wechatid - $scope.partner.marketing_wechatid = $scope.partner.representativeInfo.marketing_wechatid - } - - $scope.enablePaymentType = function (type) { - $scope.partner[type] = !$scope.partner[type] - } - - if ($state.params.commitCardPayment) { - $scope.enablePaymentType('enable_card_payment') - } - - if ($state.params.commitCrossBorderPayment) { - $scope.enablePaymentType('enable_cross_payment') - } - - function hasRole() { - var rolenum - switch (sessionStorage.getItem('role')) { - case 'administrator': - rolenum = 1 - break - case 'bduser': - rolenum = 4 - break - case 'salesmanager': - rolenum = 8192 - break - case 'accountant': - rolenum = 8 - break - case 'sitemanager': - rolenum = 128 - break - case 'director': - rolenum = 64 - break - case 'developer': - rolenum = 256 - break - case 'compliance': - rolenum = 2 - break - case 'guest': - rolenum = 2048 - break - case 'orgmanager': - rolenum = 4096 - break - case 'riskmanager': - rolenum = 1024 - break - default: - break - } - if ((window.currentUser.role & rolenum) > 0) { - return true - } else { - sessionStorage.removeItem('role') - return false - } - } + }, + ]) + app.controller('partnerEditCtrl', [ + '$scope', + '$http', + '$state', + 'Upload', + 'commonDialog', + 'timezone', + 'partner', + 'upayIndustryMap', + function ($scope, $http, $state, Upload, commonDialog, timezone, partner, upayIndustryMap) { + $scope.upayIndustrys = upayIndustryMap.configs() + $scope.timezones = timezone.configs() + $scope.partner = partner.data + if (!$scope.partner.client_type) { + $scope.partner.client_type = 'cross-border' + } + if ($scope.partner.representativeInfo != null) { + $scope.partner.registered_address = $scope.partner.representativeInfo.address + $scope.partner.registered_suburb = $scope.partner.representativeInfo.suburb + $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode + $scope.partner.registered_state = $scope.partner.representativeInfo.state + $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person + $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone + $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email + $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title + + $scope.partner.marketing_person = $scope.partner.representativeInfo.marketing_person + $scope.partner.marketing_phone = $scope.partner.representativeInfo.marketing_phone + $scope.partner.marketing_email = $scope.partner.representativeInfo.marketing_email + $scope.partner.marketing_job = $scope.partner.representativeInfo.marketing_job_title + + $scope.partner.legal_representative_wechatid = $scope.partner.representativeInfo.legal_representative_wechatid + $scope.partner.marketing_wechatid = $scope.partner.representativeInfo.marketing_wechatid + } - if (hasRole()) { - $scope.role = sessionStorage.getItem('role') - } + $scope.enablePaymentType = function (type) { + $scope.partner[type] = !$scope.partner[type] + } - var origin_referrer_id = angular.copy($scope.partner.referrer_id) - var resetClientPayDescByTpey = function (type) { - type = parseInt(type) - if (type == 1) { - removeClientPayDesc($scope.partner.client_pay_desc, '10') - } - if (type == 2) { - removeClientPayDesc($scope.partner.client_pay_desc, '20') - } - } - var compare = function (x, y) { - x = parseInt(x) - y = parseInt(y) - if (x < y) { - return -1 - } else if (x > y) { - return 1 - } else { - return 0 - } - } - $scope.toggleClientPayType = function (type) { - if (!$scope.partner.client_pay_type) { - $scope.partner.client_pay_type = [] - } - var $idx = $scope.partner.client_pay_type.indexOf(type) - if ($idx >= 0) { - $scope.partner.client_pay_type.splice($idx, 1) - resetClientPayDescByTpey(type) - } else { - $scope.partner.client_pay_type.push(type) - $scope.partner.client_pay_type.sort(compare) - } - } - $scope.toggleClientPayDesc = function (type) { - if (!$scope.partner.client_pay_desc) { - $scope.partner.client_pay_desc = [] - } - var $idx = $scope.partner.client_pay_desc.indexOf(type) - if ($idx >= 0) { - if (type == '203') { - removeClientPayDesc($scope.partner.client_pay_desc, '2030') - } - $scope.partner.client_pay_desc.splice($idx, 1) - } else { - $scope.partner.client_pay_desc.push(type) - $scope.partner.client_pay_desc.sort(compare) - } - } - - $scope.partner.sameAsContactPerson = false - $scope.checkboxOnclick = function () { - $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson - if ($scope.partner.sameAsContactPerson) { - $scope.partner.legal_representative_person = $scope.partner.contact_person - $scope.partner.legal_representative_phone = $scope.partner.contact_phone - $scope.partner.legal_representative_email = $scope.partner.contact_email - $scope.partner.legal_representative_job = $scope.partner.contact_job - $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.marketingSameAsContact = false - $scope.checkMarketingSameAsContact = function () { - $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact - if ($scope.partner.marketingSameAsContact) { - $scope.partner.marketing_person = $scope.partner.contact_person - $scope.partner.marketing_phone = $scope.partner.contact_phone - $scope.partner.marketing_email = $scope.partner.contact_email - $scope.partner.marketing_job = $scope.partner.contact_job - $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.sameAsAddress = false - $scope.sameAddress = function () { - $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress - if ($scope.partner.sameAsAddress) { - // $scope.partner.registered_address = $scope.partner.address; - // $scope.partner.registered_suburb = $scope.partner.suburb; - // $scope.partner.registered_postcode = $scope.partner.postcode; - // $scope.partner.registered_state = $scope.partner.state; - $scope.partner.address = $scope.partner.registered_address - $scope.partner.suburb = $scope.partner.registered_suburb - $scope.partner.postcode = $scope.partner.registered_postcode - $scope.partner.state = $scope.partner.registered_state - } - } - - $scope.listReferrers = function () { - $http.get('/sys/orgs/referrer').then(function (resp) { - $scope.referrers = resp.data - }) - } - $scope.listReferrers() - - $scope.loadAlipayCategory = function () { - $http.get('/static/data/alipayMcc.json').then(function (resp) { - $scope.alipayMccCategory = resp.data - }) - } - $scope.loadAlipayCategory() - $scope.loadJDindustry = function () { - $http.get('/static/data/jdindustry.json').then(function (resp) { - $scope.jdindustry = resp.data - }) - } - $scope.loadJDindustry() - - $scope.loadLakalaPayindustry = function () { - $http.get('/static/data/lakalapayindustry.json').then(function (resp) { - $scope.lakalapayindustry = resp.data - }) - } - $scope.loadLakalaPayindustry() - - $scope.loadLakalaPaySettle = function () { - $http.get('/static/data/lakalapaysettle.json').then(function (resp) { - $scope.lakalapaysettle = resp.data - }) - } - $scope.loadLakalaPaySettle() - - $scope.loadLakalaPayGoods = function () { - $http.get('/static/data/lakalapaygoods.json').then(function (resp) { - $scope.lakalapaygoods = resp.data - }) - } - $scope.loadLakalaPayGoods() - - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - }) - } - $scope.loadRoyalpayindustry() - - $scope.loadHfindustry = function () { - $http.get('/static/data/hfindustry.json').then(function (resp) { - $scope.hfindustry = resp.data - }) - } - $scope.loadHfindustry() - - $scope.onAlipayMccSelect = function (selectedItem) { - $scope.partner.alipay_category = selectedItem.label - $scope.partner.alipayindustry = selectedItem.mccCode - } - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.partner.royalpay_label = selectedItem.label - $scope.partner.royalpayindustry = selectedItem.mccCode - } - $scope.onHfIndustrySelect = function (selectedItem) { - $scope.partner.hf_label = selectedItem.label - $scope.partner.hfindustry = selectedItem.mccCode - } - - $scope.updatePartner = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } + if ($state.params.commitCardPayment) { + $scope.enablePaymentType('enable_card_payment') + } - if ($scope.partner.company_name.indexOf('Migration') != -1) { - alert('Company Name包含敏感词汇,请检查后重新提交!') - return - } - if ($scope.partner.company_phone.indexOf(' ') != -1) { - alert('Company Phone can not contain space character') - return - } - if ($scope.partner.contact_email.indexOf(' ') != -1) { - alert('Contact email Phone can not contain space character') - return - } - if ($scope.partner.suburb.indexOf(' ') != -1) { - alert('suburb can not contain two and more continuous space characters') - return - } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if (!$scope.partner.company_photo) { - alert('Shop Photo1 is necessary') - return - } - if (!$scope.partner.store_photo) { - alert('Shop Photo2 is necessary') - return - } - } + if ($state.params.commitCrossBorderPayment) { + $scope.enablePaymentType('enable_cross_payment') + } - if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { - if ($scope.partner.acn.length != 9) { - alert('Acn is not valid') - } - } - if ($scope.partner.referrer_id) { - $scope.referrers.forEach(function (e) { - if ($scope.partner.referrer_id == e.org_id) { - $scope.partner.referrer_name = e.name - return + function hasRole() { + var rolenum + switch (sessionStorage.getItem('role')) { + case 'administrator': + rolenum = 1 + break + case 'bduser': + rolenum = 4 + break + case 'salesmanager': + rolenum = 8192 + break + case 'accountant': + rolenum = 8 + break + case 'sitemanager': + rolenum = 128 + break + case 'director': + rolenum = 64 + break + case 'developer': + rolenum = 256 + break + case 'compliance': + rolenum = 2 + break + case 'guest': + rolenum = 2048 + break + case 'orgmanager': + rolenum = 4096 + break + case 'riskmanager': + rolenum = 1024 + break + default: + break + } + if ((window.currentUser.role & rolenum) > 0) { + return true + } else { + sessionStorage.removeItem('role') + return false + } } - }) - } - var content = '' - if (!origin_referrer_id && $scope.partner.referrer_id) { - content = 'Update partner info successfully,But You Had add new Referrer,Please Change the BD Commission Proportion!' - } - if ($scope.partner.client_pay_type.length == 0) { - alert('请选择商户支付场景') - return - } - if ($scope.partner.client_pay_desc.length == 0) { - alert('请选择商户支付方式') - return - } - if ($scope.partner.client_pay_type.indexOf('1') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { - alert('请检查线上支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { - alert('请检查线下支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { - alert('请检查线下支付是否已选择收银系统类型') - return - } - } - $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') - $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') - $http.put('/sys/partners/' + $scope.partner.client_moniker, $scope.partner).then( - function () { - if (content != '') { - commonDialog.alert({ - title: 'Warning', - content: content, - type: 'error', - }) - } else { - commonDialog.alert({ - title: 'Success', - content: 'Update partner information successfully', - type: 'success', - }) - } - $scope.updateMerchantLocation() - $scope.loadPartners() - $state.go('^.detail', { clientMoniker: $scope.partner.client_moniker }, { reload: true }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.uploadLogo = function (file) { - if (file != null) { - if (file.size > 1 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error' }) - } else { - $scope.logoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.logoProgress - $scope.partner.logo_id = resp.data.fileid - $scope.partner.logo_url = resp.data.url - }, - function (resp) { - delete $scope.logoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadShopPhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.shopPhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.shopPhotoProgress - $scope.partner.company_photo = resp.data.url - }, - function (resp) { - delete $scope.shopPhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadStorePhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.storePhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.storePhotoProgress - $scope.partner.store_photo = resp.data.url - }, - function (resp) { - delete $scope.storePhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.getMerchantLocation = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { - $scope.merchant_location = resp.data - }) - } - $scope.getMerchantLocation() - - $scope.updateMerchantLocation = function () { - var params = window.frames['merchant_detail'].merchant_location - if (params) { - $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () {}) - } - } - }, - ]) - app.controller('partnerListCtrl', [ - '$scope', - '$sce', - '$http', - '$filter', - '$uibModal', - 'businessStructuresMap', - 'industryMap', - 'stateMap', - 'sectorMap', - 'countryMap', - function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { - $scope.analysisClients = function () { - $http.get('/sys/partners/analysis').then(function (resp) { - $scope.analysis = resp.data - }) - } - if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { - $scope.analysisClients() - } - $scope.pagination = {} - $scope.industries = industryMap.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.sectors = sectorMap.configs() - $scope.business_structures = businessStructuresMap.configs() - $scope.clean_days = angular.copy(clean_days_map) - $scope.bd_citys = angular.copy(bd_city_map) - $scope.params = { textType: 'all', org_name: 'ALL', industry: '0' } - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - var selectAll = { - label: 'All', - mccCode: '0', - children: {}, - } - $scope.royalpayindustry.unshift(selectAll) - }) - } - - $scope.loadRoyalpayindustry() - - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.params.royalpay_label = selectedItem.label - $scope.params.industry = selectedItem.mccCode - $scope.loadPartners(1) - } - - $scope.loadPartners = function (page) { - var params = angular.copy($scope.params) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners', { params: params }).then(function (resp) { - $scope.partners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.exportPartnersExcel = function () { - var params = angular.copy($scope.params) - var param_str = Object.keys(params) - .map(function (key) { - var value = params[key] - if (angular.isDate(value)) { - value = $filter('date')(value, 'yyyy-MM-ddTHH:mm:ssZ') - } - return key + '=' + encodeURIComponent(value) - }) - .join('&') - window.open('/sys/partners/exporting_excel?' + param_str) - } - - /*$scope.loadLocations = function () { - var params = angular.copy($scope.params); - $http.get('/sys/partners/merchant/list_locations', {params: params}).then(function (resp) { - $scope.locations = resp.data; - window.merchant_maps.initMap($scope.locations); - }); - };*/ - $scope.today = new Date() - - $scope.listBDUsers = function () { - $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { - $scope.bdUserSource = resp.data - }) - } - $scope.listBDUsers() - - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - $scope.showOrg = 'Organization' - $http.get('/sys/orgs/list_all_Org', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - $scope.loadOrgs() - - /* $scope.onOrgsSelect = function (selectedItem) { - $scope.params.org_id = selectedItem.org_id; - $scope.params.org_name = selectedItem.label; - $scope.loadPartners(); - }; - */ - /* $scope.chooseOrg = function (org) { - if (org == 'all') { - delete $scope.params.org_id; - $scope.showOrg = 'All' - } else { - $scope.params.org_id = org.org_id; - $scope.showOrg = org.name; - } - $scope.loadPartners(1); - };*/ - $scope.loadPartners(1) - - $scope.openClientBoard = function (client) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/partner_card.html', - controller: 'partnerCardCtrl', - resolve: { - clientMoniker: function () { - return client.client_moniker - }, - }, - size: 'lg', - }) - } - /*$scope.toogleMapSelect = function () { - $scope.mapFrame = 'all_locations.html'; - $scope.loadLocations(); + if (hasRole()) { + $scope.role = sessionStorage.getItem('role') } - $scope.toogleMerchantSelect = function () { - $scope.mapFrame = null; + + var origin_referrer_id = angular.copy($scope.partner.referrer_id) + var resetClientPayDescByTpey = function (type) { + type = parseInt(type) + if (type == 1) { + removeClientPayDesc($scope.partner.client_pay_desc, '10') + } + if (type == 2) { + removeClientPayDesc($scope.partner.client_pay_desc, '20') + } } - $scope.toogleMerchantSelect();*/ - }, - ]) - app.controller('compliancePartnerCtrl', [ - '$scope', - '$sce', - '$http', - '$filter', - '$uibModal', - 'businessStructuresMap', - 'industryMap', - 'stateMap', - 'sectorMap', - 'countryMap', - function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { - $scope.analysisClients = function () { - $http.get('/sys/partners/analysis').then(function (resp) { - $scope.analysis = resp.data - }) - } - if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { - $scope.analysisClients() - } - $scope.pagination = {} - $scope.industries = industryMap.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.sectors = sectorMap.configs() - $scope.business_structures = businessStructuresMap.configs() - $scope.clean_days = angular.copy(clean_days_map) - $scope.bd_citys = angular.copy(bd_city_map) - $scope.params = { textType: 'all', org_name: 'ALL', approving_flag: false, card_approving_flag: false } - - $scope.loadPartners = function (page) { - $scope.validAndCleanApproveStatus() - var params = angular.copy($scope.params) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/compliance', { params: params }).then(function (resp) { - $scope.partners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.validAndCleanApproveStatus = function () { - if (!$scope.params.cross_approving_flag && !$scope.params.card_approving_flag) { - $scope.params.approving = false - $scope.params.card_approving = false - $scope.params.waitingCompliance = false - $scope.params.tempMchId = false - $scope.params.bd_upload_material = false - $scope.params.quickPass = false - $scope.params.greenChannel = false - $scope.params.pass = false - $scope.params.completed_contract = false - $scope.params.apply_to_back = false - $scope.params.is_valid = false - } - if (!$scope.params.cross_approving_flag && $scope.params.card_approving_flag) { - $scope.params.tempMchId = false - $scope.params.quickPass = false - $scope.params.greenChannel = false - } - } - - $scope.today = new Date() - - $scope.listBDUsers = function () { - $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { - $scope.bdUserSource = resp.data - }) - } - $scope.listBDUsers() - - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - $scope.showOrg = 'Organization' - $http.get('/sys/orgs/list_all_Org', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - $scope.loadOrgs() - - $scope.loadPartners(1) - - $scope.openClientBoard = function (client) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/partner_card.html', - controller: 'partnerCardCtrl', - resolve: { - clientMoniker: function () { - return client.client_moniker - }, - }, - size: 'lg', - }) - } - }, - ]) - app.controller('partnerDetailCtrl', [ - '$scope', - '$http', - '$state', - '$uibModal', - '$rootScope', - 'Upload', - 'commonDialog', - 'partner', - '$sce', - function ($scope, $http, $state, $uibModal, $rootScope, Upload, commonDialog, partner, $sce) { - $scope.init = { wechat_compliance: false, local_merchant: false } - $scope.partner = partner.data - $scope.isComplianceOfCompanyName = false - $scope.isComplianceOfShortName = false - $scope.isComplianceOfBusinessStructure = false - $scope.cardPromotionaparams = {} - if ($scope.partner.mc_code) { - $scope.partner.mc_code = $scope.partner.mc_code - } - var website = partner.data.company_website - if (website != null) { - if (website.indexOf('http') !== 0) { - $scope.partner.company_website = 'http://' + angular.copy(website) - } - } - $scope.decideCompliance = function (name) { - var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] - for (var i = 0; i < keywords.length; i++) { - if (name.indexOf(keywords[i]) !== -1) { - return true - } - } - return false - } - if (partner.data.company_name != null) { - $scope.isComplianceOfCompanyName = $scope.decideCompliance(partner.data.company_name) - } - if (partner.data.short_name != null) { - $scope.isComplianceOfShortName = $scope.decideCompliance(partner.data.short_name) - } - if (partner.data.business_structure != null) { - $scope.isComplianceOfBusinessStructure = $scope.decideCompliance(partner.data.business_structure) - } - $scope.showDBUsers = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bd_user').then(function (resp) { - $scope.partner.client_bds = resp.data - }) - } - $scope.showDBUsers() - $scope.showFile = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_agree_file').then(function (resp) { - $scope.fileManager = resp.data - }) - } - - $scope.showCardFile = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=letter_of_offer_file').then(function (resp) { - $scope.letterOfOfferFileManager = resp.data - }) - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=promotional_offer_file').then(function (resp) { - $scope.promotionalOfferFileManager = resp.data - }) - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=terms_and_conditions_file').then(function (resp) { - $scope.termsAndConditionsFile = resp.data - }) - } - - $scope.showFile() - $scope.showCardFile() - $scope.passClient = function () { - if (!$rootScope.complianceCheck) { - alert('please check first') - return - } - if (!$rootScope.complianceCheck.authFile) { - alert('Compliance Files not checked') - return - } - if (!$rootScope.complianceCheck.clientInfo) { - alert('Partner Detail not checked') - return - } - if (!$rootScope.complianceCheck.bankAccount) { - alert('Bank Account not checked') - return - } - var title = 'Audit Partner' - var content = 'Are you sure to mark partner ' + $scope.partner.company_name + ' audited?' - var choises = '' - var contentHtml = '' - if ($scope.isComplianceOfCompanyName || $scope.isComplianceOfShortName || $scope.isComplianceOfBusinessStructure) { - var info = [] - if ($scope.isComplianceOfCompanyName) { - info.push('Company Name') - } - if ($scope.isComplianceOfShortName) { - info.push('Short Name') - } - if ($scope.isComplianceOfBusinessStructure) { - info.push('Business Structure') - } - title = 'Warning' - contentHtml = $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息') - choises = [ - { label: '取消', className: 'btn-danger', key: '2', dismiss: true }, - { label: '确认提交', className: 'btn-success', key: '1' }, - ] - content = '' - } - commonDialog - .confirm({ - title: title, - content: content, - choises: choises, - contentHtml: contentHtml, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit', { pass: 1 }).then( - function () { - if ($scope.partner.approve_result == 2 && ($scope.partner.source == 1 || $scope.partner.source == 2)) { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed!', - type: 'success', - }) + var compare = function (x, y) { + x = parseInt(x) + y = parseInt(y) + if (x < y) { + return -1 + } else if (x > y) { + return 1 } else { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', - }) + return 0 } - delete $rootScope.complianceCheck - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.passCardClient = function () { - if (!$rootScope.complianceCheck) { - alert('please check first') - return - } - if (!$rootScope.complianceCheck.authFile) { - alert('Compliance Files not checked') - return - } - if (!$rootScope.complianceCheck.clientInfo) { - alert('Partner Detail not checked') - return - } - if (!$rootScope.complianceCheck.bankAccount) { - alert('Bank Account not checked') - return - } - var title = 'Audit Partner Card' - var content = 'Are you sure to mark partner ' + $scope.partner.company_name + ' audited?' - var choises = '' - var contentHtml = '' - if ($scope.isComplianceOfCompanyName || $scope.isComplianceOfShortName || $scope.isComplianceOfBusinessStructure) { - var info = [] - if ($scope.isComplianceOfCompanyName) { - info.push('Company Name') - } - if ($scope.isComplianceOfShortName) { - info.push('Short Name') - } - if ($scope.isComplianceOfBusinessStructure) { - info.push('Business Structure') - } - title = 'Warning' - contentHtml = $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息') - choises = [ - { label: '取消', className: 'btn-danger', key: '2', dismiss: true }, - { label: '确认提交', className: 'btn-success', key: '1' }, - ] - content = '' - } - commonDialog - .confirm({ - title: title, - content: content, - choises: choises, - contentHtml: contentHtml, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/card_audit', { pass: 1 }).then( - function () { - if ($scope.partner.approve_result == 2 && ($scope.partner.source == 1 || $scope.partner.source == 2)) { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed!', - type: 'success', - }) + } + $scope.toggleClientPayType = function (type) { + if (!$scope.partner.client_pay_type) { + $scope.partner.client_pay_type = [] + } + var $idx = $scope.partner.client_pay_type.indexOf(type) + if ($idx >= 0) { + $scope.partner.client_pay_type.splice($idx, 1) + resetClientPayDescByTpey(type) } else { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', - }) + $scope.partner.client_pay_type.push(type) + $scope.partner.client_pay_type.sort(compare) } - delete $rootScope.complianceCheck - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.pass2GreenChannel = function () { - commonDialog - .confirm({ - title: 'Green Channel Audit Partner', - content: 'Are you sure to mark partner ' + $scope.partner.company_name + ' green channel audited ?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/aduit/green_channel').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', + } + $scope.toggleClientPayDesc = function (type) { + if (!$scope.partner.client_pay_desc) { + $scope.partner.client_pay_desc = [] + } + var $idx = $scope.partner.client_pay_desc.indexOf(type) + if ($idx >= 0) { + if (type == '203') { + removeClientPayDesc($scope.partner.client_pay_desc, '2030') + } + $scope.partner.client_pay_desc.splice($idx, 1) + } else { + $scope.partner.client_pay_desc.push(type) + $scope.partner.client_pay_desc.sort(compare) + } + } + + $scope.partner.sameAsContactPerson = false + $scope.checkboxOnclick = function () { + $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson + if ($scope.partner.sameAsContactPerson) { + $scope.partner.legal_representative_person = $scope.partner.contact_person + $scope.partner.legal_representative_phone = $scope.partner.contact_phone + $scope.partner.legal_representative_email = $scope.partner.contact_email + $scope.partner.legal_representative_job = $scope.partner.contact_job + $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.marketingSameAsContact = false + $scope.checkMarketingSameAsContact = function () { + $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact + if ($scope.partner.marketingSameAsContact) { + $scope.partner.marketing_person = $scope.partner.contact_person + $scope.partner.marketing_phone = $scope.partner.contact_phone + $scope.partner.marketing_email = $scope.partner.contact_email + $scope.partner.marketing_job = $scope.partner.contact_job + $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.sameAsAddress = false + $scope.sameAddress = function () { + $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress + if ($scope.partner.sameAsAddress) { + // $scope.partner.registered_address = $scope.partner.address; + // $scope.partner.registered_suburb = $scope.partner.suburb; + // $scope.partner.registered_postcode = $scope.partner.postcode; + // $scope.partner.registered_state = $scope.partner.state; + $scope.partner.address = $scope.partner.registered_address + $scope.partner.suburb = $scope.partner.registered_suburb + $scope.partner.postcode = $scope.partner.registered_postcode + $scope.partner.state = $scope.partner.registered_state + } + } + + $scope.listReferrers = function () { + $http.get('/sys/orgs/referrer').then(function (resp) { + $scope.referrers = resp.data }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.showBg = false - $scope.exportPDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/agreepdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.exportAgreegatePDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - //制作卡支付合同 - $scope.exportCardAgreegatePDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/card_agree_pdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.Export = function () { - var url = '/dev/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf' - return url - } - $scope.uploadAgreeFile = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.agree_file_import = resp.data.url - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', { source_agree_file: $scope.agree_file_import }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Succeed Imported! Please notify BD', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }, - function (resp) { - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - } - ) - } - } - } - - $scope.uploadCardAgreeFile = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.agree_file_import = resp.data.url - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', { source_agree_file: $scope.agree_file_import }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Succeed Imported! Please notify BD', - type: 'success', + } + $scope.listReferrers() + + $scope.loadAlipayCategory = function () { + $http.get('/static/data/alipayMcc.json').then(function (resp) { + $scope.alipayMccCategory = resp.data + }) + } + $scope.loadAlipayCategory() + $scope.loadJDindustry = function () { + $http.get('/static/data/jdindustry.json').then(function (resp) { + $scope.jdindustry = resp.data + }) + } + $scope.loadJDindustry() + + $scope.loadLakalaPayindustry = function () { + $http.get('/static/data/lakalapayindustry.json').then(function (resp) { + $scope.lakalapayindustry = resp.data + }) + } + $scope.loadLakalaPayindustry() + + $scope.loadLakalaPaySettle = function () { + $http.get('/static/data/lakalapaysettle.json').then(function (resp) { + $scope.lakalapaysettle = resp.data + }) + } + $scope.loadLakalaPaySettle() + + $scope.loadLakalaPayGoods = function () { + $http.get('/static/data/lakalapaygoods.json').then(function (resp) { + $scope.lakalapaygoods = resp.data + }) + } + $scope.loadLakalaPayGoods() + + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + }) + } + $scope.loadRoyalpayindustry() + + $scope.loadHfindustry = function () { + $http.get('/static/data/hfindustry.json').then(function (resp) { + $scope.hfindustry = resp.data + }) + } + $scope.loadHfindustry() + + $scope.onAlipayMccSelect = function (selectedItem) { + $scope.partner.alipay_category = selectedItem.label + $scope.partner.alipayindustry = selectedItem.mccCode + } + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.partner.royalpay_label = selectedItem.label + $scope.partner.royalpayindustry = selectedItem.mccCode + } + $scope.onHfIndustrySelect = function (selectedItem) { + $scope.partner.hf_label = selectedItem.label + $scope.partner.hfindustry = selectedItem.mccCode + } + + $scope.updatePartner = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + return + } + + if ($scope.partner.company_name.indexOf('Migration') != -1) { + alert('Company Name包含敏感词汇,请检查后重新提交!') + return + } + if ($scope.partner.company_phone.indexOf(' ') != -1) { + alert('Company Phone can not contain space character') + return + } + if ($scope.partner.contact_email.indexOf(' ') != -1) { + alert('Contact email Phone can not contain space character') + return + } + if ($scope.partner.suburb.indexOf(' ') != -1) { + alert('suburb can not contain two and more continuous space characters') + return + } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if (!$scope.partner.company_photo) { + alert('Shop Photo1 is necessary') + return + } + if (!$scope.partner.store_photo) { + alert('Shop Photo2 is necessary') + return + } + } + + if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { + if ($scope.partner.acn.length != 9) { + alert('Acn is not valid') + } + } + if ($scope.partner.referrer_id) { + $scope.referrers.forEach(function (e) { + if ($scope.partner.referrer_id == e.org_id) { + $scope.partner.referrer_name = e.name + return + } + }) + } + var content = '' + if (!origin_referrer_id && $scope.partner.referrer_id) { + content = 'Update partner info successfully,But You Had add new Referrer,Please Change the BD Commission Proportion!' + } + if ($scope.partner.client_pay_type.length == 0) { + alert('请选择商户支付场景') + return + } + if ($scope.partner.client_pay_desc.length == 0) { + alert('请选择商户支付方式') + return + } + if ($scope.partner.client_pay_type.indexOf('1') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { + alert('请检查线上支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { + alert('请检查线下支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { + alert('请检查线下支付是否已选择收银系统类型') + return + } + } + $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') + $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') + $http.put('/sys/partners/' + $scope.partner.client_moniker, $scope.partner).then( + function () { + if (content != '') { + commonDialog.alert({ + title: 'Warning', + content: content, + type: 'error', + }) + } else { + commonDialog.alert({ + title: 'Success', + content: 'Update partner information successfully', + type: 'success', + }) + } + $scope.updateMerchantLocation() + $scope.loadPartners() + $state.go('^.detail', {clientMoniker: $scope.partner.client_moniker}, {reload: true}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } ) - }, - function (resp) { - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - } - ) - } - } - } - $scope.notifyBD = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/notify/completeAgree').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Notify BD Successed!.', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.cardNotifyBD = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/notify/cardCompleteAgree').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Notify BD Successed!.', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.downTempPdf = function () { - return '/sys/partners/' + $scope.partner.client_moniker + '/temp/export/pdf' - } - - $scope.refuse = function () { - commonDialog.inputText({ title: 'refuse cause' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/refuse', { refuse_remark: text }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Audit application has been refused.', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.cardRefuse = function () { - commonDialog.inputText({ title: 'refuse cause' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/card_audit/refuse', { refuse_remark: text }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Card Audit application has been refused.', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.deleteClient = function () { - commonDialog - .confirm({ - title: 'Delete Partner', - content: 'Are you sure to delete ' + $scope.partner.company_name + '?', - }) - .then(function () { - $http.delete('/sys/partners/' + $scope.partner.client_moniker).then( - function () { - $state.go('^') - commonDialog.alert({ title: 'Delete', content: 'Partner Already Disabled', type: 'error' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.revertClient = function () { - commonDialog - .confirm({ - title: 'Revert Partner', - content: 'Are you sure to Revert ' + $scope.partner.company_name + '?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/revert').then( - function () { - $state.go('^') - commonDialog.alert({ title: 'Revert', content: 'Partner Already Revert', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.commitToCompliance = function () { - commonDialog - .confirm({ - title: 'Commit to Compliance', - content: 'Are you sure to commit ' + $scope.partner.company_name + ' to compliance?', - choises: [ - { label: 'Submit', className: 'btn-success', key: 1 }, - { label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true }, - ], - }) - .then(function (choice) { - if (choice == 1) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/to_compliance', {}).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Commit to Compliance successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }) - } - - $scope.commitToCardCompliance = function () { - commonDialog - .confirm({ - title: 'Commit to Compliance', - content: 'Are you sure to commit ' + $scope.partner.company_name + ' to compliance?', - choises: [ - { label: 'Submit', className: 'btn-success', key: 1 }, - { label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true }, - ], - }) - .then(function (choice) { - if (choice == 1) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/to_card_compliance', {}).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Commit to Compliance successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }) - } - $scope.apply2makeAgreeFile = function () { - if (!$scope.partner.enable_cross_payment) { - commonDialog.alert({ - title: 'Error!', - content: '请完善商户跨境支付基本信息、签约费率、合规文件!', - type: 'error', - }) - $state.go('partners.edit', { - clientMoniker: $scope.partner.client_moniker, - commitCardPayment: false, - commitCrossBorderPayment: true, - }) - return - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/make_agree_file').then( - function () { - commonDialog.alert({ - title: 'Success!', - content: '已提交制作合同!', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.apply2makeCardAgreeFile = function () { - if (!$scope.partner.enable_card_payment) { - commonDialog.alert({ - title: 'Error!', - content: '请完善商户卡支付基本信息、签约费率、合规文件!', - type: 'error', - }) - $state.go('partners.edit', { - clientMoniker: $scope.partner.client_moniker, - commitCardPayment: true, - commitCrossBorderPayment: false, - }) - return - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/make_card_agree_file').then( - function () { - commonDialog.alert({ - title: 'Success!', - content: '已提交制作合同!', - type: 'success', - }) - $state.reload() - }, - function (resp) { - if (String(resp.data.message).match('No Rate Config')) { - commonDialog.alert({ - title: 'Error!', - content: '商户卡支付签约费率未配置,请添加商户卡支付签约费率!', - type: 'error', - }) - $state.go('partners.detail.rates', { - clientMoniker: $scope.partner.client_moniker, - }) - } else { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - } - ) - } - - $scope.commit2GreenChannel = function () { - commonDialog - .confirm({ - title: 'Audit Partner', - content: 'Are you sure to mark partner ' + $scope.partner.company_name + ' Green Channel?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/compliance/green_channel').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Commit to Green Channel successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.markAuditEmail = function () { - commonDialog - .confirm({ - title: 'Warning', - content: 'Make sure you have send the email to client.', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/email_sending_status').then( - function () { - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.resendApproveEmail = function (type) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will reset the password of admin user. Are you sure this email is correct ? Or you may update this information first.', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/send_email?type=' + type).then( - function () { - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.editBDUser = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', - controller: 'partnerChooseBDUserDialogCtrl', - resolve: { - bdUsers: [ - '$http', - function ($http) { - return $http.get('/sys/manager_accounts/roles/bd_user') - }, - ], - partner: function () { - return $scope.partner - }, - type: function () { - return 'edit' - }, - }, - }) - .result.then(function () { - $state.reload() - }) - } - $scope.bindBDUser = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', - controller: 'partnerChooseBDUserDialogCtrl', - resolve: { - bdUsers: [ - '$http', - function ($http) { - return $http.get('/sys/manager_accounts/roles/bd_user') - }, - ], - partner: function () { - return $scope.partner - }, - type: function () { - return 'add' - }, - }, - }) - .result.then(function () { - $state.reload() - }) - } - - $scope.configMasterMerchant = function () { - commonDialog.inputText({ title: 'Input Master Merchant Code' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/master_configuration', { master_merchant: text }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Master Merchant Code:' + text, - type: 'success', - }) - }, - function (resp) { - commonDialog.alert({ - title: 'Config Master Merchant Failed', - content: resp.data.message, - type: 'error', - }) - } - ) - }) - } - $scope.getMerchantLocation = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { - $scope.merchant_location = resp.data - }) - } - $scope.getMerchantLocation() - - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.clientInfo = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() + } + $scope.uploadLogo = function (file) { + if (file != null) { + if (file.size > 1 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error'}) + } else { + $scope.logoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.logoProgress + $scope.partner.logo_id = resp.data.fileid + $scope.partner.logo_url = resp.data.url + }, + function (resp) { + delete $scope.logoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - $scope.changeWechatCompliance = function () { - if (!$scope.partner) { - return - } - if (!$state.is('partners.detail')) { - $scope.init.wechat_compliance = false - return - } - if (!$scope.init.wechat_compliance) { - $scope.init.wechat_compliance = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_compliance_permission', { allow: $scope.partner.wechat_compliance }).then( - function () {}, - function (resp) { - commonDialog.alert({ - title: 'failed to change wechat_compliance permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.changeLocalMerchant = function () { - if (!$scope.partner) { - return - } - if (!$state.is('partners.detail')) { - $scope.init.local_merchant = false - return - } - if (!$scope.init.local_merchant) { - $scope.init.local_merchant = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/local_merchant_permission', { allow: $scope.partner.local_merchant }).then( - function () {}, - function (resp) { - commonDialog.alert({ - title: 'failed to change local_merchant permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.removeSub = function () { - $http.delete('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { - $state.reload() - }) - } - $scope.addSub = function () { - $http.put('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { - $state.reload() - }) - } - }, - ]) - app.controller('partnerPaymentInfoCtrl', [ - '$scope', - '$http', - '$state', - 'commonDialog', - '$uibModal', - '$sce', - function ($scope, $http, $state, commonDialog, $uibModal, $sce) { - $scope.convertExtParams = [] - $scope.copyHfLink = function () { - var e = document.getElementById('cpbt') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.copyYeepayLink = function () { - var e = document.getElementById('cpyeepay') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.copyCBBankPayLink = function () { - var e = document.getElementById('cpcbbankpay') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.loadPartnerPaymentInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.extParams = {} - $scope.paymentInfo = resp.data - $scope.extParams = $scope.paymentInfo.ext_params ? JSON.parse($scope.paymentInfo.ext_params) : null - $scope.convertExtParams = $scope.extParamsEditFlags() - $scope.ctrl.editSubMerchant = false - $scope.ctrl.editAliSubMerchant = false - $scope.ctrl.editMaxOrderAmount = false - $scope.ctrl.editOrderExpiryConfig = false - $scope.ctrl.editRefundPwd = false - $scope.ctrl.editRefundCreditLine = false - }) - } - $scope.extParamsEditFlags = function () { - var paramList = [] - if ($scope.extParams != null) { - for (var key in $scope.extParams) { - var obj = {} - if (typeof $scope.extParams[key] != 'boolean') { - obj.name = key - obj.value = $scope.extParams[key] - obj.type = 'string' - obj.flag = false - } else { - obj.name = key - obj.value = $scope.extParams[key] - obj.type = 'boolean' + $scope.uploadShopPhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.shopPhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.shopPhotoProgress + $scope.partner.company_photo = resp.data.url + }, + function (resp) { + delete $scope.shopPhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } } - paramList.push(obj) - } - } - return paramList - } - $scope.qrConfig = { currency: 'AUD' } - $scope.reloadQRCode = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/qrcode', { params: $scope.qrConfig }).then(function (resp) { - $scope.qrcode = resp.data - }) - } - $scope.reloadQRCode() - $scope.loadPartnerPaymentInfo() - - $scope.showSubMerchantLogs = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', - controller: 'clientSubMerchantIdLogCtrl', - size: 'lg', - resolve: { - logs: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') - }, - ], - }, - }) - .result.then(function () { - $scope.loadSubClients() - }) - } - - $scope.saveMaxOrderAmount = function (limit) { - if (limit != null && isNaN(limit)) { - commonDialog.alert({ title: 'Error', content: 'Your input is not a number!', type: 'error' }) - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/max_order_amount', { limit: limit }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.saveCustomerSurchargeRate = function (cofig) { - if (cofig != null && isNaN(cofig)) { - commonDialog.alert({ title: 'Error', content: 'Your input is not a number!', type: 'error' }) - return - } - if (!$scope.paymentInfo.rate_value) { - commonDialog.alert({ - title: 'Error', - content: 'The merchant has not pass approval process', - type: 'error', - }) - return - } - if (cofig > 3 || cofig < parseFloat(Decimal.add($scope.paymentInfo.rate_value, 0.1).toFixed(2))) { - commonDialog.alert({ title: 'Error', content: 'Not in the valid range', type: 'error' }) - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_surcharge_rate', { customer_surcharge_rate: cofig }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - $scope.ctrl.editCustomerSurchargeRate = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.saveOrderExpiryConfig = function (config) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/order_expiry_config', { order_expiry_config: config }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.resetRefundPwd = function (config) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/reset/refund_pwd', { new_refund_password: config }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.setRefundCreditLine = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_credit_line', { refund_credit_line: $scope.paymentInfo.refund_credit_line }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.updateClientQRCodePaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.qrcode_surcharge) { - $scope.init.qrcode_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/qrcode_surcharge', { qrcode_surcharge: $scope.paymentInfo.qrcode_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.updateClientCBBankPaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_surcharge', { cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge }).then( - function () { - // $scope.loadPartnerPaymentInfo(); - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Customer Pay for Surcharge for Retail', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.updateClientApiSurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.api_surcharge) { - $scope.init.api_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/api_surcharge', { api_surcharge: $scope.paymentInfo.api_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.updateClientRetailPaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.retail_surcharge) { - $scope.init.retail_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/retail_surcharge', { retail_surcharge: $scope.paymentInfo.retail_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.ctrl = {} - $scope.saveSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: $scope.paymentInfo.sub_merchant_id }).then( - function (resp) { - $scope.refreshWechatInstitutionMerchantId() - $scope.ctrl.editSubMerchant = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.refreshWechatInstitutionMerchantId = function () { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { - wechat_institution_merchant_id: $scope.paymentInfo.wechat_institution_merchant_id, - }) - .then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.saveAliSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.paymentInfo.ali_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Ali Sub Merchant ID successfully', - type: 'success', - }) - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.submitAlipaySubId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { - $scope.alipay_gms_json = resp.data - commonDialog - .confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json: $scope.alipay_gms_json, - }) - .then(function () { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( - function () { - commonDialog.alert({ title: 'Success', content: 'Alipay进件成功', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '进件失败:' + resp.data.message, type: 'error' }) + $scope.uploadStorePhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.storePhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.storePhotoProgress + $scope.partner.store_photo = resp.data.url + }, + function (resp) { + delete $scope.storePhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } } - ) - }) - }) - } - $scope.queryAlipayGms = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( - function (resp) { - commonDialog.alert({ title: 'Success', content: resp.data.result_status, type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '查询失败:' + resp.data.message, type: 'error' }) - } - ) - } - $scope.submitAlipayOnlineSubId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { - $scope.alipayOnline_gms_json = resp.data - commonDialog - .confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json: $scope.alipayOnline_gms_json, - }) - .then(function () { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( - function () { - commonDialog.alert({ title: 'Success', content: '提示:AlipayOnline进件成功', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '进件失败:' + resp.data.message, type: 'error' }) + } + + $scope.getMerchantLocation = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { + $scope.merchant_location = resp.data + }) + } + $scope.getMerchantLocation() + + $scope.updateMerchantLocation = function () { + var params = window.frames['merchant_detail'].merchant_location + if (params) { + $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () { + }) } - ) - }) - }) - } - $scope.queryAlipayOnlineGms = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( - function (resp) { - commonDialog.alert({ title: 'Success', content: resp.data.result_status, type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '查询失败:' + resp.data.message, type: 'error' }) - } - ) - } - $scope.refreshCredential = function () { - commonDialog - .confirm({ - title: 'Warning', - content: 'Refresh Credential will expire the current one, which will cause the current payment service disabled. Are you sure going on?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/credential_code').then( - function () { - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.init = { - jsapi: false, - gateway: false, - offline: false, - refund: false, - common_sub_merchant_id: false, - channel: {}, - gateway_alipay_online: false, - hf_Link: false, - enable_hf_email_notice: false, - enable_yeepay_link: false, - enable_yeepay_email_notice: false, - } - $scope.switchCommonSubMerchantId = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.common_sub_merchant_id) { - $scope.init.common_sub_merchant_id = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', { allow: $scope.paymentInfo.common_sub_merchant_id }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change common_sub_merchant_id permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + } + }, + ]) + app.controller('partnerListCtrl', [ + '$scope', + '$sce', + '$http', + '$filter', + '$uibModal', + 'businessStructuresMap', + 'industryMap', + 'stateMap', + 'sectorMap', + 'countryMap', + function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { + $scope.analysisClients = function () { + $http.get('/sys/partners/analysis').then(function (resp) { + $scope.analysis = resp.data + }) + } + if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { + $scope.analysisClients() + } + $scope.pagination = {} + $scope.industries = industryMap.configs() + $scope.states = stateMap.configs() + $scope.countries = countryMap.configs() + $scope.sectors = sectorMap.configs() + $scope.business_structures = businessStructuresMap.configs() + $scope.clean_days = angular.copy(clean_days_map) + $scope.bd_citys = angular.copy(bd_city_map) + $scope.params = {textType: 'all', org_name: 'ALL', industry: '0'} + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + var selectAll = { + label: 'All', + mccCode: '0', + children: {}, + } + $scope.royalpayindustry.unshift(selectAll) + }) + } - $scope.switchSubManage = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.sub_manage) { - $scope.init.sub_manage = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', { allow: $scope.paymentInfo.sub_manage }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change Sub Partners Manage status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - var info = [] - $scope.decideCompliance = function (name) { - var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] - for (var i = 0; i < keywords.length; i++) { - if (name.indexOf(keywords[i]) != -1) { - return true - } - } - return false - } - $scope.getComplianceInfo = function () { - if ($scope.paymentInfo.company_name != null) { - if ($scope.decideCompliance($scope.paymentInfo.company_name)) { - info.push('Company Name') - } - } - if ($scope.paymentInfo.short_name != null) { - if ($scope.decideCompliance($scope.paymentInfo.short_name)) { - info.push('Short Name') - } - } - if ($scope.paymentInfo.business_structure != null) { - if ($scope.decideCompliance($scope.paymentInfo.business_structure)) { - info.push('Business Structure') - } - } - } - $scope.toggleChannel = function (channel) { - if (!channel) { - return - } - if (!$scope.paymentInfo) { - return - } - // if (!$scope.init.channel[channel]) { - // $scope.init.channel[channel] = true - // return - // } - $scope.getComplianceInfo() - if ($scope.paymentInfo['enable_wechat'] && channel == 'wechat' && $scope.paymentInfo.open_status == 5 && info.length > 0) { - commonDialog - .confirm({ - title: 'Warning', - contentHtml: $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息'), - }) - .then(function () { - $scope.saveChannel(channel) - }) - } else { - $scope.saveChannel(channel) - } - info = [] - } - $scope.saveChannel = function (channel) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/channels/' + channel + '/permission', { allow: $scope.paymentInfo['enable_' + channel] }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change ' + channel + ' channel permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleHfLink = function (channel) { - if (!channel) { - return - } - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.hf_Link) { - $scope.init.hf_Link = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf', { allow: $scope.paymentInfo.enable_link }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change enable_link permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.loadRoyalpayindustry() - $scope.toggleGatewayLink = function (channel) { - if (!channel) { - return - } - if (!$scope.paymentInfo) { - return - } - var channelLink = 'enable_' + channel + '_link' - if (!$scope.init[channelLink]) { - $scope.init[channelLink] = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel, { allow: $scope.paymentInfo[channelLink] }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change ' + channelLink + ' permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.params.royalpay_label = selectedItem.label + $scope.params.industry = selectedItem.mccCode + $scope.loadPartners(1) + } - $scope.toggleCBBankPayLink = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', { allow: $scope.paymentInfo.enable_cb_bankpay_link }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change cb_bankpay permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.cb_bankpay = [] - $scope.cbChannelConfig = function () { - $http.get('/sysconfig/payment/config').then(function (resp) { - resp.data.forEach(function (channel) { - if (channel.type === 1) { - $scope.cb_bankpay.push(channel) - } - }) - }) - } - $scope.cbChannelConfig() - $scope.updateCBBankPayConfig = function (key, channel) { - var content = '' - if (channel == null) { - content = '你确定要将支付通道跟随系统' - } else { - content = '你确定要将支付通道更改为:' + channel - } - commonDialog - .confirm({ - title: 'Confirm', - content: content, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay/' + key + '/channel_id', { channel_id: channel }).then( - function (resp) { - commonDialog.alert({ type: 'success', title: 'Success', content: '修改成功' }) - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message }) - $scope.loadPartnerPaymentInfo() - } - ) - }) - } - $scope.toggleGatewayEmailNotice = function (channel) { - if (!$scope.paymentInfo) { - return - } - var channelNotice = 'enable_' + channel + '_email_notice' - if (!$scope.init[channelNotice]) { - $scope.init[channelNotice] = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel + '/email_notice', { allow: $scope.paymentInfo[channelNotice] }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change ' + channelNotice + ' permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.loadPartners = function (page) { + var params = angular.copy($scope.params) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners', {params: params}).then(function (resp) { + $scope.partners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } - $scope.toggleHfEmailNotice = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_hf_email_notice) { - $scope.init.enable_hf_email_notice = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf/email_notice', { allow: $scope.paymentInfo.enable_hf_email_notice }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change enable_hf_email_notice permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.exportPartnersExcel = function () { + var params = angular.copy($scope.params) + var param_str = Object.keys(params) + .map(function (key) { + var value = params[key] + if (angular.isDate(value)) { + value = $filter('date')(value, 'yyyy-MM-ddTHH:mm:ssZ') + } + return key + '=' + encodeURIComponent(value) + }) + .join('&') + window.open('/sys/partners/exporting_excel?' + param_str) + } - $scope.toggleJsApi = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.jsapi) { - $scope.init.jsapi = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/jsapi_permission', { allow: $scope.paymentInfo.enable_jsapi }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change JSApi permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGateway = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway) { - $scope.init.gateway = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_permission', { allow: $scope.paymentInfo.enable_gateway }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGatewayUpgrade = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway_upgrade) { - $scope.init.gateway_upgrade = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_upgrade', { gateway_upgrade: $scope.paymentInfo.gateway_upgrade }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway Upgrade status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGatewayAlipayOnline = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway_alipay_online) { - $scope.init.gateway_alipay_online = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_alipay_online', { gateway_alipay_online: $scope.paymentInfo.gateway_alipay_online }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway Alipay Online status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleRefund = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_refund) { - $scope.init.enable_refund = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_permission', { allow: $scope.paymentInfo.enable_refund }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Refund permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.togglePreRefund = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_pre_refund) { - $scope.init.enable_pre_refund = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/pre_refund_permission', { allow: $scope.paymentInfo.enable_pre_refund }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Refund permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleOffline = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.offline) { - $scope.init.offline = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/offline_permission', { allow: $scope.paymentInfo.enable_retail }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Offline permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + /*$scope.loadLocations = function () { + var params = angular.copy($scope.params); + $http.get('/sys/partners/merchant/list_locations', {params: params}).then(function (resp) { + $scope.locations = resp.data; + window.merchant_maps.initMap($scope.locations); + }); + };*/ + $scope.today = new Date() - $scope.switchInternationalCard = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_International_card) { - $scope.init.enable_International_card = true - return - } - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { - key: 'enable_international_card', - allow: $scope.paymentInfo.enable_international_card, - }) - .then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change international card permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.switchThreeDS = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_threeds) { - $scope.init.enable_threeds = true - return - } - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { - allow: $scope.paymentInfo.enable_threeds, - key: 'enable_threeds', - }) - .then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change international card permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.changePaymentPage = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_page_version', { paypad_version: $scope.paymentInfo.paypad_version }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Payment Page Version', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.listBDUsers = function () { + $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { + $scope.bdUserSource = resp.data + }) + } + $scope.listBDUsers() - $scope.changeCBBankPaymentPage = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_payment_page_version', { cbbank_paypad_version: $scope.paymentInfo.cbbank_paypad_version }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change CBBank Payment Page Version', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - // 更改支付成功页 - $scope.changePaySuccessPage = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/paysuccess_version', { paysuccess_version: $scope.paymentInfo.paysuccess_version }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Payment Success Page Version', - content: resp.data.message, - type: 'error', - }) - } - ) - } + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + $scope.showOrg = 'Organization' + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { + $scope.orgs = resp.data + }) + } + + $scope.loadOrgs = function () { + var params = angular.copy($scope.params) + $http.get('/sys/orgs/orgChild', {params: params}).then(function (resp) { + $scope.orgs_child = resp.data + }) + } + $scope.loadOrgs() + + /* $scope.onOrgsSelect = function (selectedItem) { + $scope.params.org_id = selectedItem.org_id; + $scope.params.org_name = selectedItem.label; + $scope.loadPartners(); + }; + */ + /* $scope.chooseOrg = function (org) { + if (org == 'all') { + delete $scope.params.org_id; + $scope.showOrg = 'All' + } else { + $scope.params.org_id = org.org_id; + $scope.showOrg = org.name; + } + $scope.loadPartners(1); + };*/ + + $scope.loadPartners(1) + + $scope.openClientBoard = function (client) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/partner_card.html', + controller: 'partnerCardCtrl', + resolve: { + clientMoniker: function () { + return client.client_moniker + }, + }, + size: 'lg', + }) + } + /*$scope.toogleMapSelect = function () { + $scope.mapFrame = 'all_locations.html'; + $scope.loadLocations(); + } + $scope.toogleMerchantSelect = function () { + $scope.mapFrame = null; + } + $scope.toogleMerchantSelect();*/ + }, + ]) + app.controller('compliancePartnerCtrl', [ + '$scope', + '$sce', + '$http', + '$filter', + '$uibModal', + 'businessStructuresMap', + 'industryMap', + 'stateMap', + 'sectorMap', + 'countryMap', + function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { + $scope.analysisClients = function () { + $http.get('/sys/partners/analysis').then(function (resp) { + $scope.analysis = resp.data + }) + } + if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { + $scope.analysisClients() + } + $scope.pagination = {} + $scope.industries = industryMap.configs() + $scope.states = stateMap.configs() + $scope.countries = countryMap.configs() + $scope.sectors = sectorMap.configs() + $scope.business_structures = businessStructuresMap.configs() + $scope.clean_days = angular.copy(clean_days_map) + $scope.bd_citys = angular.copy(bd_city_map) + $scope.params = {textType: 'all', org_name: 'ALL', approving_flag: false, card_approving_flag: false} + + $scope.loadPartners = function (page) { + $scope.validAndCleanApproveStatus() + var params = angular.copy($scope.params) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/compliance', {params: params}).then(function (resp) { + $scope.partners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } + + $scope.validAndCleanApproveStatus = function () { + if (!$scope.params.cross_approving_flag && !$scope.params.card_approving_flag) { + $scope.params.approving = false + $scope.params.card_approving = false + $scope.params.waitingCompliance = false + $scope.params.tempMchId = false + $scope.params.bd_upload_material = false + $scope.params.quickPass = false + $scope.params.greenChannel = false + $scope.params.pass = false + $scope.params.completed_contract = false + $scope.params.apply_to_back = false + $scope.params.is_valid = false + } + if (!$scope.params.cross_approving_flag && $scope.params.card_approving_flag) { + $scope.params.tempMchId = false + $scope.params.quickPass = false + $scope.params.greenChannel = false + } + } + + $scope.today = new Date() + + $scope.listBDUsers = function () { + $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { + $scope.bdUserSource = resp.data + }) + } + $scope.listBDUsers() + + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + $scope.showOrg = 'Organization' + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { + $scope.orgs = resp.data + }) + } + + $scope.loadOrgs = function () { + var params = angular.copy($scope.params) + $http.get('/sys/orgs/orgChild', {params: params}).then(function (resp) { + $scope.orgs_child = resp.data + }) + } + $scope.loadOrgs() + + $scope.loadPartners(1) + + $scope.openClientBoard = function (client) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/partner_card.html', + controller: 'partnerCardCtrl', + resolve: { + clientMoniker: function () { + return client.client_moniker + }, + }, + size: 'lg', + }) + } + }, + ]) + app.controller('partnerDetailCtrl', [ + '$scope', + '$http', + '$state', + '$uibModal', + '$rootScope', + 'Upload', + 'commonDialog', + 'partner', + '$sce', + function ($scope, $http, $state, $uibModal, $rootScope, Upload, commonDialog, partner, $sce) { + $scope.init = {wechat_compliance: false, local_merchant: false} + $scope.partner = partner.data + $scope.isComplianceOfCompanyName = false + $scope.isComplianceOfShortName = false + $scope.isComplianceOfBusinessStructure = false + $scope.cardPromotionaparams = {} + if ($scope.partner.mc_code) { + $scope.partner.mc_code = $scope.partner.mc_code + } + var website = partner.data.company_website + if (website != null) { + if (website.indexOf('http') !== 0) { + $scope.partner.company_website = 'http://' + angular.copy(website) + } + } + $scope.decideCompliance = function (name) { + var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] + for (var i = 0; i < keywords.length; i++) { + if (name.indexOf(keywords[i]) !== -1) { + return true + } + } + return false + } + if (partner.data.company_name != null) { + $scope.isComplianceOfCompanyName = $scope.decideCompliance(partner.data.company_name) + } + if (partner.data.short_name != null) { + $scope.isComplianceOfShortName = $scope.decideCompliance(partner.data.short_name) + } + if (partner.data.business_structure != null) { + $scope.isComplianceOfBusinessStructure = $scope.decideCompliance(partner.data.business_structure) + } + $scope.showDBUsers = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bd_user').then(function (resp) { + $scope.partner.client_bds = resp.data + }) + } + $scope.showDBUsers() + $scope.showFile = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_agree_file').then(function (resp) { + $scope.fileManager = resp.data + }) + } + + $scope.showCardFile = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=letter_of_offer_file').then(function (resp) { + $scope.letterOfOfferFileManager = resp.data + }) + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=promotional_offer_file').then(function (resp) { + $scope.promotionalOfferFileManager = resp.data + }) + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/file/source_card_agree_file?fileName=terms_and_conditions_file').then(function (resp) { + $scope.termsAndConditionsFile = resp.data + }) + } + + $scope.showFile() + $scope.showCardFile() + $scope.passClient = function () { + if (!$rootScope.complianceCheck) { + alert('please check first') + return + } + if (!$rootScope.complianceCheck.authFile) { + alert('Compliance Files not checked') + return + } + if (!$rootScope.complianceCheck.clientInfo) { + alert('Partner Detail not checked') + return + } + if (!$rootScope.complianceCheck.bankAccount) { + alert('Bank Account not checked') + return + } + var title = 'Audit Partner' + var content = 'Are you sure to mark partner ' + $scope.partner.company_name + ' audited?' + var choises = '' + var contentHtml = '' + if ($scope.isComplianceOfCompanyName || $scope.isComplianceOfShortName || $scope.isComplianceOfBusinessStructure) { + var info = [] + if ($scope.isComplianceOfCompanyName) { + info.push('Company Name') + } + if ($scope.isComplianceOfShortName) { + info.push('Short Name') + } + if ($scope.isComplianceOfBusinessStructure) { + info.push('Business Structure') + } + title = 'Warning' + contentHtml = $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息') + choises = [ + {label: '取消', className: 'btn-danger', key: '2', dismiss: true}, + {label: '确认提交', className: 'btn-success', key: '1'}, + ] + content = '' + } + commonDialog + .confirm({ + title: title, + content: content, + choises: choises, + contentHtml: contentHtml, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit', {pass: 1}).then( + function () { + if ($scope.partner.approve_result == 2 && ($scope.partner.source == 1 || $scope.partner.source == 2)) { + commonDialog.alert({ + title: 'Success', + content: 'Comply Passed!', + type: 'success', + }) + } else { + commonDialog.alert({ + title: 'Success', + content: 'Comply Passed! Email will send to contact email address soon.', + type: 'success', + }) + } + delete $rootScope.complianceCheck + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.passCardClient = function () { + if (!$rootScope.complianceCheck) { + alert('please check first') + return + } + if (!$rootScope.complianceCheck.authFile) { + alert('Compliance Files not checked') + return + } + if (!$rootScope.complianceCheck.clientInfo) { + alert('Partner Detail not checked') + return + } + if (!$rootScope.complianceCheck.bankAccount) { + alert('Bank Account not checked') + return + } + var title = 'Audit Partner Card' + var content = 'Are you sure to mark partner ' + $scope.partner.company_name + ' audited?' + var choises = '' + var contentHtml = '' + if ($scope.isComplianceOfCompanyName || $scope.isComplianceOfShortName || $scope.isComplianceOfBusinessStructure) { + var info = [] + if ($scope.isComplianceOfCompanyName) { + info.push('Company Name') + } + if ($scope.isComplianceOfShortName) { + info.push('Short Name') + } + if ($scope.isComplianceOfBusinessStructure) { + info.push('Business Structure') + } + title = 'Warning' + contentHtml = $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息') + choises = [ + {label: '取消', className: 'btn-danger', key: '2', dismiss: true}, + {label: '确认提交', className: 'btn-success', key: '1'}, + ] + content = '' + } + commonDialog + .confirm({ + title: title, + content: content, + choises: choises, + contentHtml: contentHtml, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/card_audit', {pass: 1}).then( + function () { + if ($scope.partner.approve_result == 2 && ($scope.partner.source == 1 || $scope.partner.source == 2)) { + commonDialog.alert({ + title: 'Success', + content: 'Comply Passed!', + type: 'success', + }) + } else { + commonDialog.alert({ + title: 'Success', + content: 'Comply Passed! Email will send to contact email address soon.', + type: 'success', + }) + } + delete $rootScope.complianceCheck + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.pass2GreenChannel = function () { + commonDialog + .confirm({ + title: 'Green Channel Audit Partner', + content: 'Are you sure to mark partner ' + $scope.partner.company_name + ' green channel audited ?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/aduit/green_channel').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Comply Passed! Email will send to contact email address soon.', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.showBg = false + $scope.exportPDF = function () { + $scope.showBg = true + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/agreepdf').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Agreement File Generate Succeed! Please notify BD!', + type: 'success', + }) + $scope.showBg = false + $state.reload() + }, + function (resp) { + $scope.showBg = false + $state.reload() + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.exportAgreegatePDF = function () { + $scope.showBg = true + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Agreement File Generate Succeed! Please notify BD!', + type: 'success', + }) + $scope.showBg = false + $state.reload() + }, + function (resp) { + $scope.showBg = false + $state.reload() + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + //制作卡支付合同 + $scope.exportCardAgreegatePDF = function () { + $scope.showBg = true + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/card_agree_pdf').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Agreement File Generate Succeed! Please notify BD!', + type: 'success', + }) + $scope.showBg = false + $state.reload() + }, + function (resp) { + $scope.showBg = false + $state.reload() + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.Export = function () { + var url = '/dev/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf' + return url + } + $scope.uploadAgreeFile = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.agree_file_import = resp.data.url + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', {source_agree_file: $scope.agree_file_import}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Succeed Imported! Please notify BD', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }, + function (resp) { + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + } + ) + } + } + } + + $scope.uploadCardAgreeFile = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.agree_file_import = resp.data.url + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', {source_agree_file: $scope.agree_file_import}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Succeed Imported! Please notify BD', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }, + function (resp) { + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + } + ) + } + } + } + $scope.notifyBD = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/notify/completeAgree').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Notify BD Successed!.', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.cardNotifyBD = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/notify/cardCompleteAgree').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Notify BD Successed!.', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.downTempPdf = function () { + return '/sys/partners/' + $scope.partner.client_moniker + '/temp/export/pdf' + } + + $scope.refuse = function () { + commonDialog.inputText({title: 'refuse cause'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/refuse', {refuse_remark: text}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Audit application has been refused.', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.cardRefuse = function () { + commonDialog.inputText({title: 'refuse cause'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/card_audit/refuse', {refuse_remark: text}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Card Audit application has been refused.', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.deleteClient = function () { + commonDialog + .confirm({ + title: 'Delete Partner', + content: 'Are you sure to delete ' + $scope.partner.company_name + '?', + }) + .then(function () { + $http.delete('/sys/partners/' + $scope.partner.client_moniker).then( + function () { + $state.go('^') + commonDialog.alert({ + title: 'Delete', + content: 'Partner Already Disabled', + type: 'error' + }) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.revertClient = function () { + commonDialog + .confirm({ + title: 'Revert Partner', + content: 'Are you sure to Revert ' + $scope.partner.company_name + '?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/revert').then( + function () { + $state.go('^') + commonDialog.alert({ + title: 'Revert', + content: 'Partner Already Revert', + type: 'success' + }) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.commitToCompliance = function () { + commonDialog + .confirm({ + title: 'Commit to Compliance', + content: 'Are you sure to commit ' + $scope.partner.company_name + ' to compliance?', + choises: [ + {label: 'Submit', className: 'btn-success', key: 1}, + {label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true}, + ], + }) + .then(function (choice) { + if (choice == 1) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/to_compliance', {}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Commit to Compliance successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }) + } + + $scope.commitToCardCompliance = function () { + commonDialog + .confirm({ + title: 'Commit to Compliance', + content: 'Are you sure to commit ' + $scope.partner.company_name + ' to compliance?', + choises: [ + {label: 'Submit', className: 'btn-success', key: 1}, + {label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true}, + ], + }) + .then(function (choice) { + if (choice == 1) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/to_card_compliance', {}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Commit to Compliance successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }) + } + $scope.apply2makeAgreeFile = function () { + if (!$scope.partner.enable_cross_payment) { + commonDialog.alert({ + title: 'Error!', + content: '请完善商户跨境支付基本信息、签约费率、合规文件!', + type: 'error', + }) + $state.go('partners.edit', { + clientMoniker: $scope.partner.client_moniker, + commitCardPayment: false, + commitCrossBorderPayment: true, + }) + return + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/make_agree_file').then( + function () { + commonDialog.alert({ + title: 'Success!', + content: '已提交制作合同!', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.apply2makeCardAgreeFile = function () { + if (!$scope.partner.enable_card_payment) { + commonDialog.alert({ + title: 'Error!', + content: '请完善商户卡支付基本信息、签约费率、合规文件!', + type: 'error', + }) + $state.go('partners.edit', { + clientMoniker: $scope.partner.client_moniker, + commitCardPayment: true, + commitCrossBorderPayment: false, + }) + return + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/make_card_agree_file').then( + function () { + commonDialog.alert({ + title: 'Success!', + content: '已提交制作合同!', + type: 'success', + }) + $state.reload() + }, + function (resp) { + if (String(resp.data.message).match('No Rate Config')) { + commonDialog.alert({ + title: 'Error!', + content: '商户卡支付签约费率未配置,请添加商户卡支付签约费率!', + type: 'error', + }) + $state.go('partners.detail.rates', { + clientMoniker: $scope.partner.client_moniker, + }) + } else { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + } + ) + } + + $scope.commit2GreenChannel = function () { + commonDialog + .confirm({ + title: 'Audit Partner', + content: 'Are you sure to mark partner ' + $scope.partner.company_name + ' Green Channel?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/compliance/green_channel').then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Commit to Green Channel successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.markAuditEmail = function () { + commonDialog + .confirm({ + title: 'Warning', + content: 'Make sure you have send the email to client.', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/email_sending_status').then( + function () { + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.resendApproveEmail = function (type) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will reset the password of admin user. Are you sure this email is correct ? Or you may update this information first.', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/send_email?type=' + type).then( + function () { + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.editBDUser = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', + controller: 'partnerChooseBDUserDialogCtrl', + resolve: { + bdUsers: [ + '$http', + function ($http) { + return $http.get('/sys/manager_accounts/roles/bd_user') + }, + ], + partner: function () { + return $scope.partner + }, + type: function () { + return 'edit' + }, + }, + }) + .result.then(function () { + $state.reload() + }) + } + $scope.bindBDUser = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', + controller: 'partnerChooseBDUserDialogCtrl', + resolve: { + bdUsers: [ + '$http', + function ($http) { + return $http.get('/sys/manager_accounts/roles/bd_user') + }, + ], + partner: function () { + return $scope.partner + }, + type: function () { + return 'add' + }, + }, + }) + .result.then(function () { + $state.reload() + }) + } + + $scope.configMasterMerchant = function () { + commonDialog.inputText({title: 'Input Master Merchant Code'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/master_configuration', {master_merchant: text}).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Master Merchant Code:' + text, + type: 'success', + }) + }, + function (resp) { + commonDialog.alert({ + title: 'Config Master Merchant Failed', + content: resp.data.message, + type: 'error', + }) + } + ) + }) + } + $scope.getMerchantLocation = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { + $scope.merchant_location = resp.data + }) + } + $scope.getMerchantLocation() + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.clientInfo = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + $scope.changeWechatCompliance = function () { + if (!$scope.partner) { + return + } + if (!$state.is('partners.detail')) { + $scope.init.wechat_compliance = false + return + } + if (!$scope.init.wechat_compliance) { + $scope.init.wechat_compliance = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_compliance_permission', {allow: $scope.partner.wechat_compliance}).then( + function () { + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change wechat_compliance permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.changeLocalMerchant = function () { + if (!$scope.partner) { + return + } + if (!$state.is('partners.detail')) { + $scope.init.local_merchant = false + return + } + if (!$scope.init.local_merchant) { + $scope.init.local_merchant = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/local_merchant_permission', {allow: $scope.partner.local_merchant}).then( + function () { + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change local_merchant permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.removeSub = function () { + $http.delete('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { + $state.reload() + }) + } + $scope.addSub = function () { + $http.put('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { + $state.reload() + }) + } + }, + ]) + app.controller('partnerPaymentInfoCtrl', [ + '$scope', + '$http', + '$state', + 'commonDialog', + '$uibModal', + '$sce', + function ($scope, $http, $state, commonDialog, $uibModal, $sce) { + $scope.convertExtParams = [] + $scope.copyHfLink = function () { + var e = document.getElementById('cpbt') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.copyYeepayLink = function () { + var e = document.getElementById('cpyeepay') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.copyCBBankPayLink = function () { + var e = document.getElementById('cpcbbankpay') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.loadPartnerPaymentInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.extParams = {} + $scope.paymentInfo = resp.data + $scope.extParams = $scope.paymentInfo.ext_params ? JSON.parse($scope.paymentInfo.ext_params) : null + $scope.convertExtParams = $scope.extParamsEditFlags() + $scope.ctrl.editSubMerchant = false + $scope.ctrl.editAliSubMerchant = false + $scope.ctrl.editMaxOrderAmount = false + $scope.ctrl.editOrderExpiryConfig = false + $scope.ctrl.editRefundPwd = false + $scope.ctrl.editRefundCreditLine = false + }) + } + $scope.extParamsEditFlags = function () { + var paramList = [] + if ($scope.extParams != null) { + for (var key in $scope.extParams) { + var obj = {} + if (typeof $scope.extParams[key] != 'boolean') { + obj.name = key + obj.value = $scope.extParams[key] + obj.type = 'string' + obj.flag = false + } else { + obj.name = key + obj.value = $scope.extParams[key] + obj.type = 'boolean' + } + paramList.push(obj) + } + } + return paramList + } + $scope.qrConfig = {currency: 'AUD'} + $scope.reloadQRCode = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/qrcode', {params: $scope.qrConfig}).then(function (resp) { + $scope.qrcode = resp.data + }) + } + $scope.reloadQRCode() + $scope.loadPartnerPaymentInfo() + + $scope.showSubMerchantLogs = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', + controller: 'clientSubMerchantIdLogCtrl', + size: 'lg', + resolve: { + logs: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') + }, + ], + }, + }) + .result.then(function () { + $scope.loadSubClients() + }) + } + + $scope.saveMaxOrderAmount = function (limit) { + if (limit != null && isNaN(limit)) { + commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'}) + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/max_order_amount', {limit: limit}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.saveCustomerSurchargeRate = function (cofig) { + if (cofig != null && isNaN(cofig)) { + commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'}) + return + } + if (!$scope.paymentInfo.rate_value) { + commonDialog.alert({ + title: 'Error', + content: 'The merchant has not pass approval process', + type: 'error', + }) + return + } + if (cofig > 3 || cofig < parseFloat(Decimal.add($scope.paymentInfo.rate_value, 0.1).toFixed(2))) { + commonDialog.alert({title: 'Error', content: 'Not in the valid range', type: 'error'}) + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_surcharge_rate', {customer_surcharge_rate: cofig}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + $scope.ctrl.editCustomerSurchargeRate = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.saveOrderExpiryConfig = function (config) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/order_expiry_config', {order_expiry_config: config}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.resetRefundPwd = function (config) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/reset/refund_pwd', {new_refund_password: config}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.setRefundCreditLine = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_credit_line', {refund_credit_line: $scope.paymentInfo.refund_credit_line}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.updateClientQRCodePaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.qrcode_surcharge) { + $scope.init.qrcode_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/qrcode_surcharge', {qrcode_surcharge: $scope.paymentInfo.qrcode_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.updateClientCBBankPaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_surcharge', {cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge}).then( + function () { + // $scope.loadPartnerPaymentInfo(); + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Customer Pay for Surcharge for Retail', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.updateClientApiSurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.api_surcharge) { + $scope.init.api_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/api_surcharge', {api_surcharge: $scope.paymentInfo.api_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.updateClientRetailPaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.retail_surcharge) { + $scope.init.retail_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/retail_surcharge', {retail_surcharge: $scope.paymentInfo.retail_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.ctrl = {} + $scope.saveSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: $scope.paymentInfo.sub_merchant_id}).then( + function (resp) { + $scope.refreshWechatInstitutionMerchantId() + $scope.ctrl.editSubMerchant = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.refreshWechatInstitutionMerchantId = function () { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { + wechat_institution_merchant_id: $scope.paymentInfo.wechat_institution_merchant_id, + }) + .then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.saveAliSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.paymentInfo.ali_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Ali Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.submitAlipaySubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { + $scope.alipay_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipay_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( + function () { + commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'}) + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + $scope.queryAlipayGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + $scope.submitAlipayOnlineSubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { + $scope.alipayOnline_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipayOnline_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( + function () { + commonDialog.alert({ + title: 'Success', + content: '提示:AlipayOnline进件成功', + type: 'success' + }) + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + $scope.queryAlipayOnlineGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + $scope.refreshCredential = function () { + commonDialog + .confirm({ + title: 'Warning', + content: 'Refresh Credential will expire the current one, which will cause the current payment service disabled. Are you sure going on?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/credential_code').then( + function () { + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.init = { + jsapi: false, + gateway: false, + offline: false, + refund: false, + common_sub_merchant_id: false, + channel: {}, + gateway_alipay_online: false, + hf_Link: false, + enable_hf_email_notice: false, + enable_yeepay_link: false, + enable_yeepay_email_notice: false, + } + $scope.switchCommonSubMerchantId = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.common_sub_merchant_id) { + $scope.init.common_sub_merchant_id = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', {allow: $scope.paymentInfo.common_sub_merchant_id}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change common_sub_merchant_id permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchSubManage = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.sub_manage) { + $scope.init.sub_manage = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', {allow: $scope.paymentInfo.sub_manage}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + var info = [] + $scope.decideCompliance = function (name) { + var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] + for (var i = 0; i < keywords.length; i++) { + if (name.indexOf(keywords[i]) != -1) { + return true + } + } + return false + } + $scope.getComplianceInfo = function () { + if ($scope.paymentInfo.company_name != null) { + if ($scope.decideCompliance($scope.paymentInfo.company_name)) { + info.push('Company Name') + } + } + if ($scope.paymentInfo.short_name != null) { + if ($scope.decideCompliance($scope.paymentInfo.short_name)) { + info.push('Short Name') + } + } + if ($scope.paymentInfo.business_structure != null) { + if ($scope.decideCompliance($scope.paymentInfo.business_structure)) { + info.push('Business Structure') + } + } + } + $scope.switchAlipayCn = function (clientId, apsConfigId, alipayCn) { + if (!$scope.paymentInfo.enable_alipayaps) { + commonDialog.alert({ + title: 'ERROR', + content: "AlipayCN channel can be switched only after Alipay+(APS) is enabled", + type: 'error', + }) + $scope.loadPartnerPaymentInfo() + } else { + $http.put('/sys/partners/aps/' + clientId, {id: apsConfigId, alipayCnSwitch: alipayCn}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change alipayCN channel permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + } + $scope.toggleChannel = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + // if (!$scope.init.channel[channel]) { + // $scope.init.channel[channel] = true + // return + // } + if ($scope.paymentInfo.alipay_cn_switch) { + commonDialog.alert({ + title: 'ERROR', + content: "Please switch AlipayCN to Alipay channel, and then close Alipay+(APS) channel", + type: 'error', + }) + $scope.loadPartnerPaymentInfo() + return; + } + $scope.getComplianceInfo() + if ($scope.paymentInfo['enable_wechat'] && channel == 'wechat' && $scope.paymentInfo.open_status == 5 && info.length > 0) { + commonDialog + .confirm({ + title: 'Warning', + contentHtml: $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息'), + }) + .then(function () { + $scope.saveChannel(channel) + }) + } else { + $scope.saveChannel(channel) + } + info = [] + } + $scope.saveChannel = function (channel) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/channels/' + channel + '/permission', {allow: $scope.paymentInfo['enable_' + channel]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channel + ' channel permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleHfLink = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.hf_Link) { + $scope.init.hf_Link = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf', {allow: $scope.paymentInfo.enable_link}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change enable_link permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleGatewayLink = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + var channelLink = 'enable_' + channel + '_link' + if (!$scope.init[channelLink]) { + $scope.init[channelLink] = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel, {allow: $scope.paymentInfo[channelLink]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channelLink + ' permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleCBBankPayLink = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', {allow: $scope.paymentInfo.enable_cb_bankpay_link}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change cb_bankpay permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.cb_bankpay = [] + $scope.cbChannelConfig = function () { + $http.get('/sysconfig/payment/config').then(function (resp) { + resp.data.forEach(function (channel) { + if (channel.type === 1) { + $scope.cb_bankpay.push(channel) + } + }) + }) + } + $scope.cbChannelConfig() + $scope.updateCBBankPayConfig = function (key, channel) { + var content = '' + if (channel == null) { + content = '你确定要将支付通道跟随系统' + } else { + content = '你确定要将支付通道更改为:' + channel + } + commonDialog + .confirm({ + title: 'Confirm', + content: content, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay/' + key + '/channel_id', {channel_id: channel}).then( + function (resp) { + commonDialog.alert({type: 'success', title: 'Success', content: '修改成功'}) + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}) + $scope.loadPartnerPaymentInfo() + } + ) + }) + } + $scope.toggleGatewayEmailNotice = function (channel) { + if (!$scope.paymentInfo) { + return + } + var channelNotice = 'enable_' + channel + '_email_notice' + if (!$scope.init[channelNotice]) { + $scope.init[channelNotice] = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel + '/email_notice', {allow: $scope.paymentInfo[channelNotice]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channelNotice + ' permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleHfEmailNotice = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_hf_email_notice) { + $scope.init.enable_hf_email_notice = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf/email_notice', {allow: $scope.paymentInfo.enable_hf_email_notice}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change enable_hf_email_notice permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleJsApi = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.jsapi) { + $scope.init.jsapi = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/jsapi_permission', {allow: $scope.paymentInfo.enable_jsapi}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change JSApi permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGateway = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway) { + $scope.init.gateway = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_permission', {allow: $scope.paymentInfo.enable_gateway}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGatewayUpgrade = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway_upgrade) { + $scope.init.gateway_upgrade = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_upgrade', {gateway_upgrade: $scope.paymentInfo.gateway_upgrade}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway Upgrade status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGatewayAlipayOnline = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway_alipay_online) { + $scope.init.gateway_alipay_online = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_alipay_online', {gateway_alipay_online: $scope.paymentInfo.gateway_alipay_online}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway Alipay Online status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleRefund = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_refund) { + $scope.init.enable_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_permission', {allow: $scope.paymentInfo.enable_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Refund permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.togglePreRefund = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_pre_refund) { + $scope.init.enable_pre_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/pre_refund_permission', {allow: $scope.paymentInfo.enable_pre_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Refund permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleOffline = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.offline) { + $scope.init.offline = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/offline_permission', {allow: $scope.paymentInfo.enable_retail}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Offline permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchInternationalCard = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_International_card) { + $scope.init.enable_International_card = true + return + } + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { + key: 'enable_international_card', + allow: $scope.paymentInfo.enable_international_card, + }) + .then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change international card permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchThreeDS = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_threeds) { + $scope.init.enable_threeds = true + return + } + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { + allow: $scope.paymentInfo.enable_threeds, + key: 'enable_threeds', + }) + .then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change international card permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changePaymentPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_page_version', {paypad_version: $scope.paymentInfo.paypad_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Payment Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changeCBBankPaymentPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_payment_page_version', {cbbank_paypad_version: $scope.paymentInfo.cbbank_paypad_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change CBBank Payment Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + // 更改支付成功页 + $scope.changePaySuccessPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/paysuccess_version', {paysuccess_version: $scope.paymentInfo.paysuccess_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Payment Success Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleRequireCustInfo = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.require_custinfo) { + $scope.init.require_custinfo = true + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireCustinfo', {allow: $scope.paymentInfo.require_custinfo}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require customer Info permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleRequireRemark = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.require_remark) { + $scope.init.require_remark = true + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireRemark', {allow: $scope.paymentInfo.require_remark}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require remark permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changeBillCodeVersion = function () { + if (!$scope.paymentInfo) { + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/selectBillVersion', {version: $scope.paymentInfo.billcode_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require bill version permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.extChangeParam = function (name, value) { + var flag = true + $scope.convertExtParams.forEach(function (params) { + if (params.name == name && value == '' && params.type == 'string') { + flag = false + } + }) + if (flag) { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/ext_config', { + key: name, + value: value, + }) + .then(function () { + $scope.loadPartnerPaymentInfo() + }) + } + } + + $scope.queryWechatSubMerchantIdStatus = function () { + $scope.paymentInfo.sub_merchant_id + $http.get('/sys/partners/' + $scope.paymentInfo.client_moniker + '/get_merchant_ids/' + $scope.paymentInfo.sub_merchant_id + '/status').then(function (resp) { + commonDialog.alert({ + title: 'Wechat Apply Status(' + resp.data.apply_status + ')', + content: resp.data.response_str, + type: 'info', + }) + }) + } + // GatewayAlipay渠道 + $scope.setAlipayChannel = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/modifyAlipayPaymentChannels/' + $scope.partner.client_id + '/' + $scope.paymentInfo.alipay_payment_channels).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('clientSubMerchantIdLogCtrl', [ + '$scope', + '$http', + 'logs', + function ($scope, $http, logs) { + $scope.logs = logs.data + }, + ]) + app.controller('partnerSubCtrl', [ + '$scope', + '$http', + '$uibModal', + function ($scope, $http, $uibModal) { + $scope.toShow = false + $scope.init = { + child_each_refund: false, + sub_manage: false, + } + + $scope.newSubClient = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/add_sub_partner_dialog.html', + controller: 'partnerNewSubPartnerDialogCtrl', + size: 'lg', + resolve: { + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.loadSubClients(1) + }) + } + + $scope.loadSubClients = function (page) { + var params = {} + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + $scope.subPartners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } + + $scope.loadSubClients(1) + + $scope.loadPartnerPaymentInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.paymentInfo = resp.data + }) + } + $scope.loadPartnerPaymentInfo() + + $scope.switchSubManage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', {allow: $scope.partner.sub_manage}).then( + function () { + //$scope.loadPartnerPaymentInfo(); + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchChildEachRefund = function () { + if (!$scope.partner) { + return + } + if (!$scope.init.child_each_refund) { + $scope.init.child_each_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/child_each_refund', {allow: $scope.partner.child_each_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.showClient = function (sub_client) { + if ($scope.sub_client_id == sub_client.client_id) { + return + } + $scope.client_monikers = sub_client.level3Clients + $scope.sub_client_id = sub_client.client_id + } + }, + ]) + app.controller('partnerRatesCtrl', [ + '$scope', + '$rootScope', + '$http', + '$uibModal', + 'commonDialog', + '$sce', + '$state', + function ($scope, $rootScope, $http, $uibModal, commonDialog, $sce, $state) { + $scope.bankCtrl = {edit: true, rate_name: 'Wechat', modify_min_settle: false} + $scope.cardBankCtrl = {edit: true, rate_name: 'rpaypmt_card', modify_min_settle: false} + $scope.apsBankCtrl = {edit: true, rate_name: 'ApsInStore', modify_min_settle: false} + $scope.init = { + skip_clearing: false, + tax_in_surcharge: false, + customer_tax_free: false, + allow_surcharge_credit: false, + } + $scope.getBankAccount = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account').then(function (resp) { + $scope.bankaccount = resp.data + $scope.bankCtrl.edit = false + }) + } + $scope.switchSurchargeMode = function () { + if ($scope.partner.surcharge_mode === 'balance') { + commonDialog + .confirm({ + title: 'Warning', + content: '启用收支分离模式清算将使消费者支付手续费模式失效,请确认是否切换?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', {surcharge_mode: 'distributed'}).then( + function () { + commonDialog.alert({title: 'Success', content: '已切换为收支分离模式', type: 'success'}) + $scope.partner.surcharge_mode = 'distributed' + $scope.getBalance() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + commonDialog + .confirm({ + title: 'Warning', + content: '请确认是否切换成净值清算模式?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', {surcharge_mode: 'balance'}).then( + function () { + commonDialog.alert({title: 'Success', content: '已切换为净值清算模式', type: 'success'}) + $scope.partner.surcharge_mode = 'balance' + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + } + $scope.modifyMinSettle = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/min_settle', {min_settle: $scope.partner.min_settle}).then( + function () { + commonDialog.alert({title: 'Success', content: '修改起结金额成功', type: 'success'}) + $scope.bankCtrl.modify_min_settle = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.getBalance = function () { + $scope.surcharge = {} + + if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode === 'distributed') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { + $scope.surcharge = resp.data + }) + } + } + $scope.getBalance() + $scope.getBankAccount() + $scope.getRates = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/rates').then(function (resp) { + $scope.rates = resp.data + angular.forEach($scope.rates, function (rate) { + rate.active_time = new Date(rate.active_time.substr(0, 10).replace(/-/g, '/')) + rate.expiry_time = new Date(rate.expiry_time.substr(0, 10).replace(/-/g, '/')) + }) + }) + } + $scope.skipClearing = function (skipClearing) { + if (!$scope.init.skip_clearing) { + $scope.init.skip_clearing = true + return + } + if (skipClearing) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + }) + .then(function () { + commonDialog.inputText({title: '请输入跳过清算的原因'}).then(function (text) { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { + skip_clearing: skipClearing, + remark: text, + }) + .then(function (resp) { + $scope.getBankAccount() + }) + }) + }) + } else { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { + $scope.getBankAccount() + }) + }) + } + } + $scope.surchargeAccountDetail = function () { + $uibModal + .open({ + templateUrl: '/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html', + controller: 'surchargeAccountDetailCtrl', + size: 'lg', + resolve: { + balance: function () { + return $scope.surcharge + }, + partner: function () { + return $scope.partner + }, + transactions: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions') + }, + ], + }, + }) + .result.then( + function () { + $scope.getBalance() + }, + function () { + $scope.getBalance() + } + ) + } + $scope.allowSurchargeCredit = function (allowSurchargeCredit) { + if (!$scope.init.allow_surcharge_credit) { + $scope.init.allow_surcharge_credit = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/allow_surcharge_credit', {allow_surcharge_credit: allowSurchargeCredit}).then(function (resp) { + }) + } + $scope.taxInSurcharge = function (taxInSurcharge) { + if (!$scope.init.tax_in_surcharge) { + $scope.init.tax_in_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/tax_in_surcharge', {tax_in_surcharge: taxInSurcharge}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.switchPreSettle = function (presettle) { + if (!$scope.init.enable_presettle) { + $scope.init.enable_presettle = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/presettle', {enable_presettle: presettle}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.customerTaxFree = function (customerTaxFree) { + if (!$scope.init.customer_tax_free) { + $scope.init.customer_tax_free = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_tax_free', {customer_tax_free: customerTaxFree}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.settleHours = [{value: undefined, label: 'Default(24:00, GMT+10)'}] + for (var h = 24; h > 0; h--) { + $scope.settleHours.push({value: h, label: ('00' + h).substr(-2) + ':00, ' + $scope.partner.timezone}) + } + $scope.settleHourConfig = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/settle_hour', {hour: $scope.partner.settle_hour || null}).then( + function () { + commonDialog.alert({type: 'success', title: 'OK', content: 'Settle Hour configured'}) + }, + function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}) + } + ) + } + $scope.getBankInfo = function (bsb_no) { + if (bsb_no != null && bsb_no !== '') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account/bank_info/' + bsb_no).then(function (resp) { + $scope.bankInfo = resp.data + $scope.bankaccount.bank = $scope.bankInfo.bank + $scope.bankaccount.city = $scope.bankInfo.city + $scope.bankaccount.address = $scope.bankInfo.address + $scope.bankaccount.system = $scope.bankInfo.system + $scope.bankaccount.postcode = $scope.bankInfo.postcode + $scope.bankaccount.state = $scope.bankInfo.state + $scope.bankaccount.branch = $scope.bankInfo.branch + }) + } else { + commonDialog.alert({title: 'Error', content: '请先填写BSB No', type: 'error'}) + } + } + $scope.getRates() + $scope.saveBankAccount = function () { + if (isNaN($scope.bankaccount.account_no)) { + alert('Account No应输入数字!') + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/bank_account', $scope.bankaccount).then( + function () { + $scope.getBankAccount() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.newAlipayApsRate = function (rateName) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_alipay_aps_rate.html', + controller: 'newAlipayApsRateDialogCtrl', + resolve: { + rate: function () { + return {rate_name: rateName, clean_days: 3} + }, + sys_common_rate: function () { + return $http.get('/sys/partners/sys_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + $scope.newCardPaymentRates = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_card_payment_rate.html', + controller: 'newCardPaymentRateDialogCtrl', + resolve: { + sys_common_rate: function () { + return $http.get('/sys/partners/sys_card_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + cost_rate_channel: function () { + return $scope.cost_rate_channel + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + $scope.newRate = function () { + var name = $scope.bankCtrl.rate_name + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_rate.html', + controller: 'newRateDialogCtrl', + resolve: { + rate: function () { + return {rate_name: name, clean_days: 3} + }, + sys_common_rate: function () { + return $http.get('/sys/partners/sys_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + $scope.editRate = function (rate) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/rate_config_dialog.html', + controller: 'rateConfigDialogCtrl', + resolve: { + rate: function () { + return rate + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.bankAccount = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + // 是否为alipayplus + $scope.isAlipayCN = true + // 修改渠道 + $scope.changeAlipayPlusRateState = function (flag) { + $scope.isAlipayCN = flag + } + // 过滤渠道 + $scope.isAlipayPlus = function (item) { + if ($scope.isAlipayCN) { + return item.rate_name === 'AlipayPlus' && (item.pay_type === 'alipay_cn_retail' || item.pay_type === 'alipay_cn_online') + } else { + return item.rate_name === 'AlipayPlus' && item.pay_type === 'alipay_other' + } + } + // 新增alipay+费率 + $scope.newAlipayPlusRate = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_alipayplus_rate.html', + resolve: { + rate: function () { + return { + rate_name: 'AlipayPlus', + clean_days: '3', + } + }, + sys_common_rate: function () { + return $http.get('/sys/partners/sys_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + controller: [ + '$scope', + '$http', + 'rate', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, rate, sys_common_rate, clientMoniker) { + $scope.rate = angular.copy(rate) + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + // if ($scope.rate.clean_days) { + // switch ($scope.rate.clean_days) { + // case '1': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t1.AlipayPlus) + // break + // } + // case '2': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t2.AlipayPlus) + // break + // } + // case '3': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t3.AlipayPlus) + // break + // } + // } + // } + } + }, + ], + }) + .result.then(function () { + $scope.getRates() + }) + } + }, + ]) + app.controller('surchargeAccountDetailCtrl', [ + '$scope', + '$http', + 'balance', + 'partner', + 'transactions', + 'commonDialog', + function ($scope, $http, balance, partner, transactions, commonDialog) { + $scope.surcharge = angular.copy(balance) + $scope.surchargeDetailData = angular.copy(transactions.data) + $scope.partner = angular.copy(partner) + $scope.canAddDetail = false + $scope.params = {} + + $scope.getBalance = function () { + if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode == 'distributed') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { + $scope.surcharge = resp.data + }) + } + } + + $scope.getTransactions = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions').then(function (resp) { + $scope.surchargeDetailData = resp.data + }) + } + + $scope.addDetail = function () { + $scope.canAddDetail = true + } + + $scope.cancel = function () { + $scope.canAddDetail = false + $scope.params = {} + } + $scope.save = function () { + $http + .post('/sys/partners/' + $scope.partner.client_moniker + '/account/save', { + amount: $scope.params.amount, + remark: $scope.params.remark, + }) + .then( + function (resp) { + $scope.getTransactions() + $scope.getBalance() + $scope.canAddDetail = false + $scope.params = {} + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + app.controller('newCardPaymentRateDialogCtrl', [ + '$scope', + '$http', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, sys_common_rate, clientMoniker) { + $scope.rate = {} + $scope.card_payment_normal = true + $scope.card_payment_switch_title = 'Direct Debit' + $scope.card_payment = [ + { + type: 'rpaypmt_card', + title: 'Card Payment', + }, + { + type: 'rpaypmt_dd', + title: 'Direct Debit', + }, + ] + $scope.cardRateConfig = $scope.card_payment[0] + $scope.switchCardRateConfig = function () { + $scope.card_payment_normal = !$scope.card_payment_normal + $scope.rate = {} + if ($scope.card_payment_normal) { + $scope.cardRateConfig = $scope.card_payment[0] + $scope.card_payment_switch_title = 'Direct Debit' + } else { + $scope.cardRateConfig = $scope.card_payment[1] + $scope.card_payment_switch_title = 'Card Payment' + } + } + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $scope.rate.type = $scope.cardRateConfig.type + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + if ($scope.rate.clean_days && $scope.card_payment_normal) { + switch ($scope.rate.clean_days) { + case '1': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t1.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t1.transaction_fee) + break + } + case '2': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t2.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t2.transaction_fee) + break + } + case '3': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t3.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t3.transaction_fee) + break + } + } + } + } + }, + ]) + app.controller('newAlipayApsRateDialogCtrl', [ + '$scope', + '$http', + 'rate', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, rate, sys_common_rate, clientMoniker) { + $scope.rate = angular.copy(rate) + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + if ($scope.rate.clean_days) { + switch ($scope.rate.clean_days) { + case '1': { + $scope.rate.retail_interchange_fee_value = parseFloat($scope.sysRateConfig.t1.RetailInterchangeFee) + $scope.rate.retail_service_fee_value = parseFloat($scope.sysRateConfig.t1.RetailServiceFee) + $scope.rate.online_interchange_fee_value = parseFloat($scope.sysRateConfig.t1.OnlineInterchangeFee) + $scope.rate.online_service_fee_value = parseFloat($scope.sysRateConfig.t1.OnlineServiceFee) + break + } + case '2': { + $scope.rate.retail_interchange_fee_value = parseFloat($scope.sysRateConfig.t2.RetailInterchangeFee) + $scope.rate.retail_service_fee_value = parseFloat($scope.sysRateConfig.t2.RetailServiceFee) + $scope.rate.online_interchange_fee_value = parseFloat($scope.sysRateConfig.t2.OnlineInterchangeFee) + $scope.rate.online_service_fee_value = parseFloat($scope.sysRateConfig.t2.OnlineServiceFee) + break + } + case '3': { + $scope.rate.retail_interchange_fee_value = parseFloat($scope.sysRateConfig.t3.RetailInterchangeFee) + $scope.rate.retail_service_fee_value = parseFloat($scope.sysRateConfig.t3.RetailServiceFee) + $scope.rate.online_interchange_fee_value = parseFloat($scope.sysRateConfig.t3.OnlineInterchangeFee) + $scope.rate.online_service_fee_value = parseFloat($scope.sysRateConfig.t3.OnlineServiceFee) + break + } + } + } + } + } + ]) + app.controller('newRateDialogCtrl', [ + '$scope', + '$http', + 'rate', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, rate, sys_common_rate, clientMoniker) { + $scope.rate = angular.copy(rate) + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + if ($scope.rate.clean_days) { + switch ($scope.rate.clean_days) { + case '1': { + $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t1.Wechat) + $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t1.Alipay) + $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t1.AlipayOnline) + $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t1.Rpay) + $scope.rate.transaction_fee = 0 + break + } + case '2': { + $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t2.Wechat) + $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t2.Alipay) + $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t2.AlipayOnline) + $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t2.Rpay) + $scope.rate.transaction_fee = 0 + break + } + case '3': { + $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t3.Wechat) + $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t3.Alipay) + $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t3.AlipayOnline) + $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t3.Rpay) + $scope.rate.transaction_fee = 0 + break + } + } + } + } + }, + ]) + app.controller('partnerAccountsCtrl', [ + '$scope', + '$http', + '$uibModal', + 'commonDialog', + function ($scope, $http, $uibModal, commonDialog) { + $scope.partnerRoles = partnerRoles + $scope.loadPartnerAccounts = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/accounts').then(function (resp) { + $scope.accounts = resp.data + }) + } + $scope.loadPartnerAccounts() + $scope.addAccount = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/add_partner_account_dialog.html', + controller: 'partnerAddAccountDialogCtrl', + backdrop: false, + resolve: { + partner: function () { + return $scope.partner + }, + }, + }) + .result.then(function () { + $scope.loadPartnerAccounts() + }) + } + $scope.updateAccountRole = function (account) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id + '/role', {role: account.role}).then( + function () { + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.resetPwd = function (account) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_account_reset_pwd_dialog.html', + controller: 'partnerResetPwdDialogCtrl', + backdrop: false, + size: 'sm', + resolve: { + partner: function () { + return $scope.partner + }, + account: function () { + return account + }, + }, + }) + .result.then(function () { + commonDialog.alert({title: 'Success!', content: 'Password Changed Successfully', type: 'success'}) + }) + } + $scope.disableAccount = function (account) { + commonDialog + .confirm({ + title: 'Confirm Operation', + content: 'Are you sure to disable account ' + account.display_name + ' ?', + }) + .then(function () { + $http.delete('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id).then( + function () { + $scope.loadPartnerAccounts() + }, + function (resp) { + commonDialog.alert({title: 'Fail!', content: resp.data.message, type: 'error'}) + } + ) + }) + } + }, + ]) + app.controller('partnerAddAccountDialogCtrl', [ + '$scope', + '$http', + 'partner', + function ($scope, $http, partner) { + $scope.account = {role: 1} + $scope.partnerRoles = partnerRoles + $scope.account.nation_code = 61 + $scope.saveAccount = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + if ($scope.account.pwd && $scope.account.pwd.length < 8) { + $scope.errmsg = 'Password length must more than 8 !' + return + } + var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ + if ($scope.account.pwd && !regex.test($scope.account.pwd)) { + $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' + return + } + $scope.errmsg = null + $http.post('/sys/partners/' + partner.client_moniker + '/accounts', $scope.account).then( + function () { + $scope.$close() + }, + function (resp) { + $scope.errmsg = resp.data.message + } + ) + } + }, + ]) + app.controller('partnerResetPwdDialogCtrl', [ + '$scope', + '$http', + 'partner', + 'account', + function ($scope, $http, partner, account) { + $scope.updatePwd = function () { + $scope.errmsg = null + if ($scope.reset.pwd && $scope.reset.pwd.length < 8) { + $scope.errmsg = 'Password length must more than 8 !' + return + } + var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ + if ($scope.reset.pwd && !regex.test($scope.reset.pwd)) { + $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' + return + } + $http.put('/sys/partners/' + partner.client_moniker + '/accounts/' + account.account_id + '/pwd', {pwd: $scope.reset.pwd}).then( + function () { + $scope.$close() + }, + function (resp) { + $scope.errmsg = resp.data.message + } + ) + } + }, + ]) + app.controller('partnerNewSubPartnerDialogCtrl', [ + '$rootScope', + '$scope', + '$http', + '$state', + 'Upload', + 'commonDialog', + 'timezone', + 'clientMoniker', + 'industryMap', + 'businessStructuresMap', + 'stateMap', + 'countryMap', + 'wechatGoodMcc', + '$filter', + function ($rootScope, $scope, $http, $state, Upload, commonDialog, timezone, clientMoniker, industryMap, businessStructuresMap, stateMap, countryMap, wechatGoodMcc, $filter) { + if ($scope.partner_application) { + $scope.partner = angular.copy($scope.partner_application) + delete $rootScope.partner_application + } else { + $scope.partner = {timezone: 'Australia/Melbourne'} + } + $scope.initMerchantCode = function () { + $http.get('/sys/partners/init/merchant_code').then(function (response) { + $scope.partner.client_moniker = response.data.partner_code + $scope.merchantCodeChecked = true + $scope.merchantIsValid = true + }) + } + $scope.initMerchantCode() + $scope.partner.company_phone_c = 61 + $scope.partner.contact_phone_c = 61 + $scope.partner.client_pay_type = [] + $scope.partner.client_pay_desc = [] + $scope.merchantIsValid = false + $scope.merchantCodeChecked = false + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.checkExpriedate = function (value) { + if (value) { + $scope.partner.certificat_expire_date_premanent = false + $scope.partner.certificat_expire_date_NA = false + } + } + $scope.checkExpriedateOther = function (value) { + if (value == 'PERMANENT') { + if ($scope.partner.certificat_expire_date_premanent) { + $scope.partner.certificat_expire_date_NA = false + $scope.partner.certificat_expire_date_d = null + } + } else if (value == 'N/A') { + if ($scope.partner.certificat_expire_date_NA) { + $scope.partner.certificat_expire_date_premanent = false + $scope.partner.certificat_expire_date_d = null + } + } + } + var resetClientPayDescByTpey = function (type) { + type = parseInt(type) + if (type == 1) { + removeClientPayDesc($scope.partner.client_pay_desc, '10') + } + if (type == 2) { + removeClientPayDesc($scope.partner.client_pay_desc, '20') + } + } + + var compare = function (x, y) { + x = parseInt(x) + y = parseInt(y) + if (x < y) { + return -1 + } else if (x > y) { + return 1 + } else { + return 0 + } + } + $scope.toggleClientPayType = function (type) { + var $idx = $scope.partner.client_pay_type.indexOf(type) + if ($idx >= 0) { + $scope.partner.client_pay_type.splice($idx, 1) + resetClientPayDescByTpey(type) + } else { + $scope.partner.client_pay_type.push(type) + $scope.partner.client_pay_type.sort(compare) + } + } + $scope.toggleClientPayDesc = function (type) { + var $idx = $scope.partner.client_pay_desc.indexOf(type) + if ($idx >= 0) { + if (type == '203') { + removeClientPayDesc($scope.partner.client_pay_desc, '2030') + } + $scope.partner.client_pay_desc.splice($idx, 1) + } else { + $scope.partner.client_pay_desc.push(type) + $scope.partner.client_pay_desc.sort(compare) + } + } + $scope.business_structures = businessStructuresMap.configs() + $scope.industries = industryMap.configs() + + $scope.listReferrers = function () { + $http.get('/sys/orgs/referrer').then(function (resp) { + $scope.referrers = resp.data + }) + } + $scope.listReferrers() + + $scope.alipayMccCategory = {} + $scope.loadAlipayCategory = function () { + $http.get('/static/data/alipayMcc.json').then(function (resp) { + $scope.alipayMccCategory = resp.data + }) + } + $scope.loadAlipayCategory() + + $scope.loadJDindustry = function () { + $http.get('/static/data/jdindustry.json').then(function (resp) { + $scope.jdindustry = resp.data + }) + } + $scope.loadJDindustry() + + $scope.loadLakalaPayindustry = function () { + $http.get('/static/data/lakalapayindustry.json').then(function (resp) { + $scope.lakalapayindustry = resp.data + }) + } + $scope.loadLakalaPayindustry() + + $scope.loadLakalaPaySettle = function () { + $http.get('/static/data/lakalapaysettle.json').then(function (resp) { + $scope.lakalapaysettle = resp.data + }) + } + $scope.loadLakalaPaySettle() + + $scope.loadLakalaPayGoods = function () { + $http.get('/static/data/lakalapaygoods.json').then(function (resp) { + $scope.lakalapaygoods = resp.data + }) + } + $scope.loadLakalaPayGoods() + + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + }) + } + $scope.loadRoyalpayindustry() + + $scope.loadHfindustry = function () { + $http.get('/static/data/hfindustry.json').then(function (resp) { + $scope.hfindustry = resp.data + }) + } + $scope.loadHfindustry() + + $scope.onAlipayMccSelect = function (selectedItem) { + $scope.partner.alipay_category = selectedItem.label + $scope.partner.alipayindustry = selectedItem.mccCode + } + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.partner.royalpay_label = selectedItem.label + $scope.partner.royalpayindustry = selectedItem.mccCode + } + + $scope.onHfIndustrySelect = function (selectedItem) { + $scope.partner.hf_label = selectedItem.label + $scope.partner.hfindustry = selectedItem.mccCode + } + + // $scope.t2city_map = angular.copy(t2city_map); + + $scope.partner.sameAsContactPerson = false + $scope.checkboxOnclick = function () { + $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson + if ($scope.partner.sameAsContactPerson) { + $scope.partner.legal_representative_person = $scope.partner.contact_person + $scope.partner.legal_representative_phone_a = $scope.partner.contact_phone_a + $scope.partner.legal_representative_phone_c = $scope.partner.contact_phone_c + $scope.partner.legal_representative_phone_p = $scope.partner.contact_phone_p + $scope.partner.legal_representative_email = $scope.partner.contact_email + $scope.partner.legal_representative_job = $scope.partner.contact_job + $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.marketingSameAsContact = false + $scope.checkMarketingSameAsContact = function () { + $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact + if ($scope.partner.marketingSameAsContact) { + $scope.partner.marketing_person = $scope.partner.contact_person + $scope.partner.marketing_phone_a = $scope.partner.contact_phone_a + $scope.partner.marketing_phone_c = $scope.partner.contact_phone_c + $scope.partner.marketing_phone_p = $scope.partner.contact_phone_p + $scope.partner.marketing_email = $scope.partner.contact_email + $scope.partner.marketing_job = $scope.partner.contact_job + $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.sameAsAddress = false + $scope.sameAddress = function () { + $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress + if ($scope.partner.sameAsAddress) { + $scope.partner.registered_address = $scope.partner.address + $scope.partner.registered_suburb = $scope.partner.suburb + $scope.partner.registered_postcode = $scope.partner.postcode + $scope.partner.registered_state = $scope.partner.state + } + } + + $scope.timezones = timezone.configs() + $scope.states = stateMap.configs() + $scope.countries = countryMap.configs() + $scope.checkMerchantCodeIsValid = function (code) { + if (code.length != 4) { + $scope.merchantCodeChecked = false + $scope.merchantIsValid = false + return + } + $http.get('/sys/partners/init/check_code_isvalid', {params: {clientMoniker: code}}).then(function (response) { + $scope.merchantIsValid = response.data + $scope.merchantCodeChecked = true + }) + } + $scope.saveSubPartner = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + if (!$scope.partner.business_structure || $scope.partner.business_structure == '') { + alert('Please select the business structure') + return + } + if ($scope.partner.business_structure != 'Registered body(Sole Trader)') { + if ($scope.partner.certificat_expire_date_d) { + $scope.partner.certificat_expire_date = $filter('dateConversionStr')($scope.partner.certificat_expire_date_d) + } else if ($scope.partner.certificat_expire_date_premanent) { + $scope.partner.certificat_expire_date = 'PERMANENT' + } else if ($scope.partner.certificat_expire_date_NA) { + $scope.partner.certificat_expire_date = 'N/A' + } else { + alert('Certificate expiration time is required') + return + } + } + if ($scope.partner.company_name.indexOf('Migration') != -1) { + alert('Company Name包含敏感词汇,请检查后重新提交!') + return + } + + if ($scope.partner.company_phone_a && '' + $scope.partner.company_phone_a != '') { + if ($scope.partner.company_phone_a.indexOf('0') == 0) { + alert("Please remove the first character '0' of area code") + return + } + } + if ($scope.partner.contact_phone && '' + $scope.partner.contact_phone != '') { + if ($scope.partner.contact_phone.indexOf('0') == 0) { + alert("Please remove the first character '0' of area code") + return + } + } + $scope.partner.company_phone = '+' + $scope.partner.company_phone_c + ($scope.partner.company_phone_a || '') + $scope.partner.company_phone_p + $scope.partner.contact_phone = '+' + $scope.partner.contact_phone_c + ($scope.partner.contact_phone_a || '') + $scope.partner.contact_phone_p + $scope.partner.legal_representative_phone = + '+' + $scope.partner.legal_representative_phone_c + ($scope.partner.legal_representative_phone_a || '') + $scope.partner.legal_representative_phone_p + $scope.partner.marketing_phone = '+' + $scope.partner.marketing_phone_c + ($scope.partner.marketing_phone_a || '') + $scope.partner.marketing_phone_p + + if ($scope.partner.company_phone.indexOf(' ') != -1) { + alert('Company Phone can not contain space character') + return + } + if ($scope.partner.contact_phone.indexOf(' ') != -1) { + alert('Contact Phone can not contain space character') + return + } + if ($scope.partner.contact_email.indexOf(' ') != -1) { + alert('Contact email Phone can not contain space character') + return + } + if ($scope.partner.suburb.indexOf(' ') != -1) { + alert('suburb can not contain two and more continuous space characters') + return + } + if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { + if ($scope.partner.acn.length != 9) { + alert('Acn is not valid') + return + } + } + // if (!$scope.partner.logo_url) { + // alert("Logo is necessary!"); + // return; + // } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if (!$scope.partner.company_photo) { + alert('Shop Photo1 is necessary') + return + } + if (!$scope.partner.store_photo) { + alert('Shop Photo2 is necessary') + return + } + } + // if(!window.frames['merchant_detail'].merchant_location){ + // alert("Please Locate Merchant Location!"); + // return; + // } + if ($scope.partner.client_pay_type.length == 0) { + alert('请选择商户支付场景') + return + } + if ($scope.partner.client_pay_desc.length == 0) { + alert('请选择商户支付方式') + return + } + if ($scope.partner.client_pay_type.indexOf('1') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { + alert('请检查线上支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { + alert('请检查线下支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { + alert('请检查线下支付是否已选择收银系统类型') + return + } + } + $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') + $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') + $http.post('/sys/partners/' + clientMoniker + '/sub_clients', $scope.partner).then( + function () { + $scope.updateMerchantLocation() + $scope.$close() + }, + function (resp) { + $scope.errmsg = resp.data.message + $scope.partner.client_pay_type = $scope.partner.client_pay_type.split(',') + $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.split(',') + } + ) + } + $scope.uploadLogo = function (file) { + if (file != null) { + if (file.size > 1 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error'}) + } else { + $scope.logoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.logoProgress + $scope.partner.logo_id = resp.data.fileid + $scope.partner.logo_url = resp.data.url + }, + function (resp) { + delete $scope.logoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadShopPhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.shopPhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.shopPhotoProgress + $scope.partner.company_photo = resp.data.url + }, + function (resp) { + delete $scope.shopPhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadStorePhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.storePhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.storePhotoProgress + $scope.partner.store_photo = resp.data.url + }, + function (resp) { + delete $scope.storePhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.updateMerchantLocation = function () { + var params = window.frames['merchant_detail'].merchant_location + if (params) { + $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () { + }) + } + } + }, + ]) + app.controller('partnerPayLogCtrl', [ + '$scope', + '$http', + '$filter', + 'refunder', + 'orderService', + function ($scope, $http, $filter, refunder, orderService) { + $scope.params = {status: 'PAID', channel: 'ALL', textType: 'all', datefrom: new Date(), dateto: new Date()} + $scope.pagination = {} + $scope.isAll = true + $scope.isLevel3All = true + $scope.clients = [$scope.partner] + $scope.showLevel3Clients = false + $scope.subClientTable1 = [$scope.partner] + $scope.subClientTable2 = [] + $scope.choseSubClientNow = 'More' + $scope.more20ChoseSubClient = false + $scope.subSearchText = '' + + $scope.today = new Date() + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date() + $scope.loadTradeLogs(1) + } + $scope.chooseYesterday = function () { + var yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + $scope.params.datefrom = $scope.params.dateto = yesterday + $scope.loadTradeLogs(1) + } + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.loadTradeLogs(1) + } + $scope.thisMonth = function () { + $scope.params.dateto = new Date() + var monthBegin = new Date() + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadTradeLogs(1) + } + $scope.lastMonth = function () { + var monthFinish = new Date() + monthFinish.setDate(0) + $scope.params.dateto = monthFinish + var monthBegin = new Date() + monthBegin.setDate(0) + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadTradeLogs(1) + } + $scope.loadTradeLogs = function (page) { + var params = angular.copy($scope.params) + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') + } + params.page = page || $scope.pagination.page || 1 + if (params.gateway) { + if (params.gateway.sort().toString() != [0, 1].toString() && params.gateway.sort().toString() != [5, 6].toString()) { + delete params.gatewayChilds + delete params.gatewayChild + } + if (params.gatewayChilds) { + var exist = false + params.gatewayChilds.forEach(function (child) { + if (child == params.gatewayChild) { + exist = true + } + }) + if (!exist) { + params.gatewayChild = null + } + } else { + delete params.gatewayChild + } + } else { + delete params.gatewayChilds + delete params.gatewayChild + } + if ($scope.isAll) { + delete params.client_ids + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/trade_logs', {params: params}).then(function (resp) { + $scope.tradeLogs = resp.data.data + $scope.pagination = resp.data.pagination + $scope.analysis = resp.data.analysis + }) + } - $scope.toggleRequireCustInfo = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.require_custinfo) { - $scope.init.require_custinfo = true - return - } - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireCustinfo', { allow: $scope.paymentInfo.require_custinfo }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change require customer Info permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.initGatewayChild = function () { + $scope.params.gatewayChilds = $scope.params.gateway + $scope.params.gatewayChild = null + $scope.loadTradeLogs(1) + } + $scope.gatewaySelected = function (arr) { + return ( + $scope.params.gateway != null && + $scope.params.gateway.filter(function (gateway) { + return arr.indexOf(gateway) >= 0 + }).length > 0 + ) + } - $scope.toggleRequireRemark = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.require_remark) { - $scope.init.require_remark = true - return - } - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireRemark', { allow: $scope.paymentInfo.require_remark }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change require remark permission status', - content: resp.data.message, - type: 'error', + $scope.showRefundLog = function (orderId) { + refunder.refunded(orderId) + } + $scope.newRefund = function (orderId) { + refunder.refund(orderId).then(function () { + $scope.loadTradeLogs() + }) + } + $scope.showTradeDetail = function (order) { + orderService.managerOrderDetail(order) + } + $scope.$on('order_refunded', function () { + $scope.loadTradeLogs() }) - } - ) - } + $scope.chooseClient = function (client) { + if (client == 'all') { + $scope.choseSubClientNow = 'More' + $scope.params.client_ids = angular.copy($scope.clientIds) + $scope.isAll = true + $scope.chooseClientId = '' + $scope.showLevel3Clients = false + } else if (client.level3Clients) { + $scope.chooseClientId = client.client_id + $scope.showLevel3Clients = true + $scope.level3Clients = client.level3Clients + $scope.isAll = false + $scope.level3ClientIds = [] + $scope.level3ClientIds.push(client.client_id) + client.level3Clients.forEach(function (client) { + $scope.level3ClientIds.push(client.client_id) + }) + $scope.chooseLevel3Client('all') + return + } else { + $scope.chooseClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isAll = false + $scope.showLevel3Clients = false + } + $scope.loadTradeLogs() + } + $scope.chooseLevel3Client = function (client) { + if (client == 'all') { + $scope.params.client_ids = angular.copy($scope.level3ClientIds) + $scope.isLevel3All = true + $scope.chooseLevel3ClientId = '' + } else { + $scope.chooseLevel3ClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isLevel3All = false + } + $scope.loadTradeLogs() + } + $scope.searchSubClients = function (subSearchText, page) { + $scope.subClientTable1 = [$scope.partner] + $scope.subClientTable2 = [] + var params = {} + params.page = page || $scope.subClientPagination.page || 1 + if (subSearchText != '') { + $scope.subSearchText = subSearchText + params.searchText = subSearchText + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + var clientList = resp.data.data + $scope.subClientPagination = resp.data.pagination + clientList.forEach(function (client) { + if ($scope.subClientTable1.length < 11) { + $scope.subClientTable1.push(client) + } else { + $scope.subClientTable2.push(client) + } + $scope.clients.push(client) + }) + }) + } - $scope.changeBillCodeVersion = function () { - if (!$scope.paymentInfo) { - return - } - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/selectBillVersion', { version: $scope.paymentInfo.billcode_version }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change require bill version permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.extChangeParam = function (name, value) { - var flag = true - $scope.convertExtParams.forEach(function (params) { - if (params.name == name && value == '' && params.type == 'string') { - flag = false - } - }) - if (flag) { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/ext_config', { - key: name, - value: value, - }) - .then(function () { - $scope.loadPartnerPaymentInfo() - }) - } - } - - $scope.queryWechatSubMerchantIdStatus = function () { - $scope.paymentInfo.sub_merchant_id - $http.get('/sys/partners/' + $scope.paymentInfo.client_moniker + '/get_merchant_ids/' + $scope.paymentInfo.sub_merchant_id + '/status').then(function (resp) { - commonDialog.alert({ - title: 'Wechat Apply Status(' + resp.data.apply_status + ')', - content: resp.data.response_str, - type: 'info', - }) - }) - } - // GatewayAlipay渠道 - $scope.setAlipayChannel = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/modifyAlipayPaymentChannels/' + $scope.partner.client_id + '/' + $scope.paymentInfo.alipay_payment_channels).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('clientSubMerchantIdLogCtrl', [ - '$scope', - '$http', - 'logs', - function ($scope, $http, logs) { - $scope.logs = logs.data - }, - ]) - app.controller('partnerSubCtrl', [ - '$scope', - '$http', - '$uibModal', - function ($scope, $http, $uibModal) { - $scope.toShow = false - $scope.init = { - child_each_refund: false, - sub_manage: false, - } - - $scope.newSubClient = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_sub_partner_dialog.html', - controller: 'partnerNewSubPartnerDialogCtrl', - size: 'lg', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.loadSubClients(1) - }) - } - - $scope.loadSubClients = function (page) { - var params = {} - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', { params: params }).then(function (resp) { - $scope.subPartners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.loadSubClients(1) - - $scope.loadPartnerPaymentInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.paymentInfo = resp.data - }) - } - $scope.loadPartnerPaymentInfo() - - $scope.switchSubManage = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', { allow: $scope.partner.sub_manage }).then( - function () { - //$scope.loadPartnerPaymentInfo(); - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change Sub Partners Manage status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + if ($scope.partner.has_children && !$scope.partner.hide_sub_mch) { + $scope.searchSubClients('', 1) + $scope.loadTradeLogs(1) + } else { + $scope.loadTradeLogs(1) + } + $scope.checkSubClientChoseShow = function (client) { + $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient + if (client != '') { + $scope.choseSubClientNow = client.short_name + } + } + $scope.clickDisplayChoseDiv = function (event) { + $scope.more20ChoseSubClient = false + } + $scope.choseDivStopPropagation = function (event) { + event.stopPropagation() + } + }, + ]) + app.controller('partnerPluginsCtrl', [ + '$scope', + '$uibModal', + function ($scope, $uibModal) { + $scope.configRedpack = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/redpack_config.html', + controller: 'partnerRedpackConfigDialogCtrl', + size: 'lg', + resolve: { + partner: function () { + return $scope.partner + }, + config: [ + '$http', + function ($http) { + return $http.get('/sys/redpack/partners/' + $scope.partner.client_moniker) + }, + ], + }, + }) + } + $scope.redpackLogs = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/redpack_logs.html', + controller: 'partnerRedpackLogDialogCtrl', + size: 'lg', + resolve: { + partner: function () { + return $scope.partner + }, + }, + }) + } + }, + ]) + app.controller('partnerDeviceCtrl', [ + '$scope', + '$http', + 'orderService', + 'commonDialog', + 'refunder', + '$uibModal', + function ($scope, $http, orderService, commonDialog, refunder, $uibModal) { + $scope.pagination = {} + /** + * 查看设备 + * @param page + */ + $scope.listDevices = function (page) { + var params = angular.copy($scope.devsearch) || {} + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/devices', {params: params}).then(function (resp) { + $scope.pagination = resp.data.pagination + $scope.devices = resp.data.data + }) + } + $scope.listDevices(1) - $scope.switchChildEachRefund = function () { - if (!$scope.partner) { - return - } - if (!$scope.init.child_each_refund) { - $scope.init.child_each_refund = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/child_each_refund', { allow: $scope.partner.child_each_refund }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change Sub Partners Manage status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + /** + * 添加设备 + */ + $scope.addDevice = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/add_device.html', + controller: 'newDeviceDialogCtrl', + resolve: { + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.listDevices(1) + }) + } - $scope.showClient = function (sub_client) { - if ($scope.sub_client_id == sub_client.client_id) { - return - } - $scope.client_monikers = sub_client.level3Clients - $scope.sub_client_id = sub_client.client_id - } - }, - ]) - app.controller('partnerRatesCtrl', [ - '$scope', - '$rootScope', - '$http', - '$uibModal', - 'commonDialog', - '$sce', - '$state', - function ($scope, $rootScope, $http, $uibModal, commonDialog, $sce, $state) { - $scope.bankCtrl = { edit: true, rate_name: 'Wechat', modify_min_settle: false } - $scope.init = { - skip_clearing: false, - tax_in_surcharge: false, - customer_tax_free: false, - allow_surcharge_credit: false, - } - $scope.getBankAccount = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account').then(function (resp) { - $scope.bankaccount = resp.data - $scope.bankCtrl.edit = false - }) - } - $scope.switchSurchargeMode = function () { - if ($scope.partner.surcharge_mode === 'balance') { - commonDialog - .confirm({ - title: 'Warning', - content: '启用收支分离模式清算将使消费者支付手续费模式失效,请确认是否切换?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', { surcharge_mode: 'distributed' }).then( - function () { - commonDialog.alert({ title: 'Success', content: '已切换为收支分离模式', type: 'success' }) - $scope.partner.surcharge_mode = 'distributed' - $scope.getBalance() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + $scope.showDeviceOrders = function (dev) { + $scope.params.dev_id = dev.dev_id + $scope.listOrders(1) + } + $scope.modifyRemark = function (dev) { + commonDialog.inputText({title: 'Input New Remark of device'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id, {remark: text}).then( + function () { + $scope.listDevices() + }, + function (resp) { + commonDialog.alert({ + title: 'Update remark failed', + content: resp.data.message, + type: 'error' + }) + } + ) + }) + } + $scope.disableDevice = function (dev) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', {enable: false}).then( + function () { + $scope.listDevices() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to disable device', + content: resp.data.message, + type: 'error' + }) + } + ) + } + $scope.enableDevice = function (dev) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', {enable: true}).then( + function () { + $scope.listDevices() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to enable device', + content: resp.data.message, + type: 'error' + }) + } + ) + } + $scope.orderPagination = {} + $scope.today = new Date() + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date() + $scope.loadTradeLogs(1) + } + $scope.chooseYesterday = function () { + var yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + $scope.params.datefrom = $scope.params.dateto = yesterday + $scope.loadTradeLogs(1) + } + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.loadTradeLogs(1) + } + $scope.thisMonth = function () { + $scope.params.dateto = new Date() + var monthBegin = new Date() + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadTradeLogs(1) + } + $scope.lastMonth = function () { + var monthFinish = new Date() + monthFinish.setDate(0) + $scope.params.dateto = monthFinish + var monthBegin = new Date() + monthBegin.setDate(0) + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadTradeLogs(1) + } + $scope.listOrders = function (page) { + var params = angular.copy($scope.params) || {} + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') } - ) - }) - } else { - commonDialog - .confirm({ - title: 'Warning', - content: '请确认是否切换成净值清算模式?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', { surcharge_mode: 'balance' }).then( - function () { - commonDialog.alert({ title: 'Success', content: '已切换为净值清算模式', type: 'success' }) - $scope.partner.surcharge_mode = 'balance' - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') } - ) - }) - } - } - $scope.modifyMinSettle = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/min_settle', { min_settle: $scope.partner.min_settle }).then( - function () { - commonDialog.alert({ title: 'Success', content: '修改起结金额成功', type: 'success' }) - $scope.bankCtrl.modify_min_settle = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.getBalance = function () { - $scope.surcharge = {} - - if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode === 'distributed') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { - $scope.surcharge = resp.data - }) - } - } - $scope.getBalance() - $scope.getBankAccount() - $scope.getRates = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/rates').then(function (resp) { - $scope.rates = resp.data - angular.forEach($scope.rates, function (rate) { - rate.active_time = new Date(rate.active_time.substr(0, 10).replace(/-/g, '/')) - rate.expiry_time = new Date(rate.expiry_time.substr(0, 10).replace(/-/g, '/')) - }) - }) - } - $scope.skipClearing = function (skipClearing) { - if (!$scope.init.skip_clearing) { - $scope.init.skip_clearing = true - return - } - if (skipClearing) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?', - }) - .then(function () { - commonDialog.inputText({ title: '请输入跳过清算的原因' }).then(function (text) { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { - skip_clearing: skipClearing, - remark: text, - }) - .then(function (resp) { - $scope.getBankAccount() - }) - }) - }) - } else { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?', - // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { skip_clearing: skipClearing }).then(function (resp) { - $scope.getBankAccount() - }) - }) - } - } - $scope.surchargeAccountDetail = function () { - $uibModal - .open({ - templateUrl: '/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html', - controller: 'surchargeAccountDetailCtrl', - size: 'lg', - resolve: { - balance: function () { - return $scope.surcharge - }, - partner: function () { - return $scope.partner - }, - transactions: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions') - }, - ], - }, - }) - .result.then( - function () { - $scope.getBalance() - }, - function () { - $scope.getBalance() - } - ) - } - $scope.allowSurchargeCredit = function (allowSurchargeCredit) { - if (!$scope.init.allow_surcharge_credit) { - $scope.init.allow_surcharge_credit = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/allow_surcharge_credit', { allow_surcharge_credit: allowSurchargeCredit }).then(function (resp) {}) - } - $scope.taxInSurcharge = function (taxInSurcharge) { - if (!$scope.init.tax_in_surcharge) { - $scope.init.tax_in_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/tax_in_surcharge', { tax_in_surcharge: taxInSurcharge }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.switchPreSettle = function (presettle) { - if (!$scope.init.enable_presettle) { - $scope.init.enable_presettle = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/presettle', { enable_presettle: presettle }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.customerTaxFree = function (customerTaxFree) { - if (!$scope.init.customer_tax_free) { - $scope.init.customer_tax_free = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_tax_free', { customer_tax_free: customerTaxFree }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.settleHours = [{ value: undefined, label: 'Default(24:00, GMT+10)' }] - for (var h = 24; h > 0; h--) { - $scope.settleHours.push({ value: h, label: ('00' + h).substr(-2) + ':00, ' + $scope.partner.timezone }) - } - $scope.settleHourConfig = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/settle_hour', { hour: $scope.partner.settle_hour || null }).then( - function () { - commonDialog.alert({ type: 'success', title: 'OK', content: 'Settle Hour configured' }) - }, - function (resp) { - commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message }) - } - ) - } - $scope.getBankInfo = function (bsb_no) { - if (bsb_no != null && bsb_no !== '') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account/bank_info/' + bsb_no).then(function (resp) { - $scope.bankInfo = resp.data - $scope.bankaccount.bank = $scope.bankInfo.bank - $scope.bankaccount.city = $scope.bankInfo.city - $scope.bankaccount.address = $scope.bankInfo.address - $scope.bankaccount.system = $scope.bankInfo.system - $scope.bankaccount.postcode = $scope.bankInfo.postcode - $scope.bankaccount.state = $scope.bankInfo.state - $scope.bankaccount.branch = $scope.bankInfo.branch - }) - } else { - commonDialog.alert({ title: 'Error', content: '请先填写BSB No', type: 'error' }) - } - } - $scope.getRates() - $scope.saveBankAccount = function () { - if (isNaN($scope.bankaccount.account_no)) { - alert('Account No应输入数字!') - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/bank_account', $scope.bankaccount).then( - function () { - $scope.getBankAccount() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.newCardPaymentRates = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_card_payment_rate.html', - controller: 'newCardPaymentRateDialogCtrl', - resolve: { - sys_common_rate: function () { - return $http.get('/sys/partners/sys_card_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - cost_rate_channel: function () { - return $scope.cost_rate_channel - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } - $scope.newRate = function () { - var name = $scope.bankCtrl.rate_name - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_rate.html', - controller: 'newRateDialogCtrl', - resolve: { - rate: function () { - return { rate_name: name, clean_days: 3 } - }, - sys_common_rate: function () { - return $http.get('/sys/partners/sys_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } - $scope.editRate = function (rate) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/rate_config_dialog.html', - controller: 'rateConfigDialogCtrl', - resolve: { - rate: function () { - return rate - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } - - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.bankAccount = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - - // 是否为alipayplus - $scope.isAlipayCN = true - // 修改渠道 - $scope.changeAlipayPlusRateState = function (flag) { - $scope.isAlipayCN = flag - } - // 过滤渠道 - $scope.isAlipayPlus = function (item) { - if ($scope.isAlipayCN) { - return item.rate_name === 'AlipayPlus' && (item.pay_type === 'alipay_cn_retail' || item.pay_type === 'alipay_cn_online') - } else { - return item.rate_name === 'AlipayPlus' && item.pay_type === 'alipay_other' - } - } - // 新增alipay+费率 - $scope.newAlipayPlusRate = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_alipayplus_rate.html', - resolve: { - rate: function () { - return { - rate_name: 'AlipayPlus', - clean_days: '3', - } - }, - sys_common_rate: function () { - return $http.get('/sys/partners/sys_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - controller: [ - '$scope', - '$http', - 'rate', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, rate, sys_common_rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { + params.gateway = [0, 1] + params.page = page || $scope.orderPagination.page || 1 + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/trade_logs', {params: params}).then(function (resp) { + $scope.orders = resp.data.data + $scope.orderPagination = resp.data.pagination + $scope.analysis = resp.data.analysis + }) + } + $scope.listOrders(1) + $scope.orderDetail = function (order) { + orderService.managerOrderDetail(order) + } + $scope.refundOrder = function (order) { + refunder.refunded(order.order_id) + } + }, + ]) + app.controller('partnerRedpackConfigDialogCtrl', [ + '$scope', + '$http', + 'partner', + 'config', + function ($scope, $http, partner, config) { + $scope.config = config.data + if (!Object.keys($scope.config).length) { + $scope.config = {min_payment: 0, min_amount: 1, max_amount: 1, daily_limit: 1, enabled: false} + } + $scope.saveRedpackConfig = function (form) { + $scope.errmsg = null + if (form.$invalid) { angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + } + var config = angular.copy($scope.config) + $http.put('/sys/redpack/partners/' + partner.client_moniker, config).then( function () { - $scope.ctrl.sending = false - $scope.$close() + $scope.$close() }, function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - // if ($scope.rate.clean_days) { - // switch ($scope.rate.clean_days) { - // case '1': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t1.AlipayPlus) - // break - // } - // case '2': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t2.AlipayPlus) - // break - // } - // case '3': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t3.AlipayPlus) - // break - // } - // } - // } - } - }, - ], - }) - .result.then(function () { - $scope.getRates() - }) - } - }, - ]) - app.controller('surchargeAccountDetailCtrl', [ - '$scope', - '$http', - 'balance', - 'partner', - 'transactions', - 'commonDialog', - function ($scope, $http, balance, partner, transactions, commonDialog) { - $scope.surcharge = angular.copy(balance) - $scope.surchargeDetailData = angular.copy(transactions.data) - $scope.partner = angular.copy(partner) - $scope.canAddDetail = false - $scope.params = {} - - $scope.getBalance = function () { - if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode == 'distributed') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { - $scope.surcharge = resp.data - }) - } - } - - $scope.getTransactions = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions').then(function (resp) { - $scope.surchargeDetailData = resp.data - }) - } - - $scope.addDetail = function () { - $scope.canAddDetail = true - } - - $scope.cancel = function () { - $scope.canAddDetail = false - $scope.params = {} - } - $scope.save = function () { - $http - .post('/sys/partners/' + $scope.partner.client_moniker + '/account/save', { - amount: $scope.params.amount, - remark: $scope.params.remark, - }) - .then( - function (resp) { - $scope.getTransactions() - $scope.getBalance() - $scope.canAddDetail = false - $scope.params = {} - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('newCardPaymentRateDialogCtrl', [ - '$scope', - '$http', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, sys_common_rate, clientMoniker) { - $scope.rate = {} - $scope.card_payment_normal = true - $scope.card_payment_switch_title = 'Direct Debit' - $scope.card_payment = [ - { - type: 'rpaypmt_card', - title: 'Card Payment', + $scope.errmsg = resp.data.message + } + ) + } }, - { - type: 'rpaypmt_dd', - title: 'Direct Debit', + ]) + app.controller('rateConfigDialogCtrl', [ + '$scope', + '$http', + 'rate', + 'clientMoniker', + function ($scope, $http, rate, clientMoniker) { + $scope.rate = angular.copy(rate) + $scope.ctrl = {sending: false} + $scope.saveRate = function () { + $scope.errmsg = null + $scope.ctrl.sending = true + if ($scope.rate.client_rate_id) { + $http.put('/sys/partners/' + clientMoniker + '/rates/' + $scope.rate.client_rate_id, $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } else { + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + } }, - ] - $scope.cardRateConfig = $scope.card_payment[0] - $scope.switchCardRateConfig = function () { - $scope.card_payment_normal = !$scope.card_payment_normal - $scope.rate = {} - if ($scope.card_payment_normal) { - $scope.cardRateConfig = $scope.card_payment[0] - $scope.card_payment_switch_title = 'Direct Debit' - } else { - $scope.cardRateConfig = $scope.card_payment[1] - $scope.card_payment_switch_title = 'Card Payment' - } - } - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $scope.rate.type = $scope.cardRateConfig.type - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - if ($scope.rate.clean_days && $scope.card_payment_normal) { - switch ($scope.rate.clean_days) { - case '1': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t1.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t1.transaction_fee) - break - } - case '2': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t2.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t2.transaction_fee) - break - } - case '3': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t3.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t3.transaction_fee) - break - } - } - } - } - }, - ]) - app.controller('newRateDialogCtrl', [ - '$scope', - '$http', - 'rate', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, rate, sys_common_rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - if ($scope.rate.clean_days) { - switch ($scope.rate.clean_days) { - case '1': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t1.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t1.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t1.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t1.Rpay) - $scope.rate.transaction_fee = 0 - break - } - case '2': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t2.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t2.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t2.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t2.Rpay) - $scope.rate.transaction_fee = 0 - break - } - case '3': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t3.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t3.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t3.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t3.Rpay) - $scope.rate.transaction_fee = 0 - break - } - } - } - } - }, - ]) - app.controller('partnerAccountsCtrl', [ - '$scope', - '$http', - '$uibModal', - 'commonDialog', - function ($scope, $http, $uibModal, commonDialog) { - $scope.partnerRoles = partnerRoles - $scope.loadPartnerAccounts = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/accounts').then(function (resp) { - $scope.accounts = resp.data - }) - } - $scope.loadPartnerAccounts() - $scope.addAccount = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_partner_account_dialog.html', - controller: 'partnerAddAccountDialogCtrl', - backdrop: false, - resolve: { - partner: function () { - return $scope.partner - }, - }, - }) - .result.then(function () { - $scope.loadPartnerAccounts() - }) - } - $scope.updateAccountRole = function (account) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id + '/role', { role: account.role }).then( - function () {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.resetPwd = function (account) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_account_reset_pwd_dialog.html', - controller: 'partnerResetPwdDialogCtrl', - backdrop: false, - size: 'sm', - resolve: { - partner: function () { - return $scope.partner - }, - account: function () { - return account - }, - }, - }) - .result.then(function () { - commonDialog.alert({ title: 'Success!', content: 'Password Changed Successfully', type: 'success' }) - }) - } - $scope.disableAccount = function (account) { - commonDialog - .confirm({ - title: 'Confirm Operation', - content: 'Are you sure to disable account ' + account.display_name + ' ?', - }) - .then(function () { - $http.delete('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id).then( - function () { - $scope.loadPartnerAccounts() - }, - function (resp) { - commonDialog.alert({ title: 'Fail!', content: resp.data.message, type: 'error' }) - } - ) - }) - } - }, - ]) - app.controller('partnerAddAccountDialogCtrl', [ - '$scope', - '$http', - 'partner', - function ($scope, $http, partner) { - $scope.account = { role: 1 } - $scope.partnerRoles = partnerRoles - $scope.account.nation_code = 61 - $scope.saveAccount = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - if ($scope.account.pwd && $scope.account.pwd.length < 8) { - $scope.errmsg = 'Password length must more than 8 !' - return - } - var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ - if ($scope.account.pwd && !regex.test($scope.account.pwd)) { - $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' - return - } - $scope.errmsg = null - $http.post('/sys/partners/' + partner.client_moniker + '/accounts', $scope.account).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerResetPwdDialogCtrl', [ - '$scope', - '$http', - 'partner', - 'account', - function ($scope, $http, partner, account) { - $scope.updatePwd = function () { - $scope.errmsg = null - if ($scope.reset.pwd && $scope.reset.pwd.length < 8) { - $scope.errmsg = 'Password length must more than 8 !' - return - } - var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ - if ($scope.reset.pwd && !regex.test($scope.reset.pwd)) { - $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' - return - } - $http.put('/sys/partners/' + partner.client_moniker + '/accounts/' + account.account_id + '/pwd', { pwd: $scope.reset.pwd }).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerNewSubPartnerDialogCtrl', [ - '$rootScope', - '$scope', - '$http', - '$state', - 'Upload', - 'commonDialog', - 'timezone', - 'clientMoniker', - 'industryMap', - 'businessStructuresMap', - 'stateMap', - 'countryMap', - 'wechatGoodMcc', - '$filter', - function ($rootScope, $scope, $http, $state, Upload, commonDialog, timezone, clientMoniker, industryMap, businessStructuresMap, stateMap, countryMap, wechatGoodMcc, $filter) { - if ($scope.partner_application) { - $scope.partner = angular.copy($scope.partner_application) - delete $rootScope.partner_application - } else { - $scope.partner = { timezone: 'Australia/Melbourne' } - } - $scope.initMerchantCode = function () { - $http.get('/sys/partners/init/merchant_code').then(function (response) { - $scope.partner.client_moniker = response.data.partner_code - $scope.merchantCodeChecked = true - $scope.merchantIsValid = true - }) - } - $scope.initMerchantCode() - $scope.partner.company_phone_c = 61 - $scope.partner.contact_phone_c = 61 - $scope.partner.client_pay_type = [] - $scope.partner.client_pay_desc = [] - $scope.merchantIsValid = false - $scope.merchantCodeChecked = false - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.checkExpriedate = function (value) { - if (value) { - $scope.partner.certificat_expire_date_premanent = false - $scope.partner.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.partner.certificat_expire_date_premanent) { - $scope.partner.certificat_expire_date_NA = false - $scope.partner.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.partner.certificat_expire_date_NA) { - $scope.partner.certificat_expire_date_premanent = false - $scope.partner.certificat_expire_date_d = null - } - } - } - var resetClientPayDescByTpey = function (type) { - type = parseInt(type) - if (type == 1) { - removeClientPayDesc($scope.partner.client_pay_desc, '10') - } - if (type == 2) { - removeClientPayDesc($scope.partner.client_pay_desc, '20') - } - } - - var compare = function (x, y) { - x = parseInt(x) - y = parseInt(y) - if (x < y) { - return -1 - } else if (x > y) { - return 1 - } else { - return 0 - } - } - $scope.toggleClientPayType = function (type) { - var $idx = $scope.partner.client_pay_type.indexOf(type) - if ($idx >= 0) { - $scope.partner.client_pay_type.splice($idx, 1) - resetClientPayDescByTpey(type) - } else { - $scope.partner.client_pay_type.push(type) - $scope.partner.client_pay_type.sort(compare) - } - } - $scope.toggleClientPayDesc = function (type) { - var $idx = $scope.partner.client_pay_desc.indexOf(type) - if ($idx >= 0) { - if (type == '203') { - removeClientPayDesc($scope.partner.client_pay_desc, '2030') - } - $scope.partner.client_pay_desc.splice($idx, 1) - } else { - $scope.partner.client_pay_desc.push(type) - $scope.partner.client_pay_desc.sort(compare) - } - } - $scope.business_structures = businessStructuresMap.configs() - $scope.industries = industryMap.configs() - - $scope.listReferrers = function () { - $http.get('/sys/orgs/referrer').then(function (resp) { - $scope.referrers = resp.data - }) - } - $scope.listReferrers() - - $scope.alipayMccCategory = {} - $scope.loadAlipayCategory = function () { - $http.get('/static/data/alipayMcc.json').then(function (resp) { - $scope.alipayMccCategory = resp.data - }) - } - $scope.loadAlipayCategory() - - $scope.loadJDindustry = function () { - $http.get('/static/data/jdindustry.json').then(function (resp) { - $scope.jdindustry = resp.data - }) - } - $scope.loadJDindustry() - - $scope.loadLakalaPayindustry = function () { - $http.get('/static/data/lakalapayindustry.json').then(function (resp) { - $scope.lakalapayindustry = resp.data - }) - } - $scope.loadLakalaPayindustry() - - $scope.loadLakalaPaySettle = function () { - $http.get('/static/data/lakalapaysettle.json').then(function (resp) { - $scope.lakalapaysettle = resp.data - }) - } - $scope.loadLakalaPaySettle() - - $scope.loadLakalaPayGoods = function () { - $http.get('/static/data/lakalapaygoods.json').then(function (resp) { - $scope.lakalapaygoods = resp.data - }) - } - $scope.loadLakalaPayGoods() - - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - }) - } - $scope.loadRoyalpayindustry() - - $scope.loadHfindustry = function () { - $http.get('/static/data/hfindustry.json').then(function (resp) { - $scope.hfindustry = resp.data - }) - } - $scope.loadHfindustry() - - $scope.onAlipayMccSelect = function (selectedItem) { - $scope.partner.alipay_category = selectedItem.label - $scope.partner.alipayindustry = selectedItem.mccCode - } - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.partner.royalpay_label = selectedItem.label - $scope.partner.royalpayindustry = selectedItem.mccCode - } - - $scope.onHfIndustrySelect = function (selectedItem) { - $scope.partner.hf_label = selectedItem.label - $scope.partner.hfindustry = selectedItem.mccCode - } - - // $scope.t2city_map = angular.copy(t2city_map); - - $scope.partner.sameAsContactPerson = false - $scope.checkboxOnclick = function () { - $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson - if ($scope.partner.sameAsContactPerson) { - $scope.partner.legal_representative_person = $scope.partner.contact_person - $scope.partner.legal_representative_phone_a = $scope.partner.contact_phone_a - $scope.partner.legal_representative_phone_c = $scope.partner.contact_phone_c - $scope.partner.legal_representative_phone_p = $scope.partner.contact_phone_p - $scope.partner.legal_representative_email = $scope.partner.contact_email - $scope.partner.legal_representative_job = $scope.partner.contact_job - $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.marketingSameAsContact = false - $scope.checkMarketingSameAsContact = function () { - $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact - if ($scope.partner.marketingSameAsContact) { - $scope.partner.marketing_person = $scope.partner.contact_person - $scope.partner.marketing_phone_a = $scope.partner.contact_phone_a - $scope.partner.marketing_phone_c = $scope.partner.contact_phone_c - $scope.partner.marketing_phone_p = $scope.partner.contact_phone_p - $scope.partner.marketing_email = $scope.partner.contact_email - $scope.partner.marketing_job = $scope.partner.contact_job - $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.sameAsAddress = false - $scope.sameAddress = function () { - $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress - if ($scope.partner.sameAsAddress) { - $scope.partner.registered_address = $scope.partner.address - $scope.partner.registered_suburb = $scope.partner.suburb - $scope.partner.registered_postcode = $scope.partner.postcode - $scope.partner.registered_state = $scope.partner.state - } - } - - $scope.timezones = timezone.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.checkMerchantCodeIsValid = function (code) { - if (code.length != 4) { - $scope.merchantCodeChecked = false - $scope.merchantIsValid = false - return - } - $http.get('/sys/partners/init/check_code_isvalid', { params: { clientMoniker: code } }).then(function (response) { - $scope.merchantIsValid = response.data - $scope.merchantCodeChecked = true - }) - } - $scope.saveSubPartner = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - if (!$scope.partner.business_structure || $scope.partner.business_structure == '') { - alert('Please select the business structure') - return - } - if ($scope.partner.business_structure != 'Registered body(Sole Trader)') { - if ($scope.partner.certificat_expire_date_d) { - $scope.partner.certificat_expire_date = $filter('dateConversionStr')($scope.partner.certificat_expire_date_d) - } else if ($scope.partner.certificat_expire_date_premanent) { - $scope.partner.certificat_expire_date = 'PERMANENT' - } else if ($scope.partner.certificat_expire_date_NA) { - $scope.partner.certificat_expire_date = 'N/A' - } else { - alert('Certificate expiration time is required') - return - } - } - if ($scope.partner.company_name.indexOf('Migration') != -1) { - alert('Company Name包含敏感词汇,请检查后重新提交!') - return - } + ]) + app.controller('newDeviceDialogCtrl', [ + '$scope', + '$http', + 'clientMoniker', + function ($scope, $http, clientMoniker) { + $scope.save = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $http.post('/sys/partners/' + clientMoniker + '/add_device', $scope.device).then( + function () { + $scope.$close() + }, + function (resp) { + $scope.errmsg = resp.data.message + } + ) + } + }, + ]) + app.controller('partnerChooseBDUserDialogCtrl', [ + '$scope', + '$http', + '$filter', + 'partner', + 'bdUsers', + 'type', + function ($scope, $http, $filter, partner, bdUsers, type) { + $scope.bdUsers = bdUsers.data + $scope.data = {} + $scope.params = {} + + $scope.chooseOrg = {} + $scope.chooseOrg.org_name = null + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + /* $scope.showOrg = 'Organization';*/ + $http.get('/sys/orgs', {params: {}}).then(function (resp) { + $scope.orgs = resp.data + }) + } - if ($scope.partner.company_phone_a && '' + $scope.partner.company_phone_a != '') { - if ($scope.partner.company_phone_a.indexOf('0') == 0) { - alert("Please remove the first character '0' of area code") - return - } - } - if ($scope.partner.contact_phone && '' + $scope.partner.contact_phone != '') { - if ($scope.partner.contact_phone.indexOf('0') == 0) { - alert("Please remove the first character '0' of area code") - return - } - } - $scope.partner.company_phone = '+' + $scope.partner.company_phone_c + ($scope.partner.company_phone_a || '') + $scope.partner.company_phone_p - $scope.partner.contact_phone = '+' + $scope.partner.contact_phone_c + ($scope.partner.contact_phone_a || '') + $scope.partner.contact_phone_p - $scope.partner.legal_representative_phone = - '+' + $scope.partner.legal_representative_phone_c + ($scope.partner.legal_representative_phone_a || '') + $scope.partner.legal_representative_phone_p - $scope.partner.marketing_phone = '+' + $scope.partner.marketing_phone_c + ($scope.partner.marketing_phone_a || '') + $scope.partner.marketing_phone_p - - if ($scope.partner.company_phone.indexOf(' ') != -1) { - alert('Company Phone can not contain space character') - return - } - if ($scope.partner.contact_phone.indexOf(' ') != -1) { - alert('Contact Phone can not contain space character') - return - } - if ($scope.partner.contact_email.indexOf(' ') != -1) { - alert('Contact email Phone can not contain space character') - return - } - if ($scope.partner.suburb.indexOf(' ') != -1) { - alert('suburb can not contain two and more continuous space characters') - return - } - if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { - if ($scope.partner.acn.length != 9) { - alert('Acn is not valid') - return - } - } - // if (!$scope.partner.logo_url) { - // alert("Logo is necessary!"); - // return; - // } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if (!$scope.partner.company_photo) { - alert('Shop Photo1 is necessary') - return - } - if (!$scope.partner.store_photo) { - alert('Shop Photo2 is necessary') - return - } - } - // if(!window.frames['merchant_detail'].merchant_location){ - // alert("Please Locate Merchant Location!"); - // return; - // } - if ($scope.partner.client_pay_type.length == 0) { - alert('请选择商户支付场景') - return - } - if ($scope.partner.client_pay_desc.length == 0) { - alert('请选择商户支付方式') - return - } - if ($scope.partner.client_pay_type.indexOf('1') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { - alert('请检查线上支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { - alert('请检查线下支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { - alert('请检查线下支付是否已选择收银系统类型') - return - } - } - $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') - $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') - $http.post('/sys/partners/' + clientMoniker + '/sub_clients', $scope.partner).then( - function () { - $scope.updateMerchantLocation() - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - $scope.partner.client_pay_type = $scope.partner.client_pay_type.split(',') - $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.split(',') - } - ) - } - $scope.uploadLogo = function (file) { - if (file != null) { - if (file.size > 1 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error' }) - } else { - $scope.logoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.logoProgress - $scope.partner.logo_id = resp.data.fileid - $scope.partner.logo_url = resp.data.url - }, - function (resp) { - delete $scope.logoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadShopPhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.shopPhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.shopPhotoProgress - $scope.partner.company_photo = resp.data.url - }, - function (resp) { - delete $scope.shopPhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadStorePhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.storePhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.storePhotoProgress - $scope.partner.store_photo = resp.data.url - }, - function (resp) { - delete $scope.storePhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.updateMerchantLocation = function () { - var params = window.frames['merchant_detail'].merchant_location - if (params) { - $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () {}) - } - } - }, - ]) - app.controller('partnerPayLogCtrl', [ - '$scope', - '$http', - '$filter', - 'refunder', - 'orderService', - function ($scope, $http, $filter, refunder, orderService) { - $scope.params = { status: 'PAID', channel: 'ALL', textType: 'all', datefrom: new Date(), dateto: new Date() } - $scope.pagination = {} - $scope.isAll = true - $scope.isLevel3All = true - $scope.clients = [$scope.partner] - $scope.showLevel3Clients = false - $scope.subClientTable1 = [$scope.partner] - $scope.subClientTable2 = [] - $scope.choseSubClientNow = 'More' - $scope.more20ChoseSubClient = false - $scope.subSearchText = '' - - $scope.today = new Date() - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadTradeLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadTradeLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadTradeLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.loadTradeLogs = function (page) { - var params = angular.copy($scope.params) - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.page = page || $scope.pagination.page || 1 - if (params.gateway) { - if (params.gateway.sort().toString() != [0, 1].toString() && params.gateway.sort().toString() != [5, 6].toString()) { - delete params.gatewayChilds - delete params.gatewayChild - } - if (params.gatewayChilds) { - var exist = false - params.gatewayChilds.forEach(function (child) { - if (child == params.gatewayChild) { - exist = true - } - }) - if (!exist) { - params.gatewayChild = null - } - } else { - delete params.gatewayChild - } - } else { - delete params.gatewayChilds - delete params.gatewayChild - } - if ($scope.isAll) { - delete params.client_ids - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/trade_logs', { params: params }).then(function (resp) { - $scope.tradeLogs = resp.data.data - $scope.pagination = resp.data.pagination - $scope.analysis = resp.data.analysis - }) - } - - $scope.initGatewayChild = function () { - $scope.params.gatewayChilds = $scope.params.gateway - $scope.params.gatewayChild = null - $scope.loadTradeLogs(1) - } - $scope.gatewaySelected = function (arr) { - return ( - $scope.params.gateway != null && - $scope.params.gateway.filter(function (gateway) { - return arr.indexOf(gateway) >= 0 - }).length > 0 - ) - } - - $scope.showRefundLog = function (orderId) { - refunder.refunded(orderId) - } - $scope.newRefund = function (orderId) { - refunder.refund(orderId).then(function () { - $scope.loadTradeLogs() - }) - } - $scope.showTradeDetail = function (order) { - orderService.managerOrderDetail(order) - } - $scope.$on('order_refunded', function () { - $scope.loadTradeLogs() - }) - $scope.chooseClient = function (client) { - if (client == 'all') { - $scope.choseSubClientNow = 'More' - $scope.params.client_ids = angular.copy($scope.clientIds) - $scope.isAll = true - $scope.chooseClientId = '' - $scope.showLevel3Clients = false - } else if (client.level3Clients) { - $scope.chooseClientId = client.client_id - $scope.showLevel3Clients = true - $scope.level3Clients = client.level3Clients - $scope.isAll = false - $scope.level3ClientIds = [] - $scope.level3ClientIds.push(client.client_id) - client.level3Clients.forEach(function (client) { - $scope.level3ClientIds.push(client.client_id) - }) - $scope.chooseLevel3Client('all') - return - } else { - $scope.chooseClientId = client.client_id - $scope.params.client_ids = [client.client_id] - $scope.isAll = false - $scope.showLevel3Clients = false - } - $scope.loadTradeLogs() - } - $scope.chooseLevel3Client = function (client) { - if (client == 'all') { - $scope.params.client_ids = angular.copy($scope.level3ClientIds) - $scope.isLevel3All = true - $scope.chooseLevel3ClientId = '' - } else { - $scope.chooseLevel3ClientId = client.client_id - $scope.params.client_ids = [client.client_id] - $scope.isLevel3All = false - } - $scope.loadTradeLogs() - } - $scope.searchSubClients = function (subSearchText, page) { - $scope.subClientTable1 = [$scope.partner] - $scope.subClientTable2 = [] - var params = {} - params.page = page || $scope.subClientPagination.page || 1 - if (subSearchText != '') { - $scope.subSearchText = subSearchText - params.searchText = subSearchText - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', { params: params }).then(function (resp) { - var clientList = resp.data.data - $scope.subClientPagination = resp.data.pagination - clientList.forEach(function (client) { - if ($scope.subClientTable1.length < 11) { - $scope.subClientTable1.push(client) - } else { - $scope.subClientTable2.push(client) - } - $scope.clients.push(client) - }) - }) - } - - if ($scope.partner.has_children && !$scope.partner.hide_sub_mch) { - $scope.searchSubClients('', 1) - $scope.loadTradeLogs(1) - } else { - $scope.loadTradeLogs(1) - } - $scope.checkSubClientChoseShow = function (client) { - $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient - if (client != '') { - $scope.choseSubClientNow = client.short_name - } - } - $scope.clickDisplayChoseDiv = function (event) { - $scope.more20ChoseSubClient = false - } - $scope.choseDivStopPropagation = function (event) { - event.stopPropagation() - } - }, - ]) - app.controller('partnerPluginsCtrl', [ - '$scope', - '$uibModal', - function ($scope, $uibModal) { - $scope.configRedpack = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/redpack_config.html', - controller: 'partnerRedpackConfigDialogCtrl', - size: 'lg', - resolve: { - partner: function () { - return $scope.partner - }, - config: [ - '$http', - function ($http) { - return $http.get('/sys/redpack/partners/' + $scope.partner.client_moniker) - }, - ], - }, - }) - } - $scope.redpackLogs = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/redpack_logs.html', - controller: 'partnerRedpackLogDialogCtrl', - size: 'lg', - resolve: { - partner: function () { - return $scope.partner - }, - }, - }) - } - }, - ]) - app.controller('partnerDeviceCtrl', [ - '$scope', - '$http', - 'orderService', - 'commonDialog', - 'refunder', - '$uibModal', - function ($scope, $http, orderService, commonDialog, refunder, $uibModal) { - $scope.pagination = {} - /** - * 查看设备 - * @param page - */ - $scope.listDevices = function (page) { - var params = angular.copy($scope.devsearch) || {} - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/devices', { params: params }).then(function (resp) { - $scope.pagination = resp.data.pagination - $scope.devices = resp.data.data - }) - } - $scope.listDevices(1) - - /** - * 添加设备 - */ - $scope.addDevice = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_device.html', - controller: 'newDeviceDialogCtrl', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.listDevices(1) - }) - } - - $scope.showDeviceOrders = function (dev) { - $scope.params.dev_id = dev.dev_id - $scope.listOrders(1) - } - $scope.modifyRemark = function (dev) { - commonDialog.inputText({ title: 'Input New Remark of device' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id, { remark: text }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Update remark failed', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.disableDevice = function (dev) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', { enable: false }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Failed to disable device', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.enableDevice = function (dev) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', { enable: true }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Failed to enable device', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.orderPagination = {} - $scope.today = new Date() - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadTradeLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadTradeLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadTradeLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.listOrders = function (page) { - var params = angular.copy($scope.params) || {} - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.gateway = [0, 1] - params.page = page || $scope.orderPagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/trade_logs', { params: params }).then(function (resp) { - $scope.orders = resp.data.data - $scope.orderPagination = resp.data.pagination - $scope.analysis = resp.data.analysis - }) - } - $scope.listOrders(1) - $scope.orderDetail = function (order) { - orderService.managerOrderDetail(order) - } - $scope.refundOrder = function (order) { - refunder.refunded(order.order_id) - } - }, - ]) - app.controller('partnerRedpackConfigDialogCtrl', [ - '$scope', - '$http', - 'partner', - 'config', - function ($scope, $http, partner, config) { - $scope.config = config.data - if (!Object.keys($scope.config).length) { - $scope.config = { min_payment: 0, min_amount: 1, max_amount: 1, daily_limit: 1, enabled: false } - } - $scope.saveRedpackConfig = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - var config = angular.copy($scope.config) - $http.put('/sys/redpack/partners/' + partner.client_moniker, config).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('rateConfigDialogCtrl', [ - '$scope', - '$http', - 'rate', - 'clientMoniker', - function ($scope, $http, rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.ctrl = { sending: false } - $scope.saveRate = function () { - $scope.errmsg = null - $scope.ctrl.sending = true - if ($scope.rate.client_rate_id) { - $http.put('/sys/partners/' + clientMoniker + '/rates/' + $scope.rate.client_rate_id, $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } else { - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - } - }, - ]) - app.controller('newDeviceDialogCtrl', [ - '$scope', - '$http', - 'clientMoniker', - function ($scope, $http, clientMoniker) { - $scope.save = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $http.post('/sys/partners/' + clientMoniker + '/add_device', $scope.device).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerChooseBDUserDialogCtrl', [ - '$scope', - '$http', - '$filter', - 'partner', - 'bdUsers', - 'type', - function ($scope, $http, $filter, partner, bdUsers, type) { - $scope.bdUsers = bdUsers.data - $scope.data = {} - $scope.params = {} - - $scope.chooseOrg = {} - $scope.chooseOrg.org_name = null - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - /* $scope.showOrg = 'Organization';*/ - $http.get('/sys/orgs', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - - /* $scope.chooseOrgFun = function (org) { + $scope.loadOrgs = function () { + var params = angular.copy($scope.params) + $http.get('/sys/orgs/orgChild', {params: params}).then(function (resp) { + $scope.orgs_child = resp.data + }) + } + + /* $scope.chooseOrgFun = function (org) { if (org == 'all') { $scope.chooseOrg.org_name = null; $scope.showOrg = 'All' } else { $scope.chooseOrg.org_name = org.name; - $scope.showOrg = org.name; - $scope.params.org_id = org.org_id; - $scope.loadOrgs(); - } - };*/ - - function initBD() { - $http.get('/sys/partners/' + partner.client_moniker + '/bd_user/current').then(function (resp) { - var choooseBD = resp.data - choooseBD.forEach(function (e) { - $scope.bdUsers.forEach(function (m) { - if (m.manager_id == e.bd_id) { - m.choose = true - m.proportion = e.proportion - /* $scope.chooseOrgFun({org_id: m.org_id, name: m.org_name});*/ - if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0) { - $scope.params.org_ids = m.org_id - $scope.params.org_id = m.org_id - $scope.loadOrgs() - } else { - $scope.params.org_id = m.org_id - $scope.loadOrgs() - } - } - }) - }) - $scope.data.start_date = new Date(choooseBD[0].start_date) - }) - } - - if (type == 'edit') { - initBD() - } - - $scope.saveBD = function () { - $scope.data.users = [] - $scope.bdUsers.forEach(function (e) { - if (e.choose) { - $scope.data.users.push(e) - } - }) - - if ($scope.data.users.length == 0) { - $scope.errmsg = '请选择至少一位BD' - } else if ($scope.data.start_date == undefined) { - $scope.errmsg = '执行开始日期不能为空' - } else { - var isValid = true - var total = 0 - $scope.data.users.forEach(function (e) { - if (e.proportion == undefined) { - $scope.errmsg = '绩效比例不能为空' - isValid = false - return - } else if (e.proportion < 0.01 || e.proportion > 1) { - $scope.errmsg = '绩效比例无效' - isValid = false - return - } - total += e.proportion - if (total > 1) { - $scope.errmsg = '总比例不能超过1' - isValid = false - return - } - }) - // if (total != 1) { - // $scope.errmsg = "Total proportion must be 1"; - // isValid = false; - // return; - // } - if (isValid) { - $scope.errmsg = null - $scope.data.type = type - var chooseUsers = angular.copy($scope.data) - chooseUsers.start_date = $scope.data.start_date - if (chooseUsers.start_date) { - chooseUsers.start_date = $filter('date')(chooseUsers.start_date, 'yyyyMMdd') - } - $http.put('/sys/partners/' + partner.client_moniker + '/bd_user', $scope.data).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - } - } - }, - ]) - app.controller('partnerRedpackLogDialogCtrl', [ - '$scope', - '$http', - 'partner', - function ($scope, $http, partner) { - $scope.pagination = {} - $scope.queryParams = {} - $scope.listRedpackLogs = function (page) { - var params = angular.copy($scope.queryParams) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/redpack/partners/' + partner.client_moniker + '/logs', { params: params }).then(function (resp) { - $scope.logs = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - $scope.listRedpackLogs(1) - }, - ]) - app.controller('partnerAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - function ($scope, $http, $rootScope, commonDialog, $state) { - if ($state.params.commitType == 'card-payment') { - $state.go('partners.detail.files.MW_files') - } else { - $state.go('partners.detail.files.CP_files') - } - }, - ]) - app.controller('partnerCPAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.id_info_form = { edit: false } - $scope.file = file.data || {} - //audit files - $scope.uploadBankFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.bankFileProgress - $scope.file.file_bank_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_bank_info.endsWith('pdf')) { - $scope.bankIsImage = false - } else { - $scope.bankIsImage = true - } - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.agreeIsImage = true - if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) { - $scope.agreeIsImage = false - } - $scope.bankIsImage = true - if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) { - $scope.bankIsImage = false - } - $scope.companyIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } - $scope.applyIsImage = true - if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) { - $scope.applyIsImage = false - } - $scope.idIsImage = true - if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } - $scope.billIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.billIsImage = false - } - - //上传账单流水 - $scope.uploadBillFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.billFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.billFileProgress - $scope.file.utility_bill_info = resp.data.url - $scope.updateFile() - if ($scope.file.utility_bill_info.endsWith('pdf')) { - $scope.billIsImage = false - } else { - $scope.billIsImage = true - } - }, - function (resp) { - delete $scope.billFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadCompanyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.companyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.companyFileProgress - $scope.file.file_company_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } else { - $scope.companyIsImage = true - } - }, - function (resp) { - delete $scope.companyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.companyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - //上传ID信息 - $scope.uploadIDFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.idFileProgress - $scope.file.file_id_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } else { - $scope.idIsImage = true - } - }, - function (resp) { - delete $scope.idFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - //上传协议文件 - $scope.uploadAgreementFile = function (file) { - if (file != null) { - if (file.size > 10 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过10MB,请压缩后重试', type: 'error' }) - } else { - $scope.agreementFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.agreementFileProgress - $scope.file.file_agreement_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_agreement_info.endsWith('pdf')) { - $scope.agreeIsImage = false - } else { - $scope.agreeIsImage = true - } - }, - function (resp) { - delete $scope.agreementFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.agreementFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + $scope.showOrg = org.name; + $scope.params.org_id = org.org_id; + $scope.loadOrgs(); } - ) - } - } - } - - //上传申请表 - $scope.uploadApplyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.applyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.applyFileProgress - $scope.file.file_apply_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_apply_info.endsWith('pdf')) { - $scope.applyIsImage = false + };*/ + + function initBD() { + $http.get('/sys/partners/' + partner.client_moniker + '/bd_user/current').then(function (resp) { + var choooseBD = resp.data + choooseBD.forEach(function (e) { + $scope.bdUsers.forEach(function (m) { + if (m.manager_id == e.bd_id) { + m.choose = true + m.proportion = e.proportion + /* $scope.chooseOrgFun({org_id: m.org_id, name: m.org_name});*/ + if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0) { + $scope.params.org_ids = m.org_id + $scope.params.org_id = m.org_id + $scope.loadOrgs() + } else { + $scope.params.org_id = m.org_id + $scope.loadOrgs() + } + } + }) + }) + $scope.data.start_date = new Date(choooseBD[0].start_date) + }) + } + + if (type == 'edit') { + initBD() + } + + $scope.saveBD = function () { + $scope.data.users = [] + $scope.bdUsers.forEach(function (e) { + if (e.choose) { + $scope.data.users.push(e) + } + }) + + if ($scope.data.users.length == 0) { + $scope.errmsg = '请选择至少一位BD' + } else if ($scope.data.start_date == undefined) { + $scope.errmsg = '执行开始日期不能为空' } else { - $scope.applyIsImage = true - } - }, - function (resp) { - delete $scope.applyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.applyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.toggleIdTitle = function (beneficiary_id_title) { - $scope.file.beneficiary_id_title = beneficiary_id_title - } - $scope.saveIdInfo = function () { - if (!$scope.file.id_type) { - commonDialog.alert({ title: 'Error', content: '请选择ID Type', type: 'error' }) - return - } - if ($scope.file.beneficiary_id_title != 'Ultimate beneficiary owner') { - if (!$scope.file.other_id_title_desc) { - commonDialog.alert({ title: 'Error', content: '请简要告知为何无法提供受益股东的资料', type: 'error' }) - return - } - } - var config = {} - config.id_type = $scope.file.id_type - config.beneficiary_id_title = $scope.file.beneficiary_id_title - config.other_id_title_desc = $scope.file.other_id_title_desc - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/id_info', config).then( - function (resp) { - commonDialog.alert({ title: 'Success', content: 'Id Info Updated', type: 'success' }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $state.reload() - } - ) - } - - $scope.cancelIdInfo = function () { - $state.reload() - $scope.id_info_form.edit = false - } - - $scope.downloadAsZip = function () { - var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP' - return url - } - - $scope.deleteComplianceFiles = function (file_id) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will delete the file, Are you sure?', - }) - .then(function () { - $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Delete Successful', - type: 'success', + var isValid = true + var total = 0 + $scope.data.users.forEach(function (e) { + if (e.proportion == undefined) { + $scope.errmsg = '绩效比例不能为空' + isValid = false + return + } else if (e.proportion < 0.01 || e.proportion > 1) { + $scope.errmsg = '绩效比例无效' + isValid = false + return + } + total += e.proportion + if (total > 1) { + $scope.errmsg = '总比例不能超过1' + isValid = false + return + } + }) + // if (total != 1) { + // $scope.errmsg = "Total proportion must be 1"; + // isValid = false; + // return; + // } + if (isValid) { + $scope.errmsg = null + $scope.data.type = type + var chooseUsers = angular.copy($scope.data) + chooseUsers.start_date = $scope.data.start_date + if (chooseUsers.start_date) { + chooseUsers.start_date = $filter('date')(chooseUsers.start_date, 'yyyyMMdd') + } + $http.put('/sys/partners/' + partner.client_moniker + '/bd_user', $scope.data).then( + function () { + $scope.$close() + }, + function (resp) { + $scope.errmsg = resp.data.message + } + ) + } + } + } + }, + ]) + app.controller('partnerRedpackLogDialogCtrl', [ + '$scope', + '$http', + 'partner', + function ($scope, $http, partner) { + $scope.pagination = {} + $scope.queryParams = {} + $scope.listRedpackLogs = function (page) { + var params = angular.copy($scope.queryParams) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/redpack/partners/' + partner.client_moniker + '/logs', {params: params}).then(function (resp) { + $scope.logs = resp.data.data + $scope.pagination = resp.data.pagination }) + } + $scope.listRedpackLogs(1) + }, + ]) + app.controller('partnerAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + function ($scope, $http, $rootScope, commonDialog, $state) { + if ($state.params.commitType == 'card-payment') { + $state.go('partners.detail.files.MW_files') + } else { + $state.go('partners.detail.files.CP_files') + } + }, + ]) + app.controller('partnerCPAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.id_info_form = {edit: false} + $scope.file = file.data || {} + //audit files + $scope.uploadBankFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.bankFileProgress + $scope.file.file_bank_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_bank_info.endsWith('pdf')) { + $scope.bankIsImage = false + } else { + $scope.bankIsImage = true + } + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.agreeIsImage = true + if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) { + $scope.agreeIsImage = false + } + $scope.bankIsImage = true + if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) { + $scope.bankIsImage = false + } + $scope.companyIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } + $scope.applyIsImage = true + if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) { + $scope.applyIsImage = false + } + $scope.idIsImage = true + if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } + $scope.billIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.billIsImage = false + } + + //上传账单流水 + $scope.uploadBillFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.billFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.billFileProgress + $scope.file.utility_bill_info = resp.data.url + $scope.updateFile() + if ($scope.file.utility_bill_info.endsWith('pdf')) { + $scope.billIsImage = false + } else { + $scope.billIsImage = true + } + }, + function (resp) { + delete $scope.billFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadCompanyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.companyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.companyFileProgress + $scope.file.file_company_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } else { + $scope.companyIsImage = true + } + }, + function (resp) { + delete $scope.companyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.companyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + //上传ID信息 + $scope.uploadIDFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.idFileProgress + $scope.file.file_id_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } else { + $scope.idIsImage = true + } + }, + function (resp) { + delete $scope.idFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传协议文件 + $scope.uploadAgreementFile = function (file) { + if (file != null) { + if (file.size > 10 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过10MB,请压缩后重试', type: 'error'}) + } else { + $scope.agreementFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.agreementFileProgress + $scope.file.file_agreement_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_agreement_info.endsWith('pdf')) { + $scope.agreeIsImage = false + } else { + $scope.agreeIsImage = true + } + }, + function (resp) { + delete $scope.agreementFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.agreementFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传申请表 + $scope.uploadApplyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.applyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.applyFileProgress + $scope.file.file_apply_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_apply_info.endsWith('pdf')) { + $scope.applyIsImage = false + } else { + $scope.applyIsImage = true + } + }, + function (resp) { + delete $scope.applyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.applyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.toggleIdTitle = function (beneficiary_id_title) { + $scope.file.beneficiary_id_title = beneficiary_id_title + } + $scope.saveIdInfo = function () { + if (!$scope.file.id_type) { + commonDialog.alert({title: 'Error', content: '请选择ID Type', type: 'error'}) + return + } + if ($scope.file.beneficiary_id_title != 'Ultimate beneficiary owner') { + if (!$scope.file.other_id_title_desc) { + commonDialog.alert({title: 'Error', content: '请简要告知为何无法提供受益股东的资料', type: 'error'}) + return + } + } + var config = {} + config.id_type = $scope.file.id_type + config.beneficiary_id_title = $scope.file.beneficiary_id_title + config.other_id_title_desc = $scope.file.other_id_title_desc + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/id_info', config).then( + function (resp) { + commonDialog.alert({title: 'Success', content: 'Id Info Updated', type: 'success'}) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $state.reload() + } + ) + } + + $scope.cancelIdInfo = function () { $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.authFile = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - }, - ]) - app.controller('partnerMWAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.id_info_form = { edit: false } - $scope.file = file.data || {} - $scope.uploadFile = {} - $scope.file.upay_risk_level = $scope.partner.upay_risk_level - $scope.file.upay_risk_remark = $scope.partner.upay_risk_remark - - $scope.uploadApplicationFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.applicationFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.applicationFileProgress - $scope.uploadFile.upay_application_form = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.applicationFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.applicationFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadBankFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.bankFileProgress - $scope.uploadFile.client_bank_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadASICFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.ASICProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.ASICProgress - $scope.uploadFile.client_company_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.ASICProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.ASICProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadIdFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.idProgress - $scope.uploadFile.upay_driver_license = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.idProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadResidenceFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.residenceFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.residenceFileProgress - $scope.uploadFile.kyc_utility_bill_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.residenceFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.residenceFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadRefundPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.refundPolicyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.refundPolicyFileProgress - $scope.uploadFile.refund_exchange_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.refundPolicyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.refundPolicyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadPrivacyPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.privacyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.privacyFileProgress - $scope.uploadFile.upay_privacy_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.privacyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.privacyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadCardPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.cardFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.cardFileProgress - $scope.uploadFile.card_security_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.cardFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.cardFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadLetterOfOfferFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.letterFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.letterFileProgress - $scope.uploadFile.upay_offer_letter = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.letterFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.letterFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadPromotionalFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.promotionalFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.promotionalFileProgress - $scope.uploadFile.upay_promotional_offer = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.promotionalFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.promotionalFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - /*$scope.uploadTermsFile = function (file) { + $scope.id_info_form.edit = false + } + + $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP' + return url + } + + $scope.deleteComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.updateFile = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Upload Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + function commitError() { + commonDialog.alert({ + title: 'Error', + content: 'Missing file', + type: 'error', + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.authFile = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + }, + ]) + app.controller('partnerMWAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.id_info_form = {edit: false} + $scope.file = file.data || {} + $scope.uploadFile = {} + $scope.file.upay_risk_level = $scope.partner.upay_risk_level + $scope.file.upay_risk_remark = $scope.partner.upay_risk_remark + + $scope.uploadApplicationFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.applicationFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.applicationFileProgress + $scope.uploadFile.upay_application_form = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.applicationFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.applicationFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadBankFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.bankFileProgress + $scope.uploadFile.client_bank_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadASICFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.ASICProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.ASICProgress + $scope.uploadFile.client_company_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.ASICProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.ASICProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadIdFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.idProgress + $scope.uploadFile.upay_driver_license = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.idProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadResidenceFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.residenceFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.residenceFileProgress + $scope.uploadFile.kyc_utility_bill_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.residenceFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.residenceFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadRefundPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.refundPolicyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.refundPolicyFileProgress + $scope.uploadFile.refund_exchange_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.refundPolicyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.refundPolicyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadPrivacyPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.privacyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.privacyFileProgress + $scope.uploadFile.upay_privacy_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.privacyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.privacyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadCardPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.cardFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.cardFileProgress + $scope.uploadFile.card_security_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.cardFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.cardFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadLetterOfOfferFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.letterFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.letterFileProgress + $scope.uploadFile.upay_offer_letter = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.letterFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.letterFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadPromotionalFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.promotionalFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.promotionalFileProgress + $scope.uploadFile.upay_promotional_offer = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.promotionalFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.promotionalFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + /*$scope.uploadTermsFile = function (file) { if (file != null) { if (file.size > 3 * 1024 * 1024) { commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) @@ -5554,702 +5709,704 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) } } - };*/ - $scope.uploadDescFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.descFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.descFileProgress - $scope.uploadFile.upay_desc_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.descFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.descFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } + };*/ + $scope.uploadDescFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.descFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.descFileProgress + $scope.uploadFile.upay_desc_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.descFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.descFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.saveIdInfo = function () { + if (!$scope.file.upay_risk_level) { + commonDialog.alert({title: 'Error', content: '请选择商户风险等级', type: 'error'}) + return + } + var config = {} + config.upay_risk_level = $scope.file.upay_risk_level + config.upay_risk_remark = $scope.file.upay_risk_remark + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_risk_info', config).then( + function (resp) { + commonDialog.alert({title: 'Success', content: 'Risk Info Updated', type: 'success'}) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $state.reload() + } + ) + } + + $scope.cancelIdInfo = function () { + $state.reload() + $scope.id_info_form.edit = false + } + + $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/MWcomplianceAsZIP' + return url + } + + $scope.updateFile = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_file', $scope.uploadFile).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Upload Successful', + type: 'success', + }) + $state.go( + 'partners.detail.files', + { + clientMoniker: $scope.partner.client_moniker, + commitType: 'card-payment', + }, + {reload: true} + ) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + function commitError() { + commonDialog.alert({ + title: 'Error', + content: 'Missing file', + type: 'error', + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.authFile = true + $rootScope.complianceCheck.client_id = $scope.partner.client_id + + if ($scope.file.upay_application_form == null || $scope.file.upay_application_form == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充商户申请表合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.client_bank_file == null || $scope.file.client_bank_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补六个月银行对账单合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.client_company_file == null || $scope.file.client_company_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充当前公司信息摘录合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.upay_driver_license == null || $scope.file.upay_driver_license == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充法人身份证明合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.kyc_utility_bill_file == null || $scope.file.kyc_utility_bill_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充家庭住址证明 (一个水电煤网账单)合规文件'}) + $rootScope.complianceCheck.authFile = false + } + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + $scope.deleteMWComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/mw_delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + }, + ]) + + app.controller('partnerKycFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.file = file.data || {} + //kyc files + $scope.uploadCompanyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.bankFileProgress + $scope.file.file_company_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } else { + $scope.companyIsImage = true + } + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.companyIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } + + $scope.idIsImage = true + if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } + $scope.billIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.billIsImage = false + } + + //上传ID信息 + $scope.uploadIDFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.idFileProgress + $scope.file.file_id_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } else { + $scope.idIsImage = true + } + }, + function (resp) { + delete $scope.idFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传账单流水 + $scope.uploadBillFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.billFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.billFileProgress + $scope.file.utility_bill_info = resp.data.url + $scope.updateFile() + if ($scope.file.utility_bill_info.endsWith('pdf')) { + $scope.billIsImage = false + } else { + $scope.billIsImage = true + } + }, + function (resp) { + delete $scope.billFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + /* $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP'; + return url; + };*/ + + $scope.deleteComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.updateFile = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/kycFile', $scope.file).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Upload Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + function commitError() { + commonDialog.alert({ + title: 'Error', + content: 'Missing file', + type: 'error', + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.authFile = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + }, + ]) + + app.controller('partnerSettlementCtrl', [ + '$scope', + '$uibModal', + '$http', + 'clientMoniker', + '$filter', + function ($scope, $uibModal, $http, clientMoniker, $filter) { + $scope.params = {} + $scope.pagination = {} + $scope.clients = [] + $scope.showLevel3Clients = false + $scope.isLevel3All = true + $scope.clinet = {} + $scope.isAll = true + $scope.more20ChoseSubClient = false + $scope.choseSubClientNow = 'More' + $scope.searchSubClients = function (subSearchText, page) { + $scope.subClientTable1 = [$scope.partner] + $scope.subClientTable2 = [] + var params = {} + params.page = page || $scope.subClientPagination.page || 1 + if (subSearchText != '') { + $scope.subSearchText = subSearchText + params.searchText = subSearchText + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + var clientList = resp.data.data + $scope.subClientPagination = resp.data.pagination + clientList.forEach(function (client) { + if ($scope.subClientTable1.length < 11) { + $scope.subClientTable1.push(client) + } else { + $scope.subClientTable2.push(client) + } + $scope.clients.push(client) + }) + }) + } + $scope.initClientInfo = function () { + $http.get('/sys/partners/' + clientMoniker).then(function (resp) { + $scope.client = resp.data + $scope.clients = [$scope.client] + if ($scope.client.has_children && !$scope.client.hide_sub_mch) { + $scope.searchSubClients('', 1) + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.chooseClient('all') + } else { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.chooseClient('all') + } + }) + } + $scope.initClientInfo() + + $scope.exportSettlementLogs = function () { + var params = angular.copy($scope.params) + var url = '/sys/partners/' + clientMoniker + '/lists_settlements/excel' + var connectSymbol = '?' + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') + url += connectSymbol + 'datefrom=' + params.datefrom + connectSymbol = '&' + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') + url += connectSymbol + 'dateto=' + params.dateto + } + if (params.client_ids && !$scope.isAll) { + params.client_ids.forEach(function (i) { + url += connectSymbol + 'client_ids=' + i + connectSymbol = '&' + }) + } + return url + } + + $scope.chooseClient = function (client) { + if (client == 'all') { + $scope.choseSubClientNow = 'More' + $scope.params.client_ids = angular.copy($scope.clientIds) + $scope.isAll = true + $scope.chooseClientId = '' + $scope.showLevel3Clients = false + } else if (client.level3Clients) { + $scope.chooseClientId = client.client_id + $scope.showLevel3Clients = true + $scope.level3Clients = client.level3Clients + $scope.isAll = false + $scope.level3ClientIds = [] + $scope.level3ClientIds.push(client.client_id) + client.level3Clients.forEach(function (client) { + $scope.level3ClientIds.push(client.client_id) + }) + $scope.chooseLevel3Client('all') + return + } else { + $scope.chooseClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isAll = false + $scope.showLevel3Clients = false + } + $scope.loadSettlementLogs() + } + + $scope.today = new Date() + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date() + $scope.loadSettlementLogs(1) + } + $scope.chooseYesterday = function () { + var yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + $scope.params.datefrom = $scope.params.dateto = yesterday + $scope.loadSettlementLogs(1) + } + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.loadSettlementLogs(1) + } + $scope.thisMonth = function () { + $scope.params.dateto = new Date() + var monthBegin = new Date() + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadSettlementLogs(1) + } + $scope.lastMonth = function () { + var monthFinish = new Date() + monthFinish.setDate(0) + $scope.params.dateto = monthFinish + var monthBegin = new Date() + monthBegin.setDate(0) + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadSettlementLogs(1) + } + $scope.loadSettlementLogs = function (page) { + var params = angular.copy($scope.params) + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') + } + params.page = page || $scope.pagination.page || 1 + params.limit = 10 + if ($scope.isAll) { + delete params.client_ids + } + $http.get('/sys/partners/' + clientMoniker + '/lists_settlements', {params: params}).then(function (resp) { + $scope.settlementLogs = resp.data.data + $scope.padding = resp.data.padding + $scope.pagination = resp.data.pagination + }) + } + $scope.getClearingTransactions = function (client_id, detail_id) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/settlement_transactions.html', + controller: 'managerSettlementDetailCtrl', + resolve: { + detail: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) + }, + ], + detail_id: detail_id, + }, + size: 'lg', + }) + } - $scope.saveIdInfo = function () { - if (!$scope.file.upay_risk_level) { - commonDialog.alert({ title: 'Error', content: '请选择商户风险等级', type: 'error' }) - return - } - var config = {} - config.upay_risk_level = $scope.file.upay_risk_level - config.upay_risk_remark = $scope.file.upay_risk_remark - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_risk_info', config).then( - function (resp) { - commonDialog.alert({ title: 'Success', content: 'Risk Info Updated', type: 'success' }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $state.reload() - } - ) - } - - $scope.cancelIdInfo = function () { - $state.reload() - $scope.id_info_form.edit = false - } - - $scope.downloadAsZip = function () { - var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/MWcomplianceAsZIP' - return url - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_file', $scope.uploadFile).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', - }) - $state.go( - 'partners.detail.files', - { - clientMoniker: $scope.partner.client_moniker, - commitType: 'card-payment', - }, - { reload: true } - ) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.authFile = true - $rootScope.complianceCheck.client_id = $scope.partner.client_id - - if ($scope.file.upay_application_form == null || $scope.file.upay_application_form == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充商户申请表合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.client_bank_file == null || $scope.file.client_bank_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补六个月银行对账单合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.client_company_file == null || $scope.file.client_company_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充当前公司信息摘录合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.upay_driver_license == null || $scope.file.upay_driver_license == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充法人身份证明合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.kyc_utility_bill_file == null || $scope.file.kyc_utility_bill_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充家庭住址证明 (一个水电煤网账单)合规文件' }) - $rootScope.complianceCheck.authFile = false - } - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - - $scope.deleteMWComplianceFiles = function (file_id) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will delete the file, Are you sure?', - }) - .then(function () { - $http.put('/sys/partners/auth_file/' + file_id + '/mw_delete').then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Delete Successful', - type: 'success', + $scope.getClearingTransactionsOfMergeSettle = function (reportDate) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/settlement_transactions.html', + controller: 'managerSettlementDetailOfMergeSettleCtrl', + resolve: { + detail: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/analysis/partner_card/' + $scope.client.client_id + '/settlement_logs/report_date/' + reportDate) + }, + ], + client_id: $scope.client.client_id, + }, + size: 'lg', }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - }, - ]) - - app.controller('partnerKycFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.file = file.data || {} - //kyc files - $scope.uploadCompanyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.bankFileProgress - $scope.file.file_company_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } else { - $scope.companyIsImage = true - } - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.companyIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } - - $scope.idIsImage = true - if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } - $scope.billIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.billIsImage = false - } - - //上传ID信息 - $scope.uploadIDFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.idFileProgress - $scope.file.file_id_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } else { - $scope.idIsImage = true - } - }, - function (resp) { - delete $scope.idFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - //上传账单流水 - $scope.uploadBillFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.billFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.billFileProgress - $scope.file.utility_bill_info = resp.data.url - $scope.updateFile() - if ($scope.file.utility_bill_info.endsWith('pdf')) { - $scope.billIsImage = false - } else { - $scope.billIsImage = true - } - }, - function (resp) { - delete $scope.billFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } + } - /* $scope.downloadAsZip = function () { - var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP'; - return url; - };*/ + $scope.checkSubClientChoseShow = function (client) { + $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient + if (client != '') { + $scope.choseSubClientNow = client.short_name + } + } + $scope.clickDisplayChoseDiv = function (event) { + $scope.more20ChoseSubClient = false + } + $scope.choseDivStopPropagation = function (event) { + event.stopPropagation() + } + }, + ]) + app.controller('partnerSurchargeAccountCtrl', [ + '$scope', + '$uibModal', + '$http', + 'clientMoniker', + '$filter', + function ($scope, $uibModal, $http, clientMoniker, $filter) { + $scope.params = {} + $scope.pagination = {} + $scope.today = new Date() + + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date() + $scope.loadSettlementLogs(1) + } + $scope.chooseYesterday = function () { + var yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + $scope.params.datefrom = $scope.params.dateto = yesterday + $scope.loadSettlementLogs(1) + } + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.loadSettlementLogs(1) + } + $scope.thisMonth = function () { + $scope.params.dateto = new Date() + var monthBegin = new Date() + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadSettlementLogs(1) + } + $scope.lastMonth = function () { + var monthFinish = new Date() + monthFinish.setDate(0) + $scope.params.dateto = monthFinish + var monthBegin = new Date() + monthBegin.setDate(0) + monthBegin.setDate(1) + $scope.params.datefrom = monthBegin + $scope.loadSettlementLogs(1) + } + $scope.loadSettlementLogs = function (page) { + var params = angular.copy($scope.params) + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') + } + params.page = page || $scope.pagination.page || 1 + params.limit = 10 + $http.get('/sys/partners/' + clientMoniker + '/surcharge_account/month_detail').then(function (resp) { + $scope.details = resp.data + }) + } + $scope.getClearingTransactions = function (client_id, detail_id) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/settlement_transactions.html', + controller: 'managerSettlementDetailCtrl', + resolve: { + detail: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) + }, + ], + detail_id: detail_id, + }, + size: 'lg', + }) + } + $scope.chooseLast7Days() + }, + ]) + app.controller('managerSettlementDetailCtrl', [ + '$scope', + 'detail', + 'detail_id', + '$http', + function ($scope, detail, detail_id, $http) { + $scope.ctrl = {channel: null} + $scope.show = true + $scope.report = detail.data + $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) + angular.forEach($scope.report.channels, function (e) { + e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) + }) - $scope.deleteComplianceFiles = function (file_id) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will delete the file, Are you sure?', - }) - .then(function () { - $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Delete Successful', - type: 'success', + $scope.channelAndDayOfAnalysis = function () { + $http.get('/analysis/partner_card/settlement_logs/' + detail_id + '/analysis/' + $scope.ctrl.channel).then(function (resp) { + $scope.channelAndDayMap = resp.data + $scope.index = 0 }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/kycFile', $scope.file).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', + } + $scope.channelAndDayOfAnalysis(1) + }, + ]) + app.controller('managerSettlementDetailOfMergeSettleCtrl', [ + '$scope', + 'detail', + 'client_id', + '$http', + function ($scope, detail, client_id, $http) { + $scope.ctrl = {channel: null} + $scope.show = true + $scope.report = detail.data + $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) + angular.forEach($scope.report.channels, function (e) { + e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.authFile = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - }, - ]) - - app.controller('partnerSettlementCtrl', [ - '$scope', - '$uibModal', - '$http', - 'clientMoniker', - '$filter', - function ($scope, $uibModal, $http, clientMoniker, $filter) { - $scope.params = {} - $scope.pagination = {} - $scope.clients = [] - $scope.showLevel3Clients = false - $scope.isLevel3All = true - $scope.clinet = {} - $scope.isAll = true - $scope.more20ChoseSubClient = false - $scope.choseSubClientNow = 'More' - $scope.searchSubClients = function (subSearchText, page) { - $scope.subClientTable1 = [$scope.partner] - $scope.subClientTable2 = [] - var params = {} - params.page = page || $scope.subClientPagination.page || 1 - if (subSearchText != '') { - $scope.subSearchText = subSearchText - params.searchText = subSearchText - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', { params: params }).then(function (resp) { - var clientList = resp.data.data - $scope.subClientPagination = resp.data.pagination - clientList.forEach(function (client) { - if ($scope.subClientTable1.length < 11) { - $scope.subClientTable1.push(client) - } else { - $scope.subClientTable2.push(client) - } - $scope.clients.push(client) - }) - }) - } - $scope.initClientInfo = function () { - $http.get('/sys/partners/' + clientMoniker).then(function (resp) { - $scope.client = resp.data - $scope.clients = [$scope.client] - if ($scope.client.has_children && !$scope.client.hide_sub_mch) { - $scope.searchSubClients('', 1) - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.chooseClient('all') - } else { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.chooseClient('all') - } - }) - } - $scope.initClientInfo() - - $scope.exportSettlementLogs = function () { - var params = angular.copy($scope.params) - var url = '/sys/partners/' + clientMoniker + '/lists_settlements/excel' - var connectSymbol = '?' - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - url += connectSymbol + 'datefrom=' + params.datefrom - connectSymbol = '&' - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - url += connectSymbol + 'dateto=' + params.dateto - } - if (params.client_ids && !$scope.isAll) { - params.client_ids.forEach(function (i) { - url += connectSymbol + 'client_ids=' + i - connectSymbol = '&' - }) - } - return url - } - - $scope.chooseClient = function (client) { - if (client == 'all') { - $scope.choseSubClientNow = 'More' - $scope.params.client_ids = angular.copy($scope.clientIds) - $scope.isAll = true - $scope.chooseClientId = '' - $scope.showLevel3Clients = false - } else if (client.level3Clients) { - $scope.chooseClientId = client.client_id - $scope.showLevel3Clients = true - $scope.level3Clients = client.level3Clients - $scope.isAll = false - $scope.level3ClientIds = [] - $scope.level3ClientIds.push(client.client_id) - client.level3Clients.forEach(function (client) { - $scope.level3ClientIds.push(client.client_id) - }) - $scope.chooseLevel3Client('all') - return - } else { - $scope.chooseClientId = client.client_id - $scope.params.client_ids = [client.client_id] - $scope.isAll = false - $scope.showLevel3Clients = false - } - $scope.loadSettlementLogs() - } - - $scope.today = new Date() - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadSettlementLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadSettlementLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadSettlementLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.loadSettlementLogs = function (page) { - var params = angular.copy($scope.params) - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.page = page || $scope.pagination.page || 1 - params.limit = 10 - if ($scope.isAll) { - delete params.client_ids - } - $http.get('/sys/partners/' + clientMoniker + '/lists_settlements', { params: params }).then(function (resp) { - $scope.settlementLogs = resp.data.data - $scope.padding = resp.data.padding - $scope.pagination = resp.data.pagination - }) - } - $scope.getClearingTransactions = function (client_id, detail_id) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) - }, - ], - detail_id: detail_id, - }, - size: 'lg', - }) - } - - $scope.getClearingTransactionsOfMergeSettle = function (reportDate) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailOfMergeSettleCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + $scope.client.client_id + '/settlement_logs/report_date/' + reportDate) - }, - ], - client_id: $scope.client.client_id, - }, - size: 'lg', - }) - } - - $scope.checkSubClientChoseShow = function (client) { - $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient - if (client != '') { - $scope.choseSubClientNow = client.short_name - } - } - $scope.clickDisplayChoseDiv = function (event) { - $scope.more20ChoseSubClient = false - } - $scope.choseDivStopPropagation = function (event) { - event.stopPropagation() - } - }, - ]) - app.controller('partnerSurchargeAccountCtrl', [ - '$scope', - '$uibModal', - '$http', - 'clientMoniker', - '$filter', - function ($scope, $uibModal, $http, clientMoniker, $filter) { - $scope.params = {} - $scope.pagination = {} - $scope.today = new Date() - - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadSettlementLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadSettlementLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadSettlementLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.loadSettlementLogs = function (page) { - var params = angular.copy($scope.params) - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.page = page || $scope.pagination.page || 1 - params.limit = 10 - $http.get('/sys/partners/' + clientMoniker + '/surcharge_account/month_detail').then(function (resp) { - $scope.details = resp.data - }) - } - $scope.getClearingTransactions = function (client_id, detail_id) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) - }, - ], - detail_id: detail_id, - }, - size: 'lg', - }) - } - $scope.chooseLast7Days() - }, - ]) - app.controller('managerSettlementDetailCtrl', [ - '$scope', - 'detail', - 'detail_id', - '$http', - function ($scope, detail, detail_id, $http) { - $scope.ctrl = { channel: null } - $scope.show = true - $scope.report = detail.data - $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) - angular.forEach($scope.report.channels, function (e) { - e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) - }) - - $scope.channelAndDayOfAnalysis = function () { - $http.get('/analysis/partner_card/settlement_logs/' + detail_id + '/analysis/' + $scope.ctrl.channel).then(function (resp) { - $scope.channelAndDayMap = resp.data - $scope.index = 0 - }) - } - $scope.channelAndDayOfAnalysis(1) - }, - ]) - app.controller('managerSettlementDetailOfMergeSettleCtrl', [ - '$scope', - 'detail', - 'client_id', - '$http', - function ($scope, detail, client_id, $http) { - $scope.ctrl = { channel: null } - $scope.show = true - $scope.report = detail.data - $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) - angular.forEach($scope.report.channels, function (e) { - e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) - }) - }, - ]) - app.controller('productCtrl', [ - '$scope', - '$http', - '$uibModal', - 'commonDialog', - '$state', - 'Upload', - 'wechatGoodMcc', - function ($scope, $http, $uibModal, commonDialog, $state, Upload, wechatGoodMcc) { - $scope.importShow = 0 - $scope.pagination = {} - $scope.params = { text_type: 'all', search_text: null } - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.loadProducts = function () { - $http.get('/sys/product/' + $scope.partner.client_moniker + '/list').then(function (resp) { - $scope.mcc_goods = resp.data - }) - } - $scope.updateMccInfo = function (mccInfo) { - mccInfo.client_moniker = $scope.partner.client_moniker - $http.put('/sys/product/update', mccInfo).then(function (resp) { - $state.reload() - }) - } - $scope.loadProducts() - /*$scope.importExcel = function (file) { + }, + ]) + app.controller('productCtrl', [ + '$scope', + '$http', + '$uibModal', + 'commonDialog', + '$state', + 'Upload', + 'wechatGoodMcc', + function ($scope, $http, $uibModal, commonDialog, $state, Upload, wechatGoodMcc) { + $scope.importShow = 0 + $scope.pagination = {} + $scope.params = {text_type: 'all', search_text: null} + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.loadProducts = function () { + $http.get('/sys/product/' + $scope.partner.client_moniker + '/list').then(function (resp) { + $scope.mcc_goods = resp.data + }) + } + $scope.updateMccInfo = function (mccInfo) { + mccInfo.client_moniker = $scope.partner.client_moniker + $http.put('/sys/product/update', mccInfo).then(function (resp) { + $state.reload() + }) + } + $scope.loadProducts() + /*$scope.importExcel = function (file) { if (file != null) { Upload.upload({ url: '/attachment/files', @@ -6271,2078 +6428,2304 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) } }*/ - }, - ]) - app.controller('AddProductDialogCtrl', [ - '$scope', - '$http', - '$uibModal', - 'product', - 'partner', - '$state', - 'industryMap', - function ($scope, $http, $uibModal, product, partner, $state, industryMap) { - $scope.product = angular.copy(product) - $scope.product.partner = true - $scope.partner = angular.copy(partner) - $scope.industries = industryMap.configs() - - if ($scope.product.commodity_id) { - $scope.edit_or_add = 'Edit' - } else { - $scope.edit_or_add = 'Add' - $scope.product.industry = $scope.partner.industry - } - $scope.save = function () { - if ($scope.product.commodity_id) { - $http.put('/client/product/', $scope.product).then(function (resp) { - alert('Success') - $scope.$close() - $state.reload() - }) - } else { - $http.post('/client/product/' + $scope.partner.client_moniker, $scope.product).then(function (resp) { - alert('Success') - $scope.$close() - $state.reload() - }) - } - } - }, - ]) - // MID Management - app.controller('subMerchantIdApplicaitonsCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - '$sce', - function ($scope, $http, $uibModal, $state, commonDialog, $sce) { - // 初始化子商户 - $scope.loadSubMerchantInfos = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', { params: {} }).then(function (resp) { - $scope.subMerchantInfos = resp.data - }) - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_rpay_sub_applices', {params: {}}).then(function (resp) { - // $scope.subRpayMerchantInfos = resp.data; - // }); - // - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_yeepay_sub_applices', {params: {}}).then(function (resp) { - // $scope.subYeepayMerchantInfos = resp.data; - // }); - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { - // $scope.partner.cardInfo = resp.data; - // }); - } - $scope.loadSubMerchantInfos() - // 加载卡支付信息 - $scope.loadCardInfos = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { - $scope.cardInfo = resp.data - }) - } - $scope.loadCardInfos() - // 初始化信息 - $scope.loadPartnerInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.partnerInfo = resp.data - $scope.doSwitchCommonSubMerchantId() - }) - } - $scope.loadPartnerInfo() - // 编辑Wechat Sub Merchant Id - $scope.saveSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: $scope.partnerInfo.sub_merchant_id }).then( - function (resp) { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // Wechat-applay - $scope.applyWxSubMerchantId = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/new_apply_wx_sub_merchant_id.html', - controller: 'newApplyWxSubMerchantIdCtrl', - resolve: { - subMerchantInfo: function () { - return $scope.partner - }, - merchantIds: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') - }, - ], - }, - }) - .result.then(function () { + }, + ]) + app.controller('AddProductDialogCtrl', [ + '$scope', + '$http', + '$uibModal', + 'product', + 'partner', + '$state', + 'industryMap', + function ($scope, $http, $uibModal, product, partner, $state, industryMap) { + $scope.product = angular.copy(product) + $scope.product.partner = true + $scope.partner = angular.copy(partner) + $scope.industries = industryMap.configs() + + if ($scope.product.commodity_id) { + $scope.edit_or_add = 'Edit' + } else { + $scope.edit_or_add = 'Add' + $scope.product.industry = $scope.partner.industry + } + $scope.save = function () { + if ($scope.product.commodity_id) { + $http.put('/client/product/', $scope.product).then(function (resp) { + alert('Success') + $scope.$close() + $state.reload() + }) + } else { + $http.post('/client/product/' + $scope.partner.client_moniker, $scope.product).then(function (resp) { + alert('Success') + $scope.$close() + $state.reload() + }) + } + } + }, + ]) + // MID Management + app.controller('subMerchantIdApplicaitonsCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + '$sce', + function ($scope, $http, $uibModal, $state, commonDialog, $sce) { + // 初始化子商户 + $scope.loadSubMerchantInfos = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', {params: {}}).then(function (resp) { + $scope.subMerchantInfos = resp.data + }) + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_rpay_sub_applices', {params: {}}).then(function (resp) { + // $scope.subRpayMerchantInfos = resp.data; + // }); + // + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_yeepay_sub_applices', {params: {}}).then(function (resp) { + // $scope.subYeepayMerchantInfos = resp.data; + // }); + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { + // $scope.partner.cardInfo = resp.data; + // }); + } $scope.loadSubMerchantInfos() - }) - } - // 刷新Wechat Sub Merchant Id - $scope.queryWechatSubMerchantIdStatus = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.partnerInfo.sub_merchant_id + '/status').then( - function (resp) { - commonDialog.alert({ - title: 'Wechat Apply Status(' + resp.data.apply_status + ')', - content: resp.data.response_str, - type: 'info', - }) + // 加载卡支付信息 + $scope.loadCardInfos = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { + $scope.cardInfo = resp.data + }) + } + $scope.loadCardInfos() + // 初始化信息 + $scope.loadPartnerInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.partnerInfo = resp.data + $scope.doSwitchCommonSubMerchantId() + }) + } $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // history - $scope.showSubMerchantLogs = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', - controller: 'clientSubMerchantIdLogCtrl', - size: 'lg', - resolve: { - logs: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') - }, - ], - }, - }) - } - // 刷新Wechat Institution Merchant Id - $scope.refreshWechatInstitutionMerchantId = function () { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { - wechat_institution_merchant_id: $scope.partnerInfo.wechat_institution_merchant_id, - }) - .then( - function (resp) { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // switch开关 - $scope.doSwitchCommonSubMerchantId = function () { - $("input[name='switch']").bootstrapSwitch({ - onText: 'ON', - offText: 'OFF', - size: 'mini', - state: $scope.partnerInfo.common_sub_merchant_id, - onSwitchChange: function (event, state) { - //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里 - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', { allow: state }).then( - function () { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change common_sub_merchant_id permission status', - content: resp.data.message, - type: 'error', + // 编辑Wechat Sub Merchant Id + $scope.saveSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: $scope.partnerInfo.sub_merchant_id}).then( + function (resp) { + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + //alipayplus aps 注册 + $scope.applyAlipayPlusRetailMerchantId = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/apply_alipayplus_sub_merchant_id.html', + controller: 'applyAlipayPlusSubMerchantIdCtrl', + resolve: { + subMerchantInfo: function () { + return $scope.partner + }, + online: false, + }, + }) + .result.then(function () { + $scope.loadSubMerchantInfos() + }) + } + $scope.applyAlipayPlusOnlineMerchantId = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/apply_alipayplus_sub_merchant_id.html', + controller: 'applyAlipayPlusSubMerchantIdCtrl', + resolve: { + subMerchantInfo: function () { + return $scope.partner + }, + online: true, + }, + }) + .result.then(function () { + $scope.loadSubMerchantInfos() + }) + } + $scope.queryAlipayPlusApsOnline = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_aps_online').then( + function (resp) { + commonDialog.alert({ + title: 'AlipayPlus Online Apply Status', + content: resp.data.response_str, + type: 'info', + }) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + }; + $scope.queryAlipayPlusApsRetail = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_aps_retail').then( + function (resp) { + commonDialog.alert({ + title: 'AlipayPlus Retail Apply Status', + content: resp.data.response_str, + type: 'info', + }) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + }; + // Wechat-applay + $scope.applyWxSubMerchantId = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/new_apply_wx_sub_merchant_id.html', + controller: 'newApplyWxSubMerchantIdCtrl', + resolve: { + subMerchantInfo: function () { + return $scope.partner + }, + merchantIds: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') + }, + ], + }, + }) + .result.then(function () { + $scope.loadSubMerchantInfos() + }) + } + // 刷新Wechat Sub Merchant Id + $scope.queryWechatSubMerchantIdStatus = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.partnerInfo.sub_merchant_id + '/status').then( + function (resp) { + commonDialog.alert({ + title: 'Wechat Apply Status(' + resp.data.apply_status + ')', + content: resp.data.response_str, + type: 'info', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // history + $scope.showSubMerchantLogs = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', + controller: 'clientSubMerchantIdLogCtrl', + size: 'lg', + resolve: { + logs: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') + }, + ], + }, + }) + } + // 刷新Wechat Institution Merchant Id + $scope.refreshWechatInstitutionMerchantId = function () { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { + wechat_institution_merchant_id: $scope.partnerInfo.wechat_institution_merchant_id, + }) + .then( + function (resp) { + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // switch开关 + $scope.doSwitchCommonSubMerchantId = function () { + $("input[name='switch']").bootstrapSwitch({ + onText: 'ON', + offText: 'OFF', + size: 'mini', + state: $scope.partnerInfo.common_sub_merchant_id, + onSwitchChange: function (event, state) { + //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里 + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', {allow: state}).then( + function () { + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change common_sub_merchant_id permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + }, + }) + } + // Alipay保存名称修改 + $scope.saveAliSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.partnerInfo.ali_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Ali Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // 刷新Alipay + $scope.queryAlipayGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + // 刷新AlipayOnline + $scope.queryAlipayOnlineGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + // Alipay进件 + $scope.submitAlipaySubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { + $scope.alipay_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipay_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( + function () { + commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'}) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + // AlipayOnline进件 + $scope.submitAlipayOnlineSubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { + $scope.alipayOnline_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipayOnline_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( + function () { + commonDialog.alert({ + title: 'Success', + content: '提示:AlipayOnline进件成功', + type: 'success' + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + // use sub_merchant_id + $scope.useSubMerchantId = function (sub_merchant_id) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // 查看sub_merchant_id详情 + $scope.checkDetail = function (merchantInfo, channel) { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/sub_merchant_detail.html', + controller: 'subMerchantDetailCtrl', + resolve: { + subMerchantInfo: function () { + return merchantInfo + }, + channel: function () { + return channel + }, + }, + }) + } + // 修改sub_merchant_id + $scope.modifySubMerchantId = function (subMerchantId, channel) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/md_sub_merchant_id.html', + controller: 'ModifysubMerchantIdCtrl', + resolve: { + clientMoniker: function () { + return $scope.partner.client_moniker + }, + merchantId: function () { + return subMerchantId + }, + channel: function () { + return channel + }, + }, + }) + .result.then(function () { + commonDialog.alert({ + title: 'Success', + content: 'Modify successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }) + } + // 卡支付apply + $scope.applyMWSubMerchantId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/mw_info').then(function (resp) { + commonDialog + .confirm({ + title: 'Apply Merchant Warrior Sub Merchant Id', + contentHtml: $sce.trustAsHtml('Are you sure to apply merchant Warrior sub merchant id for [' + $scope.partner.company_name + ']?'), + json: resp.data, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/applyMWMerchantId').then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Merchant Warrior Sub Merchant ID successfully', + type: 'success', + }) + $scope.cardInfo = res.data + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + }) + } + + $scope.copyMWProfile = function () { + commonDialog.inputText({title: '请输入复制来源商户编码'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/copy_mw_config', {client_moniker: text}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + // $scope.showMoreMerchantInfo = false; + // $scope.hideMerchantInfo = function () { + // $scope.showMoreMerchantInfo = !$scope.showMoreMerchantInfo; + // }; + $scope.updateSubMerchantId = function (sub_merchant_id) { + angular.forEach($scope.subMerchantInfos, function (each) { + if (sub_merchant_id == each.sub_merchant_id) { + $scope.merchant_app_id = each.merchant_app_id + } + }) + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/update_apply_wx_sub_merchant_id.html', + controller: 'updateApplyWxSubMerchantIdCtrl', + resolve: { + merchantInfo: $scope.partner, + merchantIds: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') + }, + ], + subMerchantInfo: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.merchant_app_id) + }, + ], + }, + }) + .result.then(function () { + $scope.loadSubMerchantInfos() + }) + } + }, + ]) + app.controller('applyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.merchantIds = merchantIds.data + $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry) + $scope.saveAppliy = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/sub_apply', $scope.subMerchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.sub_merchant_id != null) { + commonDialog.confirm({title: 'Confirm', content: '已申请成功,是否确认使用'}).then(function () { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + // 展示信息 + app.controller('subMerchantDetailCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + 'subMerchantInfo', + 'channel', + function ($scope, $http, $uibModal, $state, commonDialog, subMerchantInfo, channel) { + $scope.channel = channel + $scope.subMerchantInfo = subMerchantInfo + }, + ]) + // 修改sub_merchant_id + app.controller('ModifysubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + 'clientMoniker', + 'merchantId', + 'channel', + function ($scope, $http, $uibModal, $state, commonDialog, clientMoniker, merchantId, channel) { + $scope.merchantId = merchantId + $scope.flag = false + $scope.confirm = function () { + $scope.flag = true + if (channel === 'Wechat') { + $http.put('/sys/partners/' + clientMoniker + '/payment_config', {sub_merchant_id: $scope.merchantId}).then( + function (resp) { + $scope.$close() + }, + function (resp) { + $scope.flag = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } else if (channel === 'Alipay' || channel === 'AlipayOnline') { + $http.put('/sys/partners/' + clientMoniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.merchantId}).then( + function (resp) { + $scope.$close() + }, + function (resp) { + $scope.flag = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + } + }, + ]) + app.controller('newApplyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + 'wechatGoodMcc', + 'businessTypesMap', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, businessTypesMap) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.subMerchantInfo.address = subMerchantInfo.address + "," + subMerchantInfo.suburb + + "," + subMerchantInfo.state + "," + subMerchantInfo.country; + $scope.subMerchantInfo.company_register_no = subMerchantInfo.abn ? subMerchantInfo.abn : subMerchantInfo.acn + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.merchantIds = merchantIds.data + $scope.businessTypesMap = businessTypesMap.configs() + if ($scope.subMerchantInfo.client_pay_type) { + if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'BOTH' + } else if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0) { + $scope.subMerchantInfo.business_type = 'ONLINE' + } else if ($scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'OFFLINE' + } + } else { + $scope.subMerchantInfo.business_type = 'BOTH' + } + + if ($scope.subMerchantInfo.industry) { + $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry) + } + if ($scope.subMerchantInfo.mc_code) { + $scope.subMerchantInfo.mcc_code = $scope.subMerchantInfo.mc_code + } + if (subMerchantInfo.certificat_expire_date) { + var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date = new Date(datestr) + } + if ($scope.subMerchantInfo.business_structure) { + $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' + } + if (subMerchantInfo.certificat_expire_date) { + if (subMerchantInfo.certificat_expire_date == 'PERMANENT') { + $scope.subMerchantInfo.certificat_expire_date_premanent = true + } else if (subMerchantInfo.certificat_expire_date == 'N/A') { + $scope.subMerchantInfo.certificat_expire_date_NA = true + } else { + var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) + } + } + + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false + } + } + $scope.checkExpriedateOther = function (value) { + if (value == 'PERMANENT') { + if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + $scope.subMerchantInfo.certificat_expire_date_NA = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } else if (value == 'N/A') { + if ($scope.subMerchantInfo.certificat_expire_date_NA) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } + } + $scope.saveAppliy = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // var merchant_type = $scope.subMerchantInfo.business_structure == 'Company'? 1:2; + var params = { + company_name: $scope.subMerchantInfo.company_name, + merchant_id: $scope.subMerchantInfo.merchant_id, + short_name: $scope.subMerchantInfo.short_name, + office_phone: $scope.subMerchantInfo.office_phone, + contact_person: $scope.subMerchantInfo.contact_person, + contact_phone: $scope.subMerchantInfo.contact_phone, + company_phone: $scope.subMerchantInfo.company_phone, + contact_email: $scope.subMerchantInfo.contact_email, + industry: $scope.subMerchantInfo.industry, + company_website: $scope.subMerchantInfo.company_website, + merchant_type: $scope.subMerchantInfo.merchant_type, + mcc_code: $scope.subMerchantInfo.mcc_code, + address: $scope.subMerchantInfo.address, + business_type: $scope.subMerchantInfo.business_type, + } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null + } + + if (params.merchant_type == 'ENTERPRISE') { + params.director_name = $scope.subMerchantInfo.director_name + params.director_id_number = $scope.subMerchantInfo.director_id_number + params.company_register_no = $scope.subMerchantInfo.company_register_no + params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date + + if ($scope.subMerchantInfo.certificat_expire_date_d) { + params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) + } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + params.certificat_expire_date = 'PERMANENT' + } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { + params.certificat_expire_date = 'N/A' + } else { + alert('Certificate expiration time is required') + return + } + } else { + params.principal_name = $scope.subMerchantInfo.principal_name + params.principal_id_number = $scope.subMerchantInfo.principal_id_number + } + + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/new_sub_apply', params).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.sub_merchant_id != null) { + commonDialog.confirm({title: 'Confirm', content: '已申请成功,是否确认使用'}).then(function () { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + app.controller('updateApplyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + 'wechatGoodMcc', + 'merchantInfo', + 'businessTypesMap', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, merchantInfo, businessTypesMap) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo.data) + $scope.merchantInfo = angular.copy(merchantInfo) + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.merchantIds = merchantIds.data + $scope.businessTypesMap = businessTypesMap.configs() + $scope.subMerchantInfo.short_name = $scope.merchantInfo.short_name + $scope.subMerchantInfo.industry = $scope.merchantInfo.industry + $scope.subMerchantInfo.company_website = $scope.merchantInfo.company_website + $scope.subMerchantInfo.address = $scope.merchantInfo.address + "," + $scope.merchantInfo.suburb + + "," + $scope.merchantInfo.state + "," + $scope.merchantInfo.country; + $scope.subMerchantInfo.company_phone = $scope.merchantInfo.company_phone + $scope.subMerchantInfo.contact_person = $scope.merchantInfo.contact_person + $scope.subMerchantInfo.contact_phone = $scope.merchantInfo.contact_phone + $scope.subMerchantInfo.contact_email = $scope.merchantInfo.contact_email + $scope.subMerchantInfo.company_register_no = $scope.merchantInfo.abn ? $scope.merchantInfo.abn : $scope.merchantInfo.acn + + if ($scope.merchantInfo.client_pay_type) { + if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'BOTH' + } else if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0) { + $scope.subMerchantInfo.business_type = 'ONLINE' + } else if ($scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'OFFLINE' + } + } else { + $scope.subMerchantInfo.business_type = 'BOTH' + } + + if ($scope.merchantInfo.industry) { + $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.merchantInfo.industry) + } + if ($scope.merchantInfo.mc_code) { + $scope.subMerchantInfo.mcc_code = $scope.merchantInfo.mc_code + } + + if ($scope.merchantInfo.business_structure) { + $scope.subMerchantInfo.merchant_type = $scope.merchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' + } + if ($scope.merchantInfo.certificat_expire_date) { + if ($scope.merchantInfo.certificat_expire_date == 'PERMANENT') { + $scope.subMerchantInfo.certificat_expire_date_premanent = true + } else if ($scope.merchantInfo.certificat_expire_date == 'N/A') { + $scope.subMerchantInfo.certificat_expire_date_NA = true + } else { + var datestr = $scope.merchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) + } + } + + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false + } + } + $scope.checkExpriedateOther = function (value) { + if (value == 'PERMANENT') { + if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + $scope.subMerchantInfo.certificat_expire_date_NA = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } else if (value == 'N/A') { + if ($scope.subMerchantInfo.certificat_expire_date_NA) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } + } + $scope.updateApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + var params = { + company_name: $scope.subMerchantInfo.company_name, + merchant_id: $scope.subMerchantInfo.merchant_id, + short_name: $scope.subMerchantInfo.short_name, + office_phone: $scope.subMerchantInfo.office_phone, + contact_person: $scope.subMerchantInfo.contact_person, + contact_phone: $scope.subMerchantInfo.contact_phone, + company_phone: $scope.subMerchantInfo.company_phone, + contact_email: $scope.subMerchantInfo.contact_email, + industry: $scope.subMerchantInfo.industry, + company_website: $scope.subMerchantInfo.company_website, + merchant_type: $scope.subMerchantInfo.merchant_type, + mcc_code: $scope.subMerchantInfo.mcc_code, + address: $scope.subMerchantInfo.address, + business_type: $scope.subMerchantInfo.business_type, + sub_mch_id: $scope.subMerchantInfo.sub_merchant_id, + merchant_remark: $scope.subMerchantInfo.merchant_remark, + } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null + } + // if($scope.subMerchantInfo.merchant_type == 'ENTERPRISE'){ + // params.director_name = $scope.subMerchantInfo.director_name; + // params.director_id_number = $scope.subMerchantInfo.director_id_number; + // params.company_register_no = $scope.subMerchantInfo.company_register_no; + // params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date; + // if($scope.subMerchantInfo.certificat_expire_date) { + // params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date) + // } + // }else{ + // params.principal_name = $scope.subMerchantInfo.principal_name; + // params.principal_id_number = $scope.subMerchantInfo.principal_id_number; + // } + if (params.merchant_type == 'ENTERPRISE') { + params.company_register_no = $scope.subMerchantInfo.company_register_no + params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date + if ($scope.subMerchantInfo.certificat_expire_date_d) { + params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) + } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + params.certificat_expire_date = 'PERMANENT' + } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { + params.certificat_expire_date = 'N/A' + } else { + alert('Certificate expiration time is required') + return + } + } + $http.put('/sys/partners/' + $scope.merchantInfo.client_moniker + '/get_merchant_ids/' + $scope.subMerchantInfo.merchant_app_id, params).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + commonDialog.confirm({title: 'Confirm', content: 'Successfully modified!'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + /** + * 申请alipayplus + */ + app.controller('applyAlipayPlusSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'commonDialog', + 'online', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, commonDialog, online) { + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.subMerchantInfo.online = online; + $scope.subMerchantInfo.merchantDisplayName = $scope.subMerchantInfo.short_name; + $scope.subMerchantInfo.registrationAddress = $scope.subMerchantInfo.address+","+$scope.subMerchantInfo.suburb+","+$scope.subMerchantInfo.state; + + // if ($scope.subMerchantInfo.client_pay_type) { + // if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + // $scope.subMerchantInfo.payment_type_online = true; + // $scope.subMerchantInfo.business_type_offline = true; + // } else if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0) { + // $scope.subMerchantInfo.business_type_offline = true + // } else if ($scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + // $scope.subMerchantInfo.business_type_agreement = true + // } + // } else { + // $scope.subMerchantInfo.payment_type_online = true; + // $scope.subMerchantInfo.business_type_offline = true; + // } + if ($scope.subMerchantInfo.online) { + $scope.title = "Alipay+(Online)Registration"; + } else { + $scope.title = "Alipay+(Retail)Registration"; + } + $scope.subMerchantInfo.websiteType = 'WEB'; + $scope.subMerchantInfo.website = $scope.subMerchantInfo.company_website; + $scope.subMerchantInfo.legalName = $scope.subMerchantInfo.company_name; + $scope.subMerchantInfo.registrationType = 'ENTERPRISE_REGISTRATION_NO' + if ($scope.subMerchantInfo.business_structure) { + $scope.subMerchantInfo.businessType = $scope.subMerchantInfo.business_structure == 'Company' ? 'ENTERPRISE' : 'INDIVIDUAL' + } + $scope.subMerchantInfo.shareholderName = $scope.subMerchantInfo.representativeInfo ? $scope.subMerchantInfo.representativeInfo.representative_person : ""; + $scope.subMerchantInfo.shareholderId = $scope.subMerchantInfo.representativeInfo ? $scope.subMerchantInfo.representativeInfo.legal_representative_id : ""; + $scope.subMerchantInfo.representativeName = $scope.subMerchantInfo.representativeInfo ? $scope.subMerchantInfo.representativeInfo.representative_person : ""; + $scope.subMerchantInfo.representativeId = $scope.subMerchantInfo.representativeInfo ? $scope.subMerchantInfo.representativeInfo.legal_representative_id : ""; + $scope.subMerchantInfo.storeAddress = $scope.subMerchantInfo.address+","+$scope.subMerchantInfo.suburb+","+$scope.subMerchantInfo.state; + $scope.subMerchantInfo.registrationNo = $scope.subMerchantInfo.acn ? $scope.subMerchantInfo.acn : $scope.subMerchantInfo.abn; + $scope.subMerchantInfo.storeMCC = $scope.subMerchantInfo.alipayindustry; + $scope.subMerchantInfo.storeName = $scope.subMerchantInfo.store_name; + + $scope.alipayMccCategory = {} + $scope.loadAlipayCategory = function () { + $http.get('/static/data/alipayMcc.json').then(function (resp) { + $scope.alipayMccCategory = resp.data }) - } - ) - }, - }) - } - // Alipay保存名称修改 - $scope.saveAliSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.partnerInfo.ali_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Ali Sub Merchant ID successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // 刷新Alipay - $scope.queryAlipayGms = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( - function (resp) { - commonDialog.alert({ title: 'Success', content: resp.data.result_status, type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '查询失败:' + resp.data.message, type: 'error' }) - } - ) - } - // 刷新AlipayOnline - $scope.queryAlipayOnlineGms = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( - function (resp) { - commonDialog.alert({ title: 'Success', content: resp.data.result_status, type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '查询失败:' + resp.data.message, type: 'error' }) - } - ) - } - // Alipay进件 - $scope.submitAlipaySubId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { - $scope.alipay_gms_json = resp.data - commonDialog - .confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json: $scope.alipay_gms_json, - }) - .then(function () { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( - function () { - commonDialog.alert({ title: 'Success', content: 'Alipay进件成功', type: 'success' }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '进件失败:' + resp.data.message, type: 'error' }) + } + $scope.loadAlipayCategory() + + $scope.onAlipayMccSelect = function (selectedItem) { + $scope.subMerchantInfo.alipay_category = selectedItem.label + $scope.subMerchantInfo.alipayindustry = selectedItem.mccCode + } + $scope.onAlipayStoreMccSelect = function (selectedItem) { + $scope.subMerchantInfo.storeMCC_category = selectedItem.label + $scope.subMerchantInfo.storeMCC = selectedItem.mccCode + } + $scope.saveAlipayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return; } - ) - }) - }) - } - // AlipayOnline进件 - $scope.submitAlipayOnlineSubId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { - $scope.alipayOnline_gms_json = resp.data - commonDialog - .confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json: $scope.alipayOnline_gms_json, - }) - .then(function () { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( - function () { - commonDialog.alert({ title: 'Success', content: '提示:AlipayOnline进件成功', type: 'success' }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '进件失败:' + resp.data.message, type: 'error' }) + var params = { + websiteType: $scope.subMerchantInfo.websiteType, + merchantDisplayName: $scope.subMerchantInfo.merchantDisplayName, + merchantMCC: $scope.subMerchantInfo.alipayindustry, + legalName: $scope.subMerchantInfo.legalName, + registrationType: $scope.subMerchantInfo.registrationType, + registrationNo: $scope.subMerchantInfo.registrationNo, + businessType: $scope.subMerchantInfo.businessType, + shareholderName: $scope.subMerchantInfo.shareholderName, + shareholderId: $scope.subMerchantInfo.shareholderId, + representativeName: $scope.subMerchantInfo.representativeName, + representativeId: $scope.subMerchantInfo.representativeId, + storeName: $scope.subMerchantInfo.storeName, + storeMCC: $scope.subMerchantInfo.storeMCC, + storeAddress: $scope.subMerchantInfo.storeAddress, + registrationAddress: $scope.subMerchantInfo.registrationAddress, } - ) - }) - }) - } - // use sub_merchant_id - $scope.useSubMerchantId = function (sub_merchant_id) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // 查看sub_merchant_id详情 - $scope.checkDetail = function (merchantInfo, channel) { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/sub_merchant_detail.html', - controller: 'subMerchantDetailCtrl', - resolve: { - subMerchantInfo: function () { - return merchantInfo - }, - channel: function () { - return channel - }, - }, - }) - } - // 修改sub_merchant_id - $scope.modifySubMerchantId = function (subMerchantId, channel) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/md_sub_merchant_id.html', - controller: 'ModifysubMerchantIdCtrl', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - merchantId: function () { - return subMerchantId - }, - channel: function () { - return channel - }, - }, - }) - .result.then(function () { - commonDialog.alert({ - title: 'Success', - content: 'Modify successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }) - } - // 卡支付apply - $scope.applyMWSubMerchantId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/mw_info').then(function (resp) { - commonDialog - .confirm({ - title: 'Apply Merchant Warrior Sub Merchant Id', - contentHtml: $sce.trustAsHtml('Are you sure to apply merchant Warrior sub merchant id for [' + $scope.partner.company_name + ']?'), - json: resp.data, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/applyMWMerchantId').then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Merchant Warrior Sub Merchant ID successfully', - type: 'success', - }) - $scope.cardInfo = res.data - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + params.productCodes = []; + if ($scope.subMerchantInfo.online) { + params.productCodes.push('CASHIER_PAYMENT'); + } else { + params.productCodes.push('IN_STORE_PAYMENT'); } - ) - }) - }) - } - - $scope.copyMWProfile = function () { - commonDialog.inputText({ title: '请输入复制来源商户编码' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/copy_mw_config', { client_moniker: text }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - // $scope.showMoreMerchantInfo = false; - // $scope.hideMerchantInfo = function () { - // $scope.showMoreMerchantInfo = !$scope.showMoreMerchantInfo; - // }; - $scope.updateSubMerchantId = function (sub_merchant_id) { - angular.forEach($scope.subMerchantInfos, function (each) { - if (sub_merchant_id == each.sub_merchant_id) { - $scope.merchant_app_id = each.merchant_app_id - } - }) - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/update_apply_wx_sub_merchant_id.html', - controller: 'updateApplyWxSubMerchantIdCtrl', - resolve: { - merchantInfo: $scope.partner, - merchantIds: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') - }, - ], - subMerchantInfo: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.merchant_app_id) - }, - ], - }, - }) - .result.then(function () { - $scope.loadSubMerchantInfos() - }) - } - }, - ]) - app.controller('applyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.merchantIds = merchantIds.data - $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry) - $scope.saveAppliy = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/sub_apply', $scope.subMerchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.confirm({ title: 'Confirm', content: '已申请成功,是否确认使用' }).then(function () { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', + params.websites = [] + if ($scope.subMerchantInfo.online) { + params.websites.push($scope.subMerchantInfo.website); + } + + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/apply_alipayplus', params).then( + function (resp) { + if (resp.data.result) { + commonDialog.alert({title: 'Success', content: "注册成功!", type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: "注册失败!", type: 'error'}) + } + + $scope.$close() + }, + function (resp) { + $scope.flag = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + + }; + + + }, + ]) + + app.controller('applyRpaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'businessStructuresMap', + '$filter', + 'commonDialog', + 'timezone', + function ($scope, $http, $uibModal, $state, subMerchantInfo, businessStructuresMap, $filter, commonDialog, timezone) { + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.business_structures = businessStructuresMap.configs() + $scope.timezone = timezone.configs() + + $scope.saveRpayAppliy = function (form) { + var merchantInfo = {} + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + return + } + angular.forEach(form, function (item, key) { + if (item != null) { + if (item.$name != null) { + merchantInfo[key] = item.$modelValue + } + } + }) + + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registRpaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.sub_merchant_id != null) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Rpay+ Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + } + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } ) - }) - } else { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - // 展示信息 - app.controller('subMerchantDetailCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - 'subMerchantInfo', - 'channel', - function ($scope, $http, $uibModal, $state, commonDialog, subMerchantInfo, channel) { - $scope.channel = channel - $scope.subMerchantInfo = subMerchantInfo - }, - ]) - // 修改sub_merchant_id - app.controller('ModifysubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - 'clientMoniker', - 'merchantId', - 'channel', - function ($scope, $http, $uibModal, $state, commonDialog, clientMoniker, merchantId, channel) { - $scope.merchantId = merchantId - $scope.flag = false - $scope.confirm = function () { - $scope.flag = true - if (channel === 'Wechat') { - $http.put('/sys/partners/' + clientMoniker + '/payment_config', { sub_merchant_id: $scope.merchantId }).then( - function (resp) { - $scope.$close() - }, - function (resp) { - $scope.flag = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } else if (channel === 'Alipay' || channel === 'AlipayOnline') { - $http.put('/sys/partners/' + clientMoniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.merchantId }).then( - function (resp) { - $scope.$close() - }, - function (resp) { - $scope.flag = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - } - }, - ]) - app.controller('newApplyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - 'wechatGoodMcc', - 'businessTypesMap', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, businessTypesMap) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.subMerchantInfo.address= subMerchantInfo.address+","+subMerchantInfo.suburb - +","+subMerchantInfo.state+","+subMerchantInfo.country; - $scope.subMerchantInfo.company_register_no = subMerchantInfo.abn ? subMerchantInfo.abn : subMerchantInfo.acn - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.merchantIds = merchantIds.data - $scope.businessTypesMap = businessTypesMap.configs() - if ($scope.subMerchantInfo.client_pay_type) { - if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'BOTH' - } else if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0) { - $scope.subMerchantInfo.business_type = 'ONLINE' - } else if ($scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'OFFLINE' - } - } else { - $scope.subMerchantInfo.business_type = 'BOTH' - } - - if ($scope.subMerchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry) - } - if ($scope.subMerchantInfo.mc_code) { - $scope.subMerchantInfo.mcc_code = $scope.subMerchantInfo.mc_code - } - if (subMerchantInfo.certificat_expire_date) { - var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date = new Date(datestr) - } - if ($scope.subMerchantInfo.business_structure) { - $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' - } - if (subMerchantInfo.certificat_expire_date) { - if (subMerchantInfo.certificat_expire_date == 'PERMANENT') { - $scope.subMerchantInfo.certificat_expire_date_premanent = true - } else if (subMerchantInfo.certificat_expire_date == 'N/A') { - $scope.subMerchantInfo.certificat_expire_date_NA = true - } else { - var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) - } - } + } + }, + ]) + app.controller('applyYeepaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'yeepayIndustryMap', + 'yeepayBusinessContentMap', + '$filter', + 'commonDialog', + 'Upload', + function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { + $scope.yeepay_industries = yeepayIndustryMap.configs() + $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + if (!$scope.subMerchantInfo.abn) { + $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn + } + var vouchers = {} + + $scope.directors = {} + $scope.executives = {} + $scope.industry = '' + $scope.business_content = '' + var merchantInfo = {} + + var merchantId = '' + + // $scope.uploadLegalIDcardFront = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardFrontProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardFrontProgress; + // $scope.legalIDcardFront = resp.data.path; + // vouchers['legalIDcardFront'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardFrontProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadLegalIDcardBack = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardBackProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardBackProgress; + // $scope.legalIDcardBack = resp.data.path; + // vouchers['legalIDcardBack'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardBackProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadBusinessLicence = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.businessLicenceProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.businessLicenceProgress + $scope.businessLicence = resp.data.path + merchantInfo['business_licence'] = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.businessLicenceProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - $scope.checkExpriedate = function (value) { - if (value) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - $scope.subMerchantInfo.certificat_expire_date_NA = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.subMerchantInfo.certificat_expire_date_NA) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } - } - $scope.saveAppliy = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - // var merchant_type = $scope.subMerchantInfo.business_structure == 'Company'? 1:2; - var params = { - company_name: $scope.subMerchantInfo.company_name, - merchant_id: $scope.subMerchantInfo.merchant_id, - short_name: $scope.subMerchantInfo.short_name, - office_phone: $scope.subMerchantInfo.office_phone, - contact_person: $scope.subMerchantInfo.contact_person, - contact_phone: $scope.subMerchantInfo.contact_phone, - company_phone: $scope.subMerchantInfo.company_phone, - contact_email: $scope.subMerchantInfo.contact_email, - industry: $scope.subMerchantInfo.industry, - company_website: $scope.subMerchantInfo.company_website, - merchant_type: $scope.subMerchantInfo.merchant_type, - mcc_code: $scope.subMerchantInfo.mcc_code, - address: $scope.subMerchantInfo.address, - business_type: $scope.subMerchantInfo.business_type, - } - if (params.business_type == 'ONLINE') { - params.address = null - } else if (params.business_type == 'OFFLINE') { - params.company_website = null - } + // $scope.uploadTaxLevel = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.taxLevelProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.taxLevelProgress; + // $scope.taxLevel = resp.data.path; + // vouchers['taxLevel'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.taxLevelProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadBankAccountOpen = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.bankAccountOpenProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.bankAccountOpenProgress; + // $scope.bankAccountOpen = resp.data.path; + // vouchers['bankAccountOpen'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.bankAccountOpenProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadOrgCode = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.orgCodeProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.orgCodeProgress; + // $scope.orgCode = resp.data.path; + // vouchers['orgCode'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.orgCodeProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadNonStanProtocol = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.nonStanProtocolProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.nonStanProtocolProgress; + // $scope.nonStanProtocol = resp.data.path; + // vouchers['nonStanProtocol'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.nonStanProtocolProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadZipPath = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.zipPathProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.zipPathProgress; + // $scope.zipPath = resp.data.path; + // vouchers['zipPath'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.zipPathProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadDirectorPassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.directorPassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.directorPassportProgress + $scope.directorPassport = resp.data.path + $scope.directors.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.directorPassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - if (params.merchant_type == 'ENTERPRISE') { - params.director_name = $scope.subMerchantInfo.director_name - params.director_id_number = $scope.subMerchantInfo.director_id_number - params.company_register_no = $scope.subMerchantInfo.company_register_no - params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date - - if ($scope.subMerchantInfo.certificat_expire_date_d) { - params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) - } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - params.certificat_expire_date = 'PERMANENT' - } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { - params.certificat_expire_date = 'N/A' - } else { - alert('Certificate expiration time is required') - return - } - } else { - params.principal_name = $scope.subMerchantInfo.principal_name - params.principal_id_number = $scope.subMerchantInfo.principal_id_number - } + $scope.uploadExecutivePassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.executivePassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.executivePassportProgress + $scope.executivePassport = resp.data.path + $scope.executives.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.executivePassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/new_sub_apply', params).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.confirm({ title: 'Confirm', content: '已申请成功,是否确认使用' }).then(function () { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', + $scope.saveYeepayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + merchantInfo['company_name'] = $scope.subMerchantInfo.company_name + merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person + merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone + merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email + merchantInfo['company_website'] = $scope.subMerchantInfo.company_website + merchantInfo['abn'] = $scope.subMerchantInfo.abn + merchantInfo['executives'] = $scope.executives + merchantInfo['directors'] = $scope.directors + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + merchantInfo['merchantId'] = merchantId + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.yeepay_sub_merchant_id != null) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Yeepay Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + } + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } ) - }) - } else { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('updateApplyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - 'wechatGoodMcc', - 'merchantInfo', - 'businessTypesMap', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, merchantInfo, businessTypesMap) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo.data) - $scope.merchantInfo = angular.copy(merchantInfo) - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.merchantIds = merchantIds.data - $scope.businessTypesMap = businessTypesMap.configs() - $scope.subMerchantInfo.short_name = $scope.merchantInfo.short_name - $scope.subMerchantInfo.industry = $scope.merchantInfo.industry - $scope.subMerchantInfo.company_website = $scope.merchantInfo.company_website - $scope.subMerchantInfo.address = $scope.merchantInfo.address+","+$scope.merchantInfo.suburb - +","+$scope.merchantInfo.state+","+$scope.merchantInfo.country; - $scope.subMerchantInfo.company_phone = $scope.merchantInfo.company_phone - $scope.subMerchantInfo.contact_person = $scope.merchantInfo.contact_person - $scope.subMerchantInfo.contact_phone = $scope.merchantInfo.contact_phone - $scope.subMerchantInfo.contact_email = $scope.merchantInfo.contact_email - $scope.subMerchantInfo.company_register_no = $scope.merchantInfo.abn ? $scope.merchantInfo.abn : $scope.merchantInfo.acn - - if ($scope.merchantInfo.client_pay_type) { - if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'BOTH' - } else if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0) { - $scope.subMerchantInfo.business_type = 'ONLINE' - } else if ($scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'OFFLINE' } - } else { - $scope.subMerchantInfo.business_type = 'BOTH' - } + }, + ]) + app.controller('addYeepaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'yeepayIndustryMap', + 'yeepayBusinessContentMap', + '$filter', + 'commonDialog', + 'Upload', + function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { + $scope.yeepay_industries = yeepayIndustryMap.configs() + $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + + var merchantInfo = {} + + $scope.saveYeepayAdd = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + + merchantInfo['sub_merchant_id'] = $scope.sub_merchant_id + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/addYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.$close() + commonDialog.alert({ + title: 'Success', + content: 'Add Yeepay Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('updateYeepaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'yeepayIndustryMap', + 'yeepayBusinessContentMap', + '$filter', + 'commonDialog', + 'Upload', + 'subMerchantId', + function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload, subMerchantId) { + $scope.yeepay_industries = yeepayIndustryMap.configs() + $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + if (!$scope.subMerchantInfo.abn) { + $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn + } + var vouchers = {} + + $scope.directors = {} + $scope.executives = {} + $scope.industry = '' + $scope.business_content = '' + var merchantInfo = {} + + var merchantId = '' + + // $scope.uploadLegalIDcardFront = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardFrontProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardFrontProgress; + // $scope.legalIDcardFront = resp.data.path; + // vouchers['legalIDcardFront'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardFrontProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadLegalIDcardBack = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardBackProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardBackProgress; + // $scope.legalIDcardBack = resp.data.path; + // vouchers['legalIDcardBack'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardBackProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadBusinessLicence = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.businessLicenceProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.businessLicenceProgress + $scope.businessLicence = resp.data.path + merchantInfo['business_licence'] = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.businessLicenceProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - if ($scope.merchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.merchantInfo.industry) - } - if ($scope.merchantInfo.mc_code) { - $scope.subMerchantInfo.mcc_code = $scope.merchantInfo.mc_code - } + // $scope.uploadTaxLevel = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.taxLevelProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.taxLevelProgress; + // $scope.taxLevel = resp.data.path; + // vouchers['taxLevel'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.taxLevelProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadBankAccountOpen = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.bankAccountOpenProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.bankAccountOpenProgress; + // $scope.bankAccountOpen = resp.data.path; + // vouchers['bankAccountOpen'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.bankAccountOpenProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadOrgCode = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.orgCodeProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.orgCodeProgress; + // $scope.orgCode = resp.data.path; + // vouchers['orgCode'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.orgCodeProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadNonStanProtocol = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.nonStanProtocolProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.nonStanProtocolProgress; + // $scope.nonStanProtocol = resp.data.path; + // vouchers['nonStanProtocol'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.nonStanProtocolProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadZipPath = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.zipPathProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.zipPathProgress; + // $scope.zipPath = resp.data.path; + // vouchers['zipPath'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.zipPathProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadDirectorPassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.directorPassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.directorPassportProgress + $scope.directorPassport = resp.data.path + $scope.directors.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.directorPassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - if ($scope.merchantInfo.business_structure) { - $scope.subMerchantInfo.merchant_type = $scope.merchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' - } - if ($scope.merchantInfo.certificat_expire_date) { - if ($scope.merchantInfo.certificat_expire_date == 'PERMANENT') { - $scope.subMerchantInfo.certificat_expire_date_premanent = true - } else if ($scope.merchantInfo.certificat_expire_date == 'N/A') { - $scope.subMerchantInfo.certificat_expire_date_NA = true - } else { - var datestr = $scope.merchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) + $scope.uploadExecutivePassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.executivePassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.executivePassportProgress + $scope.executivePassport = resp.data.path + $scope.executives.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.executivePassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } } - } - $scope.checkExpriedate = function (value) { - if (value) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - $scope.subMerchantInfo.certificat_expire_date_NA = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.subMerchantInfo.certificat_expire_date_NA) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } - } - $scope.updateApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - var params = { - company_name: $scope.subMerchantInfo.company_name, - merchant_id: $scope.subMerchantInfo.merchant_id, - short_name: $scope.subMerchantInfo.short_name, - office_phone: $scope.subMerchantInfo.office_phone, - contact_person: $scope.subMerchantInfo.contact_person, - contact_phone: $scope.subMerchantInfo.contact_phone, - company_phone: $scope.subMerchantInfo.company_phone, - contact_email: $scope.subMerchantInfo.contact_email, - industry: $scope.subMerchantInfo.industry, - company_website: $scope.subMerchantInfo.company_website, - merchant_type: $scope.subMerchantInfo.merchant_type, - mcc_code: $scope.subMerchantInfo.mcc_code, - address: $scope.subMerchantInfo.address, - business_type: $scope.subMerchantInfo.business_type, - sub_mch_id: $scope.subMerchantInfo.sub_merchant_id, - merchant_remark: $scope.subMerchantInfo.merchant_remark, - } - if (params.business_type == 'ONLINE') { - params.address = null - } else if (params.business_type == 'OFFLINE') { - params.company_website = null - } - // if($scope.subMerchantInfo.merchant_type == 'ENTERPRISE'){ - // params.director_name = $scope.subMerchantInfo.director_name; - // params.director_id_number = $scope.subMerchantInfo.director_id_number; - // params.company_register_no = $scope.subMerchantInfo.company_register_no; - // params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date; - // if($scope.subMerchantInfo.certificat_expire_date) { - // params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date) - // } - // }else{ - // params.principal_name = $scope.subMerchantInfo.principal_name; - // params.principal_id_number = $scope.subMerchantInfo.principal_id_number; - // } - if (params.merchant_type == 'ENTERPRISE') { - params.company_register_no = $scope.subMerchantInfo.company_register_no - params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date - if ($scope.subMerchantInfo.certificat_expire_date_d) { - params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) - } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - params.certificat_expire_date = 'PERMANENT' - } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { - params.certificat_expire_date = 'N/A' - } else { - alert('Certificate expiration time is required') - return - } - } - $http.put('/sys/partners/' + $scope.merchantInfo.client_moniker + '/get_merchant_ids/' + $scope.subMerchantInfo.merchant_app_id, params).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - commonDialog.confirm({ title: 'Confirm', content: 'Successfully modified!' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - - app.controller('applyRpaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'businessStructuresMap', - '$filter', - 'commonDialog', - 'timezone', - function ($scope, $http, $uibModal, $state, subMerchantInfo, businessStructuresMap, $filter, commonDialog, timezone) { - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.business_structures = businessStructuresMap.configs() - $scope.timezone = timezone.configs() - - $scope.saveRpayAppliy = function (form) { - var merchantInfo = {} - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - angular.forEach(form, function (item, key) { - if (item != null) { - if (item.$name != null) { - merchantInfo[key] = item.$modelValue - } - } - }) - - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registRpaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Rpay+ Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('applyYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - if (!$scope.subMerchantInfo.abn) { - $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn - } - var vouchers = {} - - $scope.directors = {} - $scope.executives = {} - $scope.industry = '' - $scope.business_content = '' - var merchantInfo = {} - - var merchantId = '' - - // $scope.uploadLegalIDcardFront = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardFrontProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardFrontProgress; - // $scope.legalIDcardFront = resp.data.path; - // vouchers['legalIDcardFront'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardFrontProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadLegalIDcardBack = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardBackProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardBackProgress; - // $scope.legalIDcardBack = resp.data.path; - // vouchers['legalIDcardBack'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardBackProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadBusinessLicence = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.businessLicenceProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.businessLicenceProgress - $scope.businessLicence = resp.data.path - merchantInfo['business_licence'] = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.businessLicenceProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - // $scope.uploadTaxLevel = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.taxLevelProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.taxLevelProgress; - // $scope.taxLevel = resp.data.path; - // vouchers['taxLevel'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.taxLevelProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadBankAccountOpen = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.bankAccountOpenProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.bankAccountOpenProgress; - // $scope.bankAccountOpen = resp.data.path; - // vouchers['bankAccountOpen'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.bankAccountOpenProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadOrgCode = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.orgCodeProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.orgCodeProgress; - // $scope.orgCode = resp.data.path; - // vouchers['orgCode'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.orgCodeProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadNonStanProtocol = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.nonStanProtocolProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.nonStanProtocolProgress; - // $scope.nonStanProtocol = resp.data.path; - // vouchers['nonStanProtocol'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.nonStanProtocolProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadZipPath = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.zipPathProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.zipPathProgress; - // $scope.zipPath = resp.data.path; - // vouchers['zipPath'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.zipPathProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadDirectorPassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.directorPassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.directorPassportProgress - $scope.directorPassport = resp.data.path - $scope.directors.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.directorPassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadExecutivePassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.executivePassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.executivePassportProgress - $scope.executivePassport = resp.data.path - $scope.executives.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.executivePassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } + $scope.updateYeepayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + merchantInfo['company_name'] = $scope.subMerchantInfo.company_name + merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person + merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone + merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email + merchantInfo['company_website'] = $scope.subMerchantInfo.company_website + merchantInfo['abn'] = $scope.subMerchantInfo.abn + merchantInfo['executives'] = $scope.executives + merchantInfo['subMerchantId'] = angular.copy(subMerchantId) + merchantInfo['directors'] = $scope.directors + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + merchantInfo['merchantId'] = merchantId + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/updateYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.yeepay_sub_merchant_id != null) { + commonDialog.alert({ + title: 'Success', + content: 'Update Successfully,Please Wait For Review!', + type: 'success', + }) + $state.reload() + } + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('permissionClientCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + '$filter', + 'commonDialog', + function ($scope, $http, $uibModal, $state, $filter, commonDialog) { + $scope.clientPermission = {client_moniker: $scope.partner.client_moniker} + $scope.loadPermissionList = function () { + var params = angular.copy($scope.clientPermission) + $http.get('/sys/permission/list', {params: params}).then( + function (resp) { + $scope.permissionList = resp.data + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.loadPermissionList(1) + $scope.switchValid = function (permission) { + $scope.clientPermission.isValid = permission.is_valid + var params = angular.copy($scope.clientPermission) + $http.post('/sys/permission/' + permission.id, params).then( + function (resp) { + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } - $scope.saveYeepayApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true + $scope.init = function () { + var params = {client_moniker: $scope.partner.client_moniker} + $http.post('/sys/permission/init', params).then( + function (resp) { + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - merchantInfo['company_name'] = $scope.subMerchantInfo.company_name - merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person - merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone - merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email - merchantInfo['company_website'] = $scope.subMerchantInfo.company_website - merchantInfo['abn'] = $scope.subMerchantInfo.abn - merchantInfo['executives'] = $scope.executives - merchantInfo['directors'] = $scope.directors - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - merchantInfo['merchantId'] = merchantId - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.yeepay_sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Yeepay Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', + }, + ]) + app.controller('incrementalServiceCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + '$filter', + 'commonDialog', + function ($scope, $http, $uibModal, $state, $filter, commonDialog) { + $scope.serviceAll = {} + $scope.channelOptions = [] + $scope.initData = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service').then(function (res) { + $scope.serviceAll = res.data.all_service + $scope.serviceAll.forEach(function (service) { + service.logo_url = '/static/images/' + service.channel + '.jpg' + service.logo_url = $scope.CheckImgExists(service.logo_url) ? service.logo_url : '/static/images/royalpay_sign.png' + }) + $scope.channelOptions = res.data.incremental_channel + }) + } + $scope.CheckImgExists = function (url) { + var xmlHttp + if (window.ActiveXObject) { + xmlHttp = new ActiveXObject('Microsoft.XMLHTTP') + } else if (window.XMLHttpRequest) { + xmlHttp = new XMLHttpRequest() + } + xmlHttp.open('Get', url, false) + xmlHttp.send() + if (xmlHttp.status == 404) return false + else return true + } + $scope.initData() + $scope.newServiceChannelDialog = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', + controller: 'incrementalServiceDialogCtrl', + resolve: { + params: function () { + return { + isCreate: true, + clientMoniker: $scope.partner.client_moniker, + channelOptions: $scope.channelOptions, + serviceChannel: null, + } + }, + }, + }) + .result.then(function () { + $scope.initData() + }) + } + $scope.editServiceChannelDialog = function (serviceChannel) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', + controller: 'incrementalServiceDialogCtrl', + resolve: { + params: function () { + return { + isCreate: false, + clientMoniker: $scope.partner.client_moniker, + channelOptions: $scope.channelOptions, + serviceChannel: serviceChannel, + } + }, + }, + }) + .result.then(function () { + $scope.initData() + }) + } + $scope.updateStatus = function (service) { + commonDialog + .confirm({ + title: 'Update ' + service.channel + ' Incremental Service Status', + content: 'Are you sure update ' + service.channel + ' status?', + choises: [ + {label: 'Submit', className: 'btn-success', key: 1}, + {label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true}, + ], + }) + .then(function (choice) { + if (choice == 1) { + service.is_valid = !service.is_valid + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service/status', service).then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: 'Update Service Successful!', + type: 'success', + }) + $scope.initData() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $scope.initData() + } + ) + } + }) + } + }, + ]) + app.controller('incrementalServiceDialogCtrl', [ + '$scope', + '$http', + 'params', + 'commonDialog', + function ($scope, $http, params, commonDialog) { + $scope.model = {} + $scope.ctrl = {sending: false} + $scope.isCreate = true + $scope.initData = function () { + $scope.isCreate = angular.copy(params.isCreate) + if ($scope.isCreate) { + $scope.model.channel = angular.copy(params.channelOptions[0]) + $scope.model.channelOptions = angular.copy(params.channelOptions) + } else { + $scope.model = angular.copy(params.serviceChannel) + } + } + $scope.initData() + $scope.save = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.ctrl.sending = true + $http.post('/sys/partners/' + params.clientMoniker + '/incremental_service', $scope.model).then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: $scope.isCreate ? 'Create Service Successful!' : 'Update Service Successful!', + type: 'success', + }) + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + + app.filter('bdOrg', function () { + return function (bdUsers, org_id) { + if (org_id) { + var bdUserByOrg = {} + var count = 0 + angular.forEach(bdUsers, function (bdUser) { + if (bdUser.org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + }) + return bdUserByOrg + } + return bdUsers + } + }) + app.filter('wxMerchants', function () { + return function (values) { + var industry = '' + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } }) - } - ) - } - }, - ]) - app.controller('addYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - - var merchantInfo = {} - - $scope.saveYeepayAdd = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - - merchantInfo['sub_merchant_id'] = $scope.sub_merchant_id - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/addYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.$close() - commonDialog.alert({ - title: 'Success', - content: 'Add Yeepay Sub Merchant ID successfully', - type: 'success', + return industry + } + }) + //将保存的industry 和最新的分类比较,若查不到,返回空 + app.filter('newWxMerchantsFilter', function () { + return function (values) { + var industry = null + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.value + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', + return industry + } + }) + app.filter('newWxMerchants', function () { + return function (values) { + var industry = '' + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } }) - } - ) - } - }, - ]) - app.controller('updateYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - 'subMerchantId', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload, subMerchantId) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - if (!$scope.subMerchantInfo.abn) { - $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn - } - var vouchers = {} - - $scope.directors = {} - $scope.executives = {} - $scope.industry = '' - $scope.business_content = '' - var merchantInfo = {} - - var merchantId = '' - - // $scope.uploadLegalIDcardFront = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardFrontProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardFrontProgress; - // $scope.legalIDcardFront = resp.data.path; - // vouchers['legalIDcardFront'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardFrontProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadLegalIDcardBack = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardBackProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardBackProgress; - // $scope.legalIDcardBack = resp.data.path; - // vouchers['legalIDcardBack'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardBackProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadBusinessLicence = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.businessLicenceProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.businessLicenceProgress - $scope.businessLicence = resp.data.path - merchantInfo['business_licence'] = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.businessLicenceProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + return industry + } + }) + app.filter('yeepayIndustry', function () { + return function (value) { + switch (value + '') { + case 'ehk100000': + return '货物贸易' + case 'ehk200000': + return '旅游' + case 'ehk300000': + return '文化教育' + case 'ehk400000': + return '服务贸易' + case 'ehk500000': + return '物流' + case 'ehk600000': + return '数字娱乐' + case 'ehk700000': + return '金融保险' + case 'ehk999999': + return '其他' + } } - } - - // $scope.uploadTaxLevel = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.taxLevelProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.taxLevelProgress; - // $scope.taxLevel = resp.data.path; - // vouchers['taxLevel'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.taxLevelProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadBankAccountOpen = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.bankAccountOpenProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.bankAccountOpenProgress; - // $scope.bankAccountOpen = resp.data.path; - // vouchers['bankAccountOpen'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.bankAccountOpenProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadOrgCode = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.orgCodeProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.orgCodeProgress; - // $scope.orgCode = resp.data.path; - // vouchers['orgCode'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.orgCodeProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadNonStanProtocol = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.nonStanProtocolProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.nonStanProtocolProgress; - // $scope.nonStanProtocol = resp.data.path; - // vouchers['nonStanProtocol'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.nonStanProtocolProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadZipPath = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.zipPathProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.zipPathProgress; - // $scope.zipPath = resp.data.path; - // vouchers['zipPath'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.zipPathProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadDirectorPassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.directorPassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.directorPassportProgress - $scope.directorPassport = resp.data.path - $scope.directors.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.directorPassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + }) + + app.filter('yeepayBusinessContent', function () { + return function (value) { + switch (value + '') { + case 'SERVICETRADE': + return '服务贸易' + case 'GOODSTRADE': + return '货物贸易' + case 'OVERSEASTUDY': + return '留学' + case 'HOTELTICKET': + return '酒店机票' + case 'INTTRANSPORT': + return '国际运输' + case 'TOURSERVICE': + return '旅游服务' + case 'INSURANCE': + return '保险' + } } - } - - $scope.uploadExecutivePassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.executivePassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.executivePassportProgress - $scope.executivePassport = resp.data.path - $scope.executives.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.executivePassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + }) + + app.filter('bdOrgSelect', function () { + return function (bdUsers, params) { + var org_id + org_id = params.org_ids || params.org_id || currentUser.org_id + if (org_id) { + var bdUserByOrg = {} + var count = 0 + angular.forEach(bdUsers, function (bdUser) { + if (params.org_ids) { + if (bdUser.org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + } else { + if (bdUser.org_id == org_id || bdUser.parent_org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + } + }) + return bdUserByOrg + } + return bdUsers + } + }) + + app.filter('wxindustries', function () { + return function (value) { + switch (value + '') { + case '327': + return '343' + case '339': + return '493' + case '337': + return '492' + case '328': + return '491' + case '362': + case '361': + case '363': + case '329': + return '490' + case '330': + return '489' + case '332': + return '487' + case '334': + return '486' + case '335': + return '485' + case '336': + return '484' + case '338': + case '358': + return '494' + } } - } + }) - $scope.updateYeepayApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true + app.filter('wechatMcc', [ + 'wechatGoodMcc', + function (wechatGoodMcc) { + return function (values) { + var industry = '' + angular.forEach(wechatGoodMcc.configs(), function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } + }) + return industry + } + }, + ]) + + app.filter('choose_merchant_id', function () { + return function (value) { + switch (value + '') { + case '1307485301': + return '1307485301(Tunnel Show1)' + case '1431999902': + return '1431999902(Tunnel Show2)' + case '1487387142': + return '1487387142(NAP)' + case '': + return '' } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - merchantInfo['company_name'] = $scope.subMerchantInfo.company_name - merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person - merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone - merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email - merchantInfo['company_website'] = $scope.subMerchantInfo.company_website - merchantInfo['abn'] = $scope.subMerchantInfo.abn - merchantInfo['executives'] = $scope.executives - merchantInfo['subMerchantId'] = angular.copy(subMerchantId) - merchantInfo['directors'] = $scope.directors - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - merchantInfo['merchantId'] = merchantId - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/updateYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.yeepay_sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Update Successfully,Please Wait For Review!', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('permissionClientCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - '$filter', - 'commonDialog', - function ($scope, $http, $uibModal, $state, $filter, commonDialog) { - $scope.clientPermission = { client_moniker: $scope.partner.client_moniker } - $scope.loadPermissionList = function () { - var params = angular.copy($scope.clientPermission) - $http.get('/sys/permission/list', { params: params }).then( - function (resp) { - $scope.permissionList = resp.data - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.loadPermissionList(1) - $scope.switchValid = function (permission) { - $scope.clientPermission.isValid = permission.is_valid - var params = angular.copy($scope.clientPermission) - $http.post('/sys/permission/' + permission.id, params).then( - function (resp) {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.init = function () { - var params = { client_moniker: $scope.partner.client_moniker } - $http.post('/sys/permission/init', params).then( - function (resp) {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('incrementalServiceCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - '$filter', - 'commonDialog', - function ($scope, $http, $uibModal, $state, $filter, commonDialog) { - $scope.serviceAll = {} - $scope.channelOptions = [] - $scope.initData = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service').then(function (res) { - $scope.serviceAll = res.data.all_service - $scope.serviceAll.forEach(function (service) { - service.logo_url = '/static/images/' + service.channel + '.jpg' - service.logo_url = $scope.CheckImgExists(service.logo_url) ? service.logo_url : '/static/images/royalpay_sign.png' - }) - $scope.channelOptions = res.data.incremental_channel - }) - } - $scope.CheckImgExists = function (url) { - var xmlHttp - if (window.ActiveXObject) { - xmlHttp = new ActiveXObject('Microsoft.XMLHTTP') - } else if (window.XMLHttpRequest) { - xmlHttp = new XMLHttpRequest() - } - xmlHttp.open('Get', url, false) - xmlHttp.send() - if (xmlHttp.status == 404) return false - else return true - } - $scope.initData() - $scope.newServiceChannelDialog = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', - controller: 'incrementalServiceDialogCtrl', - resolve: { - params: function () { - return { - isCreate: true, - clientMoniker: $scope.partner.client_moniker, - channelOptions: $scope.channelOptions, - serviceChannel: null, - } - }, - }, - }) - .result.then(function () { - $scope.initData() - }) - } - $scope.editServiceChannelDialog = function (serviceChannel) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', - controller: 'incrementalServiceDialogCtrl', - resolve: { - params: function () { - return { - isCreate: false, - clientMoniker: $scope.partner.client_moniker, - channelOptions: $scope.channelOptions, - serviceChannel: serviceChannel, - } - }, - }, - }) - .result.then(function () { - $scope.initData() - }) - } - $scope.updateStatus = function (service) { - commonDialog - .confirm({ - title: 'Update ' + service.channel + ' Incremental Service Status', - content: 'Are you sure update ' + service.channel + ' status?', - choises: [ - { label: 'Submit', className: 'btn-success', key: 1 }, - { label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true }, - ], - }) - .then(function (choice) { - if (choice == 1) { - service.is_valid = !service.is_valid - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service/status', service).then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: 'Update Service Successful!', - type: 'success', - }) - $scope.initData() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $scope.initData() - } - ) - } - }) - } - }, - ]) - app.controller('incrementalServiceDialogCtrl', [ - '$scope', - '$http', - 'params', - 'commonDialog', - function ($scope, $http, params, commonDialog) { - $scope.model = {} - $scope.ctrl = { sending: false } - $scope.isCreate = true - $scope.initData = function () { - $scope.isCreate = angular.copy(params.isCreate) - if ($scope.isCreate) { - $scope.model.channel = angular.copy(params.channelOptions[0]) - $scope.model.channelOptions = angular.copy(params.channelOptions) - } else { - $scope.model = angular.copy(params.serviceChannel) - } - } - $scope.initData() - $scope.save = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.ctrl.sending = true - $http.post('/sys/partners/' + params.clientMoniker + '/incremental_service', $scope.model).then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: $scope.isCreate ? 'Create Service Successful!' : 'Update Service Successful!', - type: 'success', - }) - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - - app.filter('bdOrg', function () { - return function (bdUsers, org_id) { - if (org_id) { - var bdUserByOrg = {} - var count = 0 - angular.forEach(bdUsers, function (bdUser) { - if (bdUser.org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - }) - return bdUserByOrg - } - return bdUsers - } - }) - app.filter('wxMerchants', function () { - return function (values) { - var industry = '' - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label - } - }) - return industry - } - }) - //将保存的industry 和最新的分类比较,若查不到,返回空 - app.filter('newWxMerchantsFilter', function () { - return function (values) { - var industry = null - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.value - } - }) - return industry - } - }) - app.filter('newWxMerchants', function () { - return function (values) { - var industry = '' - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label } - }) - return industry - } - }) - app.filter('yeepayIndustry', function () { - return function (value) { - switch (value + '') { - case 'ehk100000': - return '货物贸易' - case 'ehk200000': - return '旅游' - case 'ehk300000': - return '文化教育' - case 'ehk400000': - return '服务贸易' - case 'ehk500000': - return '物流' - case 'ehk600000': - return '数字娱乐' - case 'ehk700000': - return '金融保险' - case 'ehk999999': - return '其他' - } - } - }) - - app.filter('yeepayBusinessContent', function () { - return function (value) { - switch (value + '') { - case 'SERVICETRADE': - return '服务贸易' - case 'GOODSTRADE': - return '货物贸易' - case 'OVERSEASTUDY': - return '留学' - case 'HOTELTICKET': - return '酒店机票' - case 'INTTRANSPORT': - return '国际运输' - case 'TOURSERVICE': - return '旅游服务' - case 'INSURANCE': - return '保险' - } - } - }) - - app.filter('bdOrgSelect', function () { - return function (bdUsers, params) { - var org_id - org_id = params.org_ids || params.org_id || currentUser.org_id - if (org_id) { - var bdUserByOrg = {} - var count = 0 - angular.forEach(bdUsers, function (bdUser) { - if (params.org_ids) { - if (bdUser.org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - } else { - if (bdUser.org_id == org_id || bdUser.parent_org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - } - }) - return bdUserByOrg - } - return bdUsers - } - }) - - app.filter('wxindustries', function () { - return function (value) { - switch (value + '') { - case '327': - return '343' - case '339': - return '493' - case '337': - return '492' - case '328': - return '491' - case '362': - case '361': - case '363': - case '329': - return '490' - case '330': - return '489' - case '332': - return '487' - case '334': - return '486' - case '335': - return '485' - case '336': - return '484' - case '338': - case '358': - return '494' - } - } - }) - - app.filter('wechatMcc', [ - 'wechatGoodMcc', - function (wechatGoodMcc) { - return function (values) { - var industry = '' - angular.forEach(wechatGoodMcc.configs(), function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label - } - }) - return industry - } - }, - ]) - - app.filter('choose_merchant_id', function () { - return function (value) { - switch (value + '') { - case '1307485301': - return '1307485301(Tunnel Show1)' - case '1431999902': - return '1431999902(Tunnel Show2)' - case '1487387142': - return '1487387142(NAP)' - case '': - return '' - } - } - }) + }) - app.filter('cut', function () { - return function (value, wordwise, max, tail) { - if (!value) return '' + app.filter('cut', function () { + return function (value, wordwise, max, tail) { + if (!value) return '' - max = parseInt(max, 10) - if (!max) return value - if (value.length <= max) return value + max = parseInt(max, 10) + if (!max) return value + if (value.length <= max) return value - value = value.substr(0, max) - if (wordwise) { - var lastspace = value.lastIndexOf(' ') - if (lastspace != -1) { - value = value.substr(0, lastspace) + value = value.substr(0, max) + if (wordwise) { + var lastspace = value.lastIndexOf(' ') + if (lastspace != -1) { + value = value.substr(0, lastspace) + } + } + return value + (tail || ' …') + } + }) + app.filter('dateConversionStr', function () { + return function (date) { + var year = date.getFullYear() //获取完整的年份(4位,1970-????) + var month = date.getMonth() + 1 //获取当前月份(0-11,0代表1月) + var day = date.getDate() //获取当前日(1-31) + if (month < 10) { + month = '0' + month + } + if (day < 10) { + day = '0' + day + } + var dateString = year + '-' + month + '-' + day + return dateString } - } - return value + (tail || ' …') - } - }) - app.filter('dateConversionStr', function () { - return function (date) { - var year = date.getFullYear() //获取完整的年份(4位,1970-????) - var month = date.getMonth() + 1 //获取当前月份(0-11,0代表1月) - var day = date.getDate() //获取当前日(1-31) - if (month < 10) { - month = '0' + month - } - if (day < 10) { - day = '0' + day - } - var dateString = year + '-' + month + '-' + day - return dateString - } - }) - return app + }) + return app }) diff --git a/src/main/ui/static/payment/partner/partner.js b/src/main/ui/static/payment/partner/partner.js index 43bf94ce6..e974da51a 100644 --- a/src/main/ui/static/payment/partner/partner.js +++ b/src/main/ui/static/payment/partner/partner.js @@ -435,6 +435,7 @@ define(['angular', 'decimal', 'uiRouter', 'ngBootSwitch', 'ngFileUpload', 'uiBoo $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode; $scope.partner.registered_state = $scope.partner.representativeInfo.state; $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person; + $scope.partner.legal_representative_id = $scope.partner.representativeInfo.legal_representative_id; $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone; $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email; $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title; diff --git a/src/main/ui/static/payment/partner/templates/add_partner.html b/src/main/ui/static/payment/partner/templates/add_partner.html index 95308a108..c74cd5998 100644 --- a/src/main/ui/static/payment/partner/templates/add_partner.html +++ b/src/main/ui/static/payment/partner/templates/add_partner.html @@ -854,6 +854,22 @@ +
+ +
+ +
+

Less + Than 50 + Characters(including symbols and spaces)

+
+
+
+
+ +
+ +
+

Required + Field

+

Less + Than 50 +

+
+
+
+
+ + +
+

+
+
diff --git a/src/main/ui/static/payment/partner/templates/client_partner_edit.html b/src/main/ui/static/payment/partner/templates/client_partner_edit.html index f0e866f92..d73ee76d3 100644 --- a/src/main/ui/static/payment/partner/templates/client_partner_edit.html +++ b/src/main/ui/static/payment/partner/templates/client_partner_edit.html @@ -458,6 +458,24 @@
+
+ +
+ +
+

Required + Field

+

Less + Than 50 +

+
+
+
diff --git a/src/main/ui/static/payment/partner/templates/client_payment_info.html b/src/main/ui/static/payment/partner/templates/client_payment_info.html index 8d5234b4b..c685a9f3c 100644 --- a/src/main/ui/static/payment/partner/templates/client_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/client_payment_info.html @@ -67,7 +67,7 @@

Download Aggregate QR Board Image (聚合支付水晶立牌:支持支付宝、微信、翼支付) + target="_blank">Download Aggregate QR Board Image (聚合支付水晶立牌:支持支付宝、微信、A+)

diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index ab0ad5e8a..696f4d033 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -8,7 +8,7 @@

Bank Account + ng-if="!bankCtrl.edit && (('11'|withRole)||((!partner.approve_result||partner.approve_result>4) && ('111'|withRole)))">

@@ -17,16 +17,16 @@
-

{{surcharge.balance|currency:'AUD'}}

+

{{surcharge.balance | currency:'AUD'}}

+ switch-change="allowSurchargeCredit(partner.allow_surcharge_credit)">
@@ -35,11 +35,11 @@

balance + ng-click="switchSurchargeMode()"> distributed + ng-click="switchSurchargeMode()">

启用到收支分离(distributed)模式,将使消费者支付手续费模式失效
@@ -52,41 +52,41 @@

+ switch-change="taxInSurcharge(partner.tax_in_surcharge)">
+ switch-change="customerTaxFree(partner.customer_tax_free)">
+ switch-change="skipClearing(partner.skip_clearing)">
+ switch-change="switchPreSettle(partner.enable_presettle)">

- AU${{partner.min_settle||'Not Configure'}} + AU${{partner.min_settle || 'Not Configure'}}

AU$
+ min="0">
+ ng-if="$root.complianceCheck.bankAccount"> + required ng-readonly="!bankCtrl.edit">
-
-

Rates - -

+
+

China Wallets Rate

+ + Add Rate +
- - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + +
Rate NameRate ValueDomestic Rate ValueInternational Rate ValueTransaction FeeActive TimeExpire Time - Clean Days - Update TimeOperatorRemarkOperation
Rate NameRate ValueTransaction FeeActive TimeExpire Time + Clean Days + Update TimeOperatorRemarkOperation
- - T+{{rate.clean_days}} - - - - (Promotional Offer) - - -
+ T+{{rate.clean_days}} + + +
-
+

AlipayPlus Rates - + ng-if="partner.rate_editable && (('11'|withRole)||((!partner.approve_result||partner.approve_result>4||(partner.approve_result==4&&partner.open_status==3)) && ('111'|withRole)))" + ng-click="newAlipayPlusRate()"> +

- - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + - + +
Rate NameRate ValueTransaction FeeActive TimeExpire TimeClean DaysUpdate TimeOperatorRemarkOperation
Rate NameRate ValueTransaction FeeActive TimeExpire TimeClean DaysUpdate TimeOperatorRemarkOperation
T+{{rate.clean_days}} - - + T+{{rate.clean_days}} + + (Promotional Offer) + ng-href="/sys/partners/{{partner.client_moniker}}/export/aggregate/card_promotion_agree_pdf?rateid={{rate.client_rate_id}}"> -
@@ -404,4 +383,132 @@
+ + +
+

Card Payment Rate

+ + Add Card Payment Rates + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rate NameDomestic Rate ValueInternational Rate ValueTransaction FeeActive TimeExpire TimeClean DaysUpdate TimeOperatorRemarkOperation
+ T+{{rate.clean_days}} + + + (Promotional Offer) + + +
+
+
+
+
+ + +
+

Alipay+ Rate

+ + Add A+(APS) Rate + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rate NameInterchange FeeService FeeActive TimeExpire TimeUpdate TimeOperatorRemarkOperation
+ +
+
+
+
+
\ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_detail.html b/src/main/ui/static/payment/partner/templates/partner_detail.html index d6aa58510..cd9d79c4c 100644 --- a/src/main/ui/static/payment/partner/templates/partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/partner_detail.html @@ -1025,6 +1025,14 @@ ng-bind="partner.representativeInfo.representative_person ">

+
+ + +
+

+
+
diff --git a/src/main/ui/static/payment/partner/templates/partner_edit.html b/src/main/ui/static/payment/partner/templates/partner_edit.html index 6804d3cf0..8a1f1e890 100644 --- a/src/main/ui/static/payment/partner/templates/partner_edit.html +++ b/src/main/ui/static/payment/partner/templates/partner_edit.html @@ -795,6 +795,26 @@
+
+ +
+
+ +
+
+ +

Less + Than 50 +

+
+
+
diff --git a/src/main/ui/static/payment/partner/templates/partner_new_alipay_aps_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_alipay_aps_rate.html new file mode 100644 index 000000000..0e38955b5 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/partner_new_alipay_aps_rate.html @@ -0,0 +1,152 @@ + + + diff --git a/src/main/ui/static/payment/partner/templates/partner_new_card_payment_rate.html b/src/main/ui/static/payment/partner/templates/partner_new_card_payment_rate.html index 18f5807c8..65d081b3a 100644 --- a/src/main/ui/static/payment/partner/templates/partner_new_card_payment_rate.html +++ b/src/main/ui/static/payment/partner/templates/partner_new_card_payment_rate.html @@ -1,6 +1,6 @@
@@ -376,6 +371,8 @@ ng-if="trade.channel=='Alipay'" /> + Max Order Amount

- {{(paymentInfo.max_order_amount|currency:'AUD ')||'Not Configure'}} + {{(paymentInfo.max_order_amount | currency:'AUD ') || 'Not Configure'}}

AUD
+ title="Max Order Amount">
@@ -140,19 +140,19 @@

- {{paymentInfo.customer_surcharge_rate||'Not Configure'}} + {{paymentInfo.customer_surcharge_rate || 'Not Configure'}}

+ title="Customer Surcharge Rate" max="{{paymentInfo.max_customer_surcharge_rate}}" + min="{{paymentInfo.min_customer_surcharge_rate}}" name="customer_surcharge_rate">
%
@@ -163,7 +163,7 @@
@@ -178,16 +178,16 @@

- {{paymentInfo.order_expiry_config||'Not Configure'}} + {{paymentInfo.order_expiry_config || 'Not Configure'}}

+ title="Prevent not enough refund">
@@ -218,21 +218,21 @@
+ ng-change="toggleChannel('alipay')">
+ ng-change="toggleChannel('wechat')">
+ ng-change="toggleChannel('cb_bankpay')">
@@ -240,21 +240,28 @@
+ ng-change="toggleChannel('rpaypmt_card')">
+ ng-change="toggleChannel('rpaypmt_dd')">
+ + + + + + +
- +
- +
@@ -274,7 +281,7 @@
+ switch-change="updateClientQRCodePaySurCharge()">
@@ -290,13 +297,13 @@ Pre Authorization + uib-tooltip="Pre Authorize means this bill will not be settled until completion">

@@ -327,7 +334,7 @@

Download Aggregate QR Board Image + download> Download Aggregate QR Board Image (聚合支付水晶立牌:支持支付宝、微信、翼支付)

@@ -344,28 +351,28 @@
+ switch-change="toggleGateway()">
+ switch-change="toggleGatewayUpgrade()">
+ switch-change="toggleGatewayAlipayOnline()">
+ switch-change="updateClientApiSurCharge()">

If client have already attached surcharge in their own system, ignore this choice.
@@ -380,8 +387,8 @@

+ data-on-text="Alipay+" data-off-text="Alipay" data-off-color="primary" + ng-change="setAlipayChannel()">
@@ -453,29 +460,29 @@
+ ng-change="toggleCBBankPayLink()">   {{paymentInfo.cb_bankpay_url}} + ng-if="paymentInfo.enable_cb_bankpay_link">{{paymentInfo.cb_bankpay_url}} + style="cursor: pointer" ng-click="copyCBBankPayLink()"> + value={{paymentInfo.cb_bankpay_url}} readonly>
+ ng-change="updateClientCBBankPaySurCharge()">
@@ -483,7 +490,7 @@
- +
  仅支持微信客户端扫描
@@ -498,7 +505,7 @@
@@ -507,9 +514,9 @@
+ src="/static/images/cbbank_payment_page_v1.jpg"> + src="/static/images/cbbank_payment_page_v2.jpg">
@@ -527,14 +534,36 @@
+ switch-change="switchInternationalCard()">
+ switch-change="switchThreeDS()"> +
+
+
+
+
+ + +
+
AlipayCN Channel Configuration
+
+
+
+ +
+ +
@@ -550,14 +579,14 @@
+ switch-change="toggleOffline()">
+ switch-change="updateClientRetailPaySurCharge()">
@@ -565,14 +594,14 @@
-
Refund
+
Refund
+ switch-change="toggleRefund()">
@@ -580,7 +609,7 @@
+ switch-change="togglePreRefund()">
@@ -589,13 +618,13 @@

- {{paymentInfo.refund_credit_line||'Not Configure'}} + {{paymentInfo.refund_credit_line || 'Not Configure'}}

+ ng-model="paymentInfo.refund_credit_line">
+ switch-change="toggleRequireRemark()">
@@ -668,7 +697,7 @@
+ ng-change="extChangeParam(param.name,param.value)">
@@ -679,7 +708,7 @@

+ title="Prevent not enough refund">
+ +
+
+
+
+
+ No Data +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+ +
+ Alipay+(Online) : + none +
+ +
+
+ + + +
+
+
+
+
+ No Data +
+
+
+
+
+
+
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 2b284e8f3..81daa870e 100644 --- a/src/main/ui/static/payment/tradelog/templates/balance_report.html +++ b/src/main/ui/static/payment/tradelog/templates/balance_report.html @@ -154,6 +154,14 @@ ng-class="{'bg-primary':params.channel=='ALIPAYONLINE'}" ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline | + Alipay+ + | + Alipay+(Online) + | RPay + | + {{trade.order_id2}} diff --git a/src/main/ui/static/payment/tradelog/templates/incremental_trade_logs.html b/src/main/ui/static/payment/tradelog/templates/incremental_trade_logs.html index b57f0757e..dadf1d892 100644 --- a/src/main/ui/static/payment/tradelog/templates/incremental_trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/incremental_trade_logs.html @@ -155,12 +155,19 @@ ng-class="{'bg-primary':params.channel=='ALIPAYONLINE'}" ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline | + Alipay+ + | + Alipay+(Online) + | RPay + | Card Payment | - Direct Debit + ng-click="params.channel='RPAYPMT_CARD';loadTradeLogs(1)">Card Payment +

@@ -370,6 +377,8 @@ uib-tooltip="Card Payment" ng-if="trade.channel=='rpaypmt_card'"/> + {{trade.order_id}} diff --git a/src/main/ui/static/payment/tradelog/templates/partner_incremental_trade_logs.html b/src/main/ui/static/payment/tradelog/templates/partner_incremental_trade_logs.html index 4a78f5a94..76510a722 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_incremental_trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_incremental_trade_logs.html @@ -135,22 +135,17 @@ ng-click="params.channel='ALIPAY';loadTradeLogs(1)">Alipay | AlipayOnline | - BestPay | - JD Pay | - HF Pay | + Alipay+ | + Alipay+(Online) | + RPay+ | - Yeepay | - LakalaPay | + Card Payment | - Direct Debit + ng-click="params.channel='RPAYPMT_CARD';loadTradeLogs(1)">Card Payment +

@@ -347,6 +342,8 @@ + {{trade.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 1e3747d0f..8319319ee 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 @@ -214,8 +214,11 @@ ng-class="{'bg-primary':params.channel=='ALIPAYONLINE'}" ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline | - Alipay+ + Alipay+ + | + Alipay+(Online) | RPay+ | @@ -731,6 +734,9 @@ + {{trade.order_id}}AlipayOnline | - Alipay+ + Alipay+ + | + Alipay+(Online) | - BestPay | - JD Pay | - HF Pay | RPay + | - Yeepay | - LakalaPay - | Card - Payment | - Direct - Debit + Payment +

@@ -502,6 +492,9 @@ ng-if="trade.channel=='rpaypmt_card'" /> + diff --git a/src/main/ui/static/payment/validation/order-validation.js b/src/main/ui/static/payment/validation/order-validation.js index fc901dba7..683d30057 100644 --- a/src/main/ui/static/payment/validation/order-validation.js +++ b/src/main/ui/static/payment/validation/order-validation.js @@ -164,6 +164,25 @@ define(['angular', 'uiRouter'], function () { $scope.date = angular.copy($stateParams.date) $scope.date = $scope.date.substr(0, 4) + '-' + $scope.date.substr(4, 2) + '-' + $scope.date.substr(6) $scope.warningLevel = JSON.parse(sessionStorage.getItem('warningLevel')) + $scope.validItAgain = function () { + commonDialog + .confirm({ + title: 'Confirm reconciliations', + contentHtml: $sce.trustAsHtml('Agree to send push message'), + }) + .then(function () { + var isSendMessage = document.getElementById('isSendMessage').checked + $http + .get('/sys/financial/order_validations/' + $stateParams.date, { + params: { + use_cache: false, + is_send_message: isSendMessage, + }, + timeout: 300000, + }) + .then($scope.startValid()) + }) + } // 加载渠道信息 $scope.startValid = function () { $http diff --git a/src/main/ui/static/payment/validation/templates/valid_new.html b/src/main/ui/static/payment/validation/templates/valid_new.html index 38246adf3..b41c07c8d 100644 --- a/src/main/ui/static/payment/validation/templates/valid_new.html +++ b/src/main/ui/static/payment/validation/templates/valid_new.html @@ -10,6 +10,7 @@ +
diff --git a/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js index 4afadc43b..1b4a99494 100644 --- a/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js +++ b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js @@ -37,6 +37,14 @@ $(document).ready(function () { location.href = window.redirect; return; } + if (pay.web_url) { + location.href = pay.web_url; + return; + } + if (pay.mweb_url) { + location.href = pay.mweb_url; + return; + } if (window.AlipayJSBridge) { callPayment(); } else { diff --git a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js index dddac6e4e..d2e791774 100644 --- a/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js +++ b/src/main/ui/static/templates/alipay/v1/gateway_jsapi.js @@ -57,9 +57,9 @@ $(document).ready(function () { } else { // 如果没有注入则监听注入的事件 document.addEventListener('AlipayJSBridgeReady', function () { - + callPayment(pay.trade_no); }); - callPayment(pay.trade_no); + } }, diff --git a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js index 6e1145907..274404c2f 100644 --- a/src/main/ui/static/templates/alipay/v1/retail_jsapi.js +++ b/src/main/ui/static/templates/alipay/v1/retail_jsapi.js @@ -4,18 +4,21 @@ $(document).ready(function () { 'use strict'; decode(); + function decode() { var redirect = window.redirect; - while(redirect.indexOf('://')<0){ + while (redirect.indexOf('://') < 0) { redirect = decodeURIComponent(redirect); - if(redirect==window.redirect){ + if (redirect == window.redirect) { break; } window.redirect = redirect; } } + var dataCache = {paying: false}; $('#key_P').bind('touchstart', startPay); + function startPay() { $('#wdiv').show(); if (dataCache.paying) { @@ -32,6 +35,9 @@ $(document).ready(function () { location.href = window.redirect; return; } + if (window.client_moniker == 'PINE') { + alert(JSON.stringify(pay)) + } if (pay.web_from) { $('#alipay_plus').html(pay.web_from) startCheckOrder(window.order_id, window.redirect); @@ -94,7 +100,7 @@ $(document).ready(function () { setTimeout(checkOrderStd, 500); } }, - error:function (){ + error: function () { setTimeout(checkOrderStd, 500); } }) diff --git a/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js b/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js new file mode 100644 index 000000000..c88db1939 --- /dev/null +++ b/src/main/ui/static/templates/alipayaps/v1/gateway_jsapi.js @@ -0,0 +1,73 @@ +$(document).ready(function (){ + + decode(); + + function decode() { + if (window.client_moniker == 'PINE') { + alert('debug:origin redirect:' + window.redirect); + } + let redirect = window.redirect; + if (window.redirect !=null) { + while (redirect.indexOf('://') < 0) { + redirect = decodeURIComponent(redirect); + if (redirect == window.redirect) { + break; + } + window.redirect = redirect; + } + } + + } + + let dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: './preorder', + method: 'GET', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + startCheckOrder(window.client_moniker, window.merchant_orderid); + return; + } + if (pay.mweb_url){ + location.href = pay.mweb_url + } + + }, + error: function (jqXhr) { + alert(jqXhr.responseJSON.message); + $('#wdiv').hide(); + dataCache.paying = false; + } + }) + + + } + + function startCheckOrder(clientMoniker, merchantOrderId) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/clients/' + clientMoniker + '/orders/' + merchantOrderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true&time=' + res.time + '&nonce_str=' + res.nonce_str + '&sign=' + res.sign; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } +}) \ No newline at end of file diff --git a/src/main/ui/static/templates/alipayaps/v1/payment.js b/src/main/ui/static/templates/alipayaps/v1/payment.js new file mode 100644 index 000000000..0a49f9143 --- /dev/null +++ b/src/main/ui/static/templates/alipayaps/v1/payment.js @@ -0,0 +1,444 @@ +/** + * Created by yixian on 2017-05-08 + */ +$(function () { + 'use strict'; + // document.querySelector('body').addEventListener('touchmove', function (e) { + // if (!document.querySelector('.coupons').contains(e.target)) { + // e.preventDefault(); + // } + // }) + var dataCache = {price: '0', coupons: [], coupon_groups: {}}; + var exchangeRate = parseFloat(window.exchange_rate); + + if (window.AlipayJSBridge) { + AlipayJSBridge.call('hideOptionMenu'); + } else { + document.addEventListener('AlipayJSBridgeReady', function () { + AlipayJSBridge.call('hideOptionMenu'); + }, false); + } + dataCache.paying = false; + var ctrl = {}; + + $('.ff.key').bind('touchstart', function () { + if (dataCache.paying) { + return; + } + var char = $(this).attr('data-char'); + appendChar(char); + }); + + $('.coupons .use-check').click(function () { + if ($(this).hasClass('disabled')) { + return; + } + var couponId = $(this).attr('data-coupon-id'); + var couponGroup = $(this).attr('data-coupon-group'); + if (couponGroup) { + var prevCouponId = dataCache.coupon_groups[couponGroup]; + if (prevCouponId) { + var prevIdx = dataCache.coupons.indexOf(prevCouponId); + if (prevIdx >= 0) { + dataCache.coupons.splice(prevIdx, 1); + } + if (prevCouponId != couponId) { + $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked'); + dataCache.coupon_groups[couponGroup] = couponId; + } else { + dataCache.coupon_groups[couponGroup] = null; + } + } else { + dataCache.coupon_groups[couponGroup] = couponId; + } + + } + + if ($(this).is('.checked')) { + $(this).removeClass('checked').addClass('unchecked'); + } else { + $(this).removeClass('unchecked').addClass('checked'); + } + var checked = $(this).is('.checked'); + if (checked) { + dataCache.coupons.push(couponId); + updatePrice(); + } else { + var idx = dataCache.coupons.indexOf(couponId); + dataCache.coupons.splice(idx, 1); + updatePrice(); + } + }); + + $('#key_B').bind('touchstart', function () { + backspace(); + }); + + function updatePoundage(price) { + if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) { + if (window.use_customised_rate) { + var rate = new Decimal(100).plus(window.rateValue).div(100); + var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price); + } else { + var rateRemain = new Decimal(100).sub(window.rateValue).div(100); + poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price); + } + dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP); + return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP); + } + return price; + } + + function updatePrice() { + $('#audVal').html(dataCache.price); + var realPrice = dataCache.price; + $('#audValReal').html(realPrice); + var surchargeData = calculateSurcharge(realPrice); + + var price = surchargeData.newPrice || realPrice; + var priceBeforeDiscount = price; + dataCache.discounts = []; + dataCache.tax = surchargeData.tax; + dataCache.surcharge = surchargeData.surcharge; + + $(window.coupons).each(function () { + price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons); + }); + dataCache.customSurcharge = new Decimal(price).sub(realPrice).toFixed(2, Decimal.ROUND_HALF_UP); + dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR); + var rate = 'CNY' == window.currency ? 1 : exchangeRate; + var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_HALF_UP); + $('#cnyVal').html(cnyVal); + dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount; + } + + function updatePoundageStatus() { + $(window.coupons).each(function () { + var coupon = this; + var couponId = coupon.couponId(); + if (coupon.isEnable(dataCache.currencyPrice || 0)) { + $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled'); + } else { + var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled'); + var couponGroup = dom.attr('data-coupon-group'); + if (couponGroup) { + if (dataCache.coupon_groups[couponGroup] == couponId) { + dataCache.coupon_groups[couponGroup] = null; + } + } + var idx = dataCache.coupons.indexOf(couponId); + if (idx >= 0) { + dataCache.coupons.splice(idx, 1); + } + dom.removeClass('checked').addClass('unchecked'); + } + }) + } + + updatePoundageStatus(); + + function backspace() { + dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1); + if (dataCache.price.length == 0) { + dataCache.price = '0'; + } + updatePrice(); + updatePoundageStatus(); + } + + function appendChar(char) { + var pointLocation = dataCache.price.indexOf('.'); + if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) { + if (pointLocation >= 0 && char == '.') { + return; + } + if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) { + return; + } + if (dataCache.price == '0' && char != '.') { + dataCache.price = ''; + } + dataCache.price += char; + updatePrice(); + updatePoundageStatus(); + } + } + + $('#coupon-box-toggle').click(function () { + $('.coupons-container').addClass('show'); + }); + $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () { + $(this).parents('.coupons-container').removeClass('show'); + }); + + + $('.remark-btn').click(function () { + var cfg = { + title: '备注 Remark', + template: '', + initialize: function (dialog) { + $('').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog)); + }, + confirm: function (dialog, chosen) { + if (chosen) { + var remark = $('textarea[name="remark"]', dialog).val(); + if (remark) { + $('#remark-box').text('备注:' + remark).show() + } else { + $('#remark-box').text('').hide(); + } + dataCache.remark = remark; + } + + } + }; + showWeuiDialog(cfg); + }); + + $('.paydetail').click(function () { + var config = { + title: 'Payment Detail', + template: '', + initialize: function (dialog) { + var bd = $('.weui_dialog_bd', dialog); + var currencySymbol = window.currency == 'AUD' ? '$' : '¥'; + $('

').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd); + if (parseFloat(dataCache.customSurcharge) > 0) { + $('

').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.customSurcharge).appendTo(bd); + $('

').addClass('warning-sm').html('温馨提示:商户将向您收取本次消费手续费' + window.rateValue + '%').appendTo(bd); + } + $(dataCache.discounts).each(function () { + $('

').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); + }); + $('

').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd); + } + }; + showWeuiDialog(config); + }); + + $('#key_P').click(function () { + if (window.requireRemark) { + if (!dataCache.remark) { + var config = { + title: '请先输入备注', + template: '' + }; + showWeuiDialog(config); + } + + } + }); + + $('#key_P').bind('touchstart', function () { + if (window.requireRemark) { + if (!dataCache.remark) { + return; + } + } + $('#key_P').addClass('hidden'); + $('#key_Loading').removeClass('hidden'); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + var data = {price: dataCache.price + '', original_number: true, currency: window.currency}; + if (dataCache.remark) { + data.description = dataCache.remark; + } + if (window.extensions.indexOf('preauthorize') >= 0) { + data.preauthorize = true; + } + if (window.extensions.indexOf('qrcodemode') >= 0) { + data.qrmode = true; + } + if (window.extensions.indexOf('customerrate') >= 0) { + data.customerrate = true; + } + data.coupons = dataCache.coupons; + data.qrcodeVersion = window.qrcodeVersion; + + $.ajax({ + url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders', + method: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; + return; + } + if (pay.mweb_url){ + location.href = pay.mweb_url; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'); + } else if (res.resultCode == '6001') { + //do nothing + } else { + if (res.memo) { + weuiAlert(res.memo); + } + } + $('#key_P').removeClass('hidden'); + $('#key_Loading').addClass('hidden'); + }) + } catch (err) { + weuiAlert(err) + } + } + }, + error: function (jqXhr) { + weuiAlert(jqXhr.responseJSON.message); + $('#key_P').removeClass('hidden'); + $('#key_Loading').addClass('hidden'); + dataCache.paying = false; + } + }) + }); + + function startCheckOrder(orderId, url) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = url; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } + + function weuiAlert(msg) { + var config = { + template: msg + }; + showWeuiDialog(config); + } + + function showWeuiDialog(config) { + if (config.templateUrl) { + $.ajax({ + url: config.templateUrl, + dataType: 'html', + success: function (template) { + buildDialog(template); + } + }); + } else { + buildDialog(config.template); + } + + + function buildDialog(template) { + var defaultConfig = {backdrop: true}; + config = $.extend({}, defaultConfig, config); + var dialog = $("
", {class: 'weui_dialog_confirm'}); + var mask = $('
', {class: 'weui_mask'}).appendTo(dialog); + if (config.backdrop) { + mask.click(function () { + dialog.remove(); + if ($.isFunction(config.dismiss)) { + config.dismiss(); + } + }) + } + var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog); + if (config.title) { + $('
', {class: 'weui_dialog_hd'}).append($('', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox); + } + var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox); + if (template) { + dialogBody.append(template); + } + if ($.isFunction(config.initialize)) { + config.initialize(dialog); + } + var ft = $('
').appendTo(dialogBox); + if(window.paypad_version !== 'v3'){ + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #108ee9;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #108ee9;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + }else{ + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + } + dialog.appendTo($('body')); + } + + } +}); diff --git a/src/main/ui/static/templates/alipayaps/v4/payment.js b/src/main/ui/static/templates/alipayaps/v4/payment.js new file mode 100644 index 000000000..be2d64c9a --- /dev/null +++ b/src/main/ui/static/templates/alipayaps/v4/payment.js @@ -0,0 +1,488 @@ +/** + * Created by yixian on 2017-05-08 + */ +var num = function(obj){ + obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符 + obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字 + obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的 + obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); + obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数 +}; + +$(function () { + 'use strict'; + // document.querySelector('body').addEventListener('touchmove', function(e) { + // if (!document.querySelector('.coupons').contains(e.target)) { + // e.preventDefault(); + // } + // }); + var dataCache = {price: '0', coupons: [], coupon_groups: {}}; + var exchangeRate = parseFloat(window.exchange_rate); + + if (window.AlipayJSBridge) { + AlipayJSBridge.call('hideOptionMenu'); + } else { + document.addEventListener('AlipayJSBridgeReady', function () { + AlipayJSBridge.call('hideOptionMenu'); + }, false); + } + dataCache.paying = false; + var ctrl = {}; + + $('.ff.key').bind('touchstart', function () { + if (dataCache.paying) { + return; + } + var char = $(this).attr('data-char'); + appendChar(char); + }); + + $('#audVal').bind('input porpertychange', function () { + if (dataCache.paying) { + return; + } + var char = $(this).val(); + if (parseFloat(char) >= 100000) { + char = char.slice(0, char.length - 1); + $(this).val(char); + return; + } + appendChar(char); + }); + + $('.coupons .use-check').click(function () { + if ($(this).hasClass('disabled')) { + return; + } + var couponId = $(this).attr('data-coupon-id'); + var couponGroup = $(this).attr('data-coupon-group'); + if (couponGroup) { + var prevCouponId = dataCache.coupon_groups[couponGroup]; + if (prevCouponId) { + var prevIdx = dataCache.coupons.indexOf(prevCouponId); + if (prevIdx >= 0) { + dataCache.coupons.splice(prevIdx, 1); + } + if (prevCouponId != couponId) { + $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked'); + dataCache.coupon_groups[couponGroup] = couponId; + } else { + dataCache.coupon_groups[couponGroup] = null; + } + } else { + dataCache.coupon_groups[couponGroup] = couponId; + } + + } + + if ($(this).is('.checked')) { + $(this).removeClass('checked').addClass('unchecked'); + } else { + $(this).removeClass('unchecked').addClass('checked'); + } + var checked = $(this).is('.checked'); + if (checked) { + dataCache.coupons.push(couponId); + updatePrice(); + } else { + var idx = dataCache.coupons.indexOf(couponId); + dataCache.coupons.splice(idx, 1); + updatePrice(); + } + }); + $('.cb_bankpay').click(function () { + $.ajax({ + url: '/sys/partners/' + window.client_moniker + '/jump/link', + method: 'GET', + success: function (res) { + location.href = res; + }, + error: function (resp) { + var config = { + template: resp + }; + showWeuiDialog(config); + } + }) + }); + $('#key_B').bind('touchstart', function () { + backspace(); + }); + + function updatePoundage(price) { + if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) { + if (window.use_customised_rate) { + var rate = new Decimal(100).plus(window.rateValue).div(100); + var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price); + } else { + var rateRemain = new Decimal(100).sub(window.rateValue).div(100); + poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price); + } + dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP); + return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP); + } + return price; + } + + function updatePrice() { + $('#audVal').html(dataCache.price); + var realPrice = dataCache.price; + $('#audValReal').html(realPrice); + var surchargeData = calculateSurcharge(realPrice); + + var price = surchargeData.newPrice || realPrice; + var priceBeforeDiscount = price; + dataCache.discounts = []; + dataCache.tax = surchargeData.tax; + dataCache.surcharge = surchargeData.surcharge; + $(window.coupons).each(function () { + price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons); + }); + dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR); + var rate = 'CNY' == window.currency ? 1 : exchangeRate; + var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_FLOOR); + dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount; + $('#cnyVal').html(cnyVal) + } + + function backspace() { + dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1); + if (dataCache.price.length == 0) { + dataCache.price = '0'; + } + updatePrice(); + updatePoundageStatus(); + } + + function appendChar(char) { + if (char == "") { + char = '0'; + } + var check = /[^\d.]/g; + if (check.test(char)) { + return; + } + var tmpChar = (char.split('.')).length-1; + if (tmpChar > 1) { + return; + } + var pointLocation = dataCache.price.indexOf('.'); + if (char == '.' || char.length > 8) { + return; + } + if (pointLocation >= 0 && pointLocation <= char.length - 4) { + return; + } + if (dataCache.price == '0' && char != '.') { + dataCache.price = ''; + } + dataCache.price = char; + updatePrice(); + updatePoundageStatus(); + } + + function updatePoundageStatus() { + $(window.coupons).each(function () { + var coupon = this; + var couponId = coupon.couponId(); + if (coupon.isEnable(dataCache.currencyPrice || 0)) { + $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled'); + } else { + var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled'); + var couponGroup = dom.attr('data-coupon-group'); + if (couponGroup) { + if (dataCache.coupon_groups[couponGroup] == couponId) { + dataCache.coupon_groups[couponGroup] = null; + } + } + var idx = dataCache.coupons.indexOf(couponId); + if (idx >= 0) { + dataCache.coupons.splice(idx, 1); + } + dom.removeClass('checked').addClass('unchecked'); + } + }) + } + + updatePoundageStatus(); + + $('#coupon-box-toggle').click(function () { + $('.coupons-container').addClass('show'); + }); + $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () { + $(this).parents('.coupons-container').removeClass('show'); + }); + + + $('.remark-btn').click(function () { + var cfg = { + title: '备注 Remark', + template: '', + initialize: function (dialog) { + $('').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog)); + }, + confirm: function (dialog, chosen) { + if (chosen) { + var remark = $('textarea[name="remark"]', dialog).val(); + if (remark) { + $('#remark-box').text('备注:' + remark).show() + } else { + $('#remark-box').text('').hide(); + } + dataCache.remark = remark; + } + + } + }; + showWeuiDialog(cfg); + }); + + $('.paydetail').click(function () { + var config = { + title: 'Payment Detail', + template: '', + initialize: function (dialog) { + var bd = $('.weui_dialog_bd', dialog); + var currencySymbol = window.currency == 'CNY' ? '¥' : '$'; + $('

').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd); + if (parseFloat(dataCache.surcharge) > 0) { + $('

').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd); + } + if (parseFloat(dataCache.tax) > 0) { + $('

').html('GST(10%):' + currencySymbol + dataCache.tax).appendTo(bd); + } + $(dataCache.discounts).each(function () { + $('

').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); + }); + $('

').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd); + } + }; + showWeuiDialog(config); + }); + + $('#key_P').click(function () { + dataCache.remark = $('.remark-textarea-new').val(); + if (window.requireRemark) { + if (!dataCache.remark) { + var config = { + title: '请先输入备注', + template: '' + }; + showWeuiDialog(config); + } + + } + }); + + $('#key_P').bind('touchstart', function () { + dataCache.remark = $('.remark-textarea-new').val(); + if (window.requireRemark) { + if (!dataCache.remark) { + return; + } + } + $('#key_P_div').addClass('hidden'); + $('#key_Loading_div').removeClass('hidden'); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + var data = {price: dataCache.price + '', currency: window.currency}; + if (dataCache.remark) { + data.description = dataCache.remark; + } + if (window.extensions.indexOf('preauthorize') >= 0) { + data.preauthorize = true; + } + if (window.extensions.indexOf('qrcodemode') >= 0) { + data.qrmode = true; + } + if (window.extensions.indexOf('customerrate') >= 0) { + data.customerrate = true; + } + data.coupons = dataCache.coupons; + data.qrcodeVersion = window.qrcodeVersion; + $.ajax({ + url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders', + method: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; + return; + } + if (pay.mweb_url){ + location.href = pay.mweb_url; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'); + } else if (res.resultCode == '6001') { + //do nothing + } else { + if (res.memo) { + weuiAlert(res.memo); + } + } + $('#key_P_div').removeClass('hidden'); + $('#key_Loading_div').addClass('hidden'); + }) + } catch (err) { + weuiAlert(err) + } + } + }, + error: function (jqXhr) { + weuiAlert(jqXhr.responseJSON.message); + $('#key_P_div').removeClass('hidden'); + $('#key_Loading_div').addClass('hidden'); + dataCache.paying = false; + } + }) + }); + + function startCheckOrder(orderId, url) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = url; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } + + function weuiAlert(msg) { + var config = { + template: msg + }; + showWeuiDialog(config); + } + + function showWeuiDialog(config) { + if (config.templateUrl) { + $.ajax({ + url: config.templateUrl, + dataType: 'html', + success: function (template) { + buildDialog(template); + } + }); + } else { + buildDialog(config.template); + } + + function buildDialog(template) { + var defaultConfig = {backdrop: true}; + config = $.extend({}, defaultConfig, config); + var dialog = $("
", {class: 'weui_dialog_confirm'}); + var mask = $('
', {class: 'weui_mask'}).appendTo(dialog); + if (config.backdrop) { + mask.click(function () { + dialog.remove(); + if ($.isFunction(config.dismiss)) { + config.dismiss(); + } + }) + } + var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog); + if (config.title) { + $('
', {class: 'weui_dialog_hd'}).append($('', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox); + } + var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox); + if (template) { + dialogBody.append(template); + } + if ($.isFunction(config.initialize)) { + config.initialize(dialog); + } + var ft = $('
').appendTo(dialogBox); + if(window.paypad_version !== 'v3'){ + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #0bb20c;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #0bb20c;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + } else { + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + } + dialog.appendTo($('body')); + } + + } +}); diff --git a/src/main/ui/static/templates/alipayaps/v5/payment.js b/src/main/ui/static/templates/alipayaps/v5/payment.js new file mode 100644 index 000000000..759356aff --- /dev/null +++ b/src/main/ui/static/templates/alipayaps/v5/payment.js @@ -0,0 +1,452 @@ +/** + * Created by yixian on 2017-05-08 + */ + +$(function () { + 'use strict'; + // document.querySelector('body').addEventListener('touchmove', function(e) { + // if (!document.querySelector('.coupons').contains(e.target)) { + // e.preventDefault(); + // } + // }); + var dataCache = {price: '0', coupons: [], coupon_groups: {}}; + var exchangeRate = 'CNY' == window.currency ? 1 : parseFloat(window.exchange_rate); + dataCache.paying = false; + var ctrl = {}; + + if (window.AlipayJSBridge) { + AlipayJSBridge.call('hideOptionMenu'); + } else { + document.addEventListener('AlipayJSBridgeReady', function () { + AlipayJSBridge.call('hideOptionMenu'); + }, false); + } + dataCache.paying = false; + var ctrl = {}; + + $('.ff.key').bind('touchstart', function () { + if (dataCache.paying) { + return; + } + var char = $(this).attr('data-char'); + appendChar(char); + }); + + $('.coupons .use-check').click(function () { + if ($(this).hasClass('disabled')) { + return; + } + var couponId = $(this).attr('data-coupon-id'); + var couponGroup = $(this).attr('data-coupon-group'); + if (couponGroup) { + var prevCouponId = dataCache.coupon_groups[couponGroup]; + if (prevCouponId) { + var prevIdx = dataCache.coupons.indexOf(prevCouponId); + if (prevIdx >= 0) { + dataCache.coupons.splice(prevIdx, 1); + } + if (prevCouponId != couponId) { + $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked'); + dataCache.coupon_groups[couponGroup] = couponId; + } else { + dataCache.coupon_groups[couponGroup] = null; + } + } else { + dataCache.coupon_groups[couponGroup] = couponId; + } + + } + + if ($(this).is('.checked')) { + $(this).removeClass('checked').addClass('unchecked'); + } else { + $(this).removeClass('unchecked').addClass('checked'); + } + var checked = $(this).is('.checked'); + if (checked) { + dataCache.coupons.push(couponId); + updatePrice(); + } else { + var idx = dataCache.coupons.indexOf(couponId); + dataCache.coupons.splice(idx, 1); + updatePrice(); + } + }); + $('.cb_bankpay').click(function () { + $.ajax({ + url: '/sys/partners/' + window.client_moniker + '/jump/link', + method: 'GET', + success: function (res) { + location.href = res; + }, + error: function (resp) { + var config = { + template: resp + }; + showWeuiDialog(config); + } + }) + }); + $('#key_B').bind('touchstart', function () { + backspace(); + }); + + function updatePoundage(price) { + if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) { + if (window.use_customised_rate) { + var rate = new Decimal(100).plus(window.rateValue).div(100); + var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price); + } else { + var rateRemain = new Decimal(100).sub(window.rateValue).div(100); + poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price); + } + dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP); + return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP); + } + return price; + } + + function updatePrice() { + $('#audVal').html(dataCache.price); + var realPrice = dataCache.price; + $('#audValReal').html(realPrice); + var surchargeData = calculateSurcharge(realPrice); + + var price = surchargeData.newPrice || realPrice; + var priceBeforeDiscount = price; + dataCache.discounts = []; + dataCache.tax = surchargeData.tax; + dataCache.surcharge = surchargeData.surcharge; + $(window.coupons).each(function () { + price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons); + }); + dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR); + var rate = 'CNY' == window.currency ? 1 : exchangeRate; + var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_FLOOR); + dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount; + $('#cnyVal').html(cnyVal) + } + + function backspace() { + dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1); + if (dataCache.price.length == 0) { + dataCache.price = '0'; + } + updatePrice(); + updatePoundageStatus(); + } + + function appendChar(char) { + var pointLocation = dataCache.price.indexOf('.'); + if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) { + if (pointLocation >= 0 && char == '.') { + return; + } + if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) { + return; + } + if (dataCache.price == '0' && char != '.') { + dataCache.price = ''; + } + dataCache.price += char; + updatePrice(); + updatePoundageStatus(); + } + } + + function updatePoundageStatus() { + $(window.coupons).each(function () { + var coupon = this; + var couponId = coupon.couponId(); + if (coupon.isEnable(dataCache.currencyPrice || 0)) { + $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled'); + } else { + var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled'); + var couponGroup = dom.attr('data-coupon-group'); + if (couponGroup) { + if (dataCache.coupon_groups[couponGroup] == couponId) { + dataCache.coupon_groups[couponGroup] = null; + } + } + var idx = dataCache.coupons.indexOf(couponId); + if (idx >= 0) { + dataCache.coupons.splice(idx, 1); + } + dom.removeClass('checked').addClass('unchecked'); + } + }) + } + + updatePoundageStatus(); + + $('#coupon-box-toggle').click(function () { + $('.coupons-container').addClass('show'); + }); + $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () { + $(this).parents('.coupons-container').removeClass('show'); + }); + + $('.paydetail').click(function () { + var config = { + title: 'Payment Detail', + template: '', + initialize: function (dialog) { + var bd = $('.weui_dialog_bd', dialog); + var currencySymbol = window.currency == 'CNY' ? '¥' : '$'; + $('

').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd); + if (parseFloat(dataCache.surcharge) > 0) { + $('

').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd); + } + if (parseFloat(dataCache.tax) > 0) { + $('

').html('GST(10%):' + currencySymbol + dataCache.tax).appendTo(bd); + } + $(dataCache.discounts).each(function () { + $('

').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); + }); + $('

').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd); + } + }; + showWeuiDialog(config); + }); + + $('#key_P').click(function () { + if (window.requireRemark) { + if (!dataCache.remark) { + var config = { + title: '请先输入备注', + template: '' + }; + showWeuiDialog(config); + } + + } + }); + + function addBlurListen() { + $('.remark-input').on('blur', function (event) { + dataCache.remark = $('textarea[name="remark"]').val(); + }); + } + addBlurListen(); + + $('#audVal').bind('DOMNodeInserted', function(e) { + if(dataCache.price==0){ + $('.pay_button').css({"background-color":"#eee",}).attr('disabled',true); + $('.bank_button').css({"background-color":"#eee",}).attr('disabled',true); + }else{ + $('.pay_button').css({"background-color":"#108ee9",}).attr('disabled',false); + $('.bank_button').css({"background-color":"#FF6600",}).attr('disabled',false); + } + }); + $('#key_P').bind('touchstart', function () { + if (window.requireRemark) { + if ($('textarea[name="remark"]').val()=="") { + return; + } + } + $('#key_P').addClass('hidden'); + $('#key_Loading').removeClass('hidden'); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + var data = {price: dataCache.price + '', currency: window.currency}; + if (dataCache.remark) { + data.description = dataCache.remark; + } + if (window.extensions.indexOf('preauthorize') >= 0) { + data.preauthorize = true; + } + if (window.extensions.indexOf('qrcodemode') >= 0) { + data.qrmode = true; + } + if (window.extensions.indexOf('customerrate') >= 0) { + data.customerrate = true; + } + data.coupons = dataCache.coupons; + data.qrcodeVersion = window.qrcodeVersion; + $.ajax({ + url: '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders', + method: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; + return; + } + if (pay.mweb_url){ + location.href = pay.mweb_url; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + startCheckOrder(pay.order_id, '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'); + } else if (res.resultCode == '6001') { + //do nothing + } else { + if (res.memo) { + weuiAlert(res.memo); + } + } + $('#key_P_div').removeClass('hidden'); + $('#key_Loading_div').addClass('hidden'); + }) + } catch (err) { + weuiAlert(err) + } + } + }, + error: function (jqXhr) { + weuiAlert(jqXhr.responseJSON.message); + $('#key_P_div').removeClass('hidden'); + $('#key_Loading_div').addClass('hidden'); + dataCache.paying = false; + } + }) + }); + + function startCheckOrder(orderId, url) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = url; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } + + function weuiAlert(msg) { + var config = { + template: msg + }; + showWeuiDialog(config); + } + + function showWeuiDialog(config) { + if (config.templateUrl) { + $.ajax({ + url: config.templateUrl, + dataType: 'html', + success: function (template) { + buildDialog(template); + } + }); + } else { + buildDialog(config.template); + } + + function buildDialog(template) { + var defaultConfig = {backdrop: true}; + config = $.extend({}, defaultConfig, config); + var dialog = $("
", {class: 'weui_dialog_confirm'}); + var mask = $('
', {class: 'weui_mask'}).appendTo(dialog); + if (config.backdrop) { + mask.click(function () { + dialog.remove(); + if ($.isFunction(config.dismiss)) { + config.dismiss(); + } + }) + } + var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog); + if (config.title) { + $('
', {class: 'weui_dialog_hd'}).append($('', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox); + } + var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox); + if (template) { + dialogBody.append(template); + } + if ($.isFunction(config.initialize)) { + config.initialize(dialog); + } + var ft = $('
').appendTo(dialogBox); + if(window.paypad_version !== 'v3'){ + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #0bb20c;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #0bb20c;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + } else { + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #FF9705;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + } + dialog.appendTo($('body')); + addBlurListen(); + } + + } +}); diff --git a/src/main/ui/static/templates/billCode/js/mobile_payment.js b/src/main/ui/static/templates/billCode/js/mobile_payment.js index 7a61910a8..8c63fdec4 100644 --- a/src/main/ui/static/templates/billCode/js/mobile_payment.js +++ b/src/main/ui/static/templates/billCode/js/mobile_payment.js @@ -9,9 +9,18 @@ $(document).ready(function () { if(window.openmobilefun == 'wechat'|| window.openmobilefun == 'other'){ paymentFun = 'Wechat' - }else{ + } + else if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){ + paymentFun = 'AlipayAps' + $(".select_wechat").empty(); + $(".select_alipay_aps").append(selectPaymentHTML); + $(".select_alipay").empty(); + $(".select_bank").empty(); + } + else{ paymentFun = 'Alipay' $(".select_wechat").empty(); + $(".select_alipay_aps").empty(); $(".select_alipay").append(selectPaymentHTML); $(".select_bank").empty(); } @@ -35,6 +44,8 @@ $(document).ready(function () { paymentFun = 'Wechat' $(".select_wechat").append(selectPaymentHTML); $(".select_alipay").empty(); + $(".select_alipay_aps").empty(); + $(".select_bank").empty(); } }) @@ -42,15 +53,28 @@ $(document).ready(function () { if(paymentFun != 'Alipay'){ paymentFun = 'Alipay' $(".select_wechat").empty(); + $(".select_alipay_aps").empty(); + $(".select_alipay").append(selectPaymentHTML); $(".select_bank").empty(); } }) + $("#select_alipay_aps").click(function(){ + if(paymentFun != 'AlipayAps'){ + paymentFun = 'AlipayAps' + $(".select_wechat").empty(); + $(".select_alipay").empty(); + $(".select_alipay_aps").append(selectPaymentHTML); + $(".select_bank").empty(); + } + }) $("#select_bank").click(function(){ if(paymentFun != 'Bank'){ paymentFun = 'Bank' $(".select_wechat").empty(); $(".select_alipay").empty(); + $(".select_alipay_aps").empty(); + $(".select_bank").append(selectPaymentHTML); } }) @@ -81,6 +105,13 @@ $(document).ready(function () { redirectH5Payment(res.partner_order_id,res.client_moniker) } } + if(paymentFun == 'AlipayAps'){ + if(window.openmobilefun == 'alipayaps'){ + callPayment(res); + }else{ + redirectH5PaymentForAps(res.partner_order_id,res.client_moniker) + } + } if(paymentFun == 'Alipay'){ if(window.openmobilefun == 'alipay'){ callPayment(res); @@ -108,6 +139,9 @@ $(document).ready(function () { function redirectH5Payment(orderId,clientMoniker){ window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/pay'; } + function redirectH5PaymentForAps(orderId,clientMoniker){ + window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/alipayaps_pay'; + } function getShareLink(){ var paymentLink = '' @@ -127,6 +161,13 @@ $(document).ready(function () { paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay'; } } + if(paymentFun == 'AlipayAps'){ + if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){ + paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay_aps/mobile'; + }else{ + paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay_aps/mobile/redirectApp?priorityChannel=AlipayAps'; + } + } if(paymentFun == 'Bank'){ paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/cbbank/mobile?partner_moniker='+window.clientmoniker; } @@ -147,6 +188,14 @@ $(document).ready(function () { } } + if(paymentFun == 'AlipayAps'){ + if(window.openmobilefun == 'alipayaps'|| window.openmobilefun == 'alipayaps_cn'){ + paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/alipay_aps/share_link' + }else{ + paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay_aps/mobile/redirectApp?priorityChannel=AlipayAps'; + + } + } if(paymentFun == 'Bank'){ paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/cbbank/share_link?partner_moniker='+window.clientmoniker; } @@ -187,7 +236,11 @@ $(document).ready(function () { function callPayment(paydata) { try { if(typeof paydata.trade_no == 'undefined'){ - window.location.href = paydata.mweb_url + if(paydata.mweb_url!=null){ + window.location.href = paydata.mweb_url + }else{ + window.location.href = paydata.web_url + } }else { AlipayJSBridge.call('tradePay', { tradeNO: paydata.trade_no diff --git a/src/main/ui/static/templates/billCode/js/pc_payment.js b/src/main/ui/static/templates/billCode/js/pc_payment.js index e69cdfa9f..feda74b2f 100644 --- a/src/main/ui/static/templates/billCode/js/pc_payment.js +++ b/src/main/ui/static/templates/billCode/js/pc_payment.js @@ -19,6 +19,9 @@ $(document).ready(function () { }else if(window.clientInfo.enable_cb_bankpay){ var paymentFun = 'Bank'; showQRcode(); + }else if(window.clientInfo.enable_alipayaps){ + var paymentFun = 'AlipayAps'; + showQRcode(); } startCheckOrder(); @@ -43,6 +46,8 @@ $(document).ready(function () { $("#select_wechat").removeClass("no-select-pay-fun").addClass("select-pay-fun"); $("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun"); $("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + showQRcode(); } }) @@ -52,6 +57,18 @@ $(document).ready(function () { $("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun"); $("#select_alipay").removeClass("no-select-pay-fun").addClass("select-pay-fun"); $("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + showQRcode(); + } + }) + $("#select_alipay_aps").click(function(){ + if(paymentFun != 'AlipayAps'){ + paymentFun = 'AlipayAps' + $("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + $("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + $("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun"); + $("#select_alipay_aps").removeClass("no-select-pay-fun").addClass("select-pay-fun"); + showQRcode(); } }) @@ -61,6 +78,7 @@ $(document).ready(function () { $("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun"); $("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun"); $("#select_bank").removeClass("no-select-pay-fun").addClass("select-pay-fun"); + $("#select_alipay_aps").removeClass("select-pay-fun").addClass("no-select-pay-fun"); showQRcode(); } }) @@ -85,7 +103,15 @@ $(document).ready(function () { "

请使用" + channelName + "客户端扫码支付

" + ""; $('#qrImg').append(selectPaymentHTML) - } else if (paymentFun == 'Bank') { + } + else if (paymentFun == 'AlipayAps') { + $('#qrImg').empty(); + document.getElementById("qrImg").style.display = 'block'; + var selectPaymentHTML = + "

请使用" + channelName + "客户端扫码支付

" + + ""; + $('#qrImg').append(selectPaymentHTML) + }else if (paymentFun == 'Bank') { $('#qrImg').empty(); document.getElementById("qrImg").style.display = 'block'; if( hasPayment){ diff --git a/src/main/ui/static/templates/payment/gateway_jsapi.css b/src/main/ui/static/templates/payment/gateway_jsapi.css index a573b9fd0..4cf61b514 100644 --- a/src/main/ui/static/templates/payment/gateway_jsapi.css +++ b/src/main/ui/static/templates/payment/gateway_jsapi.css @@ -68,4 +68,19 @@ body{ .alipay .royal-pay-btn{ background: #108ee9; +} + +.alipayaps-pay-brands { + text-align: center; + line-height: 20px; + font-size: 24px; + margin-top: 64px; + color: #dddddd; +} +.alipayaps-pay-brands img { + height: 18px; +} + +.alipayaps-pay-brands img.alipayaps-logo { + height: 14px; } \ No newline at end of file diff --git a/src/main/ui/static/templates/skip_wxbrowser.css b/src/main/ui/static/templates/skip_wxbrowser.css index e91cd1866..e9a832f30 100644 --- a/src/main/ui/static/templates/skip_wxbrowser.css +++ b/src/main/ui/static/templates/skip_wxbrowser.css @@ -59,6 +59,15 @@ body { background-size: contain; } +.result-alipayaps-logo { + width: 80px; + height: 80px; + margin: auto; + background-image: url(/static/images/alipay_aps_big.svg); + background-repeat: no-repeat; + background-size: contain; +} + .result-royalpay-logo { width: 70px; height: 98px;