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

Merge branch 'release_toaliyun_real_20230308' of https://git.malls.iformall.com/server/formallProject into release_toaliyun_real_20230308

release_toaliyun_real
xhxu 3 лет назад
Родитель
Сommit
0e791a5595
16 измененных файлов: 483 добавлений и 19 удалений
  1. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponBatchController.java
  2. +105
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java
  3. +75
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java
  4. +206
    -0
      mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql
  5. +14
    -0
      mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java
  6. +24
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxCardPriceTemplate.java
  7. +3
    -3
      mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchItemMapper.java
  8. +1
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchMapper.java
  9. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxCouponBatchService.java
  10. +4
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java
  11. +3
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java
  12. +35
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java
  13. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  14. +3
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java
  15. +6
    -6
      mallinkService/src/main/resources/mapper/WxCouponBatchItemMapper.xml
  16. +1
    -1
      mallinkService/src/main/resources/mapper/WxCouponBatchMapper.xml

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

@@ -101,7 +101,7 @@ public class WxCouponBatchController extends BaseController {
return new ResultData(order);
}
@ApiOperation("砍价券接口")
@ApiOperation("券接口")
@GetMapping("itemList")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),


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

@@ -4,10 +4,13 @@ import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.controller.mem.AsyncTask;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
@@ -15,15 +18,27 @@ import com.iformall.domain.vo.WxCouponPasswordVo;
import com.iformall.enums.EnumCouponPasswordStatus;
import com.iformall.enums.EnumCouponSubsidyType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.utils.Constant;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
* @author gongbiao
@@ -36,6 +51,13 @@ public class WxCouponPasswordController extends BaseController {

@Autowired
private WxCouponPasswordService wxCouponPasswordService;
@Autowired
StringRedisTemplate stringRedisTemplate;
@Autowired
private AsyncTask asyncTask;
@Autowired
private String fmUploadDir;

@ApiOperation("分页列表接口")
@GetMapping("/list")
@@ -136,6 +158,89 @@ public class WxCouponPasswordController extends BaseController {
wxCouponPasswordService.setPrice(wxCouponPassword);
return new ResultData();
}
@TenantIgnore
@PostMapping(value = "/importPrice", consumes = "multipart/*")
@SystemControllerLog(description = "消费卡批量导入面额")
public ResultData importPrice(@RequestParam("file") MultipartFile mFile) {
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importCardPrice + userId;

//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
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 = fmUploadDir;
File targetFile = new File(fpath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = "1.xlsx";
int dot = mFile.getOriginalFilename().lastIndexOf('.');
fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length());

File lFile = new File(fpath + File.separator + fileName);

FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
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.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(), "模板上传失败");
} 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(), "模板上传失败");
}
}
}

asyncTask.importExcelData(lFile, user, importKey);

return new ResultData(Result.SUCCESS, "模板正在导入");
}


}

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

@@ -9,8 +9,10 @@ import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxTags;
import com.iformall.domain.vo.CUserBaseInfoT;
import com.iformall.domain.vo.MerchantPoiT;
import com.iformall.domain.vo.WxCardPriceTemplate;
import com.iformall.service.TtMerchantPoiService;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.service.WxTagsService;
import org.apache.shiro.session.UnknownSessionException;
import org.slf4j.Logger;
@@ -36,6 +38,9 @@ public class AsyncTask {

@Autowired
private WxTagsService wxTagsService;
@Autowired
private WxCouponPasswordService wxCouponPasswordService;

@Autowired
StringRedisTemplate stringRedisTemplate;
@@ -46,7 +51,6 @@ public class AsyncTask {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

@@ -58,7 +62,17 @@ public class AsyncTask {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}

}
private class CardPriceExcelHandler extends ExcelDataHandlerDefaultImpl<WxCardPriceTemplate> {
@Override
public Object importHandler(WxCardPriceTemplate obj, String name, Object value) {
if (value == null) {
value = "";
}
return super.importHandler(obj, name, value);
}

@@ -195,4 +209,63 @@ public class AsyncTask {
}
}
}
@Async
public void importCardPriceData(File file, MallUserInfo user, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"卡ID", "面额(元)"});
IExcelDataHandler<WxCardPriceTemplate> handler = new AsyncTask.CardPriceExcelHandler();
handler.setNeedHandlerFields(new String[]{"卡ID","面额(元)"});
params.setNeedVerify(true);

