|
|
@@ -13,6 +13,7 @@ import common.model.User;
|
|
|
import common.utils.http.MyController;
|
|
|
import common.utils.http.MyRet;
|
|
|
import common.utils.http.VerifyCode;
|
|
|
+import common.utils.hyg.AESUtils;
|
|
|
import common.utils.jdcloud.SMS;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
@@ -228,31 +229,40 @@ public class UserController extends MyController {
|
|
|
// 慧用工签约回调地址
|
|
|
public void hygSign() {
|
|
|
JSONObject requestBodyJson = MyController.getJsonModelByRequestAndType(getRequest(), JSONObject.class);
|
|
|
+ String businessBodyEncryptedHex = requestBodyJson.getString("businessBody");
|
|
|
|
|
|
- System.out.println(System.currentTimeMillis() + "有人请求hygSign" + requestBodyJson);
|
|
|
-
|
|
|
- Map<String, Object> responseJson = new HashMap<>();
|
|
|
- responseJson.put("statusCode", "000000");
|
|
|
- responseJson.put("statusText", "回调成功");
|
|
|
-
|
|
|
- // 获取所有参数的 Map (键值对形式)
|
|
|
- Map<String, String[]> paraMap = getParaMap(); // 注意: 这里的 value 是 String[],因为一个参数名可能对应多个值
|
|
|
+ try {
|
|
|
+ String body = AESUtils.decryptByHex(businessBodyEncryptedHex, System.getenv("HYG_AES_SECRET_KEY"));
|
|
|
+ JSONObject businessBody = JSONObject.parseObject(body);
|
|
|
+
|
|
|
+ String workerId = businessBody.getString("workerId");
|
|
|
+ String agreeState = businessBody.getString("agreeState");
|
|
|
+ String workerMobile = businessBody.getString("workerMobile");
|
|
|
+ User user = service.findUserByMobileNumber(workerMobile);
|
|
|
+
|
|
|
+ // 签约成功,则赋予用户workerId
|
|
|
+ if (agreeState.equals("2")) {
|
|
|
+ user.setHygWorkerId(workerId);
|
|
|
+ }
|
|
|
+ // 无论成功与否,签约结果都放到数据库,方便维护
|
|
|
+ user.setHygSignRst(businessBody.toJSONString());
|
|
|
+ // 对user进行升级
|
|
|
+ user.update();
|
|
|
|
|
|
- // 如果想获取单个值,可以使用 paraMap.get("paramName")[0] (要小心 null 或索引越界)
|
|
|
- // 更推荐使用 getPara() 获取单个值
|
|
|
- for (Map.Entry<String, String[]> entry : paraMap.entrySet()) {
|
|
|
- System.out.println("Sign ParaMap Name: " + entry.getKey() + ", Values: " + String.join(",", entry.getValue()));
|
|
|
- }
|
|
|
+ System.out.println(businessBody.toJSONString());
|
|
|
|
|
|
-// if (StrKit.notBlank(workerid)) {
|
|
|
-// System.out.println(workerid);
|
|
|
-//// renderText(service.update(hygSign));
|
|
|
-// renderText("ok");
|
|
|
-// } else {
|
|
|
-// renderText("");
|
|
|
-// }
|
|
|
-
|
|
|
- renderJson(responseJson);
|
|
|
+ Map<String, Object> responseJson = new HashMap<>();
|
|
|
+ responseJson.put("statusCode", "000000");
|
|
|
+ responseJson.put("statusText", "回调成功");
|
|
|
+
|
|
|
+ renderJson(responseJson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Map<String, Object> responseJson = new HashMap<>();
|
|
|
+ responseJson.put("statusCode", "100000");
|
|
|
+ responseJson.put("statusText", "回调失败,解密出现错误 " + e.getMessage());
|
|
|
+
|
|
|
+ renderJson(responseJson);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Before(LoginInterceptor.class)
|
|
|
@@ -266,6 +276,8 @@ public class UserController extends MyController {
|
|
|
|
|
|
renderJson(MyRet.fail("登录信息失效,请重新登录。").setCode(MyRet.CODE_NO_LOGIN));
|
|
|
} else {
|
|
|
+ setSessionAttr("role", user.getRole().toString());
|
|
|
+
|
|
|
renderJson(MyRet.ok("获取成功").setData(user));
|
|
|
}
|
|
|
}
|