diff --git a/src/db/modify.sql b/src/db/modify.sql index 2b04a74c7..0e4cc4745 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -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)'; \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 90f12b218..592c8cedd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -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); diff --git a/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java index 95c222236..1c13bf35a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/application/core/impls/SimpleClientApplyServiceImpl.java @@ -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()); + @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")); diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java index c52dac881..99217ffa0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java @@ -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 trades = transactionMapper.listTransactionsForBDPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, channel); List clientsWithBDAway = clientBDMapper.clientsWithBDAway(); List 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 report = calculator.getReport(); + List 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 details = (List) log.get("details"); for (JSONObject detail : details) { diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java index 49e4365b6..049a5bedb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java @@ -11,5 +11,5 @@ public interface BDPrizeCalculator { void calculate(); - List getReport(); + List getReport(int year,int month); } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java index 7107827b1..d2e234522 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java @@ -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 tradeLogs; private final Date month; private ClientBDMapper clientBDMapper; @@ -27,6 +31,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator { private Map bdMap = new HashMap<>(); private Map>> rateConfigMap = new HashMap<>(); private Map bdTotalMap = new HashMap<>(); + private TransactionMapper transactionMapper; public BDPrizeCalculatorDefaultImpl(List 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> rates = rateConfigMap.get(level); - if (rates == null) { - rates = new HashMap<>(); - rateConfigMap.put(level, rates); + Map> levelRates = rateConfigMap.get(level); + if (levelRates == null) { + levelRates = new HashMap<>(); + rateConfigMap.put(level, levelRates); } - List rate = rates.get(kpiRange); + List 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 getReport() { + public List getReport(int year,int month1) { List report = new ArrayList<>(); for (Map.Entry> 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 details = new ArrayList<>(); - for (Map.Entry 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 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> rates = rateConfigMap.get(bdLevel); - List rate = rates.get(kpiRange); + Map> levelRates = rateConfigMap.get(bdLevel); + List 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"); diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java index 8a753f4e4..39009ee7d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/EncourageMoneyController.java @@ -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); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/ManualService.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/ManualService.java new file mode 100644 index 000000000..cc083f972 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/ManualService.java @@ -0,0 +1,9 @@ +package au.com.royalpay.payment.manage.dev.core; + +/** + * @author kira + * @date 2018/8/2 + */ +public interface ManualService { + void clientPostpone(); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java new file mode 100644 index 000000000..6218b5be9 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/ManualServiceimpl.java @@ -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 expiryClient = clientRateMapper.getAllExpiry(now); + + if (CollectionUtils.isEmpty(expiryClient)) { + return; + } + Map 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 adminAccounts = clientAccountMapper.listAdminAccounts(client_id); + List 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"); + + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/ManualController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/ManualController.java new file mode 100644 index 000000000..32892a63f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/ManualController.java @@ -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(); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/PartnerModuleInfo.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/PartnerModuleInfo.java index ff0433fe4..99dd8a24f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/PartnerModuleInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/beans/PartnerModuleInfo.java @@ -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()); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionPartnerManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionPartnerManagerImpl.java index a70c7997d..6205aa9f2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionPartnerManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/sysconfig/core/impls/PermissionPartnerManagerImpl.java @@ -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); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index be48b0efc..38eb75087 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -93,6 +93,8 @@ public interface TransactionMapper { List 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); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/PermissionPartnerModuleMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/PermissionPartnerModuleMapper.java index c3080f90c..364c524d7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/PermissionPartnerModuleMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/PermissionPartnerModuleMapper.java @@ -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; diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java index e67086828..94a7e4227 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientApplyImpl.java @@ -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")); 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 36683e2a7..d7d1bf3eb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,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 log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); + List 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 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 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 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 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 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 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 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 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 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 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 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 exceptClientIds) { + public JSONObject getByEmail(String email, int page, int limit, List 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); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java index 9a14767e5..b6e108502 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java @@ -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); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java index baa3e543e..a6ffe91a7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java @@ -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; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/permission/manager/ManagerUserInterceptor.java b/src/main/java/au/com/royalpay/payment/manage/permission/manager/ManagerUserInterceptor.java index 124ffe67c..967ef6324 100644 --- a/src/main/java/au/com/royalpay/payment/manage/permission/manager/ManagerUserInterceptor.java +++ b/src/main/java/au/com/royalpay/payment/manage/permission/manager/ManagerUserInterceptor.java @@ -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); } diff --git a/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSender.java b/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSender.java new file mode 100644 index 000000000..8373b5a63 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/support/sms/SmsSender.java @@ -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; + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java index 34f765665..36365eb9e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java @@ -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"); diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml index fc20ac668..585bc9238 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml @@ -331,7 +331,7 @@ ) and s.date >= #{begin} - and s.date < #{end} + and s.date <= #{end} and c.org_id=#{org_id} and c.org_id in #{org_id} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index c6911c549..4b4b0063e 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -502,23 +502,32 @@ ORDER BY trade_date ASC, o.client_id ASC + + + + +
+ +
+ +
+
+
+ +
+ +
+
+ +
用户关单率检测 检测用户当日订单
diff --git a/src/main/ui/static/analysis/trans-analysis-monthly.js b/src/main/ui/static/analysis/trans-analysis-monthly.js index a53eb2a79..c1bccba7c 100644 --- a/src/main/ui/static/analysis/trans-analysis-monthly.js +++ b/src/main/ui/static/analysis/trans-analysis-monthly.js @@ -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: { diff --git a/src/main/ui/static/boot/indexMainApp.js b/src/main/ui/static/boot/indexMainApp.js index c214a29bd..e51254417 100644 --- a/src/main/ui/static/boot/indexMainApp.js +++ b/src/main/ui/static/boot/indexMainApp.js @@ -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', diff --git a/src/main/ui/static/commons/templates/order_detail.html b/src/main/ui/static/commons/templates/order_detail.html index e51a8e8d2..748662a23 100644 --- a/src/main/ui/static/commons/templates/order_detail.html +++ b/src/main/ui/static/commons/templates/order_detail.html @@ -120,7 +120,7 @@

-
+

diff --git a/src/main/ui/static/config/bdprize/templates/bd_prize_detail.html b/src/main/ui/static/config/bdprize/templates/bd_prize_detail.html index 6b91a8b91..05fd32c87 100644 --- a/src/main/ui/static/config/bdprize/templates/bd_prize_detail.html +++ b/src/main/ui/static/config/bdprize/templates/bd_prize_detail.html @@ -80,6 +80,19 @@
+
+
+
+ +
+
+
Transaction: ${{detail.AlipayOnlineDetail.total_amount}}
+
Commission: ${{detail.AlipayOnlineDetail.total_prize}}
+
Send: ${{detail.AlipayOnlineDetail.send_prize}}
+
Fund: ${{detail.AlipayOnlineDetail.total_donation}}
+
+
+
@@ -93,6 +106,32 @@
+
+
+
+ +
+
+
Transaction: ${{detail.jdDetail.total_amount}}
+
Commission: ${{detail.jdDetail.total_prize}}
+
Send: ${{detail.jdDetail.send_prize}}
+
Fund: ${{detail.jdDetail.total_donation}}
+
+
+
+
+
+
+ +
+
+
Transaction: ${{detail.hfDetail.total_amount}}
+
Commission: ${{detail.hfDetail.total_prize}}
+
Send: ${{detail.hfDetail.send_prize}}
+
Fund: ${{detail.hfDetail.total_donation}}
+
+
+
Details(Red Client Moniker means received from BD User who left company.)
@@ -131,7 +170,10 @@ + + + diff --git a/src/main/ui/static/config/bdprize/templates/bd_prize_month_report.html b/src/main/ui/static/config/bdprize/templates/bd_prize_month_report.html index c8ccb0cef..1ab3492ee 100644 --- a/src/main/ui/static/config/bdprize/templates/bd_prize_month_report.html +++ b/src/main/ui/static/config/bdprize/templates/bd_prize_month_report.html @@ -59,6 +59,18 @@
+
+
+
+ +
+
+
BD Total Commission: ${{report.AlipayOnlineReport.total_prize}}
+
BD Total Send: ${{report.AlipayOnlineReport.total_send_prize}}
+
BD Total Fund: ${{report.AlipayOnlineReport.total_donation}}
+
+
+
@@ -71,6 +83,30 @@
+
+
+
+ +
+
+
BD Total Commission: ${{report.jdReport.total_prize}}
+
BD Total Send: ${{report.jdReport.total_send_prize}}
+
BD Total Fund: ${{report.jdReport.total_donation}}
+
+
+
+
+
+
+ +
+
+
BD Total Commission: ${{report.hfReport.total_prize}}
+
BD Total Send: ${{report.hfReport.total_send_prize}}
+
BD Total Fund: ${{report.hfReport.total_donation}}
+
+
+
BD Commission
diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js index 39fdc0ff0..1fafc8cc9 100644 --- a/src/main/ui/static/config/organizations/organizations.js +++ b/src/main/ui/static/config/organizations/organizations.js @@ -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; diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html index e42e41e9d..8872a29f7 100644 --- a/src/main/ui/static/config/organizations/templates/new_org.html +++ b/src/main/ui/static/config/organizations/templates/new_org.html @@ -32,6 +32,17 @@

+
+ +
+ +
+
diff --git a/src/main/ui/static/config/organizations/templates/org_detail.html b/src/main/ui/static/config/organizations/templates/org_detail.html index 66f4c64f8..118952eb4 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -44,6 +44,16 @@

+
+ +
+ +
+
diff --git a/src/main/ui/static/config/organizations/templates/org_detail_parent.html b/src/main/ui/static/config/organizations/templates/org_detail_parent.html index f77d47cb7..464290749 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail_parent.html +++ b/src/main/ui/static/config/organizations/templates/org_detail_parent.html @@ -181,6 +181,16 @@

+
+ +
+ +
+
diff --git a/src/main/ui/static/config/sysconfigs/sysconfigs.js b/src/main/ui/static/config/sysconfigs/sysconfigs.js index a905017ce..bde46911e 100644 --- a/src/main/ui/static/config/sysconfigs/sysconfigs.js +++ b/src/main/ui/static/config/sysconfigs/sysconfigs.js @@ -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; diff --git a/src/main/ui/static/config/sysconfigs/templates/permissionPartner_config.html b/src/main/ui/static/config/sysconfigs/templates/permissionPartner_config.html index f6006f936..9df5e6d9c 100644 --- a/src/main/ui/static/config/sysconfigs/templates/permissionPartner_config.html +++ b/src/main/ui/static/config/sysconfigs/templates/permissionPartner_config.html @@ -27,9 +27,13 @@ Administrator + + + Manager + - - Compliance + + Cashier
diff --git a/src/main/ui/static/config/sysconfigs/templates/permissionPartner_module_dialog.html b/src/main/ui/static/config/sysconfigs/templates/permissionPartner_module_dialog.html index 892cd3ca7..c37279392 100644 --- a/src/main/ui/static/config/sysconfigs/templates/permissionPartner_module_dialog.html +++ b/src/main/ui/static/config/sysconfigs/templates/permissionPartner_module_dialog.html @@ -9,19 +9,11 @@

-
- - -
-
- - -
-
+
diff --git a/src/main/ui/static/merchantapplication/merchant_application.js b/src/main/ui/static/merchantapplication/merchant_application.js index 5987e3fbc..4aac3f34b 100644 --- a/src/main/ui/static/merchantapplication/merchant_application.js +++ b/src/main/ui/static/merchantapplication/merchant_application.js @@ -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; diff --git a/src/main/ui/static/payment/invoice/templates/invoice.html b/src/main/ui/static/payment/invoice/templates/invoice.html index 113dd5bc0..cf06b87f7 100644 --- a/src/main/ui/static/payment/invoice/templates/invoice.html +++ b/src/main/ui/static/payment/invoice/templates/invoice.html @@ -211,7 +211,7 @@

-

-

+

{{trade.exchange_rate}}

diff --git a/src/main/ui/static/payment/partner/partner.js b/src/main/ui/static/payment/partner/partner.js index ef95850c4..989273068 100644 --- a/src/main/ui/static/payment/partner/partner.js +++ b/src/main/ui/static/payment/partner/partner.js @@ -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) diff --git a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html index 0d5c69752..0055cf480 100644 --- a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html +++ b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html @@ -194,7 +194,9 @@ - + + + diff --git a/src/main/ui/static/payment/tradelog/templates/partner_trade_detail_edit.html b/src/main/ui/static/payment/tradelog/templates/partner_trade_detail_edit.html index 2eb6e0ff9..978617150 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_trade_detail_edit.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_trade_detail_edit.html @@ -98,7 +98,7 @@
-
+

