@ -15,6 +15,7 @@ import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService ;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService ;
import au.com.royalpay.payment.manage.support.sms.SmsSender ;
import au.com.royalpay.payment.manage.support.sms.SmsSender ;
import au.com.royalpay.payment.manage.system.core.MailGunService ;
import au.com.royalpay.payment.manage.system.core.MailGunService ;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient ;
import au.com.royalpay.payment.tools.env.PlatformEnvironment ;
import au.com.royalpay.payment.tools.env.PlatformEnvironment ;
import au.com.royalpay.payment.tools.env.SysConfigManager ;
import au.com.royalpay.payment.tools.env.SysConfigManager ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
@ -24,21 +25,32 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.locale.LocaleSupport ;
import au.com.royalpay.payment.tools.locale.LocaleSupport ;
import au.com.royalpay.payment.tools.utils.PasswordUtils ;
import au.com.royalpay.payment.tools.utils.PasswordUtils ;
import au.com.royalpay.payment.tools.utils.PdfUtils ;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONObject ;
import com.alibaba.fastjson.JSONObject ;
import com.alibaba.fastjson.parser.Feature ;
import org.apache.commons.codec.binary.Base64 ;
import org.apache.commons.lang3.RandomStringUtils ;
import org.apache.commons.lang3.RandomStringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.time.DateFormatUtils ;
import org.apache.commons.lang3.time.DateFormatUtils ;
import org.apache.commons.lang3.time.DateUtils ;
import org.apache.commons.lang3.time.DateUtils ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.data.redis.core.StringRedisTemplate ;
import org.springframework.data.redis.core.StringRedisTemplate ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.util.Assert ;
import org.springframework.util.Assert ;
import org.springframework.web.bind.annotation.RequestMethod ;
import org.springframework.web.bind.annotation.RequestMethod ;
import org.springframework.web.multipart.MultipartFile ;
import org.thymeleaf.context.Context ;
import org.thymeleaf.context.Context ;
import java.io.IOException ;
import java.awt.image.BufferedImage ;
import java.io.* ;
import java.math.BigDecimal ;
import java.net.URISyntaxException ;
import java.net.URISyntaxException ;
import java.net.URLDecoder ;
import java.util.* ;
import java.util.* ;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.ThreadPoolExecutor ;
@ -47,6 +59,7 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct ;
import javax.annotation.PostConstruct ;
import javax.annotation.Resource ;
import javax.annotation.Resource ;
import javax.imageio.ImageIO ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletRequest ;
import cn.yixblog.platform.http.HttpRequestGenerator ;
import cn.yixblog.platform.http.HttpRequestGenerator ;
@ -65,20 +78,29 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@Resource
@Resource
private MailService mailService ;
private MailService mailService ;
@Resource
@Resource
private AttachmentClient attachmentClient ;
@Resource
private PermissionPartnerManager permissionPartnerManager ;
private PermissionPartnerManager permissionPartnerManager ;
@Resource
@Resource
private SpringTemplateEngine thymeleaf ;
private SpringTemplateEngine thymeleaf ;
@Resource
@Resource
private SysClientLegalPersonMapper sysClientLegalPersonMapper ;
@Resource
private ClientManager clientManager ;
private ClientManager clientManager ;
@Resource
@Resource
private SignInAccountService signInAccountService ;
private SignInAccountService signInAccountService ;
@Resource
@Resource
private SimpleClientApplyService simpleClientApplyService ;
private Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ;
@Resource
private ClientAccountMapper clientAccountMapper ;
private ClientAccountMapper clientAccountMapper ;
@Resource
@Resource
private SysClientPreMapperMapper sysClientPreMapperMapper ;
private SysClientPreMapperMapper sysClientPreMapperMapper ;
@Resource
@Resource
private ClientBankAccountMapper clientBankAccountMapper ;
private ClientBankAccountMapper clientBankAccountMapper ;
@Resource
@Resource
private ClientFilesMapper clientFilesMapper ;
@Resource
private ClientMapper clientMapper ;
private ClientMapper clientMapper ;
@Resource
@Resource
private ClientRateMapper clientRateMapper ;
private ClientRateMapper clientRateMapper ;
@ -95,6 +117,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
private ClientBDMapper clientBDMapper ;
private ClientBDMapper clientBDMapper ;
private ThreadPoolExecutor pool = new ThreadPoolExecutor ( 1 , 10 , 5 , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ;
private ThreadPoolExecutor pool = new ThreadPoolExecutor ( 1 , 10 , 5 , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ;
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/09/06/1567741055646_qeWC7kwqEwsJjRHisJSyAjqnB9nnnh.pdf" ;
@Resource
@Resource
private SmsSender smsSender ;
private SmsSender smsSender ;
@Resource
@Resource
@ -104,6 +127,9 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT" ;
private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT" ;
private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS" ;
private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS" ;
private final String VERIFY_MAIL_PREFIX = "VERIFY_MAIL" ;
private final String VERIFY_MAIL_PREFIX = "VERIFY_MAIL" ;
private final String LOGIN_CLIENT_PREFIX = "LGOIN_CLIENT" ;
private final String LOGIN_CLIENT_PROCESS_PREFIX = "LOGIN_CLIENT_PROCESS" ;
private static final String CLIENT_AGREE_FILE = "client_agree_file" ;
private final List < String > tags = new ArrayList < > ( ) ;
private final List < String > tags = new ArrayList < > ( ) ;
@PostConstruct
@PostConstruct
@ -158,6 +184,19 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
return registerClientCode ;
return registerClientCode ;
}
}
@Override
public void sendOpenSms ( String phoneNumber , String nationCode ) {
ArrayList < String > param = new ArrayList < > ( ) ;
String phone_Number = phoneNumber . substring ( 0 , 3 ) + "****" + phoneNumber . substring ( 7 , phoneNumber . length ( ) ) ;
param . add ( phone_Number ) ;
try {
smsSender . getSender ( ) . sendWithParam ( nationCode . trim ( ) , phoneNumber , 462770 , param , "RoyalPay" , "" , "" ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
throw new ServerErrorException ( "Phone number is wrong Please try again" ) ;
}
}
@Override
@Override
public void sendVerifyEmail ( String address , int client_id , String username ) {
public void sendVerifyEmail ( String address , int client_id , String username ) {
JSONObject client = clientManager . getClientInfo ( client_id ) ;
JSONObject client = clientManager . getClientInfo ( client_id ) ;
@ -281,6 +320,68 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
}
}
}
}
@Override
public JSONObject getSourceAggregateFile ( String username , String clean_days ) {
JSONObject apply = sysClientPreMapperMapper . findByUserName ( username ) ;
String address = apply . getString ( "address" ) . trim ( ) ;
if ( address . contains ( "," ) ) {
apply . put ( "address" , address . substring ( 0 , address . lastIndexOf ( "," ) ) . trim ( ) ) ;
apply . put ( "address_sub" , address . substring ( address . lastIndexOf ( "," ) + 1 ) . trim ( ) ) ;
}
apply . put ( "acn_type" , "ABN: (" + apply . getString ( "abn" ) + ")" ) ;
apply . put ( "company_name_acn" , apply . getString ( "company_name" ) + " (ABN " + apply . getString ( "abn" ) + ")" ) ;
apply . put ( "clean" , "T+" + clean_days . trim ( ) ) ;
apply . put ( "clean_days" , clean_days ) ;
JSONObject sysConfig = sysConfigManager . getSysConfig ( ) ;
JSONObject test = JSONObject . parseObject ( sysConfig . getString ( "sys_apply_rates" ) ) ;
JSONObject rate = test . getJSONObject ( "t" + clean_days . trim ( ) ) ;
apply . put ( "wechat_rate" , rate . getString ( "Wechat" ) ) ;
apply . put ( "alipay_rate" , rate . getString ( "Alipay" ) ) ;
apply . put ( "alipay_online_rate" , rate . getString ( "AlipayOnline" ) ) ;
apply . put ( "cbbank_rate" , rate . getString ( "CB_Bankpay" ) ) ;
apply . put ( "bestpay_rate" , rate . getString ( "Bestpay" ) ) ;
apply . put ( "jd_rate" , rate . getString ( "JDpay" ) ) ;
JSONObject bankInfo = getBankInfo ( apply . getString ( "bsb_no" ) ) ;
apply . put ( "bank" , bankInfo . getString ( "bank" ) ) ;
apply . put ( "bsb_no" , apply . getString ( "bsb_no" ) ) ;
apply . put ( "account_no" , apply . getString ( "bank_no" ) ) ;
apply . put ( "account_name" , apply . getString ( "bank_name" ) ) ;
String start_date = DateFormatUtils . format ( new Date ( ) , "dd/MM/yyyy" ) ;
apply . put ( "start_date" , start_date ) ;
Date endDate = TimeZoneUtils . nextYearByCurrDay ( ) ;
String end_date = DateFormatUtils . format ( endDate , "dd/MM/yyyy" ) ;
apply . put ( "end_date" , end_date ) ;
apply . put ( "legal_person" , apply . getString ( "representative_person" ) ) ;
apply . put ( "legal_job_title" , apply . getString ( "representative_job_title" ) ) ;
apply . put ( "legal_phone" , apply . getString ( "representative_phone" ) ) ;
apply . put ( "legal_email" , apply . getString ( "representative_email" ) ) ;
return exportClientAggregateFile ( apply ) ;
}
private JSONObject exportClientAggregateFile ( JSONObject apply ) {
InputStream stream = null ;
JSONObject result = new JSONObject ( ) ;
try {
PdfUtils pdu = new PdfUtils ( ) ;
pdu . setTemplatePdfPath ( IMG_AGGREGATE_FILE ) ;
pdu . setPdfTemplate ( apply ) ;
File file = new File ( apply . getString ( "username" ) + "_agreement.pdf" ) ;
ByteArrayOutputStream bos = pdu . templetPdfBos ( file ) ;
stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileInfo = attachmentClient . uploadFile ( stream , apply . getString ( "username" ) + "_" + System . currentTimeMillis ( ) + "_agreement_source.pdf" , false ) ;
result . put ( "file_value" , fileInfo . getString ( "url" ) ) ;
} catch ( Exception e ) {
throw new BadRequestException ( "获取合同文件失败" ) ;
}
return result ;
}
@Override
@Override
@Transactional
@Transactional
public void saveOrUpdateApplyInfo ( JSONObject applyInfo , String username ) {
public void saveOrUpdateApplyInfo ( JSONObject applyInfo , String username ) {
@ -296,21 +397,193 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
applyInfo . put ( "update_time" , new Date ( ) ) ;
applyInfo . put ( "update_time" , new Date ( ) ) ;
sysClientPreMapperMapper . update ( applyInfo ) ;
sysClientPreMapperMapper . update ( applyInfo ) ;
if ( applyInfo . getBooleanValue ( "agree" ) ) {
if ( applyInfo . getBooleanValue ( "agree" ) ) {
applyerToClient ( username ) ;
applyerToClient ( username , null ) ;
}
}
}
@Override
public JSONObject getPayType ( ) {
String [ ] online_desc = { "pc网站|PC Web" , "手机端网站|Mobile Web" , "APP " , "微信内/支付宝内网站|Wechat/Alipay JSAPI" , "小程序|MiniProgram" } ;
String [ ] online_desc_value = { "101" , "102" , "103" , "104" , "105" } ;
String [ ] offline_desc = { "二维码立牌|QR Code" , "Royalpay POS" , "收银系统|POS" , "无人售货机|Vending machine" } ;
String [ ] offline_desc_value = { "201" , "202" , "203" , "204" } ;
String [ ] pos = { "ipos" , "pospal" , "Aus Post" , "Lotus" , "AoShangBao" , "Infinity" , "EasyCloud" , "AoMaiKe" , "其他|other" } ;
String [ ] pos_value = { "20301" , "20302" , "20303" , "20304" , "20305" , "20306" , "20307" , "20308" , "20399" } ;
JSONObject payType = new JSONObject ( ) ;
List < JSONObject > online = new ArrayList < > ( ) ;
List < JSONObject > offline = new ArrayList < > ( ) ;
List < JSONObject > sub = new ArrayList < > ( ) ;
for ( int i = 0 ; i < pos . length ; i + + ) {
JSONObject temp = new JSONObject ( ) ;
temp . put ( "label" , pos [ i ] ) ;
temp . put ( "value" , pos_value [ i ] ) ;
sub . add ( temp ) ;
}
for ( int i = 0 ; i < online_desc . length ; i + + ) {
JSONObject temp = new JSONObject ( ) ;
temp . put ( "label" , online_desc [ i ] ) ;
temp . put ( "value" , online_desc_value [ i ] ) ;
online . add ( temp ) ;
}
for ( int i = 0 ; i < offline_desc . length ; i + + ) {
JSONObject temp = new JSONObject ( ) ;
temp . put ( "label" , offline_desc [ i ] ) ;
temp . put ( "value" , offline_desc_value [ i ] ) ;
if ( "收银系统|POS" . equals ( offline_desc [ i ] ) ) {
temp . put ( "sub" , sub ) ;
}
offline . add ( temp ) ;
}
payType . put ( "online" , online ) ;
payType . put ( "offline" , offline ) ;
return payType ;
}
@Override
public List < JSONObject > getSysRate ( JSONObject sysConfig ) {
HashMap < String , JSONObject > map = JSON . parseObject ( sysConfig . getString ( "sys_apply_rates" ) , LinkedHashMap . class , Feature . OrderedField ) ;
List < JSONObject > rates = new ArrayList < > ( ) ;
JSONObject tName = new JSONObject ( ) ;
tName . put ( "t1" , "T+1" ) ;
tName . put ( "t2" , "T+2" ) ;
tName . put ( "t3" , "T+3" ) ;
for ( String strt : map . keySet ( ) ) {
JSONObject t = map . get ( strt ) ;
List < JSONObject > data = new ArrayList < > ( ) ;
for ( String str : t . keySet ( ) ) {
JSONObject rate = new JSONObject ( ) ;
rate . put ( "channel" , str ) ;
rate . put ( "rate" , t . get ( str ) ) ;
data . add ( rate ) ;
}
JSONObject temp = new JSONObject ( ) ;
temp . put ( "data" , data ) ;
temp . put ( "name" , tName . getString ( strt ) ) ;
rates . add ( temp ) ;
}
return rates ;
}
@Override
public List < JSONObject > getIndustryMap ( ) {
List < JSONObject > industryMap = new ArrayList < > ( ) ;
String [ ] industryLabel = { "鞋包服饰" , "机票行业" , "软件服务" , "旅游票务" , "国际租车" , "医疗服务(出国)" , "医疗服务(不出国)" , "留学教育(网络教育)" , "留学教育(一年及以下)" , "其它货物贸易行业" , "文具/办公用品" , "综合商城" , "酒店行业" , "教育行业" , "国际物流" , "数码电器" , "母婴" , "化妆品" , "食品" , "留学教育(一年以上)" , "其它服务行业" } ;
String [ ] industryValue = { "327" , "339" , "356" , "357" , "358" , "359" , "360" , "361" , "362" , "338" , "337" , "336" , "328" , "329" , "330" , "332" , "333" , "334" , "335" , "363" , "331" } ;
for ( int i = 0 ; i < industryLabel . length ; i + + ) {
JSONObject temp = new JSONObject ( ) ;
temp . put ( "label" , industryLabel [ i ] ) ;
temp . put ( "value" , industryValue [ i ] ) ;
industryMap . add ( temp ) ;
}
return industryMap ;
}
@Override
public JSONObject getPreApplyInfoForAggree ( String username , String clean_days ) {
JSONObject apply = sysClientPreMapperMapper . findByUserName ( username ) ;
String address = apply . getString ( "address" ) . trim ( ) ;
if ( address . contains ( "," ) ) {
apply . put ( "address" , address . substring ( 0 , address . lastIndexOf ( "," ) ) . trim ( ) ) ;
apply . put ( "address_sub" , address . substring ( address . lastIndexOf ( "," ) + 1 ) . trim ( ) ) ;
}
apply . put ( "acn_type" , "ABN: (" + apply . getString ( "abn" ) + ")" ) ;
apply . put ( "company_name_acn" , apply . getString ( "company_name" ) + " (ABN " + apply . getString ( "abn" ) + ")" ) ;
apply . put ( "clean" , "T+" + clean_days . trim ( ) ) ;
apply . put ( "clean_days" , clean_days ) ;
JSONObject sysConfig = sysConfigManager . getSysConfig ( ) ;
JSONObject test = JSONObject . parseObject ( sysConfig . getString ( "sys_apply_rates" ) ) ;
JSONObject rate = test . getJSONObject ( "t" + clean_days . trim ( ) ) ;
apply . put ( "wechat_rate" , rate . getString ( "Wechat" ) ) ;
apply . put ( "alipay_rate" , rate . getString ( "Alipay" ) ) ;
apply . put ( "alipay_online_rate" , rate . getString ( "AlipayOnline" ) ) ;
apply . put ( "cbbank_rate" , rate . getString ( "CB_Bankpay" ) ) ;
apply . put ( "bestpay_rate" , rate . getString ( "Bestpay" ) ) ;
apply . put ( "jd_rate" , rate . getString ( "JDpay" ) ) ;
JSONObject bankInfo = getBankInfo ( apply . getString ( "bsb_no" ) ) ;
apply . put ( "bank" , bankInfo . getString ( "bank" ) ) ;
apply . put ( "bsb_no" , apply . getString ( "bsb_no" ) ) ;
apply . put ( "account_no" , apply . getString ( "bank_no" ) ) ;
apply . put ( "account_name" , apply . getString ( "bank_name" ) ) ;
String start_date = DateFormatUtils . format ( new Date ( ) , "dd/MM/yyyy" ) ;
apply . put ( "start_date" , start_date ) ;
Date endDate = TimeZoneUtils . nextYearByCurrDay ( ) ;
String end_date = DateFormatUtils . format ( endDate , "dd/MM/yyyy" ) ;
apply . put ( "end_date" , end_date ) ;
apply . put ( "legal_person" , apply . getString ( "representative_person" ) ) ;
apply . put ( "legal_job_title" , apply . getString ( "representative_job_title" ) ) ;
apply . put ( "legal_phone" , apply . getString ( "representative_phone" ) ) ;
apply . put ( "legal_email" , apply . getString ( "representative_email" ) ) ;
return apply ;
}
@Override
public JSONObject getClientAggregateFile ( String username , MultipartFile file , String clean_days , JSONObject signInfo ) throws IOException {
JSONObject apply = getPreApplyInfoForAggree ( username , clean_days ) ;
apply . put ( "full_name" , URLDecoder . decode ( file . getOriginalFilename ( ) , "UTF-8" ) ) ;
BufferedImage img = ImageIO . read ( file . getInputStream ( ) ) ;
ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ;
ImageIO . write ( img , "png" , out ) ;
apply . put ( "img" , "data:image/png;base64," + Base64 . encodeBase64String ( out . toByteArray ( ) ) ) ;
return exportImgAggregateFile ( username , apply , signInfo ) ;
}
}
private JSONObject exportImgAggregateFile ( String username , JSONObject apply , JSONObject signInfo ) throws IOException {
InputStream stream = null ;
JSONObject contractInfo = new JSONObject ( ) ;
try {
PdfUtils pdu = new PdfUtils ( ) ;
pdu . setTemplatePdfPath ( IMG_AGGREGATE_FILE ) ;
pdu . setPdfTemplate ( apply ) ;
File file = new File ( username + "_agreement.pdf" ) ;
ByteArrayOutputStream bos = pdu . templetPdfBos ( file , "STSong-Light" , "UniGB-UCS2-H" ) ;
stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileInfo = attachmentClient . uploadFile ( stream , username + "_" + System . currentTimeMillis ( ) + "_agreement.pdf" , false ) ;
contractInfo . put ( "contract_url" , fileInfo . getString ( "url" ) ) ;
apply . put ( "contract_url" , contractInfo . getString ( "contract_url" ) ) ;
signInfo . put ( "contract_url" , contractInfo . getString ( "contract_url" ) ) ;
apply . put ( "agree" , true ) ;
apply . put ( "update_time" , new Date ( ) ) ;
sysClientPreMapperMapper . update ( apply ) ;
} catch ( Exception e ) {
logger . error ( "合同制作出现问题:" , e ) ;
throw new BadRequestException ( "合同制作出现问题:" + e . getMessage ( ) ) ;
} finally {
stream . close ( ) ;
}
}
applyerToClient ( apply . getString ( "username" ) , signInfo ) ;
return contractInfo ;
}
}
//todo
//todo
private void applyerToClient ( String username ) {
private void applyerToClient ( String username , JSONObject signInfo ) {
JSONObject sysConfig = sysConfigManager . getSysConfig ( ) ;
JSONObject sysConfig = sysConfigManager . getSysConfig ( ) ;
String arr [ ] = sysConfig . getString ( "temp_sub_mch_id" ) . split ( "," ) ;
String arr [ ] = sysConfig . getString ( "temp_sub_mch_id" ) . split ( "," ) ;
List < String > availableMerchants = WechatPayEnvironment . getEnv ( ) . getWechatMerchantConfigs ( ) . stream ( )
List < String > availableMerchants = WechatPayEnvironment . getEnv ( ) . getWechatMerchantConfigs ( ) . stream ( )
. filter ( mch - > StringUtils . equals ( mch . getMpId ( ) , "globalpay" ) )
. filter ( mch - > StringUtils . equals ( mch . getMpId ( ) , "globalpay" ) )
. map ( WeChatPayConfig . Merchant : : getMerchantId )
. map ( WeChatPayConfig . Merchant : : getMerchantId )
. collect ( Collectors . toList ( ) ) ;
. collect ( Collectors . toList ( ) ) ;
JSONObject subMerchant = pmtSubMerchantIdMapper . randomOne ( availableMerchants ) ;
JSONObject subMerchant = pmtSubMerchantIdMapper . randomOne ( availableMerchants ) ;
if ( subMerchant = = null ) {
if ( subMerchant = = null ) {
throw new BadRequestException ( "System is busy Please try again" ) ;
throw new BadRequestException ( "System is busy Please try again" ) ;
}
}
Date now = new Date ( ) ;
Date now = new Date ( ) ;
@ -329,9 +602,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
throw new ForbiddenException ( "The user name has been registered" ) ;
throw new ForbiddenException ( "The user name has been registered" ) ;
}
}
String clientMoniker = generateClientMoniker ( ) ;
String clientMoniker = generateClientMoniker ( ) ;
JSONObject sysClient = new JSONObject ( ) ;
JSONObject sysClient = new JSONObject ( ) ;
JSONObject followBd = managerMapper . findByLoginId ( "customerservice" ) ;
JSONObject followBd = managerMapper . findByLoginId ( "customerservice" ) ;
sysClient . put ( "bd_user" , followBd . getString ( "manager_id" ) ) ;
sysClient . put ( "bd_user" , followBd . getString ( "manager_id" ) ) ;
@ -344,9 +615,21 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysClient . put ( "state" , apply . getString ( "state" ) ) ;
sysClient . put ( "state" , apply . getString ( "state" ) ) ;
sysClient . put ( "postcode" , apply . getString ( "postcode" ) ) ;
sysClient . put ( "postcode" , apply . getString ( "postcode" ) ) ;
sysClient . put ( "royalpayindustry" , apply . getString ( "industry" ) ) ;
sysClient . put ( "royalpayindustry" , apply . getString ( "industry" ) ) ;
sysClient . put ( "alipayindustry" , apply . getString ( "alipayindustry" ) ) ;
sysClient . put ( "industry" , apply . getString ( "wechatindustry" ) ) ;
sysClient . put ( "enable_wechat" , 1 ) ;
if ( StringUtils . isBlank ( apply . getString ( "wechatindustry" ) ) ) {
sysClient . put ( "industry" , 331 ) ;
sysClient . put ( "enable_wechat" , 0 ) ;
}
sysClient . put ( "contact_person" , apply . getString ( "contact_person" ) ) ;
sysClient . put ( "contact_person" , apply . getString ( "contact_person" ) ) ;
sysClient . put ( "contact_job" , apply . getString ( "contact_job" ) ) ;
sysClient . put ( "logo_url" , apply . getString ( "logo_url" ) ) ;
sysClient . put ( "company_website" , apply . getString ( "company_website" ) ) ;
sysClient . put ( "company_photo" , apply . getString ( "company_photo" ) ) ;
sysClient . put ( "store_photo" , apply . getString ( "store_photo" ) ) ;
sysClient . put ( "contact_email" , apply . getString ( "contact_email" ) ) ;
sysClient . put ( "contact_email" , apply . getString ( "contact_email" ) ) ;
sysClient . put ( "contact_phone" , "+61" + apply . getString ( "contact_phone" ) ) ;
sysClient . put ( "contact_phone" , "+61" + apply . getString ( "contact_phone" ) ) ;
sysClient . put ( "company_phone" , apply . getString ( "company_phone" ) ) ;
sysClient . put ( "company_phone" , apply . getString ( "company_phone" ) ) ;
sysClient . put ( "client_moniker" , clientMoniker ) ;
sysClient . put ( "client_moniker" , clientMoniker ) ;
sysClient . put ( "create_time" , new Date ( ) ) ;
sysClient . put ( "create_time" , new Date ( ) ) ;
@ -356,7 +639,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysClient . put ( "approve_time" , new Date ( ) ) ;
sysClient . put ( "approve_time" , new Date ( ) ) ;
sysClient . put ( "creator" , 0 ) ;
sysClient . put ( "creator" , 0 ) ;
sysClient . put ( "business_name" , apply . getString ( "short_name" ) ) ;
sysClient . put ( "business_name" , apply . getString ( "short_name" ) ) ;
sysClient . put ( "industry" , 331 ) ;
/*sysClient.put("industry", 331);*/
sysClient . put ( "merchant_id" , subMerchant . getString ( "merchant_id" ) ) ;
sysClient . put ( "merchant_id" , subMerchant . getString ( "merchant_id" ) ) ;
sysClient . put ( "sub_merchant_id" , subMerchant . getString ( "sub_merchant_id" ) ) ;
sysClient . put ( "sub_merchant_id" , subMerchant . getString ( "sub_merchant_id" ) ) ;
sysClient . put ( "common_sub_merchant_id" , 1 ) ;
sysClient . put ( "common_sub_merchant_id" , 1 ) ;
@ -367,12 +650,24 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysClient . put ( "ali_sub_merchant_id" , clientMoniker ) ;
sysClient . put ( "ali_sub_merchant_id" , clientMoniker ) ;
clientMapper . save ( sysClient ) ;
clientMapper . save ( sysClient ) ;
JSONObject representativeInfo = new JSONObject ( ) ;
representativeInfo . put ( "client_id" , sysClient . getIntValue ( "client_id" ) ) ;
representativeInfo . put ( "representative_person" , apply . getString ( "representative_person" ) ) ;
representativeInfo . put ( "job_title" , apply . getString ( "representative_job_title" ) ) ;
representativeInfo . put ( "phone" , apply . getString ( "representative_phone" ) ) ;
representativeInfo . put ( "email" , apply . getString ( "representative_email" ) ) ;
representativeInfo . put ( "address" , apply . getString ( "registered_address" ) ) ;
representativeInfo . put ( "suburb" , apply . getString ( "registered_suburb" ) ) ;
representativeInfo . put ( "state" , apply . getString ( "registered_state" ) ) ;
representativeInfo . put ( "postcode" , apply . getString ( "registered_postcode" ) ) ;
sysClientLegalPersonMapper . save ( representativeInfo ) ;
JSONObject clientBd = new JSONObject ( ) ;
JSONObject clientBd = new JSONObject ( ) ;
clientBd . put ( "client_id" , sysClient . getIntValue ( "client_id" ) ) ;
clientBd . put ( "client_id" , sysClient . getIntValue ( "client_id" ) ) ;
clientBd . put ( "bd_id" , followBd . getString ( "manager_id" ) ) ;
clientBd . put ( "bd_id" , followBd . getString ( "manager_id" ) ) ;
clientBd . put ( "bd_name" , followBd . getString ( "display_name" ) ) ;
clientBd . put ( "bd_name" , followBd . getString ( "display_name" ) ) ;
clientBd . put ( "create_time" , new Date ( ) ) ;
clientBd . put ( "create_time" , new Date ( ) ) ;
clientBd . put ( "create_id" , "0" ) ;
clientBd . put ( "create_id" , "0" ) ;
clientBd . put ( "start_date" , new Date ( ) ) ;
clientBd . put ( "start_date" , new Date ( ) ) ;
clientBd . put ( "proportion" , 1 ) ;
clientBd . put ( "proportion" , 1 ) ;
clientBDMapper . saveBD ( clientBd ) ;
clientBDMapper . saveBD ( clientBd ) ;
@ -394,6 +689,22 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysAccount . put ( "nation_code" , "+61" ) ;
sysAccount . put ( "nation_code" , "+61" ) ;
clientAccountMapper . save ( sysAccount ) ;
clientAccountMapper . save ( sysAccount ) ;
if ( signInfo ! = null ) {
JSONObject fileJson = new JSONObject ( ) ;
fileJson . put ( "client_id" , sysClient . getString ( "client_id" ) ) ;
fileJson . put ( "last_update_date" , new Date ( ) ) ;
//fileJson.put("last_update_by", manager.getString("display_name"));
fileJson . put ( "file_name" , CLIENT_AGREE_FILE ) ;
fileJson . put ( "file_value" , signInfo . getString ( "contract_url" ) ) ;
fileJson . put ( "status" , 1 ) ;
fileJson . put ( "signature_time" , new Date ( ) ) ;
fileJson . put ( "signature_ip" , signInfo . getString ( "signature_ip" ) ) ;
fileJson . put ( "user_agent" , signInfo . getString ( "user_agent" ) ) ;
fileJson . put ( "signature_account_id" , sysAccount . getString ( "account_id" ) ) ;
fileJson . put ( "is_valid" , 1 ) ;
clientFilesMapper . save ( fileJson ) ;
}
JSONObject sysBank = new JSONObject ( ) ;
JSONObject sysBank = new JSONObject ( ) ;
sysBank . put ( "client_id" , clientId ) ;
sysBank . put ( "client_id" , clientId ) ;
sysBank . put ( "account_no" , apply . getString ( "bank_no" ) ) ;
sysBank . put ( "account_no" , apply . getString ( "bank_no" ) ) ;
@ -412,6 +723,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
JSONObject clientConfig = new JSONObject ( ) ;
JSONObject clientConfig = new JSONObject ( ) ;
clientConfig . put ( "client_id" , clientId ) ;
clientConfig . put ( "client_id" , clientId ) ;
clientConfig . put ( "skip_clearing" , 1 ) ;
clientConfig . put ( "skip_clearing" , 1 ) ;
clientConfig . put ( "enable_wechat" , 1 ) ;
clientConfig . put ( "client_moniker" , clientMoniker ) ;
clientConfig . put ( "client_moniker" , clientMoniker ) ;
clientConfig . put ( "clean_days" , apply . getIntValue ( "clean_days" ) ) ;
clientConfig . put ( "clean_days" , apply . getIntValue ( "clean_days" ) ) ;
clientConfig . put ( "common_sub_merchant_id" , 1 ) ;
clientConfig . put ( "common_sub_merchant_id" , 1 ) ;
@ -424,7 +736,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
apply . put ( "client_moniker" , clientMoniker ) ;
apply . put ( "client_moniker" , clientMoniker ) ;
sysClientPreMapperMapper . update ( apply ) ;
sysClientPreMapperMapper . update ( apply ) ;
permissionPartnerManager . permissionClientModuleSave ( clientId , clientMoniker ) ;
permissionPartnerManager . permissionClientModuleSave ( clientId , clientMoniker ) ;
JSONObject sysRate = new JSONObject ( ) ;
JSONObject sysRate = new JSONObject ( ) ;
sysRate . put ( "client_id" , clientId ) ;
sysRate . put ( "client_id" , clientId ) ;
@ -432,7 +744,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
sysRate . put ( "remark" , "自主申请" ) ;
sysRate . put ( "remark" , "自主申请" ) ;
sysRate . put ( "create_time" , new Date ( ) ) ;
sysRate . put ( "create_time" , new Date ( ) ) ;
sysRate . put ( "update_time" , new Date ( ) ) ;
sysRate . put ( "update_time" , new Date ( ) ) ;
sysRate . put ( "active_time" , DateFormatUtils . format ( new Date ( ) , "yyyy-MM-dd" ) ) ;
sysRate . put ( "active_time" , DateFormatUtils . format ( DateUtils . addDays ( new Date ( ) , - 1 ) , "yyyy-MM-dd" ) ) ;
sysRate . put ( "expiry_time" , DateFormatUtils . format ( DateUtils . addYears ( new Date ( ) , 1 ) , "yyyy-MM-dd" ) ) ;
sysRate . put ( "expiry_time" , DateFormatUtils . format ( DateUtils . addYears ( new Date ( ) , 1 ) , "yyyy-MM-dd" ) ) ;
JSONObject rateConfig = JSONObject . parseObject ( sysConfig . getString ( "sys_apply_rates" ) ) ;
JSONObject rateConfig = JSONObject . parseObject ( sysConfig . getString ( "sys_apply_rates" ) ) ;
@ -453,14 +765,26 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
configNewClientRate ( sysRate , clientId , "AlipayOnline" , "AlipayOnline" ) ;
configNewClientRate ( sysRate , clientId , "AlipayOnline" , "AlipayOnline" ) ;
configNewClientRate ( sysRate , clientId , "Bestpay" , "Bestpay" ) ;
configNewClientRate ( sysRate , clientId , "Bestpay" , "Bestpay" ) ;
configNewClientRate ( sysRate , clientId , "jd" , "JDpay" ) ;
configNewClientRate ( sysRate , clientId , "jd" , "JDpay" ) ;
configNewClientRate ( sysRate , clientId , "CB_BankPay" , "CB_Bankpay" ) ;
Runnable task2 = ( ) - > {
Runnable task2 = ( ) - > {
try {
try {
if ( signInfo ! = null ) {
clientManager . registerClientApplyGMS ( clientMoniker , sysAccount . getString ( "account_id" ) ) ;
} else {
clientManager . getNewAggregateAgreeFile ( clientMoniker , null , true ) ;
clientManager . getNewAggregateAgreeFile ( clientMoniker , null , true ) ;
}
} catch ( Exception ignore ) {
} catch ( Exception ignore ) {
logger . error ( "{}自助申请成功,支付宝报备失败:{}" , clientMoniker , ignore ) ;
}
//发送开通短信和邮件
try {
simpleClientApplyService . sendOpenSms ( apply . getString ( "contact_phone" ) , "61" ) ;
// clientManager.sendOpenEmail(sysClient, apply.getString("username"), apply.getString("password"));
} catch ( Exception e ) {
logger . error ( "{}:发送短信或邮件失败:{}" , clientMoniker , e ) ;
}
}
} ;
} ;
pool . execute ( task2 ) ;
pool . execute ( task2 ) ;
}
}
private String generateClientMoniker ( ) {
private String generateClientMoniker ( ) {
@ -533,7 +857,55 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
return REGISTER_CLIENT_PROCESS_PREFIX + codeKey ;
return REGISTER_CLIENT_PROCESS_PREFIX + codeKey ;
}
}
//region 手机登录
@Override
public void getAndSendLoginSmsCode ( String phoneNumber , String nationCode , HttpServletRequest request ) {
JSONObject result = new JSONObject ( ) ;
String reidsCheckCodeKey = getLoginClientRedisKey ( phoneNumber ) ;
String value = stringRedisTemplate . boundValueOps ( reidsCheckCodeKey ) . get ( ) ;
if ( StringUtils . isNotEmpty ( value ) ) {
throw new BadRequestException ( "SMS has been sent, Please check your messages or try again in 1 minutes." ) ;
}
ArrayList < String > param = new ArrayList < > ( ) ;
String registerClientCode = RandomStringUtils . random ( 6 , false , true ) ;
param . add ( "RoyalPay" ) ;
param . add ( registerClientCode ) ;
String expireMin = "1" ;
param . add ( expireMin ) ;
try {
if ( request . getLocales ( ) . nextElement ( ) . equals ( Locale . CHINESE ) | | request . getLocales ( ) . nextElement ( ) . equals ( Locale . SIMPLIFIED_CHINESE ) ) {
smsSender . getSender ( ) . sendWithParam ( nationCode . trim ( ) , phoneNumber , REGISTER_CLIENT_TEMPLID , param , "RoyalPay" , "" , "" ) ;
} else {
smsSender . getSender ( ) . sendWithParam ( nationCode . trim ( ) , phoneNumber , REGISTER_CLIENT_TEMPLID_ENGLISH , param , "RoyalPay" , "" , "" ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
throw new ServerErrorException ( "Phone number is wrong Please try again" ) ;
}
stringRedisTemplate . boundValueOps ( getLoginClientRedisKey ( phoneNumber ) ) . set ( registerClientCode , Long . parseLong ( expireMin ) , TimeUnit . MINUTES ) ;
}
@Override
public void verifyLoginSMSCode ( String codeKey , String phoneNumber ) {
String rediskey = getLoginClientRedisKey ( phoneNumber ) ;
String codeValue = stringRedisTemplate . boundValueOps ( rediskey ) . get ( ) ;
if ( codeValue = = null | | ! codeValue . equals ( codeKey ) ) {
throw new BadRequestException ( "Verification code has expired or is not correct" ) ;
}
stringRedisTemplate . delete ( rediskey ) ;
}
private String getVerifyMailRedisKey ( String codekey ) {
private String getVerifyMailRedisKey ( String codekey ) {
return VERIFY_MAIL_PREFIX + codekey ;
return VERIFY_MAIL_PREFIX + codekey ;
}
}
private String getLoginClientRedisKey ( String phoneNumber ) {
return LOGIN_CLIENT_PREFIX + phoneNumber ;
}
private String getLoginClientProcessRedisKey ( String codeKey ) {
return LOGIN_CLIENT_PROCESS_PREFIX + codeKey ;
}
//endregion
}
}