From 7b0f130ffe2bef37ca1f69df28c8923e165d0e94 Mon Sep 17 00:00:00 2001 From: Todking Date: Mon, 13 Sep 2021 13:53:19 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9Eaps=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8CalipayCN=E6=B8=A0=E9=81=93=E5=88=87=E6=8D=A2=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../mappers/system/aps/ApsConfigMapper.java | 20 + .../merchants/core/ApsConfigService.java | 13 + .../core/descriptor/ApsConfigDescriptor.java | 17 + .../core/impls/ApsConfigServiceImpl.java | 38 + .../core/impls/ClientManagerImpl.java | 153 +- .../merchants/entity/ApsConfigData.java | 46 + .../merchants/web/ApsConfigController.java | 55 + .../mappers/system/aps/ApsConfigMapper.xml | 23 + .../static/payment/partner/partner-manage.js | 16485 ++++++++-------- .../templates/partner_payment_info.html | 150 +- 11 files changed, 8681 insertions(+), 8321 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/core/descriptor/ApsConfigDescriptor.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml diff --git a/pom.xml b/pom.xml index 2934cc261..d66c495f6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ au.com.royalpay.payment payment-parent - 2.2.31 + 2.3.0 4.0.0 manage diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java new file mode 100644 index 000000000..e819edb63 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.java @@ -0,0 +1,20 @@ +package au.com.royalpay.payment.manage.mappers.system.aps; + +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import com.alibaba.fastjson.JSONObject; +import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; +import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; +import com.yixsoft.support.mybatis.autosql.annotations.SqlType; +import org.apache.ibatis.annotations.Param; + +@AutoMapper(tablename = "sys_client_aps_config", pkName = "id") +public interface ApsConfigMapper { + + @AutoSql(SqlType.SELECT) + ApsConfigData findByClientId(@Param("client_id") String clientId); + + @AutoSql(SqlType.INSERT) + void saveApsConfigClientId(ApsConfigData apsConfigData); + + void updateApsConfigClientId(JSONObject apsConfigData); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java new file mode 100644 index 000000000..6fa193b6d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ApsConfigService.java @@ -0,0 +1,13 @@ +package au.com.royalpay.payment.manage.merchants.core; + +import au.com.royalpay.payment.manage.merchants.core.descriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import com.alibaba.fastjson.JSONObject; + +public interface ApsConfigService { + ApsConfigData getApsConfigByClientId(String clientId); + + ApsConfigData saveApsConfigClientId(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor); + + ApsConfigData updateApsConfigClientId(String managerId,String clientId, JSONObject apsConfig); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/descriptor/ApsConfigDescriptor.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/descriptor/ApsConfigDescriptor.java new file mode 100644 index 000000000..9274fc04c --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/descriptor/ApsConfigDescriptor.java @@ -0,0 +1,17 @@ +package au.com.royalpay.payment.manage.merchants.core.descriptor; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class ApsConfigDescriptor { + + private Boolean enableAlipayAps = false; + + private Boolean alipayCnSwitch = false; +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java new file mode 100644 index 000000000..6444876b4 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ApsConfigServiceImpl.java @@ -0,0 +1,38 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.aps.ApsConfigMapper; +import au.com.royalpay.payment.manage.merchants.core.ApsConfigService; +import au.com.royalpay.payment.manage.merchants.core.descriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + + +@Service +public class ApsConfigServiceImpl implements ApsConfigService { + + @Resource + private ApsConfigMapper apsConfigMapper; + + @Override + public ApsConfigData getApsConfigByClientId(String clientId) { + return apsConfigMapper.findByClientId(clientId); + } + + @Override + public ApsConfigData saveApsConfigClientId(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor) { + ApsConfigData apsConfigData = ApsConfigData.saveData(managerId, clientId, apsConfigDescriptor); + apsConfigMapper.saveApsConfigClientId(apsConfigData); + return apsConfigMapper.findByClientId(clientId); + } + + @Override + public ApsConfigData updateApsConfigClientId(String managerId, String clientId, JSONObject apsConfig) { + apsConfig.put("clientId", clientId); + apsConfig.put("modifier", managerId); + apsConfigMapper.updateApsConfigClientId(apsConfig); + return apsConfigMapper.findByClientId(clientId); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 209f609dc..7e016ae24 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 @@ -55,13 +55,12 @@ import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMap import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper; import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.merchants.beans.*; -import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; -import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; -import au.com.royalpay.payment.manage.merchants.core.ClientManager; -import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; +import au.com.royalpay.payment.manage.merchants.core.*; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBank; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBankClientNullException; import au.com.royalpay.payment.manage.merchants.core.bank.AustraliaBankInfo; +import au.com.royalpay.payment.manage.merchants.core.descriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; import au.com.royalpay.payment.manage.merchants.entity.impls.*; import au.com.royalpay.payment.manage.merchants.enums.UPayAuthFileEnum; import au.com.royalpay.payment.manage.notice.core.MailService; @@ -329,6 +328,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private PaymentApi paymentApi; @Resource private MerchantChannelPermissionManager merchantChannelPermissionManager; + @Resource + private ApsConfigService apsConfigService; DateTimeFormatter formatter = DateTimeFormat.forPattern("dd MMM yyyy"); @@ -356,7 +357,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private String agreetemplatePdfPath; @Value("${app.agreetemplate.aggregate.path}") private String aggregateAgreetemplatePdfPath; -// private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf"; + // private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf"; private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2021/09/07/1630997571126_fqWcLQ5Rx0wFm8pVwpKuI1gjf6FmwX.pdf"; @@ -554,7 +555,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid resolver.newOrderEnabled(client, null, PlatformEnvironment.getEnv().getForeignCurrency())) { client.put("enable_alipayplus", true); } - + ApsConfigData apsConfig = apsConfigService.getApsConfigByClientId(client.getString("client_id")); + if (apsConfig == null) { + apsConfig = apsConfigService.saveApsConfigClientId(manager.getString("manager_id"), client.getString("client_id"), new ApsConfigDescriptor()); + } + client.put("aps_config_id", apsConfig.getId()); + client.put("enable_alipayaps", apsConfig.getEnableAlipayAps()); + client.put("alipay_cn_switch", apsConfig.getAlipayCnSwitch()); return client; } @@ -1583,11 +1590,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new NotFoundException("Client Not Exists"); } - merchantChannelPermissionManager.switchMerchantChannelPermission(channelApi.getMetadata().payChannel(), client.getIntValue("client_id"), allow); - try { - clientModifySupport.processModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow)); - } catch (Exception e) { - logger.error("Failed to change channel switch:{}", channel); + if (channelApi.channel().equalsIgnoreCase("alipayaps")) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("enableAlipayAps", allow); + apsConfigService.updateApsConfigClientId(manager.getString("manager_id"), client.getString("client_id"), jsonObject); + } else { + 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))) { @@ -2050,12 +2063,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } else { List existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); existRate.stream().filter(existConfig -> { - if (existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time"))) { - return false; - } - return true; - } - ) + if (existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time"))) { + return false; + } + return true; + } + ) .forEach((rateLog) -> { rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1)); clientRateMapper.updateConfig(rateLog); @@ -2980,24 +2993,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("The Partner's Rate is not config!"); } client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); - client.put("clean", "T+"+weChatRate.getString("clean_days")); + client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } try { JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay"); @@ -3116,19 +3129,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); client.put("clean", "T+" + p.getString("clean_days")); client.put("clean_days", p.getString("clean_days")); - if("1".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(p.getString("clean_days"))){ - client.put("clean_1", p.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + if ("1".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(p.getString("clean_days"))) { + client.put("clean_1", p.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } } else if ("Alipay".equals(rate_name)) { client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); @@ -3205,21 +3218,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } try { @@ -4106,21 +4119,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); client.put("located_country", "Australia"); - if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){ + if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) { // clean_1 clean_1_friday clean_1_saturday // second, third or fourth - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "first"); - client.put("clean_1_saturday", "second"); - }else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "second"); - client.put("clean_1_saturday", "third"); - - }else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){ - client.put("clean_1", weChatRate.getString("clean_days")); - client.put("clean_1_friday", "third"); - client.put("clean_1_saturday", "fourth"); + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "first"); + client.put("clean_1_saturday", "second"); + } else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "second"); + client.put("clean_1_saturday", "third"); + + } else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) { + client.put("clean_1", weChatRate.getString("clean_days")); + client.put("clean_1_friday", "third"); + client.put("clean_1_saturday", "fourth"); } String rateConfig = sysConfigManager.getSysConfig().getString("sys_rates"); JSONObject sysConfigRate = JSON.parseObject(rateConfig); @@ -4201,7 +4214,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); JSONObject result = PageListUtils.buildPageListResult(logs); - result.put("padding", logs.stream().anyMatch(log->log.getBooleanValue("editable"))); + result.put("padding", logs.stream().anyMatch(log -> log.getBooleanValue("editable"))); logger.info("##editable{}", result.getBooleanValue("padding")); return result; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java new file mode 100644 index 000000000..5a945f842 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ApsConfigData.java @@ -0,0 +1,46 @@ +package au.com.royalpay.payment.manage.merchants.entity; + + +import au.com.royalpay.payment.manage.merchants.core.descriptor.ApsConfigDescriptor; +import com.alibaba.fastjson.JSONObject; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; +import java.util.UUID; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class ApsConfigData implements Serializable { + + private String id; + + private String creator; + + private Date createTime; + + private String modifier; + + private Date modifyTime; + + private String clientId; + + private Boolean enableAlipayAps; + + private Boolean alipayCnSwitch; + + public static ApsConfigData saveData(String managerId, String clientId, ApsConfigDescriptor apsConfigDescriptor) { + return new ApsConfigData() + .setClientId(clientId) + .setId(UUID.randomUUID().toString().replace("-", "")) + .setAlipayCnSwitch(apsConfigDescriptor.getAlipayCnSwitch()) + .setEnableAlipayAps(apsConfigDescriptor.getEnableAlipayAps()) + .setCreator(managerId) + .setCreateTime(new Date()); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java new file mode 100644 index 000000000..5b64f54bc --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/ApsConfigController.java @@ -0,0 +1,55 @@ +package au.com.royalpay.payment.manage.merchants.web; + +import au.com.royalpay.payment.manage.merchants.core.ApsConfigService; +import au.com.royalpay.payment.manage.merchants.core.descriptor.ApsConfigDescriptor; +import au.com.royalpay.payment.manage.merchants.entity.ApsConfigData; +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/sys/partners/aps") +public class ApsConfigController { + + @Resource + private ApsConfigService apsConfigService; + + /** + * 获取aps配置信息 + * + * @param clientId + * @return + */ + @GetMapping("/{clientId}") + public ApsConfigData getApsConfigByClientId(@PathVariable("clientId") String clientId) { + return apsConfigService.getApsConfigByClientId(clientId); + } + + /** + * 初始化aps配置 + * + * @param clientId + * @param apsConfigDescriptor + * @return + */ + @ManagerMapping(value = "/{clientId}", method = RequestMethod.POST, role = { ManagerRole.ADMIN,ManagerRole.OPERATOR,ManagerRole.SITE_MANAGER }) + public ApsConfigData saveApsConfigClientId(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable("clientId") String clientId, @RequestBody ApsConfigDescriptor apsConfigDescriptor) { + return apsConfigService.saveApsConfigClientId(manager.getString("managerId"), clientId, apsConfigDescriptor); + } + + /** + * 修改aps配置 + * + * @param clientId + * @param apsConfig + * @return + */ + @ManagerMapping(value = "/{clientId}", method = RequestMethod.PUT, role = { ManagerRole.ADMIN,ManagerRole.OPERATOR,ManagerRole.SITE_MANAGER }) + public ApsConfigData updateApsConfigClientId(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable("clientId") String clientId, @RequestBody JSONObject apsConfig) { + return apsConfigService.updateApsConfigClientId(manager.getString("managerId"),clientId, apsConfig); + } +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml new file mode 100644 index 000000000..3c0630c8f --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/aps/ApsConfigMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + UPDATE sys_client_aps_config SET modify_time = now(), modifier = #{modifier} + , alipay_cn_switch = #{alipayCnSwitch} + , enable_alipayaps = #{enableAlipayAps} + WHERE client_id = #{clientId} + + + \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 4e63e0fb4..d3b0b07e2 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2,459 +2,459 @@ * Created by yixian on 2016-06-29. */ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload', 'uiSelect'], function (angular, Decimal) { - 'use strict' - var clean_days_map = [ - { - label: 'T+1', - value: '1', - }, - { - label: 'T+2', - value: '2', - }, - { - label: 'T+3', - value: '3', - }, - ] - var bd_city_map = [ - { - label: 'Sydney', - value: 'Sydney', - }, - { - label: 'Melbourne', - value: 'Melbourne', - }, - ] - var partnerRoles = [ - { code: 1, label: 'Admin' }, - { code: 2, label: 'Manager' }, - { code: 3, label: 'Cashier' }, - ] - // var wxMerchantIndustries = [ - // { - // "label": "鞋包服饰|Shoes&Garments", - // "value": "343" - // }, - // { - // "label": "机票行业|Air Ticket", - // "value": "493" - // }, - // { - // "label": "文具/办公用品|Stationery/office supplies", - // "value": "492" - // }, - // { - // "label": "酒店行业|Hotel Industry", - // "value": "491" - // }, - // { - // "label": "教育行业|Education Industry", - // "value": "490" - // }, - // { - // "label": "国际物流|Logistics", - // "value": "489" - // }, - // { - // "label": "数码电器|Digital appliance", - // "value": "488" - // }, - // { - // "label": "母婴|Maternal and infant", - // "value": "487" - // }, - // { - // "label": "化妆品|Cosmetics", - // "value": "486" - // }, - // { - // "label": "食品|Food", - // "value": "485" - // }, - // { - // "label": "综合商城|Comprehensive mall", - // "value": "484" - // }, - // { - // "label": "其它货物贸易行业|Other trade industry", - // "value": "494" - // } - // ]; - - var wxMerchantIndustries = [ - { - label: 'Shoes&Garments', - value: '343', - }, - { - label: 'Comprehensive mall', - value: '484', - }, - { - label: 'Food', - value: '485', - }, - { - label: 'Cosmetics', - value: '486', - }, - { - label: 'Maternal and infant', - value: '487', - }, - { - label: 'Digital appliance', - value: '488', - }, - { - label: 'Logistics', - value: '489', - }, - { - label: 'Education Industry', - value: '490', - }, - { - label: 'Hotel Industry', - value: '491', - }, - { - label: 'Stationery/office supplies', - value: '492', - }, - { - label: 'Air Ticket', - value: '493', - }, - { - label: 'Other trade industry', - value: '494', - }, - { - label: 'Overseas Education', - value: '528', - }, - { - label: 'Travel ticket', - value: '529', - }, - { - label: 'Car rental', - value: '530', - }, - { - label: 'International Conference', - value: '531', - }, - { - label: 'Software', - value: '532', - }, - { - label: 'Medical Service', - value: '533', - }, - { - label: 'Online games (Top-up)', - value: '644', - }, - { - label: 'Online Shopping Mall', - value: '648', - }, - { - label: 'Supermarket', - value: '649', - }, - { - label: 'Convenience Store', - value: '651', - }, - { - label: 'Duty-free Shop', - value: '652', - }, - { - label: 'Pharmacy', - value: '653', - }, - { - label: 'Vending Machine', - value: '654', - }, - { - label: 'Department Store /Shopping Centre', - value: '655', - }, - { - label: 'Food/Beverages', - value: '656', - }, - { - label: 'Catering Services', - value: '657', - }, - { - label: 'Furniture/Household Products', - value: '658', - }, - { - label: 'Home Appliances/Camera Equipment/Office Equipment', - value: '659', - }, - { - label: 'Beauty/Personal Care Products', - value: '660', - }, - { - label: 'Flowers/Plants/Interior Decorations/Decorations', - value: '661', - }, - { - label: 'Nursery Products/Toys', - value: '662', - }, - { - label: 'Clothing/Shoes/Other Accessories', - value: '663', - }, - { - label: 'Sports/Fitness Equipment/Security', - value: '664', - }, - { - label: 'Watches/Eyewear/Jewellery', - value: '665', - }, - { - label: 'Outdoor Products /Travel Products', - value: '666', - }, - { - label: 'Books / Records / Stationery / Musical Instruments', - value: '667', - }, - { - label: 'Flight ticket/ticketing agent', - value: '668', - }, - { - label: 'Sightseeing Passes', - value: '669', - }, - { - label: 'Hotel/Resort', - value: '670', - }, - { - label: 'Online Books/Video/Music', - value: '671', - }, - { - label: 'Online games (Download)', - value: '672', - }, - { - label: 'University Education', - value: '677', - }, - { - label: 'Public hospitals/Medical Institutions', - value: '679', - }, - { - label: 'Private hospitals/Clinics/Medical institutions', - value: '678', - }, - { - label: 'Public transit', - value: '680', - }, - { - label: 'Logistics/ Courier Service', - value: '684', - }, - ] - var removeClientPayDesc = function (items, key) { - for (var i = 0; i < items.length; i++) { - var item = items[i] - if (item.indexOf(key) >= 0) { - items.splice(items.indexOf(item), 1) - i = i - 1 - } + 'use strict' + var clean_days_map = [ + { + label: 'T+1', + value: '1', + }, + { + label: 'T+2', + value: '2', + }, + { + label: 'T+3', + value: '3', + }, + ] + var bd_city_map = [ + { + label: 'Sydney', + value: 'Sydney', + }, + { + label: 'Melbourne', + value: 'Melbourne', + }, + ] + var partnerRoles = [ + {code: 1, label: 'Admin'}, + {code: 2, label: 'Manager'}, + {code: 3, label: 'Cashier'}, + ] + // var wxMerchantIndustries = [ + // { + // "label": "鞋包服饰|Shoes&Garments", + // "value": "343" + // }, + // { + // "label": "机票行业|Air Ticket", + // "value": "493" + // }, + // { + // "label": "文具/办公用品|Stationery/office supplies", + // "value": "492" + // }, + // { + // "label": "酒店行业|Hotel Industry", + // "value": "491" + // }, + // { + // "label": "教育行业|Education Industry", + // "value": "490" + // }, + // { + // "label": "国际物流|Logistics", + // "value": "489" + // }, + // { + // "label": "数码电器|Digital appliance", + // "value": "488" + // }, + // { + // "label": "母婴|Maternal and infant", + // "value": "487" + // }, + // { + // "label": "化妆品|Cosmetics", + // "value": "486" + // }, + // { + // "label": "食品|Food", + // "value": "485" + // }, + // { + // "label": "综合商城|Comprehensive mall", + // "value": "484" + // }, + // { + // "label": "其它货物贸易行业|Other trade industry", + // "value": "494" + // } + // ]; + + var wxMerchantIndustries = [ + { + label: 'Shoes&Garments', + value: '343', + }, + { + label: 'Comprehensive mall', + value: '484', + }, + { + label: 'Food', + value: '485', + }, + { + label: 'Cosmetics', + value: '486', + }, + { + label: 'Maternal and infant', + value: '487', + }, + { + label: 'Digital appliance', + value: '488', + }, + { + label: 'Logistics', + value: '489', + }, + { + label: 'Education Industry', + value: '490', + }, + { + label: 'Hotel Industry', + value: '491', + }, + { + label: 'Stationery/office supplies', + value: '492', + }, + { + label: 'Air Ticket', + value: '493', + }, + { + label: 'Other trade industry', + value: '494', + }, + { + label: 'Overseas Education', + value: '528', + }, + { + label: 'Travel ticket', + value: '529', + }, + { + label: 'Car rental', + value: '530', + }, + { + label: 'International Conference', + value: '531', + }, + { + label: 'Software', + value: '532', + }, + { + label: 'Medical Service', + value: '533', + }, + { + label: 'Online games (Top-up)', + value: '644', + }, + { + label: 'Online Shopping Mall', + value: '648', + }, + { + label: 'Supermarket', + value: '649', + }, + { + label: 'Convenience Store', + value: '651', + }, + { + label: 'Duty-free Shop', + value: '652', + }, + { + label: 'Pharmacy', + value: '653', + }, + { + label: 'Vending Machine', + value: '654', + }, + { + label: 'Department Store /Shopping Centre', + value: '655', + }, + { + label: 'Food/Beverages', + value: '656', + }, + { + label: 'Catering Services', + value: '657', + }, + { + label: 'Furniture/Household Products', + value: '658', + }, + { + label: 'Home Appliances/Camera Equipment/Office Equipment', + value: '659', + }, + { + label: 'Beauty/Personal Care Products', + value: '660', + }, + { + label: 'Flowers/Plants/Interior Decorations/Decorations', + value: '661', + }, + { + label: 'Nursery Products/Toys', + value: '662', + }, + { + label: 'Clothing/Shoes/Other Accessories', + value: '663', + }, + { + label: 'Sports/Fitness Equipment/Security', + value: '664', + }, + { + label: 'Watches/Eyewear/Jewellery', + value: '665', + }, + { + label: 'Outdoor Products /Travel Products', + value: '666', + }, + { + label: 'Books / Records / Stationery / Musical Instruments', + value: '667', + }, + { + label: 'Flight ticket/ticketing agent', + value: '668', + }, + { + label: 'Sightseeing Passes', + value: '669', + }, + { + label: 'Hotel/Resort', + value: '670', + }, + { + label: 'Online Books/Video/Music', + value: '671', + }, + { + label: 'Online games (Download)', + value: '672', + }, + { + label: 'University Education', + value: '677', + }, + { + label: 'Public hospitals/Medical Institutions', + value: '679', + }, + { + label: 'Private hospitals/Clinics/Medical institutions', + value: '678', + }, + { + label: 'Public transit', + value: '680', + }, + { + label: 'Logistics/ Courier Service', + value: '684', + }, + ] + var removeClientPayDesc = function (items, key) { + for (var i = 0; i < items.length; i++) { + var item = items[i] + if (item.indexOf(key) >= 0) { + items.splice(items.indexOf(item), 1) + i = i - 1 + } + } } - } - var app = angular.module('partnerManageApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ui.select', 'ngFileUpload']) - app.config([ - '$stateProvider', - function ($stateProvider) { - $stateProvider - .state('partners', { - url: '/partners', - templateUrl: '/static/payment/partner/templates/partners.html', - controller: 'partnerListCtrl', - data: { label: '商户列表' }, - }) - .state('businessCompliance', { - url: '/partners/compliance', - templateUrl: '/static/payment/partner/templates/partner_compliance.html', - controller: 'compliancePartnerCtrl', - }) - .state('complianceDocumentAudit', { - url: '/partners/compliance', - templateUrl: '/static/payment/partner/templates/partner_compliance.html', - controller: 'compliancePartnerCtrl', - }) - .state('partners.detail', { - url: '/{clientMoniker}/detail', - templateUrl: '/static/payment/partner/templates/partner_detail.html', - controller: 'partnerDetailCtrl', - resolve: { - partner: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker) - }, - ], - }, - }) - .state('partners.detail.payment_info', { - url: '/payment', - templateUrl: '/static/payment/partner/templates/partner_payment_info.html', - controller: 'partnerPaymentInfoCtrl', - }) - .state('partners.detail.payment_info_invalid', { - url: '/payment_invalid', - templateUrl: '/static/payment/partner/templates/partner_payment_info_invalid.html', - controller: 'partnerPaymentInfoCtrl', - }) - .state('partners.detail.subpartners', { - url: '/sub_partners', - templateUrl: '/static/payment/partner/templates/sub_partners.html', - controller: 'partnerSubCtrl', - }) - .state('partners.detail.accounts', { - url: '/accounts', - templateUrl: '/static/payment/partner/templates/partner_accounts.html', - controller: 'partnerAccountsCtrl', - }) - .state('partners.detail.paylogs', { - url: '/pay_logs', - templateUrl: '/static/payment/partner/templates/partner_pay_logs.html', - controller: 'partnerPayLogCtrl', - }) - .state('partners.detail.rates', { - url: '/rates', - templateUrl: '/static/payment/partner/templates/partner_bankaccounts.html', - controller: 'partnerRatesCtrl', - }) - .state('partners.detail.plugins', { - url: '/plugins', - templateUrl: '/static/payment/partner/templates/partner_plugins.html', - controller: 'partnerPluginsCtrl', - }) - .state('partners.detail.devices', { - url: '/devices', - templateUrl: '/static/payment/partner/templates/partner_devices.html', - controller: 'partnerDeviceCtrl', - }) - .state('partners.detail.files', { - url: '/files', - params: { commitType: 'cross-border' }, - templateUrl: '/static/payment/partner/templates/partner_auth_files.html', - controller: 'partnerAuthFileCtrl', - }) - .state('partners.detail.files.CP_files', { - url: '/cp_files', - templateUrl: '/static/payment/partner/templates/partner_cp_auth_files.html', - controller: 'partnerCPAuthFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/file') - }, - ], - }, - }) - .state('partners.detail.files.MW_files', { - url: '/mw_files', - templateUrl: '/static/payment/partner/templates/partner_mw_auth_files.html', - controller: 'partnerMWAuthFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/mw_file') - }, - ], - }, - }) - .state('partners.detail.kyc_files', { - url: '/kyc_files', - templateUrl: '/static/payment/kyc/templates/partner_kyc_files.html', - controller: 'partnerKycFileCtrl', - resolve: { - file: [ - '$http', - '$stateParams', - function ($http, $stateParams) { - return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/kycFile') - }, - ], - }, - }) - .state('partners.detail.settlement', { - url: '/settlement', - templateUrl: '/static/payment/partner/templates/partner_settlement.html', - controller: 'partnerSettlementCtrl', - resolve: { - clientMoniker: [ - '$stateParams', - function ($stateParams) { - return $stateParams.clientMoniker - }, - ], - }, - }) - .state('partners.detail.surcharge_account', { - url: '/surcharge_account', - templateUrl: '/static/payment/partner/templates/partner_surcharge_account.html', - controller: 'partnerSurchargeAccountCtrl', - resolve: { - clientMoniker: [ - '$stateParams', - function ($stateParams) { - return $stateParams.clientMoniker - }, - ], - }, - }) - .state('partners.detail.product', { - url: '/partner_product', - templateUrl: 'static/payment/product/templates/partner_product.html', - controller: 'productCtrl', - }) - .state('partners.detail.sub_merchant_applicaitons', { - url: '/sub_merchant_applicaitons', - templateUrl: 'static/payment/partner/templates/sub_merchant_id_apply.html', - controller: 'subMerchantIdApplicaitonsCtrl', - }) - .state('partners.detail.permission_client', { - url: '/permission_client', - templateUrl: 'static/payment/partner/templates/partner_permission.html', - controller: 'permissionClientCtrl', - }) - .state('partners.detail.incremental_service', { - url: '/incremental_service', - templateUrl: 'static/payment/partner/templates/incremental_service.html', - controller: 'incrementalServiceCtrl', - }) /*.state('partners.edit', { + var app = angular.module('partnerManageApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ui.select', 'ngFileUpload']) + app.config([ + '$stateProvider', + function ($stateProvider) { + $stateProvider + .state('partners', { + url: '/partners', + templateUrl: '/static/payment/partner/templates/partners.html', + controller: 'partnerListCtrl', + data: {label: '商户列表'}, + }) + .state('businessCompliance', { + url: '/partners/compliance', + templateUrl: '/static/payment/partner/templates/partner_compliance.html', + controller: 'compliancePartnerCtrl', + }) + .state('complianceDocumentAudit', { + url: '/partners/compliance', + templateUrl: '/static/payment/partner/templates/partner_compliance.html', + controller: 'compliancePartnerCtrl', + }) + .state('partners.detail', { + url: '/{clientMoniker}/detail', + templateUrl: '/static/payment/partner/templates/partner_detail.html', + controller: 'partnerDetailCtrl', + resolve: { + partner: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker) + }, + ], + }, + }) + .state('partners.detail.payment_info', { + url: '/payment', + templateUrl: '/static/payment/partner/templates/partner_payment_info.html', + controller: 'partnerPaymentInfoCtrl', + }) + .state('partners.detail.payment_info_invalid', { + url: '/payment_invalid', + templateUrl: '/static/payment/partner/templates/partner_payment_info_invalid.html', + controller: 'partnerPaymentInfoCtrl', + }) + .state('partners.detail.subpartners', { + url: '/sub_partners', + templateUrl: '/static/payment/partner/templates/sub_partners.html', + controller: 'partnerSubCtrl', + }) + .state('partners.detail.accounts', { + url: '/accounts', + templateUrl: '/static/payment/partner/templates/partner_accounts.html', + controller: 'partnerAccountsCtrl', + }) + .state('partners.detail.paylogs', { + url: '/pay_logs', + templateUrl: '/static/payment/partner/templates/partner_pay_logs.html', + controller: 'partnerPayLogCtrl', + }) + .state('partners.detail.rates', { + url: '/rates', + templateUrl: '/static/payment/partner/templates/partner_bankaccounts.html', + controller: 'partnerRatesCtrl', + }) + .state('partners.detail.plugins', { + url: '/plugins', + templateUrl: '/static/payment/partner/templates/partner_plugins.html', + controller: 'partnerPluginsCtrl', + }) + .state('partners.detail.devices', { + url: '/devices', + templateUrl: '/static/payment/partner/templates/partner_devices.html', + controller: 'partnerDeviceCtrl', + }) + .state('partners.detail.files', { + url: '/files', + params: {commitType: 'cross-border'}, + templateUrl: '/static/payment/partner/templates/partner_auth_files.html', + controller: 'partnerAuthFileCtrl', + }) + .state('partners.detail.files.CP_files', { + url: '/cp_files', + templateUrl: '/static/payment/partner/templates/partner_cp_auth_files.html', + controller: 'partnerCPAuthFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/file') + }, + ], + }, + }) + .state('partners.detail.files.MW_files', { + url: '/mw_files', + templateUrl: '/static/payment/partner/templates/partner_mw_auth_files.html', + controller: 'partnerMWAuthFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/mw_file') + }, + ], + }, + }) + .state('partners.detail.kyc_files', { + url: '/kyc_files', + templateUrl: '/static/payment/kyc/templates/partner_kyc_files.html', + controller: 'partnerKycFileCtrl', + resolve: { + file: [ + '$http', + '$stateParams', + function ($http, $stateParams) { + return $http.get('/sys/partners/' + $stateParams.clientMoniker + '/kycFile') + }, + ], + }, + }) + .state('partners.detail.settlement', { + url: '/settlement', + templateUrl: '/static/payment/partner/templates/partner_settlement.html', + controller: 'partnerSettlementCtrl', + resolve: { + clientMoniker: [ + '$stateParams', + function ($stateParams) { + return $stateParams.clientMoniker + }, + ], + }, + }) + .state('partners.detail.surcharge_account', { + url: '/surcharge_account', + templateUrl: '/static/payment/partner/templates/partner_surcharge_account.html', + controller: 'partnerSurchargeAccountCtrl', + resolve: { + clientMoniker: [ + '$stateParams', + function ($stateParams) { + return $stateParams.clientMoniker + }, + ], + }, + }) + .state('partners.detail.product', { + url: '/partner_product', + templateUrl: 'static/payment/product/templates/partner_product.html', + controller: 'productCtrl', + }) + .state('partners.detail.sub_merchant_applicaitons', { + url: '/sub_merchant_applicaitons', + templateUrl: 'static/payment/partner/templates/sub_merchant_id_apply.html', + controller: 'subMerchantIdApplicaitonsCtrl', + }) + .state('partners.detail.permission_client', { + url: '/permission_client', + templateUrl: 'static/payment/partner/templates/partner_permission.html', + controller: 'permissionClientCtrl', + }) + .state('partners.detail.incremental_service', { + url: '/incremental_service', + templateUrl: 'static/payment/partner/templates/incremental_service.html', + controller: 'incrementalServiceCtrl', + }) /*.state('partners.edit', { url: '/{clientMoniker}/edit', params: {"commitCardPayment": false, "commitCrossBorderPayment": false}, templateUrl: 'static/payment/partner/templates/partner_edit.html', @@ -465,4326 +465,4396 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }] } })*/ - }, - ]) - app.controller('partnerEditCtrl', [ - '$scope', - '$http', - '$state', - 'Upload', - 'commonDialog', - 'timezone', - 'partner', - 'upayIndustryMap', - function ($scope, $http, $state, Upload, commonDialog, timezone, partner, upayIndustryMap) { - $scope.upayIndustrys = upayIndustryMap.configs() - $scope.timezones = timezone.configs() - $scope.partner = partner.data - if (!$scope.partner.client_type) { - $scope.partner.client_type = 'cross-border' - } - if ($scope.partner.representativeInfo != null) { - $scope.partner.registered_address = $scope.partner.representativeInfo.address - $scope.partner.registered_suburb = $scope.partner.representativeInfo.suburb - $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode - $scope.partner.registered_state = $scope.partner.representativeInfo.state - $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person - $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone - $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email - $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title - - $scope.partner.marketing_person = $scope.partner.representativeInfo.marketing_person - $scope.partner.marketing_phone = $scope.partner.representativeInfo.marketing_phone - $scope.partner.marketing_email = $scope.partner.representativeInfo.marketing_email - $scope.partner.marketing_job = $scope.partner.representativeInfo.marketing_job_title - - $scope.partner.legal_representative_wechatid = $scope.partner.representativeInfo.legal_representative_wechatid - $scope.partner.marketing_wechatid = $scope.partner.representativeInfo.marketing_wechatid - } - - $scope.enablePaymentType = function (type) { - $scope.partner[type] = !$scope.partner[type] - } - - if ($state.params.commitCardPayment) { - $scope.enablePaymentType('enable_card_payment') - } - - if ($state.params.commitCrossBorderPayment) { - $scope.enablePaymentType('enable_cross_payment') - } - - function hasRole() { - var rolenum - switch (sessionStorage.getItem('role')) { - case 'administrator': - rolenum = 1 - break - case 'bduser': - rolenum = 4 - break - case 'salesmanager': - rolenum = 8192 - break - case 'accountant': - rolenum = 8 - break - case 'sitemanager': - rolenum = 128 - break - case 'director': - rolenum = 64 - break - case 'developer': - rolenum = 256 - break - case 'compliance': - rolenum = 2 - break - case 'guest': - rolenum = 2048 - break - case 'orgmanager': - rolenum = 4096 - break - case 'riskmanager': - rolenum = 1024 - break - default: - break - } - if ((window.currentUser.role & rolenum) > 0) { - return true - } else { - sessionStorage.removeItem('role') - return false - } - } + }, + ]) + app.controller('partnerEditCtrl', [ + '$scope', + '$http', + '$state', + 'Upload', + 'commonDialog', + 'timezone', + 'partner', + 'upayIndustryMap', + function ($scope, $http, $state, Upload, commonDialog, timezone, partner, upayIndustryMap) { + $scope.upayIndustrys = upayIndustryMap.configs() + $scope.timezones = timezone.configs() + $scope.partner = partner.data + if (!$scope.partner.client_type) { + $scope.partner.client_type = 'cross-border' + } + if ($scope.partner.representativeInfo != null) { + $scope.partner.registered_address = $scope.partner.representativeInfo.address + $scope.partner.registered_suburb = $scope.partner.representativeInfo.suburb + $scope.partner.registered_postcode = $scope.partner.representativeInfo.postcode + $scope.partner.registered_state = $scope.partner.representativeInfo.state + $scope.partner.legal_representative_person = $scope.partner.representativeInfo.representative_person + $scope.partner.legal_representative_phone = $scope.partner.representativeInfo.phone + $scope.partner.legal_representative_email = $scope.partner.representativeInfo.email + $scope.partner.legal_representative_job = $scope.partner.representativeInfo.job_title + + $scope.partner.marketing_person = $scope.partner.representativeInfo.marketing_person + $scope.partner.marketing_phone = $scope.partner.representativeInfo.marketing_phone + $scope.partner.marketing_email = $scope.partner.representativeInfo.marketing_email + $scope.partner.marketing_job = $scope.partner.representativeInfo.marketing_job_title + + $scope.partner.legal_representative_wechatid = $scope.partner.representativeInfo.legal_representative_wechatid + $scope.partner.marketing_wechatid = $scope.partner.representativeInfo.marketing_wechatid + } - if (hasRole()) { - $scope.role = sessionStorage.getItem('role') - } + $scope.enablePaymentType = function (type) { + $scope.partner[type] = !$scope.partner[type] + } - var origin_referrer_id = angular.copy($scope.partner.referrer_id) - var resetClientPayDescByTpey = function (type) { - type = parseInt(type) - if (type == 1) { - removeClientPayDesc($scope.partner.client_pay_desc, '10') - } - if (type == 2) { - removeClientPayDesc($scope.partner.client_pay_desc, '20') - } - } - var compare = function (x, y) { - x = parseInt(x) - y = parseInt(y) - if (x < y) { - return -1 - } else if (x > y) { - return 1 - } else { - return 0 - } - } - $scope.toggleClientPayType = function (type) { - if (!$scope.partner.client_pay_type) { - $scope.partner.client_pay_type = [] - } - var $idx = $scope.partner.client_pay_type.indexOf(type) - if ($idx >= 0) { - $scope.partner.client_pay_type.splice($idx, 1) - resetClientPayDescByTpey(type) - } else { - $scope.partner.client_pay_type.push(type) - $scope.partner.client_pay_type.sort(compare) - } - } - $scope.toggleClientPayDesc = function (type) { - if (!$scope.partner.client_pay_desc) { - $scope.partner.client_pay_desc = [] - } - var $idx = $scope.partner.client_pay_desc.indexOf(type) - if ($idx >= 0) { - if (type == '203') { - removeClientPayDesc($scope.partner.client_pay_desc, '2030') - } - $scope.partner.client_pay_desc.splice($idx, 1) - } else { - $scope.partner.client_pay_desc.push(type) - $scope.partner.client_pay_desc.sort(compare) - } - } - - $scope.partner.sameAsContactPerson = false - $scope.checkboxOnclick = function () { - $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson - if ($scope.partner.sameAsContactPerson) { - $scope.partner.legal_representative_person = $scope.partner.contact_person - $scope.partner.legal_representative_phone = $scope.partner.contact_phone - $scope.partner.legal_representative_email = $scope.partner.contact_email - $scope.partner.legal_representative_job = $scope.partner.contact_job - $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.marketingSameAsContact = false - $scope.checkMarketingSameAsContact = function () { - $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact - if ($scope.partner.marketingSameAsContact) { - $scope.partner.marketing_person = $scope.partner.contact_person - $scope.partner.marketing_phone = $scope.partner.contact_phone - $scope.partner.marketing_email = $scope.partner.contact_email - $scope.partner.marketing_job = $scope.partner.contact_job - $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.sameAsAddress = false - $scope.sameAddress = function () { - $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress - if ($scope.partner.sameAsAddress) { - // $scope.partner.registered_address = $scope.partner.address; - // $scope.partner.registered_suburb = $scope.partner.suburb; - // $scope.partner.registered_postcode = $scope.partner.postcode; - // $scope.partner.registered_state = $scope.partner.state; - $scope.partner.address = $scope.partner.registered_address - $scope.partner.suburb = $scope.partner.registered_suburb - $scope.partner.postcode = $scope.partner.registered_postcode - $scope.partner.state = $scope.partner.registered_state - } - } - - $scope.listReferrers = function () { - $http.get('/sys/orgs/referrer').then(function (resp) { - $scope.referrers = resp.data - }) - } - $scope.listReferrers() - - $scope.loadAlipayCategory = function () { - $http.get('/static/data/alipayMcc.json').then(function (resp) { - $scope.alipayMccCategory = resp.data - }) - } - $scope.loadAlipayCategory() - $scope.loadJDindustry = function () { - $http.get('/static/data/jdindustry.json').then(function (resp) { - $scope.jdindustry = resp.data - }) - } - $scope.loadJDindustry() - - $scope.loadLakalaPayindustry = function () { - $http.get('/static/data/lakalapayindustry.json').then(function (resp) { - $scope.lakalapayindustry = resp.data - }) - } - $scope.loadLakalaPayindustry() - - $scope.loadLakalaPaySettle = function () { - $http.get('/static/data/lakalapaysettle.json').then(function (resp) { - $scope.lakalapaysettle = resp.data - }) - } - $scope.loadLakalaPaySettle() - - $scope.loadLakalaPayGoods = function () { - $http.get('/static/data/lakalapaygoods.json').then(function (resp) { - $scope.lakalapaygoods = resp.data - }) - } - $scope.loadLakalaPayGoods() - - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - }) - } - $scope.loadRoyalpayindustry() - - $scope.loadHfindustry = function () { - $http.get('/static/data/hfindustry.json').then(function (resp) { - $scope.hfindustry = resp.data - }) - } - $scope.loadHfindustry() - - $scope.onAlipayMccSelect = function (selectedItem) { - $scope.partner.alipay_category = selectedItem.label - $scope.partner.alipayindustry = selectedItem.mccCode - } - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.partner.royalpay_label = selectedItem.label - $scope.partner.royalpayindustry = selectedItem.mccCode - } - $scope.onHfIndustrySelect = function (selectedItem) { - $scope.partner.hf_label = selectedItem.label - $scope.partner.hfindustry = selectedItem.mccCode - } - - $scope.updatePartner = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } + if ($state.params.commitCardPayment) { + $scope.enablePaymentType('enable_card_payment') + } - if ($scope.partner.company_name.indexOf('Migration') != -1) { - alert('Company Name包含敏感词汇,请检查后重新提交!') - return - } - if ($scope.partner.company_phone.indexOf(' ') != -1) { - alert('Company Phone can not contain space character') - return - } - if ($scope.partner.contact_email.indexOf(' ') != -1) { - alert('Contact email Phone can not contain space character') - return - } - if ($scope.partner.suburb.indexOf(' ') != -1) { - alert('suburb can not contain two and more continuous space characters') - return - } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if (!$scope.partner.company_photo) { - alert('Shop Photo1 is necessary') - return - } - if (!$scope.partner.store_photo) { - alert('Shop Photo2 is necessary') - return - } - } + if ($state.params.commitCrossBorderPayment) { + $scope.enablePaymentType('enable_cross_payment') + } - if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { - if ($scope.partner.acn.length != 9) { - alert('Acn is not valid') - } - } - if ($scope.partner.referrer_id) { - $scope.referrers.forEach(function (e) { - if ($scope.partner.referrer_id == e.org_id) { - $scope.partner.referrer_name = e.name - return + function hasRole() { + var rolenum + switch (sessionStorage.getItem('role')) { + case 'administrator': + rolenum = 1 + break + case 'bduser': + rolenum = 4 + break + case 'salesmanager': + rolenum = 8192 + break + case 'accountant': + rolenum = 8 + break + case 'sitemanager': + rolenum = 128 + break + case 'director': + rolenum = 64 + break + case 'developer': + rolenum = 256 + break + case 'compliance': + rolenum = 2 + break + case 'guest': + rolenum = 2048 + break + case 'orgmanager': + rolenum = 4096 + break + case 'riskmanager': + rolenum = 1024 + break + default: + break + } + if ((window.currentUser.role & rolenum) > 0) { + return true + } else { + sessionStorage.removeItem('role') + return false + } } - }) - } - var content = '' - if (!origin_referrer_id && $scope.partner.referrer_id) { - content = 'Update partner info successfully,But You Had add new Referrer,Please Change the BD Commission Proportion!' - } - if ($scope.partner.client_pay_type.length == 0) { - alert('请选择商户支付场景') - return - } - if ($scope.partner.client_pay_desc.length == 0) { - alert('请选择商户支付方式') - return - } - if ($scope.partner.client_pay_type.indexOf('1') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { - alert('请检查线上支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_type.indexOf('2') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { - alert('请检查线下支付场景是否已选择支付方式') - return - } - } - if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { - if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { - alert('请检查线下支付是否已选择收银系统类型') - return - } - } - $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') - $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') - $http.put('/sys/partners/' + $scope.partner.client_moniker, $scope.partner).then( - function () { - if (content != '') { - commonDialog.alert({ - title: 'Warning', - content: content, - type: 'error', - }) - } else { - commonDialog.alert({ - title: 'Success', - content: 'Update partner information successfully', - type: 'success', - }) - } - $scope.updateMerchantLocation() - $scope.loadPartners() - $state.go('^.detail', { clientMoniker: $scope.partner.client_moniker }, { reload: true }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.uploadLogo = function (file) { - if (file != null) { - if (file.size > 1 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error' }) - } else { - $scope.logoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.logoProgress - $scope.partner.logo_id = resp.data.fileid - $scope.partner.logo_url = resp.data.url - }, - function (resp) { - delete $scope.logoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadShopPhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.shopPhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.shopPhotoProgress - $scope.partner.company_photo = resp.data.url - }, - function (resp) { - delete $scope.shopPhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadStorePhoto = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - $scope.storePhotoProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.storePhotoProgress - $scope.partner.store_photo = resp.data.url - }, - function (resp) { - delete $scope.storePhotoProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.getMerchantLocation = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { - $scope.merchant_location = resp.data - }) - } - $scope.getMerchantLocation() - - $scope.updateMerchantLocation = function () { - var params = window.frames['merchant_detail'].merchant_location - if (params) { - $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () {}) - } - } - }, - ]) - app.controller('partnerListCtrl', [ - '$scope', - '$sce', - '$http', - '$filter', - '$uibModal', - 'businessStructuresMap', - 'industryMap', - 'stateMap', - 'sectorMap', - 'countryMap', - function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { - $scope.analysisClients = function () { - $http.get('/sys/partners/analysis').then(function (resp) { - $scope.analysis = resp.data - }) - } - if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { - $scope.analysisClients() - } - $scope.pagination = {} - $scope.industries = industryMap.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.sectors = sectorMap.configs() - $scope.business_structures = businessStructuresMap.configs() - $scope.clean_days = angular.copy(clean_days_map) - $scope.bd_citys = angular.copy(bd_city_map) - $scope.params = { textType: 'all', org_name: 'ALL', industry: '0' } - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - var selectAll = { - label: 'All', - mccCode: '0', - children: {}, - } - $scope.royalpayindustry.unshift(selectAll) - }) - } - - $scope.loadRoyalpayindustry() - - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.params.royalpay_label = selectedItem.label - $scope.params.industry = selectedItem.mccCode - $scope.loadPartners(1) - } - - $scope.loadPartners = function (page) { - var params = angular.copy($scope.params) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners', { params: params }).then(function (resp) { - $scope.partners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.exportPartnersExcel = function () { - var params = angular.copy($scope.params) - var param_str = Object.keys(params) - .map(function (key) { - var value = params[key] - if (angular.isDate(value)) { - value = $filter('date')(value, 'yyyy-MM-ddTHH:mm:ssZ') - } - return key + '=' + encodeURIComponent(value) - }) - .join('&') - window.open('/sys/partners/exporting_excel?' + param_str) - } - - /*$scope.loadLocations = function () { - var params = angular.copy($scope.params); - $http.get('/sys/partners/merchant/list_locations', {params: params}).then(function (resp) { - $scope.locations = resp.data; - window.merchant_maps.initMap($scope.locations); - }); - };*/ - $scope.today = new Date() - - $scope.listBDUsers = function () { - $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { - $scope.bdUserSource = resp.data - }) - } - $scope.listBDUsers() - - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - $scope.showOrg = 'Organization' - $http.get('/sys/orgs/list_all_Org', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - $scope.loadOrgs() - - /* $scope.onOrgsSelect = function (selectedItem) { - $scope.params.org_id = selectedItem.org_id; - $scope.params.org_name = selectedItem.label; - $scope.loadPartners(); - }; - */ - /* $scope.chooseOrg = function (org) { - if (org == 'all') { - delete $scope.params.org_id; - $scope.showOrg = 'All' - } else { - $scope.params.org_id = org.org_id; - $scope.showOrg = org.name; - } - $scope.loadPartners(1); - };*/ - $scope.loadPartners(1) - - $scope.openClientBoard = function (client) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/partner_card.html', - controller: 'partnerCardCtrl', - resolve: { - clientMoniker: function () { - return client.client_moniker - }, - }, - size: 'lg', - }) - } - /*$scope.toogleMapSelect = function () { - $scope.mapFrame = 'all_locations.html'; - $scope.loadLocations(); + if (hasRole()) { + $scope.role = sessionStorage.getItem('role') } - $scope.toogleMerchantSelect = function () { - $scope.mapFrame = null; + + var origin_referrer_id = angular.copy($scope.partner.referrer_id) + var resetClientPayDescByTpey = function (type) { + type = parseInt(type) + if (type == 1) { + removeClientPayDesc($scope.partner.client_pay_desc, '10') + } + if (type == 2) { + removeClientPayDesc($scope.partner.client_pay_desc, '20') + } } - $scope.toogleMerchantSelect();*/ - }, - ]) - app.controller('compliancePartnerCtrl', [ - '$scope', - '$sce', - '$http', - '$filter', - '$uibModal', - 'businessStructuresMap', - 'industryMap', - 'stateMap', - 'sectorMap', - 'countryMap', - function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { - $scope.analysisClients = function () { - $http.get('/sys/partners/analysis').then(function (resp) { - $scope.analysis = resp.data - }) - } - if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { - $scope.analysisClients() - } - $scope.pagination = {} - $scope.industries = industryMap.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.sectors = sectorMap.configs() - $scope.business_structures = businessStructuresMap.configs() - $scope.clean_days = angular.copy(clean_days_map) - $scope.bd_citys = angular.copy(bd_city_map) - $scope.params = { textType: 'all', org_name: 'ALL', approving_flag: false, card_approving_flag: false } - - $scope.loadPartners = function (page) { - $scope.validAndCleanApproveStatus() - var params = angular.copy($scope.params) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/compliance', { params: params }).then(function (resp) { - $scope.partners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.validAndCleanApproveStatus = function () { - if (!$scope.params.cross_approving_flag && !$scope.params.card_approving_flag) { - $scope.params.approving = false - $scope.params.card_approving = false - $scope.params.waitingCompliance = false - $scope.params.tempMchId = false - $scope.params.bd_upload_material = false - $scope.params.quickPass = false - $scope.params.greenChannel = false - $scope.params.pass = false - $scope.params.completed_contract = false - $scope.params.apply_to_back = false - $scope.params.is_valid = false - } - if (!$scope.params.cross_approving_flag && $scope.params.card_approving_flag) { - $scope.params.tempMchId = false - $scope.params.quickPass = false - $scope.params.greenChannel = false - } - } - - $scope.today = new Date() - - $scope.listBDUsers = function () { - $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { - $scope.bdUserSource = resp.data - }) - } - $scope.listBDUsers() - - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - $scope.showOrg = 'Organization' - $http.get('/sys/orgs/list_all_Org', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - $scope.loadOrgs() - - $scope.loadPartners(1) - - $scope.openClientBoard = function (client) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/partner_card.html', - controller: 'partnerCardCtrl', - resolve: { - clientMoniker: function () { - return client.client_moniker - }, - }, - size: 'lg', - }) - } - }, - ]) - app.controller('partnerDetailCtrl', [ - '$scope', - '$http', - '$state', - '$uibModal', - '$rootScope', - 'Upload', - 'commonDialog', - 'partner', - '$sce', - function ($scope, $http, $state, $uibModal, $rootScope, Upload, commonDialog, partner, $sce) { - $scope.init = { wechat_compliance: false, local_merchant: false } - $scope.partner = partner.data - $scope.isComplianceOfCompanyName = false - $scope.isComplianceOfShortName = false - $scope.isComplianceOfBusinessStructure = false - $scope.cardPromotionaparams = {} - if ($scope.partner.mc_code) { - $scope.partner.mc_code = 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', - }) + var compare = function (x, y) { + x = parseInt(x) + y = parseInt(y) + if (x < y) { + return -1 + } else if (x > y) { + return 1 } else { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', - }) + return 0 } - delete $rootScope.complianceCheck - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.passCardClient = function () { - if (!$rootScope.complianceCheck) { - alert('please check first') - return - } - if (!$rootScope.complianceCheck.authFile) { - alert('Compliance Files not checked') - return - } - if (!$rootScope.complianceCheck.clientInfo) { - alert('Partner Detail not checked') - return - } - if (!$rootScope.complianceCheck.bankAccount) { - alert('Bank Account not checked') - return - } - var title = 'Audit Partner Card' - var content = 'Are you sure to mark partner ' + $scope.partner.company_name + ' audited?' - var choises = '' - var contentHtml = '' - if ($scope.isComplianceOfCompanyName || $scope.isComplianceOfShortName || $scope.isComplianceOfBusinessStructure) { - var info = [] - if ($scope.isComplianceOfCompanyName) { - info.push('Company Name') - } - if ($scope.isComplianceOfShortName) { - info.push('Short Name') - } - if ($scope.isComplianceOfBusinessStructure) { - info.push('Business Structure') - } - title = 'Warning' - contentHtml = $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息') - choises = [ - { label: '取消', className: 'btn-danger', key: '2', dismiss: true }, - { label: '确认提交', className: 'btn-success', key: '1' }, - ] - content = '' - } - commonDialog - .confirm({ - title: title, - content: content, - choises: choises, - contentHtml: contentHtml, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/card_audit', { pass: 1 }).then( - function () { - if ($scope.partner.approve_result == 2 && ($scope.partner.source == 1 || $scope.partner.source == 2)) { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed!', - type: 'success', - }) + } + $scope.toggleClientPayType = function (type) { + if (!$scope.partner.client_pay_type) { + $scope.partner.client_pay_type = [] + } + var $idx = $scope.partner.client_pay_type.indexOf(type) + if ($idx >= 0) { + $scope.partner.client_pay_type.splice($idx, 1) + resetClientPayDescByTpey(type) } else { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', - }) + $scope.partner.client_pay_type.push(type) + $scope.partner.client_pay_type.sort(compare) } - delete $rootScope.complianceCheck - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.pass2GreenChannel = function () { - commonDialog - .confirm({ - title: 'Green Channel Audit Partner', - content: 'Are you sure to mark partner ' + $scope.partner.company_name + ' green channel audited ?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/aduit/green_channel').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Comply Passed! Email will send to contact email address soon.', - type: 'success', + } + $scope.toggleClientPayDesc = function (type) { + if (!$scope.partner.client_pay_desc) { + $scope.partner.client_pay_desc = [] + } + var $idx = $scope.partner.client_pay_desc.indexOf(type) + if ($idx >= 0) { + if (type == '203') { + removeClientPayDesc($scope.partner.client_pay_desc, '2030') + } + $scope.partner.client_pay_desc.splice($idx, 1) + } else { + $scope.partner.client_pay_desc.push(type) + $scope.partner.client_pay_desc.sort(compare) + } + } + + $scope.partner.sameAsContactPerson = false + $scope.checkboxOnclick = function () { + $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson + if ($scope.partner.sameAsContactPerson) { + $scope.partner.legal_representative_person = $scope.partner.contact_person + $scope.partner.legal_representative_phone = $scope.partner.contact_phone + $scope.partner.legal_representative_email = $scope.partner.contact_email + $scope.partner.legal_representative_job = $scope.partner.contact_job + $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.marketingSameAsContact = false + $scope.checkMarketingSameAsContact = function () { + $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact + if ($scope.partner.marketingSameAsContact) { + $scope.partner.marketing_person = $scope.partner.contact_person + $scope.partner.marketing_phone = $scope.partner.contact_phone + $scope.partner.marketing_email = $scope.partner.contact_email + $scope.partner.marketing_job = $scope.partner.contact_job + $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid + } + } + + $scope.partner.sameAsAddress = false + $scope.sameAddress = function () { + $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress + if ($scope.partner.sameAsAddress) { + // $scope.partner.registered_address = $scope.partner.address; + // $scope.partner.registered_suburb = $scope.partner.suburb; + // $scope.partner.registered_postcode = $scope.partner.postcode; + // $scope.partner.registered_state = $scope.partner.state; + $scope.partner.address = $scope.partner.registered_address + $scope.partner.suburb = $scope.partner.registered_suburb + $scope.partner.postcode = $scope.partner.registered_postcode + $scope.partner.state = $scope.partner.registered_state + } + } + + $scope.listReferrers = function () { + $http.get('/sys/orgs/referrer').then(function (resp) { + $scope.referrers = resp.data }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.showBg = false - $scope.exportPDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/agreepdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.exportAgreegatePDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - //制作卡支付合同 - $scope.exportCardAgreegatePDF = function () { - $scope.showBg = true - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/export/aggregate/card_agree_pdf').then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Agreement File Generate Succeed! Please notify BD!', - type: 'success', - }) - $scope.showBg = false - $state.reload() - }, - function (resp) { - $scope.showBg = false - $state.reload() - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.Export = function () { - var url = '/dev/' + $scope.partner.client_moniker + '/export/aggregate/agreepdf' - return url - } - $scope.uploadAgreeFile = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.agree_file_import = resp.data.url - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', { source_agree_file: $scope.agree_file_import }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Succeed Imported! Please notify BD', - type: 'success', - }) + } + $scope.listReferrers() + + $scope.loadAlipayCategory = function () { + $http.get('/static/data/alipayMcc.json').then(function (resp) { + $scope.alipayMccCategory = resp.data + }) + } + $scope.loadAlipayCategory() + $scope.loadJDindustry = function () { + $http.get('/static/data/jdindustry.json').then(function (resp) { + $scope.jdindustry = resp.data + }) + } + $scope.loadJDindustry() + + $scope.loadLakalaPayindustry = function () { + $http.get('/static/data/lakalapayindustry.json').then(function (resp) { + $scope.lakalapayindustry = resp.data + }) + } + $scope.loadLakalaPayindustry() + + $scope.loadLakalaPaySettle = function () { + $http.get('/static/data/lakalapaysettle.json').then(function (resp) { + $scope.lakalapaysettle = resp.data + }) + } + $scope.loadLakalaPaySettle() + + $scope.loadLakalaPayGoods = function () { + $http.get('/static/data/lakalapaygoods.json').then(function (resp) { + $scope.lakalapaygoods = resp.data + }) + } + $scope.loadLakalaPayGoods() + + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + }) + } + $scope.loadRoyalpayindustry() + + $scope.loadHfindustry = function () { + $http.get('/static/data/hfindustry.json').then(function (resp) { + $scope.hfindustry = resp.data + }) + } + $scope.loadHfindustry() + + $scope.onAlipayMccSelect = function (selectedItem) { + $scope.partner.alipay_category = selectedItem.label + $scope.partner.alipayindustry = selectedItem.mccCode + } + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.partner.royalpay_label = selectedItem.label + $scope.partner.royalpayindustry = selectedItem.mccCode + } + $scope.onHfIndustrySelect = function (selectedItem) { + $scope.partner.hf_label = selectedItem.label + $scope.partner.hfindustry = selectedItem.mccCode + } + + $scope.updatePartner = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + + if ($scope.partner.company_name.indexOf('Migration') != -1) { + alert('Company Name包含敏感词汇,请检查后重新提交!') + return + } + if ($scope.partner.company_phone.indexOf(' ') != -1) { + alert('Company Phone can not contain space character') + return + } + if ($scope.partner.contact_email.indexOf(' ') != -1) { + alert('Contact email Phone can not contain space character') + return + } + if ($scope.partner.suburb.indexOf(' ') != -1) { + alert('suburb can not contain two and more continuous space characters') + return + } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if (!$scope.partner.company_photo) { + alert('Shop Photo1 is necessary') + return + } + if (!$scope.partner.store_photo) { + alert('Shop Photo2 is necessary') + return + } + } + + if ($scope.partner.acn && $scope.partner.business_structure == 'Company') { + if ($scope.partner.acn.length != 9) { + alert('Acn is not valid') + } + } + if ($scope.partner.referrer_id) { + $scope.referrers.forEach(function (e) { + if ($scope.partner.referrer_id == e.org_id) { + $scope.partner.referrer_name = e.name + return + } + }) + } + var content = '' + if (!origin_referrer_id && $scope.partner.referrer_id) { + content = 'Update partner info successfully,But You Had add new Referrer,Please Change the BD Commission Proportion!' + } + if ($scope.partner.client_pay_type.length == 0) { + alert('请选择商户支付场景') + return + } + if ($scope.partner.client_pay_desc.length == 0) { + alert('请选择商户支付方式') + return + } + if ($scope.partner.client_pay_type.indexOf('1') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) { + alert('请检查线上支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_type.indexOf('2') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) { + alert('请检查线下支付场景是否已选择支付方式') + return + } + } + if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) { + if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0 && $scope.partner.client_pay_desc.join(',').indexOf('20399') < 0) { + alert('请检查线下支付是否已选择收银系统类型') + return + } + } + $scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',') + $scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',') + $http.put('/sys/partners/' + $scope.partner.client_moniker, $scope.partner).then( + function () { + if (content != '') { + commonDialog.alert({ + title: 'Warning', + content: content, + type: 'error', + }) + } else { + commonDialog.alert({ + title: 'Success', + content: 'Update partner information successfully', + type: 'success', + }) + } + $scope.updateMerchantLocation() + $scope.loadPartners() + $state.go('^.detail', {clientMoniker: $scope.partner.client_moniker}, {reload: true}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.uploadLogo = function (file) { + if (file != null) { + if (file.size > 1 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB,请压缩后重试', type: 'error'}) + } else { + $scope.logoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.logoProgress + $scope.partner.logo_id = resp.data.fileid + $scope.partner.logo_url = resp.data.url + }, + function (resp) { + delete $scope.logoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.logoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadShopPhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.shopPhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.shopPhotoProgress + $scope.partner.company_photo = resp.data.url + }, + function (resp) { + delete $scope.shopPhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.shopPhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadStorePhoto = function (file) { + if (file != null) { + if (file.size > 2 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error'}) + } else { + $scope.storePhotoProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.storePhotoProgress + $scope.partner.store_photo = resp.data.url + }, + function (resp) { + delete $scope.storePhotoProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.storePhotoProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.getMerchantLocation = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { + $scope.merchant_location = resp.data + }) + } + $scope.getMerchantLocation() + + $scope.updateMerchantLocation = function () { + var params = window.frames['merchant_detail'].merchant_location + if (params) { + $http.put('/sys/partners/modify/' + $scope.partner.client_moniker + '/location', params).then(function () { + }) + } + } + }, + ]) + app.controller('partnerListCtrl', [ + '$scope', + '$sce', + '$http', + '$filter', + '$uibModal', + 'businessStructuresMap', + 'industryMap', + 'stateMap', + 'sectorMap', + 'countryMap', + function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { + $scope.analysisClients = function () { + $http.get('/sys/partners/analysis').then(function (resp) { + $scope.analysis = resp.data + }) + } + if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { + $scope.analysisClients() + } + $scope.pagination = {} + $scope.industries = industryMap.configs() + $scope.states = stateMap.configs() + $scope.countries = countryMap.configs() + $scope.sectors = sectorMap.configs() + $scope.business_structures = businessStructuresMap.configs() + $scope.clean_days = angular.copy(clean_days_map) + $scope.bd_citys = angular.copy(bd_city_map) + $scope.params = {textType: 'all', org_name: 'ALL', industry: '0'} + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + var selectAll = { + label: 'All', + mccCode: '0', + children: {}, + } + $scope.royalpayindustry.unshift(selectAll) + }) + } + + $scope.loadRoyalpayindustry() + + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.params.royalpay_label = selectedItem.label + $scope.params.industry = selectedItem.mccCode + $scope.loadPartners(1) + } + + $scope.loadPartners = function (page) { + var params = angular.copy($scope.params) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners', {params: params}).then(function (resp) { + $scope.partners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } + + $scope.exportPartnersExcel = function () { + var params = angular.copy($scope.params) + var param_str = Object.keys(params) + .map(function (key) { + var value = params[key] + if (angular.isDate(value)) { + value = $filter('date')(value, 'yyyy-MM-ddTHH:mm:ssZ') + } + return key + '=' + encodeURIComponent(value) + }) + .join('&') + window.open('/sys/partners/exporting_excel?' + param_str) + } + + /*$scope.loadLocations = function () { + var params = angular.copy($scope.params); + $http.get('/sys/partners/merchant/list_locations', {params: params}).then(function (resp) { + $scope.locations = resp.data; + window.merchant_maps.initMap($scope.locations); + }); + };*/ + $scope.today = new Date() + + $scope.listBDUsers = function () { + $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { + $scope.bdUserSource = resp.data + }) + } + $scope.listBDUsers() + + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + $scope.showOrg = 'Organization' + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { + $scope.orgs = resp.data + }) + } + + $scope.loadOrgs = function () { + var params = angular.copy($scope.params) + $http.get('/sys/orgs/orgChild', {params: params}).then(function (resp) { + $scope.orgs_child = resp.data + }) + } + $scope.loadOrgs() + + /* $scope.onOrgsSelect = function (selectedItem) { + $scope.params.org_id = selectedItem.org_id; + $scope.params.org_name = selectedItem.label; + $scope.loadPartners(); + }; + */ + /* $scope.chooseOrg = function (org) { + if (org == 'all') { + delete $scope.params.org_id; + $scope.showOrg = 'All' + } else { + $scope.params.org_id = org.org_id; + $scope.showOrg = org.name; + } + $scope.loadPartners(1); + };*/ + + $scope.loadPartners(1) + + $scope.openClientBoard = function (client) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/partner_card.html', + controller: 'partnerCardCtrl', + resolve: { + clientMoniker: function () { + return client.client_moniker + }, + }, + size: 'lg', + }) + } + /*$scope.toogleMapSelect = function () { + $scope.mapFrame = 'all_locations.html'; + $scope.loadLocations(); + } + $scope.toogleMerchantSelect = function () { + $scope.mapFrame = null; + } + $scope.toogleMerchantSelect();*/ + }, + ]) + app.controller('compliancePartnerCtrl', [ + '$scope', + '$sce', + '$http', + '$filter', + '$uibModal', + 'businessStructuresMap', + 'industryMap', + 'stateMap', + 'sectorMap', + 'countryMap', + function ($scope, $sce, $http, $filter, $uibModal, businessStructuresMap, industryMap, stateMap, sectorMap, countryMap) { + $scope.analysisClients = function () { + $http.get('/sys/partners/analysis').then(function (resp) { + $scope.analysis = resp.data + }) + } + if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { + $scope.analysisClients() + } + $scope.pagination = {} + $scope.industries = industryMap.configs() + $scope.states = stateMap.configs() + $scope.countries = countryMap.configs() + $scope.sectors = sectorMap.configs() + $scope.business_structures = businessStructuresMap.configs() + $scope.clean_days = angular.copy(clean_days_map) + $scope.bd_citys = angular.copy(bd_city_map) + $scope.params = {textType: 'all', org_name: 'ALL', approving_flag: false, card_approving_flag: false} + + $scope.loadPartners = function (page) { + $scope.validAndCleanApproveStatus() + var params = angular.copy($scope.params) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/compliance', {params: params}).then(function (resp) { + $scope.partners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } + + $scope.validAndCleanApproveStatus = function () { + if (!$scope.params.cross_approving_flag && !$scope.params.card_approving_flag) { + $scope.params.approving = false + $scope.params.card_approving = false + $scope.params.waitingCompliance = false + $scope.params.tempMchId = false + $scope.params.bd_upload_material = false + $scope.params.quickPass = false + $scope.params.greenChannel = false + $scope.params.pass = false + $scope.params.completed_contract = false + $scope.params.apply_to_back = false + $scope.params.is_valid = false + } + if (!$scope.params.cross_approving_flag && $scope.params.card_approving_flag) { + $scope.params.tempMchId = false + $scope.params.quickPass = false + $scope.params.greenChannel = false + } + } + + $scope.today = new Date() + + $scope.listBDUsers = function () { + $http.get('/sys/manager_accounts/roles/bd_user').then(function (resp) { + $scope.bdUserSource = resp.data + }) + } + $scope.listBDUsers() + + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + $scope.showOrg = 'Organization' + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { + $scope.orgs = resp.data + }) + } + + $scope.loadOrgs = function () { + var params = angular.copy($scope.params) + $http.get('/sys/orgs/orgChild', {params: params}).then(function (resp) { + $scope.orgs_child = resp.data + }) + } + $scope.loadOrgs() + + $scope.loadPartners(1) + + $scope.openClientBoard = function (client) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/partner_card.html', + controller: 'partnerCardCtrl', + resolve: { + clientMoniker: function () { + return client.client_moniker + }, + }, + size: 'lg', + }) + } + }, + ]) + app.controller('partnerDetailCtrl', [ + '$scope', + '$http', + '$state', + '$uibModal', + '$rootScope', + 'Upload', + 'commonDialog', + 'partner', + '$sce', + function ($scope, $http, $state, $uibModal, $rootScope, Upload, commonDialog, partner, $sce) { + $scope.init = {wechat_compliance: false, local_merchant: false} + $scope.partner = partner.data + $scope.isComplianceOfCompanyName = false + $scope.isComplianceOfShortName = false + $scope.isComplianceOfBusinessStructure = false + $scope.cardPromotionaparams = {} + if ($scope.partner.mc_code) { + $scope.partner.mc_code = 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', + }) + } + ) + }) + } + $scope.getMerchantLocation = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { + $scope.merchant_location = resp.data + }) + } + $scope.getMerchantLocation() + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.clientInfo = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + $scope.changeWechatCompliance = function () { + if (!$scope.partner) { + return + } + if (!$state.is('partners.detail')) { + $scope.init.wechat_compliance = false + return + } + if (!$scope.init.wechat_compliance) { + $scope.init.wechat_compliance = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_compliance_permission', {allow: $scope.partner.wechat_compliance}).then( + function () { + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change wechat_compliance permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.changeLocalMerchant = function () { + if (!$scope.partner) { + return + } + if (!$state.is('partners.detail')) { + $scope.init.local_merchant = false + return + } + if (!$scope.init.local_merchant) { + $scope.init.local_merchant = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/local_merchant_permission', {allow: $scope.partner.local_merchant}).then( + function () { + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change local_merchant permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.removeSub = function () { + $http.delete('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + }) + } + $scope.addSub = function () { + $http.put('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { + $state.reload() + }) + } + }, + ]) + app.controller('partnerPaymentInfoCtrl', [ + '$scope', + '$http', + '$state', + 'commonDialog', + '$uibModal', + '$sce', + function ($scope, $http, $state, commonDialog, $uibModal, $sce) { + $scope.convertExtParams = [] + $scope.copyHfLink = function () { + var e = document.getElementById('cpbt') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.copyYeepayLink = function () { + var e = document.getElementById('cpyeepay') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.copyCBBankPayLink = function () { + var e = document.getElementById('cpcbbankpay') + e.select() + var successful = document.execCommand('Copy') + if (successful) { + commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'}) + } else { + commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'}) + } + } + $scope.loadPartnerPaymentInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.extParams = {} + $scope.paymentInfo = resp.data + $scope.extParams = $scope.paymentInfo.ext_params ? JSON.parse($scope.paymentInfo.ext_params) : null + $scope.convertExtParams = $scope.extParamsEditFlags() + $scope.ctrl.editSubMerchant = false + $scope.ctrl.editAliSubMerchant = false + $scope.ctrl.editMaxOrderAmount = false + $scope.ctrl.editOrderExpiryConfig = false + $scope.ctrl.editRefundPwd = false + $scope.ctrl.editRefundCreditLine = false + }) + } + $scope.extParamsEditFlags = function () { + var paramList = [] + if ($scope.extParams != null) { + for (var key in $scope.extParams) { + var obj = {} + if (typeof $scope.extParams[key] != 'boolean') { + obj.name = key + obj.value = $scope.extParams[key] + obj.type = 'string' + obj.flag = false + } else { + obj.name = key + obj.value = $scope.extParams[key] + obj.type = 'boolean' + } + paramList.push(obj) + } + } + return paramList + } + $scope.qrConfig = {currency: 'AUD'} + $scope.reloadQRCode = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/qrcode', {params: $scope.qrConfig}).then(function (resp) { + $scope.qrcode = resp.data + }) + } + $scope.reloadQRCode() + $scope.loadPartnerPaymentInfo() + + $scope.showSubMerchantLogs = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', + controller: 'clientSubMerchantIdLogCtrl', + size: 'lg', + resolve: { + logs: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') + }, + ], + }, + }) + .result.then(function () { + $scope.loadSubClients() + }) + } + + $scope.saveMaxOrderAmount = function (limit) { + if (limit != null && isNaN(limit)) { + commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'}) + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/max_order_amount', {limit: limit}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.saveCustomerSurchargeRate = function (cofig) { + if (cofig != null && isNaN(cofig)) { + commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'}) + return + } + if (!$scope.paymentInfo.rate_value) { + commonDialog.alert({ + title: 'Error', + content: 'The merchant has not pass approval process', + type: 'error', + }) + return + } + if (cofig > 3 || cofig < parseFloat(Decimal.add($scope.paymentInfo.rate_value, 0.1).toFixed(2))) { + commonDialog.alert({title: 'Error', content: 'Not in the valid range', type: 'error'}) + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_surcharge_rate', {customer_surcharge_rate: cofig}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + $scope.ctrl.editCustomerSurchargeRate = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.saveOrderExpiryConfig = function (config) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/order_expiry_config', {order_expiry_config: config}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.resetRefundPwd = function (config) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/reset/refund_pwd', {new_refund_password: config}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.setRefundCreditLine = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_credit_line', {refund_credit_line: $scope.paymentInfo.refund_credit_line}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.updateClientQRCodePaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.qrcode_surcharge) { + $scope.init.qrcode_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/qrcode_surcharge', {qrcode_surcharge: $scope.paymentInfo.qrcode_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.updateClientCBBankPaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_surcharge', {cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge}).then( + function () { + // $scope.loadPartnerPaymentInfo(); + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Customer Pay for Surcharge for Retail', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.updateClientApiSurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.api_surcharge) { + $scope.init.api_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/api_surcharge', {api_surcharge: $scope.paymentInfo.api_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.updateClientRetailPaySurCharge = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.retail_surcharge) { + $scope.init.retail_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/retail_surcharge', {retail_surcharge: $scope.paymentInfo.retail_surcharge}).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function () { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.ctrl = {} + $scope.saveSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: $scope.paymentInfo.sub_merchant_id}).then( + function (resp) { + $scope.refreshWechatInstitutionMerchantId() + $scope.ctrl.editSubMerchant = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + $scope.refreshWechatInstitutionMerchantId = function () { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { + wechat_institution_merchant_id: $scope.paymentInfo.wechat_institution_merchant_id, + }) + .then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.saveAliSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.paymentInfo.ali_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Ali Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.submitAlipaySubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { + $scope.alipay_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipay_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( + function () { + commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'}) + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + $scope.queryAlipayGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + $scope.submitAlipayOnlineSubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { + $scope.alipayOnline_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipayOnline_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( + function () { + commonDialog.alert({ + title: 'Success', + content: '提示:AlipayOnline进件成功', + type: 'success' + }) + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + $scope.queryAlipayOnlineGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + $scope.refreshCredential = function () { + commonDialog + .confirm({ + title: 'Warning', + content: 'Refresh Credential will expire the current one, which will cause the current payment service disabled. Are you sure going on?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/credential_code').then( + function () { + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + $scope.init = { + jsapi: false, + gateway: false, + offline: false, + refund: false, + common_sub_merchant_id: false, + channel: {}, + gateway_alipay_online: false, + hf_Link: false, + enable_hf_email_notice: false, + enable_yeepay_link: false, + enable_yeepay_email_notice: false, + } + $scope.switchCommonSubMerchantId = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.common_sub_merchant_id) { + $scope.init.common_sub_merchant_id = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', {allow: $scope.paymentInfo.common_sub_merchant_id}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change common_sub_merchant_id permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchSubManage = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.sub_manage) { + $scope.init.sub_manage = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', {allow: $scope.paymentInfo.sub_manage}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + var info = [] + $scope.decideCompliance = function (name) { + var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] + for (var i = 0; i < keywords.length; i++) { + if (name.indexOf(keywords[i]) != -1) { + return true + } + } + return false + } + $scope.getComplianceInfo = function () { + if ($scope.paymentInfo.company_name != null) { + if ($scope.decideCompliance($scope.paymentInfo.company_name)) { + info.push('Company Name') + } + } + if ($scope.paymentInfo.short_name != null) { + if ($scope.decideCompliance($scope.paymentInfo.short_name)) { + info.push('Short Name') + } + } + if ($scope.paymentInfo.business_structure != null) { + if ($scope.decideCompliance($scope.paymentInfo.business_structure)) { + info.push('Business Structure') + } + } + } + $scope.switchAlipayCn = function (clientId, apsConfigId, alipayCn) { + if (!$scope.paymentInfo.enable_alipayaps) { + commonDialog.alert({ + title: 'ERROR', + content: "AlipayCN channel can be switched only after Alipay+(APS) is enabled", + type: 'error', + }) + $scope.loadPartnerPaymentInfo() + } else { + $http.put('/sys/partners/aps/' + clientId, {id: apsConfigId, alipayCnSwitch: alipayCn}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change alipayCN channel permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + } + $scope.toggleChannel = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + // if (!$scope.init.channel[channel]) { + // $scope.init.channel[channel] = true + // return + // } + if($scope.paymentInfo.alipay_cn_switch){ + commonDialog.alert({ + title: 'ERROR', + content: "Please switch AlipayCN to Alipay channel, and then close Alipay+(APS) channel", + type: 'error', + }) + $scope.loadPartnerPaymentInfo() + return; + } + $scope.getComplianceInfo() + if ($scope.paymentInfo['enable_wechat'] && channel == 'wechat' && $scope.paymentInfo.open_status == 5 && info.length > 0) { + commonDialog + .confirm({ + title: 'Warning', + contentHtml: $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息'), + }) + .then(function () { + $scope.saveChannel(channel) + }) + } else { + $scope.saveChannel(channel) + } + info = [] + } + $scope.saveChannel = function (channel) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/channels/' + channel + '/permission', {allow: $scope.paymentInfo['enable_' + channel]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channel + ' channel permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleHfLink = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.hf_Link) { + $scope.init.hf_Link = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf', {allow: $scope.paymentInfo.enable_link}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change enable_link permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleGatewayLink = function (channel) { + if (!channel) { + return + } + if (!$scope.paymentInfo) { + return + } + var channelLink = 'enable_' + channel + '_link' + if (!$scope.init[channelLink]) { + $scope.init[channelLink] = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel, {allow: $scope.paymentInfo[channelLink]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channelLink + ' permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleCBBankPayLink = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', {allow: $scope.paymentInfo.enable_cb_bankpay_link}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change cb_bankpay permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.cb_bankpay = [] + $scope.cbChannelConfig = function () { + $http.get('/sysconfig/payment/config').then(function (resp) { + resp.data.forEach(function (channel) { + if (channel.type === 1) { + $scope.cb_bankpay.push(channel) + } + }) + }) + } + $scope.cbChannelConfig() + $scope.updateCBBankPayConfig = function (key, channel) { + var content = '' + if (channel == null) { + content = '你确定要将支付通道跟随系统' + } else { + content = '你确定要将支付通道更改为:' + channel + } + commonDialog + .confirm({ + title: 'Confirm', + content: content, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay/' + key + '/channel_id', {channel_id: channel}).then( + function (resp) { + commonDialog.alert({type: 'success', title: 'Success', content: '修改成功'}) + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}) + $scope.loadPartnerPaymentInfo() + } + ) + }) + } + $scope.toggleGatewayEmailNotice = function (channel) { + if (!$scope.paymentInfo) { + return + } + var channelNotice = 'enable_' + channel + '_email_notice' + if (!$scope.init[channelNotice]) { + $scope.init[channelNotice] = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel + '/email_notice', {allow: $scope.paymentInfo[channelNotice]}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change ' + channelNotice + ' permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleHfEmailNotice = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_hf_email_notice) { + $scope.init.enable_hf_email_notice = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf/email_notice', {allow: $scope.paymentInfo.enable_hf_email_notice}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change enable_hf_email_notice permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleJsApi = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.jsapi) { + $scope.init.jsapi = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/jsapi_permission', {allow: $scope.paymentInfo.enable_jsapi}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change JSApi permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGateway = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway) { + $scope.init.gateway = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_permission', {allow: $scope.paymentInfo.enable_gateway}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGatewayUpgrade = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway_upgrade) { + $scope.init.gateway_upgrade = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_upgrade', {gateway_upgrade: $scope.paymentInfo.gateway_upgrade}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway Upgrade status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleGatewayAlipayOnline = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.gateway_alipay_online) { + $scope.init.gateway_alipay_online = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_alipay_online', {gateway_alipay_online: $scope.paymentInfo.gateway_alipay_online}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Gateway Alipay Online status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleRefund = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_refund) { + $scope.init.enable_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_permission', {allow: $scope.paymentInfo.enable_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Refund permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.togglePreRefund = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_pre_refund) { + $scope.init.enable_pre_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/pre_refund_permission', {allow: $scope.paymentInfo.enable_pre_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Refund permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + $scope.toggleOffline = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.offline) { + $scope.init.offline = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/offline_permission', {allow: $scope.paymentInfo.enable_retail}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Offline permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchInternationalCard = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_International_card) { + $scope.init.enable_International_card = true + return + } + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { + key: 'enable_international_card', + allow: $scope.paymentInfo.enable_international_card, + }) + .then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change international card permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchThreeDS = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.enable_threeds) { + $scope.init.enable_threeds = true + return + } + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', { + allow: $scope.paymentInfo.enable_threeds, + key: 'enable_threeds', + }) + .then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change international card permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changePaymentPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_page_version', {paypad_version: $scope.paymentInfo.paypad_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Payment Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changeCBBankPaymentPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_payment_page_version', {cbbank_paypad_version: $scope.paymentInfo.cbbank_paypad_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change CBBank Payment Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + // 更改支付成功页 + $scope.changePaySuccessPage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/paysuccess_version', {paysuccess_version: $scope.paymentInfo.paysuccess_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change Payment Success Page Version', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleRequireCustInfo = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.require_custinfo) { + $scope.init.require_custinfo = true + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireCustinfo', {allow: $scope.paymentInfo.require_custinfo}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require customer Info permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.toggleRequireRemark = function () { + if (!$scope.paymentInfo) { + return + } + if (!$scope.init.require_remark) { + $scope.init.require_remark = true + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/requireRemark', {allow: $scope.paymentInfo.require_remark}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require remark permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.changeBillCodeVersion = function () { + if (!$scope.paymentInfo) { + return + } + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/selectBillVersion', {version: $scope.paymentInfo.billcode_version}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'failed to change require bill version permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.extChangeParam = function (name, value) { + var flag = true + $scope.convertExtParams.forEach(function (params) { + if (params.name == name && value == '' && params.type == 'string') { + flag = false + } + }) + if (flag) { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/ext_config', { + key: name, + value: value, + }) + .then(function () { + $scope.loadPartnerPaymentInfo() + }) + } + } + + $scope.queryWechatSubMerchantIdStatus = function () { + $scope.paymentInfo.sub_merchant_id + $http.get('/sys/partners/' + $scope.paymentInfo.client_moniker + '/get_merchant_ids/' + $scope.paymentInfo.sub_merchant_id + '/status').then(function (resp) { + commonDialog.alert({ + title: 'Wechat Apply Status(' + resp.data.apply_status + ')', + content: resp.data.response_str, + type: 'info', + }) + }) + } + // GatewayAlipay渠道 + $scope.setAlipayChannel = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/modifyAlipayPaymentChannels/' + $scope.partner.client_id + '/' + $scope.paymentInfo.alipay_payment_channels).then( + function (resp) { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('clientSubMerchantIdLogCtrl', [ + '$scope', + '$http', + 'logs', + function ($scope, $http, logs) { + $scope.logs = logs.data + }, + ]) + app.controller('partnerSubCtrl', [ + '$scope', + '$http', + '$uibModal', + function ($scope, $http, $uibModal) { + $scope.toShow = false + $scope.init = { + child_each_refund: false, + sub_manage: false, + } + + $scope.newSubClient = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/add_sub_partner_dialog.html', + controller: 'partnerNewSubPartnerDialogCtrl', + size: 'lg', + resolve: { + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.loadSubClients(1) + }) + } + + $scope.loadSubClients = function (page) { + var params = {} + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + $scope.subPartners = resp.data.data + $scope.pagination = resp.data.pagination + }) + } + + $scope.loadSubClients(1) + + $scope.loadPartnerPaymentInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.paymentInfo = resp.data + }) + } + $scope.loadPartnerPaymentInfo() + + $scope.switchSubManage = function () { + if (!$scope.paymentInfo) { + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', {allow: $scope.partner.sub_manage}).then( + function () { + //$scope.loadPartnerPaymentInfo(); + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.switchChildEachRefund = function () { + if (!$scope.partner) { + return + } + if (!$scope.init.child_each_refund) { + $scope.init.child_each_refund = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/child_each_refund', {allow: $scope.partner.child_each_refund}).then( + function () { + $scope.loadPartnerPaymentInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change Sub Partners Manage status', + content: resp.data.message, + type: 'error', + }) + } + ) + } + + $scope.showClient = function (sub_client) { + if ($scope.sub_client_id == sub_client.client_id) { + return + } + $scope.client_monikers = sub_client.level3Clients + $scope.sub_client_id = sub_client.client_id + } + }, + ]) + app.controller('partnerRatesCtrl', [ + '$scope', + '$rootScope', + '$http', + '$uibModal', + 'commonDialog', + '$sce', + '$state', + function ($scope, $rootScope, $http, $uibModal, commonDialog, $sce, $state) { + $scope.bankCtrl = {edit: true, rate_name: 'Wechat', modify_min_settle: false} + $scope.init = { + skip_clearing: false, + tax_in_surcharge: false, + customer_tax_free: false, + allow_surcharge_credit: false, + } + $scope.getBankAccount = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account').then(function (resp) { + $scope.bankaccount = resp.data + $scope.bankCtrl.edit = false + }) + } + $scope.switchSurchargeMode = function () { + if ($scope.partner.surcharge_mode === 'balance') { + commonDialog + .confirm({ + title: 'Warning', + content: '启用收支分离模式清算将使消费者支付手续费模式失效,请确认是否切换?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', {surcharge_mode: 'distributed'}).then( + function () { + commonDialog.alert({title: 'Success', content: '已切换为收支分离模式', type: 'success'}) + $scope.partner.surcharge_mode = 'distributed' + $scope.getBalance() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + commonDialog + .confirm({ + title: 'Warning', + content: '请确认是否切换成净值清算模式?', + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', {surcharge_mode: 'balance'}).then( + function () { + commonDialog.alert({title: 'Success', content: '已切换为净值清算模式', type: 'success'}) + $scope.partner.surcharge_mode = 'balance' + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + } + $scope.modifyMinSettle = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/min_settle', {min_settle: $scope.partner.min_settle}).then( + function () { + commonDialog.alert({title: 'Success', content: '修改起结金额成功', type: 'success'}) + $scope.bankCtrl.modify_min_settle = false + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.getBalance = function () { + $scope.surcharge = {} + + if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode === 'distributed') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { + $scope.surcharge = resp.data + }) + } + } + $scope.getBalance() + $scope.getBankAccount() + $scope.getRates = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/rates').then(function (resp) { + $scope.rates = resp.data + angular.forEach($scope.rates, function (rate) { + rate.active_time = new Date(rate.active_time.substr(0, 10).replace(/-/g, '/')) + rate.expiry_time = new Date(rate.expiry_time.substr(0, 10).replace(/-/g, '/')) + }) + }) + } + $scope.skipClearing = function (skipClearing) { + if (!$scope.init.skip_clearing) { + $scope.init.skip_clearing = true + return + } + if (skipClearing) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + }) + .then(function () { + commonDialog.inputText({title: '请输入跳过清算的原因'}).then(function (text) { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { + skip_clearing: skipClearing, + remark: text, + }) + .then(function (resp) { + $scope.getBankAccount() + }) + }) + }) + } else { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will switch skip clearing status. Are you sure?', + // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', {skip_clearing: skipClearing}).then(function (resp) { + $scope.getBankAccount() + }) + }) + } + } + $scope.surchargeAccountDetail = function () { + $uibModal + .open({ + templateUrl: '/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html', + controller: 'surchargeAccountDetailCtrl', + size: 'lg', + resolve: { + balance: function () { + return $scope.surcharge + }, + partner: function () { + return $scope.partner + }, + transactions: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions') + }, + ], + }, + }) + .result.then( + function () { + $scope.getBalance() + }, + function () { + $scope.getBalance() + } + ) + } + $scope.allowSurchargeCredit = function (allowSurchargeCredit) { + if (!$scope.init.allow_surcharge_credit) { + $scope.init.allow_surcharge_credit = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/allow_surcharge_credit', {allow_surcharge_credit: allowSurchargeCredit}).then(function (resp) { + }) + } + $scope.taxInSurcharge = function (taxInSurcharge) { + if (!$scope.init.tax_in_surcharge) { + $scope.init.tax_in_surcharge = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/tax_in_surcharge', {tax_in_surcharge: taxInSurcharge}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.switchPreSettle = function (presettle) { + if (!$scope.init.enable_presettle) { + $scope.init.enable_presettle = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/presettle', {enable_presettle: presettle}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.customerTaxFree = function (customerTaxFree) { + if (!$scope.init.customer_tax_free) { + $scope.init.customer_tax_free = true + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_tax_free', {customer_tax_free: customerTaxFree}).then(function (resp) { + $scope.getBankAccount() + }) + } + $scope.settleHours = [{value: undefined, label: 'Default(24:00, GMT+10)'}] + for (var h = 24; h > 0; h--) { + $scope.settleHours.push({value: h, label: ('00' + h).substr(-2) + ':00, ' + $scope.partner.timezone}) + } + $scope.settleHourConfig = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/settle_hour', {hour: $scope.partner.settle_hour || null}).then( + function () { + commonDialog.alert({type: 'success', title: 'OK', content: 'Settle Hour configured'}) + }, + function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}) + } + ) + } + $scope.getBankInfo = function (bsb_no) { + if (bsb_no != null && bsb_no !== '') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account/bank_info/' + bsb_no).then(function (resp) { + $scope.bankInfo = resp.data + $scope.bankaccount.bank = $scope.bankInfo.bank + $scope.bankaccount.city = $scope.bankInfo.city + $scope.bankaccount.address = $scope.bankInfo.address + $scope.bankaccount.system = $scope.bankInfo.system + $scope.bankaccount.postcode = $scope.bankInfo.postcode + $scope.bankaccount.state = $scope.bankInfo.state + $scope.bankaccount.branch = $scope.bankInfo.branch + }) + } else { + commonDialog.alert({title: 'Error', content: '请先填写BSB No', type: 'error'}) + } + } + $scope.getRates() + $scope.saveBankAccount = function () { + if (isNaN($scope.bankaccount.account_no)) { + alert('Account No应输入数字!') + return + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/bank_account', $scope.bankaccount).then( + function () { + $scope.getBankAccount() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.newCardPaymentRates = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_card_payment_rate.html', + controller: 'newCardPaymentRateDialogCtrl', + resolve: { + sys_common_rate: function () { + return $http.get('/sys/partners/sys_card_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + cost_rate_channel: function () { + return $scope.cost_rate_channel + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + $scope.newRate = function () { + var name = $scope.bankCtrl.rate_name + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_rate.html', + controller: 'newRateDialogCtrl', + resolve: { + rate: function () { + return {rate_name: name, clean_days: 3} + }, + sys_common_rate: function () { + return $http.get('/sys/partners/sys_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + $scope.editRate = function (rate) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/rate_config_dialog.html', + controller: 'rateConfigDialogCtrl', + resolve: { + rate: function () { + return rate + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + }) + .result.then(function () { + $scope.getRates() + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.bankAccount = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + // 是否为alipayplus + $scope.isAlipayCN = true + // 修改渠道 + $scope.changeAlipayPlusRateState = function (flag) { + $scope.isAlipayCN = flag + } + // 过滤渠道 + $scope.isAlipayPlus = function (item) { + if ($scope.isAlipayCN) { + return item.rate_name === 'AlipayPlus' && (item.pay_type === 'alipay_cn_retail' || item.pay_type === 'alipay_cn_online') + } else { + return item.rate_name === 'AlipayPlus' && item.pay_type === 'alipay_other' + } + } + // 新增alipay+费率 + $scope.newAlipayPlusRate = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/partner_new_alipayplus_rate.html', + resolve: { + rate: function () { + return { + rate_name: 'AlipayPlus', + clean_days: '3', + } + }, + sys_common_rate: function () { + return $http.get('/sys/partners/sys_rates') + }, + clientMoniker: function () { + return $scope.partner.client_moniker + }, + }, + controller: [ + '$scope', + '$http', + 'rate', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, rate, sys_common_rate, clientMoniker) { + $scope.rate = angular.copy(rate) + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + // if ($scope.rate.clean_days) { + // switch ($scope.rate.clean_days) { + // case '1': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t1.AlipayPlus) + // break + // } + // case '2': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t2.AlipayPlus) + // break + // } + // case '3': { + // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t3.AlipayPlus) + // break + // } + // } + // } + } + }, + ], + }) + .result.then(function () { + $scope.getRates() + }) + } + }, + ]) + app.controller('surchargeAccountDetailCtrl', [ + '$scope', + '$http', + 'balance', + 'partner', + 'transactions', + 'commonDialog', + function ($scope, $http, balance, partner, transactions, commonDialog) { + $scope.surcharge = angular.copy(balance) + $scope.surchargeDetailData = angular.copy(transactions.data) + $scope.partner = angular.copy(partner) + $scope.canAddDetail = false + $scope.params = {} + + $scope.getBalance = function () { + if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode == 'distributed') { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { + $scope.surcharge = resp.data + }) + } + } + + $scope.getTransactions = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions').then(function (resp) { + $scope.surchargeDetailData = resp.data + }) + } + + $scope.addDetail = function () { + $scope.canAddDetail = true + } + + $scope.cancel = function () { + $scope.canAddDetail = false + $scope.params = {} + } + $scope.save = function () { + $http + .post('/sys/partners/' + $scope.partner.client_moniker + '/account/save', { + amount: $scope.params.amount, + remark: $scope.params.remark, + }) + .then( + function (resp) { + $scope.getTransactions() + $scope.getBalance() + $scope.canAddDetail = false + $scope.params = {} + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + app.controller('newCardPaymentRateDialogCtrl', [ + '$scope', + '$http', + 'sys_common_rate', + 'clientMoniker', + function ($scope, $http, sys_common_rate, clientMoniker) { + $scope.rate = {} + $scope.card_payment_normal = true + $scope.card_payment_switch_title = 'Direct Debit' + $scope.card_payment = [ + { + type: 'rpaypmt_card', + title: 'Card Payment', + }, + { + type: 'rpaypmt_dd', + title: 'Direct Debit', + }, + ] + $scope.cardRateConfig = $scope.card_payment[0] + $scope.switchCardRateConfig = function () { + $scope.card_payment_normal = !$scope.card_payment_normal + $scope.rate = {} + if ($scope.card_payment_normal) { + $scope.cardRateConfig = $scope.card_payment[0] + $scope.card_payment_switch_title = 'Direct Debit' + } else { + $scope.cardRateConfig = $scope.card_payment[1] + $scope.card_payment_switch_title = 'Card Payment' + } + } + $scope.sysRateConfig = angular.copy(sys_common_rate.data) + $scope.ctrl = {sending: false} + $scope.saveRate = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.errmsg = null + $scope.ctrl.sending = true + $scope.rate.type = $scope.cardRateConfig.type + $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + function () { + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + $scope.errmsg = resp.data.message + } + ) + } + $scope.changeDays = function () { + if ($scope.rate.clean_days && $scope.card_payment_normal) { + switch ($scope.rate.clean_days) { + case '1': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t1.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t1.transaction_fee) + break + } + case '2': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t2.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t2.transaction_fee) + break + } + case '3': { + $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t3.domestic_rate) + $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t3.transaction_fee) + break + } + } + } + } + }, + ]) + app.controller('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'}) + } ) - }, - function (resp) { - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - } - ) - } - } - } - - $scope.uploadCardAgreeFile = function (file) { - if (file != null) { - if (file.size > 2 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过2MB,请压缩后重试', type: 'error' }) - } else { - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.agree_file_import = resp.data.url - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/import/agreepdf', { source_agree_file: $scope.agree_file_import }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Succeed Imported! Please notify BD', - type: 'success', + } + $scope.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 + }, + }, }) - $state.reload() - }, - 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'}) + } + ) + }) + } + }, + ]) + 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 + } ) - }, - 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, - }) + } + }, + ]) + 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 { - 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', + $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 }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.markAuditEmail = function () { - commonDialog - .confirm({ - title: 'Warning', - content: 'Make sure you have send the email to client.', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/email_sending_status').then( - function () { - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.resendApproveEmail = function (type) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will reset the password of admin user. Are you sure this email is correct ? Or you may update this information first.', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/audit/send_email?type=' + type).then( - function () { - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.editBDUser = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', - controller: 'partnerChooseBDUserDialogCtrl', - resolve: { - bdUsers: [ - '$http', - function ($http) { - return $http.get('/sys/manager_accounts/roles/bd_user') - }, - ], - partner: function () { - return $scope.partner - }, - type: function () { - return 'edit' - }, - }, - }) - .result.then(function () { - $state.reload() - }) - } - $scope.bindBDUser = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/bd_user_choose_dialog.html', - controller: 'partnerChooseBDUserDialogCtrl', - resolve: { - bdUsers: [ - '$http', - function ($http) { - return $http.get('/sys/manager_accounts/roles/bd_user') - }, - ], - partner: function () { - return $scope.partner - }, - type: function () { - return 'add' - }, - }, - }) - .result.then(function () { - $state.reload() - }) - } - - $scope.configMasterMerchant = function () { - commonDialog.inputText({ title: 'Input Master Merchant Code' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/master_configuration', { master_merchant: text }).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Master Merchant Code:' + text, - type: 'success', - }) - }, - function (resp) { - commonDialog.alert({ - title: 'Config Master Merchant Failed', - content: resp.data.message, - type: 'error', - }) - } - ) - }) - } - $scope.getMerchantLocation = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) { - $scope.merchant_location = resp.data - }) - } - $scope.getMerchantLocation() - - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.clientInfo = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - - $scope.changeWechatCompliance = function () { - if (!$scope.partner) { - return - } - if (!$state.is('partners.detail')) { - $scope.init.wechat_compliance = false - return - } - if (!$scope.init.wechat_compliance) { - $scope.init.wechat_compliance = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_compliance_permission', { allow: $scope.partner.wechat_compliance }).then( - function () {}, - function (resp) { - commonDialog.alert({ - title: 'failed to change wechat_compliance permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.changeLocalMerchant = function () { - if (!$scope.partner) { - return - } - if (!$state.is('partners.detail')) { - $scope.init.local_merchant = false - return - } - if (!$scope.init.local_merchant) { - $scope.init.local_merchant = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/local_merchant_permission', { allow: $scope.partner.local_merchant }).then( - function () {}, - function (resp) { - commonDialog.alert({ - title: 'failed to change local_merchant permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.removeSub = function () { - $http.delete('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { - $state.reload() - }) - } - $scope.addSub = function () { - $http.put('/sys/partners/unsub/' + $scope.partner.client_moniker).then(function (resp) { - $state.reload() - }) - } - }, - ]) - app.controller('partnerPaymentInfoCtrl', [ - '$scope', - '$http', - '$state', - 'commonDialog', - '$uibModal', - '$sce', - function ($scope, $http, $state, commonDialog, $uibModal, $sce) { - $scope.convertExtParams = [] - $scope.copyHfLink = function () { - var e = document.getElementById('cpbt') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.copyYeepayLink = function () { - var e = document.getElementById('cpyeepay') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.copyCBBankPayLink = function () { - var e = document.getElementById('cpcbbankpay') - e.select() - var successful = document.execCommand('Copy') - if (successful) { - commonDialog.alert({ title: 'Success', content: '已复制到剪切板!', type: 'success' }) - } else { - commonDialog.alert({ title: 'Error', content: '您的浏览器不支持!', type: 'error' }) - } - } - $scope.loadPartnerPaymentInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.extParams = {} - $scope.paymentInfo = resp.data - $scope.extParams = $scope.paymentInfo.ext_params ? JSON.parse($scope.paymentInfo.ext_params) : null - $scope.convertExtParams = $scope.extParamsEditFlags() - $scope.ctrl.editSubMerchant = false - $scope.ctrl.editAliSubMerchant = false - $scope.ctrl.editMaxOrderAmount = false - $scope.ctrl.editOrderExpiryConfig = false - $scope.ctrl.editRefundPwd = false - $scope.ctrl.editRefundCreditLine = false - }) - } - $scope.extParamsEditFlags = function () { - var paramList = [] - if ($scope.extParams != null) { - for (var key in $scope.extParams) { - var obj = {} - if (typeof $scope.extParams[key] != 'boolean') { - obj.name = key - obj.value = $scope.extParams[key] - obj.type = 'string' - obj.flag = false - } else { - obj.name = key - obj.value = $scope.extParams[key] - obj.type = 'boolean' } - paramList.push(obj) - } - } - return paramList - } - $scope.qrConfig = { currency: 'AUD' } - $scope.reloadQRCode = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/qrcode', { params: $scope.qrConfig }).then(function (resp) { - $scope.qrcode = resp.data - }) - } - $scope.reloadQRCode() - $scope.loadPartnerPaymentInfo() - - $scope.showSubMerchantLogs = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', - controller: 'clientSubMerchantIdLogCtrl', - size: 'lg', - resolve: { - logs: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') - }, - ], - }, - }) - .result.then(function () { - $scope.loadSubClients() - }) - } - - $scope.saveMaxOrderAmount = function (limit) { - if (limit != null && isNaN(limit)) { - commonDialog.alert({ title: 'Error', content: 'Your input is not a number!', type: 'error' }) - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/max_order_amount', { limit: limit }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.saveCustomerSurchargeRate = function (cofig) { - if (cofig != null && isNaN(cofig)) { - commonDialog.alert({ title: 'Error', content: 'Your input is not a number!', type: 'error' }) - return - } - if (!$scope.paymentInfo.rate_value) { - commonDialog.alert({ - title: 'Error', - content: 'The merchant has not pass approval process', - type: 'error', - }) - return - } - if (cofig > 3 || cofig < parseFloat(Decimal.add($scope.paymentInfo.rate_value, 0.1).toFixed(2))) { - commonDialog.alert({ title: 'Error', content: 'Not in the valid range', type: 'error' }) - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_surcharge_rate', { customer_surcharge_rate: cofig }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - $scope.ctrl.editCustomerSurchargeRate = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.saveOrderExpiryConfig = function (config) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/order_expiry_config', { order_expiry_config: config }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.resetRefundPwd = function (config) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/reset/refund_pwd', { new_refund_password: config }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.setRefundCreditLine = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_credit_line', { refund_credit_line: $scope.paymentInfo.refund_credit_line }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.updateClientQRCodePaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.qrcode_surcharge) { - $scope.init.qrcode_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/qrcode_surcharge', { qrcode_surcharge: $scope.paymentInfo.qrcode_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.updateClientCBBankPaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cbbank_surcharge', { cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge }).then( - function () { - // $scope.loadPartnerPaymentInfo(); - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Customer Pay for Surcharge for Retail', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.updateClientApiSurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.api_surcharge) { - $scope.init.api_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/api_surcharge', { api_surcharge: $scope.paymentInfo.api_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.updateClientRetailPaySurCharge = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.retail_surcharge) { - $scope.init.retail_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/retail_surcharge', { retail_surcharge: $scope.paymentInfo.retail_surcharge }).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function () { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.ctrl = {} - $scope.saveSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: $scope.paymentInfo.sub_merchant_id }).then( - function (resp) { - $scope.refreshWechatInstitutionMerchantId() - $scope.ctrl.editSubMerchant = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.refreshWechatInstitutionMerchantId = function () { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { - wechat_institution_merchant_id: $scope.paymentInfo.wechat_institution_merchant_id, - }) - .then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.saveAliSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.paymentInfo.ali_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Ali Sub Merchant ID successfully', - type: 'success', - }) - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.submitAlipaySubId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { - $scope.alipay_gms_json = resp.data - commonDialog - .confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json: $scope.alipay_gms_json, - }) - .then(function () { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( - function () { - commonDialog.alert({ title: 'Success', content: 'Alipay进件成功', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: '进件失败:' + resp.data.message, type: 'error' }) + $scope.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.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.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 + } } - ) - }) - }) - } - $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', - }) - } - ) - } + } + var resetClientPayDescByTpey = function (type) { + type = parseInt(type) + if (type == 1) { + removeClientPayDesc($scope.partner.client_pay_desc, '10') + } + if (type == 2) { + removeClientPayDesc($scope.partner.client_pay_desc, '20') + } + } - $scope.switchSubManage = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.sub_manage) { - $scope.init.sub_manage = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', { allow: $scope.paymentInfo.sub_manage }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change Sub Partners Manage status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - var info = [] - $scope.decideCompliance = function (name) { - var keywords = ['education', 'financial', 'train', 'immigrant', 'invest', '律师咨询', '会计事务所', '移民', '留学', '娱乐', '金融', '地产', '投资'] - for (var i = 0; i < keywords.length; i++) { - if (name.indexOf(keywords[i]) != -1) { - return true - } - } - return false - } - $scope.getComplianceInfo = function () { - if ($scope.paymentInfo.company_name != null) { - if ($scope.decideCompliance($scope.paymentInfo.company_name)) { - info.push('Company Name') - } - } - if ($scope.paymentInfo.short_name != null) { - if ($scope.decideCompliance($scope.paymentInfo.short_name)) { - info.push('Short Name') - } - } - if ($scope.paymentInfo.business_structure != null) { - if ($scope.decideCompliance($scope.paymentInfo.business_structure)) { - info.push('Business Structure') - } - } - } - $scope.toggleChannel = function (channel) { - if (!channel) { - return - } - if (!$scope.paymentInfo) { - return - } - // if (!$scope.init.channel[channel]) { - // $scope.init.channel[channel] = true - // return - // } - $scope.getComplianceInfo() - if ($scope.paymentInfo['enable_wechat'] && channel == 'wechat' && $scope.paymentInfo.open_status == 5 && info.length > 0) { - commonDialog - .confirm({ - title: 'Warning', - contentHtml: $sce.trustAsHtml('本次提交的商户[' + $scope.partner.company_name + '],' + info.toString() + '存在微信渠道不合规信息'), - }) - .then(function () { - $scope.saveChannel(channel) - }) - } else { - $scope.saveChannel(channel) - } - info = [] - } - $scope.saveChannel = function (channel) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/channels/' + channel + '/permission', { allow: $scope.paymentInfo['enable_' + channel] }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change ' + channel + ' channel permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleHfLink = function (channel) { - if (!channel) { - return - } - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.hf_Link) { - $scope.init.hf_Link = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/hf', { allow: $scope.paymentInfo.enable_link }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change enable_link permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + 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.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.listReferrers = function () { + $http.get('/sys/orgs/referrer').then(function (resp) { + $scope.referrers = resp.data + }) + } + $scope.listReferrers() - $scope.toggleCBBankPayLink = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay', { allow: $scope.paymentInfo.enable_cb_bankpay_link }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change cb_bankpay permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.cb_bankpay = [] - $scope.cbChannelConfig = function () { - $http.get('/sysconfig/payment/config').then(function (resp) { - resp.data.forEach(function (channel) { - if (channel.type === 1) { - $scope.cb_bankpay.push(channel) - } - }) - }) - } - $scope.cbChannelConfig() - $scope.updateCBBankPayConfig = function (key, channel) { - var content = '' - if (channel == null) { - content = '你确定要将支付通道跟随系统' - } else { - content = '你确定要将支付通道更改为:' + channel - } - commonDialog - .confirm({ - title: 'Confirm', - content: content, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/cb_bankpay/' + key + '/channel_id', { channel_id: channel }).then( - function (resp) { - commonDialog.alert({ type: 'success', title: 'Success', content: '修改成功' }) - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message }) - $scope.loadPartnerPaymentInfo() - } - ) - }) - } - $scope.toggleGatewayEmailNotice = function (channel) { - if (!$scope.paymentInfo) { - return - } - var channelNotice = 'enable_' + channel + '_email_notice' - if (!$scope.init[channelNotice]) { - $scope.init[channelNotice] = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/' + channel + '/email_notice', { allow: $scope.paymentInfo[channelNotice] }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change ' + channelNotice + ' permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.alipayMccCategory = {} + $scope.loadAlipayCategory = function () { + $http.get('/static/data/alipayMcc.json').then(function (resp) { + $scope.alipayMccCategory = resp.data + }) + } + $scope.loadAlipayCategory() - $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.loadJDindustry = function () { + $http.get('/static/data/jdindustry.json').then(function (resp) { + $scope.jdindustry = resp.data + }) + } + $scope.loadJDindustry() - $scope.toggleJsApi = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.jsapi) { - $scope.init.jsapi = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/jsapi_permission', { allow: $scope.paymentInfo.enable_jsapi }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change JSApi permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGateway = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway) { - $scope.init.gateway = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_permission', { allow: $scope.paymentInfo.enable_gateway }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGatewayUpgrade = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway_upgrade) { - $scope.init.gateway_upgrade = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_upgrade', { gateway_upgrade: $scope.paymentInfo.gateway_upgrade }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway Upgrade status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleGatewayAlipayOnline = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.gateway_alipay_online) { - $scope.init.gateway_alipay_online = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/gateway_alipay_online', { gateway_alipay_online: $scope.paymentInfo.gateway_alipay_online }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Gateway Alipay Online status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleRefund = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_refund) { - $scope.init.enable_refund = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/refund_permission', { allow: $scope.paymentInfo.enable_refund }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Refund permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.togglePreRefund = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.enable_pre_refund) { - $scope.init.enable_pre_refund = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/pre_refund_permission', { allow: $scope.paymentInfo.enable_pre_refund }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Refund permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - $scope.toggleOffline = function () { - if (!$scope.paymentInfo) { - return - } - if (!$scope.init.offline) { - $scope.init.offline = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/offline_permission', { allow: $scope.paymentInfo.enable_retail }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change Offline permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.loadLakalaPayindustry = function () { + $http.get('/static/data/lakalapayindustry.json').then(function (resp) { + $scope.lakalapayindustry = resp.data + }) + } + $scope.loadLakalaPayindustry() - $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.loadLakalaPaySettle = function () { + $http.get('/static/data/lakalapaysettle.json').then(function (resp) { + $scope.lakalapaysettle = resp.data + }) + } + $scope.loadLakalaPaySettle() - $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.loadLakalaPayGoods = function () { + $http.get('/static/data/lakalapaygoods.json').then(function (resp) { + $scope.lakalapaygoods = resp.data + }) + } + $scope.loadLakalaPayGoods() - $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.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data + }) + } + $scope.loadRoyalpayindustry() - $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.loadHfindustry = function () { + $http.get('/static/data/hfindustry.json').then(function (resp) { + $scope.hfindustry = resp.data + }) + } + $scope.loadHfindustry() - $scope.changeBillCodeVersion = function () { - if (!$scope.paymentInfo) { - return - } - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/selectBillVersion', { version: $scope.paymentInfo.billcode_version }).then( - function () { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'failed to change require bill version permission status', - content: resp.data.message, - type: 'error', - }) - } - ) - } - - $scope.extChangeParam = function (name, value) { - var flag = true - $scope.convertExtParams.forEach(function (params) { - if (params.name == name && value == '' && params.type == 'string') { - flag = false - } - }) - if (flag) { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/ext_config', { - key: name, - value: value, - }) - .then(function () { - $scope.loadPartnerPaymentInfo() - }) - } - } - - $scope.queryWechatSubMerchantIdStatus = function () { - $scope.paymentInfo.sub_merchant_id - $http.get('/sys/partners/' + $scope.paymentInfo.client_moniker + '/get_merchant_ids/' + $scope.paymentInfo.sub_merchant_id + '/status').then(function (resp) { - commonDialog.alert({ - title: 'Wechat Apply Status(' + resp.data.apply_status + ')', - content: resp.data.response_str, - type: 'info', - }) - }) - } - // GatewayAlipay渠道 - $scope.setAlipayChannel = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/modifyAlipayPaymentChannels/' + $scope.partner.client_id + '/' + $scope.paymentInfo.alipay_payment_channels).then( - function (resp) { - $scope.loadPartnerPaymentInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('clientSubMerchantIdLogCtrl', [ - '$scope', - '$http', - 'logs', - function ($scope, $http, logs) { - $scope.logs = logs.data - }, - ]) - app.controller('partnerSubCtrl', [ - '$scope', - '$http', - '$uibModal', - function ($scope, $http, $uibModal) { - $scope.toShow = false - $scope.init = { - child_each_refund: false, - sub_manage: false, - } - - $scope.newSubClient = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_sub_partner_dialog.html', - controller: 'partnerNewSubPartnerDialogCtrl', - size: 'lg', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.loadSubClients(1) - }) - } - - $scope.loadSubClients = function (page) { - var params = {} - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', { params: params }).then(function (resp) { - $scope.subPartners = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - - $scope.loadSubClients(1) - - $scope.loadPartnerPaymentInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.paymentInfo = resp.data - }) - } - $scope.loadPartnerPaymentInfo() - - $scope.switchSubManage = function () { - if (!$scope.paymentInfo) { - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', { allow: $scope.partner.sub_manage }).then( - function () { - //$scope.loadPartnerPaymentInfo(); - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change Sub Partners Manage status', - content: resp.data.message, - type: 'error', - }) - } - ) - } + $scope.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.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.onHfIndustrySelect = function (selectedItem) { + $scope.partner.hf_label = selectedItem.label + $scope.partner.hfindustry = selectedItem.mccCode + } - $scope.showClient = function (sub_client) { - if ($scope.sub_client_id == sub_client.client_id) { - return - } - $scope.client_monikers = sub_client.level3Clients - $scope.sub_client_id = sub_client.client_id - } - }, - ]) - app.controller('partnerRatesCtrl', [ - '$scope', - '$rootScope', - '$http', - '$uibModal', - 'commonDialog', - '$sce', - '$state', - function ($scope, $rootScope, $http, $uibModal, commonDialog, $sce, $state) { - $scope.bankCtrl = { edit: true, rate_name: 'Wechat', modify_min_settle: false } - $scope.init = { - skip_clearing: false, - tax_in_surcharge: false, - customer_tax_free: false, - allow_surcharge_credit: false, - } - $scope.getBankAccount = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account').then(function (resp) { - $scope.bankaccount = resp.data - $scope.bankCtrl.edit = false - }) - } - $scope.switchSurchargeMode = function () { - if ($scope.partner.surcharge_mode === 'balance') { - commonDialog - .confirm({ - title: 'Warning', - content: '启用收支分离模式清算将使消费者支付手续费模式失效,请确认是否切换?', - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_mode', { surcharge_mode: 'distributed' }).then( - function () { - commonDialog.alert({ title: 'Success', content: '已切换为收支分离模式', type: 'success' }) - $scope.partner.surcharge_mode = 'distributed' - $scope.getBalance() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + // $scope.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 } - ) - }) - } 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.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.modifyMinSettle = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/min_settle', { min_settle: $scope.partner.min_settle }).then( - function () { - commonDialog.alert({ title: 'Success', content: '修改起结金额成功', type: 'success' }) - $scope.bankCtrl.modify_min_settle = false - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.getBalance = function () { - $scope.surcharge = {} - - if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode === 'distributed') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { - $scope.surcharge = resp.data - }) - } - } - $scope.getBalance() - $scope.getBankAccount() - $scope.getRates = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/rates').then(function (resp) { - $scope.rates = resp.data - angular.forEach($scope.rates, function (rate) { - rate.active_time = new Date(rate.active_time.substr(0, 10).replace(/-/g, '/')) - rate.expiry_time = new Date(rate.expiry_time.substr(0, 10).replace(/-/g, '/')) - }) - }) - } - $scope.skipClearing = function (skipClearing) { - if (!$scope.init.skip_clearing) { - $scope.init.skip_clearing = true - return - } - if (skipClearing) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?', - }) - .then(function () { - commonDialog.inputText({ title: '请输入跳过清算的原因' }).then(function (text) { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { - skip_clearing: skipClearing, - remark: text, - }) - .then(function (resp) { - $scope.getBankAccount() - }) - }) - }) - } else { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will switch skip clearing status. Are you sure?', - // contentHtml: $sce.trustAsHtml('This operation will switch skip clearing status. Are you sure?') - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/skip_clearing', { skip_clearing: skipClearing }).then(function (resp) { - $scope.getBankAccount() - }) - }) - } - } - $scope.surchargeAccountDetail = function () { - $uibModal - .open({ - templateUrl: '/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html', - controller: 'surchargeAccountDetailCtrl', - size: 'lg', - resolve: { - balance: function () { - return $scope.surcharge - }, - partner: function () { - return $scope.partner - }, - transactions: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions') - }, - ], - }, - }) - .result.then( - function () { - $scope.getBalance() - }, - function () { - $scope.getBalance() - } - ) - } - $scope.allowSurchargeCredit = function (allowSurchargeCredit) { - if (!$scope.init.allow_surcharge_credit) { - $scope.init.allow_surcharge_credit = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/allow_surcharge_credit', { allow_surcharge_credit: allowSurchargeCredit }).then(function (resp) {}) - } - $scope.taxInSurcharge = function (taxInSurcharge) { - if (!$scope.init.tax_in_surcharge) { - $scope.init.tax_in_surcharge = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/tax_in_surcharge', { tax_in_surcharge: taxInSurcharge }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.switchPreSettle = function (presettle) { - if (!$scope.init.enable_presettle) { - $scope.init.enable_presettle = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/presettle', { enable_presettle: presettle }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.customerTaxFree = function (customerTaxFree) { - if (!$scope.init.customer_tax_free) { - $scope.init.customer_tax_free = true - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/customer_tax_free', { customer_tax_free: customerTaxFree }).then(function (resp) { - $scope.getBankAccount() - }) - } - $scope.settleHours = [{ value: undefined, label: 'Default(24:00, GMT+10)' }] - for (var h = 24; h > 0; h--) { - $scope.settleHours.push({ value: h, label: ('00' + h).substr(-2) + ':00, ' + $scope.partner.timezone }) - } - $scope.settleHourConfig = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/settle_hour', { hour: $scope.partner.settle_hour || null }).then( - function () { - commonDialog.alert({ type: 'success', title: 'OK', content: 'Settle Hour configured' }) - }, - function (resp) { - commonDialog.alert({ type: 'error', title: 'Error', content: resp.data.message }) - } - ) - } - $scope.getBankInfo = function (bsb_no) { - if (bsb_no != null && bsb_no !== '') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bank_account/bank_info/' + bsb_no).then(function (resp) { - $scope.bankInfo = resp.data - $scope.bankaccount.bank = $scope.bankInfo.bank - $scope.bankaccount.city = $scope.bankInfo.city - $scope.bankaccount.address = $scope.bankInfo.address - $scope.bankaccount.system = $scope.bankInfo.system - $scope.bankaccount.postcode = $scope.bankInfo.postcode - $scope.bankaccount.state = $scope.bankInfo.state - $scope.bankaccount.branch = $scope.bankInfo.branch - }) - } else { - commonDialog.alert({ title: 'Error', content: '请先填写BSB No', type: 'error' }) - } - } - $scope.getRates() - $scope.saveBankAccount = function () { - if (isNaN($scope.bankaccount.account_no)) { - alert('Account No应输入数字!') - return - } - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/bank_account', $scope.bankaccount).then( - function () { - $scope.getBankAccount() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.newCardPaymentRates = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_card_payment_rate.html', - controller: 'newCardPaymentRateDialogCtrl', - resolve: { - sys_common_rate: function () { - return $http.get('/sys/partners/sys_card_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - cost_rate_channel: function () { - return $scope.cost_rate_channel - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } - $scope.newRate = function () { - var name = $scope.bankCtrl.rate_name - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_rate.html', - controller: 'newRateDialogCtrl', - resolve: { - rate: function () { - return { rate_name: name, clean_days: 3 } - }, - sys_common_rate: function () { - return $http.get('/sys/partners/sys_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } - $scope.editRate = function (rate) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/rate_config_dialog.html', - controller: 'rateConfigDialogCtrl', - resolve: { - rate: function () { - return rate - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { - $scope.getRates() - }) - } + } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.bankAccount = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - - // 是否为alipayplus - $scope.isAlipayCN = true - // 修改渠道 - $scope.changeAlipayPlusRateState = function (flag) { - $scope.isAlipayCN = flag - } - // 过滤渠道 - $scope.isAlipayPlus = function (item) { - if ($scope.isAlipayCN) { - return item.rate_name === 'AlipayPlus' && (item.pay_type === 'alipay_cn_retail' || item.pay_type === 'alipay_cn_online') - } else { - return item.rate_name === 'AlipayPlus' && item.pay_type === 'alipay_other' - } - } - // 新增alipay+费率 - $scope.newAlipayPlusRate = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_new_alipayplus_rate.html', - resolve: { - rate: function () { - return { - rate_name: 'AlipayPlus', - clean_days: '3', - } - }, - sys_common_rate: function () { - return $http.get('/sys/partners/sys_rates') - }, - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - controller: [ - '$scope', - '$http', - 'rate', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, rate, sys_common_rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { + $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 - } + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( + } + $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.ctrl.sending = false - $scope.$close() + $scope.updateMerchantLocation() + $scope.$close() }, function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - // if ($scope.rate.clean_days) { - // switch ($scope.rate.clean_days) { - // case '1': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t1.AlipayPlus) - // break - // } - // case '2': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t2.AlipayPlus) - // break - // } - // case '3': { - // $scope.rate.alipayplus = parseFloat($scope.sysRateConfig.t3.AlipayPlus) - // break - // } - // } - // } - } - }, - ], - }) - .result.then(function () { - $scope.getRates() - }) - } - }, - ]) - app.controller('surchargeAccountDetailCtrl', [ - '$scope', - '$http', - 'balance', - 'partner', - 'transactions', - 'commonDialog', - function ($scope, $http, balance, partner, transactions, commonDialog) { - $scope.surcharge = angular.copy(balance) - $scope.surchargeDetailData = angular.copy(transactions.data) - $scope.partner = angular.copy(partner) - $scope.canAddDetail = false - $scope.params = {} - - $scope.getBalance = function () { - if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode == 'distributed') { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { - $scope.surcharge = resp.data - }) - } - } - - $scope.getTransactions = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions').then(function (resp) { - $scope.surchargeDetailData = resp.data - }) - } - - $scope.addDetail = function () { - $scope.canAddDetail = true - } - - $scope.cancel = function () { - $scope.canAddDetail = false - $scope.params = {} - } - $scope.save = function () { - $http - .post('/sys/partners/' + $scope.partner.client_moniker + '/account/save', { - amount: $scope.params.amount, - remark: $scope.params.remark, - }) - .then( - function (resp) { - $scope.getTransactions() - $scope.getBalance() - $scope.canAddDetail = false - $scope.params = {} - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('newCardPaymentRateDialogCtrl', [ - '$scope', - '$http', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, sys_common_rate, clientMoniker) { - $scope.rate = {} - $scope.card_payment_normal = true - $scope.card_payment_switch_title = 'Direct Debit' - $scope.card_payment = [ - { - type: 'rpaypmt_card', - title: 'Card Payment', - }, - { - type: 'rpaypmt_dd', - title: 'Direct Debit', + $scope.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 () { + }) + } + } }, - ] - $scope.cardRateConfig = $scope.card_payment[0] - $scope.switchCardRateConfig = function () { - $scope.card_payment_normal = !$scope.card_payment_normal - $scope.rate = {} - if ($scope.card_payment_normal) { - $scope.cardRateConfig = $scope.card_payment[0] - $scope.card_payment_switch_title = 'Direct Debit' - } else { - $scope.cardRateConfig = $scope.card_payment[1] - $scope.card_payment_switch_title = 'Card Payment' - } - } - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $scope.rate.type = $scope.cardRateConfig.type - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - if ($scope.rate.clean_days && $scope.card_payment_normal) { - switch ($scope.rate.clean_days) { - case '1': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t1.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t1.transaction_fee) - break - } - case '2': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t2.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t2.transaction_fee) - break - } - case '3': { - $scope.rate.rate_value = parseFloat($scope.sysRateConfig.t3.domestic_rate) - $scope.rate.transaction_fee = parseFloat($scope.sysRateConfig.t3.transaction_fee) - break - } - } - } - } - }, - ]) - app.controller('newRateDialogCtrl', [ - '$scope', - '$http', - 'rate', - 'sys_common_rate', - 'clientMoniker', - function ($scope, $http, rate, sys_common_rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.sysRateConfig = angular.copy(sys_common_rate.data) - $scope.ctrl = { sending: false } - $scope.saveRate = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - $scope.ctrl.sending = true - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - $scope.changeDays = function () { - if ($scope.rate.clean_days) { - switch ($scope.rate.clean_days) { - case '1': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t1.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t1.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t1.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t1.Rpay) - $scope.rate.transaction_fee = 0 - break - } - case '2': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t2.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t2.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t2.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t2.Rpay) - $scope.rate.transaction_fee = 0 - break - } - case '3': { - $scope.rate.wechat_rate_value = parseFloat($scope.sysRateConfig.t3.Wechat) - $scope.rate.alipay_rate_value = parseFloat($scope.sysRateConfig.t3.Alipay) - $scope.rate.alipayonline_rate_value = parseFloat($scope.sysRateConfig.t3.AlipayOnline) - $scope.rate.Rpay_rate_value = parseFloat($scope.sysRateConfig.t3.Rpay) - $scope.rate.transaction_fee = 0 - break - } - } - } - } - }, - ]) - app.controller('partnerAccountsCtrl', [ - '$scope', - '$http', - '$uibModal', - 'commonDialog', - function ($scope, $http, $uibModal, commonDialog) { - $scope.partnerRoles = partnerRoles - $scope.loadPartnerAccounts = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/accounts').then(function (resp) { - $scope.accounts = resp.data - }) - } - $scope.loadPartnerAccounts() - $scope.addAccount = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_partner_account_dialog.html', - controller: 'partnerAddAccountDialogCtrl', - backdrop: false, - resolve: { - partner: function () { - return $scope.partner - }, - }, - }) - .result.then(function () { - $scope.loadPartnerAccounts() - }) - } - $scope.updateAccountRole = function (account) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id + '/role', { role: account.role }).then( - function () {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.resetPwd = function (account) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/partner_account_reset_pwd_dialog.html', - controller: 'partnerResetPwdDialogCtrl', - backdrop: false, - size: 'sm', - resolve: { - partner: function () { - return $scope.partner - }, - account: function () { - return account - }, - }, - }) - .result.then(function () { - commonDialog.alert({ title: 'Success!', content: 'Password Changed Successfully', type: 'success' }) - }) - } - $scope.disableAccount = function (account) { - commonDialog - .confirm({ - title: 'Confirm Operation', - content: 'Are you sure to disable account ' + account.display_name + ' ?', - }) - .then(function () { - $http.delete('/sys/partners/' + $scope.partner.client_moniker + '/accounts/' + account.account_id).then( - function () { - $scope.loadPartnerAccounts() - }, - function (resp) { - commonDialog.alert({ title: 'Fail!', content: resp.data.message, type: 'error' }) - } - ) - }) - } - }, - ]) - app.controller('partnerAddAccountDialogCtrl', [ - '$scope', - '$http', - 'partner', - function ($scope, $http, partner) { - $scope.account = { role: 1 } - $scope.partnerRoles = partnerRoles - $scope.account.nation_code = 61 - $scope.saveAccount = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - if ($scope.account.pwd && $scope.account.pwd.length < 8) { - $scope.errmsg = 'Password length must more than 8 !' - return - } - var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ - if ($scope.account.pwd && !regex.test($scope.account.pwd)) { - $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' - return - } - $scope.errmsg = null - $http.post('/sys/partners/' + partner.client_moniker + '/accounts', $scope.account).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerResetPwdDialogCtrl', [ - '$scope', - '$http', - 'partner', - 'account', - function ($scope, $http, partner, account) { - $scope.updatePwd = function () { - $scope.errmsg = null - if ($scope.reset.pwd && $scope.reset.pwd.length < 8) { - $scope.errmsg = 'Password length must more than 8 !' - return - } - var regex = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ - if ($scope.reset.pwd && !regex.test($scope.reset.pwd)) { - $scope.errmsg = 'The password needs to consist of 8-16 digits and letters !' - return - } - $http.put('/sys/partners/' + partner.client_moniker + '/accounts/' + account.account_id + '/pwd', { pwd: $scope.reset.pwd }).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerNewSubPartnerDialogCtrl', [ - '$rootScope', - '$scope', - '$http', - '$state', - 'Upload', - 'commonDialog', - 'timezone', - 'clientMoniker', - 'industryMap', - 'businessStructuresMap', - 'stateMap', - 'countryMap', - 'wechatGoodMcc', - '$filter', - function ($rootScope, $scope, $http, $state, Upload, commonDialog, timezone, clientMoniker, industryMap, businessStructuresMap, stateMap, countryMap, wechatGoodMcc, $filter) { - if ($scope.partner_application) { - $scope.partner = angular.copy($scope.partner_application) - delete $rootScope.partner_application - } else { - $scope.partner = { timezone: 'Australia/Melbourne' } - } - $scope.initMerchantCode = function () { - $http.get('/sys/partners/init/merchant_code').then(function (response) { - $scope.partner.client_moniker = response.data.partner_code - $scope.merchantCodeChecked = true - $scope.merchantIsValid = true - }) - } - $scope.initMerchantCode() - $scope.partner.company_phone_c = 61 - $scope.partner.contact_phone_c = 61 - $scope.partner.client_pay_type = [] - $scope.partner.client_pay_desc = [] - $scope.merchantIsValid = false - $scope.merchantCodeChecked = false - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.checkExpriedate = function (value) { - if (value) { - $scope.partner.certificat_expire_date_premanent = false - $scope.partner.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.partner.certificat_expire_date_premanent) { - $scope.partner.certificat_expire_date_NA = false - $scope.partner.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.partner.certificat_expire_date_NA) { - $scope.partner.certificat_expire_date_premanent = false - $scope.partner.certificat_expire_date_d = null - } - } - } - var resetClientPayDescByTpey = function (type) { - type = parseInt(type) - if (type == 1) { - removeClientPayDesc($scope.partner.client_pay_desc, '10') - } - if (type == 2) { - removeClientPayDesc($scope.partner.client_pay_desc, '20') - } - } - - var compare = function (x, y) { - x = parseInt(x) - y = parseInt(y) - if (x < y) { - return -1 - } else if (x > y) { - return 1 - } else { - return 0 - } - } - $scope.toggleClientPayType = function (type) { - var $idx = $scope.partner.client_pay_type.indexOf(type) - if ($idx >= 0) { - $scope.partner.client_pay_type.splice($idx, 1) - resetClientPayDescByTpey(type) - } else { - $scope.partner.client_pay_type.push(type) - $scope.partner.client_pay_type.sort(compare) - } - } - $scope.toggleClientPayDesc = function (type) { - var $idx = $scope.partner.client_pay_desc.indexOf(type) - if ($idx >= 0) { - if (type == '203') { - removeClientPayDesc($scope.partner.client_pay_desc, '2030') - } - $scope.partner.client_pay_desc.splice($idx, 1) - } else { - $scope.partner.client_pay_desc.push(type) - $scope.partner.client_pay_desc.sort(compare) - } - } - $scope.business_structures = businessStructuresMap.configs() - $scope.industries = industryMap.configs() - - $scope.listReferrers = function () { - $http.get('/sys/orgs/referrer').then(function (resp) { - $scope.referrers = resp.data - }) - } - $scope.listReferrers() - - $scope.alipayMccCategory = {} - $scope.loadAlipayCategory = function () { - $http.get('/static/data/alipayMcc.json').then(function (resp) { - $scope.alipayMccCategory = resp.data - }) - } - $scope.loadAlipayCategory() - - $scope.loadJDindustry = function () { - $http.get('/static/data/jdindustry.json').then(function (resp) { - $scope.jdindustry = resp.data - }) - } - $scope.loadJDindustry() - - $scope.loadLakalaPayindustry = function () { - $http.get('/static/data/lakalapayindustry.json').then(function (resp) { - $scope.lakalapayindustry = resp.data - }) - } - $scope.loadLakalaPayindustry() - - $scope.loadLakalaPaySettle = function () { - $http.get('/static/data/lakalapaysettle.json').then(function (resp) { - $scope.lakalapaysettle = resp.data - }) - } - $scope.loadLakalaPaySettle() - - $scope.loadLakalaPayGoods = function () { - $http.get('/static/data/lakalapaygoods.json').then(function (resp) { - $scope.lakalapaygoods = resp.data - }) - } - $scope.loadLakalaPayGoods() - - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/royalpayindustry.json').then(function (resp) { - $scope.royalpayindustry = resp.data - }) - } - $scope.loadRoyalpayindustry() - - $scope.loadHfindustry = function () { - $http.get('/static/data/hfindustry.json').then(function (resp) { - $scope.hfindustry = resp.data - }) - } - $scope.loadHfindustry() - - $scope.onAlipayMccSelect = function (selectedItem) { - $scope.partner.alipay_category = selectedItem.label - $scope.partner.alipayindustry = selectedItem.mccCode - } - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.partner.royalpay_label = selectedItem.label - $scope.partner.royalpayindustry = selectedItem.mccCode - } - - $scope.onHfIndustrySelect = function (selectedItem) { - $scope.partner.hf_label = selectedItem.label - $scope.partner.hfindustry = selectedItem.mccCode - } - - // $scope.t2city_map = angular.copy(t2city_map); - - $scope.partner.sameAsContactPerson = false - $scope.checkboxOnclick = function () { - $scope.partner.sameAsContactPerson = !$scope.partner.sameAsContactPerson - if ($scope.partner.sameAsContactPerson) { - $scope.partner.legal_representative_person = $scope.partner.contact_person - $scope.partner.legal_representative_phone_a = $scope.partner.contact_phone_a - $scope.partner.legal_representative_phone_c = $scope.partner.contact_phone_c - $scope.partner.legal_representative_phone_p = $scope.partner.contact_phone_p - $scope.partner.legal_representative_email = $scope.partner.contact_email - $scope.partner.legal_representative_job = $scope.partner.contact_job - $scope.partner.legal_representative_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.marketingSameAsContact = false - $scope.checkMarketingSameAsContact = function () { - $scope.partner.marketingSameAsContact = !$scope.partner.marketingSameAsContact - if ($scope.partner.marketingSameAsContact) { - $scope.partner.marketing_person = $scope.partner.contact_person - $scope.partner.marketing_phone_a = $scope.partner.contact_phone_a - $scope.partner.marketing_phone_c = $scope.partner.contact_phone_c - $scope.partner.marketing_phone_p = $scope.partner.contact_phone_p - $scope.partner.marketing_email = $scope.partner.contact_email - $scope.partner.marketing_job = $scope.partner.contact_job - $scope.partner.marketing_wechatid = $scope.partner.contact_wechatid - } - } - - $scope.partner.sameAsAddress = false - $scope.sameAddress = function () { - $scope.partner.sameAsAddress = !$scope.partner.sameAsAddress - if ($scope.partner.sameAsAddress) { - $scope.partner.registered_address = $scope.partner.address - $scope.partner.registered_suburb = $scope.partner.suburb - $scope.partner.registered_postcode = $scope.partner.postcode - $scope.partner.registered_state = $scope.partner.state - } - } - - $scope.timezones = timezone.configs() - $scope.states = stateMap.configs() - $scope.countries = countryMap.configs() - $scope.checkMerchantCodeIsValid = function (code) { - if (code.length != 4) { - $scope.merchantCodeChecked = false - $scope.merchantIsValid = false - return - } - $http.get('/sys/partners/init/check_code_isvalid', { params: { clientMoniker: code } }).then(function (response) { - $scope.merchantIsValid = response.data - $scope.merchantCodeChecked = true - }) - } - $scope.saveSubPartner = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.errmsg = null - if (!$scope.partner.business_structure || $scope.partner.business_structure == '') { - alert('Please select the business structure') - return - } - if ($scope.partner.business_structure != 'Registered body(Sole Trader)') { - if ($scope.partner.certificat_expire_date_d) { - $scope.partner.certificat_expire_date = $filter('dateConversionStr')($scope.partner.certificat_expire_date_d) - } else if ($scope.partner.certificat_expire_date_premanent) { - $scope.partner.certificat_expire_date = 'PERMANENT' - } else if ($scope.partner.certificat_expire_date_NA) { - $scope.partner.certificat_expire_date = 'N/A' - } else { - alert('Certificate expiration time is required') - return - } - } - if ($scope.partner.company_name.indexOf('Migration') != -1) { - alert('Company Name包含敏感词汇,请检查后重新提交!') - return - } + ]) + app.controller('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 + }) + } - 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.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() }) - 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) + $scope.chooseClient = function (client) { + if (client == 'all') { + $scope.choseSubClientNow = 'More' + $scope.params.client_ids = angular.copy($scope.clientIds) + $scope.isAll = true + $scope.chooseClientId = '' + $scope.showLevel3Clients = false + } else if (client.level3Clients) { + $scope.chooseClientId = client.client_id + $scope.showLevel3Clients = true + $scope.level3Clients = client.level3Clients + $scope.isAll = false + $scope.level3ClientIds = [] + $scope.level3ClientIds.push(client.client_id) + client.level3Clients.forEach(function (client) { + $scope.level3ClientIds.push(client.client_id) + }) + $scope.chooseLevel3Client('all') + return + } else { + $scope.chooseClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isAll = false + $scope.showLevel3Clients = false + } + $scope.loadTradeLogs() + } + $scope.chooseLevel3Client = function (client) { + if (client == 'all') { + $scope.params.client_ids = angular.copy($scope.level3ClientIds) + $scope.isLevel3All = true + $scope.chooseLevel3ClientId = '' + } else { + $scope.chooseLevel3ClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isLevel3All = false + } + $scope.loadTradeLogs() + } + $scope.searchSubClients = function (subSearchText, page) { + $scope.subClientTable1 = [$scope.partner] + $scope.subClientTable2 = [] + var params = {} + params.page = page || $scope.subClientPagination.page || 1 + if (subSearchText != '') { + $scope.subSearchText = subSearchText + params.searchText = subSearchText + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + var clientList = resp.data.data + $scope.subClientPagination = resp.data.pagination + clientList.forEach(function (client) { + if ($scope.subClientTable1.length < 11) { + $scope.subClientTable1.push(client) + } else { + $scope.subClientTable2.push(client) + } + $scope.clients.push(client) + }) + }) + } + + if ($scope.partner.has_children && !$scope.partner.hide_sub_mch) { + $scope.searchSubClients('', 1) + $scope.loadTradeLogs(1) } else { - $scope.subClientTable2.push(client) - } - $scope.clients.push(client) - }) - }) - } - - if ($scope.partner.has_children && !$scope.partner.hide_sub_mch) { - $scope.searchSubClients('', 1) - $scope.loadTradeLogs(1) - } else { - $scope.loadTradeLogs(1) - } - $scope.checkSubClientChoseShow = function (client) { - $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient - if (client != '') { - $scope.choseSubClientNow = client.short_name - } - } - $scope.clickDisplayChoseDiv = function (event) { - $scope.more20ChoseSubClient = false - } - $scope.choseDivStopPropagation = function (event) { - event.stopPropagation() - } - }, - ]) - app.controller('partnerPluginsCtrl', [ - '$scope', - '$uibModal', - function ($scope, $uibModal) { - $scope.configRedpack = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/redpack_config.html', - controller: 'partnerRedpackConfigDialogCtrl', - size: 'lg', - resolve: { - partner: function () { - return $scope.partner - }, - config: [ - '$http', - function ($http) { - return $http.get('/sys/redpack/partners/' + $scope.partner.client_moniker) - }, - ], - }, - }) - } - $scope.redpackLogs = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/redpack_logs.html', - controller: 'partnerRedpackLogDialogCtrl', - size: 'lg', - resolve: { - partner: function () { - return $scope.partner - }, - }, - }) - } - }, - ]) - app.controller('partnerDeviceCtrl', [ - '$scope', - '$http', - 'orderService', - 'commonDialog', - 'refunder', - '$uibModal', - function ($scope, $http, orderService, commonDialog, refunder, $uibModal) { - $scope.pagination = {} - /** - * 查看设备 - * @param page - */ - $scope.listDevices = function (page) { - var params = angular.copy($scope.devsearch) || {} - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/devices', { params: params }).then(function (resp) { - $scope.pagination = resp.data.pagination - $scope.devices = resp.data.data - }) - } - $scope.listDevices(1) - - /** - * 添加设备 - */ - $scope.addDevice = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/add_device.html', - controller: 'newDeviceDialogCtrl', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - }, - }) - .result.then(function () { + $scope.loadTradeLogs(1) + } + $scope.checkSubClientChoseShow = function (client) { + $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient + if (client != '') { + $scope.choseSubClientNow = client.short_name + } + } + $scope.clickDisplayChoseDiv = function (event) { + $scope.more20ChoseSubClient = false + } + $scope.choseDivStopPropagation = function (event) { + event.stopPropagation() + } + }, + ]) + app.controller('partnerPluginsCtrl', [ + '$scope', + '$uibModal', + function ($scope, $uibModal) { + $scope.configRedpack = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/redpack_config.html', + controller: 'partnerRedpackConfigDialogCtrl', + size: 'lg', + resolve: { + partner: function () { + return $scope.partner + }, + config: [ + '$http', + function ($http) { + return $http.get('/sys/redpack/partners/' + $scope.partner.client_moniker) + }, + ], + }, + }) + } + $scope.redpackLogs = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/redpack_logs.html', + controller: 'partnerRedpackLogDialogCtrl', + size: 'lg', + resolve: { + partner: function () { + return $scope.partner + }, + }, + }) + } + }, + ]) + app.controller('partnerDeviceCtrl', [ + '$scope', + '$http', + 'orderService', + 'commonDialog', + 'refunder', + '$uibModal', + function ($scope, $http, orderService, commonDialog, refunder, $uibModal) { + $scope.pagination = {} + /** + * 查看设备 + * @param page + */ + $scope.listDevices = function (page) { + var params = angular.copy($scope.devsearch) || {} + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/devices', {params: params}).then(function (resp) { + $scope.pagination = resp.data.pagination + $scope.devices = resp.data.data + }) + } $scope.listDevices(1) - }) - } - - $scope.showDeviceOrders = function (dev) { - $scope.params.dev_id = dev.dev_id - $scope.listOrders(1) - } - $scope.modifyRemark = function (dev) { - commonDialog.inputText({ title: 'Input New Remark of device' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id, { remark: text }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Update remark failed', content: resp.data.message, type: 'error' }) - } - ) - }) - } - $scope.disableDevice = function (dev) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', { enable: false }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Failed to disable device', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.enableDevice = function (dev) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/devices/' + dev.dev_id + '/enable', { enable: true }).then( - function () { - $scope.listDevices() - }, - function (resp) { - commonDialog.alert({ title: 'Failed to enable device', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.orderPagination = {} - $scope.today = new Date() - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadTradeLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadTradeLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadTradeLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadTradeLogs(1) - } - $scope.listOrders = function (page) { - var params = angular.copy($scope.params) || {} - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.gateway = [0, 1] - params.page = page || $scope.orderPagination.page || 1 - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/trade_logs', { params: params }).then(function (resp) { - $scope.orders = resp.data.data - $scope.orderPagination = resp.data.pagination - $scope.analysis = resp.data.analysis - }) - } - $scope.listOrders(1) - $scope.orderDetail = function (order) { - orderService.managerOrderDetail(order) - } - $scope.refundOrder = function (order) { - refunder.refunded(order.order_id) - } - }, - ]) - app.controller('partnerRedpackConfigDialogCtrl', [ - '$scope', - '$http', - 'partner', - 'config', - function ($scope, $http, partner, config) { - $scope.config = config.data - if (!Object.keys($scope.config).length) { - $scope.config = { min_payment: 0, min_amount: 1, max_amount: 1, daily_limit: 1, enabled: false } - } - $scope.saveRedpackConfig = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - var config = angular.copy($scope.config) - $http.put('/sys/redpack/partners/' + partner.client_moniker, config).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('rateConfigDialogCtrl', [ - '$scope', - '$http', - 'rate', - 'clientMoniker', - function ($scope, $http, rate, clientMoniker) { - $scope.rate = angular.copy(rate) - $scope.ctrl = { sending: false } - $scope.saveRate = function () { - $scope.errmsg = null - $scope.ctrl.sending = true - if ($scope.rate.client_rate_id) { - $http.put('/sys/partners/' + clientMoniker + '/rates/' + $scope.rate.client_rate_id, $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } else { - $http.post('/sys/partners/' + clientMoniker + '/rates', $scope.rate).then( - function () { - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - $scope.errmsg = resp.data.message - } - ) - } - } - }, - ]) - app.controller('newDeviceDialogCtrl', [ - '$scope', - '$http', - 'clientMoniker', - function ($scope, $http, clientMoniker) { - $scope.save = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $http.post('/sys/partners/' + clientMoniker + '/add_device', $scope.device).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - }, - ]) - app.controller('partnerChooseBDUserDialogCtrl', [ - '$scope', - '$http', - '$filter', - 'partner', - 'bdUsers', - 'type', - function ($scope, $http, $filter, partner, bdUsers, type) { - $scope.bdUsers = bdUsers.data - $scope.data = {} - $scope.params = {} - - $scope.chooseOrg = {} - $scope.chooseOrg.org_name = null - if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { - /* $scope.showOrg = 'Organization';*/ - $http.get('/sys/orgs', { params: {} }).then(function (resp) { - $scope.orgs = resp.data - }) - } - - $scope.loadOrgs = function () { - var params = angular.copy($scope.params) - $http.get('/sys/orgs/orgChild', { params: params }).then(function (resp) { - $scope.orgs_child = resp.data - }) - } - - /* $scope.chooseOrgFun = function (org) { + + /** + * 添加设备 + */ + $scope.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' @@ -4796,743 +4866,744 @@ 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() + function initBD() { + $http.get('/sys/partners/' + partner.client_moniker + '/bd_user/current').then(function (resp) { + var choooseBD = resp.data + choooseBD.forEach(function (e) { + $scope.bdUsers.forEach(function (m) { + if (m.manager_id == e.bd_id) { + m.choose = true + m.proportion = e.proportion + /* $scope.chooseOrgFun({org_id: m.org_id, name: m.org_name});*/ + if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0) { + $scope.params.org_ids = m.org_id + $scope.params.org_id = m.org_id + $scope.loadOrgs() + } else { + $scope.params.org_id = m.org_id + $scope.loadOrgs() + } + } + }) + }) + $scope.data.start_date = new Date(choooseBD[0].start_date) + }) + } + + if (type == 'edit') { + initBD() + } + + $scope.saveBD = function () { + $scope.data.users = [] + $scope.bdUsers.forEach(function (e) { + if (e.choose) { + $scope.data.users.push(e) + } + }) + + if ($scope.data.users.length == 0) { + $scope.errmsg = '请选择至少一位BD' + } else if ($scope.data.start_date == undefined) { + $scope.errmsg = '执行开始日期不能为空' } else { - $scope.params.org_id = m.org_id - $scope.loadOrgs() + 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.data.start_date = new Date(choooseBD[0].start_date) - }) - } - - if (type == 'edit') { - initBD() - } - - $scope.saveBD = function () { - $scope.data.users = [] - $scope.bdUsers.forEach(function (e) { - if (e.choose) { - $scope.data.users.push(e) - } - }) - - if ($scope.data.users.length == 0) { - $scope.errmsg = '请选择至少一位BD' - } else if ($scope.data.start_date == undefined) { - $scope.errmsg = '执行开始日期不能为空' - } else { - var isValid = true - var total = 0 - $scope.data.users.forEach(function (e) { - if (e.proportion == undefined) { - $scope.errmsg = '绩效比例不能为空' - isValid = false - return - } else if (e.proportion < 0.01 || e.proportion > 1) { - $scope.errmsg = '绩效比例无效' - isValid = false - return - } - total += e.proportion - if (total > 1) { - $scope.errmsg = '总比例不能超过1' - isValid = false - return - } - }) - // if (total != 1) { - // $scope.errmsg = "Total proportion must be 1"; - // isValid = false; - // return; - // } - if (isValid) { - $scope.errmsg = null - $scope.data.type = type - var chooseUsers = angular.copy($scope.data) - chooseUsers.start_date = $scope.data.start_date - if (chooseUsers.start_date) { - chooseUsers.start_date = $filter('date')(chooseUsers.start_date, 'yyyyMMdd') - } - $http.put('/sys/partners/' + partner.client_moniker + '/bd_user', $scope.data).then( - function () { - $scope.$close() - }, - function (resp) { - $scope.errmsg = resp.data.message - } - ) - } - } - } - }, - ]) - app.controller('partnerRedpackLogDialogCtrl', [ - '$scope', - '$http', - 'partner', - function ($scope, $http, partner) { - $scope.pagination = {} - $scope.queryParams = {} - $scope.listRedpackLogs = function (page) { - var params = angular.copy($scope.queryParams) - params.page = page || $scope.pagination.page || 1 - $http.get('/sys/redpack/partners/' + partner.client_moniker + '/logs', { params: params }).then(function (resp) { - $scope.logs = resp.data.data - $scope.pagination = resp.data.pagination - }) - } - $scope.listRedpackLogs(1) - }, - ]) - app.controller('partnerAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - function ($scope, $http, $rootScope, commonDialog, $state) { - if ($state.params.commitType == 'card-payment') { - $state.go('partners.detail.files.MW_files') - } else { - $state.go('partners.detail.files.CP_files') - } - }, - ]) - app.controller('partnerCPAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.id_info_form = { edit: false } - $scope.file = file.data || {} - //audit files - $scope.uploadBankFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.bankFileProgress - $scope.file.file_bank_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_bank_info.endsWith('pdf')) { - $scope.bankIsImage = false - } else { - $scope.bankIsImage = true - } - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.agreeIsImage = true - if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) { - $scope.agreeIsImage = false - } - $scope.bankIsImage = true - if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) { - $scope.bankIsImage = false - } - $scope.companyIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } - $scope.applyIsImage = true - if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) { - $scope.applyIsImage = false - } - $scope.idIsImage = true - if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } - $scope.billIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.billIsImage = false - } - - //上传账单流水 - $scope.uploadBillFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.billFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.billFileProgress - $scope.file.utility_bill_info = resp.data.url - $scope.updateFile() - if ($scope.file.utility_bill_info.endsWith('pdf')) { - $scope.billIsImage = false - } else { - $scope.billIsImage = true - } - }, - function (resp) { - delete $scope.billFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadCompanyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.companyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.companyFileProgress - $scope.file.file_company_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } else { - $scope.companyIsImage = true - } - }, - function (resp) { - delete $scope.companyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.companyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - //上传ID信息 - $scope.uploadIDFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.idFileProgress - $scope.file.file_id_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } else { - $scope.idIsImage = true - } - }, - function (resp) { - delete $scope.idFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - //上传协议文件 - $scope.uploadAgreementFile = function (file) { - if (file != null) { - if (file.size > 10 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过10MB,请压缩后重试', type: 'error' }) - } else { - $scope.agreementFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.agreementFileProgress - $scope.file.file_agreement_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_agreement_info.endsWith('pdf')) { - $scope.agreeIsImage = false - } else { - $scope.agreeIsImage = true - } - }, - function (resp) { - delete $scope.agreementFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.agreementFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - //上传申请表 - $scope.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', + } + }, + ]) + app.controller('partnerRedpackLogDialogCtrl', [ + '$scope', + '$http', + 'partner', + function ($scope, $http, partner) { + $scope.pagination = {} + $scope.queryParams = {} + $scope.listRedpackLogs = function (page) { + var params = angular.copy($scope.queryParams) + params.page = page || $scope.pagination.page || 1 + $http.get('/sys/redpack/partners/' + partner.client_moniker + '/logs', {params: params}).then(function (resp) { + $scope.logs = resp.data.data + $scope.pagination = resp.data.pagination }) + } + $scope.listRedpackLogs(1) + }, + ]) + app.controller('partnerAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + function ($scope, $http, $rootScope, commonDialog, $state) { + if ($state.params.commitType == 'card-payment') { + $state.go('partners.detail.files.MW_files') + } else { + $state.go('partners.detail.files.CP_files') + } + }, + ]) + app.controller('partnerCPAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.id_info_form = {edit: false} + $scope.file = file.data || {} + //audit files + $scope.uploadBankFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.bankFileProgress + $scope.file.file_bank_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_bank_info.endsWith('pdf')) { + $scope.bankIsImage = false + } else { + $scope.bankIsImage = true + } + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.agreeIsImage = true + if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) { + $scope.agreeIsImage = false + } + $scope.bankIsImage = true + if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) { + $scope.bankIsImage = false + } + $scope.companyIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } + $scope.applyIsImage = true + if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) { + $scope.applyIsImage = false + } + $scope.idIsImage = true + if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } + $scope.billIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.billIsImage = false + } + + //上传账单流水 + $scope.uploadBillFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.billFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.billFileProgress + $scope.file.utility_bill_info = resp.data.url + $scope.updateFile() + if ($scope.file.utility_bill_info.endsWith('pdf')) { + $scope.billIsImage = false + } else { + $scope.billIsImage = true + } + }, + function (resp) { + delete $scope.billFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.uploadCompanyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.companyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.companyFileProgress + $scope.file.file_company_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } else { + $scope.companyIsImage = true + } + }, + function (resp) { + delete $scope.companyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.companyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + //上传ID信息 + $scope.uploadIDFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.idFileProgress + $scope.file.file_id_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } else { + $scope.idIsImage = true + } + }, + function (resp) { + delete $scope.idFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传协议文件 + $scope.uploadAgreementFile = function (file) { + if (file != null) { + if (file.size > 10 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过10MB,请压缩后重试', type: 'error'}) + } else { + $scope.agreementFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.agreementFileProgress + $scope.file.file_agreement_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_agreement_info.endsWith('pdf')) { + $scope.agreeIsImage = false + } else { + $scope.agreeIsImage = true + } + }, + function (resp) { + delete $scope.agreementFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.agreementFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传申请表 + $scope.uploadApplyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.applyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.applyFileProgress + $scope.file.file_apply_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_apply_info.endsWith('pdf')) { + $scope.applyIsImage = false + } else { + $scope.applyIsImage = true + } + }, + function (resp) { + delete $scope.applyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.applyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.toggleIdTitle = function (beneficiary_id_title) { + $scope.file.beneficiary_id_title = beneficiary_id_title + } + $scope.saveIdInfo = function () { + if (!$scope.file.id_type) { + commonDialog.alert({title: 'Error', content: '请选择ID Type', type: 'error'}) + return + } + if ($scope.file.beneficiary_id_title != 'Ultimate beneficiary owner') { + if (!$scope.file.other_id_title_desc) { + commonDialog.alert({title: 'Error', content: '请简要告知为何无法提供受益股东的资料', type: 'error'}) + return + } + } + var config = {} + config.id_type = $scope.file.id_type + config.beneficiary_id_title = $scope.file.beneficiary_id_title + config.other_id_title_desc = $scope.file.other_id_title_desc + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/id_info', config).then( + function (resp) { + commonDialog.alert({title: 'Success', content: 'Id Info Updated', type: 'success'}) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $state.reload() + } + ) + } + + $scope.cancelIdInfo = function () { $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.authFile = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - }, - ]) - app.controller('partnerMWAuthFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.id_info_form = { edit: false } - $scope.file = file.data || {} - $scope.uploadFile = {} - $scope.file.upay_risk_level = $scope.partner.upay_risk_level - $scope.file.upay_risk_remark = $scope.partner.upay_risk_remark - - $scope.uploadApplicationFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.applicationFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.applicationFileProgress - $scope.uploadFile.upay_application_form = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.applicationFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.applicationFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadBankFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.bankFileProgress - $scope.uploadFile.client_bank_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadASICFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.ASICProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.ASICProgress - $scope.uploadFile.client_company_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.ASICProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.ASICProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadIdFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.idProgress - $scope.uploadFile.upay_driver_license = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.idProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadResidenceFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.residenceFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.residenceFileProgress - $scope.uploadFile.kyc_utility_bill_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.residenceFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.residenceFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadRefundPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.refundPolicyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.refundPolicyFileProgress - $scope.uploadFile.refund_exchange_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.refundPolicyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.refundPolicyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadPrivacyPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.privacyFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.privacyFileProgress - $scope.uploadFile.upay_privacy_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.privacyFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.privacyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadCardPolicyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.cardFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.cardFileProgress - $scope.uploadFile.card_security_policy = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.cardFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.cardFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadLetterOfOfferFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.letterFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.letterFileProgress - $scope.uploadFile.upay_offer_letter = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.letterFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.letterFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.uploadPromotionalFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.promotionalFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.promotionalFileProgress - $scope.uploadFile.upay_promotional_offer = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.promotionalFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.promotionalFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - /*$scope.uploadTermsFile = function (file) { + $scope.id_info_form.edit = false + } + + $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP' + return url + } + + $scope.deleteComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + $scope.updateFile = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Upload Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + function commitError() { + commonDialog.alert({ + title: 'Error', + content: 'Missing file', + type: 'error', + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.authFile = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + }, + ]) + app.controller('partnerMWAuthFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.id_info_form = {edit: false} + $scope.file = file.data || {} + $scope.uploadFile = {} + $scope.file.upay_risk_level = $scope.partner.upay_risk_level + $scope.file.upay_risk_remark = $scope.partner.upay_risk_remark + + $scope.uploadApplicationFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.applicationFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.applicationFileProgress + $scope.uploadFile.upay_application_form = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.applicationFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.applicationFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadBankFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.bankFileProgress + $scope.uploadFile.client_bank_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadASICFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.ASICProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.ASICProgress + $scope.uploadFile.client_company_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.ASICProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.ASICProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadIdFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.idProgress + $scope.uploadFile.upay_driver_license = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.idProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadResidenceFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.residenceFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.residenceFileProgress + $scope.uploadFile.kyc_utility_bill_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.residenceFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.residenceFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadRefundPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.refundPolicyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.refundPolicyFileProgress + $scope.uploadFile.refund_exchange_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.refundPolicyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.refundPolicyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadPrivacyPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.privacyFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.privacyFileProgress + $scope.uploadFile.upay_privacy_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.privacyFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.privacyFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadCardPolicyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.cardFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.cardFileProgress + $scope.uploadFile.card_security_policy = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.cardFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.cardFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadLetterOfOfferFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.letterFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.letterFileProgress + $scope.uploadFile.upay_offer_letter = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.letterFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.letterFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + $scope.uploadPromotionalFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.promotionalFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.promotionalFileProgress + $scope.uploadFile.upay_promotional_offer = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.promotionalFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.promotionalFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + /*$scope.uploadTermsFile = function (file) { if (file != null) { if (file.size > 3 * 1024 * 1024) { commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) @@ -5552,704 +5623,706 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }, function (evt) { $scope.termsFileProgress.value = parseInt(100 * evt.loaded / evt.total); }) - } + } + } + };*/ + $scope.uploadDescFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.descFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + $scope.uploadFile = {} + delete $scope.descFileProgress + $scope.uploadFile.upay_desc_file = resp.data.url + $scope.updateFile() + }, + function (resp) { + delete $scope.descFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.descFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.saveIdInfo = function () { + if (!$scope.file.upay_risk_level) { + commonDialog.alert({title: 'Error', content: '请选择商户风险等级', type: 'error'}) + return + } + var config = {} + config.upay_risk_level = $scope.file.upay_risk_level + config.upay_risk_remark = $scope.file.upay_risk_remark + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_risk_info', config).then( + function (resp) { + commonDialog.alert({title: 'Success', content: 'Risk Info Updated', type: 'success'}) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $state.reload() + } + ) + } + + $scope.cancelIdInfo = function () { + $state.reload() + $scope.id_info_form.edit = false + } + + $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/MWcomplianceAsZIP' + return url + } + + $scope.updateFile = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_file', $scope.uploadFile).then( + function () { + commonDialog.alert({ + title: 'Success', + content: 'Upload Successful', + type: 'success', + }) + $state.go( + 'partners.detail.files', + { + clientMoniker: $scope.partner.client_moniker, + commitType: 'card-payment', + }, + {reload: true} + ) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + + function commitError() { + commonDialog.alert({ + title: 'Error', + content: 'Missing file', + type: 'error', + }) + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.authFile = true + $rootScope.complianceCheck.client_id = $scope.partner.client_id + + if ($scope.file.upay_application_form == null || $scope.file.upay_application_form == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充商户申请表合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.client_bank_file == null || $scope.file.client_bank_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补六个月银行对账单合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.client_company_file == null || $scope.file.client_company_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充当前公司信息摘录合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.upay_driver_license == null || $scope.file.upay_driver_license == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充法人身份证明合规文件'}) + $rootScope.complianceCheck.authFile = false + } else if ($scope.file.kyc_utility_bill_file == null || $scope.file.kyc_utility_bill_file == '') { + commonDialog.alert({type: 'error', title: 'Error', content: '请补充家庭住址证明 (一个水电煤网账单)合规文件'}) + $rootScope.complianceCheck.authFile = false + } + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + + $scope.deleteMWComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/mw_delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + }, + ]) + + app.controller('partnerKycFileCtrl', [ + '$scope', + '$http', + '$rootScope', + 'commonDialog', + '$state', + 'Upload', + 'file', + function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { + $scope.file = file.data || {} + //kyc files + $scope.uploadCompanyFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.bankFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.bankFileProgress + $scope.file.file_company_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } else { + $scope.companyIsImage = true + } + }, + function (resp) { + delete $scope.bankFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + $scope.companyIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.companyIsImage = false + } + + $scope.idIsImage = true + if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } + $scope.billIsImage = true + if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { + $scope.billIsImage = false + } + + //上传ID信息 + $scope.uploadIDFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.idFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.idFileProgress + $scope.file.file_id_info = resp.data.url + $scope.updateFile() + if ($scope.file.file_id_info.endsWith('pdf')) { + $scope.idIsImage = false + } else { + $scope.idIsImage = true + } + }, + function (resp) { + delete $scope.idFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + //上传账单流水 + $scope.uploadBillFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.billFileProgress = {value: 0} + Upload.upload({ + url: '/attachment/files', + data: {file: file}, + }).then( + function (resp) { + delete $scope.billFileProgress + $scope.file.utility_bill_info = resp.data.url + $scope.updateFile() + if ($scope.file.utility_bill_info.endsWith('pdf')) { + $scope.billIsImage = false + } else { + $scope.billIsImage = true + } + }, + function (resp) { + delete $scope.billFileProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.billFileProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } + + /* $scope.downloadAsZip = function () { + var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP'; + return url; + };*/ + + $scope.deleteComplianceFiles = function (file_id) { + commonDialog + .confirm({ + title: 'Warning', + content: 'This operation will delete the file, Are you sure?', + }) + .then(function () { + $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Delete Successful', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) } - };*/ - $scope.uploadDescFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.descFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - $scope.uploadFile = {} - delete $scope.descFileProgress - $scope.uploadFile.upay_desc_file = resp.data.url - $scope.updateFile() - }, - function (resp) { - delete $scope.descFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.descFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - $scope.saveIdInfo = function () { - if (!$scope.file.upay_risk_level) { - commonDialog.alert({ title: 'Error', content: '请选择商户风险等级', type: 'error' }) - return - } - var config = {} - config.upay_risk_level = $scope.file.upay_risk_level - config.upay_risk_remark = $scope.file.upay_risk_remark - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_risk_info', config).then( - function (resp) { - commonDialog.alert({ title: 'Success', content: 'Risk Info Updated', type: 'success' }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $state.reload() - } - ) - } - - $scope.cancelIdInfo = function () { - $state.reload() - $scope.id_info_form.edit = false - } - - $scope.downloadAsZip = function () { - var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/MWcomplianceAsZIP' - return url - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/mw_file', $scope.uploadFile).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', - }) - $state.go( - 'partners.detail.files', - { - clientMoniker: $scope.partner.client_moniker, - commitType: 'card-payment', - }, - { reload: true } - ) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.authFile = true - $rootScope.complianceCheck.client_id = $scope.partner.client_id - - if ($scope.file.upay_application_form == null || $scope.file.upay_application_form == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充商户申请表合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.client_bank_file == null || $scope.file.client_bank_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补六个月银行对账单合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.client_company_file == null || $scope.file.client_company_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充当前公司信息摘录合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.upay_driver_license == null || $scope.file.upay_driver_license == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充法人身份证明合规文件' }) - $rootScope.complianceCheck.authFile = false - } else if ($scope.file.kyc_utility_bill_file == null || $scope.file.kyc_utility_bill_file == '') { - commonDialog.alert({ type: 'error', title: 'Error', content: '请补充家庭住址证明 (一个水电煤网账单)合规文件' }) - $rootScope.complianceCheck.authFile = false - } - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - - $scope.deleteMWComplianceFiles = function (file_id) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will delete the file, Are you sure?', - }) - .then(function () { - $http.put('/sys/partners/auth_file/' + file_id + '/mw_delete').then( - function (resp) { + $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: 'Success', - content: 'Delete Successful', - type: 'success', + title: 'Error', + content: 'Missing file', + type: 'error', }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - }, - ]) - - app.controller('partnerKycFileCtrl', [ - '$scope', - '$http', - '$rootScope', - 'commonDialog', - '$state', - 'Upload', - 'file', - function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { - $scope.file = file.data || {} - //kyc files - $scope.uploadCompanyFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.bankFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.bankFileProgress - $scope.file.file_company_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } else { - $scope.companyIsImage = true - } - }, - function (resp) { - delete $scope.bankFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.bankFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.companyIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.companyIsImage = false - } - - $scope.idIsImage = true - if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } - $scope.billIsImage = true - if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) { - $scope.billIsImage = false - } - - //上传ID信息 - $scope.uploadIDFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.idFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.idFileProgress - $scope.file.file_id_info = resp.data.url - $scope.updateFile() - if ($scope.file.file_id_info.endsWith('pdf')) { - $scope.idIsImage = false - } else { - $scope.idIsImage = true - } - }, - function (resp) { - delete $scope.idFileProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.idFileProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - //上传账单流水 - $scope.uploadBillFile = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.billFileProgress = { value: 0 } - Upload.upload({ - url: '/attachment/files', - data: { file: file }, - }).then( - function (resp) { - delete $scope.billFileProgress - $scope.file.utility_bill_info = resp.data.url - $scope.updateFile() - if ($scope.file.utility_bill_info.endsWith('pdf')) { - $scope.billIsImage = false + } + + $scope.complianceCheck = function () { + if (!$rootScope.complianceCheck) { + $rootScope.complianceCheck = {} + } + $rootScope.complianceCheck.client_id = $scope.partner.client_id + $rootScope.complianceCheck.authFile = true + } + $scope.complianceChangeCheck = function () { + if ($rootScope.complianceCheck) { + if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { + delete $rootScope.complianceCheck + } + } + } + $scope.complianceChangeCheck() + }, + ]) + + app.controller('partnerSettlementCtrl', [ + '$scope', + '$uibModal', + '$http', + 'clientMoniker', + '$filter', + function ($scope, $uibModal, $http, clientMoniker, $filter) { + $scope.params = {} + $scope.pagination = {} + $scope.clients = [] + $scope.showLevel3Clients = false + $scope.isLevel3All = true + $scope.clinet = {} + $scope.isAll = true + $scope.more20ChoseSubClient = false + $scope.choseSubClientNow = 'More' + $scope.searchSubClients = function (subSearchText, page) { + $scope.subClientTable1 = [$scope.partner] + $scope.subClientTable2 = [] + var params = {} + params.page = page || $scope.subClientPagination.page || 1 + if (subSearchText != '') { + $scope.subSearchText = subSearchText + params.searchText = subSearchText + } + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', {params: params}).then(function (resp) { + var clientList = resp.data.data + $scope.subClientPagination = resp.data.pagination + clientList.forEach(function (client) { + if ($scope.subClientTable1.length < 11) { + $scope.subClientTable1.push(client) + } else { + $scope.subClientTable2.push(client) + } + $scope.clients.push(client) + }) + }) + } + $scope.initClientInfo = function () { + $http.get('/sys/partners/' + clientMoniker).then(function (resp) { + $scope.client = resp.data + $scope.clients = [$scope.client] + if ($scope.client.has_children && !$scope.client.hide_sub_mch) { + $scope.searchSubClients('', 1) + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.chooseClient('all') + } else { + $scope.params.dateto = new Date() + var day = new Date() + day.setDate(day.getDate() - 7) + $scope.params.datefrom = day + $scope.chooseClient('all') + } + }) + } + $scope.initClientInfo() + + $scope.exportSettlementLogs = function () { + var params = angular.copy($scope.params) + var url = '/sys/partners/' + clientMoniker + '/lists_settlements/excel' + var connectSymbol = '?' + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') + url += connectSymbol + 'datefrom=' + params.datefrom + connectSymbol = '&' + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') + url += connectSymbol + 'dateto=' + params.dateto + } + if (params.client_ids && !$scope.isAll) { + params.client_ids.forEach(function (i) { + url += connectSymbol + 'client_ids=' + i + connectSymbol = '&' + }) + } + return url + } + + $scope.chooseClient = function (client) { + if (client == 'all') { + $scope.choseSubClientNow = 'More' + $scope.params.client_ids = angular.copy($scope.clientIds) + $scope.isAll = true + $scope.chooseClientId = '' + $scope.showLevel3Clients = false + } else if (client.level3Clients) { + $scope.chooseClientId = client.client_id + $scope.showLevel3Clients = true + $scope.level3Clients = client.level3Clients + $scope.isAll = false + $scope.level3ClientIds = [] + $scope.level3ClientIds.push(client.client_id) + client.level3Clients.forEach(function (client) { + $scope.level3ClientIds.push(client.client_id) + }) + $scope.chooseLevel3Client('all') + return } else { - $scope.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.chooseClientId = client.client_id + $scope.params.client_ids = [client.client_id] + $scope.isAll = false + $scope.showLevel3Clients = false + } + $scope.loadSettlementLogs() + } - /* $scope.downloadAsZip = function () { - var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP'; - return url; - };*/ + $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.deleteComplianceFiles = function (file_id) { - commonDialog - .confirm({ - title: 'Warning', - content: 'This operation will delete the file, Are you sure?', - }) - .then(function () { - $http.put('/sys/partners/auth_file/' + file_id + '/delete').then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Delete Successful', - type: 'success', + $scope.getClearingTransactionsOfMergeSettle = function (reportDate) { + $uibModal.open({ + templateUrl: '/static/analysis/templates/settlement_transactions.html', + controller: 'managerSettlementDetailOfMergeSettleCtrl', + resolve: { + detail: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/analysis/partner_card/' + $scope.client.client_id + '/settlement_logs/report_date/' + reportDate) + }, + ], + client_id: $scope.client.client_id, + }, + size: 'lg', }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - $scope.updateFile = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/kycFile', $scope.file).then( - function () { - commonDialog.alert({ - title: 'Success', - content: 'Upload Successful', - type: 'success', + } + + $scope.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) }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - function commitError() { - commonDialog.alert({ - title: 'Error', - content: 'Missing file', - type: 'error', - }) - } - $scope.complianceCheck = function () { - if (!$rootScope.complianceCheck) { - $rootScope.complianceCheck = {} - } - $rootScope.complianceCheck.client_id = $scope.partner.client_id - $rootScope.complianceCheck.authFile = true - } - $scope.complianceChangeCheck = function () { - if ($rootScope.complianceCheck) { - if ($scope.partner.client_id != $rootScope.complianceCheck.client_id) { - delete $rootScope.complianceCheck - } - } - } - $scope.complianceChangeCheck() - }, - ]) - - app.controller('partnerSettlementCtrl', [ - '$scope', - '$uibModal', - '$http', - 'clientMoniker', - '$filter', - function ($scope, $uibModal, $http, clientMoniker, $filter) { - $scope.params = {} - $scope.pagination = {} - $scope.clients = [] - $scope.showLevel3Clients = false - $scope.isLevel3All = true - $scope.clinet = {} - $scope.isAll = true - $scope.more20ChoseSubClient = false - $scope.choseSubClientNow = 'More' - $scope.searchSubClients = function (subSearchText, page) { - $scope.subClientTable1 = [$scope.partner] - $scope.subClientTable2 = [] - var params = {} - params.page = page || $scope.subClientPagination.page || 1 - if (subSearchText != '') { - $scope.subSearchText = subSearchText - params.searchText = subSearchText - } - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/sub_clients/page', { params: params }).then(function (resp) { - var clientList = resp.data.data - $scope.subClientPagination = resp.data.pagination - clientList.forEach(function (client) { - if ($scope.subClientTable1.length < 11) { - $scope.subClientTable1.push(client) - } else { - $scope.subClientTable2.push(client) - } - $scope.clients.push(client) - }) - }) - } - $scope.initClientInfo = function () { - $http.get('/sys/partners/' + clientMoniker).then(function (resp) { - $scope.client = resp.data - $scope.clients = [$scope.client] - if ($scope.client.has_children && !$scope.client.hide_sub_mch) { - $scope.searchSubClients('', 1) - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.chooseClient('all') - } else { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.chooseClient('all') - } - }) - } - $scope.initClientInfo() - - $scope.exportSettlementLogs = function () { - var params = angular.copy($scope.params) - var url = '/sys/partners/' + clientMoniker + '/lists_settlements/excel' - var connectSymbol = '?' - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - url += connectSymbol + 'datefrom=' + params.datefrom - connectSymbol = '&' - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - url += connectSymbol + 'dateto=' + params.dateto - } - if (params.client_ids && !$scope.isAll) { - params.client_ids.forEach(function (i) { - url += connectSymbol + 'client_ids=' + i - connectSymbol = '&' - }) - } - return url - } - - $scope.chooseClient = function (client) { - if (client == 'all') { - $scope.choseSubClientNow = 'More' - $scope.params.client_ids = angular.copy($scope.clientIds) - $scope.isAll = true - $scope.chooseClientId = '' - $scope.showLevel3Clients = false - } else if (client.level3Clients) { - $scope.chooseClientId = client.client_id - $scope.showLevel3Clients = true - $scope.level3Clients = client.level3Clients - $scope.isAll = false - $scope.level3ClientIds = [] - $scope.level3ClientIds.push(client.client_id) - client.level3Clients.forEach(function (client) { - $scope.level3ClientIds.push(client.client_id) - }) - $scope.chooseLevel3Client('all') - return - } else { - $scope.chooseClientId = client.client_id - $scope.params.client_ids = [client.client_id] - $scope.isAll = false - $scope.showLevel3Clients = false - } - $scope.loadSettlementLogs() - } - - $scope.today = new Date() - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadSettlementLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadSettlementLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadSettlementLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.loadSettlementLogs = function (page) { - var params = angular.copy($scope.params) - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.page = page || $scope.pagination.page || 1 - params.limit = 10 - if ($scope.isAll) { - delete params.client_ids - } - $http.get('/sys/partners/' + clientMoniker + '/lists_settlements', { params: params }).then(function (resp) { - $scope.settlementLogs = resp.data.data - $scope.padding = resp.data.padding - $scope.pagination = resp.data.pagination - }) - } - $scope.getClearingTransactions = function (client_id, detail_id) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) - }, - ], - detail_id: detail_id, - }, - size: 'lg', - }) - } - - $scope.getClearingTransactionsOfMergeSettle = function (reportDate) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailOfMergeSettleCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + $scope.client.client_id + '/settlement_logs/report_date/' + reportDate) - }, - ], - client_id: $scope.client.client_id, - }, - size: 'lg', - }) - } - - $scope.checkSubClientChoseShow = function (client) { - $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient - if (client != '') { - $scope.choseSubClientNow = client.short_name - } - } - $scope.clickDisplayChoseDiv = function (event) { - $scope.more20ChoseSubClient = false - } - $scope.choseDivStopPropagation = function (event) { - event.stopPropagation() - } - }, - ]) - app.controller('partnerSurchargeAccountCtrl', [ - '$scope', - '$uibModal', - '$http', - 'clientMoniker', - '$filter', - function ($scope, $uibModal, $http, clientMoniker, $filter) { - $scope.params = {} - $scope.pagination = {} - $scope.today = new Date() - - $scope.chooseToday = function () { - $scope.params.datefrom = $scope.params.dateto = new Date() - $scope.loadSettlementLogs(1) - } - $scope.chooseYesterday = function () { - var yesterday = new Date() - yesterday.setDate(yesterday.getDate() - 1) - $scope.params.datefrom = $scope.params.dateto = yesterday - $scope.loadSettlementLogs(1) - } - $scope.chooseLast7Days = function () { - $scope.params.dateto = new Date() - var day = new Date() - day.setDate(day.getDate() - 7) - $scope.params.datefrom = day - $scope.loadSettlementLogs(1) - } - $scope.thisMonth = function () { - $scope.params.dateto = new Date() - var monthBegin = new Date() - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.lastMonth = function () { - var monthFinish = new Date() - monthFinish.setDate(0) - $scope.params.dateto = monthFinish - var monthBegin = new Date() - monthBegin.setDate(0) - monthBegin.setDate(1) - $scope.params.datefrom = monthBegin - $scope.loadSettlementLogs(1) - } - $scope.loadSettlementLogs = function (page) { - var params = angular.copy($scope.params) - if (params.datefrom) { - params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd') - } - if (params.dateto) { - params.dateto = $filter('date')(params.dateto, 'yyyyMMdd') - } - params.page = page || $scope.pagination.page || 1 - params.limit = 10 - $http.get('/sys/partners/' + clientMoniker + '/surcharge_account/month_detail').then(function (resp) { - $scope.details = resp.data - }) - } - $scope.getClearingTransactions = function (client_id, detail_id) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerSettlementDetailCtrl', - resolve: { - detail: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/analysis/partner_card/' + client_id + '/settlement_logs/' + detail_id) - }, - ], - detail_id: detail_id, - }, - size: 'lg', - }) - } - $scope.chooseLast7Days() - }, - ]) - app.controller('managerSettlementDetailCtrl', [ - '$scope', - 'detail', - 'detail_id', - '$http', - function ($scope, detail, detail_id, $http) { - $scope.ctrl = { channel: null } - $scope.show = true - $scope.report = detail.data - $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) - angular.forEach($scope.report.channels, function (e) { - e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) - }) - - $scope.channelAndDayOfAnalysis = function () { - $http.get('/analysis/partner_card/settlement_logs/' + detail_id + '/analysis/' + $scope.ctrl.channel).then(function (resp) { - $scope.channelAndDayMap = resp.data - $scope.index = 0 - }) - } - $scope.channelAndDayOfAnalysis(1) - }, - ]) - app.controller('managerSettlementDetailOfMergeSettleCtrl', [ - '$scope', - 'detail', - 'client_id', - '$http', - function ($scope, detail, client_id, $http) { - $scope.ctrl = { channel: null } - $scope.show = true - $scope.report = detail.data - $scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2) - angular.forEach($scope.report.channels, function (e) { - e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2) - }) - }, - ]) - app.controller('productCtrl', [ - '$scope', - '$http', - '$uibModal', - 'commonDialog', - '$state', - 'Upload', - 'wechatGoodMcc', - function ($scope, $http, $uibModal, commonDialog, $state, Upload, wechatGoodMcc) { - $scope.importShow = 0 - $scope.pagination = {} - $scope.params = { text_type: 'all', search_text: null } - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.loadProducts = function () { - $http.get('/sys/product/' + $scope.partner.client_moniker + '/list').then(function (resp) { - $scope.mcc_goods = resp.data - }) - } - $scope.updateMccInfo = function (mccInfo) { - mccInfo.client_moniker = $scope.partner.client_moniker - $http.put('/sys/product/update', mccInfo).then(function (resp) { - $state.reload() - }) - } - $scope.loadProducts() - /*$scope.importExcel = function (file) { + + $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', @@ -6271,2078 +6344,2116 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) } }*/ - }, - ]) - app.controller('AddProductDialogCtrl', [ - '$scope', - '$http', - '$uibModal', - 'product', - 'partner', - '$state', - 'industryMap', - function ($scope, $http, $uibModal, product, partner, $state, industryMap) { - $scope.product = angular.copy(product) - $scope.product.partner = true - $scope.partner = angular.copy(partner) - $scope.industries = industryMap.configs() - - if ($scope.product.commodity_id) { - $scope.edit_or_add = 'Edit' - } else { - $scope.edit_or_add = 'Add' - $scope.product.industry = $scope.partner.industry - } - $scope.save = function () { - if ($scope.product.commodity_id) { - $http.put('/client/product/', $scope.product).then(function (resp) { - alert('Success') - $scope.$close() - $state.reload() - }) - } else { - $http.post('/client/product/' + $scope.partner.client_moniker, $scope.product).then(function (resp) { - alert('Success') - $scope.$close() - $state.reload() - }) - } - } - }, - ]) - // MID Management - app.controller('subMerchantIdApplicaitonsCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - '$sce', - function ($scope, $http, $uibModal, $state, commonDialog, $sce) { - // 初始化子商户 - $scope.loadSubMerchantInfos = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', { params: {} }).then(function (resp) { - $scope.subMerchantInfos = resp.data - }) - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_rpay_sub_applices', {params: {}}).then(function (resp) { - // $scope.subRpayMerchantInfos = resp.data; - // }); - // - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_yeepay_sub_applices', {params: {}}).then(function (resp) { - // $scope.subYeepayMerchantInfos = resp.data; - // }); - // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { - // $scope.partner.cardInfo = resp.data; - // }); - } - $scope.loadSubMerchantInfos() - // 加载卡支付信息 - $scope.loadCardInfos = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { - $scope.cardInfo = resp.data - }) - } - $scope.loadCardInfos() - // 初始化信息 - $scope.loadPartnerInfo = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { - $scope.partnerInfo = resp.data - $scope.doSwitchCommonSubMerchantId() - }) - } - $scope.loadPartnerInfo() - // 编辑Wechat Sub Merchant Id - $scope.saveSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: $scope.partnerInfo.sub_merchant_id }).then( - function (resp) { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // Wechat-applay - $scope.applyWxSubMerchantId = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/new_apply_wx_sub_merchant_id.html', - controller: 'newApplyWxSubMerchantIdCtrl', - resolve: { - subMerchantInfo: function () { - return $scope.partner - }, - merchantIds: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') - }, - ], - }, - }) - .result.then(function () { + }, + ]) + app.controller('AddProductDialogCtrl', [ + '$scope', + '$http', + '$uibModal', + 'product', + 'partner', + '$state', + 'industryMap', + function ($scope, $http, $uibModal, product, partner, $state, industryMap) { + $scope.product = angular.copy(product) + $scope.product.partner = true + $scope.partner = angular.copy(partner) + $scope.industries = industryMap.configs() + + if ($scope.product.commodity_id) { + $scope.edit_or_add = 'Edit' + } else { + $scope.edit_or_add = 'Add' + $scope.product.industry = $scope.partner.industry + } + $scope.save = function () { + if ($scope.product.commodity_id) { + $http.put('/client/product/', $scope.product).then(function (resp) { + alert('Success') + $scope.$close() + $state.reload() + }) + } else { + $http.post('/client/product/' + $scope.partner.client_moniker, $scope.product).then(function (resp) { + alert('Success') + $scope.$close() + $state.reload() + }) + } + } + }, + ]) + // MID Management + app.controller('subMerchantIdApplicaitonsCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + '$sce', + function ($scope, $http, $uibModal, $state, commonDialog, $sce) { + // 初始化子商户 + $scope.loadSubMerchantInfos = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_sub_applices', {params: {}}).then(function (resp) { + $scope.subMerchantInfos = resp.data + }) + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_rpay_sub_applices', {params: {}}).then(function (resp) { + // $scope.subRpayMerchantInfos = resp.data; + // }); + // + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/list_yeepay_sub_applices', {params: {}}).then(function (resp) { + // $scope.subYeepayMerchantInfos = resp.data; + // }); + // $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { + // $scope.partner.cardInfo = resp.data; + // }); + } $scope.loadSubMerchantInfos() - }) - } - // 刷新Wechat Sub Merchant Id - $scope.queryWechatSubMerchantIdStatus = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.partnerInfo.sub_merchant_id + '/status').then( - function (resp) { - commonDialog.alert({ - title: 'Wechat Apply Status(' + resp.data.apply_status + ')', - content: resp.data.response_str, - type: 'info', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // history - $scope.showSubMerchantLogs = function () { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', - controller: 'clientSubMerchantIdLogCtrl', - size: 'lg', - resolve: { - logs: [ - '$http', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') - }, - ], - }, - }) - } - // 刷新Wechat Institution Merchant Id - $scope.refreshWechatInstitutionMerchantId = function () { - $http - .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { - wechat_institution_merchant_id: $scope.partnerInfo.wechat_institution_merchant_id, - }) - .then( - function (resp) { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // switch开关 - $scope.doSwitchCommonSubMerchantId = function () { - $("input[name='switch']").bootstrapSwitch({ - onText: 'ON', - offText: 'OFF', - size: 'mini', - state: $scope.partnerInfo.common_sub_merchant_id, - onSwitchChange: function (event, state) { - //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里 - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', { allow: state }).then( - function () { - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ - title: 'Failed to change common_sub_merchant_id permission status', - content: resp.data.message, - type: 'error', + // 加载卡支付信息 + $scope.loadCardInfos = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/queryMWMerchantIdStatus').then(function (resp) { + $scope.cardInfo = resp.data }) - } - ) - }, - }) - } - // Alipay保存名称修改 - $scope.saveAliSubMerchantId = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.partnerInfo.ali_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Ali Sub Merchant ID successfully', - type: 'success', - }) + } + $scope.loadCardInfos() + // 初始化信息 + $scope.loadPartnerInfo = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) { + $scope.partnerInfo = resp.data + $scope.doSwitchCommonSubMerchantId() + }) + } $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // 刷新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 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', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // history + $scope.showSubMerchantLogs = function () { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/client_sub_merchant_id_log.html', + controller: 'clientSubMerchantIdLogCtrl', + size: 'lg', + resolve: { + logs: [ + '$http', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_sub_merchant_id_logs') + }, + ], + }, + }) + } + // 刷新Wechat Institution Merchant Id + $scope.refreshWechatInstitutionMerchantId = function () { + $http + .put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', { + wechat_institution_merchant_id: $scope.partnerInfo.wechat_institution_merchant_id, + }) + .then( + function (resp) { + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // switch开关 + $scope.doSwitchCommonSubMerchantId = function () { + $("input[name='switch']").bootstrapSwitch({ + onText: 'ON', + offText: 'OFF', + size: 'mini', + state: $scope.partnerInfo.common_sub_merchant_id, + onSwitchChange: function (event, state) { + //监听switch change事件,可以根据状态把相应的业务逻辑代码写在这里 + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/common_sub_merchant_id', {allow: state}).then( + function () { + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Failed to change common_sub_merchant_id permission status', + content: resp.data.message, + type: 'error', + }) + } + ) + }, + }) + } + // Alipay保存名称修改 + $scope.saveAliSubMerchantId = function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.partnerInfo.ali_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Ali Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // 刷新Alipay + $scope.queryAlipayGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + // 刷新AlipayOnline + $scope.queryAlipayOnlineGms = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then( + function (resp) { + commonDialog.alert({title: 'Success', content: resp.data.result_status, type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: '查询失败:' + resp.data.message, type: 'error'}) + } + ) + } + // Alipay进件 + $scope.submitAlipaySubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { + $scope.alipay_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipay_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then( + function () { + commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'}) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + // AlipayOnline进件 + $scope.submitAlipayOnlineSubId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms_json').then(function (resp) { + $scope.alipayOnline_gms_json = resp.data + commonDialog + .confirm({ + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipayOnline_gms_json, + }) + .then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then( + function () { + commonDialog.alert({ + title: 'Success', + content: '提示:AlipayOnline进件成功', + type: 'success' + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: '进件失败:' + resp.data.message, + type: 'error' + }) + } + ) + }) + }) + } + // use sub_merchant_id + $scope.useSubMerchantId = function (sub_merchant_id) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', {sub_merchant_id: sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + // 查看sub_merchant_id详情 + $scope.checkDetail = function (merchantInfo, channel) { + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/sub_merchant_detail.html', + controller: 'subMerchantDetailCtrl', + resolve: { + subMerchantInfo: function () { + return merchantInfo + }, + channel: function () { + return channel + }, + }, + }) + } + // 修改sub_merchant_id + $scope.modifySubMerchantId = function (subMerchantId, channel) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/md_sub_merchant_id.html', + controller: 'ModifysubMerchantIdCtrl', + resolve: { + clientMoniker: function () { + return $scope.partner.client_moniker + }, + merchantId: function () { + return subMerchantId + }, + channel: function () { + return channel + }, + }, + }) + .result.then(function () { + commonDialog.alert({ + title: 'Success', + content: 'Modify successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }) + } + // 卡支付apply + $scope.applyMWSubMerchantId = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/mw_info').then(function (resp) { + commonDialog + .confirm({ + title: 'Apply Merchant Warrior Sub Merchant Id', + contentHtml: $sce.trustAsHtml('Are you sure to apply merchant Warrior sub merchant id for [' + $scope.partner.company_name + ']?'), + json: resp.data, + }) + .then(function () { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/applyMWMerchantId').then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Merchant Warrior Sub Merchant ID successfully', + type: 'success', + }) + $scope.cardInfo = res.data + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + }) + } + + $scope.copyMWProfile = function () { + commonDialog.inputText({title: '请输入复制来源商户编码'}).then(function (text) { + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/copy_mw_config', {client_moniker: text}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify successfully', + type: 'success', + }) + $scope.loadPartnerInfo() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } + + // $scope.showMoreMerchantInfo = false; + // $scope.hideMerchantInfo = function () { + // $scope.showMoreMerchantInfo = !$scope.showMoreMerchantInfo; + // }; + $scope.updateSubMerchantId = function (sub_merchant_id) { + angular.forEach($scope.subMerchantInfos, function (each) { + if (sub_merchant_id == each.sub_merchant_id) { + $scope.merchant_app_id = each.merchant_app_id + } + }) + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/update_apply_wx_sub_merchant_id.html', + controller: 'updateApplyWxSubMerchantIdCtrl', + resolve: { + merchantInfo: $scope.partner, + merchantIds: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') + }, + ], + subMerchantInfo: [ + '$http', + '$stateParams', + function ($http) { + return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.merchant_app_id) + }, + ], + }, + }) + .result.then(function () { + $scope.loadSubMerchantInfos() + }) + } + }, + ]) + app.controller('applyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.merchantIds = merchantIds.data + $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry) + $scope.saveAppliy = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/sub_apply', $scope.subMerchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.sub_merchant_id != null) { + commonDialog.confirm({title: 'Confirm', content: '已申请成功,是否确认使用'}).then(function () { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + // 展示信息 + app.controller('subMerchantDetailCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + 'subMerchantInfo', + 'channel', + function ($scope, $http, $uibModal, $state, commonDialog, subMerchantInfo, channel) { + $scope.channel = channel + $scope.subMerchantInfo = subMerchantInfo + }, + ]) + // 修改sub_merchant_id + app.controller('ModifysubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'commonDialog', + 'clientMoniker', + 'merchantId', + 'channel', + function ($scope, $http, $uibModal, $state, commonDialog, clientMoniker, merchantId, channel) { + $scope.merchantId = merchantId + $scope.flag = false + $scope.confirm = function () { + $scope.flag = true + if (channel === 'Wechat') { + $http.put('/sys/partners/' + clientMoniker + '/payment_config', {sub_merchant_id: $scope.merchantId}).then( + function (resp) { + $scope.$close() + }, + function (resp) { + $scope.flag = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } else if (channel === 'Alipay' || channel === 'AlipayOnline') { + $http.put('/sys/partners/' + clientMoniker + '/ali_sub_merchant_id', {ali_sub_merchant_id: $scope.merchantId}).then( + function (resp) { + $scope.$close() + }, + function (resp) { + $scope.flag = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + } + }, + ]) + app.controller('newApplyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + 'wechatGoodMcc', + 'businessTypesMap', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, businessTypesMap) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + $scope.subMerchantInfo.address = subMerchantInfo.address + "," + subMerchantInfo.suburb + + "," + subMerchantInfo.state + "," + subMerchantInfo.country; + $scope.subMerchantInfo.company_register_no = subMerchantInfo.abn ? subMerchantInfo.abn : subMerchantInfo.acn + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.merchantIds = merchantIds.data + $scope.businessTypesMap = businessTypesMap.configs() + if ($scope.subMerchantInfo.client_pay_type) { + if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'BOTH' + } else if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0) { + $scope.subMerchantInfo.business_type = 'ONLINE' + } else if ($scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'OFFLINE' + } + } else { + $scope.subMerchantInfo.business_type = 'BOTH' + } + + if ($scope.subMerchantInfo.industry) { + $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry) + } + if ($scope.subMerchantInfo.mc_code) { + $scope.subMerchantInfo.mcc_code = $scope.subMerchantInfo.mc_code + } + if (subMerchantInfo.certificat_expire_date) { + var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date = new Date(datestr) + } + if ($scope.subMerchantInfo.business_structure) { + $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' + } + if (subMerchantInfo.certificat_expire_date) { + if (subMerchantInfo.certificat_expire_date == 'PERMANENT') { + $scope.subMerchantInfo.certificat_expire_date_premanent = true + } else if (subMerchantInfo.certificat_expire_date == 'N/A') { + $scope.subMerchantInfo.certificat_expire_date_NA = true + } else { + var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) + } + } + + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false + } + } + $scope.checkExpriedateOther = function (value) { + if (value == 'PERMANENT') { + if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + $scope.subMerchantInfo.certificat_expire_date_NA = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } else if (value == 'N/A') { + if ($scope.subMerchantInfo.certificat_expire_date_NA) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } + } + $scope.saveAppliy = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // var merchant_type = $scope.subMerchantInfo.business_structure == 'Company'? 1:2; + var params = { + company_name: $scope.subMerchantInfo.company_name, + merchant_id: $scope.subMerchantInfo.merchant_id, + short_name: $scope.subMerchantInfo.short_name, + office_phone: $scope.subMerchantInfo.office_phone, + contact_person: $scope.subMerchantInfo.contact_person, + contact_phone: $scope.subMerchantInfo.contact_phone, + company_phone: $scope.subMerchantInfo.company_phone, + contact_email: $scope.subMerchantInfo.contact_email, + industry: $scope.subMerchantInfo.industry, + company_website: $scope.subMerchantInfo.company_website, + merchant_type: $scope.subMerchantInfo.merchant_type, + mcc_code: $scope.subMerchantInfo.mcc_code, + address: $scope.subMerchantInfo.address, + business_type: $scope.subMerchantInfo.business_type, + } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null + } + + if (params.merchant_type == 'ENTERPRISE') { + params.director_name = $scope.subMerchantInfo.director_name + params.director_id_number = $scope.subMerchantInfo.director_id_number + params.company_register_no = $scope.subMerchantInfo.company_register_no + params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date + + if ($scope.subMerchantInfo.certificat_expire_date_d) { + params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) + } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + params.certificat_expire_date = 'PERMANENT' + } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { + params.certificat_expire_date = 'N/A' + } else { + alert('Certificate expiration time is required') + return + } + } else { + params.principal_name = $scope.subMerchantInfo.principal_name + params.principal_id_number = $scope.subMerchantInfo.principal_id_number } - ) - }) - }) - } - // 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' }) + + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/new_sub_apply', params).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.sub_merchant_id != null) { + commonDialog.confirm({title: 'Confirm', content: '已申请成功,是否确认使用'}).then(function () { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + }) + } else { + $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', {sub_merchant_id: $scope.apply_sub_merchant_id}).then( + function (resp) { + commonDialog.alert({ + title: 'Success', + content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + app.controller('updateApplyWxSubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + '$filter', + 'merchantIds', + 'commonDialog', + 'wechatGoodMcc', + 'merchantInfo', + 'businessTypesMap', + function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, merchantInfo, businessTypesMap) { + $scope.wxIndustries = angular.copy(wxMerchantIndustries) + $scope.subMerchantInfo = angular.copy(subMerchantInfo.data) + $scope.merchantInfo = angular.copy(merchantInfo) + $scope.wechatMccIndustries = wechatGoodMcc.configs() + $scope.merchantIds = merchantIds.data + $scope.businessTypesMap = businessTypesMap.configs() + $scope.subMerchantInfo.short_name = $scope.merchantInfo.short_name + $scope.subMerchantInfo.industry = $scope.merchantInfo.industry + $scope.subMerchantInfo.company_website = $scope.merchantInfo.company_website + $scope.subMerchantInfo.address = $scope.merchantInfo.address + "," + $scope.merchantInfo.suburb + + "," + $scope.merchantInfo.state + "," + $scope.merchantInfo.country; + $scope.subMerchantInfo.company_phone = $scope.merchantInfo.company_phone + $scope.subMerchantInfo.contact_person = $scope.merchantInfo.contact_person + $scope.subMerchantInfo.contact_phone = $scope.merchantInfo.contact_phone + $scope.subMerchantInfo.contact_email = $scope.merchantInfo.contact_email + $scope.subMerchantInfo.company_register_no = $scope.merchantInfo.abn ? $scope.merchantInfo.abn : $scope.merchantInfo.acn + + if ($scope.merchantInfo.client_pay_type) { + if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'BOTH' + } else if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0) { + $scope.subMerchantInfo.business_type = 'ONLINE' + } else if ($scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { + $scope.subMerchantInfo.business_type = 'OFFLINE' } - ) - }) - }) - } - // use sub_merchant_id - $scope.useSubMerchantId = function (sub_merchant_id) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_config', { sub_merchant_id: sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - // 查看sub_merchant_id详情 - $scope.checkDetail = function (merchantInfo, channel) { - $uibModal.open({ - templateUrl: '/static/payment/partner/templates/sub_merchant_detail.html', - controller: 'subMerchantDetailCtrl', - resolve: { - subMerchantInfo: function () { - return merchantInfo - }, - channel: function () { - return channel - }, - }, - }) - } - // 修改sub_merchant_id - $scope.modifySubMerchantId = function (subMerchantId, channel) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/md_sub_merchant_id.html', - controller: 'ModifysubMerchantIdCtrl', - resolve: { - clientMoniker: function () { - return $scope.partner.client_moniker - }, - merchantId: function () { - return subMerchantId - }, - channel: function () { - return channel - }, - }, - }) - .result.then(function () { - commonDialog.alert({ - title: 'Success', - content: 'Modify successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }) - } - // 卡支付apply - $scope.applyMWSubMerchantId = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/mw_info').then(function (resp) { - commonDialog - .confirm({ - title: 'Apply Merchant Warrior Sub Merchant Id', - contentHtml: $sce.trustAsHtml('Are you sure to apply merchant Warrior sub merchant id for [' + $scope.partner.company_name + ']?'), - json: resp.data, - }) - .then(function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/applyMWMerchantId').then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Merchant Warrior Sub Merchant ID successfully', - type: 'success', - }) - $scope.cardInfo = res.data - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + } else { + $scope.subMerchantInfo.business_type = 'BOTH' + } + + if ($scope.merchantInfo.industry) { + $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.merchantInfo.industry) + } + if ($scope.merchantInfo.mc_code) { + $scope.subMerchantInfo.mcc_code = $scope.merchantInfo.mc_code + } + + if ($scope.merchantInfo.business_structure) { + $scope.subMerchantInfo.merchant_type = $scope.merchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' + } + if ($scope.merchantInfo.certificat_expire_date) { + if ($scope.merchantInfo.certificat_expire_date == 'PERMANENT') { + $scope.subMerchantInfo.certificat_expire_date_premanent = true + } else if ($scope.merchantInfo.certificat_expire_date == 'N/A') { + $scope.subMerchantInfo.certificat_expire_date_NA = true + } else { + var datestr = $scope.merchantInfo.certificat_expire_date.replace(/-/g, '/') + $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) } - ) - }) - }) - } - - $scope.copyMWProfile = function () { - commonDialog.inputText({ title: '请输入复制来源商户编码' }).then(function (text) { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/copy_mw_config', { client_moniker: text }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify successfully', - type: 'success', - }) - $scope.loadPartnerInfo() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - }) - } - - // $scope.showMoreMerchantInfo = false; - // $scope.hideMerchantInfo = function () { - // $scope.showMoreMerchantInfo = !$scope.showMoreMerchantInfo; - // }; - $scope.updateSubMerchantId = function (sub_merchant_id) { - angular.forEach($scope.subMerchantInfos, function (each) { - if (sub_merchant_id == each.sub_merchant_id) { - $scope.merchant_app_id = each.merchant_app_id - } - }) - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/update_apply_wx_sub_merchant_id.html', - controller: 'updateApplyWxSubMerchantIdCtrl', - resolve: { - merchantInfo: $scope.partner, - merchantIds: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids') - }, - ], - subMerchantInfo: [ - '$http', - '$stateParams', - function ($http) { - return $http.get('/sys/partners/' + $scope.partner.client_moniker + '/get_merchant_ids/' + $scope.merchant_app_id) - }, - ], - }, - }) - .result.then(function () { - $scope.loadSubMerchantInfos() - }) - } - }, - ]) - app.controller('applyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.merchantIds = merchantIds.data - $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry) - $scope.saveAppliy = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/sub_apply', $scope.subMerchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.confirm({ title: 'Confirm', content: '已申请成功,是否确认使用' }).then(function () { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', + } + + $scope.checkExpriedate = function (value) { + if (value) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_NA = false + } + } + $scope.checkExpriedateOther = function (value) { + if (value == 'PERMANENT') { + if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + $scope.subMerchantInfo.certificat_expire_date_NA = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } else if (value == 'N/A') { + if ($scope.subMerchantInfo.certificat_expire_date_NA) { + $scope.subMerchantInfo.certificat_expire_date_premanent = false + $scope.subMerchantInfo.certificat_expire_date_d = null + } + } + } + $scope.updateApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + return + } + var params = { + company_name: $scope.subMerchantInfo.company_name, + merchant_id: $scope.subMerchantInfo.merchant_id, + short_name: $scope.subMerchantInfo.short_name, + office_phone: $scope.subMerchantInfo.office_phone, + contact_person: $scope.subMerchantInfo.contact_person, + contact_phone: $scope.subMerchantInfo.contact_phone, + company_phone: $scope.subMerchantInfo.company_phone, + contact_email: $scope.subMerchantInfo.contact_email, + industry: $scope.subMerchantInfo.industry, + company_website: $scope.subMerchantInfo.company_website, + merchant_type: $scope.subMerchantInfo.merchant_type, + mcc_code: $scope.subMerchantInfo.mcc_code, + address: $scope.subMerchantInfo.address, + business_type: $scope.subMerchantInfo.business_type, + sub_mch_id: $scope.subMerchantInfo.sub_merchant_id, + merchant_remark: $scope.subMerchantInfo.merchant_remark, + } + if (params.business_type == 'ONLINE') { + params.address = null + } else if (params.business_type == 'OFFLINE') { + params.company_website = null + } + // if($scope.subMerchantInfo.merchant_type == 'ENTERPRISE'){ + // params.director_name = $scope.subMerchantInfo.director_name; + // params.director_id_number = $scope.subMerchantInfo.director_id_number; + // params.company_register_no = $scope.subMerchantInfo.company_register_no; + // params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date; + // if($scope.subMerchantInfo.certificat_expire_date) { + // params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date) + // } + // }else{ + // params.principal_name = $scope.subMerchantInfo.principal_name; + // params.principal_id_number = $scope.subMerchantInfo.principal_id_number; + // } + if (params.merchant_type == 'ENTERPRISE') { + params.company_register_no = $scope.subMerchantInfo.company_register_no + params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date + if ($scope.subMerchantInfo.certificat_expire_date_d) { + params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) + } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { + params.certificat_expire_date = 'PERMANENT' + } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { + params.certificat_expire_date = 'N/A' + } else { + alert('Certificate expiration time is required') + return + } + } + $http.put('/sys/partners/' + $scope.merchantInfo.client_moniker + '/get_merchant_ids/' + $scope.subMerchantInfo.merchant_app_id, params).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + commonDialog.confirm({title: 'Confirm', content: 'Successfully modified!'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } ) - }) - } else { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - // 展示信息 - app.controller('subMerchantDetailCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - 'subMerchantInfo', - 'channel', - function ($scope, $http, $uibModal, $state, commonDialog, subMerchantInfo, channel) { - $scope.channel = channel - $scope.subMerchantInfo = subMerchantInfo - }, - ]) - // 修改sub_merchant_id - app.controller('ModifysubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'commonDialog', - 'clientMoniker', - 'merchantId', - 'channel', - function ($scope, $http, $uibModal, $state, commonDialog, clientMoniker, merchantId, channel) { - $scope.merchantId = merchantId - $scope.flag = false - $scope.confirm = function () { - $scope.flag = true - if (channel === 'Wechat') { - $http.put('/sys/partners/' + clientMoniker + '/payment_config', { sub_merchant_id: $scope.merchantId }).then( - function (resp) { - $scope.$close() - }, - function (resp) { - $scope.flag = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } else if (channel === 'Alipay' || channel === 'AlipayOnline') { - $http.put('/sys/partners/' + clientMoniker + '/ali_sub_merchant_id', { ali_sub_merchant_id: $scope.merchantId }).then( - function (resp) { - $scope.$close() - }, - function (resp) { - $scope.flag = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - } - }, - ]) - app.controller('newApplyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - 'wechatGoodMcc', - 'businessTypesMap', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, businessTypesMap) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.subMerchantInfo.address= subMerchantInfo.address+","+subMerchantInfo.suburb - +","+subMerchantInfo.state+","+subMerchantInfo.country; - $scope.subMerchantInfo.company_register_no = subMerchantInfo.abn ? subMerchantInfo.abn : subMerchantInfo.acn - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.merchantIds = merchantIds.data - $scope.businessTypesMap = businessTypesMap.configs() - if ($scope.subMerchantInfo.client_pay_type) { - if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'BOTH' - } else if ($scope.subMerchantInfo.client_pay_type.indexOf('1') >= 0) { - $scope.subMerchantInfo.business_type = 'ONLINE' - } else if ($scope.subMerchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'OFFLINE' - } - } else { - $scope.subMerchantInfo.business_type = 'BOTH' - } - - if ($scope.subMerchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry) - } - if ($scope.subMerchantInfo.mc_code) { - $scope.subMerchantInfo.mcc_code = $scope.subMerchantInfo.mc_code - } - if (subMerchantInfo.certificat_expire_date) { - var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date = new Date(datestr) - } - if ($scope.subMerchantInfo.business_structure) { - $scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' - } - if (subMerchantInfo.certificat_expire_date) { - if (subMerchantInfo.certificat_expire_date == 'PERMANENT') { - $scope.subMerchantInfo.certificat_expire_date_premanent = true - } else if (subMerchantInfo.certificat_expire_date == 'N/A') { - $scope.subMerchantInfo.certificat_expire_date_NA = true - } else { - var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) - } - } + } + }, + ]) + + app.controller('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 + } + } + }) - $scope.checkExpriedate = function (value) { - if (value) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - $scope.subMerchantInfo.certificat_expire_date_NA = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.subMerchantInfo.certificat_expire_date_NA) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } - } - $scope.saveAppliy = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - // var merchant_type = $scope.subMerchantInfo.business_structure == 'Company'? 1:2; - var params = { - company_name: $scope.subMerchantInfo.company_name, - merchant_id: $scope.subMerchantInfo.merchant_id, - short_name: $scope.subMerchantInfo.short_name, - office_phone: $scope.subMerchantInfo.office_phone, - contact_person: $scope.subMerchantInfo.contact_person, - contact_phone: $scope.subMerchantInfo.contact_phone, - company_phone: $scope.subMerchantInfo.company_phone, - contact_email: $scope.subMerchantInfo.contact_email, - industry: $scope.subMerchantInfo.industry, - company_website: $scope.subMerchantInfo.company_website, - merchant_type: $scope.subMerchantInfo.merchant_type, - mcc_code: $scope.subMerchantInfo.mcc_code, - address: $scope.subMerchantInfo.address, - business_type: $scope.subMerchantInfo.business_type, - } - if (params.business_type == 'ONLINE') { - params.address = null - } else if (params.business_type == 'OFFLINE') { - params.company_website = null - } + $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) + } + ) + } + } + } - 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.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) + } + ) + } + } + } - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/new_sub_apply', params).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.confirm({ title: 'Confirm', content: '已申请成功,是否确认使用' }).then(function () { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Wechat Sub Merchant ID successfully', - type: 'success', + $scope.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 + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + merchantInfo['company_name'] = $scope.subMerchantInfo.company_name + merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person + merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone + merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email + merchantInfo['company_website'] = $scope.subMerchantInfo.company_website + merchantInfo['abn'] = $scope.subMerchantInfo.abn + merchantInfo['executives'] = $scope.executives + merchantInfo['directors'] = $scope.directors + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + merchantInfo['merchantId'] = merchantId + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.yeepay_sub_merchant_id != null) { + commonDialog.alert({ + title: 'Success', + content: 'Modify Yeepay Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + } + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } ) - }) - } else { - $http.put('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/payment_config', { sub_merchant_id: $scope.apply_sub_merchant_id }).then( - function (resp) { - commonDialog.alert({ - title: 'Success', - content: 'Apply Success And Modify Wechat Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('updateApplyWxSubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - '$filter', - 'merchantIds', - 'commonDialog', - 'wechatGoodMcc', - 'merchantInfo', - 'businessTypesMap', - function ($scope, $http, $uibModal, $state, subMerchantInfo, $filter, merchantIds, commonDialog, wechatGoodMcc, merchantInfo, businessTypesMap) { - $scope.wxIndustries = angular.copy(wxMerchantIndustries) - $scope.subMerchantInfo = angular.copy(subMerchantInfo.data) - $scope.merchantInfo = angular.copy(merchantInfo) - $scope.wechatMccIndustries = wechatGoodMcc.configs() - $scope.merchantIds = merchantIds.data - $scope.businessTypesMap = businessTypesMap.configs() - $scope.subMerchantInfo.short_name = $scope.merchantInfo.short_name - $scope.subMerchantInfo.industry = $scope.merchantInfo.industry - $scope.subMerchantInfo.company_website = $scope.merchantInfo.company_website - $scope.subMerchantInfo.address = $scope.merchantInfo.address+","+$scope.merchantInfo.suburb - +","+$scope.merchantInfo.state+","+$scope.merchantInfo.country; - $scope.subMerchantInfo.company_phone = $scope.merchantInfo.company_phone - $scope.subMerchantInfo.contact_person = $scope.merchantInfo.contact_person - $scope.subMerchantInfo.contact_phone = $scope.merchantInfo.contact_phone - $scope.subMerchantInfo.contact_email = $scope.merchantInfo.contact_email - $scope.subMerchantInfo.company_register_no = $scope.merchantInfo.abn ? $scope.merchantInfo.abn : $scope.merchantInfo.acn - - if ($scope.merchantInfo.client_pay_type) { - if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'BOTH' - } else if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0) { - $scope.subMerchantInfo.business_type = 'ONLINE' - } else if ($scope.merchantInfo.client_pay_type.indexOf('2') >= 0) { - $scope.subMerchantInfo.business_type = 'OFFLINE' } - } else { - $scope.subMerchantInfo.business_type = 'BOTH' - } + }, + ]) + app.controller('addYeepaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'yeepayIndustryMap', + 'yeepayBusinessContentMap', + '$filter', + 'commonDialog', + 'Upload', + function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { + $scope.yeepay_industries = yeepayIndustryMap.configs() + $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + + var merchantInfo = {} + + $scope.saveYeepayAdd = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + + merchantInfo['sub_merchant_id'] = $scope.sub_merchant_id + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/addYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.$close() + commonDialog.alert({ + title: 'Success', + content: 'Add Yeepay Sub Merchant ID successfully', + type: 'success', + }) + $state.reload() + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('updateYeepaySubMerchantIdCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + 'subMerchantInfo', + 'yeepayIndustryMap', + 'yeepayBusinessContentMap', + '$filter', + 'commonDialog', + 'Upload', + 'subMerchantId', + function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload, subMerchantId) { + $scope.yeepay_industries = yeepayIndustryMap.configs() + $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() + $scope.subMerchantInfo = angular.copy(subMerchantInfo) + if (!$scope.subMerchantInfo.abn) { + $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn + } + var vouchers = {} + + $scope.directors = {} + $scope.executives = {} + $scope.industry = '' + $scope.business_content = '' + var merchantInfo = {} + + var merchantId = '' + + // $scope.uploadLegalIDcardFront = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardFrontProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardFrontProgress; + // $scope.legalIDcardFront = resp.data.path; + // vouchers['legalIDcardFront'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardFrontProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadLegalIDcardBack = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.legalIDcardBackProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.legalIDcardBackProgress; + // $scope.legalIDcardBack = resp.data.path; + // vouchers['legalIDcardBack'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.legalIDcardBackProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadBusinessLicence = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.businessLicenceProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.businessLicenceProgress + $scope.businessLicence = resp.data.path + merchantInfo['business_licence'] = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.businessLicenceProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - if ($scope.merchantInfo.industry) { - $scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.merchantInfo.industry) - } - if ($scope.merchantInfo.mc_code) { - $scope.subMerchantInfo.mcc_code = $scope.merchantInfo.mc_code - } + // $scope.uploadTaxLevel = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.taxLevelProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.taxLevelProgress; + // $scope.taxLevel = resp.data.path; + // vouchers['taxLevel'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.taxLevelProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadBankAccountOpen = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.bankAccountOpenProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.bankAccountOpenProgress; + // $scope.bankAccountOpen = resp.data.path; + // vouchers['bankAccountOpen'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.bankAccountOpenProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + // $scope.uploadOrgCode = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.orgCodeProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.orgCodeProgress; + // $scope.orgCode = resp.data.path; + // vouchers['orgCode'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.orgCodeProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadNonStanProtocol = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.nonStanProtocolProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.nonStanProtocolProgress; + // $scope.nonStanProtocol = resp.data.path; + // vouchers['nonStanProtocol'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.nonStanProtocolProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + // + // $scope.uploadZipPath = function (file) { + // if (file != null) { + // if (file.size > 3 * 1024 * 1024) { + // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + // } else { + // $scope.zipPathProgress = {value: 0}; + // Upload.upload({ + // url: '/attachment/yeepayFiles', + // data: {file: file} + // }).then(function (resp) { + // delete $scope.zipPathProgress; + // $scope.zipPath = resp.data.path; + // vouchers['zipPath'] = resp.data.path; + // merchantId = resp.data.merchantId; + // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) + // }, function (resp) { + // delete $scope.zipPathProgress; + // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + // }, function (evt) { + // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); + // }) + // } + // } + // }; + + $scope.uploadDirectorPassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.directorPassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.directorPassportProgress + $scope.directorPassport = resp.data.path + $scope.directors.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.directorPassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } + } - if ($scope.merchantInfo.business_structure) { - $scope.subMerchantInfo.merchant_type = $scope.merchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL' - } - if ($scope.merchantInfo.certificat_expire_date) { - if ($scope.merchantInfo.certificat_expire_date == 'PERMANENT') { - $scope.subMerchantInfo.certificat_expire_date_premanent = true - } else if ($scope.merchantInfo.certificat_expire_date == 'N/A') { - $scope.subMerchantInfo.certificat_expire_date_NA = true - } else { - var datestr = $scope.merchantInfo.certificat_expire_date.replace(/-/g, '/') - $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr) + $scope.uploadExecutivePassport = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.executivePassportProgress = {value: 0} + Upload.upload({ + url: '/attachment/yeepayFiles', + data: {file: file}, + }).then( + function (resp) { + delete $scope.executivePassportProgress + $scope.executivePassport = resp.data.path + $scope.executives.filePath = resp.data.path + merchantId = resp.data.merchantId + commonDialog.alert({ + title: 'Upload Success', + content: 'Upload Success', + type: 'success' + }) + }, + function (resp) { + delete $scope.executivePassportProgress + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, + function (evt) { + $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) + } + ) + } + } } - } - $scope.checkExpriedate = function (value) { - if (value) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_NA = false - } - } - $scope.checkExpriedateOther = function (value) { - if (value == 'PERMANENT') { - if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - $scope.subMerchantInfo.certificat_expire_date_NA = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } else if (value == 'N/A') { - if ($scope.subMerchantInfo.certificat_expire_date_NA) { - $scope.subMerchantInfo.certificat_expire_date_premanent = false - $scope.subMerchantInfo.certificat_expire_date_d = null - } - } - } - $scope.updateApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - var params = { - company_name: $scope.subMerchantInfo.company_name, - merchant_id: $scope.subMerchantInfo.merchant_id, - short_name: $scope.subMerchantInfo.short_name, - office_phone: $scope.subMerchantInfo.office_phone, - contact_person: $scope.subMerchantInfo.contact_person, - contact_phone: $scope.subMerchantInfo.contact_phone, - company_phone: $scope.subMerchantInfo.company_phone, - contact_email: $scope.subMerchantInfo.contact_email, - industry: $scope.subMerchantInfo.industry, - company_website: $scope.subMerchantInfo.company_website, - merchant_type: $scope.subMerchantInfo.merchant_type, - mcc_code: $scope.subMerchantInfo.mcc_code, - address: $scope.subMerchantInfo.address, - business_type: $scope.subMerchantInfo.business_type, - sub_mch_id: $scope.subMerchantInfo.sub_merchant_id, - merchant_remark: $scope.subMerchantInfo.merchant_remark, - } - if (params.business_type == 'ONLINE') { - params.address = null - } else if (params.business_type == 'OFFLINE') { - params.company_website = null - } - // if($scope.subMerchantInfo.merchant_type == 'ENTERPRISE'){ - // params.director_name = $scope.subMerchantInfo.director_name; - // params.director_id_number = $scope.subMerchantInfo.director_id_number; - // params.company_register_no = $scope.subMerchantInfo.company_register_no; - // params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date; - // if($scope.subMerchantInfo.certificat_expire_date) { - // params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date) - // } - // }else{ - // params.principal_name = $scope.subMerchantInfo.principal_name; - // params.principal_id_number = $scope.subMerchantInfo.principal_id_number; - // } - if (params.merchant_type == 'ENTERPRISE') { - params.company_register_no = $scope.subMerchantInfo.company_register_no - params.certificat_expire_date = $scope.subMerchantInfo.certificat_expire_date - if ($scope.subMerchantInfo.certificat_expire_date_d) { - params.certificat_expire_date = $filter('dateConversionStr')($scope.subMerchantInfo.certificat_expire_date_d) - } else if ($scope.subMerchantInfo.certificat_expire_date_premanent) { - params.certificat_expire_date = 'PERMANENT' - } else if ($scope.subMerchantInfo.certificat_expire_date_NA) { - params.certificat_expire_date = 'N/A' - } else { - alert('Certificate expiration time is required') - return - } - } - $http.put('/sys/partners/' + $scope.merchantInfo.client_moniker + '/get_merchant_ids/' + $scope.subMerchantInfo.merchant_app_id, params).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - commonDialog.confirm({ title: 'Confirm', content: 'Successfully modified!' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - - app.controller('applyRpaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'businessStructuresMap', - '$filter', - 'commonDialog', - 'timezone', - function ($scope, $http, $uibModal, $state, subMerchantInfo, businessStructuresMap, $filter, commonDialog, timezone) { - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - $scope.business_structures = businessStructuresMap.configs() - $scope.timezone = timezone.configs() - - $scope.saveRpayAppliy = function (form) { - var merchantInfo = {} - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - angular.forEach(form, function (item, key) { - if (item != null) { - if (item.$name != null) { - merchantInfo[key] = item.$modelValue - } - } - }) - - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registRpaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Rpay+ Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('applyYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - if (!$scope.subMerchantInfo.abn) { - $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn - } - var vouchers = {} - - $scope.directors = {} - $scope.executives = {} - $scope.industry = '' - $scope.business_content = '' - var merchantInfo = {} - - var merchantId = '' - - // $scope.uploadLegalIDcardFront = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardFrontProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardFrontProgress; - // $scope.legalIDcardFront = resp.data.path; - // vouchers['legalIDcardFront'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardFrontProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadLegalIDcardBack = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardBackProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardBackProgress; - // $scope.legalIDcardBack = resp.data.path; - // vouchers['legalIDcardBack'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardBackProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadBusinessLicence = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.businessLicenceProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.businessLicenceProgress - $scope.businessLicence = resp.data.path - merchantInfo['business_licence'] = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.businessLicenceProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - // $scope.uploadTaxLevel = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.taxLevelProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.taxLevelProgress; - // $scope.taxLevel = resp.data.path; - // vouchers['taxLevel'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.taxLevelProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadBankAccountOpen = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.bankAccountOpenProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.bankAccountOpenProgress; - // $scope.bankAccountOpen = resp.data.path; - // vouchers['bankAccountOpen'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.bankAccountOpenProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadOrgCode = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.orgCodeProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.orgCodeProgress; - // $scope.orgCode = resp.data.path; - // vouchers['orgCode'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.orgCodeProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadNonStanProtocol = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.nonStanProtocolProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.nonStanProtocolProgress; - // $scope.nonStanProtocol = resp.data.path; - // vouchers['nonStanProtocol'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.nonStanProtocolProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadZipPath = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.zipPathProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.zipPathProgress; - // $scope.zipPath = resp.data.path; - // vouchers['zipPath'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.zipPathProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadDirectorPassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.directorPassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.directorPassportProgress - $scope.directorPassport = resp.data.path - $scope.directors.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.directorPassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } - - $scope.uploadExecutivePassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.executivePassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.executivePassportProgress - $scope.executivePassport = resp.data.path - $scope.executives.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.executivePassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } - } - } + $scope.updateYeepayApply = function (form) { + $scope.errmsg = null + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + // angular.forEach(form, function (item, key) { + // if(item !=null) { + // if(item.$name !=null) { + // merchantInfo[key] = item.$modelValue; + // } + // } + // }); + merchantInfo['company_name'] = $scope.subMerchantInfo.company_name + merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person + merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone + merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email + merchantInfo['company_website'] = $scope.subMerchantInfo.company_website + merchantInfo['abn'] = $scope.subMerchantInfo.abn + merchantInfo['executives'] = $scope.executives + merchantInfo['subMerchantId'] = angular.copy(subMerchantId) + merchantInfo['directors'] = $scope.directors + merchantInfo['business_content'] = $scope.business_content + merchantInfo['industry'] = $scope.industry + merchantInfo['merchantId'] = merchantId + $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/updateYeepaySubMerchantId', merchantInfo).then( + function (resp) { + $scope.apply_sub_merchant_id = resp.data + $scope.$close() + if (subMerchantInfo.yeepay_sub_merchant_id != null) { + commonDialog.alert({ + title: 'Success', + content: 'Update Successfully,Please Wait For Review!', + type: 'success', + }) + $state.reload() + } + }, + function (resp) { + commonDialog.alert({ + title: 'Error', + content: resp.data.message, + type: 'error', + }) + } + ) + } + }, + ]) + app.controller('permissionClientCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + '$filter', + 'commonDialog', + function ($scope, $http, $uibModal, $state, $filter, commonDialog) { + $scope.clientPermission = {client_moniker: $scope.partner.client_moniker} + $scope.loadPermissionList = function () { + var params = angular.copy($scope.clientPermission) + $http.get('/sys/permission/list', {params: params}).then( + function (resp) { + $scope.permissionList = resp.data + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + $scope.loadPermissionList(1) + $scope.switchValid = function (permission) { + $scope.clientPermission.isValid = permission.is_valid + var params = angular.copy($scope.clientPermission) + $http.post('/sys/permission/' + permission.id, params).then( + function (resp) { + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } - $scope.saveYeepayApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true + $scope.init = function () { + var params = {client_moniker: $scope.partner.client_moniker} + $http.post('/sys/permission/init', params).then( + function (resp) { + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - merchantInfo['company_name'] = $scope.subMerchantInfo.company_name - merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person - merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone - merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email - merchantInfo['company_website'] = $scope.subMerchantInfo.company_website - merchantInfo['abn'] = $scope.subMerchantInfo.abn - merchantInfo['executives'] = $scope.executives - merchantInfo['directors'] = $scope.directors - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - merchantInfo['merchantId'] = merchantId - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/registYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.yeepay_sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Modify Yeepay Sub Merchant ID successfully', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', + }, + ]) + app.controller('incrementalServiceCtrl', [ + '$scope', + '$http', + '$uibModal', + '$state', + '$filter', + 'commonDialog', + function ($scope, $http, $uibModal, $state, $filter, commonDialog) { + $scope.serviceAll = {} + $scope.channelOptions = [] + $scope.initData = function () { + $http.get('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service').then(function (res) { + $scope.serviceAll = res.data.all_service + $scope.serviceAll.forEach(function (service) { + service.logo_url = '/static/images/' + service.channel + '.jpg' + service.logo_url = $scope.CheckImgExists(service.logo_url) ? service.logo_url : '/static/images/royalpay_sign.png' + }) + $scope.channelOptions = res.data.incremental_channel + }) + } + $scope.CheckImgExists = function (url) { + var xmlHttp + if (window.ActiveXObject) { + xmlHttp = new ActiveXObject('Microsoft.XMLHTTP') + } else if (window.XMLHttpRequest) { + xmlHttp = new XMLHttpRequest() + } + xmlHttp.open('Get', url, false) + xmlHttp.send() + if (xmlHttp.status == 404) return false + else return true + } + $scope.initData() + $scope.newServiceChannelDialog = function () { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', + controller: 'incrementalServiceDialogCtrl', + resolve: { + params: function () { + return { + isCreate: true, + clientMoniker: $scope.partner.client_moniker, + channelOptions: $scope.channelOptions, + serviceChannel: null, + } + }, + }, + }) + .result.then(function () { + $scope.initData() + }) + } + $scope.editServiceChannelDialog = function (serviceChannel) { + $uibModal + .open({ + templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', + controller: 'incrementalServiceDialogCtrl', + resolve: { + params: function () { + return { + isCreate: false, + clientMoniker: $scope.partner.client_moniker, + channelOptions: $scope.channelOptions, + serviceChannel: serviceChannel, + } + }, + }, + }) + .result.then(function () { + $scope.initData() + }) + } + $scope.updateStatus = function (service) { + commonDialog + .confirm({ + title: 'Update ' + service.channel + ' Incremental Service Status', + content: 'Are you sure update ' + service.channel + ' status?', + choises: [ + {label: 'Submit', className: 'btn-success', key: 1}, + {label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true}, + ], + }) + .then(function (choice) { + if (choice == 1) { + service.is_valid = !service.is_valid + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service/status', service).then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: 'Update Service Successful!', + type: 'success', + }) + $scope.initData() + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $scope.initData() + } + ) + } + }) + } + }, + ]) + app.controller('incrementalServiceDialogCtrl', [ + '$scope', + '$http', + 'params', + 'commonDialog', + function ($scope, $http, params, commonDialog) { + $scope.model = {} + $scope.ctrl = {sending: false} + $scope.isCreate = true + $scope.initData = function () { + $scope.isCreate = angular.copy(params.isCreate) + if ($scope.isCreate) { + $scope.model.channel = angular.copy(params.channelOptions[0]) + $scope.model.channelOptions = angular.copy(params.channelOptions) + } else { + $scope.model = angular.copy(params.serviceChannel) + } + } + $scope.initData() + $scope.save = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true + } + }) + return + } + $scope.ctrl.sending = true + $http.post('/sys/partners/' + params.clientMoniker + '/incremental_service', $scope.model).then( + function (res) { + commonDialog.alert({ + title: 'Success', + content: $scope.isCreate ? 'Create Service Successful!' : 'Update Service Successful!', + type: 'success', + }) + $scope.ctrl.sending = false + $scope.$close() + }, + function (resp) { + $scope.ctrl.sending = false + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + + app.filter('bdOrg', function () { + return function (bdUsers, org_id) { + if (org_id) { + var bdUserByOrg = {} + var count = 0 + angular.forEach(bdUsers, function (bdUser) { + if (bdUser.org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + }) + return bdUserByOrg + } + return bdUsers + } + }) + app.filter('wxMerchants', function () { + return function (values) { + var industry = '' + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } }) - } - ) - } - }, - ]) - app.controller('addYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - - var merchantInfo = {} - - $scope.saveYeepayAdd = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - - merchantInfo['sub_merchant_id'] = $scope.sub_merchant_id - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/addYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.$close() - commonDialog.alert({ - title: 'Success', - content: 'Add Yeepay Sub Merchant ID successfully', - type: 'success', + return industry + } + }) + //将保存的industry 和最新的分类比较,若查不到,返回空 + app.filter('newWxMerchantsFilter', function () { + return function (values) { + var industry = null + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.value + } }) - $state.reload() - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', + return industry + } + }) + app.filter('newWxMerchants', function () { + return function (values) { + var industry = '' + angular.forEach(wxMerchantIndustries, function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } }) - } - ) - } - }, - ]) - app.controller('updateYeepaySubMerchantIdCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - 'subMerchantInfo', - 'yeepayIndustryMap', - 'yeepayBusinessContentMap', - '$filter', - 'commonDialog', - 'Upload', - 'subMerchantId', - function ($scope, $http, $uibModal, $state, subMerchantInfo, yeepayIndustryMap, yeepayBusinessContentMap, $filter, commonDialog, Upload, subMerchantId) { - $scope.yeepay_industries = yeepayIndustryMap.configs() - $scope.yeepay_business_contents = yeepayBusinessContentMap.configs() - $scope.subMerchantInfo = angular.copy(subMerchantInfo) - if (!$scope.subMerchantInfo.abn) { - $scope.subMerchantInfo.abn = $scope.subMerchantInfo.acn - } - var vouchers = {} - - $scope.directors = {} - $scope.executives = {} - $scope.industry = '' - $scope.business_content = '' - var merchantInfo = {} - - var merchantId = '' - - // $scope.uploadLegalIDcardFront = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardFrontProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardFrontProgress; - // $scope.legalIDcardFront = resp.data.path; - // vouchers['legalIDcardFront'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardFrontProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardFrontProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadLegalIDcardBack = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.legalIDcardBackProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.legalIDcardBackProgress; - // $scope.legalIDcardBack = resp.data.path; - // vouchers['legalIDcardBack'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.legalIDcardBackProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.legalIDcardBackProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadBusinessLicence = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.businessLicenceProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.businessLicenceProgress - $scope.businessLicence = resp.data.path - merchantInfo['business_licence'] = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.businessLicenceProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.businessLicenceProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + return industry + } + }) + app.filter('yeepayIndustry', function () { + return function (value) { + switch (value + '') { + case 'ehk100000': + return '货物贸易' + case 'ehk200000': + return '旅游' + case 'ehk300000': + return '文化教育' + case 'ehk400000': + return '服务贸易' + case 'ehk500000': + return '物流' + case 'ehk600000': + return '数字娱乐' + case 'ehk700000': + return '金融保险' + case 'ehk999999': + return '其他' + } } - } - - // $scope.uploadTaxLevel = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.taxLevelProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.taxLevelProgress; - // $scope.taxLevel = resp.data.path; - // vouchers['taxLevel'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.taxLevelProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.taxLevelProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadBankAccountOpen = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.bankAccountOpenProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.bankAccountOpenProgress; - // $scope.bankAccountOpen = resp.data.path; - // vouchers['bankAccountOpen'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.bankAccountOpenProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.bankAccountOpenProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - // $scope.uploadOrgCode = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.orgCodeProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.orgCodeProgress; - // $scope.orgCode = resp.data.path; - // vouchers['orgCode'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.orgCodeProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.orgCodeProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadNonStanProtocol = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.nonStanProtocolProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.nonStanProtocolProgress; - // $scope.nonStanProtocol = resp.data.path; - // vouchers['nonStanProtocol'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.nonStanProtocolProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.nonStanProtocolProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - // - // $scope.uploadZipPath = function (file) { - // if (file != null) { - // if (file.size > 3 * 1024 * 1024) { - // commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) - // } else { - // $scope.zipPathProgress = {value: 0}; - // Upload.upload({ - // url: '/attachment/yeepayFiles', - // data: {file: file} - // }).then(function (resp) { - // delete $scope.zipPathProgress; - // $scope.zipPath = resp.data.path; - // vouchers['zipPath'] = resp.data.path; - // merchantId = resp.data.merchantId; - // commonDialog.alert({title: 'Upload Success', content: 'Upload Success', type: 'success'}) - // }, function (resp) { - // delete $scope.zipPathProgress; - // commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) - // }, function (evt) { - // $scope.zipPathProgress.value = parseInt(100 * evt.loaded / evt.total); - // }) - // } - // } - // }; - - $scope.uploadDirectorPassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.directorPassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.directorPassportProgress - $scope.directorPassport = resp.data.path - $scope.directors.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.directorPassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.directorPassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + }) + + app.filter('yeepayBusinessContent', function () { + return function (value) { + switch (value + '') { + case 'SERVICETRADE': + return '服务贸易' + case 'GOODSTRADE': + return '货物贸易' + case 'OVERSEASTUDY': + return '留学' + case 'HOTELTICKET': + return '酒店机票' + case 'INTTRANSPORT': + return '国际运输' + case 'TOURSERVICE': + return '旅游服务' + case 'INSURANCE': + return '保险' + } } - } - - $scope.uploadExecutivePassport = function (file) { - if (file != null) { - if (file.size > 3 * 1024 * 1024) { - commonDialog.alert({ title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error' }) - } else { - $scope.executivePassportProgress = { value: 0 } - Upload.upload({ - url: '/attachment/yeepayFiles', - data: { file: file }, - }).then( - function (resp) { - delete $scope.executivePassportProgress - $scope.executivePassport = resp.data.path - $scope.executives.filePath = resp.data.path - merchantId = resp.data.merchantId - commonDialog.alert({ title: 'Upload Success', content: 'Upload Success', type: 'success' }) - }, - function (resp) { - delete $scope.executivePassportProgress - commonDialog.alert({ title: 'Upload Failed', content: resp.data.message, type: 'error' }) - }, - function (evt) { - $scope.executivePassportProgress.value = parseInt((100 * evt.loaded) / evt.total) - } - ) - } + }) + + app.filter('bdOrgSelect', function () { + return function (bdUsers, params) { + var org_id + org_id = params.org_ids || params.org_id || currentUser.org_id + if (org_id) { + var bdUserByOrg = {} + var count = 0 + angular.forEach(bdUsers, function (bdUser) { + if (params.org_ids) { + if (bdUser.org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + } else { + if (bdUser.org_id == org_id || bdUser.parent_org_id == org_id) { + bdUserByOrg[count] = bdUser + count++ + } + } + }) + return bdUserByOrg + } + return bdUsers + } + }) + + app.filter('wxindustries', function () { + return function (value) { + switch (value + '') { + case '327': + return '343' + case '339': + return '493' + case '337': + return '492' + case '328': + return '491' + case '362': + case '361': + case '363': + case '329': + return '490' + case '330': + return '489' + case '332': + return '487' + case '334': + return '486' + case '335': + return '485' + case '336': + return '484' + case '338': + case '358': + return '494' + } } - } + }) - $scope.updateYeepayApply = function (form) { - $scope.errmsg = null - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true + app.filter('wechatMcc', [ + 'wechatGoodMcc', + function (wechatGoodMcc) { + return function (values) { + var industry = '' + angular.forEach(wechatGoodMcc.configs(), function (wxMerchant) { + if (wxMerchant.value == values) { + industry = wxMerchant.label + } + }) + return industry + } + }, + ]) + + app.filter('choose_merchant_id', function () { + return function (value) { + switch (value + '') { + case '1307485301': + return '1307485301(Tunnel Show1)' + case '1431999902': + return '1431999902(Tunnel Show2)' + case '1487387142': + return '1487387142(NAP)' + case '': + return '' } - }) - return - } - // angular.forEach(form, function (item, key) { - // if(item !=null) { - // if(item.$name !=null) { - // merchantInfo[key] = item.$modelValue; - // } - // } - // }); - merchantInfo['company_name'] = $scope.subMerchantInfo.company_name - merchantInfo['contact_person'] = $scope.subMerchantInfo.contact_person - merchantInfo['contact_phone'] = $scope.subMerchantInfo.contact_phone - merchantInfo['contact_email'] = $scope.subMerchantInfo.contact_email - merchantInfo['company_website'] = $scope.subMerchantInfo.company_website - merchantInfo['abn'] = $scope.subMerchantInfo.abn - merchantInfo['executives'] = $scope.executives - merchantInfo['subMerchantId'] = angular.copy(subMerchantId) - merchantInfo['directors'] = $scope.directors - merchantInfo['business_content'] = $scope.business_content - merchantInfo['industry'] = $scope.industry - merchantInfo['merchantId'] = merchantId - $http.post('/sys/partners/' + $scope.subMerchantInfo.client_moniker + '/updateYeepaySubMerchantId', merchantInfo).then( - function (resp) { - $scope.apply_sub_merchant_id = resp.data - $scope.$close() - if (subMerchantInfo.yeepay_sub_merchant_id != null) { - commonDialog.alert({ - title: 'Success', - content: 'Update Successfully,Please Wait For Review!', - type: 'success', - }) - $state.reload() - } - }, - function (resp) { - commonDialog.alert({ - title: 'Error', - content: resp.data.message, - type: 'error', - }) - } - ) - } - }, - ]) - app.controller('permissionClientCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - '$filter', - 'commonDialog', - function ($scope, $http, $uibModal, $state, $filter, commonDialog) { - $scope.clientPermission = { client_moniker: $scope.partner.client_moniker } - $scope.loadPermissionList = function () { - var params = angular.copy($scope.clientPermission) - $http.get('/sys/permission/list', { params: params }).then( - function (resp) { - $scope.permissionList = resp.data - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - $scope.loadPermissionList(1) - $scope.switchValid = function (permission) { - $scope.clientPermission.isValid = permission.is_valid - var params = angular.copy($scope.clientPermission) - $http.post('/sys/permission/' + permission.id, params).then( - function (resp) {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - - $scope.init = function () { - var params = { client_moniker: $scope.partner.client_moniker } - $http.post('/sys/permission/init', params).then( - function (resp) {}, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - app.controller('incrementalServiceCtrl', [ - '$scope', - '$http', - '$uibModal', - '$state', - '$filter', - 'commonDialog', - function ($scope, $http, $uibModal, $state, $filter, commonDialog) { - $scope.serviceAll = {} - $scope.channelOptions = [] - $scope.initData = function () { - $http.get('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service').then(function (res) { - $scope.serviceAll = res.data.all_service - $scope.serviceAll.forEach(function (service) { - service.logo_url = '/static/images/' + service.channel + '.jpg' - service.logo_url = $scope.CheckImgExists(service.logo_url) ? service.logo_url : '/static/images/royalpay_sign.png' - }) - $scope.channelOptions = res.data.incremental_channel - }) - } - $scope.CheckImgExists = function (url) { - var xmlHttp - if (window.ActiveXObject) { - xmlHttp = new ActiveXObject('Microsoft.XMLHTTP') - } else if (window.XMLHttpRequest) { - xmlHttp = new XMLHttpRequest() - } - xmlHttp.open('Get', url, false) - xmlHttp.send() - if (xmlHttp.status == 404) return false - else return true - } - $scope.initData() - $scope.newServiceChannelDialog = function () { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', - controller: 'incrementalServiceDialogCtrl', - resolve: { - params: function () { - return { - isCreate: true, - clientMoniker: $scope.partner.client_moniker, - channelOptions: $scope.channelOptions, - serviceChannel: null, - } - }, - }, - }) - .result.then(function () { - $scope.initData() - }) - } - $scope.editServiceChannelDialog = function (serviceChannel) { - $uibModal - .open({ - templateUrl: '/static/payment/partner/templates/incremental_service_dialog.html', - controller: 'incrementalServiceDialogCtrl', - resolve: { - params: function () { - return { - isCreate: false, - clientMoniker: $scope.partner.client_moniker, - channelOptions: $scope.channelOptions, - serviceChannel: serviceChannel, - } - }, - }, - }) - .result.then(function () { - $scope.initData() - }) - } - $scope.updateStatus = function (service) { - commonDialog - .confirm({ - title: 'Update ' + service.channel + ' Incremental Service Status', - content: 'Are you sure update ' + service.channel + ' status?', - choises: [ - { label: 'Submit', className: 'btn-success', key: 1 }, - { label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true }, - ], - }) - .then(function (choice) { - if (choice == 1) { - service.is_valid = !service.is_valid - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/incremental_service/status', service).then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: 'Update Service Successful!', - type: 'success', - }) - $scope.initData() - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $scope.initData() - } - ) - } - }) - } - }, - ]) - app.controller('incrementalServiceDialogCtrl', [ - '$scope', - '$http', - 'params', - 'commonDialog', - function ($scope, $http, params, commonDialog) { - $scope.model = {} - $scope.ctrl = { sending: false } - $scope.isCreate = true - $scope.initData = function () { - $scope.isCreate = angular.copy(params.isCreate) - if ($scope.isCreate) { - $scope.model.channel = angular.copy(params.channelOptions[0]) - $scope.model.channelOptions = angular.copy(params.channelOptions) - } else { - $scope.model = angular.copy(params.serviceChannel) - } - } - $scope.initData() - $scope.save = function (form) { - if (form.$invalid) { - angular.forEach(form, function (item, key) { - if (key.indexOf('$') < 0) { - item.$dirty = true - } - }) - return - } - $scope.ctrl.sending = true - $http.post('/sys/partners/' + params.clientMoniker + '/incremental_service', $scope.model).then( - function (res) { - commonDialog.alert({ - title: 'Success', - content: $scope.isCreate ? 'Create Service Successful!' : 'Update Service Successful!', - type: 'success', - }) - $scope.ctrl.sending = false - $scope.$close() - }, - function (resp) { - $scope.ctrl.sending = false - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - - app.filter('bdOrg', function () { - return function (bdUsers, org_id) { - if (org_id) { - var bdUserByOrg = {} - var count = 0 - angular.forEach(bdUsers, function (bdUser) { - if (bdUser.org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - }) - return bdUserByOrg - } - return bdUsers - } - }) - app.filter('wxMerchants', function () { - return function (values) { - var industry = '' - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label - } - }) - return industry - } - }) - //将保存的industry 和最新的分类比较,若查不到,返回空 - app.filter('newWxMerchantsFilter', function () { - return function (values) { - var industry = null - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.value - } - }) - return industry - } - }) - app.filter('newWxMerchants', function () { - return function (values) { - var industry = '' - angular.forEach(wxMerchantIndustries, function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label } - }) - return industry - } - }) - app.filter('yeepayIndustry', function () { - return function (value) { - switch (value + '') { - case 'ehk100000': - return '货物贸易' - case 'ehk200000': - return '旅游' - case 'ehk300000': - return '文化教育' - case 'ehk400000': - return '服务贸易' - case 'ehk500000': - return '物流' - case 'ehk600000': - return '数字娱乐' - case 'ehk700000': - return '金融保险' - case 'ehk999999': - return '其他' - } - } - }) - - app.filter('yeepayBusinessContent', function () { - return function (value) { - switch (value + '') { - case 'SERVICETRADE': - return '服务贸易' - case 'GOODSTRADE': - return '货物贸易' - case 'OVERSEASTUDY': - return '留学' - case 'HOTELTICKET': - return '酒店机票' - case 'INTTRANSPORT': - return '国际运输' - case 'TOURSERVICE': - return '旅游服务' - case 'INSURANCE': - return '保险' - } - } - }) - - app.filter('bdOrgSelect', function () { - return function (bdUsers, params) { - var org_id - org_id = params.org_ids || params.org_id || currentUser.org_id - if (org_id) { - var bdUserByOrg = {} - var count = 0 - angular.forEach(bdUsers, function (bdUser) { - if (params.org_ids) { - if (bdUser.org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - } else { - if (bdUser.org_id == org_id || bdUser.parent_org_id == org_id) { - bdUserByOrg[count] = bdUser - count++ - } - } - }) - return bdUserByOrg - } - return bdUsers - } - }) - - app.filter('wxindustries', function () { - return function (value) { - switch (value + '') { - case '327': - return '343' - case '339': - return '493' - case '337': - return '492' - case '328': - return '491' - case '362': - case '361': - case '363': - case '329': - return '490' - case '330': - return '489' - case '332': - return '487' - case '334': - return '486' - case '335': - return '485' - case '336': - return '484' - case '338': - case '358': - return '494' - } - } - }) - - app.filter('wechatMcc', [ - 'wechatGoodMcc', - function (wechatGoodMcc) { - return function (values) { - var industry = '' - angular.forEach(wechatGoodMcc.configs(), function (wxMerchant) { - if (wxMerchant.value == values) { - industry = wxMerchant.label - } - }) - return industry - } - }, - ]) - - app.filter('choose_merchant_id', function () { - return function (value) { - switch (value + '') { - case '1307485301': - return '1307485301(Tunnel Show1)' - case '1431999902': - return '1431999902(Tunnel Show2)' - case '1487387142': - return '1487387142(NAP)' - case '': - return '' - } - } - }) + }) - app.filter('cut', function () { - return function (value, wordwise, max, tail) { - if (!value) return '' + app.filter('cut', function () { + return function (value, wordwise, max, tail) { + if (!value) return '' - max = parseInt(max, 10) - if (!max) return value - if (value.length <= max) return value + max = parseInt(max, 10) + if (!max) return value + if (value.length <= max) return value - value = value.substr(0, max) - if (wordwise) { - var lastspace = value.lastIndexOf(' ') - if (lastspace != -1) { - value = value.substr(0, lastspace) + value = value.substr(0, max) + if (wordwise) { + var lastspace = value.lastIndexOf(' ') + if (lastspace != -1) { + value = value.substr(0, lastspace) + } + } + return value + (tail || ' …') + } + }) + app.filter('dateConversionStr', function () { + return function (date) { + var year = date.getFullYear() //获取完整的年份(4位,1970-????) + var month = date.getMonth() + 1 //获取当前月份(0-11,0代表1月) + var day = date.getDate() //获取当前日(1-31) + if (month < 10) { + month = '0' + month + } + if (day < 10) { + day = '0' + day + } + var dateString = year + '-' + month + '-' + day + return dateString } - } - return value + (tail || ' …') - } - }) - app.filter('dateConversionStr', function () { - return function (date) { - var year = date.getFullYear() //获取完整的年份(4位,1970-????) - var month = date.getMonth() + 1 //获取当前月份(0-11,0代表1月) - var day = date.getDate() //获取当前日(1-31) - if (month < 10) { - month = '0' + month - } - if (day < 10) { - day = '0' + day - } - var dateString = year + '-' + month + '-' + day - return dateString - } - }) - return app + }) + return app }) diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index 79245604a..13627efc0 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 @@ -108,28 +108,28 @@

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

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

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

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

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

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

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

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

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

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

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

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

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

+ title="Prevent not enough refund">