diff --git a/pom.xml b/pom.xml index 2d7a0d240..fce6dd7c9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ au.com.royalpay.payment payment-parent - 2.2.26 + 2.2.27 4.0.0 manage diff --git a/src/document/openapi/cn/components_order.yml b/src/document/openapi/cn/components_order.yml index 38a9d38f1..ea511b3ea 100644 --- a/src/document/openapi/cn/components_order.yml +++ b/src/document/openapi/cn/components_order.yml @@ -32,6 +32,80 @@ orderBasic: 可以提供以下格式的精确时间:yyyy-MM-dd HH:mm:ss,基于GMT+10时区。 或以以下格式提供:数字+m/h,m=分钟,h=小时 超时时间最小1m,最大24h + extra: + type: object + description: 订单扩展参数,部分渠道必填 + 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: 数量 orderWithChannel: allOf: - $ref: '#/orderBasic' @@ -42,6 +116,7 @@ orderWithChannel: enum: - Alipay - Wechat + - AlipayPlus type: object required: - channel diff --git a/src/document/openapi/cn/document.yml b/src/document/openapi/cn/document.yml index 110937038..d00778a0d 100644 --- a/src/document/openapi/cn/document.yml +++ b/src/document/openapi/cn/document.yml @@ -140,9 +140,9 @@ tags: - name: RetailPay description: | 线下支付订单接口用于线下零售收银,有B扫C和C扫B两种模式 - - name: AlipayOnline + - name: ChannelGateway description: | - 用于PC端支付宝支付,创建订单后跳转到返回的pay_url(需附加签名参数和redirect参数),随后进入支付宝支付页面完成支付 + 用于PC端渠道网关支付,创建订单后跳转到返回的pay_url(需附加签名参数和redirect参数),随后进入渠道收银台页面完成支付 该接口现仅支持支付宝。 - name: CB Bank @@ -212,7 +212,7 @@ paths: - SDK Payment - CB Bank - RetailPay - - AlipayOnline + - ChannelGateway - CardPayment - MiniProgram - MobileH5 @@ -239,7 +239,7 @@ paths: - SDK Payment - CB Bank - RetailPay - - AlipayOnline + - ChannelGateway - CardPayment - MiniProgram - MobileH5 @@ -833,13 +833,13 @@ paths: description: 付款码字符串,商户可自行生成二维码 # todo /alipay/partners/{partner_code}/orders/{partner_order_id}: put: - summary: 支付宝WEB订单下单 + summary: 渠道网关订单下单 x-sort-order: 0 description: | 创建订单后跳转到返回的pay_url(需附加签名参数和redirect参数),随后进入支付宝支付页面完成支付 该接口现仅支持支付宝。 tags: - - AlipayOnline + - ChannelGateway parameters: - name: partner_code in: path @@ -851,7 +851,16 @@ paths: content: application/json: schema: - $ref: 'components_order.yml#/orderBasic' + allOf: + - $ref: 'components_order.yml#/orderBasic' + - type: object + properties: + channel: + type: string + description: 支付渠道,默认为Alipay + enum: + - Alipay + - AlipayPlus responses: 200: description: Order @@ -1016,7 +1025,7 @@ paths: - MobileH5 - MiniProgram - CardPayment - - AlipayOnline + - ChannelGateway - RetailPay - CB Bank - SDK Payment @@ -1062,7 +1071,7 @@ paths: - MobileH5 - MiniProgram - CardPayment - - AlipayOnline + - ChannelGateway - RetailPay - CB Bank - SDK Payment @@ -1234,7 +1243,7 @@ paths: - SDK Payment - CB Bank - RetailPay - - AlipayOnline + - ChannelGateway - CardPayment - MiniProgram - MobileH5 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 638bb9133..6a46ae9d3 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 @@ -19,6 +19,7 @@ import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.NotFoundException; +import au.com.royalpay.payment.tools.utils.Currency; import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; @@ -81,12 +82,12 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa JSONObject dietOrderInfo = new JSONObject(); dietOrderInfo.put("order_id", orderId); dietOrderInfo.put("client_id", paymentInfo.getClientId()); - String currency = paymentInfo.getCurrency(); + Currency currency = paymentInfo.getCurrency(); dietOrderInfo.put("order_currency", currency); BigDecimal totalFee = paymentInfo.getTotalFee(); BigDecimal payAmount = totalFee.divide(CommonConsts.HUNDRED, 2, RoundingMode.DOWN); BigDecimal payLocalCurrency = paymentInfo.getDisplayAmount().divide(CommonConsts.HUNDRED, 2, RoundingMode.DOWN); - if (!"AUD".equals(currency)) { + if (currency != Currency.AUD) { BigDecimal exchange = mpPaymentApi.queryExchangeRateDecimal(clientId); payLocalCurrency = payLocalCurrency.divide(exchange, 2, RoundingMode.DOWN); } @@ -95,7 +96,7 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa } BigDecimal discount; dietOrderInfo.put("order_amount", totalFee.divide(CommonConsts.HUNDRED, 2, RoundingMode.DOWN)); - if (!"AUD".equals(currency)) { + if (currency != Currency.AUD) { BigDecimal exchange = mpPaymentApi.queryExchangeRateDecimal(clientId); discount = DISCOUNT_AMOUNT.multiply(exchange).setScale(2, RoundingMode.DOWN); } else { diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java index 99f6556e9..264b6d7c4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/PartnerCardDashboardServiceImp.java @@ -79,7 +79,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Override public JSONObject getTransactionAnalysis(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - Assert.notNull(client); + Assert.notNull(client, "client not found"); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); return transactionAnalysisMapper.getTransactionCommonAnalysis(params); @@ -88,7 +88,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Override public List getOrderCustomerChartAnalysis(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - Assert.notNull(client); + Assert.notNull(client, "client not found"); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); return customerAndOrdersStatisticsMapper.getPartnerCustomerAndOrderStatistics(params); @@ -97,7 +97,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Override public List getTransTypesAnalysis(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - Assert.notNull(client); + Assert.notNull(client, "client not found"); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); return dashboardService.getTradeInTypes(params); @@ -106,7 +106,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Override public JSONObject getOrderAndCustomerPerDay(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - Assert.notNull(client); + Assert.notNull(client, "client not found"); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); return customerAndOrdersStatisticsMapper.getAvgOrderAndCustomerStatistics(params); @@ -115,7 +115,7 @@ public class PartnerCardDashboardServiceImp implements PartnerCardDashboardServi @Override public List getTradeAnalysisInHours(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - Assert.notNull(client); + Assert.notNull(client, "client not found"); JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client.getIntValue("client_id")); String timezone = client.getString("timezone"); AnalysisBean analysisBean = new AnalysisBean(); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/NewSubMerchantIdApply.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/NewSubMerchantIdApply.java index 30309d852..b8e2b88a4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/NewSubMerchantIdApply.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/NewSubMerchantIdApply.java @@ -1,5 +1,7 @@ package au.com.royalpay.payment.manage.merchants.beans; +import au.com.royalpay.payment.channels.wechat.runtime.beans.WechatMerchantInfo; +import au.com.royalpay.payment.tools.utils.JsonUtils; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; import org.apache.commons.lang3.StringUtils; @@ -148,29 +150,29 @@ public class NewSubMerchantIdApply { return params; } - public static JSONObject resultParams(JSONObject subMerchantApplyInfo){ - return new JSONObject(){{ - put("company_name",subMerchantApplyInfo.getString("merchant_name")); - put("merchant_id",subMerchantApplyInfo.getString("merchant_id")); - put("short_name",subMerchantApplyInfo.getString("merchant_shortname")); - put("company_phone",subMerchantApplyInfo.getString("office_phone")); - put("contact_person",subMerchantApplyInfo.getString("contact_name")); - put("contact_phone",subMerchantApplyInfo.getString("contact_phone")); - put("contact_email",subMerchantApplyInfo.getString("contact_email")); - put("industry",subMerchantApplyInfo.getString("business_category")); - put("company_website",subMerchantApplyInfo.getString("website")); - put("mcc_code",subMerchantApplyInfo.getString("mcc_code")); - put("address",subMerchantApplyInfo.getString("stores_address")); - put("company_register_no",subMerchantApplyInfo.getString("extra_reg_cer_number")); - put("certificat_expire_date",subMerchantApplyInfo.getString("extra_reg_cer_exp_date")); - put("merchant_type",subMerchantApplyInfo.getString("extra_merchant_type")); - put("director_name",subMerchantApplyInfo.getString("director_name")); - put("director_id_number",subMerchantApplyInfo.getString("director_id_number")); - put("principal_name",subMerchantApplyInfo.getString("principal_name")); - put("principal_id_number",subMerchantApplyInfo.getString("principal_id_number")); - put("business_type",subMerchantApplyInfo.getString("business_type")); - put("sub_merchant_id",subMerchantApplyInfo.getString("sub_merchant_id")); - }}; + public static JSONObject resultParams(WechatMerchantInfo subMerchantApplyInfo){ + return JsonUtils.newJson(json->{ + json.put("company_name",subMerchantApplyInfo.getMerchantName()); + json.put("merchant_id",subMerchantApplyInfo.getMerchantId()); + json.put("short_name",subMerchantApplyInfo.getMerchantShortname()); + json.put("company_phone",subMerchantApplyInfo.getOfficePhone()); + json.put("contact_person",subMerchantApplyInfo.getContactName()); + json.put("contact_phone",subMerchantApplyInfo.getContactPhone()); + json.put("contact_email",subMerchantApplyInfo.getContactEmail()); + json.put("industry",subMerchantApplyInfo.getBusinessCategory()); + json.put("company_website",subMerchantApplyInfo.getWebsite()); + json.put("mcc_code",subMerchantApplyInfo.getMccCode()); + json.put("address",subMerchantApplyInfo.getStoresAddress()); + json.put("company_register_no",subMerchantApplyInfo.getExtraRegCerNumber()); + json.put("certificat_expire_date",subMerchantApplyInfo.getExtraRegCerExpDate()); + json.put("merchant_type",subMerchantApplyInfo.getExtraMerchantType()); + json.put("director_name",subMerchantApplyInfo.getDirectorName()); + json.put("director_id_number",subMerchantApplyInfo.getDirectorIdNumber()); + json.put("principal_name",subMerchantApplyInfo.getPrincipalName()); + json.put("principal_id_number",subMerchantApplyInfo.getPrincipalIdNumber()); + json.put("business_type",subMerchantApplyInfo.getBusinessType()); + json.put("sub_merchant_id",subMerchantApplyInfo.getSubMerchantId()); + }); } public NewSubMerchantIdApply() { 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 66661665e..def6bff51 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,6 +1,7 @@ package au.com.royalpay.payment.manage.merchants.core; 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.exceptions.EmailException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean; @@ -426,10 +427,11 @@ public interface ClientManager { void setWeekendDelay(JSONObject account, String clientMoniker, int clientId, boolean delay); - List listSubMerchantIdApplys(JSONObject manager, String clientMoniker); + List listSubMerchantIdApplys(JSONObject manager, String clientMoniker); List listRpaySubMerchantIdApplys(JSONObject manager, String clientMoniker); + @Deprecated String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply, JSONObject manager); String newSubMerchantApplication(String clientMoniker, NewSubMerchantIdApply subMerchantIdApply, JSONObject manager); @@ -456,8 +458,6 @@ public interface ClientManager { List listMerchantIds(String clientMoniker, JSONObject manager); - void clearCacheSubMerchantIdApplices(String clientMoniker); - JSONObject getCheckClientInfo(int client_id, String account_id, String channel); List getClientSubMerchantIdLogs(String clientMoniker, JSONObject manager); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/AlipayChannelsConfig.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/AlipayChannelsConfig.java new file mode 100644 index 000000000..5081dd21e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/AlipayChannelsConfig.java @@ -0,0 +1,68 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Optional; + +/** + * @Description + * @title: + * @Date 2021/1/28 11:15 + * @author: zhangTao + */ +@Component +public class AlipayChannelsConfig { + + @Resource + private ClientConfigMapper clientConfigMapper; + + + public boolean isMandatoryAlipayOnline(int clientId) { + Optional optionalClientConfigInfo = getClientConfig(clientId); + if (optionalClientConfigInfo.isPresent()){ + JSONObject clientConfigInfo = optionalClientConfigInfo.get(); + if (clientConfigInfo.getBooleanValue("mandatory_alipay_online")){ + return true; + } + } + return false; + } + + + + public void modifyMandatoryAlipayOnline(int clientId ,boolean mandatoryAlipayOnlineStatus){ + JSONObject mandatoryAlipayOnlineConfig = new JSONObject(); + mandatoryAlipayOnlineConfig.put("client_id",clientId); + mandatoryAlipayOnlineConfig.put("mandatory_alipay_online",mandatoryAlipayOnlineStatus); + clientConfigMapper.update(mandatoryAlipayOnlineConfig); + } + + + public boolean isAlipayPlus(int clientId) { + Optional optionalClientConfigInfo = getClientConfig(clientId); + if (optionalClientConfigInfo.isPresent()){ + JSONObject clientConfigInfo = optionalClientConfigInfo.get(); + if (clientConfigInfo.getBooleanValue("alipay_payment_channels")){ + return true; + } + } + return false; + } + + public void modifyAlipayPaymentChannels(int clientId ,boolean alipayPaymentChannelsStatus){ + JSONObject mandatoryAlipayOnlineConfig = new JSONObject(); + mandatoryAlipayOnlineConfig.put("client_id",clientId); + mandatoryAlipayOnlineConfig.put("alipay_payment_channels",alipayPaymentChannelsStatus); + clientConfigMapper.update(mandatoryAlipayOnlineConfig); + } + + + private Optional getClientConfig(int clientId) { + Optional optionalClientConfigInfo = Optional.of(clientConfigMapper.find(clientId)); + return optionalClientConfigInfo; + } + +} 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 2837dde2d..7b0de4e2b 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 @@ -2,24 +2,33 @@ package au.com.royalpay.payment.manage.merchants.core.impls; 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.AlipayClient; -import au.com.royalpay.payment.channels.rpay.runtime.RpayApi; +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.entity.AlipayMerchantEntity; import au.com.royalpay.payment.channels.rpay.runtime.beans.SubRpayMerchantInfo; +import au.com.royalpay.payment.channels.rpay.runtime.impls.RPayMerchantRegister; import au.com.royalpay.payment.channels.rpaypaymentsvc.mappers.RPayMerchantMapper; import au.com.royalpay.payment.channels.rpaypaymentsvc.runtime.RPayPaymentCardSvcApi; import au.com.royalpay.payment.channels.rpaypaymentsvc.runtime.request.entities.RPayMerchantEntity; 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.WxPayClient; import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo; import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfoInheritance; +import au.com.royalpay.payment.channels.wechat.runtime.beans.WechatMerchantInfo; +import au.com.royalpay.payment.channels.wechat.runtime.impls.WxPayMerchantRegister; +import au.com.royalpay.payment.channels.wechat.runtime.impls.WxPayMerchantRegisterLegacy; import au.com.royalpay.payment.channels.wechat.runtime.mappers.PaymentChannelMccGoodMapper; +import au.com.royalpay.payment.channels.wechat.runtime.mappers.WxMerchantApplyMapper; +import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.PaymentChannelApi; +import au.com.royalpay.payment.core.beans.ChannelMerchantInfo; import au.com.royalpay.payment.core.beans.EmptyMerchantApplication; import au.com.royalpay.payment.core.beans.MerchantApplicationResult; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; +import au.com.royalpay.payment.core.impls.MerchantChannelApplicationManager; +import au.com.royalpay.payment.core.impls.MerchantChannelPermissionManager; import au.com.royalpay.payment.core.mappers.SysClientMapper; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; @@ -74,6 +83,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException; import au.com.royalpay.payment.tools.defines.IncrementalChannel; +import au.com.royalpay.payment.tools.defines.PayChannel; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; @@ -87,6 +97,7 @@ import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; +import au.com.royalpay.payment.tools.merchants.core.MerchantChannelPermissionResolver; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider; @@ -168,7 +179,7 @@ import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.chec */ @Service public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvider, ApplicationEventPublisherAware { - private Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); @Resource private ClientMapper clientMapper; @Resource @@ -216,20 +227,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private ClientModifySupport clientModifySupport; @Resource - private PaymentChannelApi[] channels; + private MerchantChannelApplicationManager merchantChannelApplicationManager; @Resource private MerchantInfoProvider merchantInfoProvider; @Resource - private MpPaymentApi mpPaymentApi; - @Resource private SignInAccountService signInAccountService; - @Resource - private WxPayClient wxPayClient; - @Resource - private AlipayClient alipayClient; - - @Resource - private RpayApi rpayApi; @Resource private ManagerMapper managerMapper; @@ -251,7 +253,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private ClientAuditProcessMapper clientAuditProcessMapper; @Resource - private SysWxMerchantApplyMapper sysWxMerchantApplyMapper; + private WxMerchantApplyMapper wxMerchantApplyMapper; @Resource private SysRpayMerchantApplyMapper sysRpayMerchantApplyMapper; @Resource @@ -279,8 +281,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private MailGunService mailGunService; @Resource - private MailSendMapper mailSendMapper; - @Resource private ClearingDetailMapper clearingDetailMapper; @Resource private ClearingLogMapper clearingLogMapper; @@ -326,6 +326,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private RPayMerchantMapper rPayMerchantMapper; @Resource private SysClientUpayProfileMapper sysClientUpayProfileMapper; + @Resource + private PaymentApi paymentApi; + @Resource + private MerchantChannelPermissionManager merchantChannelPermissionManager; + DateTimeFormatter formatter = DateTimeFormat.forPattern("dd MMM yyyy"); @@ -362,6 +367,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private PaymentChannelMccGoodMapper paymentChannelMccGoodMapper; + @PostConstruct public void init() { tags.add("account"); @@ -539,10 +545,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (representativeInfo != null) { client.put("representativeInfo", representativeInfo); } - JSONObject wechatMcc= paymentChannelMccGoodMapper.findWechatPayMccByClientId(client.getIntValue("client_id")); + JSONObject wechatMcc = paymentChannelMccGoodMapper.findWechatPayMccByClientId(client.getIntValue("client_id")); if (wechatMcc != null) { client.put("mc_code", wechatMcc.getIntValue("mc_code")); } + client.put("enable_alipayplus", false); + MerchantChannelPermissionResolver resolver = this.paymentApi.channelApi(PayChannel.ALIPAY_PLUS.getChannelCode()).getChannelPermissionResolver(); + if(!Objects.isNull(resolver)) { + if (resolver.newOrderEnabled(client)) { + client.put("enable_alipayplus", true); + } + } return client; } @@ -876,22 +889,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid /** * 保存微信mccode + * * @param partner */ - private void saveWechatMcc(JSONObject partner){ + private void saveWechatMcc(JSONObject partner) { JSONObject wxGoodMcc = paymentChannelMccGoodMapper.findWechatPayMccByClientId(partner.getIntValue("client_id")); - if ((wxGoodMcc == null || wxGoodMcc.isEmpty())&& !TextUtils.isEmpty(partner.getString("mc_code"))) { + if ((wxGoodMcc == null || wxGoodMcc.isEmpty()) && !TextUtils.isEmpty(partner.getString("mc_code"))) { wxGoodMcc = new JSONObject(); - wxGoodMcc.put("client_id",partner.getIntValue("client_id")); - wxGoodMcc.put("mc_code",partner.getString("mc_code")); - wxGoodMcc.put("channel","Wechat"); - wxGoodMcc.put("creation_date",new Date()); - wxGoodMcc.put("creation_by","System"); + wxGoodMcc.put("client_id", partner.getIntValue("client_id")); + wxGoodMcc.put("mc_code", partner.getString("mc_code")); + wxGoodMcc.put("channel", "Wechat"); + wxGoodMcc.put("creation_date", new Date()); + wxGoodMcc.put("creation_by", "System"); paymentChannelMccGoodMapper.save(wxGoodMcc); return; } - if(!TextUtils.isEmpty(partner.getString("mc_code"))) { + if (!TextUtils.isEmpty(partner.getString("mc_code"))) { wxGoodMcc.put("mc_code", partner.getString("mc_code")); paymentChannelMccGoodMapper.update(wxGoodMcc); } @@ -976,7 +990,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } clientConfigMapper.update(clientConfig); clientInfoCacheSupport.clearClientCache(clientId); - client.put("mc_code",info.getMc_code()); + client.put("mc_code", info.getMc_code()); saveWechatMcc(client); } @@ -1069,7 +1083,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid String originSubMerchantId = client.getString("sub_merchant_id"); update.put("client_id", clientId); String subMerchantId = subMerchantInfo.getString("sub_merchant_id"); - WeChatPayConfig.Merchant availableMerchant = mpPaymentApi.determineMerchant(subMerchantId); + MpPaymentApi wxApi = (MpPaymentApi) paymentApi.channelApi(PayChannel.WECHAT.getChannelCode()); + WeChatPayConfig.Merchant availableMerchant = wxApi.determineMerchant(subMerchantId); update.put("merchant_id", availableMerchant == null ? null : availableMerchant.getMerchantId()); update.put("sub_merchant_id", subMerchantId); try { @@ -1556,16 +1571,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow) { - for (PaymentChannelApi channelApi : channels) { - if (channelApi.channel().equalsIgnoreCase(channel) || "CB_BankPay".equalsIgnoreCase(channel)) { + for (PaymentChannelApi channelApi : paymentApi.channels()) { + if (channelApi.channel().equalsIgnoreCase(channel) ) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new NotFoundException("Client Not Exists"); } - clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow)); - - logger.info(manager.getString("display_name") + "(" + manager.getString("manager_id") + ") switched client " + clientMoniker + " channel " - + channel + " to " + allow); + merchantChannelPermissionManager.switchMerchantChannelPermission(channelApi.getMetadata().payChannel(), client.getIntValue("client_id"), allow); + try { + clientModifySupport.processModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow)); + } catch (Exception e) { + logger.error("Failed to change channel switch:{}" ,channel); + } + 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))) { int clientId = client.getIntValue("client_id"); List clientBankAccounts = clientBankAccountMapper.clientBankAccounts(clientId); @@ -1886,7 +1904,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid int clientId = client.getIntValue("client_id"); JSONObject clientConfig = clientConfigService.find(clientId); List rates = new ArrayList<>(); - for (PaymentChannelApi channel : channels) { + for (PaymentChannelApi channel : paymentApi.channels()) { rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), channel.channel(), includingInactive)); } rates.addAll(merchantInfoProvider.listClientRates(clientId, new Date(), "CB_BankPay", includingInactive)); @@ -5206,15 +5224,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat"); - MpWechatApi paymentApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); - String templateId = paymentApi.getTemplateId("new-apply"); + MpWechatApi wxApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); + String templateId = wxApi.getTemplateId("new-apply"); try { TemplateMessage msg = initSendToComplianceTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception e) { try { TemplateMessage msg = initSendToComplianceTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception ignore) { } } @@ -5241,9 +5259,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid // String loginUrl = // PlatformEnvironment.getEnvironment().concatUrl("/global/userstatus/manager_signin_wechat"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendToBDTemplate(wxopenid, paymentApi.getTemplateId("refuse-bd"), refuseRemark, client); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendToBDTemplate(wxopenid, wxApi.getTemplateId("refuse-bd"), refuseRemark, client); + wxApi.sendTemplateMessage(msg); } catch (Exception ignored) { } } @@ -5270,9 +5288,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (wxopenid != null) { String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendToBDAgreeFileTemplate(wxopenid, paymentApi.getTemplateId("new-apply"), remark, client); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendToBDAgreeFileTemplate(wxopenid, wxApi.getTemplateId("new-apply"), remark, client); + wxApi.sendTemplateMessage(msg); } catch (Exception e) { } } @@ -5298,15 +5316,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat"); - MpWechatApi paymentApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); - String templateId = paymentApi.getTemplateId("new-apply"); + MpWechatApi wxApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); + String templateId = wxApi.getTemplateId("new-apply"); try { TemplateMessage msg = initSendToComAgreeFileTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception e) { try { TemplateMessage msg = initSendToComAgreeFileTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception ignore) { } } @@ -5331,15 +5349,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat"); - MpWechatApi paymentApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); - String templateId = paymentApi.getTemplateId("new-apply"); + MpWechatApi wxApi = mpWechatApiProvider.getWechatApiForTemplateMessage(wxopenid); + String templateId = wxApi.getTemplateId("new-apply"); try { TemplateMessage msg = initSendToComplianceGreenChannelTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception e) { try { TemplateMessage msg = initSendToComplianceGreenChannelTemplate(loginUrl, wxopenid, templateId, bd_user_name, client); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (Exception ignore) { } } @@ -5392,10 +5410,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (wxopenid != null) { try { TemplateMessage msg = initTaskFinishTemplate(wxopenid, client_moniker + "已快速开通", "绿色通道申请通过", ""); - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,绿色通道开通完成" + e.getMessage()); + logger.error("Wechat Message Error,绿色通道开通完成", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,绿色通道开通完成,openid=" + wxopenid)); } } @@ -5409,12 +5427,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), "BD申请制作合同" + client_moniker, + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), "BD申请制作合同" + client_moniker, bd_user_name, "制作合同申请", "BD申请制作" + short_name + "的合同"); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=1,openid=" + wxopenid)); } } @@ -5427,12 +5445,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid String wxopenid = bd.getString("wx_openid"); if (wxopenid != null) { try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), client_moniker + "合同制作完成", + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), client_moniker + "合同制作完成", "Compliance", "合规材料", "上传完整合规材料,商户:" + short_name); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=3" + e.getMessage()); + logger.error("Wechat Message Error,open_status=3", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=3,openid=" + wxopenid)); } @@ -5450,15 +5468,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), client_moniker + "合规材料已提交", + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), client_moniker + "合规材料已提交", bd_user_name, "审核材料", "已提交合规材料,等待审核"); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=1,openid=" + wxopenid)); } catch (Exception e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); } } } @@ -5471,10 +5489,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (wxopenid != null) { try { TemplateMessage msg = initTaskFinishTemplate(wxopenid, client_moniker + "已正式开通", "Compliance审核通过", ""); - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=5" + e.getMessage()); + logger.error("Wechat Message Error,open_status=5", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=5,openid=" + wxopenid)); } } @@ -5488,12 +5506,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), client_moniker + "申请绿色通道", + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), client_moniker + "申请绿色通道", bd_user_name, "绿色通道申请", "BD已提交绿色通道申请,商户:" + short_name); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=10"); + logger.error("Wechat Message Error,open_status=10", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=10,openid=" + wxopenid)); } } @@ -5517,12 +5535,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), "BD申请制作信用卡支付合同" + client_moniker, + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), "BD申请制作信用卡支付合同" + client_moniker, bd_user_name, "制作卡支付合同申请", "BD申请制作" + short_name + "的卡支付合同"); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=1,openid=" + wxopenid)); } } @@ -5535,12 +5553,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid String wxopenid = bd.getString("wx_openid"); if (wxopenid != null) { try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), client_moniker + "信用卡支付合同制作完成", + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), client_moniker + "信用卡支付合同制作完成", "Compliance", "合规材料", "上传完整合规材料,商户:" + short_name); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=3" + e.getMessage()); + logger.error("Wechat Message Error,open_status=3", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=3,openid=" + wxopenid)); } @@ -5558,15 +5576,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (JSONObject compliance : complianceList) { String wxopenid = compliance.getString("wx_openid"); try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendCommissionTemplate(wxopenid, paymentApi.getTemplateId("commission"), client_moniker + "信用卡卡支付合规材料已提交", + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendCommissionTemplate(wxopenid, wxApi.getTemplateId("commission"), client_moniker + "信用卡卡支付合规材料已提交", bd_user_name, "审核材料", "已提交合规材料,等待审核"); - paymentApi.sendTemplateMessage(msg); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=1,openid=" + wxopenid)); } catch (Exception e) { - logger.error("Wechat Message Error,open_status=1" + e.getMessage()); + logger.error("Wechat Message Error,open_status=1", e); } } } @@ -5579,10 +5597,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (wxopenid != null) { try { TemplateMessage msg = initTaskFinishTemplate(wxopenid, client_moniker + "已正式开通", "Card Payment Compliance审核通过", ""); - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + wxApi.sendTemplateMessage(msg); } catch (WechatException e) { - logger.error("Wechat Message Error,open_status=5" + e.getMessage()); + logger.error("Wechat Message Error,open_status=5", e); publisher.publishEvent(new WechatExceptionEvent(this, e, "Audit,open_status=5,openid=" + wxopenid)); } } @@ -5593,37 +5611,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Cacheable(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") - public List listSubMerchantIdApplys(JSONObject manager, String clientMoniker) { + public List listSubMerchantIdApplys(JSONObject manager, String clientMoniker) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - List applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"), + List applices = wxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"), new PageBounds(Order.formString("create_time.desc"))); if (!applices.isEmpty()) { - return applices; + return new ArrayList<>(applices); } else { if (StringUtils.isNotEmpty(client.getString("sub_merchant_id")) && StringUtils.isNotEmpty(client.getString("merchant_id"))) { - Element elem = wxPayClient.querySubMerchant(client.getString("merchant_id"), client.getString("sub_merchant_id")); - JSONObject object = new JSONObject(); - object.put("sub_merchant_id", elem.elementText("sub_mch_id_0")); - object.put("client_id", client.getInteger("client_id")); - object.put("merchant_name", elem.elementText("merchant_name_0")); - object.put("merchant_shortname", elem.elementText("merchant_shortname_0")); - object.put("office_phone", elem.elementText("office_phone_0")); - object.put("contact_name", elem.elementText("contact_name_0")); - object.put("contact_email", elem.elementText("contact_email_0")); - object.put("contact_phone", elem.elementText("contact_phone_0")); - object.put("business_category", elem.elementText("business_category_0")); - object.put("merchant_remark", elem.elementText("merchant_remark_0")); - object.put("website", elem.elementText("website_0")); - object.put("merchant_introduction", elem.elementText("merchant_introduction_0")); - object.put("merchant_id", client.getString("merchant_id")); - object.put("create_time", new Date()); - object.put("operator", manager.getString("display_name")); - List applyQuery = new ArrayList<>(); - applyQuery.add(object); + WxPayMerchantRegister wxRegistry = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class)).orElseThrow(() -> new ServerErrorException("No Wechat registry found")); + ChannelMerchantInfo wxMerchantInfo = wxRegistry.findMerchant(client); + List applyQuery = new ArrayList<>(); + applyQuery.add(wxMerchantInfo); return applyQuery; } } @@ -5647,6 +5650,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") + @Deprecated public String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply, JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { @@ -5655,25 +5659,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); JSONObject params = subMerchantApply.insertObject(); - SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class); - params.put("merchant_id", subMerchantApply.getMerchant_id()); - params.put("client_id", client.getString("client_id")); - params.put("create_time", new Date()); - params.put("operator", manager.getString("display_name")); - Element elem = wxPayClient.subMerchantApplication(subMerchantApply.getMerchant_id(), subMerchantInfo); - String sub_merchant_id = elem.elementText("sub_mch_id"); - if (StringUtils.isNotEmpty(sub_merchant_id)) { - params.put("sub_merchant_id", sub_merchant_id); - sysWxMerchantApplyMapper.insertWxMerchantApply(params); - clearCacheSubMerchantIdApplices(clientMoniker); + SubMerchantInfo subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfo.class); + + MerchantApplicationResult res = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegisterLegacy.class)) + .map(channel -> channel.apply(client, subMerchantInfo, manager)) + .orElseThrow(() -> new ServerErrorException("No Wechat merchant registry found")); + if (res.isSuccess()) { + return res.getMid(); } else { - throw new BadRequestException(elem.elementText("return_msg")); + throw new BadRequestException("Failed to register wechat merchant"); } - return sub_merchant_id; } /** * 微信新进件 + * * @param clientMoniker * @param subMerchantApply * @param manager @@ -5681,7 +5681,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid */ @Override @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") - public String newSubMerchantApplication(String clientMoniker, NewSubMerchantIdApply subMerchantApply, JSONObject manager){ + public String newSubMerchantApplication(String clientMoniker, NewSubMerchantIdApply subMerchantApply, JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -5689,48 +5689,39 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); JSONObject params = subMerchantApply.insertObject(client); - SubMerchantInfoInheritance subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfoInheritance.class); - params.put("merchant_id", subMerchantApply.getMerchant_id()); - params.put("client_id", client.getString("client_id")); - params.put("create_time", new Date()); - params.put("operator", manager.getString("display_name")); - params.put("is_valid","1"); - Element elem = wxPayClient.newSubMerchantApplication(subMerchantApply.getMerchant_id(), subMerchantInfo); - String sub_merchant_id = elem.elementText("sub_mch_id"); - if (StringUtils.isNotEmpty(sub_merchant_id)) { - params.put("sub_merchant_id", sub_merchant_id); - List subMerchants= sysWxMerchantApplyMapper.findByClientIdAndSubMerchantId(client.getInteger("client_id"),sub_merchant_id); - if(subMerchants.size()>0){ - sysWxMerchantApplyMapper.failureSubMerchantByClientIdAndSubMerchantId(client.getInteger("client_id"),sub_merchant_id); - } - sysWxMerchantApplyMapper.insertWxMerchantApply(params); - clearCacheSubMerchantIdApplices(clientMoniker); + SubMerchantInfoInheritance subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfoInheritance.class); + MerchantApplicationResult res = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class)) + .map(channel -> channel.apply(client, subMerchantInfo, manager)) + .orElseThrow(() -> new ServerErrorException("No Wechat merchant registry found")); + if (res.isSuccess()) { + return res.getMid(); } else { - throw new BadRequestException(elem.elementText("return_msg")); + throw new BadRequestException("Failed to register wechat merchant"); } - return sub_merchant_id; } /** * 获取指定商户-微信子商户详情 + * * @param clientMoniker * @param merchantAppId */ @Override - public JSONObject queryApplicationSubMerchantById(String clientMoniker, String merchantAppId){ + public JSONObject queryApplicationSubMerchantById(String clientMoniker, String merchantAppId) { JSONObject client = clientMapper.findClientByMoniker(clientMoniker); if (client == null) { throw new BadRequestException("partner code is not exists!"); } - JSONObject subMerchantApplyInfo = sysWxMerchantApplyMapper.findByClientIdAndSubMerchantAppId(client.getInteger("client_id"), merchantAppId); + WechatMerchantInfo subMerchantApplyInfo = wxMerchantApplyMapper.findByClientIdAndSubMerchantAppId(client.getInteger("client_id"), merchantAppId); JSONObject resultParams = NewSubMerchantIdApply.resultParams(subMerchantApplyInfo); - resultParams.put("merchant_app_id",subMerchantApplyInfo.getString("merchant_app_id")); + resultParams.put("merchant_app_id", subMerchantApplyInfo.getMerchantAppId()); return resultParams; } /** * 修改指定微信子进件商户信息 + * * @param clientMoniker * @param merchantAppId * @param subMerchantIdApply @@ -5738,7 +5729,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid */ @Override @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") - public void changeApplicationSubMerchantById(String clientMoniker, String merchantAppId, NewSubMerchantIdApply subMerchantIdApply, JSONObject manager){ + public void changeApplicationSubMerchantById(String clientMoniker, String merchantAppId, NewSubMerchantIdApply subMerchantIdApply, JSONObject manager) { JSONObject client = clientMapper.findClientByMoniker(clientMoniker); if (client == null) { throw new BadRequestException("partner code is not exists!"); @@ -5746,37 +5737,32 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); JSONObject params = subMerchantIdApply.insertObject(client); - params.put("merchant_app_id",merchantAppId); - SubMerchantInfoInheritance subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfoInheritance.class); + params.put("merchant_app_id", merchantAppId); + SubMerchantInfoInheritance subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfoInheritance.class); params.put("merchant_id", subMerchantIdApply.getMerchant_id()); params.put("client_id", client.getString("client_id")); params.put("create_time", new Date()); params.put("operator", manager.getString("display_name")); - - - Element elem = wxPayClient.modfiySubMerchant(subMerchantIdApply.getMerchant_id(), subMerchantInfo); - String sub_merchant_id = elem.elementText("sub_mch_id"); - if (StringUtils.isNotEmpty(sub_merchant_id)) { - params.put("sub_merchant_id", sub_merchant_id); - sysWxMerchantApplyMapper.updateSubMerchantInfoByMerchantAppId(params); - clearCacheSubMerchantIdApplices(clientMoniker); - } else { - throw new BadRequestException(elem.elementText("return_msg")); - } + WxPayMerchantRegister register = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class)) + .orElseThrow(() -> new ServerErrorException("No Register found for wechat")); + register.modify(merchantAppId, client, subMerchantInfo, manager); } @Override - public JSONObject querySubMerchantStatus(String clientMoniker,String subMerchantId){ + public JSONObject querySubMerchantStatus(String clientMoniker, String subMerchantId) { JSONObject client = clientMapper.findClientByMoniker(clientMoniker); if (client == null) { throw new BadRequestException("partner code is not exists!"); } - Element elem = wxPayClient.querySubMerchant(client.getString("merchant_id"), subMerchantId); + client.put("sub_merchant_id", subMerchantId); + WechatMerchantInfo info = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class)) + .map(register -> register.findMerchant(client)) + .orElseThrow(() -> new ServerErrorException("No Register found for wechat")); + Element xml = info.getRawResponseXml(); JSONObject object = new JSONObject(); - - object.put("apply_status", elem.elementText("result_code")); - object.put("response_str", elem.asXML()); + object.put("response_str", xml); + object.put("apply_status", info.getRawResponse()); return object; } @@ -5798,20 +5784,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("Alipay Industry can't be null"); } - AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); - Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client); - if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { - throw new BadRequestException(resultElement.elementText("error")); - } - try { - Element responseElement = resultElement.element("response").element("alipay"); - if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) { - throw new BadRequestException(responseElement.elementText("result_code") + - ":" + responseElement.elementText("reject_reason")); - } - } catch (Exception e) { - throw new ServerErrorException(e); - } + merchantChannelApplicationManager.getRegister(AlipayRetailApi.class).apply(client, new EmptyMerchantApplication(), manager); } @Override @@ -5821,8 +5794,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); - Element resultElement = alipayClient.queryGmsPortalStatus(mch.getPid(), client); + AlipayMerchantEntity alipayMch = merchantChannelApplicationManager.getRegister(AlipayRetailApi.class).findMerchant(client); + Element resultElement = alipayMch.getRawResponseXml(); if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { return "查询成功:" + resultElement.elementText("error"); } @@ -5841,7 +5814,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); - JSONObject queryGMSJson = new JSONObject(new LinkedHashMap()); + JSONObject queryGMSJson = new JSONObject(new LinkedHashMap<>()); queryGMSJson.put("service", "alipay.overseas.secmerchant.offline.maintain"); queryGMSJson.put("partner", mch.getPid()); queryGMSJson.put("sign_type", "MD5"); @@ -5877,7 +5850,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - JSONObject queryGMSJson = new JSONObject(new LinkedHashMap()); + JSONObject queryGMSJson = new JSONObject(new LinkedHashMap<>()); AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); queryGMSJson.put("service", "alipay.overseas.secmerchant.online.maintain"); queryGMSJson.put("partner", mch.getPid()); @@ -5927,19 +5900,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); - Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client); - if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { - throw new BadRequestException(resultElement.elementText("error")); - } - try { - Element responseElement = resultElement.element("response").element("alipay"); - if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) { - throw new BadRequestException(responseElement.elementText("result_code") + - ":" + responseElement.elementText("reject_reason")); - } - } catch (Exception e) { - throw new ServerErrorException(e); - } + merchantChannelApplicationManager.getRegister(AlipayOnlineApi.class).apply(client, new EmptyMerchantApplication(), manager); } @Override @@ -5974,7 +5935,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); - Element resultElement = alipayClient.queryOnlineGmsPortalStatus(mch.getPid(), client); + AlipayMerchantEntity entity = merchantChannelApplicationManager.getRegister(AlipayOnlineApi.class) + .findMerchant(client); + Element resultElement = entity.getRawResponseXml(); if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { return "查询成功:" + resultElement.elementText("error"); } @@ -6001,20 +5964,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("您已申请成功子商务号,请勿重复申请"); } - SubRpayMerchantInfo subRpayMerchantInfo = JSONObject.toJavaObject(merchantInfo, SubRpayMerchantInfo.class); + SubRpayMerchantInfo subRpayMerchantInfo = JSON.toJavaObject(merchantInfo, SubRpayMerchantInfo.class); subRpayMerchantInfo.CheckEmpty(); - JSONObject rpayMerchantInfo = rpayApi.registerMerchant(client.getIntValue("client_id"), subRpayMerchantInfo); + MerchantApplicationResult rpayMerchantInfo = merchantChannelApplicationManager.getRegister(RPayMerchantRegister.class) + .apply(client, subRpayMerchantInfo, manager); if (rpayMerchantInfo != null) { - merchantInfo.put("merchant_id", rpayMerchantInfo.getString("rpay_order_id")); - merchantInfo.put("client_id", client.getString("client_id")); - merchantInfo.put("create_time", new Date()); - merchantInfo.put("operator", manager.getString("display_name")); - merchantInfo.put("sub_merchant_id", rpayMerchantInfo.getString("merchantId")); - merchantInfo.put("business_category", client.getString("royalpayindustry")); - merchantInfo.put("merchant_shortname", merchantInfo.getString("company_shortname")); - sysRpayMerchantApplyMapper.insertRpayMerchantApply(merchantInfo); - clientMapper.updateRpayEnterpriseId(client.getIntValue("client_id"), rpayMerchantInfo.getString("merchantId")); + + clientMapper.updateRpayEnterpriseId(client.getIntValue("client_id"), rpayMerchantInfo.getMid()); } else { throw new BadRequestException("请求失败"); } @@ -6036,11 +5993,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return list; } - @Override - @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") - public void clearCacheSubMerchantIdApplices(String clientMoniker) { - } - @Override public JSONObject getCheckClientInfo(int client_id, String account_id, String channel) { JSONObject result = null; @@ -6049,67 +6001,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) { return result; } else { - if (expireInfo.getBoolean("alert")) { + if (expireInfo.getBooleanValue("alert")) { result = new JSONObject(); - // result.put("content","Dear Valued Merchants,\n" + - // "\n" + - // "\n" + - // "\n" + - // "We would like to extend our warm gratitude to your business for your continued support of RoyalPay. - // Without our merchants we wouldn't be where we are today. \n" + - // "\n" + - // "\n" + - // "\n" + - // "RoyalPay has and always will be committed to complying with all Australian laws, rules and - // regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously - // with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax - // Office) to make sure that we are in alignment with all tax requirements. \n" + - // "\n" + - // "\n" + - // "\n" + - // "\n" + - // "During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of - // surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we - // comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. - // \n" + - // "\n" + - // "\n" + - // "\n" + - // "This will result in contractual changes to your agreement. However, your business may be eligible to - // claim this amount back depending on the tax relationship of your business. Please consult with your - // accounting team in relation to these changes. \n" + - // "\n" + - // "\n" + - // "\n" + - // "If you have any questions related to this change please direct them to our Sales Management Team or - // your relevant BD officer.\n" + - // "\n" + - // "\n" + - // "\n" + - // "(note: GST is for the surcharge fee only, not related to the price of the goods.)\n" + - // "\n" + - // "\n" + - // "\n" + - // "尊敬的商户,\n" + - // "\n" + - // "\n" + - // "\n" + - // "\n" + - // "感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。\n" - // + - // "\n" + - // "\n" + - // "\n" + - // "RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax - // Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST - // Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。\n" + - // "\n" + - // "\n" + - // "\n" + - // "有任何疑问,请随时联络我们的客服与公众号。\n" + - // "\n" + - // "(注:GST只针对手续费部分,与商品价格无关)\n" + - // "\n"); result.put("content", "

