浏览代码

人员账户提现及余额查询调整

qinfenglong 2 年之前
父节点
当前提交
9fdd228330

+ 145 - 105
src/main/java/com/ydtech/modules/ins/controller/InsPayApplyController.java

@@ -6,7 +6,9 @@ import com.ydtech.core.page.PageRequest;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.admin.model.SysDept;
 import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.admin.model.SysUserInfo;
 import com.ydtech.modules.admin.service.SysDeptService;
+import com.ydtech.modules.admin.service.SysUserInfoService;
 import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.esm.model.vo.ExtensionVO;
@@ -48,6 +50,8 @@ public class InsPayApplyController extends BaseController {
     @Autowired
     SysUserService sysUserService;
     @Autowired
+    SysUserInfoService sysUserInfoService;
+    @Autowired
     SysDeptService sysDeptService;
     @Autowired
     InsCommissionService insCommissionService;
@@ -117,6 +121,39 @@ public class InsPayApplyController extends BaseController {
         return HttpResult.ok(pageResult);
     }
 
+    /**
+     * 人员账户分页查询
+     *
+     * @param pageRequest
+     * @return
+     */
+    @PostMapping(value = "/findPageAccount")
+    public HttpResult findPageAccount(@RequestBody PageRequest pageRequest) {
+
+        int pageNum = pageRequest.getPageNum();
+        int pageSize = pageRequest.getPageSize();
+
+
+        String userid = pageRequest.getColumnFilterValue(pageRequest, "userid"); // 出单员
+        String deptid = pageRequest.getColumnFilterValue(pageRequest, "deptid"); // 所属机构
+
+        StringBuffer whereStr = new StringBuffer(" where 1=1");
+        ArrayList array = new ArrayList();
+
+        if (!StringUtils.isEmpty(userid)) {
+            whereStr.append(" and userid=?");
+            array.add(userid);
+        }
+        if (!StringUtils.isEmpty(deptid)) {
+            whereStr.append(" and deptid like ?");
+            array.add(deptid + "%");
+        }
+
+        PageResult pageResult = insPayApplyService.selectAccountPaging(pageNum, pageSize, whereStr.toString(), array.toArray());
+
+        return HttpResult.ok(pageResult);
+    }
+
     /**
      * 查询提现详情
      *
@@ -270,7 +307,7 @@ public class InsPayApplyController extends BaseController {
 
         AccountVo account = new AccountVo();
         //账户总金额
-        double sumAmount = insCommissionService.sumAmount(" where t.refereescode=? and t.auditstatus=?", new Object[]{userid, "1"});
+        double sumAmount = insCommissionService.sumAmount(" where t.refereescode=?", new Object[]{userid});
         //已提现金额
         double totalAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "B"});
         //可提现余额
@@ -293,58 +330,60 @@ public class InsPayApplyController extends BaseController {
         return httpResult;
     }
 
-//    /**
-//     * 推广费提现申请
-//     *
-//     * @param userid
-//     * @param amount
-//     * @return
-//     */
-//    @PostMapping(value = "/extendApply")
-//    public HttpResult extendApply(@RequestParam String userid, @RequestParam double amount) {
-//        HttpResult httpResult = new HttpResult();
-//        //推广账户总金额
-//        double sumAmount = insCommissionService.sumAmount(" where t.refereescode=? and t.auditstatus=?", new Object[]{userid, "1"});
-//        //已提现金额
-//        double totalAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "B"});
-//        double accountBalance = sumAmount - totalAmount;
-//
-//        if (amount > accountBalance) {
-//            return HttpResult.error("可提现余额不足");
-//        }
-//        InsPayApply apply = new InsPayApply();
-//        String applyno = IdGenerate.nextId();
-//        SysUser user = sysUserService.getById(userid);
-//        if (user == null) {
-//            httpResult.setMsg("userId不存在");
-//            return httpResult;
-//        }
-//        apply.setApplyno(applyno);
-//        apply.setUserid(userid);
-//        apply.setUsername(user.getName());
-//        apply.setDeptid(user.getDeptId());
-//        SysDept dept = sysDeptService.getById(user.getDeptId());
-//        apply.setDeptname(dept == null ? "" : dept.getName());
-//        BigDecimal decimal = new BigDecimal(accountBalance);
-//        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
-//        apply.setAccountbalance(decimal.doubleValue());
-//        apply.setApplyamount(amount);
-//        decimal = new BigDecimal(accountBalance - amount);
-//        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
-//        apply.setBalance(decimal.doubleValue());
-//        apply.setDisrate("");
-//        EsmUserInternal userInternal = esmUserInternalService.getById(userid);
-//        apply.setBankname(userInternal.getBankname());
-//        apply.setAccountno(userInternal.getAccountno());
-//        apply.setApplystatus("0"); //0申请中 1支付中 2已支付
-//        apply.setApplytype("B");  //A跟单绩效  B推广佣金
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        apply.setCreatetime(sdf.format(new Date()));
-//
-//        insPayApplyService.insert(apply);
-//
-//        return HttpResult.ok("保存成功");
-//    }
+    /**
+     * 推广费提现申请
+     *
+     * @param userid
+     * @param amount
+     * @return
+     */
+    @PostMapping(value = "/extendApply")
+    public HttpResult extendApply(@RequestParam String userid, @RequestParam double amount) {
+        HttpResult httpResult = new HttpResult();
+        //推广账户总金额
+        double sumAmount = insCommissionService.sumAmount(" where t.refereescode=?", new Object[]{userid});
+        //已提现金额
+        double totalAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "B"});
+        double accountBalance = sumAmount - totalAmount;
+
+        if (amount > accountBalance) {
+            return HttpResult.error("可提现余额不足");
+        }
+        InsPayApply apply = new InsPayApply();
+        String applyno = IdGenerate.nextId();
+        SysUser user = sysUserService.getById(userid);
+        if (user == null) {
+            httpResult.setMsg("userId不存在");
+            return httpResult;
+        }
+        apply.setApplyno(applyno);
+        apply.setUserid(userid);
+        apply.setUsername(user.getName());
+        apply.setDeptid(user.getDeptId());
+        SysDept dept = sysDeptService.getById(user.getDeptId());
+        apply.setDeptname(dept == null ? "" : dept.getName());
+        BigDecimal decimal = new BigDecimal(accountBalance);
+        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
+        apply.setAccountbalance(decimal.doubleValue());
+        apply.setApplyamount(amount);
+        decimal = new BigDecimal(accountBalance - amount);
+        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
+        apply.setBalance(decimal.doubleValue());
+        apply.setDisrate("");
+
+        //查询详情信息
+        SysUserInfo userInfo = sysUserInfoService.getById(userid);
+        apply.setBankname(userInfo.getBankName());
+        apply.setAccountno(userInfo.getAccountno());
+        apply.setApplystatus("0"); //0申请中 1支付中 2已支付
+        apply.setApplytype("B");  //A跟单绩效  B推广佣金
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        apply.setCreatetime(sdf.format(new Date()));
+
+        insPayApplyService.insert(apply);
+
+        return HttpResult.ok("保存成功");
+    }
 
     /**
      * 提现账户
@@ -358,7 +397,7 @@ public class InsPayApplyController extends BaseController {
         AccountVo account = new AccountVo();
 
         //账户总金额
-        double sumAmount = insCompanyFeeService.sumAmount(" where t.userid=? and t.settlestatus=?", new Object[]{userid, "1"});
+        double sumAmount = insCompanyFeeService.sumAmount(" where t.userid=?", new Object[]{userid});
         //已提现金额
         double totalAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "A"});
         //可提现余额
@@ -378,57 +417,58 @@ public class InsPayApplyController extends BaseController {
         return httpResult;
     }
 
-//    /**
-//     * 提现申请
-//     *
-//     * @param userid
-//     * @param amount
-//     * @return
-//     */
-//    @PostMapping(value = "/applyPay")
-//    public HttpResult applyPay(@RequestParam String userid, @RequestParam double amount) {
-//        HttpResult httpResult = new HttpResult();
-//        //账户总金额
-//        double sumAmount = insCompanyFeeService.sumAmount(" where t.userid=? and t.settlestatus=?", new Object[]{userid, "1"});
-//        //已提现金额
-//        double applyAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "A"});
-//        double accountBalance = sumAmount - applyAmount;
-//        if (amount > accountBalance) {
-//            return HttpResult.error("可提现余额不足");
-//        }
-//        InsPayApply apply = new InsPayApply();
-//        String applyno = IdGenerate.nextId();
-//        SysUser user = sysUserService.getById(userid);
-//        if (user == null) {
-//            httpResult.setMsg("userId不存在");
-//            return httpResult;
-//        }
-//        apply.setApplyno(applyno);
-//        apply.setUserid(userid);
-//        apply.setUsername(user.getName());
-//        apply.setDeptid(user.getDeptId());
-//        SysDept dept = sysDeptService.getById(user.getDeptId());
-//        apply.setDeptname(dept == null ? "" : dept.getName());
-//        BigDecimal decimal = new BigDecimal(accountBalance);
-//        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
-//        apply.setAccountbalance(decimal.doubleValue());
-//        apply.setApplyamount(amount);
-//        decimal = new BigDecimal(accountBalance - amount);
-//        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
-//        apply.setBalance(decimal.doubleValue());
-//        apply.setDisrate("");
-//        EsmUserInternal userInternal = esmUserInternalService.getById(userid);
-//        apply.setBankname(userInternal.getBankname());
-//        apply.setAccountno(userInternal.getAccountno());
-//        apply.setApplystatus("0"); //0申请中 1支付中 2已支付
-//        apply.setApplytype("A");  //A跟单绩效  B推广佣金
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        apply.setCreatetime(sdf.format(new Date()));
-//
-//        insPayApplyService.insert(apply);
-//
-//        return HttpResult.ok("保存成功");
-//    }
+    /**
+     * 提现申请
+     *
+     * @param userid
+     * @param amount
+     * @return
+     */
+    @PostMapping(value = "/applyPay")
+    public HttpResult applyPay(@RequestParam String userid, @RequestParam double amount) {
+        HttpResult httpResult = new HttpResult();
+        //账户总金额
+        double sumAmount = insCompanyFeeService.sumAmount(" where t.userid=? ", new Object[]{userid});
+        //已提现金额
+        double applyAmount = insPayApplyService.sumAmount(" where t.userid=? and t.applytype=?", new Object[]{userid, "A"});
+        double accountBalance = sumAmount - applyAmount;
+        if (amount > accountBalance) {
+            return HttpResult.error("可提现余额不足");
+        }
+        InsPayApply apply = new InsPayApply();
+        String applyno = IdGenerate.nextId();
+        SysUser user = sysUserService.getById(userid);
+        if (user == null) {
+            httpResult.setMsg("userId不存在");
+            return httpResult;
+        }
+        apply.setApplyno(applyno);
+        apply.setUserid(userid);
+        apply.setUsername(user.getName());
+        apply.setDeptid(user.getDeptId());
+        SysDept dept = sysDeptService.getById(user.getDeptId());
+        apply.setDeptname(dept == null ? "" : dept.getName());
+        BigDecimal decimal = new BigDecimal(accountBalance);
+        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
+        apply.setAccountbalance(decimal.doubleValue());
+        apply.setApplyamount(amount);
+        decimal = new BigDecimal(accountBalance - amount);
+        decimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
+        apply.setBalance(decimal.doubleValue());
+        apply.setDisrate("");
+        //查询详情信息
+        SysUserInfo userInfo = sysUserInfoService.getById(userid);
+        apply.setBankname(userInfo.getBankName());
+        apply.setAccountno(userInfo.getAccountno());
+        apply.setApplystatus("0"); //0申请中 1支付中 2已支付
+        apply.setApplytype("A");  //A跟单绩效  B推广佣金
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        apply.setCreatetime(sdf.format(new Date()));
+
+        insPayApplyService.insert(apply);
+
+        return HttpResult.ok("保存成功");
+    }
 
     /**
      * 提现审核

+ 2 - 0
src/main/java/com/ydtech/modules/ins/dao/InsPayApplyDao.java

@@ -20,6 +20,8 @@ public interface InsPayApplyDao {
 
     public PageResult selectPaging(int pageNumber, int pageSize, String whereCase, Object[] paramValues);
 
+    public PageResult selectAccountPaging(int pageNumber, int pageSize, String whereCase, Object[] paramValues);
+
     public Integer insert(InsPayApply model);
 
     public Integer update(InsPayApply model);

+ 48 - 0
src/main/java/com/ydtech/modules/ins/dao/impl/InsPayApplyDaoImpl.java

@@ -4,6 +4,7 @@ import com.github.drinkjava2.jdialects.Dialect;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.ins.dao.InsPayApplyDao;
 import com.ydtech.modules.ins.model.InsPayApply;
+import com.ydtech.modules.ins.model.InsUserAccount;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
@@ -58,6 +59,30 @@ public class InsPayApplyDaoImpl implements InsPayApplyDao {
         }
     }
 
+    public static class InsUserAccountRowMapper implements RowMapper {
+        public InsUserAccount mapRow(ResultSet resultSet, int rowNum) throws SQLException {
+            InsUserAccount model = new InsUserAccount();
+
+            model.setMobile(resultSet.getString("mobile"));
+            model.setUserid(resultSet.getString("userid"));
+            model.setUsername(resultSet.getString("username"));
+            model.setDeptid(resultSet.getString("deptid"));
+            model.setDeptname(resultSet.getString("deptname"));
+            model.setTotalfee(resultSet.getDouble("totalfee"));
+            model.setFxtotalfee(resultSet.getDouble("fxtotalfee"));
+            model.setApplyfee(resultSet.getDouble("applyfee"));
+            model.setPayamount(resultSet.getDouble("payamount"));
+            model.setApply(resultSet.getDouble("apply"));
+            model.setBalance(resultSet.getDouble("balance"));
+            model.setFxapplyfee(resultSet.getDouble("fxapplyfee"));
+            model.setFxpayamount(resultSet.getDouble("fxpayamount"));
+            model.setFxapply(resultSet.getDouble("fxapply"));
+            model.setFxbalance(resultSet.getDouble("fxbalance"));
+
+            return model;
+        }
+    }
+
     @Override
     public InsPayApply selectByPk(String orderno) {
         String sql = " select t.applyno,t.userid,t.username,t.deptid,t.deptname,t.accountbalance,t.applyamount,t.balance,t.disrate,t.bankname,t.accountno,t.createtime,t.paytime,t.auditid,t.auditname,t.applystatus,t.applytype from ins_pay_apply t  where applyno=? ";
@@ -124,6 +149,29 @@ public class InsPayApplyDaoImpl implements InsPayApplyDao {
         return pageResult;
     }
 
+    public PageResult selectAccountPaging(int pageNumber, int pageSize, String whereCase, Object[] paramValues) {
+
+        Dialect dialect = Dialect.guessDialect(dataSource);
+        String sql = dialect.pagin(pageNumber, pageSize, "select mobile,userid,username,deptid,deptname,totalfee,fxtotalfee,applyfee,payamount,apply,balance,fxapplyfee,fxpayamount,fxapply,fxbalance from v_user_account t  " + whereCase);
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+        List<InsUserAccount> recordList = jdbcTemplate.query(sql, paramValues, new InsUserAccountRowMapper());
+
+        int totalCount = countAccount(whereCase, paramValues);
+
+        PageResult pageResult = new PageResult(pageNumber, pageSize, totalCount, recordList);
+
+        return pageResult;
+    }
+
+    public Integer countAccount(String whereCase, Object[] paramValues) {
+        String sql = "select count(1) from v_user_account t " + whereCase;
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+
+        return jdbcTemplate.queryForObject(sql, paramValues, Integer.class);
+    }
+
 
     @Override
     public Integer insert(InsPayApply model) {

+ 140 - 0
src/main/java/com/ydtech/modules/ins/model/InsUserAccount.java

@@ -0,0 +1,140 @@
+package com.ydtech.modules.ins.model;
+
+public class InsUserAccount {
+
+    private String userid;
+    private String username;
+    private String mobile;
+    private String deptid;
+    private String deptname;
+    private double totalfee;
+    private double fxtotalfee;
+    private double applyfee;
+    private double payamount;
+    private double apply;
+    private double balance;
+    private double fxapplyfee;
+    private double fxpayamount;
+    private double fxapply;
+    private double fxbalance;
+
+    public String getUserid() {
+        return userid;
+    }
+
+    public void setUserid(String userid) {
+        this.userid = userid;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getDeptid() {
+        return deptid;
+    }
+
+    public void setDeptid(String deptid) {
+        this.deptid = deptid;
+    }
+
+    public String getDeptname() {
+        return deptname;
+    }
+
+    public void setDeptname(String deptname) {
+        this.deptname = deptname;
+    }
+
+    public double getTotalfee() {
+        return totalfee;
+    }
+
+    public void setTotalfee(double totalfee) {
+        this.totalfee = totalfee;
+    }
+
+    public double getFxtotalfee() {
+        return fxtotalfee;
+    }
+
+    public void setFxtotalfee(double fxtotalfee) {
+        this.fxtotalfee = fxtotalfee;
+    }
+
+    public double getApplyfee() {
+        return applyfee;
+    }
+
+    public void setApplyfee(double applyfee) {
+        this.applyfee = applyfee;
+    }
+
+    public double getPayamount() {
+        return payamount;
+    }
+
+    public void setPayamount(double payamount) {
+        this.payamount = payamount;
+    }
+
+    public double getApply() {
+        return apply;
+    }
+
+    public void setApply(double apply) {
+        this.apply = apply;
+    }
+
+    public double getBalance() {
+        return balance;
+    }
+
+    public void setBalance(double balance) {
+        this.balance = balance;
+    }
+
+    public double getFxapplyfee() {
+        return fxapplyfee;
+    }
+
+    public void setFxapplyfee(double fxapplyfee) {
+        this.fxapplyfee = fxapplyfee;
+    }
+
+    public double getFxpayamount() {
+        return fxpayamount;
+    }
+
+    public void setFxpayamount(double fxpayamount) {
+        this.fxpayamount = fxpayamount;
+    }
+
+    public double getFxapply() {
+        return fxapply;
+    }
+
+    public void setFxapply(double fxapply) {
+        this.fxapply = fxapply;
+    }
+
+    public double getFxbalance() {
+        return fxbalance;
+    }
+
+    public void setFxbalance(double fxbalance) {
+        this.fxbalance = fxbalance;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+}