|  | @@ -1,5 +1,7 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.web.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.huifu.adapay.Adapay;
 | 
	
		
			
				|  |  | +import com.huifu.adapay.model.MerConfig;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.HfMerchantConfigService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
	
		
			
				|  | @@ -29,16 +31,32 @@ public class HfMerchantConfigController extends BaseController {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("创建汇付商户配置")
 | 
	
		
			
				|  |  |      @PostMapping("/add")
 | 
	
		
			
				|  |  | -    public HttpResponseResult<Object> add(@RequestBody HfMerchantConfig dto) {
 | 
	
		
			
				|  |  | -        hfMerchantConfigService.insert(dto);
 | 
	
		
			
				|  |  | -        return succeed();
 | 
	
		
			
				|  |  | +    public HttpResponseResult<Object> add(@RequestBody HfMerchantConfig dto) throws Exception {
 | 
	
		
			
				|  |  | +        long insert = hfMerchantConfigService.insert(dto);
 | 
	
		
			
				|  |  | +        if (insert == 1) {
 | 
	
		
			
				|  |  | +            MerConfig merConfig = new MerConfig();
 | 
	
		
			
				|  |  | +            merConfig.setApiKey(dto.getApiKey());
 | 
	
		
			
				|  |  | +            merConfig.setApiMockKey(dto.getMockApiKey());
 | 
	
		
			
				|  |  | +            merConfig.setRSAPrivateKey(dto.getRsaPrivateKey());
 | 
	
		
			
				|  |  | +            Adapay.addMerConfig(merConfig, dto.getMerKey());
 | 
	
		
			
				|  |  | +            return succeed();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return failed("添加失败");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("创建汇付商户配置")
 | 
	
		
			
				|  |  |      @PostMapping("/update")
 | 
	
		
			
				|  |  | -    public HttpResponseResult<Object> update(@RequestBody HfMerchantConfig dto) {
 | 
	
		
			
				|  |  | -        hfMerchantConfigService.update(dto);
 | 
	
		
			
				|  |  | -        return succeed();
 | 
	
		
			
				|  |  | +    public HttpResponseResult<Object> update(@RequestBody HfMerchantConfig dto) throws Exception {
 | 
	
		
			
				|  |  | +        int update = hfMerchantConfigService.update(dto);
 | 
	
		
			
				|  |  | +        if (update == 1) {
 | 
	
		
			
				|  |  | +            MerConfig merConfig = new MerConfig();
 | 
	
		
			
				|  |  | +            merConfig.setApiKey(dto.getApiKey());
 | 
	
		
			
				|  |  | +            merConfig.setApiMockKey(dto.getMockApiKey());
 | 
	
		
			
				|  |  | +            merConfig.setRSAPrivateKey(dto.getRsaPrivateKey());
 | 
	
		
			
				|  |  | +            Adapay.addMerConfig(merConfig, dto.getMerKey());
 | 
	
		
			
				|  |  | +            return succeed();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return failed("修改失败");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("根据机构id查询汇付商户配置")
 |