ExcelImportResult<WxCardPriceTemplate> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, WxCardPriceTemplate.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<WxCardPriceTemplate> successList = datalist.getList();
List<WxCardPriceTemplate> failList = datalist.getFailList();

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

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, total == all_fail);

if(successList.size() > 0) {
try {
successList.parallelStream().forEach(poiBase -> {
try {
wxCouponPasswordService.importPrice(user,importKey, poiBase);
} catch (UnknownSessionException ue) {
logger.error("session :"+ue.getMessage());
}
});
} catch (Exception e) {
set_redis_value(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
logger.error("导入模板失败:"+e.getMessage());
}
}
}
}

+ 206
- 0
mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql Просмотреть файл

@@ -22,3 +22,209 @@ CREATE TABLE `wx_coupon_batch_item` (
`parent_tenant_id` varchar(5) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

create table wx_coupon_batch_0 like wx_coupon_batch;
create table wx_coupon_batch_1 like wx_coupon_batch;
create table wx_coupon_batch_2 like wx_coupon_batch;
create table wx_coupon_batch_3 like wx_coupon_batch;
create table wx_coupon_batch_4 like wx_coupon_batch;
create table wx_coupon_batch_5 like wx_coupon_batch;
create table wx_coupon_batch_6 like wx_coupon_batch;
create table wx_coupon_batch_7 like wx_coupon_batch;
create table wx_coupon_batch_8 like wx_coupon_batch;
create table wx_coupon_batch_9 like wx_coupon_batch;
create table wx_coupon_batch_10 like wx_coupon_batch;
create table wx_coupon_batch_11 like wx_coupon_batch;
create table wx_coupon_batch_12 like wx_coupon_batch;
create table wx_coupon_batch_13 like wx_coupon_batch;
create table wx_coupon_batch_14 like wx_coupon_batch;
create table wx_coupon_batch_15 like wx_coupon_batch;
create table wx_coupon_batch_16 like wx_coupon_batch;
create table wx_coupon_batch_17 like wx_coupon_batch;
create table wx_coupon_batch_18 like wx_coupon_batch;
create table wx_coupon_batch_19 like wx_coupon_batch;
create table wx_coupon_batch_20 like wx_coupon_batch;
create table wx_coupon_batch_21 like wx_coupon_batch;
create table wx_coupon_batch_22 like wx_coupon_batch;
create table wx_coupon_batch_23 like wx_coupon_batch;
create table wx_coupon_batch_24 like wx_coupon_batch;
create table wx_coupon_batch_25 like wx_coupon_batch;
create table wx_coupon_batch_26 like wx_coupon_batch;
create table wx_coupon_batch_27 like wx_coupon_batch;
create table wx_coupon_batch_28 like wx_coupon_batch;
create table wx_coupon_batch_29 like wx_coupon_batch;
create table wx_coupon_batch_30 like wx_coupon_batch;
create table wx_coupon_batch_31 like wx_coupon_batch;
create table wx_coupon_batch_32 like wx_coupon_batch;
create table wx_coupon_batch_33 like wx_coupon_batch;
create table wx_coupon_batch_34 like wx_coupon_batch;
create table wx_coupon_batch_35 like wx_coupon_batch;
create table wx_coupon_batch_36 like wx_coupon_batch;
create table wx_coupon_batch_37 like wx_coupon_batch;
create table wx_coupon_batch_38 like wx_coupon_batch;
create table wx_coupon_batch_39 like wx_coupon_batch;
create table wx_coupon_batch_40 like wx_coupon_batch;
create table wx_coupon_batch_41 like wx_coupon_batch;
create table wx_coupon_batch_42 like wx_coupon_batch;
create table wx_coupon_batch_43 like wx_coupon_batch;
create table wx_coupon_batch_44 like wx_coupon_batch;
create table wx_coupon_batch_45 like wx_coupon_batch;
create table wx_coupon_batch_46 like wx_coupon_batch;
create table wx_coupon_batch_47 like wx_coupon_batch;
create table wx_coupon_batch_48 like wx_coupon_batch;
create table wx_coupon_batch_49 like wx_coupon_batch;
create table wx_coupon_batch_50 like wx_coupon_batch;
create table wx_coupon_batch_51 like wx_coupon_batch;
create table wx_coupon_batch_52 like wx_coupon_batch;
create table wx_coupon_batch_53 like wx_coupon_batch;
create table wx_coupon_batch_54 like wx_coupon_batch;
create table wx_coupon_batch_55 like wx_coupon_batch;
create table wx_coupon_batch_56 like wx_coupon_batch;
create table wx_coupon_batch_57 like wx_coupon_batch;
create table wx_coupon_batch_58 like wx_coupon_batch;
create table wx_coupon_batch_59 like wx_coupon_batch;
create table wx_coupon_batch_60 like wx_coupon_batch;
create table wx_coupon_batch_61 like wx_coupon_batch;
create table wx_coupon_batch_62 like wx_coupon_batch;
create table wx_coupon_batch_63 like wx_coupon_batch;
create table wx_coupon_batch_64 like wx_coupon_batch;
create table wx_coupon_batch_65 like wx_coupon_batch;
create table wx_coupon_batch_66 like wx_coupon_batch;
create table wx_coupon_batch_67 like wx_coupon_batch;
create table wx_coupon_batch_68 like wx_coupon_batch;
create table wx_coupon_batch_69 like wx_coupon_batch;
create table wx_coupon_batch_70 like wx_coupon_batch;
create table wx_coupon_batch_71 like wx_coupon_batch;
create table wx_coupon_batch_72 like wx_coupon_batch;
create table wx_coupon_batch_73 like wx_coupon_batch;
create table wx_coupon_batch_74 like wx_coupon_batch;
create table wx_coupon_batch_75 like wx_coupon_batch;
create table wx_coupon_batch_76 like wx_coupon_batch;
create table wx_coupon_batch_77 like wx_coupon_batch;
create table wx_coupon_batch_78 like wx_coupon_batch;
create table wx_coupon_batch_79 like wx_coupon_batch;
create table wx_coupon_batch_80 like wx_coupon_batch;
create table wx_coupon_batch_81 like wx_coupon_batch;
create table wx_coupon_batch_82 like wx_coupon_batch;
create table wx_coupon_batch_83 like wx_coupon_batch;
create table wx_coupon_batch_84 like wx_coupon_batch;
create table wx_coupon_batch_85 like wx_coupon_batch;
create table wx_coupon_batch_86 like wx_coupon_batch;
create table wx_coupon_batch_87 like wx_coupon_batch;
create table wx_coupon_batch_88 like wx_coupon_batch;
create table wx_coupon_batch_89 like wx_coupon_batch;
create table wx_coupon_batch_90 like wx_coupon_batch;
create table wx_coupon_batch_91 like wx_coupon_batch;
create table wx_coupon_batch_92 like wx_coupon_batch;
create table wx_coupon_batch_93 like wx_coupon_batch;
create table wx_coupon_batch_94 like wx_coupon_batch;
create table wx_coupon_batch_95 like wx_coupon_batch;
create table wx_coupon_batch_96 like wx_coupon_batch;
create table wx_coupon_batch_97 like wx_coupon_batch;
create table wx_coupon_batch_98 like wx_coupon_batch;
create table wx_coupon_batch_99 like wx_coupon_batch;

drop table wx_coupon_batch;

create table wx_coupon_batch_item_0 like wx_coupon_batch_item;
create table wx_coupon_batch_item_1 like wx_coupon_batch_item;
create table wx_coupon_batch_item_2 like wx_coupon_batch_item;
create table wx_coupon_batch_item_3 like wx_coupon_batch_item;
create table wx_coupon_batch_item_4 like wx_coupon_batch_item;
create table wx_coupon_batch_item_5 like wx_coupon_batch_item;
create table wx_coupon_batch_item_6 like wx_coupon_batch_item;
create table wx_coupon_batch_item_7 like wx_coupon_batch_item;
create table wx_coupon_batch_item_8 like wx_coupon_batch_item;
create table wx_coupon_batch_item_9 like wx_coupon_batch_item;
create table wx_coupon_batch_item_10 like wx_coupon_batch_item;
create table wx_coupon_batch_item_11 like wx_coupon_batch_item;
create table wx_coupon_batch_item_12 like wx_coupon_batch_item;
create table wx_coupon_batch_item_13 like wx_coupon_batch_item;
create table wx_coupon_batch_item_14 like wx_coupon_batch_item;
create table wx_coupon_batch_item_15 like wx_coupon_batch_item;
create table wx_coupon_batch_item_16 like wx_coupon_batch_item;
create table wx_coupon_batch_item_17 like wx_coupon_batch_item;
create table wx_coupon_batch_item_18 like wx_coupon_batch_item;
create table wx_coupon_batch_item_19 like wx_coupon_batch_item;
create table wx_coupon_batch_item_20 like wx_coupon_batch_item;
create table wx_coupon_batch_item_21 like wx_coupon_batch_item;
create table wx_coupon_batch_item_22 like wx_coupon_batch_item;
create table wx_coupon_batch_item_23 like wx_coupon_batch_item;
create table wx_coupon_batch_item_24 like wx_coupon_batch_item;
create table wx_coupon_batch_item_25 like wx_coupon_batch_item;
create table wx_coupon_batch_item_26 like wx_coupon_batch_item;
create table wx_coupon_batch_item_27 like wx_coupon_batch_item;
create table wx_coupon_batch_item_28 like wx_coupon_batch_item;
create table wx_coupon_batch_item_29 like wx_coupon_batch_item;
create table wx_coupon_batch_item_30 like wx_coupon_batch_item;
create table wx_coupon_batch_item_31 like wx_coupon_batch_item;
create table wx_coupon_batch_item_32 like wx_coupon_batch_item;
create table wx_coupon_batch_item_33 like wx_coupon_batch_item;
create table wx_coupon_batch_item_34 like wx_coupon_batch_item;
create table wx_coupon_batch_item_35 like wx_coupon_batch_item;
create table wx_coupon_batch_item_36 like wx_coupon_batch_item;
create table wx_coupon_batch_item_37 like wx_coupon_batch_item;
create table wx_coupon_batch_item_38 like wx_coupon_batch_item;
create table wx_coupon_batch_item_39 like wx_coupon_batch_item;
create table wx_coupon_batch_item_40 like wx_coupon_batch_item;
create table wx_coupon_batch_item_41 like wx_coupon_batch_item;
create table wx_coupon_batch_item_42 like wx_coupon_batch_item;
create table wx_coupon_batch_item_43 like wx_coupon_batch_item;
create table wx_coupon_batch_item_44 like wx_coupon_batch_item;
create table wx_coupon_batch_item_45 like wx_coupon_batch_item;
create table wx_coupon_batch_item_46 like wx_coupon_batch_item;
create table wx_coupon_batch_item_47 like wx_coupon_batch_item;
create table wx_coupon_batch_item_48 like wx_coupon_batch_item;
create table wx_coupon_batch_item_49 like wx_coupon_batch_item;
create table wx_coupon_batch_item_50 like wx_coupon_batch_item;
create table wx_coupon_batch_item_51 like wx_coupon_batch_item;
create table wx_coupon_batch_item_52 like wx_coupon_batch_item;
create table wx_coupon_batch_item_53 like wx_coupon_batch_item;
create table wx_coupon_batch_item_54 like wx_coupon_batch_item;
create table wx_coupon_batch_item_55 like wx_coupon_batch_item;
create table wx_coupon_batch_item_56 like wx_coupon_batch_item;
create table wx_coupon_batch_item_57 like wx_coupon_batch_item;
create table wx_coupon_batch_item_58 like wx_coupon_batch_item;
create table wx_coupon_batch_item_59 like wx_coupon_batch_item;
create table wx_coupon_batch_item_60 like wx_coupon_batch_item;
create table wx_coupon_batch_item_61 like wx_coupon_batch_item;
create table wx_coupon_batch_item_62 like wx_coupon_batch_item;
create table wx_coupon_batch_item_63 like wx_coupon_batch_item;
create table wx_coupon_batch_item_64 like wx_coupon_batch_item;
create table wx_coupon_batch_item_65 like wx_coupon_batch_item;
create table wx_coupon_batch_item_66 like wx_coupon_batch_item;
create table wx_coupon_batch_item_67 like wx_coupon_batch_item;
create table wx_coupon_batch_item_68 like wx_coupon_batch_item;
create table wx_coupon_batch_item_69 like wx_coupon_batch_item;
create table wx_coupon_batch_item_70 like wx_coupon_batch_item;
create table wx_coupon_batch_item_71 like wx_coupon_batch_item;
create table wx_coupon_batch_item_72 like wx_coupon_batch_item;
create table wx_coupon_batch_item_73 like wx_coupon_batch_item;
create table wx_coupon_batch_item_74 like wx_coupon_batch_item;
create table wx_coupon_batch_item_75 like wx_coupon_batch_item;
create table wx_coupon_batch_item_76 like wx_coupon_batch_item;
create table wx_coupon_batch_item_77 like wx_coupon_batch_item;
create table wx_coupon_batch_item_78 like wx_coupon_batch_item;
create table wx_coupon_batch_item_79 like wx_coupon_batch_item;
create table wx_coupon_batch_item_80 like wx_coupon_batch_item;
create table wx_coupon_batch_item_81 like wx_coupon_batch_item;
create table wx_coupon_batch_item_82 like wx_coupon_batch_item;
create table wx_coupon_batch_item_83 like wx_coupon_batch_item;
create table wx_coupon_batch_item_84 like wx_coupon_batch_item;
create table wx_coupon_batch_item_85 like wx_coupon_batch_item;
create table wx_coupon_batch_item_86 like wx_coupon_batch_item;
create table wx_coupon_batch_item_87 like wx_coupon_batch_item;
create table wx_coupon_batch_item_88 like wx_coupon_batch_item;
create table wx_coupon_batch_item_89 like wx_coupon_batch_item;
create table wx_coupon_batch_item_90 like wx_coupon_batch_item;
create table wx_coupon_batch_item_91 like wx_coupon_batch_item;
create table wx_coupon_batch_item_92 like wx_coupon_batch_item;
create table wx_coupon_batch_item_93 like wx_coupon_batch_item;
create table wx_coupon_batch_item_94 like wx_coupon_batch_item;
create table wx_coupon_batch_item_95 like wx_coupon_batch_item;
create table wx_coupon_batch_item_96 like wx_coupon_batch_item;
create table wx_coupon_batch_item_97 like wx_coupon_batch_item;
create table wx_coupon_batch_item_98 like wx_coupon_batch_item;
create table wx_coupon_batch_item_99 like wx_coupon_batch_item;

drop table wx_coupon_batch_item;

+ 14
- 0
mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java Просмотреть файл

@@ -337,6 +337,20 @@ public class BaseMyBatisConfiguration {
wxCarPayOrderSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxCarPayOrderSharding);
ShardingSphere wxCouponBatchSharding = new ShardingSphere();
wxCouponBatchSharding.setColumn("tenant_id");
wxCouponBatchSharding.setTableName("wx_coupon_batch");
wxCouponBatchSharding.setCount(100);
wxCouponBatchSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxCouponBatchSharding);
ShardingSphere wxCouponBatchItemSharding = new ShardingSphere();
wxCouponBatchItemSharding.setColumn("tenant_id");
wxCouponBatchItemSharding.setTableName("wx_coupon_batch_item");
wxCouponBatchItemSharding.setCount(100);
wxCouponBatchItemSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxCouponBatchItemSharding);
//初始化
shardingSpherePlugin.setShardingSpheres(shardingList);
Properties properties = new Properties();


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