Dear Valued Merchants,


We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn't be where we are today. 


RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements. 


During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. 


This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes. 


If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.


(note: GST is for the surcharge fee only, not related to the price of the goods.)


尊敬的商户,


感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。


RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。


有任何疑问,请随时联络我们的客服与公众号。

(注:GST只针对手续费部分,与商品价格无关)


"); result.put("title", "【Important!重要!!】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n"); @@ -6686,9 +6579,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid }); needNotifyUsers.forEach(userOpenId -> { try { - MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); - TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password")); - paymentApi.sendTemplateMessage(msg); + MpWechatApi wxApi = mpWechatApiProvider.getNewPaymentApi(); + TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, wxApi.getTemplateId("test-merchant-password")); + wxApi.sendTemplateMessage(msg); } catch (Exception e) { logger.error("给{}发送微信消息失败,原因:{}", userOpenId, e); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/AlipayConfigController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/AlipayConfigController.java new file mode 100644 index 000000000..88e78fa6f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/AlipayConfigController.java @@ -0,0 +1,31 @@ +package au.com.royalpay.payment.manage.merchants.web; + + +import au.com.royalpay.payment.manage.merchants.core.impls.AlipayChannelsConfig; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @Description + * @title: + * @Date 2021/2/1 9:42 + * @author: zhangTao + */ +@RestController +@RequestMapping("/sys/partners") +public class AlipayConfigController { + + @Resource + AlipayChannelsConfig alipayChannelsConfig; + + @RequestMapping(method = RequestMethod.PUT,value = "/modifyAlipayPaymentChannels/{clientId}/{alipayPaymentChannelsStatus}") + public void modifyAlipayPaymentChannels(@PathVariable Integer clientId, @PathVariable Boolean alipayPaymentChannelsStatus) { + alipayChannelsConfig.modifyAlipayPaymentChannels(clientId,alipayPaymentChannelsStatus); + } + + +} 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 efd63bec4..4d9179838 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,6 +1,7 @@ package au.com.royalpay.payment.manage.merchants.web; 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.exceptions.InvalidShortIdException; import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; import au.com.royalpay.payment.manage.merchants.beans.*; @@ -826,7 +827,7 @@ public class PartnerManageController { } @ManagerMapping(value = "/{clientMoniker}/list_sub_applices", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) - public List listSubMerchantIdApplys(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + public List listSubMerchantIdApplys(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.listSubMerchantIdApplys(manager, clientMoniker); } @@ -836,6 +837,7 @@ public class PartnerManageController { } @ManagerMapping(value = "/{clientMoniker}/sub_apply", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) + @Deprecated public String subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.subMerchantApplication(clientMoniker, subMerchantIdApply, manager); } diff --git a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java index f63418a00..8ea9f3024 100644 --- a/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java +++ b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponOnlyLogProcessor.java @@ -11,6 +11,7 @@ import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.Currency; import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; @@ -59,6 +60,7 @@ public class CtripCouponOnlyLogProcessor implements PaymentProcessor { private CouponAccuessLogMapper payCouponAccuessLogMapper; @Resource private PaymentApi paymentApi; + @Override public String processorId() { return COUPON_ID + "_USE"; @@ -82,7 +84,7 @@ public class CtripCouponOnlyLogProcessor implements PaymentProcessor { } BigDecimal payFee = paymentInfo.getTotalFee(); BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); - if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + if (paymentInfo.getCurrency() == Currency.CNY) { payFee = CurrencyAmountUtils.scale(payFee.divide(exchange, 2, RoundingMode.HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); } BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO @@ -91,15 +93,15 @@ public class CtripCouponOnlyLogProcessor 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")); //携程满减 if (StringUtils.equals(couponInfo.getString("type"), "31")) { BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); - if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + if (paymentInfo.getCurrency() == Currency.CNY) { actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); } couponAccuessLog.put("coupon_deal_amount", actureAmount); @@ -164,7 +166,7 @@ public class CtripCouponOnlyLogProcessor 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/processors/CtripCouponProvideProcessor.java b/src/main/java/au/com/royalpay/payment/manage/processors/CtripCouponProvideProcessor.java index 321728514..e77fcba6b 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 @@ -11,9 +11,11 @@ import au.com.royalpay.payment.core.mappers.PmtOrderMapper; import au.com.royalpay.payment.core.processors.PaymentProcessor; import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.defines.Money; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.utils.Currency; import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; @@ -91,7 +93,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { } BigDecimal payFee = paymentInfo.getTotalFee(); BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId()); - if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + if (paymentInfo.getCurrency() == Currency.CNY) { payFee = CurrencyAmountUtils.scale(payFee.divide(exchange, 2, RoundingMode.HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency()); } BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO @@ -109,7 +111,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { //携程满减 if (StringUtils.equals(couponInfo.getString("type"), "31")) { BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount"); - if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) { + if (paymentInfo.getCurrency() == Currency.CNY) { actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency()); } paymentInfo.setDiscount(currentDiscount.add(actureAmount)); @@ -127,15 +129,15 @@ public class CtripCouponProvideProcessor implements PaymentProcessor { payCouponAccuessLogMapper.save(couponAccuessLog); JSONObject updateOrder = new JSONObject(); - BigDecimal customerPay = paymentInfo.getUserPayAmount(); - updateOrder.put("customer_payment_amount", customerPay); + Money customerPay = paymentInfo.getUserPayAmount(); + updateOrder.put("customer_payment_amount", customerPay.getAmount()); BigDecimal couponDiscount = paymentInfo.getDiscount(); updateOrder.put("coupon_payment_amount", couponDiscount); updateOrder.put("order_id", paymentInfo.getOrderId()); pmtOrderMapper.update(updateOrder); - order.put("customer_payment_amount", customerPay); + order.put("customer_payment_amount", customerPay.getAmount()); order.put("coupon_payment_amount", couponDiscount); } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java index 820fb48ab..8f91bc885 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/refund/impls/RefundServiceImpl.java @@ -1,7 +1,6 @@ package au.com.royalpay.payment.manage.tradelog.refund.impls; import au.com.royalpay.payment.core.PaymentApi; -import au.com.royalpay.payment.core.beans.OperatorType; import au.com.royalpay.payment.core.exceptions.RefundExistException; import au.com.royalpay.payment.manage.analysis.beans.RefundReviewBean; import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper; @@ -16,6 +15,7 @@ import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.tradelog.refund.RefundService; import au.com.royalpay.payment.manage.tradelog.refund.events.NewRefundReviewEvent; import au.com.royalpay.payment.manage.tradelog.refund.events.RefundRefunseEvent; +import au.com.royalpay.payment.tools.defines.OperatorType; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.mappers.SysConfigMapper; import au.com.royalpay.payment.tools.exceptions.BadRequestException; diff --git a/src/main/ui/static/images/TNGeWalletLogo.png b/src/main/ui/static/images/TNGeWalletLogo.png new file mode 100644 index 000000000..996246f48 Binary files /dev/null and b/src/main/ui/static/images/TNGeWalletLogo.png differ diff --git a/src/main/ui/static/images/alipay-hk.png b/src/main/ui/static/images/alipay-hk.png new file mode 100644 index 000000000..bda566201 Binary files /dev/null and b/src/main/ui/static/images/alipay-hk.png differ diff --git a/src/main/ui/static/images/bkash-logo.png b/src/main/ui/static/images/bkash-logo.png new file mode 100644 index 000000000..3ce352843 Binary files /dev/null and b/src/main/ui/static/images/bkash-logo.png differ diff --git a/src/main/ui/static/images/dana-wallet-logo.png b/src/main/ui/static/images/dana-wallet-logo.png new file mode 100644 index 000000000..a90dd07c1 Binary files /dev/null and b/src/main/ui/static/images/dana-wallet-logo.png differ diff --git a/src/main/ui/static/images/easypasia-logo.png b/src/main/ui/static/images/easypasia-logo.png new file mode 100644 index 000000000..1ed1ec466 Binary files /dev/null and b/src/main/ui/static/images/easypasia-logo.png differ diff --git a/src/main/ui/static/images/ezlink-logo.png b/src/main/ui/static/images/ezlink-logo.png new file mode 100644 index 000000000..3b516cb83 Binary files /dev/null and b/src/main/ui/static/images/ezlink-logo.png differ diff --git a/src/main/ui/static/images/gcash-logo.png b/src/main/ui/static/images/gcash-logo.png new file mode 100644 index 000000000..56fa64cbd Binary files /dev/null and b/src/main/ui/static/images/gcash-logo.png differ diff --git a/src/main/ui/static/images/kakaopay.png b/src/main/ui/static/images/kakaopay.png new file mode 100644 index 000000000..4142019ca Binary files /dev/null and b/src/main/ui/static/images/kakaopay.png differ diff --git a/src/main/ui/static/images/lazada-logo.png b/src/main/ui/static/images/lazada-logo.png new file mode 100644 index 000000000..b91c1f5f0 Binary files /dev/null and b/src/main/ui/static/images/lazada-logo.png differ diff --git a/src/main/ui/static/images/paytm-logo.png b/src/main/ui/static/images/paytm-logo.png new file mode 100644 index 000000000..8488f6bf5 Binary files /dev/null and b/src/main/ui/static/images/paytm-logo.png differ diff --git a/src/main/ui/static/images/truemoney-logo.png b/src/main/ui/static/images/truemoney-logo.png new file mode 100644 index 000000000..f2f7010f6 Binary files /dev/null and b/src/main/ui/static/images/truemoney-logo.png differ diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 2fda3e242..fe48aea7a 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2,410 +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; - } - } - }; - 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', { + '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', { url: '/{clientMoniker}/edit', params: {"commitCardPayment": false, "commitCrossBorderPayment": false}, templateUrl: 'static/payment/partner/templates/partner_edit.html', @@ -415,541 +464,574 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return $http.get('/sys/partners/' + $stateParams.clientMoniker); }] } - })*/; - }]); - 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; - } - } - - if (hasRole()) { - $scope.role = sessionStorage.getItem('role'); - } - - 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; - } + })*/ + }, + ]) + 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 + } + } - 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 (hasRole()) { + $scope.role = sessionStorage.getItem('role') + } - 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' }) - }); - }; - $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); - }) - } - } - }; + 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 + } - $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) { + 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 + } + } - $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(); + 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 } - $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 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.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) { + /* $scope.chooseOrg = function (org) { if (org == 'all') { delete $scope.params.org_id; $scope.showOrg = 'All' @@ -960,23 +1042,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $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.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(); } @@ -984,3132 +1064,3636 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $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 = parseInt($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' - }); - }) + }, + ]) + 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 = parseInt($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', }) - }; - $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) { + $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: 'failed to change wechat_compliance permission status', - content: resp.data.message, - type: 'error' + title: 'Success', + content: 'Succeed Imported! Please notify BD', + type: 'success', }) - }) - }; - $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) { + $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: 'failed to change local_merchant permission status', - content: resp.data.message, - type: 'error' + title: 'Success', + content: 'Succeed Imported! Please notify BD', + type: 'success', }) - }) - }; - - $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' }); + $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', }) - }; - - $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' }); + $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', }) - }; - - $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) { + $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.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 () { + } + ) + }) + } + $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.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.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 } - - $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 () { + $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.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 () { + } + ) + }) + } + + $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.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) { + } + ) + }) + } + $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.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.changeWechatCompliance = function () { + if (!$scope.partner) { + return } - $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' }) - }) + 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.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.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.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); - }) + } + ) + } + + $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 { - $scope.saveChannel(channel); + obj.name = key + obj.value = $scope.extParams[key] + obj.type = 'boolean' } - 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' - }) - }) + paramList.push(obj) + } } - $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' - }); + 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.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.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.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.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, }) - }; - $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); - } - }) + .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.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.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, }) - }; - $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' - }); + .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.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.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.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.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', }) - }; - $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' - }) + } + ) + } + + 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() + '存在微信渠道不合规信息'), }) - }; - $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' - }) + .then(function () { + $scope.saveChannel(channel) }) - }; - $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' - }) + } 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.extChangeParam = function (name, value) { - var flag = true; - $scope.convertExtParams.forEach(function (params) { - if (params.name == name && value == '' && params.type == 'string') { - flag = false; - } + } + ) + } + $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', }) - if (flag) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ext_config', { - key: name, - value: value - }).then(function () { - $scope.loadPartnerPaymentInfo(); - }) - } - + } + ) + } + $scope.togglePreRefund = function () { + if (!$scope.paymentInfo) { + return } - - $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' - }) + 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 } - - }]); - 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; - + 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.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.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.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.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.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' }); - }) - }) - } 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.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.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.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.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.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.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.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, }) - }; - $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(); + .then(function () { + $scope.loadPartnerPaymentInfo() }) - }; - $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.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', }) - }; - $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' }) + } + ) + } + }, + ]) + 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.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(); - }]); - 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.switchChildEachRefund = function () { + if (!$scope.partner) { + return } - $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; + 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.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.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: '启用收支分离模式清算将使消费者支付手续费模式失效,请确认是否切换?', }) - }; - $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; - } + .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' }) } - }).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' }) + } else { + commonDialog + .confirm({ + title: 'Warning', + content: '请确认是否切换成净值清算模式?', }) - }; - $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; - } + .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' }) } - }).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' }) - }) + } + } + $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?', }) - }; - }]); - 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; + .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() + }) + }) }) - } - }]); - 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; + } 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() + }) }) } - }]); - 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.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); + } + $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 { - $scope.loadTradeLogs(1); + commonDialog.alert({ title: 'Error', content: '请先填写BSB No', type: 'error' }) } - $scope.checkSubClientChoseShow = function (client) { - $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient; - if (client != '') { - $scope.choseSubClientNow = client.short_name; - } + } + $scope.getRates() + $scope.saveBankAccount = function () { + if (isNaN($scope.bankaccount.account_no)) { + alert('Account No应输入数字!') + return } - $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; - } - } - }) + $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 = {} } - }]); - 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' }); - }) + $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() + }, + ]) + 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('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 + } }) - }; - $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'); + if (!exist) { + params.gatewayChild = null } - 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 { + 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 { - $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.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 } - }]); - 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.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) { if (org == 'all') { $scope.chooseOrg.org_name = null; $scope.showOrg = 'All' @@ -4121,639 +4705,743 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } };*/ - 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; - }) + 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() } - - } - } - }]); - 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'); + }) + $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 { - $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; + 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 + } + ) + } } - - //上传账单流水 - $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' }) + } + }, + ]) + 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.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(); - $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' }); - }) + $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) + } + ) + } } - - 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' }) + } + $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.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' }) + $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.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' }) + $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.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' }) + $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.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.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() + $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'}) @@ -4776,611 +5464,701 @@ 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.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' }); - }) + $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) + } + ) + } } + } - function commitError() { + $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: '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' }); - }) + title: 'Success', + content: 'Upload Successful', + type: 'success', }) - }; - - }]); - - 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; + $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 = {} } - - $scope.idIsImage = true; - if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false; + $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.billIsImage = true; - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.billIsImage = false; + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } } - - //上传ID信息 - $scope.uploadIDFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) + } + $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.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' }) + $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.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.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 () { + /* $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.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' }); + $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 = {} } - - 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; + $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.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.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 = '&' } - $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) { + 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) { if (file != null) { Upload.upload({ url: '/attachment/files', @@ -5402,1876 +6180,2056 @@ 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"; + }, + ]) + 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 { - $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(); - }); - } + $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 () { - $scope.loadSubMerchantInfos(); + } + }, + ]) + // 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 () { + $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', }) - }; - // 刷新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) { + $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: 'Wechat Apply Status(' + resp.data.apply_status + ")", - content: resp.data.response_str, - type: 'info' + title: 'Failed to change common_sub_merchant_id permission status', + content: resp.data.message, + type: 'error', }) - $scope.loadPartnerInfo(); - }, function (resp) { - commonDialog.alert({ title: 'Error', 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', }) - } - // 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'); - }] + $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' }) } + ) }) - }; - // 刷新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' - }) - }) + }) + } + // 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' }) } + ) }) - }; - // 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' }); + }) + } + // 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', }) - }; - // 刷新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' }); + $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', }) - } - // 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.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, }) - }; - // 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({ + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/applyMWMerchantId').then( + function (res) { + 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 - } + 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' }) } - }).result.then(function () { - commonDialog.alert({ - title: 'Success', - content: 'Modify successfully', - type: 'success' - }); - $scope.loadPartnerInfo(); + ) }) + }) + } + + $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 } - // 卡支付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) { + $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 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(); - }) - } - // $scope.useRpaySubMerchantId = function (sub_merchant_id) { - // $http.put('/sys/partners/' + $scope.partner.client_moniker + '/rpay_payment_config', { rpay_enterprise_id: sub_merchant_id }).then(function (resp) { - // 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' }) - // }); - // } - // $scope.useYeepaySubMerchantId = function (sub_merchant_id) { - // $http.put('/sys/partners/' + $scope.partner.client_moniker + '/yeepay_payment_config', { yeepay_sub_merchant_id: sub_merchant_id }).then(function (resp) { - // 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' }) - // }); - // } - // $scope.applyWxSubMerchantId = function () { - // $uibModal.open({ - // templateUrl: '/static/payment/partner/templates/apply_wx_sub_merchant_id.html', - // controller: 'applyWxSubMerchantIdCtrl', - // 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(); - // }) - // }; - // $scope.applyRpaySubMerchantId = function () { - // $uibModal.open({ - // templateUrl: '/static/payment/partner/templates/apply_rpay_sub_merchant_id.html', - // controller: 'applyRpaySubMerchantIdCtrl', - // resolve: { - // subMerchantInfo: function () { - // return $scope.partner; - // } - // } - // }).result.then(function () { - // $scope.loadSubMerchantInfos(); - // }) - // }; - // $scope.applyYeepaySubMerchantId = function () { - // $uibModal.open({ - // templateUrl: '/static/payment/partner/templates/apply_yeepay_sub_merchant_id.html', - // controller: 'applyYeepaySubMerchantIdCtrl', - // resolve: { - // subMerchantInfo: function () { - // return $scope.partner; - // } - // } - // }).result.then(function () { - // $scope.loadSubMerchantInfos(); - // }) - // }; - // $scope.addYeepaySubMerchantId = function () { - // $uibModal.open({ - // templateUrl: '/static/payment/partner/templates/add_yeepay_sub_merchant_id.html', - // controller: 'addYeepaySubMerchantIdCtrl', - // resolve: { - // subMerchantInfo: function () { - // return $scope.partner; - // } - // } - // }).result.then(function () { - // $scope.loadSubMerchantInfos(); - // }) - // }; - // $scope.updateYeepaySubMerchantId = function (sub_merchant_id) { - // $uibModal.open({ - // templateUrl: '/static/payment/partner/templates/update_yeepay_sub_merchant_id.html', - // controller: 'updateYeepaySubMerchantIdCtrl', - // resolve: { - // subMerchantInfo: function () { - // return $scope.partner; - // }, - // subMerchantId: function () { - // return sub_merchant_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' }) - }); + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', }) - } 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 + $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.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'; - } + } + }, + ]) + 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.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 { - $scope.subMerchantInfo.business_type = 'BOTH'; + var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) } + } - if ($scope.subMerchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry); + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false } - if ($scope.subMerchantInfo.mc_code) { - $scope.subMerchantInfo.mcc_code = $scope.subMerchantInfo.mc_code; + } + $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 + } } - if (subMerchantInfo.certificat_expire_date) { - var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/'); - $scope.subMerchantInfo.certificat_expire_date = new Date(datestr); + } + $scope.saveAppliy = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return } - if ($scope.subMerchantInfo.business_structure) { - $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.business_structure != 'Registered body(Sole Trader)' ? "ENTERPRISE" : "INDIVIDUAL"; + // 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 (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); - } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null } - $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; - } - } + 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.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' }) - }); + $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', }) - } 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' }) - }) + $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() + + if ($scope.subMerchantInfo.extra_merchant_type) { + $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.extra_merchant_type + } + if ($scope.subMerchantInfo.industry) { + $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry) + } + if ($scope.subMerchantInfo.mcc_code) { + $scope.subMerchantInfo.mcc_code = parseInt($scope.subMerchantInfo.mcc_code) + } + + // if($scope.subMerchantInfo.certificat_expire_date) { + // // var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/'); + // $scope.subMerchantInfo.certificat_expire_date=new Date($scope.subMerchantInfo.certificat_expire_date); + // } + if ($scope.subMerchantInfo.certificat_expire_date) { + if ($scope.subMerchantInfo.certificat_expire_date == 'PERMANENT') { + $scope.subMerchantInfo.certificat_expire_date_premanent = true + } else if ($scope.subMerchantInfo.certificat_expire_date == 'N/A') { + $scope.subMerchantInfo.certificat_expire_date_NA = true + } else { + var datestr = $scope.subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) } - }]); - 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(); - - if($scope.subMerchantInfo.extra_merchant_type ){ - $scope.subMerchantInfo.merchant_type=$scope.subMerchantInfo.extra_merchant_type; + } + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false } - if($scope.subMerchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry); + } + $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 + } } - if($scope.subMerchantInfo.mcc_code ){ - $scope.subMerchantInfo.mcc_code=parseInt($scope.subMerchantInfo.mcc_code); + } + $scope.updateApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return } - - // if($scope.subMerchantInfo.certificat_expire_date) { - // // var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/'); - // $scope.subMerchantInfo.certificat_expire_date=new Date($scope.subMerchantInfo.certificat_expire_date); - // } - if($scope.subMerchantInfo.certificat_expire_date) { - if( $scope.subMerchantInfo.certificat_expire_date=="PERMANENT"){ - $scope.subMerchantInfo.certificat_expire_date_premanent=true; - }else if( $scope.subMerchantInfo.certificat_expire_date=="N/A"){ - $scope.subMerchantInfo.certificat_expire_date_NA=true; - }else { - var datestr = $scope.subMerchantInfo.certificat_expire_date.replace(/-/g, '/'); - $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr); - } + 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, } - $scope.checkExpriedate=function (value) { - if(value){ - $scope.subMerchantInfo.certificat_expire_date_premanent=false; - $scope.subMerchantInfo.certificat_expire_date_NA=false; - } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null } - $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; - } - } + // 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 + } } - $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, - }; - 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' - }); + $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) + } + ) + } } - }]); - 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.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.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.saveYeepayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true } - }; - - // $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); - // }) + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; // } // } - // }; - // - // $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); - // }) + // }); + 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('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; // } // } - // }; - - $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.saveYeepayApply = 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['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' - }); + // }); + + 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', }) - } - }]); - 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' - }); + $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) + } + ) + } } - }]); - 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.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.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.updateYeepayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true } - }; - - // $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); - // }) + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; // } // } - // }; - - $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.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(); - }) - } + // }); + 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('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); - } + } + ) + } + }, + ]) + 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() } - $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({ + 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: $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' }); - }) - + 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) } - }]) - - - 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 '其他'; - } + } + $scope.initData() + $scope.save = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + 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 '保险'; - } + $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.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' - } + }) + 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 } - }); - - 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 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); - } - } - 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; - }; + 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 app; -}); + }) + return app +}) diff --git a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html index 70dd618a8..8928a2b20 100644 --- a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html +++ b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html @@ -7,36 +7,37 @@ padding: 20px; border: 1px solid orange; background-color: white; - z-index:1002; + z-index: 1002; overflow: auto; } + .white_content::-webkit-scrollbar:vertical { width: 11px; } + /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ - .white_content::-webkit-scrollbar - { + .white_content::-webkit-scrollbar { -webkit-appearance: none; - width:16px; - height:16px; - background-color:#F5F5F5; + width: 16px; + height: 16px; + background-color: #F5F5F5; } + /*定义滚动条轨道 内阴影+圆角*/ - .white_content::-webkit-scrollbar-track - { - -webkit-box-shadow:inset 0 0 6px rgba(0,0,0,0.3); - border-radius:10px; - background-color:#F5F5F5; + .white_content::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); + border-radius: 10px; + background-color: #F5F5F5; } + /*定义滑块 内阴影+圆角*/ - .white_content::-webkit-scrollbar-thumb - { - border-radius:10px; - -webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3); - background-color:#555; + .white_content::-webkit-scrollbar-thumb { + border-radius: 10px; + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3); + background-color: #555; }
@@ -56,7 +57,7 @@
+ ng-model="params.searchText">
@@ -64,15 +65,15 @@

All | + ng-click="params.status='ALL';loadTradeLogs(1)">All | Payment Success | + ng-click="params.status='PAID';loadTradeLogs(1)">Payment Success | All Refund | + ng-click="params.status='ALL_REFUNDED';loadTradeLogs(1)">All Refund | Partial Refund | + ng-click="params.status='PARTIAL_REFUNDED';loadTradeLogs(1)">Partial Refund | Full Refund | + ng-click="params.status='FULL_REFUNDED';loadTradeLogs(1)">Full Refund |

@@ -81,53 +82,53 @@

All | + ng-click="params.gateway=null;loadTradeLogs(1)">All | Retail In-Store | + ng-click="params.gateway=[0,1];initGatewayChild()">Retail In-Store | Retail API | + ng-click="params.gateway=[5,6];initGatewayChild()">Retail API | QR Code | + ng-click="params.gateway=[2,7];loadTradeLogs(1)">QR Code | Online API | + ng-click="params.gateway=[3];loadTradeLogs(1)">Online API | WeChat HTML5 | + ng-click="params.gateway=[4];loadTradeLogs(1)">WeChat HTML5 | Mobile H5 | + ng-click="params.gateway=[8];loadTradeLogs(1)">Mobile H5 | Third Party Gateway | + ng-click="params.gateway=[9];loadTradeLogs(1)">Third Party Gateway | APP | + ng-click="params.gateway=[10];loadTradeLogs(1)">APP | Share Code | + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | MiniProgram | + ng-click="params.gateway=[12];loadTradeLogs(1)">MiniProgram | Native QR Code | + ng-click="params.gateway=[13];loadTradeLogs(1)">Native QR Code | Share Link + ng-click="params.gateway=[14];loadTradeLogs(1)">Share Link

+ ng-if="params.gateway.sort().toString()==[0,1] || params.gateway.sort().toString()==[5,6]">

All | + ng-click="params.gatewayChild=null;loadTradeLogs(1)">All | 线下B端二维码 | + ng-class="{'bg-primary':params.gatewayChild==1}" + ng-click="params.gatewayChild=1;loadTradeLogs(1)">线下B端二维码 | 线下C端支付码 + ng-class="{'bg-primary':params.gatewayChild==0}" + ng-click="params.gatewayChild=0;loadTradeLogs(1)">线下C端支付码 线下网关(B端二维码) | + ng-class="{'bg-primary':params.gatewayChild==6}" + ng-click="params.gatewayChild=6;loadTradeLogs(1)">线下网关(B端二维码) | 线下网关(C端支付码) + ng-class="{'bg-primary':params.gatewayChild==5}" + ng-click="params.gatewayChild=5;loadTradeLogs(1)">线下网关(C端支付码)

@@ -136,29 +137,31 @@

All | + ng-click="params.channel='ALL';loadTradeLogs(1)">All | Wechat Pay | + ng-click="params.channel='WECHAT';loadTradeLogs(1)">Wechat Pay | Alipay | + ng-click="params.channel='ALIPAY';loadTradeLogs(1)">Alipay | AlipayOnline | + ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline | + Alipay+ | BestPay | + ng-click="params.channel='BESTPAY';loadTradeLogs(1)">BestPay | JDpay | + ng-click="params.channel='JD';loadTradeLogs(1)">JDpay | HFpay | + ng-click="params.channel='HF';loadTradeLogs(1)">HFpay | RPay + | + ng-click="params.channel='RPAY';loadTradeLogs(1)">RPay + | Yeepay | + ng-click="params.channel='YEEPAY';loadTradeLogs(1)">Yeepay | LakalaPay | + ng-click="params.channel='LAKALAPAY';loadTradeLogs(1)">LakalaPay | Card Payment | + ng-click="params.channel='RPAYPMT_CARD';loadTradeLogs(1)">Card Payment | Direct Debit + ng-click="params.channel='RPAYPMT_DD';loadTradeLogs(1)">Direct Debit

@@ -168,29 +171,24 @@
+ uib-datepicker-popup size="10" placeholder="From" is-open="dateBegin.open" + ng-click="dateBegin.open=true" datepicker-options="{maxDate:params.dateto||today}">
~
- +
- Today + Today
@@ -213,25 +211,26 @@ All

- All -

-
+
- +
-
@@ -240,77 +239,75 @@
- - - - - + + + + + - - - - + + - + + + +
Partner CodePartner NameOperation
Partner CodePartner NameOperation
- {{subPartner.client_moniker}} - - + {{subPartner.client_moniker}} + + -
- - - - - + + + + + - - - - + + - + + + +
Partner CodePartner NameOperation
Partner CodePartner NameOperation
- {{subPartner.client_moniker}} - - + {{subPartner.client_moniker}} + + -
@@ -319,10 +316,12 @@

- All + All

@@ -337,84 +336,140 @@

Orders - (Found {{pagination.totalCount}} orders and {{analysis.order_count}} transactions worth of {{analysis.paid_fee|currency:'AUD'}}) - Pre Authorization: + (Found {{pagination.totalCount}} orders and + {{analysis.order_count}} transactions worth of {{analysis.paid_fee|currency:'AUD'}}) + Pre Authorization:

- + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + +
Client Order IDOrder IDAmountInput AmountAUD AmountExchange RateStatusCreate TimeGatewayOperation
Client Order IDOrder IDAmountInput AmountAUD AmountExchange RateStatusCreate TimeGatewayOperation
- - - - - - - - - - - - - {{trade.order_id}} - - {{trade.total_amount|currency:trade.currency+' '}} - (-{{trade.refund_fee}}) - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{trade.order_id}} + + {{trade.total_amount|currency:trade.currency+' '}} + (-{{trade.refund_fee}}) + + + - + + + + + + + +
- +
Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}
-
+
\ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index ee507d95d..68c9c0692 100644 --- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html @@ -218,21 +218,21 @@
+ ng-change="toggleChannel('alipay')">
+ ng-change="toggleChannel('wechat')">
+ ng-change="toggleChannel('cb_bankpay')">
@@ -240,17 +240,23 @@
+ ng-change="toggleChannel('rpaypmt_card')">
+ ng-change="toggleChannel('rpaypmt_dd')"> +
+
+
+ +
+
- @@ -370,6 +376,14 @@

