puzhibing
2023-08-14 753c4aede53b07041841d9aa94859b59e366bd5d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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<BindAccount> 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());
        }
    }
 
}