@@ -0,0 +1,24 @@
package com.iformall.domain.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;

@Data
public class WxCardPriceTemplate implements Serializable {
private static final long serialVersionUID = -2321650008236516884L;
@NotNull
@Excel(name="卡密ID",width = 20,orderNum = "1")
@io.swagger.annotations.ApiModelProperty(value="ID",name="couponPasswordId")
private String couponPasswordId;
@NotNull
@Excel(name="面额(元)",width = 20,orderNum = "2")
@io.swagger.annotations.ApiModelProperty(value="面额(元)",name="price")
private String price;
}

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

@@ -9,15 +9,15 @@ public interface WxCouponBatchItemMapper extends CommonMapper<WxCouponBatchItem,
List<WxCouponBatchItem> findList(WxCouponBatchItem record);
List<Long> getBatchIdList(@Param("couponIds")List<Long> couponIds,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus);
List<Long> getBatchIdList(@Param("couponIds")List<Long> couponIds,@Param("tenantId")String tenantId,@Param("couponBatchStatus")Integer couponBatchStatus);

WxCouponBatchItem getById(@Param("id")Long id,@Param("tenantId")String tenantId);
void updateWxPressBatchStatus(WxCouponBatchItem record);
void updateWxCouponBatchItemStatus(WxCouponBatchItem record);
void deleteItem(WxCouponBatchItem record);

