123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /*
- *
- *
- *
- */
- package com.hboxs.control.admin;
- import com.hboxs.common.Constant;
- import com.hboxs.common.JoinpayConstant;
- import com.hboxs.common.JsonMessage;
- import com.hboxs.common.Message;
- import com.hboxs.joinpay.entity.Mch;
- import com.hboxs.service.AdminService;
- import com.hboxs.service.MchService;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.mvc.support.RedirectAttributes;
- import javax.annotation.Resource;
- /**
- * Controller - 汇聚支付 / 分销商
- */
- @Controller("adminJoinPayMchController")
- @RequestMapping("/asl-admin/joinPayMch")
- public class JoinPayMchController extends BaseController {
- @Resource(name = "adminServiceImpl")
- private AdminService adminService;
- @Resource(name = "mchServiceImpl")
- private MchService mchService;
- /**
- * 编辑
- */
- @RequestMapping(value = "/edit", method = RequestMethod.GET)
- public String edit(ModelMap model) throws InterruptedException {
- Mch mch = mchService.getUniqueness(adminService.getCurrent().getId());
- // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
- if (!StringUtils.isBlank(mch.getOrder_status())) {
- String result = mchService.refreshMch(mch);
- mchService.refreshMyAccount(mch);
- //获取协议内容
- // mchService.getQuerySignContent(mch);
- //签定协议
- // mchService.altMchSign(mch);
- //查看协议内容
- mchService.querySignRecord(mch);
- model.addAttribute("orderStatus", JoinpayConstant.order_status);
- model.addAttribute("mch", mch);
- return "/admin/joinpay/mch/edit";
- } else {
- return "/admin/joinpay/mch/add";
- }
- }
- /**
- * 创建新的
- */
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- public String save(Mch mch, RedirectAttributes redirectAttributes) {
- Mch pMch = mchService.getUniqueness(adminService.getCurrent().getId());
- String orderStatus = pMch.getOrder_status();
- // 已创建更新
- if (!StringUtils.isEmpty(orderStatus)) {
- addFlashMessage(redirectAttributes, Message.error("该账号已创建"));
- return "redirect:edit.htm";
- } else {
- // 未创建新增
- mch.setId(pMch.getId());
- mch.setAdminId(adminService.getCurrent().getId());
- String result = mchService.createMch(mch);
- if (!result.equals(Constant.correct_code)) {
- addFlashMessage(redirectAttributes, Message.error(result));
- return "redirect:edit.htm";
- }
- }
- addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
- return "redirect:edit.htm";
- }
- /**
- * 更新
- */
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public String update(Mch mch, RedirectAttributes redirectAttributes) {
- Mch pMch = mchService.getUniqueness(adminService.getCurrent().getId());
- String orderStatus = pMch.getOrder_status();
- // 已创建更新
- if (StringUtils.isEmpty(orderStatus)) {
- addFlashMessage(redirectAttributes, Message.error("该提现账号不存在"));
- return "redirect:edit.htm";
- } else {
- Mch _tempMch = new Mch();
- BeanUtils.copyProperties(pMch , _tempMch);
- String result = mchService.updateMch(_tempMch, mch.getLegal_person(), mch.getId_card_no(),
- mch.getAlt_merchant_type(), mch.getBank_account_name(), mch.getBank_account_no(), mch.getBank_channel_no());
- if (!result.equals(Constant.correct_code)) {
- addFlashMessage(redirectAttributes, Message.error(result));
- return "redirect:edit.htm";
- }
- pMch.setBank_account_type(mch.getBank_account_type());
- pMch.setLegal_person(mch.getLegal_person());
- pMch.setId_card_no(mch.getId_card_no());
- pMch.setAlt_merchant_type(mch.getAlt_merchant_type());
- pMch.setBank_account_name(mch.getBank_account_name());
- pMch.setBank_account_no(mch.getBank_account_no());
- pMch.setBank_channel_no(mch.getBank_channel_no());
- mchService.update(pMch);
- addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
- return "redirect:edit.htm";
- }
- }
- /**
- * 签约
- */
- @RequestMapping(value = "/altMchSign", method = RequestMethod.POST)
- @ResponseBody
- public JsonMessage altMchSign() {
- Long id = adminService.getCurrent().getId();
- Mch mch = mchService.getUniqueness(id);
- // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
- if (!StringUtils.isBlank(mch.getOrder_status())) {
- //签定协议
- String str =mchService.altMchSign(mch);
- return JsonMessage.success(str);
- } else {
- return null;
- }
- }
- @RequestMapping(value = "/altMchSign2", method = RequestMethod.POST)
- @ResponseBody
- public JsonMessage altMchSign2(Long id) {
- adminService.getCurrent().getId();
- Mch mch = mchService.getUniqueness(id);
- // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
- if (!StringUtils.isBlank(mch.getOrder_status())) {
- //签定协议
- String str =mchService.altMchSign(mch);
- return JsonMessage.success(str);
- } else {
- return JsonMessage.success("分销商商户状态为空");
- }
- }
- }
|