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

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

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
b7e088a831
33 измененных файлов: 377 добавлений и 273 удалений
  1. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxBillDailyController.java
  2. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxBillOtherController.java
  3. +121
    -19
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java
  4. +6
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/WxCardPayController.java
  5. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java
  6. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java
  7. +5
    -5
      mallinkAdmin/src/main/java/com/iformall/controller/WxRentContractController.java
  8. +4
    -6
      mallinkAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java
  9. +2
    -5
      mallinkAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java
  10. +18
    -0
      mallinkAdmin/src/main/java/com/iformall/utils/UrlCheck.java
  11. +1
    -4
      mallinkCApi/src/main/java/com/iformall/controller/WxCampaignController.java
  12. +6
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxMerchantController.java
  13. +1
    -1
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  14. +1
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumMsgSendStatus.java
  15. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCampaignMapper.java
  16. +4
    -4
      mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java
  17. +12
    -4
      mallinkService/src/main/java/com/iformall/service/WxCampaignService.java
  18. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxMerchantService.java
  19. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java
  20. +5
    -4
      mallinkService/src/main/java/com/iformall/service/WxRentContractService.java
  21. +0
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java
  22. +0
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java
  23. +99
    -147
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  24. +5
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java
  25. +6
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  26. +12
    -13
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java
  27. +5
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgCallbackServiceImpl.java
  28. +2
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java
  29. +7
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java
  30. +17
    -22
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  31. +9
    -3
      mallinkService/src/main/java/com/iformall/utils/HashUtil.java
  32. +15
    -1
      mallinkService/src/main/resources/mapper/WxCampaignMapper.xml
  33. +3
    -3
      mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml

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

@@ -44,12 +44,14 @@ public class WxBillDailyController extends BaseController
public ResultData add(@RequestBody WxBillDaily wxBillDaily) {
logger.debug("[" + getIpAddr() + "] WxBillDailyController::add");
wxBillDaily.setTenantId(getTenantId());
wxBillDaily.setUserId(getUser().getId());
return wxBillDailyService.saveOrUpdate(wxBillDaily);
}

@PostMapping("update")
public ResultData update(@RequestBody WxBillDaily wxBillDaily) {
logger.debug("[" + getIpAddr() + "] WxBillDailyController::update");
wxBillDaily.setUserId(getUser().getId());
return wxBillDailyService.saveOrUpdate(wxBillDaily);
}



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

@@ -44,12 +44,14 @@ public class WxBillOtherController extends BaseController
public ResultData add(@RequestBody WxBillOther wxBillOther) {
logger.debug("[" + getIpAddr() + "] WxBillOtherController::add");
wxBillOther.setTenantId(getTenantId());
wxBillOther.setUserId(getUser().getId());
return wxBillOtherService.saveOrUpdate(wxBillOther);
}

@PostMapping("update")
public ResultData update(@RequestBody WxBillOther wxBillOther) {
logger.debug("[" + getIpAddr() + "] WxBillOtherController::update");
wxBillOther.setUserId(getUser().getId());
return wxBillOtherService.saveOrUpdate(wxBillOther);
}



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

@@ -1,5 +1,10 @@
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;
@@ -8,14 +13,19 @@ 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;
@@ -39,6 +49,8 @@ import static com.iformall.domain.po.WxCouponOrder.Field.CreateDate_DESC;
public class WxCUserBasicInfoController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private String importMemPrev = "importmem/";

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@@ -55,7 +67,10 @@ public class WxCUserBasicInfoController extends BaseController {
private WxCouponService wxCouponService;

@Autowired
WxLevelConfigService wxLevelConfigService;
private WxLevelConfigService wxLevelConfigService;

@Autowired
private WxTagsService wxTagsService;

@Autowired
StringRedisTemplate stringRedisTemplate;
@@ -79,7 +94,7 @@ public class WxCUserBasicInfoController extends BaseController {

if (info.getTagId() != null) {
WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId());
if (StringUtils.isNotBlank(uTag.getTags())) {
if (uTag != null && StringUtils.isNotBlank(uTag.getTags())) {
List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class);
info.setTagsList(wxCUserTagsService.findTagList(getTenantId(), ids));
}
@@ -222,11 +237,23 @@ public class WxCUserBasicInfoController extends BaseController {
return new ResultData(Result.SUCCESS, "查询成功", page);
}

@RequestMapping("/exportData")
public void exportData(HttpServletRequest request, HttpServletResponse response) {
@ApiOperation("会员记录导出")
@GetMapping("/exportData")
public void exportData(@ModelAttribute WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::exportData");
if(basicInfo == null) {
basicInfo = new WxCUserBasicInfo();
} else {
if (StringUtils.isBlank(basicInfo.getPhone())) {
basicInfo.setPhone(null);
}
if (StringUtils.isBlank(basicInfo.getName())) {
basicInfo.setName(null);
}
}

wxCUserBasicInfoService.exportData(request, response, getTenantId());
basicInfo.setTenantId(getTenantId());
wxCUserBasicInfoService.exportData(basicInfo, request, response);

}

@@ -238,31 +265,106 @@ 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);
}

}