void deleteAllItem(WxCouponBatchItem record);
List<Long> getCouponIds(@Param("pressBatchId")Long pressBatchId,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus);
List<Long> getCouponIds(@Param("couponBatchId")Long pressBatchId,@Param("tenantId")String tenantId,@Param("couponBatchStatus")Integer pressBatchStatus);
}

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

@@ -12,7 +12,7 @@ public interface WxCouponBatchMapper extends CommonMapper<WxCouponBatch, Long> {

WxCouponBatch getById(@Param("id")Long id,@Param("tenantId")String tenantId);
void updateWxPressBatchStatus(WxCouponBatch record);
void updateWxCouponBatchStatus(WxCouponBatch record);
void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId);



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

@@ -55,6 +55,6 @@ public interface WxCouponBatchService {
void updateStatus(WxCouponBatch pressBatch);
CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId);
CouponBatchVo getCouponBatch(WxCoupon coupon, Long cUserId);

}

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

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

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCardPriceTemplate;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
import com.iformall.domain.vo.WxCouponPasswordVo;

@@ -79,4 +81,6 @@ public interface WxCouponPasswordService {
void startOrStop(WxCouponPassword wxCouponPassword);
void setPrice(WxCouponPassword wxCouponPassword);
void importPrice(MallUserInfo user,String importKey, WxCardPriceTemplate template);
}

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

