@ -21,6 +21,8 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row ;
import org.apache.poi.ss.usermodel.Sheet ;
import org.dom4j.Element ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.stereotype.Service ;
import javax.annotation.Resource ;
@ -44,6 +46,8 @@ public class AliforexcelServiceImpl implements AliforexcelService {
private AlipayClient alipayClient ;
@Resource
private OrderMapper orderMapper ;
private Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ;
@Override
public JSONObject listClients ( HttpServletResponse httpResponse , JSONObject manager , AliExcel query ) {
@ -105,7 +109,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
List < String > registerSuccessMerchant = new ArrayList < > ( ) ;
List < JSONObject > registerFailMerchant = new ArrayList < > ( ) ;
List < JSONObject > lessInfoMerchant = new ArrayList < > ( ) ;
List < Integer > useAlipayOnlineMerchant = transactionMapper. useAlipayOnlineClients ( ) ;
List < Integer > useAlipayOnlineMerchant = clientMapper. listUseAlipayMerchant ( 0 , 10000 ) ;
for ( int clientId : useAlipayOnlineMerchant ) {
JSONObject client = clientMapper . findClient ( clientId ) ;
if ( client = = null ) {
@ -113,6 +117,9 @@ public class AliforexcelServiceImpl implements AliforexcelService {
}
try {
needRegisterMerchant . add ( client . getString ( "client_moniker" ) ) ;
if ( StringUtils . isBlank ( client . getString ( "company_website" ) ) ) {
client . put ( "company_website" , client . getString ( "ali_sub_merchant_id" ) + ".royalpay.com.au" ) ;
}
checkPartnerInfo ( client , "online" ) ;
} catch ( InvalidParameterException e ) {
JSONObject exception = new JSONObject ( ) ;
@ -122,29 +129,104 @@ public class AliforexcelServiceImpl implements AliforexcelService {
lessInfoMerchant . add ( exception ) ;
continue ;
}
AlipayConfig . AlipayMerchant mch = AlipayEnvironment . getEnv ( ) . getAlipayOnlineMerchant ( ) ;
Element resultElement = alipayClient . registerOnlineGmsPortal ( mch . getPid ( ) , client ) ;
if ( ! StringUtils . equalsIgnoreCase ( "T" , resultElement . elementText ( "is_success" ) ) ) {
try {
AlipayConfig . AlipayMerchant mch = AlipayEnvironment . getEnv ( ) . getAlipayOnlineMerchant ( ) ;
Element resultElement = alipayClient . registerOnlineGmsPortal ( mch . getPid ( ) , client ) ;
if ( ! StringUtils . equalsIgnoreCase ( "T" , resultElement . elementText ( "is_success" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
Element responseElement = resultElement . element ( "response" ) . element ( "alipay" ) ;
if ( ! StringUtils . equalsIgnoreCase ( "SUCCESS" , responseElement . elementText ( "result_code" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
registerSuccessMerchant . add ( client . getString ( "client_moniker" ) ) ;
} catch ( Exception e ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
exception . put ( "return_msg" , e. getMessage ( ) ) ;
registerFailMerchant . add ( exception ) ;
}
}
result . put ( "need_register_merchant" , needRegisterMerchant ) ;
result . put ( "success_register_merchant" , registerSuccessMerchant ) ;
result . put ( "fail_register_merchant" , registerFailMerchant ) ;
result . put ( "less_info_merchant" , lessInfoMerchant ) ;
logger . info ( "-------AlipayOnline Gms end----fail_register_merchant" + registerFailMerchant . toString ( ) ) ;
return result ;
}
@Override
public JSONObject registerRangeAlipayOnlineMerchant ( int start , int end ) {
JSONObject result = new JSONObject ( ) ;
List < String > needRegisterMerchant = new ArrayList < > ( ) ;
List < String > registerSuccessMerchant = new ArrayList < > ( ) ;
List < JSONObject > registerFailMerchant = new ArrayList < > ( ) ;
List < JSONObject > lessInfoMerchant = new ArrayList < > ( ) ;
List < Integer > useAlipayOnlineMerchant = clientMapper . listUseAlipayMerchant ( start , end ) ;
for ( int clientId : useAlipayOnlineMerchant ) {
JSONObject client = clientMapper . findClient ( clientId ) ;
if ( client = = null ) {
continue ;
}
Element responseElement = resultElement . element ( "response" ) . element ( "alipay" ) ;
if ( ! StringUtils . equalsIgnoreCase ( "SUCCESS" , responseElement . elementText ( "result_code" ) ) ) {
try {
needRegisterMerchant . add ( client . getString ( "client_moniker" ) ) ;
if ( StringUtils . isBlank ( client . getString ( "company_website" ) ) ) {
client . put ( "company_website" , client . getString ( "ali_sub_merchant_id" ) + ".royalpay.com.au" ) ;
}
if ( StringUtils . isBlank ( client . getString ( "alipayindustry" ) ) ) {
client . put ( "alipayindustry" , "5311" ) ;
}
if ( StringUtils . isBlank ( client . getString ( "business_structure" ) ) ) {
client . put ( "business_structure" , "da" ) ;
}
checkPartnerInfo ( client , "online" ) ;
} catch ( InvalidParameterException e ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
exception . put ( "return_msg" , e . getMessage ( ) ) ;
exception . put ( "bd_name" , client . getString ( "bd_user_name" ) ) ;
lessInfoMerchant . add ( exception ) ;
continue ;
}
registerSuccessMerchant . add ( client . getString ( "client_moniker" ) ) ;
try {
AlipayConfig . AlipayMerchant mch = AlipayEnvironment . getEnv ( ) . getAlipayOnlineMerchant ( ) ;
Element resultElement = alipayClient . registerOnlineGmsPortal ( mch . getPid ( ) , client ) ;
if ( ! StringUtils . equalsIgnoreCase ( "T" , resultElement . elementText ( "is_success" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
Element responseElement = resultElement . element ( "response" ) . element ( "alipay" ) ;
if ( ! StringUtils . equalsIgnoreCase ( "SUCCESS" , responseElement . elementText ( "result_code" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
registerSuccessMerchant . add ( client . getString ( "client_moniker" ) ) ;
} catch ( Exception e ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , e . getMessage ( ) ) ;
registerFailMerchant . add ( exception ) ;
}
}
result . put ( "need_register_merchant" , needRegisterMerchant ) ;
result . put ( "success_register_merchant" , registerSuccessMerchant ) ;
result . put ( "fail_register_merchant" , registerFailMerchant ) ;
result . put ( "less_info_merchant" , lessInfoMerchant ) ;
logger . info ( "-------AlipayOnline Gms end----fail_register_merchant" + registerFailMerchant . toString ( ) ) ;
return result ;
}
@ -267,6 +349,65 @@ public class AliforexcelServiceImpl implements AliforexcelService {
return result ;
}
@Override
public JSONObject registerInsertAlipayOnlineMerchant ( String partners ) {
String [ ] partner = partners . split ( "," ) ;
JSONObject result = new JSONObject ( ) ;
List < String > needRegisterMerchant = new ArrayList < > ( ) ;
List < String > registerSuccessMerchant = new ArrayList < > ( ) ;
List < JSONObject > registerFailMerchant = new ArrayList < > ( ) ;
List < JSONObject > lessInfoMerchant = new ArrayList < > ( ) ;
for ( String clientMoniker : partner ) {
JSONObject client = clientMapper . findClientByMoniker ( clientMoniker ) ;
if ( client = = null ) {
continue ;
}
try {
needRegisterMerchant . add ( client . getString ( "client_moniker" ) ) ;
if ( StringUtils . isBlank ( client . getString ( "alipayindustry" ) ) ) {
client . put ( "alipayindustry" , "5311" ) ;
}
if ( StringUtils . isBlank ( client . getString ( "business_structure" ) ) ) {
client . put ( "business_structure" , "da" ) ;
}
if ( StringUtils . isBlank ( client . getString ( "company_website" ) ) ) {
client . put ( "company_website" , client . getString ( "ali_sub_merchant_id" ) + ".royalpay.com.au" ) ;
}
checkPartnerInfo ( client , "online" ) ;
} catch ( InvalidParameterException e ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , e . getMessage ( ) ) ;
exception . put ( "bd_name" , client . getString ( "bd_user_name" ) ) ;
lessInfoMerchant . add ( exception ) ;
continue ;
}
AlipayConfig . AlipayMerchant mch = AlipayEnvironment . getEnv ( ) . getAlipayOnlineMerchant ( ) ;
Element resultElement = alipayClient . registerOnlineGmsPortal ( mch . getPid ( ) , client ) ;
if ( ! StringUtils . equalsIgnoreCase ( "T" , resultElement . elementText ( "is_success" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
Element responseElement = resultElement . element ( "response" ) . element ( "alipay" ) ;
if ( ! StringUtils . equalsIgnoreCase ( "SUCCESS" , responseElement . elementText ( "result_code" ) ) ) {
JSONObject exception = new JSONObject ( ) ;
exception . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
exception . put ( "return_msg" , resultElement . elementText ( "error" ) ) ;
registerFailMerchant . add ( exception ) ;
continue ;
}
registerSuccessMerchant . add ( client . getString ( "client_moniker" ) ) ;
}
result . put ( "need_register_merchant" , needRegisterMerchant ) ;
result . put ( "success_register_merchant" , registerSuccessMerchant ) ;
result . put ( "fail_register_merchant" , registerFailMerchant ) ;
result . put ( "less_info_merchant" , lessInfoMerchant ) ;
return result ;
}
@Override
public JSONObject getLessPartnerInfo ( ) {
JSONObject result = new JSONObject ( ) ;