@RequestMapping("/importTemplate")
public ResultData importTemplate(@RequestParam("file") MultipartFile file) {
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::importTemplate");
if (file.isEmpty()) {
throw new MallinkException(500, "上传文件不能为空");
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
String userId = getUser().getId().toString();
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = importMemPrev + userId;
//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(userId, "allCount");
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount");
if (allCount) {
return new ResultData(Result.SUCCESS, "模板正在导入");
}
stringRedisTemplate.opsForHash().putIfAbsent(userId, "allCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(userId, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(userId, "successCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(userId, "failCount", "");
wxCUserBasicInfoService.importTemplate(file, getTenantId(), userId);
stringRedisTemplate.expire(userId,30,TimeUnit.MINUTES);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "");


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

ExcelImportResult<CUserBaseInfoT> datalist = null;
try {
datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params);
} 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");
logger.error(e.getMessage());
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
}

if(datalist == null) {
logger.error("导入模板失败: 模板数据解析失败");
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
}

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);

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 = "import-" + getUser().getId();
String importKey = importMemPrev + getUser().getId();
Map entries = stringRedisTemplate.opsForHash().entries(importKey);
logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1");
if (entries.size() < 4) {
@@ -271,7 +373,7 @@ public class WxCUserBasicInfoController extends BaseController {
}
String allCount = entries.get("allCount").toString();
String allSuccessCount = entries.get("allSuccessCount").toString();
String successCount = entries.get("successCount").toString();
String processCount = entries.get("processCount").toString();
String failCount = entries.get("failCount").toString();

if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS);
@@ -279,16 +381,16 @@ public class WxCUserBasicInfoController extends BaseController {
//完全失败
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "successCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
return new ResultData(ErrorCode.MEM_IMPORT_ERR);
}
//导入完成
if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(successCount)) {
if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) {
ResultData ok = new ResultData(Result.SUCCESS, "ok", entries);
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "successCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
return ok;
}


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

@@ -59,7 +59,12 @@ public class WxCardPayController extends BaseController {
public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr();
logger.info("cardPay/cardOrderList: " + ipStr);
if (wxCardVo == null) wxCardVo = new WxCardVo();
if (wxCardVo == null) {wxCardVo = new WxCardVo();}
else {
if(StringUtils.isBlank(wxCardVo.getOuPhone())) {
wxCardVo.setOuPhone(null);
}
}
MallUserInfo user = getUser();
wxCardVo.setTenantId(user.getTenantId());
if(StringUtils.isNotBlank(wxCardVo.getStatusStr())) {


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

@@ -96,7 +96,7 @@ public class WxMerchantController extends BaseController {
public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) {
logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant");
wxMerchant.setTenantId(getTenantId());
return wxMerchantService.addMerchant(wxMerchant);
return wxMerchantService.addMerchant(wxMerchant, getUser().getId());
}

@ApiOperation("更新商户接口")


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

@@ -45,14 +45,14 @@ public class WxPropertyContractController extends BaseController
public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) {
logger.debug("[" + getIpAddr() + "] WxPropertyContractController::add");
wxPropertyContract.setTenantId(getTenantId());
return wxPropertyContractService.saveOrUpdate(wxPropertyContract);
return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId());
}

@PostMapping("update")
public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) {
logger.debug("[" + getIpAddr() + "] WxPropertyContractController::update");
wxPropertyContract.setTenantId(getTenantId());
return wxPropertyContractService.saveOrUpdate(wxPropertyContract);
return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId());
}

@GetMapping("/del")


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

@@ -44,28 +44,28 @@ public class WxRentContractController extends BaseController {
public ResultData add(@RequestBody WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::add");
wxRentContract.setTenantId(getTenantId());
return wxRentContractService.save(wxRentContract);
return wxRentContractService.save(wxRentContract, getUser().getId());
}

@PostMapping("update")
public ResultData update(@RequestBody WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::update");
wxRentContract.setTenantId(getTenantId());
return wxRentContractService.update(wxRentContract);
return wxRentContractService.update(wxRentContract, getUser().getId());
}

@PostMapping("updateMoney")
public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMoney");
wxRentContract.setTenantId(getTenantId());
return wxRentContractService.update(wxRentContract);
return wxRentContractService.update(wxRentContract, getUser().getId());
}

@PostMapping("updateFile")
public ResultData updateFile(@RequestBody WxRentContract wxRentContract) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::updateFile");
wxRentContract.setTenantId(getTenantId());
return wxRentContractService.updateFile(wxRentContract);
return wxRentContractService.updateFile(wxRentContract, getUser().getId());
}


@@ -130,7 +130,7 @@ public class WxRentContractController extends BaseController {
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData updateRentContractStatus(Long id) {
logger.debug("[" + getIpAddr() + "] WxRentContractController::updateRentContractStatus");
return wxRentContractService.updateRentContractStatus(id);
return wxRentContractService.updateRentContractStatus(id, getUser().getId());
}

}

+ 4
- 6
mallinkAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java Просмотреть файл

@@ -1,5 +1,7 @@
package com.iformall.interceptor;

