UserKitingAction.java 2.92 KB
package com.cjs.site.action.user.fund;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.cjs.site.biz.user.fund.FundBiz;
import com.cjs.site.biz.user.fund.UserKitingBiz;
import com.cjs.site.dao.user.account.ClientInfoDao;
import com.cjs.site.dao.user.fund.UserKitingDao;
import com.cjs.site.util.lang.StringUtil;
import com.cjs.site.util.web.ActionUtil;
import com.cjs.site.util.web.PageUtils;
import com.cjs.site.util.web.Token;

/**
 * 客户提现
 * 
 * @author tongyufu
 *
 */
@Controller
@RequestMapping("/user")
public class UserKitingAction {

    @Autowired
    private FundBiz       fundBiz;
    @Autowired
    private UserKitingBiz userKitingBiz;
    @Autowired
    private ClientInfoDao clientInfoDao;
    @Autowired
    private UserKitingDao userKitingDao;

    /**提现*/
    @Token(save = true, group = "kiting")
    @RequestMapping(value = "kiting", method = RequestMethod.GET)
    public String kiting(@RequestParam Map<String, Object> params, Model model) {
        String userId = ActionUtil.getUser().getClient_id();
        Map<String, String> bank = clientInfoDao.queryForPnr(userId);
        //String bankAccount = bank.get("BANK_ACCOUNT");
        //bank.put("BANK_ACCOUNT", StringUtil.replace(4, 4, bankAccount, "*"));
        String clientName = bank.get("CLIENT_NAME").toString();
        clientName = "*" + clientName.substring(1);
        bank.put("CLIENT_NAME", clientName);
        model.addAttribute("bank", bank);
        model.addAttribute("balance", fundBiz.balanceSelf(userId));

        if (StringUtil.isBlank(params.get("_limit"))) {
            params.put("_limit", 10);
        }
        PageUtils.processPage(params);
        model.addAttribute("orders", userKitingBiz.search(params));
        params.put("_total", userKitingDao.searchTotal(ActionUtil.getUser().getClient_id()));
        model.addAttribute("params", params);
        model.addAttribute("subBranch", userKitingBiz.querySubBranch());
        return "user/fund/kiting.jsp";
    }

    /**提现*/
    @Token(remove = true, group = "kiting")
    @RequestMapping(value = "kiting", method = RequestMethod.POST)
    public String kiting(@RequestParam("subBranch") String subBranch,
                         @RequestParam("amount") Double amount,
                         @RequestParam("validCode") String validCode, HttpSession session,
                         RedirectAttributes atts) {
        atts.addFlashAttribute("message",
            userKitingBiz.kiting(subBranch, amount, validCode, session));
        return "redirect:/user/kiting";
    }

}