+
+ +
+ +
+
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 49fa74723..1e3747d0f 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 @@ -9,23 +9,28 @@ .i-rotate_90 { animation: rotate_90 1s forwards; - -webkit-animation: rotate_90 1s forwards; /* Safari and Chrome */ + -webkit-animation: rotate_90 1s forwards; + /* Safari and Chrome */ } @keyframes rotate_90 { from { transform: rotate(0deg); } + to { transform: rotate(90deg); } } - @-webkit-keyframes rotate_90 /* Safari and Chrome */ - { + @-webkit-keyframes rotate_90 + + /* Safari and Chrome */ + { from { -webkit-transform: rotate(0deg); } + to { -webkit-transform: rotate(90deg); } @@ -78,6 +83,7 @@ .line_height_ { line-height: 22px; } + .white_content { display: none; position: absolute; @@ -86,36 +92,37 @@ padding: 20px; border: 1px solid orange; background-color: white; - z-index:1002; + z-index: 1002; overflow: auto; } + .white_content::-webkit-scrollbar:vertical { width: 11px; } + /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ - .white_content::-webkit-scrollbar - { + .white_content::-webkit-scrollbar { -webkit-appearance: none; - width:16px; - height:16px; - background-color:#F5F5F5; + width: 16px; + height: 16px; + background-color: #F5F5F5; } + /*定义滚动条轨道 内阴影+圆角*/ - .white_content::-webkit-scrollbar-track - { - -webkit-box-shadow:inset 0 0 6px rgba(0,0,0,0.3); - border-radius:10px; - background-color:#F5F5F5; + .white_content::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); + border-radius: 10px; + background-color: #F5F5F5; } + /*定义滑块 内阴影+圆角*/ - .white_content::-webkit-scrollbar-thumb - { - border-radius:10px; - -webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3); - background-color:#555; + .white_content::-webkit-scrollbar-thumb { + border-radius: 10px; + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3); + background-color: #555; }
@@ -154,8 +161,7 @@
+ ng-enter="loadTradeLogs(1)" ng-model="params.searchText">
@@ -163,11 +169,11 @@

All | + ng-click="params.source='ALL';loadTradeLogs(1)">All | System | + ng-click="params.source='system';loadTradeLogs(1)">System | RP跨境商城 + ng-click="params.source='RP跨境商城';loadTradeLogs(1)">RP跨境商城

@@ -176,20 +182,20 @@ @@ -199,21 +205,27 @@

All | + ng-click="params.channel='ALL';loadTradeLogs(1)">All | Wechat Pay | + ng-click="params.channel='WECHAT';loadTradeLogs(1)">Wechat Pay | Alipay | + ng-click="params.channel='ALIPAY';loadTradeLogs(1)">Alipay | AlipayOnline + ng-class="{'bg-primary':params.channel=='ALIPAYONLINE'}" + ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline + | + Alipay+ | RPay+ | - Card Payment | + ng-click="params.channel='RPAY';loadTradeLogs(1)">RPay+ | + Card + Payment | Direct Debit + ng-click="params.channel='RPAYPMT_DD';loadTradeLogs(1)">Direct + Debit

@@ -222,55 +234,55 @@

All | + ng-click="params.gateway=null;loadTradeLogs(1)">All | Retail + ng-click="params.gateway=[0,1];initGatewayChild()">Retail In-Store | Retail API | + ng-click="params.gateway=[5,6];initGatewayChild()">Retail API | QR Code | + ng-click="params.gateway=[2,7];loadTradeLogs(1)">QR Code | Online API | + ng-click="params.gateway=[3];loadTradeLogs(1)">Online API | WeChat HTML5 | + ng-click="params.gateway=[4];loadTradeLogs(1)">WeChat HTML5 | Mobile H5 | + ng-click="params.gateway=[8];loadTradeLogs(1)">Mobile H5 | Third Party + ng-click="params.gateway=[9];loadTradeLogs(1)">Third Party Gateway | APP | + ng-click="params.gateway=[10];loadTradeLogs(1)">APP | Share Code | + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | MiniProgram | + ng-click="params.gateway=[12];loadTradeLogs(1)">MiniProgram | Native QR Code | + ng-click="params.gateway=[13];loadTradeLogs(1)">Native QR Code | Share Link + ng-click="params.gateway=[14];loadTradeLogs(1)">Share Link

+ ng-if="params.gateway.sort().toString()==[0,1] || params.gateway.sort().toString()==[5,6]">

All | + ng-click="params.gatewayChild=null;loadTradeLogs(1)">All | 线下B端二维码 | + ng-class="{'bg-primary':params.gatewayChild==1}" + ng-click="params.gatewayChild=1;loadTradeLogs(1)">线下B端二维码 | 线下C端支付码 + ng-class="{'bg-primary':params.gatewayChild==0}" + ng-click="params.gatewayChild=0;loadTradeLogs(1)">线下C端支付码 线下网关(B端二维码) | + ng-class="{'bg-primary':params.gatewayChild==6}" + ng-click="params.gatewayChild=6;loadTradeLogs(1)">线下网关(B端二维码) | 线下网关(C端支付码) + ng-class="{'bg-primary':params.gatewayChild==5}" + ng-click="params.gatewayChild=5;loadTradeLogs(1)">线下网关(C端支付码)

@@ -280,39 +292,39 @@
+ ng-model="params.datefrom" uib-datepicker-popup size="10" + placeholder="From" is-open="dateBegin.open" + ng-click="dateBegin.open=true" + datepicker-options="{maxDate:params.dateto||today}">
~
+ ng-model="params.dateto" uib-datepicker-popup size="10" + placeholder="To" is-open="dateTo.open" + ng-click="dateTo.open=true" + datepicker-options="{minDate:params.datefrom,maxDate:today}">
Today + ng-click="chooseToday()">Today
Yesterday + ng-click="chooseYesterday()">Yesterday
Last 7 Days + ng-click="chooseLast7Days()">Last 7 Days
This Month + ng-click="thisMonth()">This Month
Last Month + ng-click="lastMonth()">Last Month
@@ -320,148 +332,160 @@
+ ng-if="currentUser.client.has_children && !currentUser.client.hide_sub_mch">

All + ng-click="chooseClient('all')">All

All -

-
+
+ ng-model="subSearchText">
-
- +
- - - - - + + + + + - - - - + + - + + + +
Partner CodePartner NameOperation
Partner CodePartner NameOperation
- {{subPartner.client_moniker}} - - + {{subPartner.client_moniker}} + + -
- +
- - - - - + + + + + - - - - + + - + + + +
Partner CodePartner NameOperation
Partner CodePartner NameOperation
- {{subPartner.client_moniker}} - - + {{subPartner.client_moniker}} + + -
-
+ ng-if="level3Clients && showLevel3Clients && !currentUser.client.hide_sub_mch">

All + ng-click="chooseLevel3Client('all')">All

+ ng-if="deviceIds.length && !currentUser.client.hide_sub_mch">

All + ng-click="chooseDeviceIds('all')">All

@@ -471,11 +495,11 @@

All + ng-click="chooseDevices('all')">All

@@ -498,7 +522,7 @@
Transaction Amount + ng-bind="analysis.paid_fee|currency:'AUD '"> ( {{analysis.order_count}} Orders )
@@ -511,30 +535,31 @@
Input Amount - ( {{analysis.pre_display_amount | currency:'pre authorization '}} ) + ng-bind="analysis.display_amount|currency:'AUD '"> + ( {{analysis.pre_display_amount | currency:'pre + authorization '}} )
+ ng-class="{'line_height':analysis.pre_display_amount||analysis.pre_cny_display_amount}">
Input Amount + ng-class="{line_height_:!analysis.pre_display_amount}" + ng-bind="analysis.display_amount|currency:'AUD '"> + ng-if="analysis.pre_display_amount"> ( {{analysis.pre_display_amount | currency:'pre authorization '}} ) + ng-if="analysis.cny_display_amount" + ng-bind="analysis.cny_display_amount|currency:'CNY '"> + ng-if="analysis.pre_cny_display_amount"> ( {{analysis.pre_cny_display_amount | currency:'pre authorization '}} )
@@ -547,9 +572,9 @@
Refund Amount + ng-bind="analysis.refund_fee|currency:'AUD '"> - ({{analysis.pre_refund_fee|currency:'pre authorization '}}) + ({{analysis.pre_refund_fee|currency:'pre authorization '}})
@@ -561,7 +586,7 @@
CUSTOMERS + ng-bind="analysis.customers">
@@ -572,132 +597,194 @@

Orders - Pre Authorization: - - - - + Pre Authorization: + + + +

- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
Client MonikerShort NameClient Order IDOrder IDAmountInput AmountAUD AmountSettle AmountExchange RateStatusCreate TimeGatewayOrder DetailOperation
Client MonikerShort NameClient Order IDOrder IDAmountInput AmountAUD AmountSettle AmountExchange RateStatusCreate TimeGatewayOrder DetailOperation
- - - - - - - BestPay - Alipay - AlipayOnline - - - - - - - - {{trade.order_id}} - - {{trade.total_amount|currency:trade.currency+' '}} - (-{{trade.refund_fee}}) - - - - - - - - - - - - - - - - -
+ + + + + + + BestPay + Alipay + AlipayOnline + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{trade.order_id}} + + {{trade.total_amount|currency:trade.currency+' '}} + (-{{trade.refund_fee}}) + + + - + + + + + + + + + + + + +
- + \ No newline at end of file diff --git a/src/main/ui/static/payment/tradelog/templates/trade_logs.html b/src/main/ui/static/payment/tradelog/templates/trade_logs.html index 714798fa0..0f628ab0c 100644 --- a/src/main/ui/static/payment/tradelog/templates/trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/trade_logs.html @@ -95,24 +95,23 @@
+ ng-enter="loadTradeLogs(1)" ng-model="params.searchText">
+ class="col-sm-6">
@@ -147,11 +146,11 @@

All | + ng-click="params.source='ALL';loadTradeLogs(1)">All | System | + ng-click="params.source='system';loadTradeLogs(1)">System | RP跨境商城 + ng-click="params.source='RP跨境商城';loadTradeLogs(1)">RP跨境商城

@@ -160,20 +159,20 @@ @@ -183,31 +182,38 @@

All | + ng-click="params.channel='ALL';loadTradeLogs(1)">All | Wechat Pay | + ng-click="params.channel='WECHAT';loadTradeLogs(1)">Wechat Pay | Alipay | + ng-click="params.channel='ALIPAY';loadTradeLogs(1)">Alipay | AlipayOnline + ng-class="{'bg-primary':params.channel=='ALIPAYONLINE'}" + ng-click="params.channel='ALIPAYONLINE';loadTradeLogs(1)">AlipayOnline + | + Alipay+ | BestPay | + ng-click="params.channel='BESTPAY';loadTradeLogs(1)">BestPay | JD Pay | + ng-click="params.channel='JD';loadTradeLogs(1)">JD Pay | HF Pay | + ng-click="params.channel='HF';loadTradeLogs(1)">HF Pay | RPay + | + ng-click="params.channel='RPAY';loadTradeLogs(1)">RPay + | Yeepay | + ng-click="params.channel='YEEPAY';loadTradeLogs(1)">Yeepay | LakalaPay | - Card Payment | + ng-click="params.channel='LAKALAPAY';loadTradeLogs(1)">LakalaPay + | + Card + Payment | Direct Debit + ng-click="params.channel='RPAYPMT_DD';loadTradeLogs(1)">Direct + Debit

@@ -216,55 +222,57 @@

All | + ng-click="params.gateway=null;loadTradeLogs(1)">All | Retail In-Store + ng-click="params.gateway=[0,1];initGatewayChild()">Retail + In-Store | Retail API | + ng-click="params.gateway=[5,6];loadTradeLogs(1);initGatewayChild()">Retail + API | QR Code | + ng-click="params.gateway=[2,7];loadTradeLogs(1)">QR Code | Online API | + ng-click="params.gateway=[3];loadTradeLogs(1)">Online API | WeChat HTML5 | + ng-click="params.gateway=[4];loadTradeLogs(1)">WeChat HTML5 | Mobile H5 | + ng-click="params.gateway=[8];loadTradeLogs(1)">Mobile H5 | Third Party + ng-click="params.gateway=[9];loadTradeLogs(1)">Third Party Gateway | APP | + ng-click="params.gateway=[10];loadTradeLogs(1)">APP | Share Code | + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | MiniProgram | + ng-click="params.gateway=[12];loadTradeLogs(1)">MiniProgram | Native QR Code | + ng-click="params.gateway=[13];loadTradeLogs(1)">Native QR Code | Share Link + ng-click="params.gateway=[14];loadTradeLogs(1)">Share Link

+ ng-if="params.gateway.sort().toString()==[0,1] || params.gateway.sort().toString()==[5,6]">

All | + ng-click="params.gatewayChild=null;loadTradeLogs(1)">All | 线下B端二维码 | + ng-class="{'bg-primary':params.gatewayChild==1}" + ng-click="params.gatewayChild=1;loadTradeLogs(1)">线下B端二维码 | 线下C端支付码 + ng-class="{'bg-primary':params.gatewayChild==0}" + ng-click="params.gatewayChild=0;loadTradeLogs(1)">线下C端支付码 线下网关(B端二维码) | + ng-class="{'bg-primary':params.gatewayChild==6}" + ng-click="params.gatewayChild=6;loadTradeLogs(1)">线下网关(B端二维码) | 线下网关(C端支付码) + ng-class="{'bg-primary':params.gatewayChild==5}" + ng-click="params.gatewayChild=5;loadTradeLogs(1)">线下网关(C端支付码)

@@ -274,39 +282,39 @@
+ ng-model="params.datefrom" uib-datepicker-popup size="10" + placeholder="From" is-open="dateBegin.open" + ng-click="dateBegin.open=true" + datepicker-options="{maxDate:params.dateto||today}">
~
+ ng-model="params.dateto" uib-datepicker-popup size="10" + placeholder="To" is-open="dateTo.open" + ng-click="dateTo.open=true" + datepicker-options="{minDate:params.datefrom,maxDate:today}">
Today + ng-click="chooseToday()">Today
Yesterday + ng-click="chooseYesterday()">Yesterday
Last 7 Days + ng-click="chooseLast7Days()">Last 7 Days
This Month + ng-click="thisMonth()">This Month
Last Month + ng-click="lastMonth()">Last Month
@@ -316,11 +324,11 @@

All + ng-click="chooseBD('all')">All

@@ -351,7 +359,7 @@
Transaction Amount + ng-bind="analysis.paid_fee|currency:'AUD'"> ( {{analysis.order_count}} Orders )
@@ -363,30 +371,31 @@
Input Amount - ( {{analysis.pre_display_amount | currency:'pre authorization '}} ) + ng-bind="analysis.display_amount|currency:'AUD '"> + ( {{analysis.pre_display_amount | currency:'pre + authorization '}} )
+ ng-class="{'line_height':analysis.pre_display_amount||analysis.pre_cny_display_amount}">
Input Amount + ng-class="{line_height_:!analysis.pre_display_amount}" + ng-bind="analysis.display_amount|currency:'AUD '"> + ng-if="analysis.pre_display_amount"> ( {{analysis.pre_display_amount | currency:'pre authorization '}} ) + ng-if="analysis.cny_display_amount" + ng-bind="analysis.cny_display_amount|currency:'CNY '"> + ng-if="analysis.pre_cny_display_amount"> ( {{analysis.pre_cny_display_amount | currency:'pre authorization '}} )
@@ -399,9 +408,9 @@
Refund Amount + ng-bind="analysis.refund_fee|currency:'AUD '"> - ({{analysis.pre_refund_fee|currency:'pre authorization '}}) + ({{analysis.pre_refund_fee|currency:'pre authorization '}})
@@ -412,8 +421,7 @@ class="ion ion-ios-people">
Merchants - +
@@ -425,7 +433,7 @@
CUSTOMERS + ng-bind="analysis.customers">
@@ -436,109 +444,173 @@

Trade Orders Pre Authorization: + aria-hidden="true" style="color: #fff2a5">

+ ng-click="confirmOrders()">Manual Confirm Orders
- - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + +
PartnerOrder IDAmountInput AmountAUD AmountExchange RateStatusCreate TimeGatewayOperation
PartnerOrder IDAmountInput AmountAUD AmountExchange RateStatusCreate TimeGatewayOperation
- - {{trade.short_name}}({{trade.client_moniker}}) - - - - - - - - - - - - - - - - - {{trade.order_id}} - - {{trade.total_amount|currency:trade.currency}} - (-{{trade.refund_fee}}) - - - - - - - - - - - -
+ + {{trade.short_name}}({{trade.client_moniker}}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{trade.order_id}} + + {{trade.total_amount|currency:trade.currency}} + (-{{trade.refund_fee}}) + + + - + + + + + + + +
- +
Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}} @@ -549,4 +621,4 @@
- + \ No newline at end of file diff --git a/src/main/ui/static/templates/alipay/v1/payment.js b/src/main/ui/static/templates/alipay/v1/payment.js index db74dc68c..9f846d9df 100644 --- a/src/main/ui/static/templates/alipay/v1/payment.js +++ b/src/main/ui/static/templates/alipay/v1/payment.js @@ -268,6 +268,10 @@ $(function () { location.href = '/api/v1.0/alipay/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 { diff --git a/src/main/ui/static/templates/alipay/v4/payment.js b/src/main/ui/static/templates/alipay/v4/payment.js index 8585cc64c..43c4c0012 100644 --- a/src/main/ui/static/templates/alipay/v4/payment.js +++ b/src/main/ui/static/templates/alipay/v4/payment.js @@ -313,6 +313,10 @@ $(function () { location.href = '/api/v1.0/alipay/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 { diff --git a/src/main/ui/static/templates/alipay/v5/payment.js b/src/main/ui/static/templates/alipay/v5/payment.js index 263cf63db..c43709374 100644 --- a/src/main/ui/static/templates/alipay/v5/payment.js +++ b/src/main/ui/static/templates/alipay/v5/payment.js @@ -276,6 +276,10 @@ $(function () { location.href = '/api/v1.0/alipay/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 { diff --git a/uidocker/conf.d/default.conf b/uidocker/conf.d/default.conf index 9bbf8bfde..ea284d694 100644 --- a/uidocker/conf.d/default.conf +++ b/uidocker/conf.d/default.conf @@ -68,7 +68,7 @@ server { } - location ~ ^/api/v1.0/((alipay_connect)|(customs)|(alipay)|(rpay)|(yeepay)|(card_payment_view)|(lakala_pay)|(cb_bankpay)|(bestpay)|(hf)|(wechat_jsapi_gateway)|(h5_payment)|(gateway)|(hf_gateway)|(jd_gateway)|(micropay)|(retail_qrcode)|(jsapi_gateway)|(share_code)|(payment))/ { + location ~ ^/api/v1.0/((alipay\w*)|(customs)|(rpay)|(yeepay)|(card_payment_view)|(lakala_pay)|(cb_bankpay)|(bestpay)|(hf)|(\w*gateway)|(micropay)|(retail_qrcode)|(share_code)|(payment))/ { proxy_pass http://rppaycenter; proxy_http_version 1.1;