Просмотр исходного кода

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	mallinkAdmin/src/main/resources/application-prod.yml
release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
6f494cc982
19 измененных файлов: 477 добавлений и 174 удалений
  1. +123
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/AsyncTask.java
  2. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java
  3. +71
    -78
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java
  4. +45
    -7
      mallinkAdmin/src/main/resources/application-prod.yml
  5. +44
    -5
      mallinkAdmin/src/main/resources/application-test.yml
  6. +22
    -5
      mallinkBApi/src/main/resources/application-prod.yml
  7. +22
    -5
      mallinkBApi/src/main/resources/application-test.yml
  8. +24
    -5
      mallinkCApi/src/main/resources/application-prod.yml
  9. +20
    -3
      mallinkCApi/src/main/resources/application-test.yml
  10. +30
    -41
      mallinkSchedule/src/main/java/com/iformall/schedule/MsgSendingSchedule.java
  11. +22
    -3
      mallinkSchedule/src/main/resources/application-prod.yml
  12. +20
    -3
      mallinkSchedule/src/main/resources/application-test.yml
  13. +3
    -3
      mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantMicroPayVo.java
  14. +2
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  15. +1
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java
  16. +6
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  17. +12
    -6
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  18. +8
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  19. +1
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java

+ 123
- 0
mallinkAdmin/src/main/java/com/iformall/controller/AsyncTask.java Просмотреть файл

@@ -0,0 +1,123 @@
package com.iformall.controller;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxTagsService;
import com.iformall.shiro.UserSession;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class AsyncTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
private WxTagsService wxTagsService;

@Autowired
StringRedisTemplate stringRedisTemplate;

private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> {
@Override
public Object importHandler(CUserBaseInfoT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}

private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if(fail) {
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}
}

@Async
public void importExcelData(File file, MallUserInfo user, String importKey, String tenantId) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"});
IExcelDataHandler<CUserBaseInfoT> handler = new AsyncTask.UserExcelHandler();
handler.setNeedHandlerFields(new String[] { "手机号" });
params.setNeedVerify(true);

ExcelImportResult<CUserBaseInfoT> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params);
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
logger.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if(datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
set_redis_value(importKey, "1", "0", "0", "1", true);
return;
}

List<CUserBaseInfoT> successList = datalist.getList();
List<CUserBaseInfoT> failList = datalist.getFailList();

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, false);

logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

WxTags wxTagsQ = new WxTags();
List<WxTags> tagList = wxTagsService.findList(wxTagsQ);

try {
successList.parallelStream().forEach(uBase -> {
// 异步无法获取到原有的session,所以再注入一下session
Session session = SecurityUtils.getSubject().getSession();
session.setAttribute(UserSession.userInfo, user);
session.setAttribute(UserSession.userId, user.getId());
session.setAttribute(UserSession.tenantId, tenantId);

wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase);
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
}
}
}

+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java Просмотреть файл

