Merge remote-tracking branch 'origin/develop' into develop

master
yixian 6 years ago
commit 1473f89c0c

@ -677,3 +677,11 @@ ADD COLUMN `wechat_institution_merchant_id` varchar(6) NULL AFTER `wechat_insti
ALTER TABLE `log_client_sub_merchant_id`
ADD COLUMN `wechat_institution_merchant_id` varchar(6) NULL AFTER `client_id`;
INSERT INTO `sys_configs` VALUES ('payment.ali.individual_daily_limit', 100000,null);
INSERT INTO `sys_configs` VALUES ('payment.ali.individual_yearly_limit', 500000,null);
INSERT INTO `sys_configs` VALUES ('payment.ali.per_order_limit', 10000,null);
update sys_clients set contact_phone = concat('+61',contact_phone) where create_time >'2018-06-01' and source = 4
alter table sys_org add COLUMN `state` varchar(20) DEFAULT NULL COMMENT '州 (使用标准码 NSW,QLD,WA,VIC,ACT,NT,TAS,SA)';

@ -545,7 +545,6 @@ public class RetailAppServiceImp implements RetailAppService {
@Override
public JSONObject userInfo(JSONObject device) {
logger.debug("userinfo device json:" + device.toJSONString());
String accountId = device.getString("account_id");
if (accountId != null) {
JSONObject user = signInAccountService.getClient(accountId);

@ -3,17 +3,15 @@ package au.com.royalpay.payment.manage.application.core.impls;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.manage.mappers.preapply.SysClientPreMapperMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager;
@ -59,10 +57,6 @@ import cn.yixblog.platform.http.HttpRequestResult;
@Service
public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@Value("${royalpay.sms.appid:1400094878}")
private int appId;
@Value("${royalpay.sms.appkey:43390d81e20c5191c278fbf4cd275be2}")
private String appKey;
@Resource
private MpPaymentApi mpPaymentApi;
@Resource
@ -72,6 +66,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@Resource
private MailService mailService;
@Resource
private PermissionPartnerManager permissionPartnerManager;
@Resource
private SpringTemplateEngine thymeleaf;
@Resource
private ClientManager clientManager;
@ -89,11 +85,18 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
private ClientRateMapper clientRateMapper;
@Resource
private ClientConfigMapper clientConfigMapper;
@Resource
private ManagerMapper managerMapper;
@Resource
private ClientBDMapper clientBDMapper;
private ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 10, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
@Resource
private SmsSender smsSender;
@Resource
private StringRedisTemplate stringRedisTemplate;
private SmsSingleSender sender = null;
private final int REGISTER_CLIENT_TEMPLID = 126978;
private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT";
private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS";
@ -103,7 +106,6 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@PostConstruct
public void init() {
tags.add("account");
sender = new SmsSingleSender(appId, appKey);
}
@Override
@ -140,7 +142,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
String expireMin = "3";
param.add(expireMin);
try {
sender.sendWithParam(nationCode.trim(), phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", "");
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong Please try again");
@ -290,7 +292,13 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
throw new ForbiddenException("The user name has been registered");
}
String clientMoniker = generateClientMoniker();
JSONObject sysClient = new JSONObject();
JSONObject followBd = managerMapper.findByLoginId("customerservice");
sysClient.put("bd_user", followBd.getString("manager_id"));
sysClient.put("bd_user_name", followBd.getString("display_name"));
sysClient.put("company_name", apply.getString("company_name"));
sysClient.put("abn", apply.getString("abn"));
sysClient.put("short_name", apply.getString("short_name"));
@ -301,7 +309,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysClient.put("royalpayindustry", apply.getString("industry"));
sysClient.put("contact_person", apply.getString("contact_person"));
sysClient.put("contact_email", apply.getString("contact_email"));
sysClient.put("contact_phone", apply.getString("contact_phone"));
sysClient.put("contact_phone", "+61"+apply.getString("contact_phone"));
sysClient.put("company_phone", apply.getString("company_phone"));
sysClient.put("client_moniker", clientMoniker);
sysClient.put("create_time", new Date());
@ -322,6 +330,16 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysClient.put("ali_sub_merchant_id", clientMoniker);
clientMapper.save(sysClient);
JSONObject client_bd = new JSONObject();
client_bd.put("client_id", sysClient.getIntValue("client_id"));
client_bd.put("bd_id", followBd.getString("manager_id"));
client_bd.put("bd_name", followBd.getString("display_name"));
client_bd.put("create_time", new Date());
client_bd.put("create_id","0");
client_bd.put("start_date", new Date());
client_bd.put("proportion", 1);
clientBDMapper.saveBD(client_bd);
int clientId = sysClient.getIntValue("client_id");
JSONObject sysAccount = new JSONObject();
@ -365,6 +383,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
apply.put("client_moniker", clientMoniker);
sysClientPreMapperMapper.update(apply);
permissionPartnerManager.permissionClientModuleSave(clientId,clientMoniker);
JSONObject sysRate = new JSONObject();
sysRate.put("client_id", clientId);
sysRate.put("clean_days", apply.getIntValue("clean_days"));

@ -28,6 +28,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -79,6 +81,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
private static BigDecimal percent = new BigDecimal(100);
private static String[] channels = new String[]{"Wechat", "Alipay", "Bestpay", "jd", "AlipayOnline","hf"};
private static Logger logger = LoggerFactory.getLogger(BDPrizeServiceImpl.class);
@Override
public void generateRecord(String month) {
@ -121,14 +124,16 @@ public class BDPrizeServiceImpl implements BDPrizeService {
List<JSONObject> trades = transactionMapper.listTransactionsForBDPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, channel);
List<Integer> clientsWithBDAway = clientBDMapper.clientsWithBDAway();
List<JSONObject> rateConfig = getRateConfig();
BDPrizeCalculator calculator = new BDPrizeCalculatorDefaultImpl(trades, now.getTime()).clientBDMapper(clientBDMapper)
BDPrizeCalculator calculator = new BDPrizeCalculatorDefaultImpl(trades, now.getTime()).clientBDMapper(clientBDMapper).transactionMapper(transactionMapper)
.clientsWithBDAwayDeterminor(new DefaultClientWithBDAwayDeterminor(clientsWithBDAway)).rateConfig(rateConfig);
calculator.calculate();
List<JSONObject> report = calculator.getReport();
List<JSONObject> report = calculator.getReport(now.get(Calendar.YEAR),now.get(Calendar.MONTH) + 1);
logger.info("======calculator.report=========="+channel+"===="+report.toString());
for (JSONObject log : report) {
log.put("record_id", record.getString("record_id"));
log.put("channel", channel);
log.remove("prize_log_id");
logger.info("=========financialBDPrizeLogMapper.save======="+log.toString());
financialBDPrizeLogMapper.save(log);
List<JSONObject> details = (List<JSONObject>) log.get("details");
for (JSONObject detail : details) {

@ -11,5 +11,5 @@ public interface BDPrizeCalculator {
void calculate();
List<JSONObject> getReport();
List<JSONObject> getReport(int year,int month);
}

@ -9,16 +9,20 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import com.alibaba.fastjson.JSONObject;
import au.com.royalpay.payment.manage.bdprize.support.BDPrizeCalculator;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by yixian on 2017-02-08.
*/
public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
private static Logger logger = LoggerFactory.getLogger(BDPrizeCalculator.class);
private final List<JSONObject> tradeLogs;
private final Date month;
private ClientBDMapper clientBDMapper;
@ -27,6 +31,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
private Map<String, JSONObject> bdMap = new HashMap<>();
private Map<Integer, Map<Integer, List<JSONObject>>> rateConfigMap = new HashMap<>();
private Map<String, BigDecimal> bdTotalMap = new HashMap<>();
private TransactionMapper transactionMapper;
public BDPrizeCalculatorDefaultImpl(List<JSONObject> tradeLogs, Date month) {
this.tradeLogs = tradeLogs;
@ -38,6 +43,11 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
return this;
}
public BDPrizeCalculatorDefaultImpl transactionMapper(TransactionMapper transactionMapper) {
this.transactionMapper = transactionMapper;
return this;
}
public BDPrizeCalculatorDefaultImpl clientsWithBDAwayDeterminor(DefaultClientWithBDAwayDeterminor clientWithBDAwayDeterminor) {
this.clientsWithBDAwayDeterminor = clientWithBDAwayDeterminor;
return this;
@ -47,15 +57,15 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
for (JSONObject rateCfgItem : rateConfig) {
int level = rateCfgItem.getIntValue("bd_level");
int kpiRange = rateCfgItem.getIntValue("kpi_range");
Map<Integer, List<JSONObject>> rates = rateConfigMap.get(level);
if (rates == null) {
rates = new HashMap<>();
rateConfigMap.put(level, rates);
Map<Integer, List<JSONObject>> levelRates = rateConfigMap.get(level);
if (levelRates == null) {
levelRates = new HashMap<>();
rateConfigMap.put(level, levelRates);
}
List<JSONObject> rate = rates.get(kpiRange);
List<JSONObject> rate = levelRates.get(kpiRange);
if (rate == null) {
rate = new ArrayList<>();
rates.put(kpiRange, rate);
levelRates.put(kpiRange, rate);
}
rate.add(rateCfgItem);
}
@ -73,7 +83,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
}
@Override
public List<JSONObject> getReport() {
public List<JSONObject> getReport(int year,int month1) {
List<JSONObject> report = new ArrayList<>();
for (Map.Entry<String, Map<String, JSONObject>> resultItem : results.entrySet()) {
JSONObject log = new JSONObject();
@ -86,15 +96,8 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
log.put("total_amount", 0);
log.put("total_prize", 0);
log.put("total_donation", 0);
BigDecimal totalAmount = log.getBigDecimal("total_amount");
BigDecimal totalAmount = transactionMapper.TotalAmountForBDPrize(year,month1,bd.getString("bd_id"));
List<JSONObject> details = new ArrayList<>();
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
JSONObject detailItem = detail.getValue();
BigDecimal totalTransaction = detailItem.getBigDecimal("total_transaction");
BigDecimal coefficient = detailItem.getBigDecimal("coefficient");
BigDecimal realTransaction = totalTransaction.multiply(coefficient).setScale(2,BigDecimal.ROUND_DOWN);
totalAmount = totalAmount.add(realTransaction);
}
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
JSONObject detailItem = detail.getValue();
int clientId = detailItem.getIntValue("client_id");
@ -102,6 +105,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
BigDecimal totalTransaction = detailItem.getBigDecimal("total_transaction");
BigDecimal coefficient = detailItem.getBigDecimal("coefficient");
int prizeLevel = getKpiPrizeLevel(totalAmount,log.getBigDecimal("kpi_amount"));
logger.debug("-------->bd kpi level:"+bd.getString("bd_name")+"---level:"+prizeLevel+",kpi:"+log.getBigDecimal("kpi_amount")+",trans:"+totalAmount+",client_id:"+clientId);
BigDecimal bdRate = getNewRate(bdLevel, prizeLevel, detailItem.getIntValue("client_source"), detailItem.getBigDecimal("rate_value"));
BigDecimal prizeValue = totalTransaction.multiply(coefficient).multiply(bdRate).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_DOWN);
BigDecimal donation = BigDecimal.ZERO;
@ -222,8 +226,8 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
private BigDecimal getNewRate(int bdLevel, int kpiRange, int clientSource, BigDecimal clientRate) {
BigDecimal prizeRate = BigDecimal.ZERO;
Map<Integer, List<JSONObject>> rates = rateConfigMap.get(bdLevel);
List<JSONObject> rate = rates.get(kpiRange);
Map<Integer, List<JSONObject>> levelRates = rateConfigMap.get(bdLevel);
List<JSONObject> rate = levelRates.get(kpiRange);
for (JSONObject rateCfg : rate) {
if (rateCfg.getBigDecimal("rate_from").compareTo(clientRate) <= 0 && rateCfg.getBigDecimal("rate_to").compareTo(clientRate) >= 0) {
prizeRate= rateCfg.getBigDecimal("prize_rate");

@ -32,10 +32,10 @@ public class EncourageMoneyController {
public JSONObject takeEncourageMoney(@PathVariable String orderId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,
@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
String user_id = "";
logger.info("problem order id:"+orderId+"--wxUser:"+wxUser+"--aliuser:"+aliuser);
if (wxUser == null) {
user_id = aliuser.getString("user_id");
} else {
logger.info("====wxUser==" + wxUser.toJSONString());
user_id = wxUser.getString("openid");
}
if (StringUtils.isEmpty(user_id)) {
@ -81,4 +81,13 @@ public class EncourageMoneyController {
public ModelAndView merchantsPage() {
return new ModelAndView("activity/encourage_money/merchants");
}
public static void main(String[] args) {
JSONObject asd = null;
JSONObject qwe = null;
System.out.println(asd);
System.out.println(qwe);
}
}

@ -0,0 +1,9 @@
package au.com.royalpay.payment.manage.dev.core;
/**
* @author kira
* @date 2018/8/2
*/
public interface ManualService {
void clientPostpone();
}

@ -0,0 +1,95 @@
package au.com.royalpay.payment.manage.dev.core.impl;
import au.com.royalpay.payment.manage.dev.core.ManualService;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify;
import au.com.royalpay.payment.manage.task.PostponeClientTask;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/8/2
*/
@Service
public class ManualServiceimpl implements ManualService {
Logger logger = LoggerFactory.getLogger(PostponeClientTask.class);
@Resource
private ClientRateMapper clientRateMapper;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private ClientModifySupport clientModifySupport;
@Override
public void clientPostpone() {
logger.info("start doing client postpone");
synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
Date now = new Date();
Date tomorrow = DateUtils.addDays(now, 1);
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
if (CollectionUtils.isEmpty(expiryClient)) {
return;
}
Map<Integer, JSONObject> expiryClients = new HashMap<>();
expiryClient.forEach(p -> {
expiryClients.put(p.getInteger("client_id"), p);
});
expiryClients.values().forEach(p -> {
int client_id = p.getIntValue("client_id");
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
int cleanDays = 1;
if (wechatRate.getInteger("clean_days") != null) {
cleanDays = wechatRate.getIntValue("clean_days");
} else {
cleanDays = wechatRate.getIntValue("c_clean_days");
}
int finalCleanDays = cleanDays;
clientRates.forEach(o -> {
JSONObject record = clientRateMapper.latestExpiryConfig(client_id, o.getString("rate_name"));
record.remove("client_rate_id");
record.put("active_time", now);
record.put("manager_id", 0);
record.put("expiry_time", yearTomorrow);
record.put("create_time", now);
record.put("update_time", now);
record.put("clean_days", finalCleanDays);
record.put("manager_name", "System");
record.put("remark", "费率到期系统自动延期1年");
clientRateMapper.saveRate(record);
});
if(p.getBooleanValue("tax_in_surcharge")){
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null,p.getString("client_moniker"),"tax_in_surcharge",false));
}
});
});
logger.info("end doing client postpone");
}
}

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.manage.dev.core.ManualService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* Created by yixian on 2017-01-25.
*/
@RestController
@ManagerMapping(role = ManagerRole.DEVELOPER,value = "/dev/manual")
public class ManualController {
@Resource
private ManualService manualService;
@RequestMapping(method = RequestMethod.GET,value = "/client/postpone")
public void clientPostpone(){
manualService.clientPostpone();
}
}

@ -2,7 +2,6 @@ package au.com.royalpay.payment.manage.management.sysconfig.beans;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import org.hibernate.validator.constraints.NotEmpty;
/**
* Created by yangluo on 2018/07/05.
@ -54,5 +53,6 @@ public class PartnerModuleInfo {
mod.put("js_module", getJsModule());
mod.put("js_path", getJsPath());
mod.put("remark", getRemark());
mod.put("initialize",getInitialize());
}
}

@ -118,7 +118,7 @@ public class PermissionPartnerManagerImpl implements PermissionPartnerManager {
moduleClientAdd.put("client_id", clientId);
moduleClientAdd.put("client_moniker", clientMoniker);
moduleClientAdd.put("module_id", moduleClientAdd.getString("id"));
moduleClientAdd.put("is_valid", 1);
moduleClientAdd.put("is_valid", moduleClientAdd.getBooleanValue("initialize"));
permissionClientModulesService.save(moduleClientAdd);
}

@ -93,6 +93,8 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel);
BigDecimal TotalAmountForBDPrize(@Param("year") int year, @Param("month") int month, @Param("bd_id") String bd_id);
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);

@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;

@ -1,7 +1,6 @@
package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
@ -66,8 +65,6 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw
private ApplicationEventPublisher publisher;
@Resource
private ClientConfigService clientConfigService;
@Resource
private PermissionPartnerManagerImpl permissionPartnerManagerImpl;
@Override
@Transactional
@ -223,8 +220,6 @@ public class ClientApplyImpl implements ClientApply, ApplicationEventPublisherAw
clientConfig.put("client_id",partner.getIntValue("client_id"));
clientConfig.put("client_moniker",info.getClientMoniker());
clientConfigService.save(clientConfig);
permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"),info.getClientMoniker());
JSONObject client_bd = new JSONObject();
client_bd.put("client_id", partner.getIntValue("client_id"));

@ -1,5 +1,69 @@
package au.com.royalpay.payment.manage.merchants.core.impls;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.MessageSource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
@ -15,10 +79,32 @@ import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.device.core.DeviceManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl;
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper;
import au.com.royalpay.payment.manage.mappers.log.LogClientSubMerchantIdMapper;
import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.PermissionClientModuleMapper;
import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
@ -55,6 +141,7 @@ import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
@ -87,73 +174,9 @@ import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.MessageSource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/**
* partner manage Created by yixian on 2016-06-28.
*/
@ -271,9 +294,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private PermissionClientModuleMapper permissionClientModuleMapper;
@Resource
private PermissionPartnerManagerImpl permissionPartnerManagerImpl;
@Resource
private SmsSender smsSender;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
private static final String CLIENT_BANK_FILE = "client_bank_file";
private static final String CLIENT_ID_FILE = "client_id_file";
@ -290,6 +312,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
private MpWechatApiProvider mpWechatApiProvider;
private final int REFUSE_CLIENT_TEMPLID = 166108;
@PostConstruct
public void init() {
tags.add("account");
@ -328,12 +353,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkClientOrg(manager, client);
}
client.putAll(clientConfigService.find(client.getIntValue("client_id")));
client.put("unsubscribe",mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null?false:true);
client.put("unsubscribe", mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null ? false : true);
client.put("show_all_permission", true);
int role = manager != null ? manager.getIntValue("role") : 0;
if (manager != null) {
if (ManagerRole.OPERATOR.hasRole(role)) {
List<JSONObject> log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc")));
List<JSONObject> log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),
new PageBounds(Order.formString("create_time.desc")));
client.put("sub_merchant_id_log", log.size() > 0 ? true : false);
}
if (ManagerRole.BD_USER.hasRole(role)) {
@ -570,7 +596,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientConfig.put("client_id", partner.getIntValue("client_id"));
clientConfig.put("client_moniker", partner.getString("client_moniker"));
clientConfigService.save(clientConfig);
permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"),partner.getString("client_moniker"));
permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"), partner.getString("client_moniker"));
} catch (Exception e) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
@ -681,11 +707,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (!oldClient.getString("contact_email").equals(newClient.getString("contact_email"))) {
List<String> exceptClientIds = new ArrayList<>();
exceptClientIds.add(newClient.getString("client_id"));
JSONObject sameMailClients = getByEmail(oldClient.getString("contact_email"),1,1,exceptClientIds);
if(sameMailClients.getJSONArray("data").size()<1) {
JSONObject sameMailClients = getByEmail(oldClient.getString("contact_email"), 1, 1, exceptClientIds);
if (sameMailClients.getJSONArray("data").size() < 1) {
mailGunService.updateClientOfMailList(newClient, oldClient);
}else {
oldClient.put("contact_email",newClient.getString("contact_email"));
} else {
oldClient.put("contact_email", newClient.getString("contact_email"));
mailGunService.addClientToMailList(oldClient);
}
}
@ -753,20 +779,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
int clientId = client.getIntValue("client_id");
update.put("client_id", clientId);
String wechatInstitutionMerchantId = RandomStringUtils.random(6, true, true).toUpperCase();
if(StringUtils.isEmpty(refreshWechatInstitutionMerchantId.getString("wechat_institution_merchant_id"))){
update.put("wechat_institution_merchant_id",wechatInstitutionMerchantId);
}else {
update.put("wechat_institution_merchant_id",createWechatInstitutionMerchantId(wechatInstitutionMerchantId)) ;
if (StringUtils.isEmpty(refreshWechatInstitutionMerchantId.getString("wechat_institution_merchant_id"))) {
update.put("wechat_institution_merchant_id", wechatInstitutionMerchantId);
} else {
update.put("wechat_institution_merchant_id", createWechatInstitutionMerchantId(wechatInstitutionMerchantId));
}
clientMapper.update(update);
clientInfoCacheSupport.clearClientCache(clientId);
}
private String createWechatInstitutionMerchantId(String wechatInstitutionMerchantId){
private String createWechatInstitutionMerchantId(String wechatInstitutionMerchantId) {
JSONObject client = clientMapper.findByWechatInstitutionMerchantId(wechatInstitutionMerchantId);
if(client == null){
if (client == null) {
return wechatInstitutionMerchantId;
}else {
return createWechatInstitutionMerchantId(RandomStringUtils.random(6, true, true).toUpperCase());
} else {
return createWechatInstitutionMerchantId(RandomStringUtils.random(6, true, true).toUpperCase());
}
}
@ -807,10 +834,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(client.getIntValue("client_id"));
JSONObject account = accounts.get(0);
sendInitEmail(client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
saveClientAuditProcess(client.getIntValue("client_id"), open_status, 5, "合规通过", manager);
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"skip_clearing",false));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"common_sub_merchant_id",false));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "skip_clearing", false));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "common_sub_merchant_id", false));
} else if (checkGreenChannel && client.getIntValue("open_status") == 5) {
// 绿色通道通过后不发邮件
logger.info("PASS 绿色通道:" + clientMoniker);
@ -864,7 +891,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
sendInitEmail(client, username, pwd);
// sendInitEmail(manager, client, username, pwd);
// sendInitEmail(manager, client, username, pwd);
}
@Override
@ -888,7 +915,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(clientId);
if (client.getIntValue("source") == 4) {
JSONObject account = accounts.get(0);
// sendInitEmail(manager, client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
sendInitEmail(client, account.getString("username"), "*****");
} else {
if (accounts.size() == 0) {
@ -897,7 +924,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject account = accounts.get(0);
String pwd = RandomStringUtils.random(8, true, true);
resetAccountPwd(manager, clientMoniker, account.getString("account_id"), pwd);
// sendInitEmail(manager, client, account.getString("username"), pwd);
// sendInitEmail(manager, client, account.getString("username"), pwd);
sendInitEmail(client, account.getString("username"), pwd);
}
}
@ -956,62 +983,33 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}.start();
}
/**
* public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) {
logger.debug("sending email after comply");
JSONObject model = new JSONObject();
model.put("username", username);
model.put("password", pwd);
model.put("client_moniker", client.getString("client_moniker"));
model.put("contact_person", client.getString("contact_person"));
model.put("credential_code", client.getString("credential_code"));
List<JSONObject> bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date());
// todo Velocity
Context ctx = new Context();
ctx.setVariable("bds", bds);
ctx.setVariable("password", pwd);
ctx.setVariable("username", username);
ctx.setVariable("client_moniker", client.getString("client_moniker"));
ctx.setVariable("contact_person", client.getString("contact_person"));
ctx.setVariable("credential_code", client.getString("credential_code"));
ctx.setVariable("short_name", client.getString("short_name"));
final String content = thymeleaf.process("mail/new_client_notice", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm",
// "utf-8", model);
final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
emails.add(email);
}
}
new Thread() {
@Override
public void run() {
try {
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setFrom("info@mail.royalpay.com.au");
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
sendMail.setContent(content);
sendMail.setTags(tags);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
} catch (Exception e) {
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, null));
throw new EmailException("Email Sending Failed", e);
}
}
}.start();
}
/**
* public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) {
* logger.debug("sending email after comply"); JSONObject model = new JSONObject(); model.put("username", username);
* model.put("password", pwd); model.put("client_moniker", client.getString("client_moniker"));
* model.put("contact_person", client.getString("contact_person")); model.put("credential_code",
* client.getString("credential_code")); List<JSONObject> bds =
* clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date()); // todo Velocity Context
* ctx = new Context(); ctx.setVariable("bds", bds); ctx.setVariable("password", pwd); ctx.setVariable("username",
* username); ctx.setVariable("client_moniker", client.getString("client_moniker"));
* ctx.setVariable("contact_person", client.getString("contact_person")); ctx.setVariable("credential_code",
* client.getString("credential_code")); ctx.setVariable("short_name", client.getString("short_name")); final String
* content = thymeleaf.process("mail/new_client_notice", ctx); // final String content =
* VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm", // "utf-8", model); final String
* mailTo = client.getString("contact_email"); if (StringUtils.isEmpty(mailTo)) { throw new EmailException("Client
* Contact Email is invalid"); } final Set<String> emails = new HashSet<>(); for (JSONObject bd : bds) { String
* email = bd.getString("email"); if (StringUtils.isNotEmpty(email)) { emails.add(email); } } new Thread() {
*
* @Override public void run() { try { SendMail sendMail = new SendMail(); Set<String> to = new HashSet<>();
* to.add(mailTo); sendMail.setFrom("info@mail.royalpay.com.au"); sendMail.setMailTos(to);
* sendMail.setMailCcs(emails); sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
* sendMail.setContent(content); sendMail.setTags(tags); JSONObject mailResult =
* mailGunService.sendMail(sendMail); clientModifySupport.processClientModify(new EmailModify(account,
* client.getString("client_moniker"), 3, mailResult.getString("mail_id"))); } catch (Exception e) {
* clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0,
* null)); throw new EmailException("Email Sending Failed", e); } } }.start(); }
*
*/
public void sendAuthInitEmail(JSONObject account, final JSONObject client) {
@ -2605,8 +2603,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, false));
List<String> exceptClientIds = new ArrayList<>();
exceptClientIds.add(client.getString("client_id"));
JSONObject sameMailClients = getByEmail(client.getString("contact_email"),1,1,exceptClientIds);
if(sameMailClients.getJSONArray("data").size()<1) {
JSONObject sameMailClients = getByEmail(client.getString("contact_email"), 1, 1, exceptClientIds);
if (sameMailClients.getJSONArray("data").size() < 1) {
mailGunService.removeMailList(client);
}
}
@ -2697,12 +2695,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (query.getPage() == 1) {
if (!logs.isEmpty() && logs.size() > 0) {
JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id"));
if (clearingDetail!=null){
if (clearingDetail != null) {
JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id"));
if(clearingLog.getBooleanValue("editable")){
if (clearingLog.getBooleanValue("editable")) {
result.put("padding", true);
logs.get(0).put("padding",true);
logger.info("##editable"+clearingLog.getBooleanValue("editable"));
logs.get(0).put("padding", true);
logger.info("##editable" + clearingLog.getBooleanValue("editable"));
}
}
}
@ -3005,8 +3003,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new InvalidShortIdException();
}
clientModifySupport
.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "require_remark", requireRemark));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "require_remark", requireRemark));
}
@ -3055,8 +3052,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
saveClientAuditProcess(client.getIntValue("client_id"), open_status, client.getInteger("open_status"), "打回," + refuse_remark, manager);
clientModifySupport.processClientModify(auditModify);
try {
sendMessageToBD(client, refuse_remark);
// sendMessageToBD(client, refuse_remark);
if (client.getIntValue("source") == 4) {
String contact_phone = client.getString("contact_phone");
if (contact_phone.startsWith("+61")) {
ArrayList<String> param = new ArrayList<>();
param.add(refuse_remark);
try {
smsSender.getSender().sendWithParam("61", contact_phone.replace("+61", ""), REFUSE_CLIENT_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception ignore) {
throw new ServerErrorException("Phone number is wrong :" + contact_phone);
}
}
}
} catch (Exception e) {
logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage());
}
@ -3608,7 +3618,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc")));
return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"), new PageBounds(Order.formString("create_time.desc")));
}
@Override
@ -3617,7 +3627,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new InvalidShortIdException();
}
if(client.getIntValue("approve_result")==1){
if (client.getIntValue("approve_result") == 1) {
throw new BadRequestException("The merchant has been passed");
}
client.putAll(clientConfigService.find(client.getIntValue("client_id")));
@ -3678,11 +3688,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public JSONObject getByEmail(String email, int page, int limit,List<String> exceptClientIds) {
public JSONObject getByEmail(String email, int page, int limit, List<String> exceptClientIds) {
JSONObject param = new JSONObject();
param.put("contact_email",email);
param.put("except_client_ids",exceptClientIds);
return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param,new PageBounds(page, limit)));
param.put("contact_email", email);
param.put("except_client_ids", exceptClientIds);
return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param, new PageBounds(page, limit)));
}
@Override
@ -3702,10 +3712,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
JSONObject sub = mailUnsubMapper.findOneByClientMoniker(client_moniker);
if(sub == null){
throw new BadRequestException();
}
JSONObject sub = mailUnsubMapper.findOneByClientMoniker(client_moniker);
if (sub == null) {
throw new BadRequestException();
}
mailService.removeUnsub(sub.getLong("id"));
}
@ -3717,26 +3727,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
if(allow){
if(StringUtils.isEmpty(client.getString("hf_pay_url"))){
if (allow) {
if (StringUtils.isEmpty(client.getString("hf_pay_url"))) {
String hf_pay_url = getShortLink(clientMoniker);
client.put("hf_pay_url",hf_pay_url);
client.put("hf_pay_url", hf_pay_url);
JSONObject clientConfig = new JSONObject();
clientConfig.put("hf_pay_url",hf_pay_url);
clientConfig.put("client_id",client.getIntValue("client_id"));
clientConfig.put("hf_pay_url", hf_pay_url);
clientConfig.put("client_id", client.getIntValue("client_id"));
clientConfigMapper.update(clientConfig);
clientMapper.update(client);
}
}
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_link", allow));
}
@Override
public String getShortLink(String client_moniker){
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/"+client_moniker+"/jump");
public String getShortLink(String client_moniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + client_moniker + "/jump");
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
return api.registerShortUrl(longUrl);
}
}

@ -37,6 +37,7 @@ public class ClientModifySupportImpl implements ClientModifySupport {
@Override
public void processClientConfigModify(ClientConfigModify clientConfigModify) {
clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper,clientMapper,mongoTemplate);
int clientId = clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper,clientMapper,mongoTemplate);
clientInfoCacheSupport.clearClientCache(clientId);
}
}

@ -42,6 +42,7 @@ public class OrgInfo {
private Double min_jd_rate;
private Double min_alipayonline_rate;
private Double min_hf_rate;
private String state;
public JSONObject toJsonParam() {
JSONObject param = new JSONObject();
@ -301,4 +302,12 @@ public class OrgInfo {
public void setMin_hf_rate(Double min_hf_rate) {
this.min_hf_rate = min_hf_rate;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}

@ -1,7 +1,7 @@
package au.com.royalpay.payment.manage.permission.manager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
@ -13,6 +13,8 @@ import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Component;
@ -30,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
*/
@Component
public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements Ordered {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private SignInStatusManager signInStatusManager;
@Resource
@ -104,13 +107,14 @@ public class ManagerUserInterceptor extends HandlerInterceptorAdapter implements
}
}
// JSONObject func = permissionPartnerManager.getPartnerFuncById(funcId);
// if(func!=null && StringUtils.isNotEmpty(func.getString("module_id"))){
// JSONArray arr = loginUser.getJSONArray("available_module_ids");
// if (arr == null || !arr.contains(func.getString("module_id"))) {
// throw new ForbiddenException("error.permission.nopermission");
// }
// }
JSONObject func = permissionPartnerManager.getPartnerFuncById(funcId);
if(func!=null && StringUtils.isNotEmpty(func.getString("module_id"))){
JSONArray arr = loginUser.getJSONArray("available_module_ids");
if (arr == null || !arr.contains(func.getString("module_id"))) {
logger.info(funcId);
throw new ForbiddenException("error.permission.nopermission");
}
}
request.setAttribute(CommonConsts.PARTNER_STATUS, loginUser);
}

@ -0,0 +1,33 @@
package au.com.royalpay.payment.manage.support.sms;
import com.github.qcloudsms.SmsSingleSender;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* @author kira
* @date 2018/8/1
*/
@Component
public class SmsSender {
@Value("${royalpay.sms.appid:1400094878}")
private int appId;
@Value("${royalpay.sms.appkey:43390d81e20c5191c278fbf4cd275be2}")
private String appKey;
private SmsSingleSender sender = null;
@PostConstruct
public void init() {
sender = new SmsSingleSender(appId, appKey);
}
public SmsSingleSender getSender(){
return sender;
}
}

@ -22,6 +22,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.HashMap;
@ -111,6 +112,9 @@ public class PostponeClientTask {
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
try {
if(StringUtils.isEmpty(account.getString("wechat_openid"))){
return;
}
MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid"));
if (api != null) {
String templateId = api.getTemplateId("client-postpone");

@ -331,7 +331,7 @@
)
</if>
<if test="begin!=null">and s.date &gt;= #{begin} </if>
<if test="end!=null">and s.date &lt; #{end}</if>
<if test="end!=null">and s.date &lt;= #{end}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if>
<if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>

@ -502,23 +502,32 @@
ORDER BY trade_date ASC, o.client_id ASC
</select>
<select id="TotalAmountForBDPrize" resultType="java.math.BigDecimal">
<![CDATA[
select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion))
total FROM
(SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time FROM pmt_transactions l
INNER JOIN pmt_orders o
ON o.order_id = l.order_id
and year(o.create_time) = #{year} AND month(o.create_time) = #{month}
where (l.transaction_type='Credit' or l.refund_id is not null)
) temp
INNER JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
d.is_valid = '1'
AND (d.end_date is null or d.end_date > temp.create_time)
and d.bd_id=#{bd_id}
]]>
</select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)),0)
ifnull(sum(t.total),0)
total
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id
INNER JOIN sys_clients c ON c.client_id = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month}
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
FROM statistics_customer_order t
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year} AND month(t.date) = #{month}
and t.client_id!=0
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -527,22 +536,13 @@
</select>
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
SELECT
ifnull(sum(t.total),0)
total
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id
INNER JOIN sys_clients c ON c.client_id = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month}
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
FROM statistics_customer_order t
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year} AND month(t.date) = #{month}
and t.client_id!=0
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id

@ -926,17 +926,27 @@ margin-bottom: 10%;"/>
&lt;!&ndash;<i class="fa fa-shopping-cart"></i>&ndash;&gt;Sale
</a>
</li>-->
<li ng-if="currentUser.client.client_moniker=='PINE' || currentUser.client.client_moniker=='OCCO'">
<li ng-if="13|withPartnerModule">
<a ui-sref="bill_qrcode">
Bill QR Code
</a>
</li>
<li ng-if="currentUser.client.client_moniker=='WOWW' || currentUser.client.client_moniker=='PINE'">
<li ng-if="31|withPartnerModule">
<a ui-sref="custom">
Report Custom
</a>
</li>
<li ui-sref-active="active" ng-if="30|withPartnerModule">
<a ui-sref="vipcustomers">
VIP Qrcode
</a>
</li>
<li ui-sref-active="active" ng-if="(currentUser.role=='1' || currentUser.role=='2') && currentUser.client.approve_result==1 && 29|withPartnerModule" title="店长红包|Manager Welfare">
<a ui-sref="partner_wechat">
店长红包|Manager Welfare
</a>
</li>
</ul>
</li>

@ -289,7 +289,7 @@
placeholder="Your Phone" maxlength="11" ng-mouseleave="checkParams()" ng-mousedown="name_exist =false">
<button type="button" class="btn btn-success button_width" style="display:inline;height: 34px;float: right;border-radius: 0px"
title="发送验证码" ng-click="sendVerificationCode()"
ng-bind="description" ng-disabled="canClick"></button>
ng-bind="description" ng-disabled="canClick||name_exist"></button>
</div>
<div style="text-align: left" ng-if="name_exist">
<span style="text-align: left;font-size: 12px;" class="text-danger">The phone number has already existed</span>

@ -200,6 +200,29 @@
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">支付宝支付限额</div>
<div class="panel-body">
<div class="form-group col-sm-6">
<label class="control-label col-sm-4" for="wechat-max-per-order">支付宝每笔订单金额</label>
<div class="col-sm-6">
<input id="ali-max-per-order" class="form-control" ng-model="paymentconfig['payment.ali.per_order_limit']">
</div>
</div>
<div class="form-group col-sm-6">
<label class="control-label col-sm-4" for="wechat_individual_daily_limit">支付宝单人单日限额</label>
<div class="col-sm-6">
<input id="ali_individual_daily_limit" class="form-control" ng-model="paymentconfig['payment.ali.individual_daily_limit']">
</div>
</div>
<div class="form-group col-sm-6">
<label class="control-label col-sm-4" for="wechat_individual_yearly_limit">支付宝单人每年限额</label>
<div class="col-sm-6">
<input id="ali_individual_yearly_limit" class="form-control" ng-model="paymentconfig['payment.ali.individual_yearly_limit']">
</div>
</div>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">用户关单率检测 <span class="small text-red">检测用户当日订单</span></div>
<div class="panel-body">

@ -67,7 +67,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','./transaction/an
params.begin = $filter('date')(new Date(), 'yyyyMMdd');
}
if (params.end) {
params.end = $filter('date')(params.end.setMonth(params.end.getMonth()+1), 'yyyyMMdd');
params.end = $filter('date')(getLastDay(params.end.getFullYear(),params.end.getMonth()), 'yyyyMMdd');
} else {
params.end = $filter('date')(new Date(), 'yyyyMMdd');
}
@ -80,6 +80,19 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','./transaction/an
$scope.totalChannelAmount = resp.data;
});
};
function getLastDay(year,month)
{
var new_year = year; //取当前的年份
var new_month = ++month;//取下一个月的第一天,方便计算(最后一天不固定)
if(month>11) //如果当前大于12月则年份转到下一年
{
new_month -=12; //月份减
new_year++; //年份增
}
var new_date = new Date(new_year,new_month,1); //取当年当月中的第一天
return new Date(new_date.getTime()-1000*60*60*24);//获取当月最后一天日期
}
$scope.thisYear();
var ordersHistoryConfig = {
chart: {

@ -562,7 +562,7 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
angular.forEach($rootScope.currentUser.available_module_ids, function (item) {
if((item+'') == (module+'')){
result = true;
return ;
return result;
}
});
return result;
@ -574,6 +574,7 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
};
}]);
app.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',
defaultTime: '00:00:00',

@ -120,7 +120,7 @@
<p class="form-control-static" ng-bind="order.customer_payment_amount|currency:order.currency+' '"></p>
</div>
</div>
<div class="form-group" ng-if="order.status>=5">
<div class="form-group" ng-if="order.status>=5 && order.channel!='hf'">
<label class="control-label col-xs-3">Exchange Rate</label>
<div class="col-xs-9">
<p class="form-control-static" ng-bind="order.exchange_rate"></p>

@ -80,6 +80,19 @@
</div>
</div>
</div>
<div class="col-xs-4" ng-if="detail.AlipayOnlineDetail">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="AliOnline" src="/static/images/alipay_online.png">
</div>
<div class="info-box-content">
<h5>Transaction: ${{detail.AlipayOnlineDetail.total_amount}}</h5>
<h5>Commission: ${{detail.AlipayOnlineDetail.total_prize}}</h5>
<h5>Send: ${{detail.AlipayOnlineDetail.send_prize}}</h5>
<h5>Fund: ${{detail.AlipayOnlineDetail.total_donation}}</h5>
</div>
</div>
</div>
<div class="col-xs-4" ng-if="detail.BestpayDetail">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
@ -93,6 +106,32 @@
</div>
</div>
</div>
<div class="col-xs-4" ng-if="detail.jdDetail">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="JD" src="/static/images/jd_sign_lg.png">
</div>
<div class="info-box-content">
<h5>Transaction: ${{detail.jdDetail.total_amount}}</h5>
<h5>Commission: ${{detail.jdDetail.total_prize}}</h5>
<h5>Send: ${{detail.jdDetail.send_prize}}</h5>
<h5>Fund: ${{detail.jdDetail.total_donation}}</h5>
</div>
</div>
</div>
<div class="col-xs-4" ng-if="detail.hfDetail">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="HF" src="/static/images/hf_sign_lg.png">
</div>
<div class="info-box-content">
<h5>Transaction: ${{detail.hfDetail.total_amount}}</h5>
<h5>Commission: ${{detail.hfDetail.total_prize}}</h5>
<h5>Send: ${{detail.hfDetail.send_prize}}</h5>
<h5>Fund: ${{detail.hfDetail.total_donation}}</h5>
</div>
</div>
</div>
</div>
<div class="box box-default" ng-if="!detail.no_record">
<div class="box-header">Details<span class="text-danger">(Red Client Moniker means received from BD User who left company.)</span></div>
@ -131,7 +170,10 @@
<td>
<img ng-if="log.channel=='Alipay'" uib-tooltip="Alipay" src="/static/images/alipay_sign_lg.png">
<img ng-if="log.channel=='Wechat'" uib-tooltip="Wechat" src="/static/images/wechatpay_sign_lg.png">
<img ng-if="log.channel=='AlipayOnline'" uib-tooltip="Bestpay" src="/static/images/alipay_online.png">
<img ng-if="log.channel=='Bestpay'" uib-tooltip="Bestpay" src="/static/images/bestpay_sign_lg.png">
<img ng-if="log.channel=='jd'" uib-tooltip="Bestpay" src="/static/images/jd_sign_lg.png">
<img ng-if="log.channel=='hf'" uib-tooltip="Bestpay" src="/static/images/hf_sign_lg.png">
</td>
</tr>
</tbody>

@ -59,6 +59,18 @@
</div>
</div>
</div>
<div class="col-xs-4" ng-if="report.AlipayOnlineReport">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="AliOnline" src="/static/images/alipay_online.png">
</div>
<div class="info-box-content">
<h5>BD Total Commission: ${{report.AlipayOnlineReport.total_prize}}</h5>
<h5>BD Total Send: ${{report.AlipayOnlineReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.AlipayOnlineReport.total_donation}}</h5>
</div>
</div>
</div>
<div class="col-xs-4" ng-if="report.BestpayReport">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
@ -71,6 +83,30 @@
</div>
</div>
</div>
<div class="col-xs-4" ng-if="report.jdReport">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="JD" src="/static/images/jd_sign_lg.png">
</div>
<div class="info-box-content">
<h5>BD Total Commission: ${{report.jdReport.total_prize}}</h5>
<h5>BD Total Send: ${{report.jdReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.jdReport.total_donation}}</h5>
</div>
</div>
</div>
<div class="col-xs-4" ng-if="report.hfReport">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="HF" src="/static/images/hf_sign_lg.png">
</div>
<div class="info-box-content">
<h5>BD Total Commission: ${{report.hfReport.total_prize}}</h5>
<h5>BD Total Send: ${{report.hfReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.hfReport.total_donation}}</h5>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-header">BD Commission</div>

@ -85,8 +85,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
};
$scope.listOrgs(1);
}]);
app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org','stateMap', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org,stateMap) {
$scope.types = angular.copy(types);
$scope.states = stateMap.configs();
$scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
@ -191,8 +192,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
})
}
}]);
app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org','stateMap', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org,stateMap) {
$scope.types = angular.copy(types);
$scope.states = stateMap.configs();
$scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
@ -289,9 +291,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
})
}*/
}]);
app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', function ($scope, $http, $state, Upload, commonDialog) {
app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog','stateMap', function ($scope, $http, $state, Upload, commonDialog,stateMap) {
$scope.types = angular.copy(types);
$scope.commission_types = angular.copy(commission_types);
$scope.states = stateMap.configs();
$scope.uploadLogo = function (file) {
if (file == null) {
return;

@ -32,6 +32,17 @@
</p>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.state.$invalid && org_form.state.$dirty}">
<label class="control-label col-sm-2" for="org_state_input">State *</label>
<div class="col-sm-8">
<select class="form-control" name="state" required ng-model="org.state"
id="org_state_input"
ng-options="state.value as state.label for state in states">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.location.$invalid && org_form.location.$dirty}">
<label class="control-label col-sm-2" for="org_location_input">Location *</label>

@ -44,6 +44,16 @@
</p>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.state.$invalid && org_form.state.$dirty}">
<label class="control-label col-sm-2" for="org_state_input">State *</label>
<div class="col-sm-8">
<select class="form-control" name="state" required ng-model="org.state"
id="org_state_input"
ng-options="state.value as state.label for state in states">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.location.$invalid && org_form.location.$dirty}">
<label class="control-label col-sm-2" for="org_location_input">Location *</label>
<div class="col-sm-8">

@ -181,6 +181,16 @@
</p>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.state.$invalid && org_form.state.$dirty}">
<label class="control-label col-sm-2" for="org_state_input">State *</label>
<div class="col-sm-8">
<select class="form-control" name="state" required ng-model="org.state"
id="org_state_input"
ng-options="state.value as state.label for state in states">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.location.$invalid && org_form.location.$dirty}">
<label class="control-label col-sm-2" for="org_location_input">Location *</label>
<div class="col-sm-8">

@ -539,9 +539,6 @@ define(['angular', 'uiRouter'], function (angular) {
};
}]);
app.controller('partnerModuleNewCtrl', ['$scope', '$http', 'module','moduleall','commonDialog', function ($scope, $http, module,moduleall,commonDialog) {
$scope.module = angular.copy(module);
$scope.nameEditable = !module.module_name;
$scope.module.initialize = true;

@ -27,9 +27,13 @@
<i class="fa fa-user-secret"></i>
Administrator
</a>
<a class="btn btn-app" role="button" ng-click="authorizeRole('2')">
<i class="fa fa-user"></i>
Manager
</a>
<a class="btn btn-app" role="button" ng-click="authorizeRole('3')">
<i class="fa fa-eye"></i>
Compliance
<i class="fa fa-tripadvisor"></i>
Cashier
</a>
</div>
</div>

@ -9,19 +9,11 @@
<input ng-if="nameEditable" class="form-control" ng-model="module.module_name" placeholder="Module Name">
<p class="form-control-static" ng-bind="module.module_name" ng-if="!nameEditable"></p>
</div>
<div class="form-group">
<label class="control-label" for="jsModule">Js Module</label>
<input class="form-control" id="jsModule" ng-model="module.js_module">
</div>
<div class="form-group">
<label class="control-label" for="jsPath">Js Path</label>
<input class="form-control" id="jsPath" ng-model="module.js_path">
</div>
<div class="form-group">
<label class="control-label" for="remark">Remark</label>
<input class="form-control" id="remark" ng-model="module.remark">
</div>
<div class="form-group" ng-if="nameEditable">
<div class="form-group">
<label class="control-label">是否开放</label>
<input class="control-in" type="checkbox" ng-model="module.initialize" bs-switch
switch-change="init()">

@ -160,6 +160,8 @@ angular.module('applyPartnerApp', ['ngMessages']).controller('applyPartnerCtrl',
}, function (resp) {
if(resp.data.status+0 ==500) {
$interval.cancel($scope.phone_code_timer);
$scope.description="Send Code";
$scope.canClick=false;
}
$scope.resError = resp.data.message;

@ -211,7 +211,7 @@
<p ng-if="trade.trans_type=='clearing'">
-
</p>
<p ng-if="trade.trans_type !='clearing'">
<p ng-if="trade.trans_type !='clearing' && trade.channel!='hf'">
{{trade.exchange_rate}}
</p>
</td>

@ -905,7 +905,7 @@ define(['angular', 'decimal', 'uiRouter', 'ngBootSwitch', 'ngFileUpload'], funct
};
$scope.listOrders(1);
$scope.orderDetail = function (order) {
orderService.managerOrderDetail(order)
orderService.clientOrderDetail(order)
};
$scope.refundOrder = function (order) {
refunder.refunded(order.order_id)

@ -194,7 +194,9 @@
</td>
<td ng-bind="trade.display_amount|currency:trade.currency"></td>
<td ng-bind="trade.clearing_amount|currency:'AUD '"></td>
<td ng-bind="trade.exchange_rate"></td>
<td>
<span ng-if="trade.channel!='hf'" ng-bind="trade.exchange_rate"></span>
</td>
<td ng-bind="trade.status|tradeStatus"></td>
<td ng-bind="trade.create_time"></td>
<td ng-bind="trade.gateway|tradeGateway"></td>

@ -98,7 +98,7 @@
</table>
</div>
</div>
<div class="form-group" ng-if="order.status>=5">
<div class="form-group" ng-if="order.status>=5 && order.channel!='hf'">
<label class="control-label col-xs-3">Exchange Rate</label>
<div class="col-xs-9">
<p class="form-control-static" ng-bind="order.exchange_rate"></p>

@ -332,7 +332,9 @@
<td ng-bind="trade.display_amount|currency:trade.currency"></td>
<td ng-bind="trade.clearing_amount|currency:'AUD '"></td>
<td ng-bind="trade.settle_amount|currency:'AUD '"></td>
<td ng-bind="trade.exchange_rate"></td>
<td>
<span ng-if="trade.channel!='hf'" ng-bind="trade.exchange_rate"></span>
</td>
<td ng-bind="trade.status|tradeStatus"></td>
<td ng-bind="trade.create_time"></td>
<td ng-bind="trade.gateway|tradeGateway"></td>

@ -360,7 +360,9 @@
</td>
<td ng-bind="trade.display_amount|currency:trade.currency"></td>
<td ng-bind="trade.clearing_amount|currency:'AUD'"></td>
<td ng-bind="trade.exchange_rate"></td>
<td>
<span ng-if="trade.channel!='hf'" ng-bind="trade.exchange_rate"></span>
</td>
<td ng-bind="trade.status|tradeStatus"></td>
<td ng-bind="trade.create_time"></td>
<td ng-bind="trade.gateway|tradeGateway"></td>

@ -125,7 +125,9 @@
ng-click="showRefundLog(trade.order_id)">(-{{trade.refund_fee}})</a>
</td>
<td ng-bind="trade.clearing_amount|currency:'AUD '"></td>
<td ng-bind="trade.exchange_rate"></td>
<td>
<span ng-if="trade.channel!='hf'" ng-bind="trade.exchange_rate"></span>
</td>
<td ng-bind="trade.status|tradeStatus"></td>
<td ng-bind="trade.create_time"></td>
<td ng-bind="trade.gateway|tradeGateway"></td>

@ -23,6 +23,7 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMethod;
@ -31,13 +32,18 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@ -73,49 +79,198 @@ public class CustomerImpressionImplTest {
@Resource
private WeekReporter weekReporter;
// @Test
// public void redisQueue() {
// BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
// JSONObject order = orderMapper.find("00009201711300930013961422");
// for (int i = 0; i < 10000; i++) {
// ops.rightPush(order.toJSONString());
//
// }
// }
// @Test
// public void excel() {
// try {
// XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
// XSSFSheet sheet = workbook.getSheetAt(0);
// Iterator<Row> rowIterator = sheet.rowIterator();
// Row row = null;
// Cell cell = null;
// while (rowIterator.hasNext()) {
// row = rowIterator.next();
// cell = row.getCell(3);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
//
// JSONObject client = clientMapper.findClientByMoniker(cell.getStringCellValue().trim());
// if(client==null){
// System.out.println();
// continue;
// }
// JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
// if(org==null){
// continue;
// }
//
// row.createCell(5).setCellValue(org.getString("name"));
// }
//
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
// workbook.write(out);
// workbook.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
@Test
public void redisQueue() {
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
JSONObject order = orderMapper.find("00009201711300930013961422");
for (int i = 0; i < 10000; i++) {
ops.rightPush(order.toJSONString());
}
}
@Test
public void excel1() {
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
Map<String, Map<String, String>> result = new HashMap<>();
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String amount = cell.getStringCellValue().trim();
cell = row.getCell(1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String dateStr = cell.getStringCellValue();
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String clientId = cell.getStringCellValue();
if (result.containsKey(clientId)) {
result.get(clientId).put(dateStr, amount);
} else {
Map<String, String> ele = new HashMap<>();
ele.put(dateStr, amount);
result.put(clientId, ele);
}
}
Set<String> clients = new HashSet<>();
result.entrySet().parallelStream().forEach(p -> {
p.getValue().entrySet().parallelStream().forEach(o -> {
BigDecimal insAvg = BigDecimal.valueOf(Double.valueOf(o.getValue()));
BigDecimal pastTotal = BigDecimal.ZERO;
for (int i = 1; i < 4; i++) {
if (i == 1) {
pastTotal = BigDecimal.ZERO;
}
try {
Date tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),(-i+1));
String pastKey = String.valueOf(tmp.getYear()+1900)+ String.valueOf(tmp.getMonth());
if (p.getValue().containsKey(String.valueOf(pastKey))) {
BigDecimal pastAvgtmp = BigDecimal.valueOf(Double.parseDouble(p.getValue().get(String.valueOf(pastKey))));
pastTotal = pastTotal.add(pastAvgtmp);
} else {
i = 10;
}
if (i == 3) {
try {
BigDecimal pastAvg = pastTotal.divide(BigDecimal.valueOf(3L),5,BigDecimal.ROUND_HALF_DOWN);
if (pastAvg.compareTo(BigDecimal.ZERO) > 0) {
if (insAvg.divide(pastAvg,5,BigDecimal.ROUND_HALF_DOWN).intValue()>3) {
clients.add(p.getKey());
}
}
} catch (Exception ignore) {
}
}
} catch (ParseException e) {
}
}
});
});
clients.forEach(p->{
System.out.println(p);
});
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void excel2() {
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/qwe.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
Map<String, LinkedHashMap<String, String>> result = new HashMap<>();
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String orders = cell.getStringCellValue().trim();
cell = row.getCell(1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String dateStr = cell.getStringCellValue();
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String clientId = cell.getStringCellValue();
if (result.containsKey(clientId)) {
result.get(clientId).put(dateStr, orders);
} else {
LinkedHashMap<String, String> ele = new LinkedHashMap<>();
ele.put(dateStr, orders);
result.put(clientId, ele);
}
}
Set<String> clients = new HashSet<>();
for (Map.Entry<String, LinkedHashMap<String, String>> p : result.entrySet()) {
int count = 1;
for (Map.Entry<String, String> o : p.getValue().entrySet()) {
count+=1;
for (int i = 1; i < 4; i++) {
if(p.getValue().size()<4 && count==p.getValue().size()){
try {
if(DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),3).compareTo(new Date())<0){
clients.add(p.getKey());
}
} catch (ParseException e) {
}
}
Date tmp = null;
try {
tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(),"YYYYMM"),i);
String pastKey = String.valueOf(tmp.getYear()+1900)+ String.valueOf(tmp.getMonth());
if (p.getValue().containsKey(String.valueOf(pastKey))) {
i = 10;
}else {
if(i==3 && (Integer.valueOf(o.getValue())>99)){
clients.add(p.getKey());
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
}
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
// workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void sendSimpleMessage() throws Exception {
@ -359,16 +514,16 @@ public class CustomerImpressionImplTest {
public String recursionIndustry(JSONArray jsonArray, String mccCode) {
String result = "";
for (Object o : jsonArray) {
if(StringUtils.isNotEmpty(result)){
if (StringUtils.isNotEmpty(result)) {
break;
}
JSONObject tmp = (JSONObject) o;
if (tmp.getString("mccCode").equals(mccCode)) {
result = tmp.getString("label");
}else {
if(tmp.getJSONArray("children")!=null){
} else {
if (tmp.getJSONArray("children") != null) {
result = recursionIndustry(tmp.getJSONArray("children"), mccCode);
}else {
} else {
result = "";
}
}

Loading…
Cancel
Save