Quellcode durchsuchen

修改生成配置文件、App版本更新等功能

VEAR vor 2 Jahren
Ursprung
Commit
82715ddafe

+ 4 - 0
doc/运维手册.md

@@ -99,3 +99,7 @@ export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
 MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
 ```
 
+
+## minio地址
+
+    http://47.109.28.56:9001/login

+ 7 - 0
pom.xml

@@ -217,6 +217,13 @@
             <artifactId>IJPay-Core</artifactId>
             <version>${ijapy.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier>
+        </dependency>
     </dependencies>
 
     <build>

+ 300 - 0
src/main/java/org/springblade/common/utils/JheSmsUtils.java

@@ -0,0 +1,300 @@
+package org.springblade.common.utils;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * 聚合数据 短信服务
+ * @link https://www.sdk.cn/details/O09rDkZdewVabBo5pa?s=api
+ * @author xuwei
+ */
+public class JheSmsUtils {
+
+	//可选模板列表
+	public static final String URL_ALPHA = "http://v.juhe.cn/vercodesms/optionTpl.php?key=%s";
+
+	//提交短信模板
+	public static final String URL_BETA = "http://v.juhe.cn/vercodesms/submitTpl.php?key=%s&signature=%s&tplcode=%d";
+
+	//我的模板列表
+	public static final String URL_GAMMA = "http://v.juhe.cn/vercodesms/myTpl.php?key=%s";
+
+	//发送短信
+	public static final String URL_DELTA = "http://v.juhe.cn/vercodesms/send.php?key=%s&tplId=%d&tplValue=%s&mobile=%s";
+
+	//申请接口的请求key
+	// TODO: 您需要改为自己的请求key
+	public static final String KEY = "您需要改为自己的请求key";
+
+
+	public static void main(String[] args) throws UnsupportedEncodingException {
+		//可选模版列表
+		printA();
+		System.out.println("-------------------------------------分割线-------------------------------------");
+		//提交短信模板
+		String signature = "艾克斯奥特曼";
+		short tplcode = 1009;
+		printB(signature,tplcode);
+		System.out.println("-------------------------------------分割线-------------------------------------");
+		//我的模板
+		printC();
+		System.out.println("-------------------------------------分割线-------------------------------------");
+		//发送短信
+		int tplId = 65535;
+		String tplValue = "#code#=12345";
+		String mobile = "17715******";
+		printD(tplId, tplValue, mobile);
+	}
+
+	/**
+	 * 可选模版列表
+	 */
+	public static void printA() {
+		//发送http请求的url
+		String url = String.format(URL_ALPHA, KEY);
+		final String response = doGet(url);
+		System.out.println("接口返回:" + response);
+		try {
+			JSONObject jsonObject = JSONObject.fromObject(response);
+			int error_code = jsonObject.getInt("error_code");
+			if (error_code == 0) {
+				System.out.println("调用接口成功");
+				JSONArray result = jsonObject.getJSONArray("result");
+				result.stream().map(JSONObject::fromObject).forEach(hour -> {
+					System.out.println("可供选择的模板id:" + ((JSONObject) hour).getString("tplcode"));
+					System.out.println("模板内容示例:" + ((JSONObject) hour).getString("sms_tpl"));
+					System.out.println("模板规范说明:" + ((JSONObject) hour).getString("des"));
+				});
+
+			} else {
+				System.out.println("调用接口失败:" + jsonObject.getString("reason"));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 提交短信模板
+	 */
+	public static void printB(String signature, short tplcode) {
+		//发送http请求的url
+		String url = String.format(URL_BETA, KEY, signature, tplcode);
+		final String response = doGet(url);
+		System.out.println("接口返回:" + response);
+		try {
+			JSONObject jsonObject = JSONObject.fromObject(response);
+			int error_code = jsonObject.getInt("error_code");
+			if (error_code == 0) {
+				System.out.println("调用接口成功");
+				JSONObject result = jsonObject.getJSONObject("result");
+				System.out.println("模板id:" + result.getInt("tplId"));
+			} else {
+				System.out.println("调用接口失败:" + jsonObject.getString("reason"));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 我的模板列表
+	 */
+	public static void printC() {
+		//发送http请求的url
+		String url = String.format(URL_GAMMA, KEY);
+		final String response = doGet(url);
+		System.out.println("接口返回:" + response);
+		try {
+			JSONObject jsonObject = JSONObject.fromObject(response);
+			int error_code = jsonObject.getInt("error_code");
+			if (error_code == 0) {
+				System.out.println("调用接口成功");
+				JSONArray result = jsonObject.getJSONArray("result");
+
+				result.stream().map(JSONObject::fromObject).forEach(hour -> {
+					System.out.println("模板ID:" + ((JSONObject) hour).getString("tplId"));
+					System.out.println("模板签名:" + ((JSONObject) hour).getString("signature"));
+					System.out.println("模板发送内容:" + ((JSONObject) hour).getString("sms_tpl"));
+					System.out.println("模板规审核状态范说明:" + ((JSONObject) hour).getString("tpl_state"));
+					System.out.println("是否有效:" + ((JSONObject) hour).getString("status"));
+					System.out.println("模板规范说明:" + ((JSONObject) hour).getString("des"));
+				});
+
+			} else {
+				System.out.println("调用接口失败:" + jsonObject.getString("reason"));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+
+	public static void printD(int tplId, String tplValue, String mobile) throws UnsupportedEncodingException {
+		//发送http请求的url
+		String url = String.format(URL_DELTA, KEY, tplId, URLEncoder.encode(tplValue, "UTF-8"), mobile);
+		final String response = doGet(url);
+		System.out.println("接口返回:" + response);
+		try {
+			JSONObject jsonObject = JSONObject.fromObject(response);
+			int error_code = jsonObject.getInt("error_code");
+			if (error_code == 0) {
+				System.out.println("调用接口成功");
+				JSONObject result = jsonObject.getJSONObject("result");
+				System.out.println("短信唯一标识:" + result.getString("sid"));
+
+			} else {
+				System.out.println("调用接口失败:" + jsonObject.getString("reason"));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * get方式的http请求
+	 *
+	 * @param httpUrl 请求地址
+	 * @return 返回结果
+	 */
+	public static String doGet(String httpUrl) {
+		HttpURLConnection connection = null;
+		InputStream inputStream = null;
+		BufferedReader bufferedReader = null;
+		String result = null;// 返回结果字符串
+		try {
+			// 创建远程url连接对象
+			URL url = new URL(httpUrl);
+			// 通过远程url连接对象打开一个连接,强转成httpURLConnection类
+			connection = (HttpURLConnection) url.openConnection();
+			// 设置连接方式:get
+			connection.setRequestMethod("GET");
+			// 设置连接主机服务器的超时时间:15000毫秒
+			connection.setConnectTimeout(15000);
+			// 设置读取远程返回的数据时间:60000毫秒
+			connection.setReadTimeout(60000);
+			// 发送请求
+			connection.connect();
+			// 通过connection连接,获取输入流
+			if (connection.getResponseCode() == 200) {
+				inputStream = connection.getInputStream();
+				// 封装输入流,并指定字符集
+				bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+				// 存放数据
+				StringBuilder sbf = new StringBuilder();
+				String temp;
+				while ((temp = bufferedReader.readLine()) != null) {
+					sbf.append(temp);
+					sbf.append(System.getProperty("line.separator"));
+				}
+				result = sbf.toString();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			// 关闭资源
+			if (null != bufferedReader) {
+				try {
+					bufferedReader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (null != inputStream) {
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (connection != null) {
+				connection.disconnect();// 关闭远程连接
+			}
+		}
+		return result;
+	}
+
+
+	/**
+	 * post方式的http请求
+	 *
+	 * @param httpUrl 请求地址
+	 * @param param   请求参数
+	 * @return 返回结果
+	 */
+	public static String doPost(String httpUrl, String param) {
+		HttpURLConnection connection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader bufferedReader = null;
+		String result = null;
+		try {
+			URL url = new URL(httpUrl);
+			// 通过远程url连接对象打开连接
+			connection = (HttpURLConnection) url.openConnection();
+			// 设置连接请求方式
+			connection.setRequestMethod("POST");
+			// 设置连接主机服务器超时时间:15000毫秒
+			connection.setConnectTimeout(15000);
+			// 设置读取主机服务器返回数据超时时间:60000毫秒
+			connection.setReadTimeout(60000);
+			// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
+			connection.setDoOutput(true);
+			// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
+			connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+			// 通过连接对象获取一个输出流
+			outputStream = connection.getOutputStream();
+			// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
+			outputStream.write(param.getBytes());
+			// 通过连接对象获取一个输入流,向远程读取
+			if (connection.getResponseCode() == 200) {
+				inputStream = connection.getInputStream();
+				// 对输入流对象进行包装:charset根据工作项目组的要求来设置
+				bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+				StringBuilder sbf = new StringBuilder();
+				String temp;
+				// 循环遍历一行一行读取数据
+				while ((temp = bufferedReader.readLine()) != null) {
+					sbf.append(temp);
+					sbf.append(System.getProperty("line.separator"));
+				}
+				result = sbf.toString();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			// 关闭资源
+			if (null != bufferedReader) {
+				try {
+					bufferedReader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (null != outputStream) {
+				try {
+					outputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (null != inputStream) {
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (connection != null) {
+				connection.disconnect();
+			}
+		}
+		return result;
+	}
+}

+ 4 - 0
src/main/java/org/springblade/modules/api/controller/Api08Controller.java

@@ -28,9 +28,11 @@ import org.springblade.common.constant.CommonConstant;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.sms.SmsTemplate;
 import org.springblade.core.sms.model.SmsCode;
 import org.springblade.core.sms.model.SmsData;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.platform.entity.Ads;
 import org.springblade.modules.platform.entity.Payments;
 import org.springblade.modules.platform.service.IAdsService;
@@ -39,6 +41,7 @@ import org.springblade.modules.resource.builder.sms.SmsBuilder;
 import org.springblade.modules.resource.utils.SmsUtil;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.Duration;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -97,4 +100,5 @@ public class Api08Controller extends BladeController {
 		return smsCode.isSuccess() ? R.data(smsCode, SEND_SUCCESS) : R.fail(SEND_FAIL);
 	}
 
+
 }

+ 58 - 0
src/main/java/org/springblade/modules/api/controller/TestController.java

@@ -26,19 +26,29 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.log.logger.BladeLogger;
 import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.sms.model.SmsCode;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.finance.service.IOrderService;
+import org.springblade.modules.resource.utils.SmsUtil;
 import org.springblade.modules.system.entity.UserApp;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.Duration;
+import java.util.Map;
+
+import static org.springblade.modules.resource.utils.SmsUtil.PARAM_KEY;
+
 /**
  * 控制器
  *
@@ -50,6 +60,7 @@ import org.springframework.web.bind.annotation.*;
 @RequestMapping(CommonConstant.API_URL + "/test")
 @Api(value = "接口测试", tags = "99.接口测试")
 public class TestController extends BladeController {
+	private static final Logger log = LoggerFactory.getLogger(TestController.class);
 
 	private final IOrderService orderService;
 	private final BladeRedis bladeRedis;
@@ -150,4 +161,51 @@ public class TestController extends BladeController {
 		return R.data("测试");
 	}
 
+	@PostMapping("/test010")
+	@ApiOperationSupport(order = 10)
+	@ApiOperation(value = "测试010-聚合验证码", notes = "聚合验证码")
+	public R test010(@ApiParam(value = "phone", required = true) @RequestParam(required = false) String phone,
+					 @ApiParam(value = "captchaId", required = true) @RequestParam(required = false) String captchaId,
+					 @ApiParam(value = "captchaCode", required = true) @RequestParam(required = false) String captchaCode) {
+		return R.data(captchaCode(phone, captchaId, captchaCode));
+	}
+
+	@PostMapping("/test011")
+	@ApiOperationSupport(order = 11)
+	@ApiOperation(value = "测试011-聚合发送验证码", notes = "验证码发送")
+	public R<SmsCode> test011(@ApiParam(value = "phone", required = true) @RequestParam(required = false) String phone) {
+		return R.data(jheSms(phone));
+	}
+
+	private SmsCode jheSms(String phone){
+		SmsCode smsCode = new SmsCode();
+		Map<String, String> params = SmsUtil.getValidateParams();
+		String id = StringUtil.randomUUID();
+		String key = this.cacheKey(phone, id);
+		String val = bladeRedis.get(key);
+		log.info(" code === " + params.get(PARAM_KEY));
+		if (StringUtil.isBlank(val)){
+			bladeRedis.setEx(key, params.get(PARAM_KEY), Duration.ofMinutes(30L));
+			smsCode.setId(id);
+			smsCode.setValue(params.get(PARAM_KEY));
+			smsCode.setSuccess(Boolean.TRUE);
+		}else{
+			smsCode.setSuccess(Boolean.FALSE);
+		}
+		return smsCode;
+	}
+
+	String cacheKey(String phone, String id) {
+		return "blade:sms::captcha:" + phone + ":" + id;
+	}
+
+	private boolean captchaCode(String phone, String captchaId, String captchaCode){
+		String key = "blade:sms::captcha:" + phone + ":" + captchaId;
+		String cache = bladeRedis.get(key);
+		if (captchaCode.equals(cache)){
+			return true;
+		}
+		return false;
+	}
+
 }

+ 1 - 1
src/main/java/org/springblade/modules/finance/service/impl/OrderServiceImpl.java

@@ -503,7 +503,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 			return false;
 		}
 		if(queryOrder.getPayFlag() == 2){
-			log.info("订单异常", "订单已支付成功,不能重复发起支付!订单号:" + outTradeNo);
+			log.info("订单已支付成功,不能重复发起支付!订单号:" + outTradeNo);
 			return false;
 		}
 		//更新订单

+ 8 - 1
src/main/java/org/springblade/modules/platform/controller/VersionUpgradeController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.platform.controller;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -68,7 +69,8 @@ public class VersionUpgradeController extends BladeController {
 	@ApiOperation(value = "分页", notes = "传入versionUpgrade")
 	public R<IPage<VersionUpgradeVO>> list(VersionUpgrade versionUpgrade, Query query) {
 		IPage<VersionUpgrade> pages = versionUpgradeService.page(Condition.getPage(query),
-			Condition.getQueryWrapper(versionUpgrade).lambda().orderByAsc(VersionUpgrade::getSort));
+			Condition.getQueryWrapper(versionUpgrade).lambda().orderByDesc(VersionUpgrade::getStatus)
+				.orderByDesc(VersionUpgrade::getVersionCode));
 		return R.data(VersionUpgradeWrapper.build().pageVO(pages));
 	}
 
@@ -90,6 +92,11 @@ public class VersionUpgradeController extends BladeController {
 	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "新增", notes = "传入versionUpgrade")
 	public R save(@Valid @RequestBody VersionUpgrade versionUpgrade) {
+		VersionUpgrade query = versionUpgradeService.getOne(Wrappers.<VersionUpgrade>lambdaQuery()
+			.eq(VersionUpgrade::getVersionCode, versionUpgrade.getVersionCode()));
+		if(query != null){
+			return R.fail("版本编号已存在");
+		}
 		return R.status(versionUpgradeService.save(versionUpgrade));
 	}
 

+ 6 - 3
src/main/java/org/springblade/modules/platform/wrapper/UserAppWrapper.java

@@ -65,18 +65,21 @@ public class UserAppWrapper extends BaseEntityWrapper<UserApp, UserAppVO> {
 	}
 
 	/**
-	 * 信誉分
+	 * 信誉分规则
+	 *
+	 *  1.完成交易信誉分加30分
+	 * 	2.少于上一天抢的次数减30分 (日终)
+	 * 	3.到达500分完成一场加5分,减少一场减30分
 	 *
 	 * @param userId 用户
 	 * @param creditScore 信誉积分
 	 * @return boolean
 	 */
-	public boolean creditScore(Long userId, Integer creditScore){
+	public synchronized boolean creditScore(Long userId, Integer creditScore){
 		UserApp userApp = new UserApp();
 		userApp.setUserId(userId);
 		userApp.setCreditScore(creditScore);
 		return userApp.updateById();
 	}
 
-
 }

+ 1 - 1
src/main/java/org/springblade/modules/platform/wrapper/VersionUpgradeWrapper.java

@@ -42,7 +42,7 @@ public class VersionUpgradeWrapper extends BaseEntityWrapper<VersionUpgrade, Ver
 	public VersionUpgradeVO entityVO(VersionUpgrade entity) {
 		VersionUpgradeVO vo = Objects.requireNonNull(BeanUtil.copy(entity, VersionUpgradeVO.class));
 		vo.setTypeDisplayName(DictBizCache.getValue(DictBizEnum.UPGRADE_TYPE,vo.getType()));
-		vo.setStatusDisplayName(DictCache.getValue(DictEnum.YES_NO,vo.getType()));
+		vo.setStatusDisplayName(DictCache.getValue(DictEnum.YES_NO,vo.getStatus()));
 		return vo;
 	}
 

+ 10 - 0
src/main/resources/application-dev.yml

@@ -47,6 +47,16 @@ blade:
     remote-mode: true
     upload-domain: http://localhost:8999
     remote-path: /usr/share/nginx/html
+
+#oss默认配置
+oss:
+  enabled: true
+  name: minio
+  tenant-mode: true
+  endpoint:  http://47.109.28.56:9000
+  access-key: admin
+  secret-key: 12345678
+  bucket-name: bladex
 wxpay:
   appId: wx3064b51f7bace3c8
   appSecret: 89e3e5afd8623772bf5a56f460af839a

+ 8 - 1
src/main/resources/application-prod.yml

@@ -22,7 +22,14 @@ spring:
 social:
   enabled: true
   domain: http://127.0.0.1:1888
-
+oss:
+  enabled: true
+  name: minio
+  tenant-mode: true
+  endpoint:  http://47.109.28.56:9000
+  access-key: admin
+  secret-key: 12345678
+  bucket-name: bladex
 #blade配置
 blade:
   #分布式锁配置

+ 9 - 0
src/main/resources/application-test.yml

@@ -23,6 +23,15 @@ social:
   enabled: true
   domain: https://wine.gzzzyd.com
 
+#oss默认配置
+oss:
+  enabled: true
+  name: alioss
+  tenant-mode: true
+  endpoint: https://oss-cn-chengdu.aliyuncs.com
+  access-key: LTAI4GCNRML2EpFZxBWakWSc
+  secret-key: 8u1spjDrT1hD2OaN9DS8NasSHipDfO
+  bucket-name: tbladex
 #blade配置
 blade:
   #分布式锁配置

+ 0 - 9
src/main/resources/application.yml

@@ -107,15 +107,6 @@ swagger:
     email: xuweidyx@163.com
     url: https://gitee.com/x-t1/bladex-boot
 
-#oss默认配置
-oss:
-  enabled: true
-  name: alioss
-  tenant-mode: true
-  endpoint: https://oss-cn-chengdu.aliyuncs.com
-  access-key: LTAI4GCNRML2EpFZxBWakWSc
-  secret-key: 8u1spjDrT1hD2OaN9DS8NasSHipDfO
-  bucket-name: tbladex
 # 短信配置
 sms:
   enabled: false