@@ -170,7 +170,7 @@ public class HomeController extends BaseController {
if(StringUtils.isNotBlank(user.getPhone())) {
// 领导登录
user = mallUserInfoService.getByPhone(user.getPhone());
if(!isInMobileAdmin(user)) {
if(user == null && !isInMobileAdmin(user)) {
return new ResultData(ErrorCode.USER_NOT_ADMIN);
}
} else if(StringUtils.isNotBlank(user.getOpenId())) {


+ 71
- 78
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java Просмотреть файл

@@ -1,10 +1,5 @@
package com.iformall.controller;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -13,19 +8,14 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.enums.EnumAssignTagsTrigger;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.service.impl.WxCUserBasicInfoServiceImpl;
import com.iformall.shiro.UserSession;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +25,10 @@ import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -69,12 +63,14 @@ public class WxCUserBasicInfoController extends BaseController {
@Autowired
private WxLevelConfigService wxLevelConfigService;

@Autowired
private WxTagsService wxTagsService;


@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
private AsyncTask asyncTask;

private void setUserInfoLevel(WxCUserBasicInfo info) {

if (info.getPoins() == null || info.getPoins() == 0) {
@@ -265,103 +261,100 @@ public class WxCUserBasicInfoController extends BaseController {

}

private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> {
@Override
public Object importHandler(CUserBaseInfoT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if(fail) {
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}

}

@RequestMapping("/importTemplate")
public ResultData importTemplate(@RequestParam("file") MultipartFile file) {
@PostMapping(value = "/importTemplate", consumes = "multipart/*")
public ResultData importTemplate(@RequestParam("file") MultipartFile mFile) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate");
if (file.isEmpty()) {
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = importMemPrev + userId;
final String tenantId = getTenantId();

//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount");
if (allCount) {
return new ResultData(Result.SUCCESS, "模板正在导入");
}

stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + "");
stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "");

String fpath = "./upload/";
File targetFile = new File(fpath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = "1.xls";
int dot = mFile.getOriginalFilename().lastIndexOf('.');
fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length());

ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"});
IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler();
handler.setNeedHandlerFields(new String[] { "手机号" });
params.setNeedVerify(true);
File lFile = new File(fpath + File.separator + fileName);

ExcelImportResult<CUserBaseInfoT> datalist = null;
FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params);
fos = new FileOutputStream(lFile);
fs = (BufferedInputStream) mFile.getInputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fs.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
fs.close();
} catch (Exception e) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "processCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "failCount", "1");
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
}

if(datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
}

List<CUserBaseInfoT> successList = datalist.getList();
List<CUserBaseInfoT> failList = datalist.getFailList();

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + total);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "" + all_success);
stringRedisTemplate.opsForHash().put(importKey, "processCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "failCount", "" + all_fail);

logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

WxTags wxTagsQ = new WxTags();
List<WxTags> tagList = wxTagsService.findList(wxTagsQ);
asyncTask.importExcelData(lFile, user, importKey, tenantId);

final String tenantId = getTenantId();

try {
successList.parallelStream().forEach(uBase -> {
// 异步无法获取到原有的session,所以再注入一下session
Session session = SecurityUtils.getSubject().getSession();
session.setAttribute(UserSession.userInfo, user);
session.setAttribute(UserSession.userId, user.getId());
session.setAttribute(UserSession.tenantId, tenantId);

wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase);
});
} catch (Exception e) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", "" + all_fail);
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
}
stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES);
return new ResultData(Result.SUCCESS, "模板正在导入");
}


@GetMapping("/queryTemplateCount")
public ResultData queryTemplateCount() {
String importKey = importMemPrev + getUser().getId();


+ 45
- 7
mallinkAdmin/src/main/resources/application-prod.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(NUzgQOdJnCbVLKT6BaX0aw==)
password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -24,16 +24,56 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 8
max-idle: 8
max-active: 100
max-idle: 20
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=)
password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=)
secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=)


wechat:
open:
componentAppId: "wx897e4673286c915d"
componentSecret: "cdfdfda65c45689beb6766c4c427eed2"
componentToken: "formall2018"
componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN"
redis:
host: 127.0.0.1
port: 6379
password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 100
max-idle: 100
max-wait: -1
min-idle: 10


fm:
@@ -50,5 +90,3 @@ logging:
tk.mybatis: debug
com.iformall.mapper: debug
path: ./logs/admin

admin-page: http://admin.malls.iformall.com

+ 44
- 5
mallinkAdmin/src/main/resources/application-test.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(Uc0AjgkytxHHCwZrmDASWg==)
password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -24,17 +24,56 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 8
max-idle: 8
max-active: 100
max-idle: 20
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=)
password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=)
secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=)

wechat:
open:
componentAppId: "wx897e4673286c915d"
componentSecret: "cdfdfda65c45689beb6766c4c427eed2"
componentToken: "formall2018"
componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN"
redis:
host: 127.0.0.1
port: 6379
password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 100
max-idle: 100
max-wait: -1
min-idle: 10


fm:
exception: true


+ 22
- 5
mallinkBApi/src/main/resources/application-prod.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(NUzgQOdJnCbVLKT6BaX0aw==)
password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -23,17 +23,34 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 8
max-idle: 8
max-active: 100
max-idle: 20
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=)
password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=)
secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=)

fm:
exception: true


+ 22
- 5
mallinkBApi/src/main/resources/application-test.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(Uc0AjgkytxHHCwZrmDASWg==)
password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -23,17 +23,34 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 8
max-idle: 8
max-active: 50
max-idle: 30
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=)
password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=)
secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=)

fm:
exception: true


+ 24
- 5
mallinkCApi/src/main/resources/application-prod.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(NUzgQOdJnCbVLKT6BaX0aw==)
password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -23,17 +23,36 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=)
timeout: 3600
expire: 1800 #30分钟
database: 1
defaultExpiration: 2592000 # 默认生命周期30天
jedis:
pool:
max-active: 8
max-idle: 8
max-active: 100
max-idle: 20
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=)
password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=)
secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=)



fm:
exception: true


