| @@ -0,0 +1,74 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxPayAccount; | |||||
| import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.enums.EnumEnableType; | |||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxPayAccountService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/api/payAccount") | |||||
| @Api(description = "支付设置") | |||||
| public class WxPayAccountController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxPayAccountService wxPayAccountService; | |||||
| @Autowired | |||||
| private WxAppinfoService wxAppinfoService; | |||||
| @ApiOperation(value = "获取支付设置", notes = "") | |||||
| @PostMapping("/getPayAccount") | |||||
| public ResultData getPayAccount(@RequestBody Map<String, String> paramMap) { | |||||
| logger.info("/api/payAccount/getPayAccount" + paramMap.toString()); | |||||
| String appId = paramMap.get("appId"); | |||||
| if (StringUtils.isBlank(appId)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||||
| } | |||||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||||
| if(wxAppinfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
| } | |||||
| if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||||
| } | |||||
| EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||||
| if(appPlat == null){ | |||||
| return new ResultData(ErrorCode.APP_PLAT_ERROR); | |||||
| } | |||||
| WxPayAccount payAccount = wxPayAccountService.getPayAccount(getTenantInfo(), appPlat); | |||||
| if(payAccount == null){ | |||||
| return new ResultData(ErrorCode.API_KEY_NOT_FOUND.getCode(),"未找到支付配置"); | |||||
| } | |||||
| WxPayAccount returnPayAccount = new WxPayAccount(); | |||||
| returnPayAccount.setType(payAccount.getType()); | |||||
| returnPayAccount.setMchType(payAccount.getMchType()); | |||||
| returnPayAccount.setOpenPay(payAccount.getOpenPay()); | |||||
| returnPayAccount.setPayVersion(payAccount.getPayVersion()); | |||||
| returnPayAccount.setShare(payAccount.getShare()); | |||||
| return new ResultData(returnPayAccount); | |||||
| } | |||||
| } | |||||