parent
cc8af5bd32
commit
59da087d7f
@ -0,0 +1,164 @@ |
||||
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.BsAgentMerAccount; |
||||
import com.hfkj.entity.BsAgentStaff; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.agent.BsAgentMerAccountRecordService; |
||||
import com.hfkj.service.agent.BsAgentMerAccountService; |
||||
import com.hfkj.service.agent.BsAgentStaffService; |
||||
import com.hfkj.service.merchant.BsMerchantAccountRecordService; |
||||
import com.hfkj.service.merchant.BsMerchantAccountService; |
||||
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.Map; |
||||
|
||||
/** |
||||
* @className: BsMerchantAccountController |
||||
* @author: HuRui |
||||
* @date: 2024/7/2 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value = "/agentMerAccount") |
||||
@Api(value = "代理商商户账户") |
||||
public class BsAgentMerAccountController { |
||||
private static Logger log = LoggerFactory.getLogger(BsAgentMerAccountController.class); |
||||
@Resource |
||||
private BsAgentMerAccountService agentMerAccountService; |
||||
@Resource |
||||
private BsAgentMerAccountRecordService agentMerAccountRecordService; |
||||
@Resource |
||||
private BsAgentStaffService agentStaffService; |
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value = "/getAccount", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询账户") |
||||
public ResponseData getAccount(@RequestParam(value = "agentId", required = true) Long agentId, |
||||
@RequestParam(value = "merNo", required = true) String merNo) { |
||||
try { |
||||
|
||||
// 查询账户
|
||||
return ResponseMsgUtil.success(agentMerAccountService.getAccount(agentId, merNo)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsAgentMerAccountController --> 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 |
||||
|| StringUtils.isBlank(body.getString("merNo")) |
||||
|| body.getBigDecimal("amount") == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 账户充值
|
||||
agentMerAccountService.recharge(body.getLong("agentId"), body.getString("merNo"), body.getBigDecimal("amount")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsAgentMerAccountController --> recharge() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getMerList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询商户列表") |
||||
public ResponseData getMerList(@RequestParam(value = "agentId", required = false) Long agentId, |
||||
@RequestParam(value = "merNo", required = false) String merNo, |
||||
@RequestParam(value = "merName", required = false) String merName, |
||||
@RequestParam(value = "provinceCode", required = false) Long provinceCode, |
||||
@RequestParam(value = "cityCode", required = false) Long cityCode, |
||||
@RequestParam(value = "areaCode", required = false) Long areaCode, |
||||
@RequestParam(value = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
Map<String,Object> param = new HashMap<>(); |
||||
if (SecUserObjectTypeEnum.type1.getCode() == userSession.getAccount().getObjectType()) { |
||||
param.put("agentId", agentId); |
||||
|
||||
} else if (SecUserObjectTypeEnum.type4.getCode() == userSession.getAccount().getObjectType()) { |
||||
param.put("agentId", userSession.getAccount().getObjectId()); |
||||
|
||||
} else if (SecUserObjectTypeEnum.type5.getCode() == userSession.getAccount().getObjectType()) { |
||||
// 查询代理商工作人员
|
||||
BsAgentStaff agentStaff = agentStaffService.getStaffDetailById(userSession.getAccount().getId()); |
||||
if (agentStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
param.put("agentId", agentStaff.getAgentId()); |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
param.put("merNo", merNo); |
||||
param.put("merName", merName); |
||||
param.put("provinceCode", provinceCode); |
||||
param.put("cityCode", cityCode); |
||||
param.put("areaCode", areaCode); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(agentMerAccountService.getMerList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsMerchantAccountController --> getRecordList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getRecordList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "记录列表") |
||||
public ResponseData getRecordList(@RequestParam(value = "agentId", required = true) Long agentId, |
||||
@RequestParam(value = "merNo", required = true) String merNo, |
||||
@RequestParam(value = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("agentId", agentId); |
||||
param.put("merNo", merNo); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(agentMerAccountRecordService.getList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsAgentMerAccountController --> getRecordList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,7 +1,37 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsAgentMerAccountMapperExt { |
||||
|
||||
@Select("<script>" + |
||||
" SELECT" + |
||||
" b.province_name provinceName," + |
||||
" b.city_name cityName," + |
||||
" b.area_name areaName," + |
||||
" b.mer_no merNo," + |
||||
" b.mer_name merName," + |
||||
" b.address," + |
||||
" a.amount " + |
||||
" FROM" + |
||||
" bs_agent_mer_account a" + |
||||
" LEFT JOIN bs_merchant b ON a.mer_no = b.mer_no" + |
||||
" where 1 = 1" + |
||||
" <if test='param.provinceCode != null'> and b.province_code = #{param.provinceCode} </if>" + |
||||
" <if test='param.cityCode != null'> and b.city_code = #{param.cityCode} </if>" + |
||||
" <if test='param.areaCode != null'> and b.area_code = #{param.areaCode} </if>" + |
||||
" <if test='param.agentId != null'> and b.agent_id = #{param.agentId} </if>" + |
||||
" <if test='param.merNo != null'> and b.mer_no like concat('%',#{param.merNo},'%') </if>" + |
||||
" <if test='param.merName != null'> and b.mer_name like concat('%',#{param.merName},'%') </if>" + |
||||
" ORDER BY a.amount asc" + |
||||
"</script>") |
||||
List<Map<String,Object>> selectMerList(@Param("param") Map<String,Object> param); |
||||
|
||||
} |
Loading…
Reference in new issue