+ 20
- 3
mallinkCApi/src/main/resources/application-test.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(Uc0AjgkytxHHCwZrmDASWg==)
password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -23,7 +23,7 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=)
timeout: 3600
expire: 1800 #30分钟
database: 1
@@ -34,6 +34,23 @@ spring:
max-idle: 8
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=)
password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=)
secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=)

fm:
exception: true


+ 30
- 41
mallinkSchedule/src/main/java/com/iformall/schedule/MsgSendingSchedule.java Просмотреть файл

@@ -1,22 +1,28 @@
package com.iformall.schedule;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iformall.domain.po.WxMsg;
import com.iformall.domain.po.WxMsgConfig;
import com.iformall.enums.EnumMsgSendStatus;
import com.iformall.enums.EnumMsgStatus;
import com.iformall.enums.EnumVerifyCode;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxMsgConfigMapper;
import com.iformall.mapper.WxMsgMapper;
import com.iformall.service.PushLimitService;
import com.iformall.utils.*;
import com.iformall.utils.DateUtils;
import com.iformall.utils.WiwideUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.List;

/**
* @author gongbiao
*/
@Component
public class MsgSendingSchedule {

@@ -28,79 +34,62 @@ public class MsgSendingSchedule {
@Autowired
private WxMsgConfigMapper wxMsgConfigMapper;

@Autowired
private PushLimitService pushLimitService;


@Scheduled(cron = "0 1 * * * ?") // 每小时第一分钟执行
/**
* 每小时第一分钟执行
*/
@Scheduled(cron = "0 1 * * * ?")
public void sendmsgschedule() {

logger.info("sendmsg定时任务启动");

String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:00:00");
WxMsg wxMsg = new WxMsg();
wxMsg.setIsright(0);
wxMsg.setSendtime(systemTime);
List<WxMsg> list = wxMsgMapper.findList(wxMsg);

for(WxMsg msg:list){
boolean checkTime = false;
try {
checkTime = pushLimitService.checkSendTime(wxMsg.getTenantId());
} catch (MallinkException e) {
logger.error(e.getMessage());
}
if (checkTime) {
sendmsg(msg);
}
logger.info("将要发送的短信列表:" + JSONArray.toJSONString(list));
for (WxMsg msg : list) {
sendmsg(msg);
}

logger.info("sendmsg定时任务结束");
}

public void sendmsg(WxMsg wxMsg){



public void sendmsg(WxMsg wxMsg) {
logger.info("发送短信开始----------");
//从短信配置中查询密钥 bid 等信息
WxMsgConfig wxMsgConfig = new WxMsgConfig();
wxMsgConfig.setTenantId(wxMsg.getTenantId());
List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig);
if (wxMsgConfigs.size() == 0) return;
if (wxMsgConfigs.size() == 0) {
logger.info("短信相关配置不存在");
return;
}
wxMsgConfig = wxMsgConfigs.get(0);

if(wxMsgConfig.getRemains()==0){
if (wxMsgConfig.getRemains() == 0) {
logger.info("短信数量为0");
return;
}

if(wxMsgConfig.getRemains()<wxMsg.getExpectSendNumber()){
if (wxMsgConfig.getRemains() < wxMsg.getExpectSendNumber()) {
logger.info("短信数量不足");
return;
}


String secret = wxMsgConfig.getSecret();
String bid = wxMsgConfig.getBid();
String publickey = wxMsgConfig.getPublickey();

String phone = wxMsg.getPhones();
String signature = wxMsg.getSignature();
String msg = wxMsg.getMsg();
String notifyUrl = wxMsgConfig.getNotifyurl();
String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl,EnumVerifyCode.NO.getCode().toString());
String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString());
logger.info("短信返回结果:" + result);
JSONObject jsonObjectResult = JSONObject.parseObject(result);
String ret = jsonObjectResult.get("ret").toString();

if (ret.equals("1")) {
wxMsg.setSendstatus(1);
wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode());
} else {
wxMsg.setSendstatus(0);
wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode());
}

wxMsg.setStatus(1);
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode());
wxMsgMapper.updateByPrimaryKeySelective(wxMsg);
logger.info("短信发送结束:" + jsonObjectResult.toJSONString());
}

}

+ 22
- 3
mallinkSchedule/src/main/resources/application-prod.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(NUzgQOdJnCbVLKT6BaX0aw==)
password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -24,7 +24,7 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=)
timeout: 3600
expire: 1800 #30分钟
database: 1
@@ -35,6 +35,25 @@ spring:
max-idle: 8
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=)
password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=)
secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=)



fm:
exception: true


+ 20
- 3
mallinkSchedule/src/main/resources/application-test.yml Просмотреть файл

