puzhibing
2023-08-14 753c4aede53b07041841d9aa94859b59e366bd5d
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java
@@ -63,7 +63,7 @@
 * @Date 2023-02-20 09:18:08
 */
@Controller
@RequestMapping("/tAgent")
@RequestMapping("")
public class TAgentController extends BaseController {
    private String PREFIX = "/system/tAgent/";
@@ -89,6 +89,9 @@
    @Autowired
    private IRechargeRecordService rechargeRecordService;
    @Autowired
    private ITSystemConfigService systemConfigService;
    @Value("${callbackPath}")
    private String callbackPath;
@@ -96,7 +99,7 @@
    /**
     * 跳转到首页
     */
    @RequestMapping("")
    @RequestMapping("/tAgent")
    public String index(Model model) {
        model.addAttribute("userType", Objects.requireNonNull(ShiroKit.getUser()).getRoleType());
        return PREFIX + "tAgent.html";
@@ -105,7 +108,7 @@
    /**
     * 跳转到添加
     */
    @RequestMapping("/tAgent_add")
    @RequestMapping("/tAgent/tAgent_add")
    public String tAgentAdd() {
        return PREFIX + "tAgent_add.html";
    }
@@ -113,7 +116,7 @@
    /**
     * 跳转到修改
     */
    @RequestMapping("/tAgent_update/{tAgentId}")
    @RequestMapping("/tAgent/tAgent_update/{tAgentId}")
    public String tAgentUpdate(@PathVariable Integer tAgentId, Model model) {
        TAgent tAgent = tAgentService.selectById(tAgentId);
        model.addAttribute("item",tAgent);
@@ -124,7 +127,7 @@
    /**
     * 跳转详情页面
     */
    @RequestMapping("/agentDetail")
    @RequestMapping("/tAgent/agentDetail")
    public String agentDetail(Integer agentId, Model model) {
        tAgentService.detail(agentId,model);
        return PREFIX + "tAgentDetail.html";
@@ -133,7 +136,7 @@
    /**
     * 跳转区域页面
     */
    @RequestMapping("/areaDetail")
    @RequestMapping("/tAgent/areaDetail")
    public String areaDetail(String area,String areaId,Model model) {
//        String[] split1 = areaId.split("/");
//        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
@@ -211,7 +214,7 @@
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @RequestMapping(value = "/tAgent/list")
    @ResponseBody
    public Object list(String principal,String principalPhone,String createTime,Integer status) {
        EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime,status);
@@ -223,7 +226,7 @@
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list-back")
    @RequestMapping(value = "/tAgent/list-back")
    @ResponseBody
    public Object listBack(String condition) {
        return tAgentService.selectList(null);
@@ -232,7 +235,7 @@
    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @RequestMapping(value = "/tAgent/add")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
    public Object add(TAgent tAgent) {
@@ -309,7 +312,7 @@
            registerVO.setUserType("0");
            registerVO.setUserName(tAgent.getMerchantName());
            registerVO.setCertId(tAgent.getMerchantIDCode());
            registerVO.setNotifyUrl(callbackPath + "/tAgent/microenterpriseCallback");
            registerVO.setNotifyUrl(callbackPath + "/base/tAgent/microenterpriseCallback");
            TrhRequest<Register> request = new TrhRequest();
            InterfaceResponse execute = request.execute(registerVO, Register.SERVICE_CODE);
            if("0000".equals(execute.getCode())){
@@ -383,7 +386,7 @@
            registerVO.setProvCode(tAgent.getProvCodeEnterprise());
            registerVO.setAreaCode(tAgent.getAreaCodeEnterprise());
            registerVO.setFileNo(tAgent.getFileNo());
            registerVO.setNotifyUrl(callbackPath + "/tAgent/microenterpriseCallback");
            registerVO.setNotifyUrl(callbackPath + "/base/tAgent/microenterpriseCallback");
            registerVO.setParameter1(tAgent.getId().toString());
            TrhRequest<Register> request = new TrhRequest();
@@ -455,7 +458,7 @@
     * 注册商户回调
     */
    @ResponseBody
    @PostMapping("/microenterpriseCallback")
    @PostMapping("/base/tAgent/microenterpriseCallback")
    public void microenterpriseCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
        try {
            if("0000".equals(interfaceResponse.getCode())) {
@@ -532,7 +535,7 @@
    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @RequestMapping(value = "/tAgent/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tAgentId) {
        tAgentService.deleteById(tAgentId);
@@ -542,7 +545,7 @@
    /**
     * 修改用户状态
     */
    @RequestMapping(value = "/update-status")
    @RequestMapping(value = "/tAgent/update-status")
    @ResponseBody
    public Object updateStatus(Integer id,Integer status) {
        TAgent tAgent = tAgentService.selectById(id);
@@ -586,7 +589,7 @@
    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @RequestMapping(value = "/tAgent/update")
    @ResponseBody
    public Object update(TAgent tAgent) {
        tAgent.setPrincipal(tAgent.getPrincipal().replace(" ",""));
@@ -597,7 +600,7 @@
    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tAgentId}")
    @RequestMapping(value = "/tAgent/detail/{tAgentId}")
    @ResponseBody
    public Object detail(@PathVariable("tAgentId") Integer tAgentId) {
        return tAgentService.selectById(tAgentId);
@@ -605,21 +608,21 @@
    @ApiOperation(value = "省市区查询",notes="省市区查询")
    @RequestMapping(value = "/area")
    @RequestMapping(value = "/tAgent/area")
    @ResponseBody
    public Object area() {
        return tRegionService.getAreaList();
    }
    @ApiOperation(value = "省查询",notes="省查询")
    @RequestMapping(value = "/areaProvince")
    @RequestMapping(value = "/tAgent/areaProvince")
    @ResponseBody
    public Object areaProvince(Model model) {
        return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
    }
    @ApiOperation(value = "市区查询",notes="市区查询")
    @RequestMapping(value = "/areaCity")
    @RequestMapping(value = "/tAgent/areaCity")
    @ResponseBody
    public Object areaCity(Integer parentId) {
        return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id",parentId));
@@ -627,7 +630,7 @@
    @ApiOperation(value = "导出代理商列表",notes="导出代理商列表")
    @RequestMapping(value = "/export")
    @RequestMapping(value = "/tAgent/export")
    @ResponseBody
    public void export(String principal,String principalPhone,Integer status,String createTime, HttpServletResponse response) {
        try {
@@ -681,7 +684,7 @@
    @ResponseBody
    @RequestMapping(value = "/uploadFile")
    @RequestMapping(value = "/tAgent/uploadFile")
    public String uploadFile(MultipartFile file){
        File srcFile = null;
        String originalFilename = file.getOriginalFilename();
@@ -744,7 +747,7 @@
     * 跳转到企业信息页
     * @return
     */
    @GetMapping("/showEnterprisePage")
    @GetMapping("/tAgent/showEnterprisePage")
    public String showEnterprisePage(Model model){
        ShiroUser user = ShiroKit.getUser();
        Integer objectId = user.getObjectId();
@@ -764,7 +767,7 @@
        model.addAttribute("item", tAgent);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        model.addAttribute("socialCreditCodeExpires", roleType == 1 ? "" :Objects.isNull(tAgent.getSocialCreditCodeExpires())?"": sdf.format(tAgent.getSocialCreditCodeExpires()));
        model.addAttribute("certIdExpires", roleType == 1 ? "" : sdf.format(tAgent.getCertIdExpires()));
        model.addAttribute("certIdExpires", roleType == 1 ? "" : null == tAgent.getCertIdExpires() ? "" : sdf.format(tAgent.getCertIdExpires()));
        Wrapper<SettlementRecord> settlementRecordWrapper = new EntityWrapper<SettlementRecord>().eq("type", roleType == 1 ? 1 : 2);
        if(roleType == 2){
            settlementRecordWrapper.eq("objectId", objectId);
@@ -782,7 +785,8 @@
            JSONObject jsonObject = JSON.parseObject(execute.getResult());
            model.addAttribute("balance", jsonObject.getDoubleValue("settledAmount") / 100);
            if(roleType == 1){
                model.addAttribute("marketingAmount", jsonObject.getDoubleValue("marketingAmount") / 100);
                Double amount = rechargeRecordService.querSumSurplusDividedAmount(4);
                model.addAttribute("marketingAmount", amount);
            }
        }
        return PREFIX + "enterprisePage.html";
@@ -794,7 +798,7 @@
     * @return
     */
    @ResponseBody
    @PostMapping("/withdrawCash")
    @PostMapping("/tAgent/withdrawCash")
    public ResultUtil withdrawCash(){
        ShiroUser user = ShiroKit.getUser();
        Integer objectId = user.getObjectId();
@@ -816,7 +820,7 @@
        InterfaceResponse execute = request.execute(queryBalance, QueryBalance.SERVICE_CODE);
        if("0000".equals(execute.getCode())){
            JSONObject jsonObject = JSON.parseObject(execute.getResult());
            double settledAmount = jsonObject.getDoubleValue("settledAmount");
            Integer settledAmount = jsonObject.getInteger("settledAmount");
            if(0 == settledAmount){
                return ResultUtil.error("余额不足");
            }
@@ -825,17 +829,17 @@
            if(roleType == 3){
                settlementRecord.setObjectId(tAgent.getId());
            }
            settlementRecord.setAmount(settledAmount);
            settlementRecord.setAmount(Double.valueOf(settledAmount) / 100);
            settlementRecord.setInsertTime(new Date());
            settlementRecordService.insert(settlementRecord);
            Withdraw withdraw = new Withdraw();
            withdraw.setUserId(tAgent.getMerchantNumber());
            withdraw.setAmount(settledAmount + "");
            withdraw.setAmount(String.valueOf(settledAmount));
            withdraw.setOrderName("账户余额提现");
            withdraw.setRemark("账户余额提现");
            withdraw.setNotifyUrl(callbackPath + "/tAgent/withdrawCashCallback");
            withdraw.setNotifyUrl(callbackPath + "/base/tAgent/withdrawCashCallback");
            withdraw.setParameter1(settlementRecord.getId().toString());
            TrhRequest<Withdraw> request1 = new TrhRequest();
            InterfaceResponse execute1 = request1.execute(withdraw, Withdraw.SERVICE_CODE);//结算(提现)
@@ -871,7 +875,7 @@
     * @param interfaceResponse
     */
    @ResponseBody
    @PostMapping("/withdrawCashCallback")
    @PostMapping("/base/tAgent/withdrawCashCallback")
    public void withdrawCashCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response) {
        try {
            if("0000".equals(interfaceResponse.getCode())){
@@ -908,7 +912,7 @@
     * @return
     */
    @ResponseBody
    @PostMapping("/accountRecharge")
    @PostMapping("/tAgent/accountRecharge")
    public ResultUtil accountRecharge(Double amount){
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
@@ -927,8 +931,8 @@
            deposit.setOrderName("补贴充值");
            deposit.setPayType("ALI_CB");
            deposit.setTerminalIp(InetAddress.getLocalHost().getHostAddress());
            deposit.setFrontUrl(callbackPath + "/tAgent/accountRechargeCallback");
            deposit.setNotifyUrl(callbackPath + "/tAgent/accountRechargeCallback");
            deposit.setFrontUrl(callbackPath + "/base/tAgent/accountRechargeCallback");
            deposit.setNotifyUrl(callbackPath + "/base/tAgent/accountRechargeCallback");
            deposit.setParameter1(rechargeRecord.getId().toString());
            TrhRequest<Deposit> request = new TrhRequest();
            InterfaceResponse execute = request.execute(deposit, Deposit.SERVICE_CODE);
@@ -1009,7 +1013,7 @@
     * @param interfaceResponse
     */
    @ResponseBody
    @PostMapping("/accountRechargeCallback")
    @PostMapping("/base/tAgent/accountRechargeCallback")
    public void accountRechargeCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
        try {
            if("0000".equals(interfaceResponse.getCode())){