parent
058d13bb98
commit
aecf86062c
@ -0,0 +1,138 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.PageUtil; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.agent.BsAgentApiAccountRecordService; |
||||
import com.hfkj.service.agent.BsAgentApiAccountService; |
||||
import com.hfkj.service.agent.BsAgentDiscountService; |
||||
import com.hfkj.service.discount.BsDiscountPkService; |
||||
import com.hfkj.service.discount.BsDiscountService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
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.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/agentApiAccount") |
||||
@Api(value = "优惠券管理") |
||||
public class BsAgentApiAccountController { |
||||
private static Logger log = LoggerFactory.getLogger(BsAgentApiAccountController.class); |
||||
@Resource |
||||
private BsAgentApiAccountService agentApiAccountService; |
||||
@Resource |
||||
private BsAgentApiAccountRecordService agentApiAccountRecordService; |
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value = "/getAccount", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询账户") |
||||
public ResponseData getAccount(@RequestParam(value = "agentId", required = false) Long agentId) { |
||||
try { |
||||
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (SecUserObjectTypeEnum.type1.getCode() == userSession.getAccount().getObjectType()) { |
||||
|
||||
} else if (SecUserObjectTypeEnum.type4.getCode() == userSession.getAccount().getObjectType()) { |
||||
agentId = userSession.getAccount().getObjectId();; |
||||
|
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
// 查询账户
|
||||
return ResponseMsgUtil.success(agentApiAccountService.getAccount(agentId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("agentApiAccount --> getAccount() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/recharge", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "充值") |
||||
public ResponseData recharge(@RequestBody JSONObject body) { |
||||
try { |
||||
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (SecUserObjectTypeEnum.type1.getCode() != userSession.getAccount().getObjectType()) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
if (body == null || body.getLong("agentId") == null || body.getBigDecimal("amount") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 账户充值
|
||||
agentApiAccountService.recharge(body.getLong("agentId"), body.getBigDecimal("amount")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("agentApiAccount --> recharge() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value = "/getRecordList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "记录列表") |
||||
public ResponseData getRecordList(@RequestParam(value = "agentId", required = false) Long agentId, |
||||
@RequestParam(value = "type", required = false) Integer type, |
||||
@RequestParam(value = "sourceType", required = false) Integer sourceType, |
||||
@RequestParam(value = "sourceOrderNo", required = false) String sourceOrderNo, |
||||
@RequestParam(value = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(value = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(value = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (SecUserObjectTypeEnum.type1.getCode() == userSession.getAccount().getObjectType()) { |
||||
|
||||
} else if (SecUserObjectTypeEnum.type4.getCode() == userSession.getAccount().getObjectType()) { |
||||
agentId = userSession.getAccount().getObjectId();; |
||||
|
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
// 查询账户
|
||||
BsAgentApiAccount account = agentApiAccountService.getAccount(agentId); |
||||
if (account == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到账户"); |
||||
} |
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("agentApiAccountId", account.getId()); |
||||
param.put("type", type); |
||||
param.put("sourceType", sourceType); |
||||
param.put("sourceOrderNo", sourceOrderNo); |
||||
param.put("createTimeS", createTimeS); |
||||
param.put("createTimeE", createTimeE); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(agentApiAccountRecordService.getList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("agentApiAccount --> getRecordList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,80 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsAgentApiAccount; |
||||
import com.hfkj.entity.BsAgentApiParam; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.agent.BsAgentApiAccountRecordService; |
||||
import com.hfkj.service.agent.BsAgentApiAccountService; |
||||
import com.hfkj.service.agent.BsAgentApiParamService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/agentApiParam") |
||||
@Api(value = "代理商API参数") |
||||
public class BsAgentApiParamController { |
||||
private static Logger log = LoggerFactory.getLogger(BsAgentApiParamController.class); |
||||
@Resource |
||||
private BsAgentApiParamService agentApiParamService; |
||||
|
||||
@RequestMapping(value = "/getApiParam", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询参数") |
||||
public ResponseData getApiParam(@RequestParam(value = "agentId", required = true) Long agentId) { |
||||
try { |
||||
|
||||
// 查询账户
|
||||
return ResponseMsgUtil.success(agentApiParamService.getParam(agentId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsAgentApiParamController --> getApiParam() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "修改参数") |
||||
public ResponseData update(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("agentId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 代理商API参数
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParam(body.getLong("agentId")); |
||||
if (apiParam == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到API参数"); |
||||
} |
||||
apiParam.setMerInfoNotify(body.getString("merInfoNotify")); |
||||
apiParam.setOrderRefundNotify(body.getString("orderRefundNotify")); |
||||
agentApiParamService.update(apiParam); |
||||
|
||||
// 查询账户
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsAgentApiParamController --> getApiParam() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,74 @@ |
||||
package com.bweb.controller.notify; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.channel.gas.newlink.NewLinkGasService; |
||||
import com.hfkj.channel.gas.newlink.NewLinkRequestService; |
||||
import com.hfkj.common.security.AESEncodeUtil; |
||||
import com.hfkj.entity.BsGasOrder; |
||||
import com.hfkj.openapi.model.request.RequestOrderRefundModel; |
||||
import com.hfkj.openapi.service.ApiGasOrderService; |
||||
import com.hfkj.service.gas.BsGasOrderService; |
||||
import com.hfkj.service.order.BsOrderRefundService; |
||||
import com.hfkj.sysenum.gas.GasOrderCreateType; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
/** |
||||
* @className: NewLinkNotify |
||||
* @author: HuRui |
||||
* @date: 2024/7/26 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value = "/testNotify") |
||||
@Api(value = "测试通知") |
||||
public class TestNotify { |
||||
|
||||
@Resource |
||||
private NewLinkGasService newLinkGasService; |
||||
@Resource |
||||
private BsOrderRefundService orderRefundService; |
||||
@Resource |
||||
private BsGasOrderService gasOrderService; |
||||
@Resource |
||||
private ApiGasOrderService apiGasOrderService; |
||||
|
||||
@RequestMapping(value="/merChange",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "商户变更") |
||||
public String merChange(@RequestBody JSONObject body) { |
||||
try { |
||||
System.out.println("================测试商户变更通知=================="); |
||||
System.out.println("参数"+body); |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println("变更异常:" + e.getMessage()); |
||||
} finally { |
||||
System.out.println("================测试商户变更通知=================="); |
||||
} |
||||
return "success"; |
||||
} |
||||
|
||||
@RequestMapping(value="/orderRefund",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "订单退款") |
||||
public String orderRefund(@RequestBody JSONObject body) { |
||||
try { |
||||
System.out.println("================测试订单退款通知=================="); |
||||
System.out.println("参数"+body); |
||||
} catch (Exception e) { |
||||
System.out.println("变更异常:" + e.getMessage()); |
||||
} finally { |
||||
System.out.println("================测试订单退款通知=================="); |
||||
} |
||||
return "success"; |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,72 @@ |
||||
package com.openapi.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.pay.util.SignatureUtil; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsAgentApiAccount; |
||||
import com.hfkj.entity.BsAgentApiParam; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.openapi.model.request.RequestAmountModel; |
||||
import com.hfkj.openapi.model.response.ResponseAmountModel; |
||||
import com.hfkj.service.agent.BsAgentApiAccountService; |
||||
import com.hfkj.service.agent.BsAgentApiParamService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/account") |
||||
@Api(value = "账户管理") |
||||
public class BsAccountController { |
||||
private static Logger log = LoggerFactory.getLogger(BsAccountController.class); |
||||
@Resource |
||||
private BsAgentApiParamService agentApiParamService; |
||||
@Resource |
||||
private BsAgentApiAccountService agentApiAccountService; |
||||
|
||||
@RequestMapping(value="/queryAmount",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询账户余额") |
||||
public ResponseData queryAmount(@Validated @RequestBody RequestAmountModel body) { |
||||
log.info("========= Start 查询账户余额 Start ==========="); |
||||
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||
try { |
||||
// 验证签名
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
||||
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||
} |
||||
// 查询账户
|
||||
BsAgentApiAccount account = agentApiAccountService.getAccount(apiParam.getAgentId()); |
||||
if (account == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到账户"); |
||||
} |
||||
ResponseAmountModel response = new ResponseAmountModel(); |
||||
response.setAppId(body.getAppId()); |
||||
response.setAmount(account.getAmount()); |
||||
log.info("返回参数:" +response); |
||||
return ResponseMsgUtil.success(response); |
||||
|
||||
} catch (Exception e) { |
||||
log.info("出现异常:", e); |
||||
// 异常内容
|
||||
ResponseData exception = ResponseMsgUtil.exception(e); |
||||
return exception; |
||||
} finally { |
||||
log.info("========= END 查询账户余额 END ==========="); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
package com.hfkj.openapi.model.request; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
@Data |
||||
public class RequestAmountModel { |
||||
|
||||
/** |
||||
* appid |
||||
*/ |
||||
@NotBlank(message = "appId必填项") |
||||
private String appId; |
||||
|
||||
/** |
||||
* 签名参数 |
||||
*/ |
||||
@NotBlank(message = "签名必填项") |
||||
private String sign; |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.hfkj.openapi.model.response; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.math.BigDecimal; |
||||
|
||||
@Data |
||||
public class ResponseAmountModel { |
||||
|
||||
/** |
||||
* appid |
||||
*/ |
||||
private String appId; |
||||
|
||||
/** |
||||
* 余额 |
||||
*/ |
||||
private BigDecimal amount; |
||||
} |
Loading…
Reference in new issue