import com.iformall.utils.UrlCheck;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@@ -17,13 +19,8 @@ public class HttpServletRequestWrapperFilter implements Filter {
ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest) {
String url = ((HttpServletRequest) request).getRequestURI();
if (!url.contains("awsFileUpload")
&& !url.contains("cimgUpload")
&& !url.contains("ueditor/exec")
&& !url.contains("/wxCUserBasicInfo/importTemplate")) {
if (!UrlCheck.checkUrl(url)) {
requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request);
} else {
requestWrapper = null;
}
}
if (null == requestWrapper) {
@@ -34,6 +31,7 @@ public class HttpServletRequestWrapperFilter implements Filter {

}


@Override
public void destroy() {



+ 2
- 5
mallinkAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java Просмотреть файл

@@ -4,6 +4,7 @@ import com.iformall.common.ErrorCode;
import com.iformall.exception.MallinkException;
import com.iformall.utils.HashUtil;
import com.iformall.utils.IPUtil;
import com.iformall.utils.UrlCheck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
@@ -43,11 +44,7 @@ public class RequestInterceptor extends HandlerInterceptorAdapter {

String ipaddress = IPUtil.getIpAddr(request);
String url = request.getRequestURL().toString();
if(url.contains("pvlog")
|| url.contains("awsFileUpload")
|| url.contains("cimgUpload")
|| url.contains("ueditor/exec")
|| url.contains("/wxCUserBasicInfo/importTemplate")) {
if (UrlCheck.checkUrl(url)) {
// pvlog不检查幂等
// awsFileUpload不检查幂等
// ueditor 不检查幂等


+ 18
- 0
mallinkAdmin/src/main/java/com/iformall/utils/UrlCheck.java Просмотреть файл

@@ -0,0 +1,18 @@
package com.iformall.utils;

/**
* @author gongbiao
*/
public class UrlCheck {

public static boolean checkUrl(String url) {
return url.contains("awsFileUpload")
|| url.contains("cimgUpload")
|| url.contains("ueditor/exec")
|| url.contains("/wxCUserBasicInfo/importTemplate")
|| url.contains("wxMsgCallback")
|| url.contains("notify")
|| url.contains("pvlog");
}

}

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

@@ -10,7 +10,6 @@ import com.iformall.enums.EnumCampaignStatus;
import com.iformall.enums.EnumCouponChannelType;
import com.iformall.service.WxCampaignService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -38,8 +37,6 @@ public class WxCampaignController extends BaseController {
@Autowired
private WxCampaignService wxCampaignService;
@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCouponChannelService wxCouponChannelService;

@ApiOperation("分页列表接口")
@@ -53,7 +50,7 @@ public class WxCampaignController extends BaseController {
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.setTenantId(getTenantId());
wxCampaign.setSortColumns(SortNum_ASC, CreateTime_ASC);
final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize);
final PageInfo<WxCampaign> page = wxCampaignService.clistAsPage(wxCampaign, pageNum, pageSize);
return new ResultData(page);
}



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

@@ -7,6 +7,7 @@ import com.iformall.service.WxMerchantService;
import com.iformall.utils.HashUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,9 +35,13 @@ public class WxMerchantController extends BaseController {
if(merchantCode == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
String codeMD5 = HashUtil.DecodeByMD5(merchantCode);
if(StringUtils.isBlank(codeMD5)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
HashMap<String, String> params = new HashMap<String, String>();
params.put("tenantId", getTenantId());
params.put("merchantCode", HashUtil.DecodeByMD5(merchantCode));
params.put("merchantCode", codeMD5);
WxMerchantVo wxMerchant = wxMerchantService.getMerchantInfo(params);
return new ResultData(wxMerchant);
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/common/ErrorCode.java Просмотреть файл

@@ -253,7 +253,7 @@ public enum ErrorCode{
/**
* 会员
*/
MEM_IMPORT_ERR(13000, "模板导入失败,请尝试重新导入"),
MEM_IMPORT_ERR(13000, "模板导入失败,请检查数据,尝试重新导入"),
MEM_SCORE_NOT_ENOUGH(13001, "成长值不够扣减值"),

/**


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

@@ -4,6 +4,7 @@ package com.iformall.enums;
* Created by Stormeye on 2018/08/09.
*/
public enum EnumMsgSendStatus {
MSG_SENDING(2, "发送中"),
MSG_SEND_SUCCESS(1,"发送成功"),
MSG_SEND_FAIL(0,"发送失败")
;


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

@@ -9,6 +9,8 @@ public interface WxCampaignMapper extends CommonMapper<WxCampaign, Long> {

List<WxCampaign> findList(WxCampaign wxCampaign);

List<WxCampaign> findCList(WxCampaign wxCampaign);

int getMaxSortNum(String tenantId);


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

@@ -1,10 +1,10 @@
package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.po.WxCUserBasicInfo;
import org.springframework.web.multipart.MultipartFile;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -99,11 +99,11 @@ public interface WxCUserBasicInfoService {
long findCountByScore(WxCUserBasicInfoDto dto);


void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId);
void exportData(WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response);

void exportTemplate(HttpServletRequest request, HttpServletResponse response, String tenantId);

ResultData importTemplate(MultipartFile file, String tenantId, String userId);
void importOneMem(String tenantId, String importKey, List<WxTags> tagList, CUserBaseInfoT uBase);

long findCount(WxCUserBasicInfoDto dto);



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

@@ -8,15 +8,23 @@ import javax.servlet.http.HttpServletResponse;

public interface WxCampaignService {

/**
/**
* 根据实体查询分页列表
*
* @param record
* @param offset
* @param limit
* @param pageIndex
* @param pageSize
* @return
*/
PageInfo<WxCampaign> listAsPage(WxCampaign record, Integer pageIndex, Integer pageSize);

/**
* 根据实体查询分页列表
* @param record
* @param pageIndex
* @param pageSize
* @return
*/
PageInfo<WxCampaign> clistAsPage(WxCampaign record, Integer pageIndex, Integer pageSize);
/**
* 根据Id获得实体


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

@@ -65,7 +65,7 @@ public interface WxMerchantService {

void disable(Long id);

ResultData addMerchant(WxMerchant wxMerchant);
ResultData addMerchant(WxMerchant wxMerchant, Long userId);

ResultData updateMerchant(WxMerchant wxMerchant);



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

@@ -35,7 +35,7 @@ public interface WxPropertyContractService {
*
* @param record
*/
ResultData saveOrUpdate(WxPropertyContract record);
ResultData saveOrUpdate(WxPropertyContract record, Long userId);

/**
* 根据Id删除实体


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

@@ -34,10 +34,11 @@ public interface WxRentContractService {
* 保存或更新实体
*
* @param record
* @param id
*/
ResultData save(WxRentContract record);
ResultData save(WxRentContract record, Long userId);

ResultData update(WxRentContract record);
ResultData update(WxRentContract record, Long userId);

/**
* 根据Id删除实体
@@ -59,9 +60,9 @@ public interface WxRentContractService {

void exportContract(HttpServletRequest request, HttpServletResponse response, String tenantId, Long id);

ResultData updateFile(WxRentContract wxRentContract);
ResultData updateFile(WxRentContract wxRentContract, Long userId);

ResultData updateRentContractStatus(Long id);
ResultData updateRentContractStatus(Long id, Long userId);

void updateApplyStatus(WxRentContract wxRentContract);



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

@@ -6,7 +6,6 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxBillDaily;
import com.iformall.domain.po.WxShop;
import com.iformall.enums.EnumBillDailyStatus;
@@ -16,7 +15,6 @@ import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxBillDailyMapper;
import com.iformall.mapper.WxShopMapper;
import com.iformall.service.WxBillDailyService;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -117,7 +115,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService {
return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(),"实收金额不能大于实际应收金额");
}

MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
if (record.getId() == null) {
logger.info("新增日常账单");
final IdWorker idWorker = IdWorker.get();
@@ -126,7 +123,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService {
record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode());
record.setCreatetime(date);
record.setUpdatetime(date);
record.setUserId(user.getId());
record.setExpiredDay(0L);
record.setOwe(record.getReceivePay()-record.getPay());
record.setIsDel(EnumDelStatus.NOT_DEL.getCode());
@@ -149,7 +145,6 @@ public class WxBillDailyServiceImpl implements WxBillDailyService {
wxBillDaily.setOwe(record.getReceivePay()-record.getPay());
wxBillDaily.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillDaily.getStatus());
wxBillDaily.setUpdatetime(new Date());
wxBillDaily.setUserId(user.getId());
try {
wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily);
} catch (Exception e) {


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

@@ -6,7 +6,6 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxBillOther;
import com.iformall.domain.po.WxShop;
import com.iformall.enums.EnumBillDailyStatus;
@@ -16,7 +15,6 @@ import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxBillOtherMapper;
import com.iformall.mapper.WxShopMapper;
import com.iformall.service.WxBillOtherService;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -116,7 +114,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService {
if(pay>receivepay){
return new ResultData(ErrorCode.BILL_PAY_ERROR,"实收金额不能大于实际应收金额");
}
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
if (record.getId() == null) {
logger.info("新增其他账单");
final IdWorker idWorker = IdWorker.get();
@@ -125,7 +122,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService {
record.setStatus(record.getReceiveDate().after(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode());
record.setCreatetime(date);
record.setUpdatetime(date);
record.setUserId(user.getId());
record.setExpiredDay(0L);
record.setOwe(record.getReceivePay()-record.getPay());
record.setIsDel(EnumDelStatus.NOT_DEL.getCode());
@@ -148,7 +144,6 @@ public class WxBillOtherServiceImpl implements WxBillOtherService {
wxBillOther.setOwe(record.getReceivePay()-record.getPay());
wxBillOther.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillOther.getStatus());
wxBillOther.setUpdatetime(new Date());
wxBillOther.setUserId(user.getId());
try {
wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther);
} catch (Exception e) {


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

@@ -1,19 +1,12 @@
package com.iformall.service.impl;

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.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxCUserTags;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.domain.vo.CUserBaseVo;
@@ -39,9 +32,7 @@ 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.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -153,10 +144,8 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {


@Override
public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) {
WxCUserBasicInfo basicInfoQ = new WxCUserBasicInfo();
basicInfoQ.setTenantId(tenantId);
List<WxCUserBasicInfoVo> memberlist = wxCUserBasicInfoMapper.findVoList(basicInfoQ);
public void exportData(WxCUserBasicInfo basicInfo, HttpServletRequest request, HttpServletResponse response) {
List<WxCUserBasicInfoVo> memberlist = wxCUserBasicInfoMapper.findVoList(basicInfo);

XSSFWorkbook workbook;
String filepath = Constant.fileDirectory;
@@ -500,163 +489,126 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
return userBase;
}

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);
}

}

@Async
@Override
public ResultData importTemplate(MultipartFile file, String tenantId, String userId) {

public void importOneMem(String tenantId, String importKey, List<WxTags> tagList, CUserBaseInfoT uBase) {
final IdWorker idWorker = IdWorker.get();

String importKey = "import-" + userId;

//默认添加到redis里
stringRedisTemplate.opsForHash().put(importKey, "allCount", "");
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "successCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "failCount", "0");

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

try {
ExcelImportResult<CUserBaseInfoT> datalist = ExcelImportUtil.importExcelMore(file.getInputStream(), CUserBaseInfoT.class, params);
List<CUserBaseInfoT> successList = datalist.getList();
List<CUserBaseInfoT> failList = datalist.getFailList();
logger.info("验证通过的数量: " + successList.size());
logger.info("验证未通过的数量: " + failList.size());

successList.parallelStream().forEach(uBase->{
if (StringUtils.isBlank(uBase.getPhone())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error("手机号为空", uBase.toString());
return;
}
WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId);
if (userBase == null) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error("userBase为null", uBase.toString());
return;
}

if (StringUtils.isBlank(uBase.getPhone())) {
logger.error("手机号为空", uBase.toString());
return;
}
WxCUserBasicInfo userBase = InitUserBaseInfo(uBase, tenantId);
if (userBase == null) {
return;
}
WxCUserBasicInfo oldUserBase = null;
WxCUserBasicInfo userBaseQ = new WxCUserBasicInfo();
userBaseQ.setTenantId(tenantId);
userBaseQ.setPhone(userBase.getPhone());
List<WxCUserBasicInfo> userBList = wxCUserBasicInfoMapper.select(userBaseQ);
if (userBList.size() > 0) {
oldUserBase = userBList.get(0);
}

WxCUserBasicInfo oldUserBase = null;
WxCUserBasicInfo userBaseQ = new WxCUserBasicInfo();
userBaseQ.setTenantId(tenantId);
userBaseQ.setPhone(userBase.getPhone());
List<WxCUserBasicInfo> userBList = wxCUserBasicInfoMapper.select(userBaseQ);
if (userBList.size() > 0) {
oldUserBase = userBList.get(0);
}
if (oldUserBase != null) {
oldUserBase.setName(userBase.getName());
oldUserBase.setSex(userBase.getSex());
oldUserBase.setNickName(userBase.getNickName());
oldUserBase.setEducation(userBase.getEducation());
oldUserBase.setBirthdate(userBase.getBirthdate());
oldUserBase.setAddress(userBase.getAddress());
oldUserBase.setUpdateDate(new Date());
oldUserBase.setCreateDate(userBase.getCreateDate());
} else {
userBase.setId(idWorker.nextId());
}

if (oldUserBase != null) {
oldUserBase.setName(userBase.getName());
oldUserBase.setSex(userBase.getSex());
oldUserBase.setNickName(userBase.getNickName());
oldUserBase.setEducation(userBase.getEducation());
oldUserBase.setBirthdate(userBase.getBirthdate());
oldUserBase.setAddress(userBase.getAddress());
oldUserBase.setUpdateDate(new Date());
oldUserBase.setCreateDate(userBase.getCreateDate());
} else {
// check c_user 是否存在
WxCUser cUserQ = new WxCUser();
cUserQ.setTenantId(tenantId);
cUserQ.setPhone(userBase.getPhone());
List<WxCUser> cUsers = wxCUserMapper.findList(cUserQ);
if (cUsers.size() > 0) {
WxCUser wUser = cUsers.get(0);
if (wUser != null) {
userBase.setId(wUser.getId());
userBase.setNickName(wUser.getNickName());
// update 昵称
{
// check c_user 是否存在
WxCUser cUserQ = new WxCUser();
cUserQ.setTenantId(tenantId);
cUserQ.setPhone(userBase.getPhone());
List<WxCUser> userList = wxCUserMapper.select(cUserQ);
if (userList.size() > 0) {
WxCUser user = userList.get(0);
if (user != null) {
if (oldUserBase != null) {
if(oldUserBase != null) {
oldUserBase.setNickName(user.getNickName());
}
userBase.setId(user.getId());
userBase.setNickName(user.getNickName());
} else {
userBase.setId(idWorker.nextId());

userBase.setNickName(user.getNickName());
}
}
}
}

// update 昵称
if (oldUserBase != null) {
WxCUser cUserQ = new WxCUser();
cUserQ.setTenantId(tenantId);
cUserQ.setPhone(userBase.getPhone());
List<WxCUser> userList = wxCUserMapper.select(cUserQ);
if (userList.size() > 0) {
WxCUser user = userList.get(0);
if (user != null) {
if (oldUserBase != null) {
oldUserBase.setNickName(user.getNickName());
} else {
userBase.setNickName(user.getNickName());
}
if (oldUserBase != null) {
logger.info("update user base: " + oldUserBase.getId());
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase);
} else {
logger.info("insert user base: " + userBase.getId());
try {
wxCUserBasicInfoMapper.insertSelective(userBase);
} catch (Exception e) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error(e.getMessage());
return;
}
}
// update tags
try {
if (StringUtils.isNotBlank(userBase.getTagNames())) {
// get tag ids
String tagNames = userBase.getTagNames();
List<Long> tagIdList = new ArrayList<>();
for (String tagName : tagNames.split("/")) {
for(WxTags tag: tagList) {
if(tagName.equals(tag.getName())) {
tagIdList.add(Long.valueOf(tag.getId()));
break;
}
}
}

if (oldUserBase != null) {
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase);
} else {
wxCUserBasicInfoMapper.insertSelective(userBase);
if (oldUserBase != null){
wxCUserTagsService.assignTags(tagIdList,oldUserBase);
}else{
wxCUserTagsService.assignTags(tagIdList,userBase);
}
// update tags
if (StringUtils.isNotBlank(userBase.getTagNames())) {
// get tag ids
String tagNames = userBase.getTagNames();
List<Long> tagIdList = new ArrayList<>();
for (String tagName : tagNames.split("/")) {
List<WxTags> wxTagsList = wxTagsMapper.getByName(tagName);
if (wxTagsList.size()==1) {
WxTags wxTags = wxTagsList.get(0);
tagIdList.add(Long.valueOf(wxTags.getId()));
}
}
}

if (oldUserBase != null){
wxCUserTagsService.assignTags(tagIdList,oldUserBase);
}else{
wxCUserTagsService.assignTags(tagIdList,userBase);
}
}
//触发自动打标签
if (oldUserBase != null) {
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase);
}
else{
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase);
}

//触发自动打标签
// 成长值
if (StringUtils.isNotBlank(uBase.getPoins())) {
if (oldUserBase != null) {
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,oldUserBase);
}
else{
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase);
}

// 成长值
if (StringUtils.isNotBlank(uBase.getPoins())) {
if (oldUserBase != null) {
wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins());
} else {
wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins());
}
wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins());
} else {
wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins());
}

//记数
stringRedisTemplate.opsForHash().increment(userId,"successCount",1);
});
}
} catch (Exception e) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", "1");
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "successCount", "0");
stringRedisTemplate.opsForHash().put(importKey, "failCount", "1");
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
logger.error(e.getMessage());
logger.error("打标签+成长值失败--继续导入");
}

return new ResultData();
//记数
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1);
}

@Override


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

@@ -56,6 +56,11 @@ public class WxCampaignServiceImpl implements WxCampaignService {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCampaignMapper.findList(record));
}

@Override
public PageInfo<WxCampaign> clistAsPage(WxCampaign record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCampaignMapper.findCList(record));
}

@Override
public WxCampaign getById(Long id) {
WxCampaign wxCampaign = wxCampaignMapper.selectByPrimaryKey(id);


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

@@ -116,18 +116,22 @@ public class WxCouponServiceImpl implements WxCouponService {
if(record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
record.getType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) {
Integer subsidyType = record.getSubsidyType();
Integer subsidyNum = record.getSubsidyNum();
if(subsidyType == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴类型");
}
if(subsidyNum == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴金额");
}
if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_COUPON.getCode())) {
// 微信 立减
if(record.getSubsidyNum() > record.getSalePrice()) {
if(subsidyNum > record.getSalePrice()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于售价");
}
} else if(subsidyType.equals(EnumCouponSubsidyType.OFFLINE_SUBSIDY.getCode())) {
// 线下补贴
int subsidy_num = record.getPrice() - record.getSalePrice();
if(record.getSubsidyNum() > subsidy_num) {
if(subsidyNum > subsidy_num) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于面额与售价的差值");
}
} else if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_MCHPAY.getCode())) {


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

@@ -14,7 +14,6 @@ import com.iformall.mapper.*;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxProfitSharingReceiverService;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -220,6 +219,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop);
//更新商铺状态
WxShop wxShop = new WxShop();
wxShop.setTenantId(wxMerchant.getTenantId());
wxShop.setId(wxMerchantShop.getShopId());
wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode());
wxShopMapper.updateByPrimaryKeySelective(wxShop);
@@ -234,12 +234,14 @@ public class WxMerchantServiceImpl implements WxMerchantService {
}
//作废卡券
WxCouponMerchant wxCouponMerchant = new WxCouponMerchant();
wxCouponMerchant.setTenantId(wxMerchant.getTenantId());
wxCouponMerchant.setMerchantId(wxMerchant.getId());
wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant);
List<Long> couponIds = wxCouponMerchantList.stream().map(cm->cm.getProductId()).collect(Collectors.toList());
WxCoupon wxCoupon = new WxCoupon();
couponIds.parallelStream().filter(cid->!isCouponMerchantValid(cid)).forEach(cid->{

couponIds.stream().filter(cid->!isCouponMerchantValid(cid)).forEach(cid->{
WxCoupon wxCoupon = new WxCoupon();
wxCoupon.setId(cid);
wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode());
wxCouponService.saveOrUpdate(wxCoupon);
@@ -248,7 +250,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData addMerchant(WxMerchant wxMerchant) {
public ResultData addMerchant(WxMerchant wxMerchant, Long userId) {
try {

final IdWorker idWorker = IdWorker.get();
@@ -309,9 +311,9 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode());
wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract);
//创建账单
buildRent(wxMerchant);
buildRent(wxMerchant, userId);
//创建押金
buildDeposit(wxMerchant);
buildDeposit(wxMerchant, userId);
}
return new ResultData(Result.SUCCESS, "商户创建成功", merchantId);
} catch (Exception e) {
@@ -507,8 +509,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {


@Transactional(rollbackFor = {Exception.class})
public void buildDeposit(WxMerchant wxMerchant) {
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
public void buildDeposit(WxMerchant wxMerchant, Long userId) {
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setMerchantId(wxMerchant.getId());
List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract);
@@ -555,7 +556,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxBillDeposit.setTenantId(wxMerchant.getTenantId());
wxBillDeposit.setIsDel(0);
wxBillDeposit.setMerchantId(wxMerchant.getId());
wxBillDeposit.setUserId(user.getId());
wxBillDeposit.setUserId(userId);
wxBillDeposit.setShopId(wxRentContract.getShopId());
wxBillDeposit.setCreatetime(date);
wxBillDeposit.setUpdatetime(date);
@@ -569,10 +570,8 @@ public class WxMerchantServiceImpl implements WxMerchantService {
}

@Transactional(rollbackFor = {Exception.class})
public void buildRent(WxMerchant wxMerchant) {
public void buildRent(WxMerchant wxMerchant, Long userId) {

//获取用户
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setMerchantId(wxMerchant.getId());
//根据商户ID找出合同
@@ -653,7 +652,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxBillRent.setTenantId(wxRentContract.getTenantId());
wxBillRent.setIsDel(0);
wxBillRent.setMerchantId(wxRentContract.getMerchantId());
wxBillRent.setUserId(user.getId());
wxBillRent.setUserId(userId);
wxBillRent.setShopId(wxRentContract.getShopId());
wxBillRent.setCreatetime(date);
wxBillRent.setUpdatetime(date);


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

@@ -83,7 +83,11 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService {
if(callback!=null){//有更新,无插入
callback.setSign(param.get("sign"));
callback.setTenantId(tenantId);
callback.setStatus(wxMsgCallback.getStatus());
if (!wxMsgCallback.getStatus().equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode())) {
callback.setStatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode());
} else {
callback.setStatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode());
}
callback.setStatusMsg(wxMsgCallback.getStatusMsg());
callback.setBegintime(wxMsgCallback.getBegintime());
callback.setEndtime(wxMsgCallback.getEndtime());


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

@@ -262,7 +262,8 @@ public class WxMsgServiceImpl implements WxMsgService {
wxMsgCallback.setTenantId(wxmsg.getTenantId());
wxMsgCallback.setBatchNo(batchNo);
wxMsgCallback.setMsgId(wxmsg.getId());
wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode());
wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SENDING.getCode());
wxMsgCallback.setStatusMsg(EnumMsgSendStatus.MSG_SENDING.getMessage());
wxMsgCallback.setCreatetime(new Date());
wxMsgCallbackMapper.insertSelective(wxMsgCallback);
}


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

@@ -15,7 +15,6 @@ import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.WxPropertyContractService;
import com.iformall.utils.Constant;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -100,7 +99,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}

@Override
public ResultData saveOrUpdate(WxPropertyContract record) {
public ResultData saveOrUpdate(WxPropertyContract record, Long userId) {

if (null == record.getShopId()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "shopId不能为空");
@@ -188,9 +187,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
wxMerchant.setId(record.getMerchantId());
wxMerchant.setTenantId(record.getTenantId());
//物业账单
buildProperty(wxMerchant);
buildProperty(wxMerchant, userId);
//物业押金账单
buildDeposit(wxMerchant);
buildDeposit(wxMerchant, userId);
}
}
} catch (Exception e) {
@@ -231,8 +230,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}

@Transactional(rollbackFor = {Exception.class})
public void buildDeposit(WxMerchant wxMerchant) {
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
public void buildDeposit(WxMerchant wxMerchant, Long userId) {
WxPropertyContract wxPropertyContract = new WxPropertyContract();
wxPropertyContract.setMerchantId(wxMerchant.getId());
List<WxPropertyContract> list = wxPropertyContractMapper.findList(wxPropertyContract);
@@ -276,7 +274,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
wxBillDeposit.setTenantId(wxMerchant.getTenantId());
wxBillDeposit.setIsDel(0);
wxBillDeposit.setMerchantId(wxMerchant.getId());
wxBillDeposit.setUserId(user.getId());
wxBillDeposit.setUserId(userId);
wxBillDeposit.setShopId(wxPropertyContract.getShopId());
wxBillDeposit.setCreatetime(date);
wxBillDeposit.setUpdatetime(date);
@@ -291,9 +289,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}

@Transactional(rollbackFor = {Exception.class})
public void buildProperty(WxMerchant wxMerchant) {
//获取用户
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
public void buildProperty(WxMerchant wxMerchant, Long userId) {
//根据商户ID找出合同
WxPropertyContract wxPropertyContract = new WxPropertyContract();
wxPropertyContract.setMerchantId(wxMerchant.getId());
@@ -371,7 +367,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
wxBillProperty.setTenantId(wxMerchant.getTenantId());
wxBillProperty.setIsDel(0);
wxBillProperty.setMerchantId(wxMerchant.getId());
wxBillProperty.setUserId(user.getId());
wxBillProperty.setUserId(userId);
wxBillProperty.setShopId(wxPropertyContract.getShopId());
wxBillProperty.setCreatetime(date);
wxBillProperty.setUpdatetime(date);


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

@@ -18,7 +18,6 @@ import com.iformall.utils.DateUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -118,7 +117,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData save(WxRentContract record) {
public ResultData save(WxRentContract record, Long userId) {
//保存租赁合同信息
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
@@ -178,9 +177,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxMerchant.setId(record.getMerchantId());
wxMerchant.setTenantId(record.getTenantId());
//租金
buildRent(wxMerchant);
buildRent(wxMerchant, userId);
//押金
buildDeposit(wxMerchant);
buildDeposit(wxMerchant, userId);
}
}
} catch (Exception e) {
@@ -192,11 +191,11 @@ public class WxRentContractServiceImpl implements WxRentContractService {

@Transactional(rollbackFor = {Exception.class})
@Override
public ResultData update(WxRentContract record) {
return getResultDataForUpdate(record);
public ResultData update(WxRentContract record, Long userId) {
return getResultDataForUpdate(record, userId);
}

public ResultData getResultDataForUpdate(WxRentContract record) {
public ResultData getResultDataForUpdate(WxRentContract record, Long userId) {
//更新租赁合同信息
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId());
if (wxRentContract == null) {
@@ -254,9 +253,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxMerchant.setId(record.getMerchantId());
wxMerchant.setTenantId(record.getTenantId());
//租金
buildRent(wxMerchant);
buildRent(wxMerchant, userId);
//押金
buildDeposit(wxMerchant);
buildDeposit(wxMerchant, userId);
}
}
} catch (Exception e) {
@@ -268,8 +267,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {


@Transactional(rollbackFor = {Exception.class})
public void buildDeposit(WxMerchant wxMerchant) {
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
public void buildDeposit(WxMerchant wxMerchant, Long userId) {
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setMerchantId(wxMerchant.getId());
List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract);
@@ -318,7 +316,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillDeposit.setTenantId(wxMerchant.getTenantId());
wxBillDeposit.setIsDel(0);
wxBillDeposit.setMerchantId(wxMerchant.getId());
wxBillDeposit.setUserId(user.getId());
wxBillDeposit.setUserId(userId);
wxBillDeposit.setShopId(wxRentContract.getShopId());
wxBillDeposit.setCreatetime(date);
wxBillDeposit.setUpdatetime(date);
@@ -334,10 +332,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}

@Transactional(rollbackFor = {Exception.class})
public void buildRent(WxMerchant wxMerchant) {

//获取用户
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession");
public void buildRent(WxMerchant wxMerchant, Long userId) {

//根据商户ID找出合同
WxRentContract wxRentContract = new WxRentContract();
@@ -419,7 +414,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setTenantId(wxMerchant.getTenantId());
wxBillRent.setIsDel(0);
wxBillRent.setMerchantId(wxMerchant.getId());
wxBillRent.setUserId(user.getId());
wxBillRent.setUserId(userId);
wxBillRent.setShopId(wxRentContract.getShopId());
wxBillRent.setCreatetime(date);
wxBillRent.setUpdatetime(date);
@@ -714,12 +709,12 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}

@Override
public ResultData updateFile(WxRentContract record) {
return getResultDataForUpdate(record);
public ResultData updateFile(WxRentContract record, Long userId) {
return getResultDataForUpdate(record, userId);
}

@Override
public ResultData updateRentContractStatus(Long id) {
public ResultData updateRentContractStatus(Long id, Long userId) {
if(id == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
@@ -744,9 +739,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxMerchant.setId(record.getMerchantId());
wxMerchant.setTenantId(record.getTenantId());
//租金
buildRent(wxMerchant);
buildRent(wxMerchant, userId);
//押金
buildDeposit(wxMerchant);
buildDeposit(wxMerchant, userId);
}
}
return new ResultData(Result.SUCCESS, "操作成功");


+ 9
- 3
mallinkService/src/main/java/com/iformall/utils/HashUtil.java Просмотреть файл

@@ -91,7 +91,7 @@ public class HashUtil {
}
try {
String enc = hash("md5", str);
enc = new String(Base64.getUrlEncoder().encode(enc.getBytes("utf-8")));
enc = new String(Base64.getUrlEncoder().encode(enc.getBytes("utf-8")), "utf-8");
return enc;
} catch (UnsupportedEncodingException e) {
return null;
@@ -102,7 +102,13 @@ public class HashUtil {
if (str == null) {
return null;
}
String dec = new String(Base64.getUrlDecoder().decode(str));
return dec;
try {
String dec = new String(Base64.getUrlDecoder().decode(str), "utf-8");
return dec;
} catch (Exception e) {
System.out.println(str);
System.out.println(e.getMessage());
return null;
}
}
}

+ 15
- 1
mallinkService/src/main/resources/mapper/WxCampaignMapper.xml Просмотреть файл

@@ -29,6 +29,15 @@
`mechant_id`,`sort_num`,`status`,`create_time`,`update_time`,`html`
</sql>

<sql id="allCHeadColumns">
`id`,`tenant_id`,`cover_img`,`title`,`type`,`sort_num`
</sql>

<sql id="allAHeadColumns">
`id`,`tenant_id`,`cover_img`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`,
`mechant_id`,`sort_num`,`status`,`create_time`,`update_time`
</sql>

<sql id="dynamicWhereConditions">
where 1 = 1

@@ -131,10 +140,15 @@
</sql>

<select id="findList" parameterType="com.iformall.domain.po.WxCampaign" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_campaign
select <include refid="allAHeadColumns" /> from wx_campaign
<include refid="dynamicWhereConditions" />
</select>

<select id="findCList" parameterType="com.iformall.domain.po.WxCampaign" resultMap="BaseResultMap">
select <include refid="allCHeadColumns" /> from wx_campaign
<include refid="dynamicWhereConditions" />
</select>

<select id="getMaxSortNum" parameterType="java.lang.String" resultType="java.lang.Integer">
select max(sort_num) from wx_campaign where `tenant_id` = #{tenantId}
</select>


+ 3
- 3
mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml Просмотреть файл

@@ -38,9 +38,9 @@
<if test=" null != batchNo ">
and `batch_no` like concat('%', #{batchNo},'%')
</if>
<if test=" null != phone ">
</if>
<if test=" null != phone and phone!=''">
and `phone` like concat('%', #{phone},'%')
</if>


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