@@ -159,16 +159,16 @@ public class WxCouponBatchServiceImpl implements WxCouponBatchService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public void updateStatus(WxCouponBatch pressBatch) {
wxCouponBatchMapper.updateWxPressBatchStatus(pressBatch);
wxCouponBatchMapper.updateWxCouponBatchStatus(pressBatch);
WxCouponBatchItem item = new WxCouponBatchItem();
item.updateTenantInfo(pressBatch);
item.setCouponBatchId(pressBatch.getId());
item.setCouponBatchStatus(pressBatch.getStatus());
wxCouponBatchItemMapper.updateWxPressBatchStatus(item);
wxCouponBatchItemMapper.updateWxCouponBatchItemStatus(item);
}

@Override
public CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId) {
public CouponBatchVo getCouponBatch(WxCoupon coupon, Long cUserId) {
WxCouponBatchItem query = new WxCouponBatchItem();
query.updateTenantInfo(coupon);
query.setCouponId(coupon.getId());


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

@@ -3,6 +3,7 @@ package com.iformall.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxCardInfo;
import com.iformall.domain.po.WxCoupon;
@@ -15,6 +16,7 @@ import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCouponOrderStatus;
import com.iformall.enums.EnumCouponPasswordStatus;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.domain.vo.WxCardPriceTemplate;
import com.iformall.domain.vo.WxCouponOrderBVo;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
import com.iformall.domain.vo.WxCouponPasswordVo;
@@ -34,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
@@ -48,6 +51,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;

@Service
public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
@@ -65,6 +69,9 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {

@Autowired
ExcelService excelService;
@Autowired
StringRedisTemplate stringRedisTemplate;

@Override
public PageInfo<WxCouponPassword> listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize) {
@@ -340,5 +347,33 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
public void setPrice(WxCouponPassword wxCouponPassword) {
wxCouponPasswordMapper.setPrice(wxCouponPassword);
}

@Override
public void importPrice(MallUserInfo user,String importKey, WxCardPriceTemplate template) {
if (StringUtils.isBlank(template.getCouponPasswordId())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error("卡密ID为空", template.toString());
return;
}
if (StringUtils.isBlank(template.getPrice())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error("面额为空", template.toString());
return;
}
try {
WxCouponPassword password = new WxCouponPassword();
password.updateTenantInfo(user);
password.setId(Long.parseLong(template.getCouponPasswordId()));
password.setPrice(new BigDecimal(template.getPrice()).multiply(new BigDecimal(100)).intValue());
setPrice(password);
}catch(Exception e) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
logger.error("import price error.",e);
return;
}
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1);
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}
}

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

