修改号码牌。限制彩色信封尺寸

This commit is contained in:
2026-04-27 14:51:51 +08:00
parent 8ea3cc18c9
commit 4eeb45b64c
5 changed files with 167 additions and 156 deletions
@@ -0,0 +1,156 @@
package lingtao.net.util;
import okhttp3.*;
import java.io.IOException;
import java.util.Map;
public class HttpUtils {
private static final OkHttpClient HTTP_CLIENT = new OkHttpClient();
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final MediaType FORM = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8");
/**
* 通用HTTP GET请求方法
*
* @param url 请求地址
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendGetRequest(String url, Map<String, String> headers) {
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP GET请求方法(无请求头)
*
* @param url 请求地址
* @return 响应结果字符串
*/
public static String sendGetRequest(String url) {
return sendGetRequest(url, null);
}
/**
* 通用HTTP POST请求方法(JSON参数)
*
* @param url 请求地址
* @param jsonParam JSON参数
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendPostRequest(String url, String jsonParam, Map<String, String> headers) {
RequestBody body = RequestBody.create(JSON, jsonParam);
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url)
.post(body);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP POST请求方法(JSON参数,无请求头)
*
* @param url 请求地址
* @param jsonParam JSON参数
* @return 响应结果字符串
*/
public static String sendPostRequest(String url, String jsonParam) {
return sendPostRequest(url, jsonParam, null);
}
/**
* 通用HTTP POST请求方法(表单参数)
*
* @param url 请求地址
* @param formParams 表单参数映射
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendPostFormRequest(String url, Map<String, String> formParams, Map<String, String> headers) {
StringBuilder formBody = new StringBuilder();
if (formParams != null && !formParams.isEmpty()) {
for (Map.Entry<String, String> entry : formParams.entrySet()) {
if (formBody.length() > 0) {
formBody.append("&");
}
formBody.append(entry.getKey()).append("=").append(entry.getValue());
}
}
RequestBody body = RequestBody.create(FORM, formBody.toString());
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url)
.post(body);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP POST请求方法(表单参数,无请求头)
*
* @param url 请求地址
* @param formParams 表单参数映射
* @return 响应结果字符串
*/
public static String sendPostFormRequest(String url, Map<String, String> formParams) {
return sendPostFormRequest(url, formParams, null);
}
}
@@ -14,156 +14,11 @@ import java.util.Map;
public class HuaFangPriceUtil {
private static final OkHttpClient HTTP_CLIENT = new OkHttpClient();
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final MediaType FORM = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8");
private static final String userName = "001008";
private static final String password = "lt666888";
/**
* 通用HTTP GET请求方法
*
* @param url 请求地址
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendGetRequest(String url, Map<String, String> headers) {
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP GET请求方法(无请求头)
*
* @param url 请求地址
* @return 响应结果字符串
*/
public static String sendGetRequest(String url) {
return sendGetRequest(url, null);
}
/**
* 通用HTTP POST请求方法(JSON参数)
*
* @param url 请求地址
* @param jsonParam JSON参数
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendPostRequest(String url, String jsonParam, Map<String, String> headers) {
RequestBody body = RequestBody.create(JSON, jsonParam);
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url)
.post(body);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP POST请求方法(JSON参数,无请求头)
*
* @param url 请求地址
* @param jsonParam JSON参数
* @return 响应结果字符串
*/
public static String sendPostRequest(String url, String jsonParam) {
return sendPostRequest(url, jsonParam, null);
}
/**
* 通用HTTP POST请求方法(表单参数)
*
* @param url 请求地址
* @param formParams 表单参数映射
* @param headers 请求头映射
* @return 响应结果字符串
*/
public static String sendPostFormRequest(String url, Map<String, String> formParams, Map<String, String> headers) {
StringBuilder formBody = new StringBuilder();
if (formParams != null && !formParams.isEmpty()) {
for (Map.Entry<String, String> entry : formParams.entrySet()) {
if (formBody.length() > 0) {
formBody.append("&");
}
formBody.append(entry.getKey()).append("=").append(entry.getValue());
}
}
RequestBody body = RequestBody.create(FORM, formBody.toString());
Request.Builder builder = new Request.Builder()
.header("Content-Type", "application/json")
.url(url)
.post(body);
// 添加请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
}
}
Request request = builder.build();
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求异常: " + response.code());
}
return response.body().string();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 通用HTTP POST请求方法(表单参数,无请求头)
*
* @param url 请求地址
* @param formParams 表单参数映射
* @return 响应结果字符串
*/
public static String sendPostFormRequest(String url, Map<String, String> formParams) {
return sendPostFormRequest(url, formParams, null);
}
public static String getToken() {
String token = "";
@@ -175,7 +30,7 @@ public class HuaFangPriceUtil {
params.put("userName", userName);
params.put("password", password);
String tokenString = sendPostRequest("http://ds.gw.chenghuiyin.com/ordering/api/User/GetToken", JSONObject.toJSONString(params));
String tokenString = HttpUtils.sendPostRequest("http://ds.gw.chenghuiyin.com/ordering/api/User/GetToken", JSONObject.toJSONString(params));
System.out.println("获取token返回:" + tokenString);
HuaFangTokenVo huaFangTokenVo = JSONObject.parseObject(tokenString, HuaFangTokenVo.class);
RedisUtil.set(templateName, huaFangTokenVo.getAccessToken(), huaFangTokenVo.getExpiresIn() - 50);
@@ -191,7 +46,7 @@ public class HuaFangPriceUtil {
public static HuaFangPriceResultVo getPrice(HuaFangPriceRequstVo params) {
Map<String, String> heards = new HashMap<>();
heards.put("Authorization", "Bearer " + getToken());
String resultText = sendPostRequest("http://ds.quote.chenghuiyin.com/api/app/price/calc-price", JSONObject.toJSONString(params), heards);
String resultText = HttpUtils.sendPostRequest("http://ds.quote.chenghuiyin.com/api/app/price/calc-price", JSONObject.toJSONString(params), heards);
HuaFangPriceResultVo result = JSONObject.parseObject(resultText, HuaFangPriceResultVo.class);
return result;
}
@@ -2650,28 +2650,28 @@ public class PriceUtils {
Product pro;
double price = 0;
if (length == 240 && width == 200 || length == 200 && width == 240) {
if (kind.equals("春亚布")) {
price = num * count * 2;
} else {
price = num * count * 3;
}
} else if (length == 200 && width == 140 || length == 140 && width == 200) {
if (kind.equals("春亚布")) {
price = num * count * 1.8;
} else {
price = num * count * 2.5;
}
} else if (length == 200 && width == 140 || length == 140 && width == 200) {
if (kind.equals("春亚布")) {
price = num * count * 1.5;
} else {
price = num * count * 1.3;
}
} else {
if (kind.equals("春亚布")) {
price = num * count * 1.5;
} else {
price = num * count * 1.8;
price = num * count * 2;
}
}
pro = new Product();
pro.setCount(count);
pro.setPrice(Math.ceil(price) > 50 ? price : 50);
pro.setPrice(Math.max(Math.ceil(price), 30));
list.add(pro);
return list;
}
+2 -2
View File
@@ -408,8 +408,8 @@
layer.msg("联单尺寸不能小于10*7 cm",{offset:['300px','300px']},function(){});
return false;
}
if ((size.split("*")[0] > 42 || size.split("*")[1] > 28.5) && (size.split("*")[0] > 28.5 || size.split("*")[1] > 42)) {
layer.msg("联单尺寸超过42*28.5 cm请单独报价",{offset:['300px','300px']},function(){});
if ((size.split("*")[0] > 21 || size.split("*")[1] > 28.5) && (size.split("*")[0] > 28.5 || size.split("*")[1] > 21)) {
layer.msg("彩色信纸尺寸不能超过21*28.5 cm",{offset:['300px','300px']},function(){});
return false;
}
}
+1 -1
View File
@@ -35,7 +35,7 @@
<input type="radio" lay-filter="kindValue" name="kindValue" value="7" title="贡缎布">
<input type="radio" lay-filter="kindValue" name="kindValue" value="8" title="锦旗">
<!-- <input type="radio" lay-filter="kindValue" name="kindValue" value="9" title="彩旗"> -->
<!--<input type="radio" lay-filter="kindValue" name="kindValue" value="9" title="号牌布">-->
<input type="radio" lay-filter="kindValue" name="kindValue" value="9" title="号牌布">
<!--<input type="radio" lay-filter="kindValue" name="kindValue" value="10" title="帆布"> -->
</div>
<div class="qita productName">