Commit edce0a6c by 黄森林

app开发

parent 640da9e1
...@@ -249,6 +249,7 @@ public class PackageUpgradeController extends BaseController { ...@@ -249,6 +249,7 @@ public class PackageUpgradeController extends BaseController {
order.setHehuorenSchool(schoolName); order.setHehuorenSchool(schoolName);
order.setHehuorenPhone(sysUser.getPhone()); order.setHehuorenPhone(sysUser.getPhone());
Integer insert = orderMapper.insert(order); Integer insert = orderMapper.insert(order);
packageUpgradeMapper.inserOrderHis(id, "下单成功", date);
// MessageUtil.sent(contactNumber,"4",""); // MessageUtil.sent(contactNumber,"4","");
if (StringUtils.isNotBlank(mark)) { if (StringUtils.isNotBlank(mark)) {
String id1 = UUID.randomUUID().toString(); String id1 = UUID.randomUUID().toString();
...@@ -267,14 +268,12 @@ public class PackageUpgradeController extends BaseController { ...@@ -267,14 +268,12 @@ public class PackageUpgradeController extends BaseController {
yangChengTong.setContactPhone(contactNumber); yangChengTong.setContactPhone(contactNumber);
yangChengTong.setCustomerPhone(businessNumber); yangChengTong.setCustomerPhone(businessNumber);
insert += yangChengTongrMapper.insert(yangChengTong); insert += yangChengTongrMapper.insert(yangChengTong);
packageUpgradeMapper.inserOrderHis(id1, "下单成功", date);
return ResponseData.success(id+":"+id1,"下单成功!");
} }
if (insert == 1) { if (insert == 1) {
packageUpgradeMapper.inserOrderHis(id, "下单成功", date);
return ResponseData.success(id); return ResponseData.success(id);
} }
if (insert == 3) {
return ResponseData.success("下单成功!");
}
return ResponseData.error("升级失败!"); return ResponseData.error("升级失败!");
} }
......
package com.winsun.constant; package com.winsun.constant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Author xuede * 排序
* @Date 2020/3/6 9:31 * @author Liph
* @Version 1.0 * @datetime 2019-09-19/9/27 11:19
*/ */
public enum FilePath { public enum FilePath {
//
BACKGROUNDIMG("套餐背景图片基础路径","BackgroundImg"); BACKGROUNDIMG("套餐背景图片基础路径","BackgroundImg"),
IDCARD("身份证明","packageNewClothes/images/idCard/");
FilePath(String name,String value){ FilePath(String id, String value) {
this.name=name; this.id = id;
this.value=value; this.value = value;
};
private static final Map<String, FilePath> DATAS = new HashMap<>();
static {
Arrays.asList(values()).forEach(data -> DATAS.put(data.getId(), data));
} }
private String name; private String id;
private String value; private String value;
public String getId() {
public String getName() { return id;
return name;
} }
public String getValue() { public String getValue() {
return value; return value;
} }
public static FilePath findById(String id) {
return DATAS.getOrDefault(id, null);
}
} }
...@@ -36,6 +36,9 @@ public interface PackageUpgradeMapper extends BaseMapper<PackageUpgrade> { ...@@ -36,6 +36,9 @@ public interface PackageUpgradeMapper extends BaseMapper<PackageUpgrade> {
@Select("select school_name schoolName from `hhr_school` where id = #{schoolId}") @Select("select school_name schoolName from `hhr_school` where id = #{schoolId}")
String selectSchoolById(String schoolId); String selectSchoolById(String schoolId);
@Select("select user_id userId from `hhr_supervisor_school` where school = #{schoolId} ORDER BY user_id asc")
List<String> selectsupervisorBySchool(String schoolId);
@Select("select package_id packageId from `hhr_school_package` where school_id = #{schoolId}") @Select("select package_id packageId from `hhr_school_package` where school_id = #{schoolId}")
List<String> selectPackageId(String schoolId); List<String> selectPackageId(String schoolId);
......
package com.winsun.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* HTTP请求封装
*
*
*/
public class HttpHelper {
private static Logger log = LoggerFactory.getLogger(HttpHelper.class);
/**
* @desc :1.发起GET请求
*
* @param url
* @return JSONObject
* @throws Exception
*/
public static JSONObject doGet(String url) throws Exception {
//1.生成一个请求
HttpGet httpGet = new HttpGet(url);
//2.配置请求的属性
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//2000
httpGet.setConfig(requestConfig);
//3.发起请求,获取响应信息
//3.1 创建httpClient
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
//3.2 发起请求,获取响应信息
response = httpClient.execute(httpGet, new BasicHttpContext());
//如果返回结果的code不等于200,说明出错了
if (response.getStatusLine().getStatusCode() != 200) {
/* log.info("request url failed, http code=" + response.getStatusLine().getStatusCode()
+ ", url=" + url);*/
return null;
}
//4.解析请求结果
HttpEntity entity = response.getEntity(); //reponse返回的数据在entity中
if (entity != null) {
String resultStr = EntityUtils.toString(entity, "utf-8"); //将数据转化为string格式
// log.info("GET请求结果:"+resultStr);
JSONObject result = JSON.parseObject(resultStr); //将String转换为 JSONObject
if(result.getInteger("errcode")==null) {
return result;
}else if (0 == result.getInteger("errcode")) {
return result;
}else {
// log.info("request url=" + url + ",return value="+resultStr);
// log.info(resultStr);
int errCode = result.getInteger("errcode");
String errMsg = result.getString("errmsg");
throw new Exception("error code:"+errCode+", error message:"+errMsg);
}
}
} catch (IOException e) {
log.info( e.getMessage());
} finally {
if (response != null) try {
response.close(); //释放资源
} catch (IOException e) {
e.printStackTrace();
}
if(httpClient!=null){
httpClient.close();
}
}
return null;
}
/** 2.发起POST请求
* @desc :
*
* @param url 请求url
* @param data 请求参数(json)
* @return
* @throws Exception JSONObject
*/
public static JSONObject doPost(String url, String data) throws Exception {
//1.生成一个请求
HttpPost httpPost = new HttpPost(url);
//2.配置请求属性
//2.1 设置请求超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(100000).setConnectTimeout(100000).build();
httpPost.setConfig(requestConfig);
//2.2 设置数据传输格式-json
httpPost.addHeader("Content-Type", "application/json");
//2.3 设置请求实体,封装了请求参数
StringEntity requestEntity = new StringEntity(data, "utf-8");
httpPost.setEntity(requestEntity);
//3.发起请求,获取响应信息
//3.1 创建httpClient
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
//3.3 发起请求,获取响应
response = httpClient.execute(httpPost, new BasicHttpContext());
if (response.getStatusLine().getStatusCode() != 200) {
log.info("request url failed, http code=" + response.getStatusLine().getStatusCode()
+ ", url=" + url);
return null;
}
//获取响应内容
HttpEntity entity = response.getEntity();
if (entity != null) {
String resultStr = EntityUtils.toString(entity, "utf-8");
// log.info("POST请求结果:"+resultStr);
//解析响应内容
JSONObject result = JSON.parseObject(resultStr);
if(result.getInteger("errcode")==null) {
return result;
}else if (0 == result.getInteger("errcode")) {
return result;
}else {
/* log.info("request url=" + url + ",return value="+resultStr);*/
//log.info(resultStr);
int errCode = result.getInteger("errcode");
String errMsg = result.getString("errmsg");
throw new Exception("error code:"+errCode+", error message:"+errMsg);
}
}
} catch (IOException e) {
log.error(e.getMessage());
e.printStackTrace();
} finally {
if (response != null) try {
response.close(); //释放资源
} catch (IOException e) {
e.printStackTrace();
}
if(httpClient!=null){
httpClient.close();
}
}
return null;
}
}
package com.winsun.utils;
import lombok.extern.slf4j.Slf4j;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@Slf4j
public class MD5Utils {
/**
* 使用md5的算法进行加密
*/
public static String md5(String plainText) {
byte[] secretBytes = null;
try {
secretBytes = MessageDigest.getInstance("md5").digest(
plainText.getBytes());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("没有md5这个算法!");
}
// 16进制数字
String md5code = new BigInteger(1, secretBytes).toString(16);
// 如果生成数字未满32位,需要前面补0
for (int i = 0; i < 32 - md5code.length(); i++) {
md5code = "0" + md5code;
}
return md5code;
}
public static String getDigestStr(String info) {
try {
byte[] res = info.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] result = md.digest(res);
for (int i = 0; i < result.length; i++) {
md.update(result[i]);
}
byte[] hash = md.digest();
StringBuffer d = new StringBuffer("");
for (int i = 0; i < hash.length; i++) {
int v = hash[i] & 0xFF;
if (v < 16) {
d.append("0");
}
d.append(Integer.toString(v, 16).toUpperCase());
}
return d.toString();
} catch (Exception e) {
return null;
}
}
}
package com.winsun.utils;
import com.alibaba.fastjson.JSONObject;
import com.winsun.auth.core.common.model.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 小白卡调取接口工具类
* @Author: chancy
* @Date: 2020/3/5 16:26
*/
@Slf4j
public class XbkUtil {
public static JSONObject xbkCreate(Map<String, Object> map, String type){
Map<String, Object> mapParm = new HashMap<>();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String tablename = dateFormat.format(now);
mapParm.put("sysNum", 10026);
mapParm.put("intfCode", type);
mapParm.put("eventTime", tablename);
String s = MD5Utils.md5(tablename + "gzxy951753@.123");
mapParm.put("sign", s.toUpperCase());
JSONObject jsonObject = httpDoPost(map, mapParm, type);
return jsonObject;
}
public static JSONObject httpDoPost(Map<String, Object> map, Map<String, Object> mapParm, String type){
mapParm.put("param", map);
JSONObject json = new JSONObject(mapParm);
JSONObject jsonObject = null;
try { jsonObject = HttpHelper.doPost("http://enter.gd189.cn:9090/o2oweb/outMain/service.do", json.toString());
}catch (Exception e){
log.info(type+"调取接口异常",e.getMessage());
}
return jsonObject;
}
/**
* 小白下单接口 JT0002
*
*
* @param customerName 用户姓名
* @param contactNumber 联系电话
* @param idCard 用户身份证
* @param businessNumber 办理号码
* @param cardId 套餐ID
* @param partner 用户ID
* @return
*/
public static JSONObject xbkOrderJT0002(String cardId, String partner,String businessNumber, String idCard,
String customerName,String contactNumber,String xbId ,String netId) throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("prodId", xbId);
map.put("coUserId", netId);
map.put("phoneNumber", businessNumber);
map.put("isDelivery", "0");
map.put("custName", customerName);
map.put("idCardNo", idCard);
map.put("contactNumber", contactNumber);
map.put("sendSms", "0");
map.put("openChannel", "WECHAT");
String type = "JT0002";
JSONObject jsonObject = XbkUtil.xbkCreate(map, type);
return jsonObject;
}
/**
* 身份证校验 JT0005
*
* @param customerName 用户姓名
* @param idCard 用户身份证
* @return
*/
public static JSONObject idCardCheckJT0005(String idCard,String customerName) throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("custName", customerName);
map.put("idCardNo", idCard);
String type = "JT0005";
JSONObject jsonObject = XbkUtil.xbkCreate(map, type);
return jsonObject;
}
/**
* 订单详情 JT0006
*
* @param orderCode 订单编号
* @return
*/
public static JSONObject orderInfoJT0006(String orderCode) throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("orderCode", orderCode);
String type = "JT0006";
JSONObject jsonObject = XbkUtil.xbkCreate(map, type);
return jsonObject;
}
/**
* 手机号码获取 JT0001
*
* @return
*/
public static JSONObject getNumberJT0001(String contNumber,String xbId,String netId) throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("prodId", xbId);
map.put("coUserId", netId);
map.put("pageIndex", "0");
map.put("pageSize", "6");
if (StringUtils.isNotBlank(contNumber)) {
map.put("contNumber", contNumber);
}
String type = "JT0001";
JSONObject jsonObject = XbkUtil.xbkCreate(map, type);
return jsonObject;
}
}
package com.winsun.controller; package com.winsun.controller;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.enums.SqlLike; import com.baomidou.mybatisplus.enums.SqlLike;
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
...@@ -9,7 +7,6 @@ import com.baomidou.mybatisplus.plugins.Page; ...@@ -9,7 +7,6 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.winsun.auth.core.annotion.Permission; import com.winsun.auth.core.annotion.Permission;
import com.winsun.auth.core.base.controller.BaseController; import com.winsun.auth.core.base.controller.BaseController;
import com.winsun.auth.core.common.model.ResponseData; import com.winsun.auth.core.common.model.ResponseData;
import com.winsun.auth.core.shiro.ShiroUser;
import com.winsun.bean.Package; import com.winsun.bean.Package;
import com.winsun.bean.SchoolPackage; import com.winsun.bean.SchoolPackage;
import com.winsun.constant.FilePath; import com.winsun.constant.FilePath;
...@@ -26,9 +23,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -26,9 +23,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*; import java.util.*;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment