JoinPayMchController.java 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. *
  3. *
  4. *
  5. */
  6. package com.hboxs.control.admin;
  7. import com.hboxs.common.Constant;
  8. import com.hboxs.common.JoinpayConstant;
  9. import com.hboxs.common.JsonMessage;
  10. import com.hboxs.common.Message;
  11. import com.hboxs.joinpay.entity.Mch;
  12. import com.hboxs.service.AdminService;
  13. import com.hboxs.service.MchService;
  14. import org.apache.commons.lang.StringUtils;
  15. import org.springframework.beans.BeanUtils;
  16. import org.springframework.stereotype.Controller;
  17. import org.springframework.ui.ModelMap;
  18. import org.springframework.web.bind.annotation.PostMapping;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.ResponseBody;
  22. import org.springframework.web.servlet.mvc.support.RedirectAttributes;
  23. import javax.annotation.Resource;
  24. /**
  25. * Controller - 汇聚支付 / 分销商
  26. */
  27. @Controller("adminJoinPayMchController")
  28. @RequestMapping("/asl-admin/joinPayMch")
  29. public class JoinPayMchController extends BaseController {
  30. @Resource(name = "adminServiceImpl")
  31. private AdminService adminService;
  32. @Resource(name = "mchServiceImpl")
  33. private MchService mchService;
  34. /**
  35. * 编辑
  36. */
  37. @RequestMapping(value = "/edit", method = RequestMethod.GET)
  38. public String edit(ModelMap model) throws InterruptedException {
  39. Mch mch = mchService.getUniqueness(adminService.getCurrent().getId());
  40. // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
  41. if (!StringUtils.isBlank(mch.getOrder_status())) {
  42. String result = mchService.refreshMch(mch);
  43. mchService.refreshMyAccount(mch);
  44. //获取协议内容
  45. // mchService.getQuerySignContent(mch);
  46. //签定协议
  47. // mchService.altMchSign(mch);
  48. //查看协议内容
  49. mchService.querySignRecord(mch);
  50. model.addAttribute("orderStatus", JoinpayConstant.order_status);
  51. model.addAttribute("mch", mch);
  52. return "/admin/joinpay/mch/edit";
  53. } else {
  54. return "/admin/joinpay/mch/add";
  55. }
  56. }
  57. /**
  58. * 创建新的
  59. */
  60. @RequestMapping(value = "/save", method = RequestMethod.POST)
  61. public String save(Mch mch, RedirectAttributes redirectAttributes) {
  62. Mch pMch = mchService.getUniqueness(adminService.getCurrent().getId());
  63. String orderStatus = pMch.getOrder_status();
  64. // 已创建更新
  65. if (!StringUtils.isEmpty(orderStatus)) {
  66. addFlashMessage(redirectAttributes, Message.error("该账号已创建"));
  67. return "redirect:edit.htm";
  68. } else {
  69. // 未创建新增
  70. mch.setId(pMch.getId());
  71. mch.setAdminId(adminService.getCurrent().getId());
  72. String result = mchService.createMch(mch);
  73. if (!result.equals(Constant.correct_code)) {
  74. addFlashMessage(redirectAttributes, Message.error(result));
  75. return "redirect:edit.htm";
  76. }
  77. }
  78. addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
  79. return "redirect:edit.htm";
  80. }
  81. /**
  82. * 更新
  83. */
  84. @RequestMapping(value = "/update", method = RequestMethod.POST)
  85. public String update(Mch mch, RedirectAttributes redirectAttributes) {
  86. Mch pMch = mchService.getUniqueness(adminService.getCurrent().getId());
  87. String orderStatus = pMch.getOrder_status();
  88. // 已创建更新
  89. if (StringUtils.isEmpty(orderStatus)) {
  90. addFlashMessage(redirectAttributes, Message.error("该提现账号不存在"));
  91. return "redirect:edit.htm";
  92. } else {
  93. Mch _tempMch = new Mch();
  94. BeanUtils.copyProperties(pMch , _tempMch);
  95. String result = mchService.updateMch(_tempMch, mch.getLegal_person(), mch.getId_card_no(),
  96. mch.getAlt_merchant_type(), mch.getBank_account_name(), mch.getBank_account_no(), mch.getBank_channel_no());
  97. if (!result.equals(Constant.correct_code)) {
  98. addFlashMessage(redirectAttributes, Message.error(result));
  99. return "redirect:edit.htm";
  100. }
  101. pMch.setBank_account_type(mch.getBank_account_type());
  102. pMch.setLegal_person(mch.getLegal_person());
  103. pMch.setId_card_no(mch.getId_card_no());
  104. pMch.setAlt_merchant_type(mch.getAlt_merchant_type());
  105. pMch.setBank_account_name(mch.getBank_account_name());
  106. pMch.setBank_account_no(mch.getBank_account_no());
  107. pMch.setBank_channel_no(mch.getBank_channel_no());
  108. mchService.update(pMch);
  109. addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
  110. return "redirect:edit.htm";
  111. }
  112. }
  113. /**
  114. * 签约
  115. */
  116. @RequestMapping(value = "/altMchSign", method = RequestMethod.POST)
  117. @ResponseBody
  118. public JsonMessage altMchSign() {
  119. Long id = adminService.getCurrent().getId();
  120. Mch mch = mchService.getUniqueness(id);
  121. // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
  122. if (!StringUtils.isBlank(mch.getOrder_status())) {
  123. //签定协议
  124. String str =mchService.altMchSign(mch);
  125. return JsonMessage.success(str);
  126. } else {
  127. return null;
  128. }
  129. }
  130. @RequestMapping(value = "/altMchSign2", method = RequestMethod.POST)
  131. @ResponseBody
  132. public JsonMessage altMchSign2(Long id) {
  133. adminService.getCurrent().getId();
  134. Mch mch = mchService.getUniqueness(id);
  135. // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
  136. if (!StringUtils.isBlank(mch.getOrder_status())) {
  137. //签定协议
  138. String str =mchService.altMchSign(mch);
  139. return JsonMessage.success(str);
  140. } else {
  141. return JsonMessage.success("分销商商户状态为空");
  142. }
  143. }
  144. /**
  145. * 发送身份证照片
  146. */
  147. @RequestMapping(value = "/sendCard", method = RequestMethod.POST)
  148. @ResponseBody
  149. public JsonMessage sendCard(Long id,String cardPositive,String cardNegative) {
  150. adminService.getCurrent().getId();
  151. Mch mch = mchService.getUniqueness(id);
  152. if(cardPositive==null||cardNegative==null){
  153. return JsonMessage.success("图片地址不能为空");
  154. }
  155. String[] string1 = cardPositive.split("\\.");
  156. String[] string2 = cardNegative.split("\\.");
  157. if(string1.length<2||string2.length<2){
  158. return JsonMessage.success("图片地址不规范,留意是否加入后缀名");
  159. }
  160. // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
  161. if (!StringUtils.isBlank(mch.getOrder_status())) {
  162. String str = mchService.sendCard(mch,cardPositive,cardNegative);
  163. return JsonMessage.success(str);
  164. } else {
  165. return JsonMessage.success("分销商商户状态为空");
  166. }
  167. }
  168. /**
  169. * 查询身份证照片审核状态
  170. */
  171. @RequestMapping(value = "/searchApprove", method = RequestMethod.POST)
  172. @ResponseBody
  173. public JsonMessage searchApprove(Long id) {
  174. adminService.getCurrent().getId();
  175. Mch mch = mchService.getUniqueness(id);
  176. // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
  177. if (!StringUtils.isBlank(mch.getOrder_status())) {
  178. //签定协议
  179. String str =mchService.searchApprove(mch);
  180. return JsonMessage.success(str);
  181. } else {
  182. return JsonMessage.success("分销商商户状态为空");
  183. }
  184. }
  185. }