diff --git a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html index 50b3dc590..e093dd66e 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html @@ -332,7 +332,9 @@ - + + + diff --git a/src/main/ui/static/payment/tradelog/templates/trade_logs.html b/src/main/ui/static/payment/tradelog/templates/trade_logs.html index f04435a1e..7dc4e3a21 100644 --- a/src/main/ui/static/payment/tradelog/templates/trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/trade_logs.html @@ -360,7 +360,9 @@ - + + + diff --git a/src/main/ui/static/payment/vipcustomer/templates/vipcustomer_detail.html b/src/main/ui/static/payment/vipcustomer/templates/vipcustomer_detail.html index a030da0ff..8b0e25e48 100644 --- a/src/main/ui/static/payment/vipcustomer/templates/vipcustomer_detail.html +++ b/src/main/ui/static/payment/vipcustomer/templates/vipcustomer_detail.html @@ -125,7 +125,9 @@ ng-click="showRefundLog(trade.order_id)">(-{{trade.refund_fee}}) - + + + diff --git a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java index e61eae7ae..051952185 100644 --- a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java +++ b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java @@ -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 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 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 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 rowIterator = sheet.rowIterator(); + Row row = null; + Cell cell = null; + Map> 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 ele = new HashMap<>(); + ele.put(dateStr, amount); + result.put(clientId, ele); + } + } + Set 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 rowIterator = sheet.rowIterator(); + Row row = null; + Cell cell = null; + Map> 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 ele = new LinkedHashMap<>(); + ele.put(dateStr, orders); + result.put(clientId, ele); + } + } + Set clients = new HashSet<>(); + + + for (Map.Entry> p : result.entrySet()) { + int count = 1; + for (Map.Entry 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 = ""; } }