@@ -2,8 +2,8 @@ spring:
# JDBC
datasource:
url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: ENC(BDv01/sQdBGEhFEXuw+8tw==)
password: ENC(0wvpX49+RMUpGP2tb9PY4ta/yCwAmLLhbKG9ndvifPI=)
username: ENC(Uc0AjgkytxHHCwZrmDASWg==)
password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=)
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
filters: stat
@@ -24,7 +24,7 @@ spring:
redis:
host: 127.0.0.1
port: 6379
password: ENC(4Z6xTEJOw04DYyhur0mTwlveexVEX9YRfNTY78MyKgU=)
password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=)
timeout: 3600
expire: 1800 #30分钟
database: 1
@@ -35,6 +35,23 @@ spring:
max-idle: 8
max-wait: -1
min-idle: 0
# EMAIL
mail:
host: smtp.exmail.qq.com
username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=)
password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码
properties:
mail:
smtp:
auth: true
starttls:
enable: true

aws:
clientRegion: cn-northwest-1
bucketName: iformall-net
access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=)
secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=)

fm:
exception: true


+ 3
- 3
mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantMicroPayVo.java Просмотреть файл

@@ -29,7 +29,7 @@ public class WxMerchantMicroPayVo implements Serializable {
private String reportDate;
/*商户电话**/
@io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId")
private Long merchantPhone;
private String merchantPhone;
/*商户名**/
@io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName")
private String merchantName;
@@ -58,11 +58,11 @@ public class WxMerchantMicroPayVo implements Serializable {
tradeAmt = _tradeAmt;
}

public Long getMerchantPhone() {
public String getMerchantPhone() {
return merchantPhone;
}

public void setMerchantPhone(Long merchantPhone) {
public void setMerchantPhone(String merchantPhone) {
this.merchantPhone = merchantPhone;
}



+ 2
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -43,6 +43,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@Service
public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
@@ -609,6 +610,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {

//记数
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1);
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}

@Override


+ 1
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java Просмотреть файл

@@ -239,6 +239,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService {
couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(), wxCoupon.getId());
} catch (MallinkException e) {
logger.error(e.getMessage());
return false;
}
if (couponOrder != null) {
wxCouponActionLogService.addOne(tempCUser.getTenantId(), wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId);


+ 6
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -226,8 +226,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
logger.error("商户不存在:" + bUserId);
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}

WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId));
WxCouponOrderCVo wxCouponOrderCVo = null;
try {
wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId));
} catch (Exception e) {
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
}
if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
return new ResultData(wxCouponOrderCVo);


+ 12
- 6
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java Просмотреть файл

@@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
@@ -103,7 +104,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}

@Override
@Transactional
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public boolean sendCouponToUser(EnumCouponSendSendType type, Object param) {

String tenantId;
@@ -177,12 +178,17 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
continue;

// 发放免费券
WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId());
if (couponOrder != null) {
wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId());
bRet = true;
WxCouponOrder couponOrder = null;
try {
couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId());
if (couponOrder != null) {
wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId());
bRet = true;
}
// wxCouponService.reduceInventory(send.getCouponId(), 1);
} catch (Exception e) {
logger.error(e.getMessage());
}
wxCouponService.reduceInventory(send.getCouponId(), 1);
}

return bRet;


+ 8
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -614,7 +614,12 @@ public class WxOrderServiceImpl implements WxOrderService {
}

// 减库存操作
stockReduce(user, coupon, couponIdStr);
try {
stockReduce(user, coupon, couponIdStr);
} catch (Exception e) {
logger.error(e.getMessage());
}


int payment = coupon.getSalePrice();

@@ -665,7 +670,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class})
public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId) {
// check 用户状态
WxCUser user = null;
@@ -771,7 +776,7 @@ public class WxOrderServiceImpl implements WxOrderService {
updateOrder.setUpdateDate(currentDate);
int ret = 0;
try {
ret = wxOrderMapper.updateByPrimaryKey(updateOrder);
wxOrderMapper.updateByPrimaryKey(updateOrder);
} catch (Exception e) {
logger.error("订单更新失败:" + e.getMessage());
throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR);


+ 1
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java Просмотреть файл

@@ -1191,10 +1191,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {

// 修改订单状态
try {
int _count = wxOrderService.couponOrderSuccess(order);
if (_count > 1) {
throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
}
wxOrderService.couponOrderSuccess(order);
} catch (Exception e) {
logger.error(e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新");


Загрузка…
Отмена
Сохранить