package com.stylefeng.guns.modular.api; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.base.tips.ErrorTip; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.core.util.JwtTokenUtil; import com.stylefeng.guns.modular.system.dao.UserMapper; import com.stylefeng.guns.modular.system.model.TAgent; import com.stylefeng.guns.modular.system.model.User; import com.stylefeng.guns.modular.system.service.ITAgentService; import com.stylefeng.guns.modular.system.util.MallBook.model.BindAccount; import com.stylefeng.guns.modular.system.util.MallBook.model.InterfaceResponse; import com.stylefeng.guns.modular.system.util.MallBook.util.TrhRequest; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.credential.HashedCredentialsMatcher; import org.apache.shiro.crypto.hash.Md5Hash; import org.apache.shiro.util.ByteSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.HashMap; /** * 接口控制器提供 * * @author stylefeng * @Date 2018/7/20 23:39 */ @RestController @RequestMapping("") public class ApiController extends BaseController { @Autowired private ITAgentService tAgentService; @ResponseBody @PostMapping("/base/driver/microenterpriseCallback") public void microenterpriseCallback(@RequestBody InterfaceResponse response){ if("0000".equals(response.getCode())){ JSONObject jsonObject = JSON.parseObject(response.getResult()); String status = jsonObject.getString("status"); String parameter1 = jsonObject.getString("parameter1"); TAgent tAgent = tAgentService.selectById(parameter1); if("2".equals(status)){ tAgent.setMerchantStatus(2); tAgentService.updateById(tAgent); System.err.println("注册代理商子商户失败"); } if("0".equals(status)){ tAgent.setMerchantStatus(0); tAgentService.updateById(tAgent); System.err.println("注册代理商子商户处理中"); } if("1".equals(status)){ String userId = jsonObject.getString("userId"); tAgent.setMerchantNumber(userId); tAgent.setMerchantStatus(1); tAgentService.updateById(tAgent); //开始绑定结算账户 BindAccount bindAccount = new BindAccount(); bindAccount.setUserId(tAgent.getMerchantNumber()); bindAccount.setCertId(tAgent.getMerchantIDCode()); bindAccount.setCardName(tAgent.getCardName()); bindAccount.setCardNo(tAgent.getCardNo()); bindAccount.setBankAcctType(tAgent.getBankAcctType().toString()); bindAccount.setPhone(tAgent.getPhone()); bindAccount.setBankCode(tAgent.getBankCode()); /** * 省份编码 */ bindAccount.setProvCode("0035"); /** * 地区编码 */ bindAccount.setAreaCode("3501"); TrhRequest request = new TrhRequest(); InterfaceResponse execute = request.execute(bindAccount, BindAccount.SERVICE_CODE); if("0000".equals(execute.getCode())){ JSONObject jsonObject1 = JSON.parseObject(execute.getResult()); String status1 = jsonObject1.getString("status"); if("2".equals(status1)){ tAgent.setBankStatus(2); tAgentService.updateById(tAgent); System.err.println("绑定结算账户失败" ); } if("1".equals(status1)){ tAgent.setBankStatus(1); tAgentService.updateById(tAgent); System.err.println("绑定结算账户成功"); } if("0".equals(status1)){ tAgent.setBankStatus(0); tAgentService.updateById(tAgent); System.err.println("绑定结算账户处理中"); } }else{ System.err.println("绑定结算账户失败:" + execute.getMsg()); } } }else{ System.err.println("注册代理商子商户异常:" + response.getMsg()); } } }