@@ -842,7 +842,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}
private void checkCouponBatchRule(WxCoupon counpon,WxCouponOrder couponOrderQ,WxCUserBasicInfo user) {
CouponBatchVo checkPressResult = wxCouponBatchService.getCouponPressBatch(counpon, user.getId());
CouponBatchVo checkPressResult = wxCouponBatchService.getCouponBatch(counpon, user.getId());
if (null != checkPressResult) {
WxCouponBatch pressBatch = checkPressResult.getCouponBatch();
List<Long> cids = checkPressResult.getCouponIdList();


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

@@ -88,6 +88,9 @@ public class Constant {
// 导入会员
public static final String importMemPrev = "importmem:";
public static final String importInvestCustomerPrev = "importinvestcustomer:";
//导入卡面额
public static final String importCardPrice = "importCardPrice:";

// 导入POI
public static final String importPoiPrev = "importpoi:";


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

@@ -28,16 +28,16 @@
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != pressBatchId">
and `press_batch_id` = #{pressBatchId}
<if test=" null != couponBatchId">
and `coupon_batch_id` = #{couponBatchId}
</if>
<if test=" null != couponId">
and `coupon_id` = #{couponId}
</if>
<if test=" null != pressBatchStatus">
and `press_batch_status` = #{pressBatchStatus}
<if test=" null != couponBatchStatus">
and `coupon_batch_status` = #{couponBatchStatus}
</if>
<if test=" null != ids ">
@@ -59,7 +59,7 @@
<select id="getBatchIdList" parameterType="java.util.HashMap" resultType="Long">
select distinct coupon_batch_id from wx_coupon_batch_item where `tenant_id` = #{tenantId}
<if test=" null != pressBatchStatus">
<if test=" null != couponBatchStatus">
and `coupon_batch_status` = #{couponBatchStatus}
</if>
<if test=" null != couponIds ">
@@ -78,7 +78,7 @@
and tenant_id=#{tenantId}
</select>
<update id="updateWxPressBatchStatus" parameterType="com.iformall.domain.po.WxCouponBatchItem" >
<update id="updateWxCouponBatchItemStatus" parameterType="com.iformall.domain.po.WxCouponBatchItem" >
update wx_coupon_batch_item set coupon_batch_status = #{couponBatchStatus} where `coupon_batch_id` = #{couponBatchId} and tenant_id=#{tenantId}
</update>


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

@@ -57,7 +57,7 @@
select <include refid="allColumns"/> from wx_coupon_batch where `id` = #{id} and tenant_id=#{tenantId}
</select>
<update id="updateWxPressBatchStatus" parameterType="com.iformall.domain.po.WxCouponBatch" >
<update id="updateWxCouponBatchStatus" parameterType="com.iformall.domain.po.WxCouponBatch" >
update wx_coupon_batch set status = #{status} where `id` = #{id} and tenant_id=#{tenantId}
</update>



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