|
@@ -22,8 +22,10 @@ import org.springframework.stereotype.Service;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.zskk.shop.dao.entry.Appointment;
|
|
|
import com.zskk.shop.dao.entry.BuyOrder;
|
|
|
import com.zskk.shop.dao.entry.FamilyPeople;
|
|
|
+import com.zskk.shop.dao.entry.GoodBase;
|
|
|
import com.zskk.shop.exception.ErrorConstant;
|
|
|
import com.zskk.shop.exception.ZSKKException;
|
|
|
import com.zskk.shop.utils.HttpClient;
|
|
@@ -38,6 +40,9 @@ public class TJCenterService {
|
|
|
|
|
|
@Value("${zskk.tjkey}")
|
|
|
private String tjkey;
|
|
|
+
|
|
|
+ @Value("${zskk.myhost}")
|
|
|
+ private String myhost;
|
|
|
|
|
|
public List<String> getDJDetail(String id) {
|
|
|
String url = tjcenter + "/public/api.php/shop/getPackageDetail?id=" + id;
|
|
@@ -62,20 +67,42 @@ public class TJCenterService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public String appointment(FamilyPeople people, BuyOrder order, String atime, String extend) {
|
|
|
+ public String appointment(FamilyPeople people, BuyOrder order, GoodBase good, String atime, String extend) {
|
|
|
// 调用体检系统 预约
|
|
|
Map<String, String> data = new HashMap<>();
|
|
|
- data.put("name", people.getName());
|
|
|
+ data.put("outer_key", people.getId().toString());
|
|
|
+ data.put("role_name", people.getName());
|
|
|
data.put("cardtype", "身份证");
|
|
|
data.put("idcard", people.getIdcard());
|
|
|
data.put("sex", people.getSex().equals(0) ? "2" : "1"); // 体检系统 1:男 2:女
|
|
|
data.put("vip", "0");
|
|
|
data.put("age", this.getAge(people.getBirth()));
|
|
|
data.put("birth", people.getBirth());
|
|
|
- data.put("package_id", this.getPackageId(order));
|
|
|
+ data.put("package_id", good.getPackageid());
|
|
|
+ data.put("package_name", good.getPackageName());
|
|
|
data.put("maketime", atime);
|
|
|
data.put("phone", people.getPhone());
|
|
|
+ data.put("callback_url", myhost + "tj/callback");
|
|
|
+
|
|
|
+ String url = tjcenter + "public/api.php/shop/addSubscribe";
|
|
|
+ String content = this.doPost(url, data);
|
|
|
+ JSONObject obj = JSON.parseObject(content);
|
|
|
+ if (obj.containsKey("code") && obj.getInteger("code").equals(1)) {
|
|
|
+ return obj.getJSONObject("data").getString("subscribe_id");
|
|
|
+ } else {
|
|
|
+ throw new ZSKKException(ErrorConstant.SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void cancelAppointment(FamilyPeople people, Appointment appointment){
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
+ data.put("id", appointment.getTjaid());
|
|
|
+ data.put("outer_key", people.getId().toString());
|
|
|
|
|
|
+ this.doPost(tjcenter + "public/api.php/shop/cancelSubscribe", data);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String doPost(String url, Map<String, String> data){
|
|
|
String main = JSON.toJSONString(data);
|
|
|
String nonce = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
String timestamp = ToolsUtil.getNow().toString();
|
|
@@ -89,15 +116,9 @@ public class TJCenterService {
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("main", main);
|
|
|
|
|
|
- String url = tjcenter + "public/api.php/shop/addSubscribe";
|
|
|
try{
|
|
|
String content = HttpClient.doPost(url, params, headers);
|
|
|
- JSONObject obj = JSON.parseObject(content);
|
|
|
- if (obj.containsKey("code") && obj.getInteger("code").equals(0)){
|
|
|
- return obj.getJSONObject("data").getString("id");
|
|
|
- }else{
|
|
|
- throw new ZSKKException(ErrorConstant.SERVER_ERROR);
|
|
|
- }
|
|
|
+ return content;
|
|
|
}catch (Exception e) {
|
|
|
LogUtil.sysError(e.getMessage(), e);
|
|
|
throw new ZSKKException(ErrorConstant.NET_ERROR);
|
|
@@ -121,11 +142,6 @@ public class TJCenterService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 获取套餐ID
|
|
|
- private String getPackageId(BuyOrder order) {
|
|
|
- return "";
|
|
|
- }
|
|
|
-
|
|
|
private String sign(String main, String nonce, String timestamp, String secretKey){
|
|
|
StringBuffer content = new StringBuffer(main.length() + 50);
|
|
|
content.append(main).append(":").append(nonce).append(":").append(timestamp);
|