Browse Source

[卡密][新增]:卡密导出

release_toaliyun_real
Stormeye Wu 6 years ago
parent
commit
238115a756
7 changed files with 135 additions and 69 deletions
  1. +83
    -63
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  2. +3
    -3
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponPassword.java
  4. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCouponPasswordMapper.java
  5. +10
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java
  6. +19
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java
  7. +16
    -0
      mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml

+ 83
- 63
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java View File

@@ -8,9 +8,11 @@ import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.vo.WxCouponStatisVo; import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.mapper.WxCouponChannelMapper; import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.service.WxCouponService; import com.iformall.service.WxCouponService;
import com.iformall.service.WxFlowService; import com.iformall.service.WxFlowService;
import com.iformall.utils.DateUtils; import com.iformall.utils.DateUtils;
@@ -24,6 +26,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*; import java.util.*;


@RestController @RestController
@@ -35,6 +40,8 @@ public class WxCouponController extends BaseController {
@Autowired @Autowired
private WxCouponService wxCouponService; private WxCouponService wxCouponService;
@Autowired @Autowired
private WxCouponPasswordService couponPasswordService;
@Autowired
private WxCouponChannelMapper wxCouponChannelMapper; private WxCouponChannelMapper wxCouponChannelMapper;
@Autowired @Autowired
private WxFlowService wxFlowService; private WxFlowService wxFlowService;
@@ -51,6 +58,7 @@ public class WxCouponController extends BaseController {
wxCoupon.setTenantId(getTenantId()); wxCoupon.setTenantId(getTenantId());
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表
} }

@ApiOperation("分页列表接口") @ApiOperation("分页列表接口")
@GetMapping("listWithTypePress") @GetMapping("listWithTypePress")
@ApiImplicitParams({ @ApiImplicitParams({
@@ -82,13 +90,13 @@ public class WxCouponController extends BaseController {
wxCoupon.setTenantId(getTenantId()); wxCoupon.setTenantId(getTenantId());


ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon); ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon);
if(resultData.code != 200){
if (resultData.code != 200) {
return resultData; return resultData;
} }


//启动投放审批 //启动投放审批
if(wxCoupon.getFlowParams() !=null && wxCoupon.getFlowParams().size()>0) {
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
wxCoupon.getFlowParams().put("businessId", wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId());
//修改coupon applyStatus状态为审核中 //修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
@@ -104,12 +112,12 @@ public class WxCouponController extends BaseController {
if (wxCoupon.getId() == null) { if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id"); return new ResultData(ResultData.ERROR, "缺少id");
} }
if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){
if (EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())) {
WxCouponChannel query = new WxCouponChannel(); WxCouponChannel query = new WxCouponChannel();
query.setTenantId(wxCoupon.getTenantId()); query.setTenantId(wxCoupon.getTenantId());
query.setCouponId(wxCoupon.getId()); query.setCouponId(wxCoupon.getId());
query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
if(CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))){
if (CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))) {
return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。"); return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。");
} }
} }
@@ -117,14 +125,14 @@ public class WxCouponController extends BaseController {


//启动审批流 //启动审批流
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType"));
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
logger.info("------coupon.update().businessType:" + wxCoupon.getFlowParams().get("businessType"));
wxCoupon.getFlowParams().put("businessId", wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId());
//作废审批 //作废审批
if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) {
wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
return new ResultData(wxCoupon); return new ResultData(wxCoupon);
}else{
} else {
//投放审批 //投放审批
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
} }
@@ -133,7 +141,7 @@ public class WxCouponController extends BaseController {
} }


@ApiOperation("根据id更新库存及有效期接口") @ApiOperation("根据id更新库存及有效期接口")
@PostMapping("updateStokeAndValidDate")
@PostMapping("updateStokeAndValidDate")
@SystemControllerLog(description = "券投放-库存/有效期更新") @SystemControllerLog(description = "券投放-库存/有效期更新")
public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate");
@@ -141,93 +149,93 @@ public class WxCouponController extends BaseController {
logger.error("缺少id"); logger.error("缺少id");
return new ResultData(ResultData.ERROR, "缺少id"); return new ResultData(ResultData.ERROR, "缺少id");
} }
if(wxCoupon.getType() == null) {
if (wxCoupon.getType() == null) {
logger.error("缺少type"); logger.error("缺少type");
return new ResultData(ResultData.ERROR, "缺少type"); return new ResultData(ResultData.ERROR, "缺少type");
} }
if(wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) {
if (wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) {
logger.error("库存错误1"); logger.error("库存错误1");
return new ResultData(ErrorCode.COUPON_STOCK_ERR); return new ResultData(ErrorCode.COUPON_STOCK_ERR);
} }
if(wxCoupon.getRemainInventory() > wxCoupon.getInventory()) {
if (wxCoupon.getRemainInventory() > wxCoupon.getInventory()) {
logger.error("库存错误2"); logger.error("库存错误2");
return new ResultData(ErrorCode.COUPON_STOCK_ERR); return new ResultData(ErrorCode.COUPON_STOCK_ERR);
} }
if(wxCoupon.getValidType() == null) {
if (wxCoupon.getValidType() == null) {
logger.error("库存错误3"); logger.error("库存错误3");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
} }
if(wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) {
if(wxCoupon.getValidEndDate() == null) {
if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) {
if (wxCoupon.getValidEndDate() == null) {
logger.error("有效期错误1"); logger.error("有效期错误1");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
} }
} else { } else {
if(wxCoupon.getValidDays() == null) {
if (wxCoupon.getValidDays() == null) {
logger.error("有效期错误2"); logger.error("有效期错误2");
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR);
} }
} }
if(wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) ||
wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) {
if (wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) ||
wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) {
logger.error("券库存有效期不支持停车券"); logger.error("券库存有效期不支持停车券");
return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR); return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR);
} }
wxCoupon.setTenantId(getTenantId()); wxCoupon.setTenantId(getTenantId());


WxCoupon coupon = wxCouponService.findById(wxCoupon); WxCoupon coupon = wxCouponService.findById(wxCoupon);
if(coupon!=null){
if((wxCoupon.getValidEndDate()!=null&&coupon.getValidEndDate()!=null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate()))
if (coupon != null) {
if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate()))
&& wxCoupon.getInventory().equals(coupon.getInventory())) && wxCoupon.getInventory().equals(coupon.getInventory()))
|| ||
(wxCoupon.getValidDays()!=null && coupon.getValidDays()!=null && wxCoupon.getInventory().equals(coupon.getInventory()) &&
(wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) &&
wxCoupon.getValidDays().equals(coupon.getValidDays())) wxCoupon.getValidDays().equals(coupon.getValidDays()))
){
) {
return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR);
} }


if(wxCoupon.getValidEndDate()!=null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())){
if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) {
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR);
} }
if(wxCoupon.getInventory()!=null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue() ){
if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) {
return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR);
} }


if(wxCoupon.getValidDays()!=null && coupon.getValidDays()!=null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()){
if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) {
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR);
} }
} }


//启动审批流 //启动审批流
if(wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() >0){
List<Map<String,Object>> variables = (List)wxCoupon.getFlowParams().get("variables");
Map<String,Object> map = new HashedMap();
map.put("key","inventory");
map.put("value",wxCoupon.getInventory());
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
List<Map<String, Object>> variables = (List) wxCoupon.getFlowParams().get("variables");
Map<String, Object> map = new HashedMap();
map.put("key", "inventory");
map.put("value", wxCoupon.getInventory());
variables.add(map); variables.add(map);
map = new HashedMap(); map = new HashedMap();
map.put("key","remainInventory");
map.put("value",wxCoupon.getRemainInventory());
map.put("key", "remainInventory");
map.put("value", wxCoupon.getRemainInventory());
variables.add(map); variables.add(map);
map = new HashedMap(); map = new HashedMap();
map.put("key","type");
map.put("value",wxCoupon.getType());
map.put("key", "type");
map.put("value", wxCoupon.getType());
variables.add(map); variables.add(map);
map = new HashedMap(); map = new HashedMap();
map.put("key","validEndDate");
map.put("value",wxCoupon.getValidEndDate());
map.put("key", "validEndDate");
map.put("value", wxCoupon.getValidEndDate());
map = new HashedMap(); map = new HashedMap();
map.put("key","validStartDate");
map.put("value",wxCoupon.getValidStartDate());
map.put("key", "validStartDate");
map.put("value", wxCoupon.getValidStartDate());
map = new HashedMap(); map = new HashedMap();
map.put("key","validType");
map.put("value",wxCoupon.getValidType());
map.put("key", "validType");
map.put("value", wxCoupon.getValidType());
variables.add(map); variables.add(map);
map = new HashedMap(); map = new HashedMap();
map.put("key","validDays");
map.put("value",wxCoupon.getValidDays());
map.put("key", "validDays");
map.put("value", wxCoupon.getValidDays());
variables.add(map); variables.add(map);
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxCoupon.getFlowParams().put("businessId", wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId()); wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantId());
//更新状态 //更新状态
WxCoupon updateCoupon = new WxCoupon(); WxCoupon updateCoupon = new WxCoupon();
@@ -236,7 +244,7 @@ public class WxCouponController extends BaseController {
updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
updateCoupon.setUpdateDate(new Date()); updateCoupon.setUpdateDate(new Date());
wxCouponService.update(updateCoupon); wxCouponService.update(updateCoupon);
}else{
} else {
return wxCouponService.updateCouponStockAndEndTime(wxCoupon); return wxCouponService.updateCouponStockAndEndTime(wxCoupon);
} }


@@ -258,7 +266,8 @@ public class WxCouponController extends BaseController {
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询") @SystemControllerLog(description = "券投放-查询")
public ResultData findById(@RequestParam Long id) { public ResultData findById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");;
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
;
return new ResultData(wxCouponService.getVoById(id)); return new ResultData(wxCouponService.getVoById(id));
} }


@@ -271,26 +280,26 @@ public class WxCouponController extends BaseController {
@SystemControllerLog(description = "券投放-卡营销列表") @SystemControllerLog(description = "券投放-卡营销列表")
public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天 //默认时间本月第一天,截止到当天
Map<String,Object> result = new HashedMap();
if(wxCoupon.getStartdate() == null){
Map<String, Object> result = new HashedMap();
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
} }
if(wxCoupon.getEnddate() == null){
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
} }
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon,pageNum,pageSize);
for (WxCouponStatisVo coupon:pageInfo.getList()) {
if(coupon.getSaleAmount() == null){
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSaleAmount() == null) {
coupon.setSaleAmount(0); coupon.setSaleAmount(0);
} }
if(coupon.getSumPayment() == null){
if (coupon.getSumPayment() == null) {
coupon.setSumPayment(0); coupon.setSumPayment(0);
} }
if(coupon.getSumSubsidy() == null){
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0); coupon.setSumSubsidy(0);
} }
} }
result.put("list",pageInfo);
result.put("list", pageInfo);
return new ResultData(result); return new ResultData(result);
} }


@@ -302,20 +311,20 @@ public class WxCouponController extends BaseController {
@SystemControllerLog(description = "券投放-券营销列表") @SystemControllerLog(description = "券投放-券营销列表")
public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天 //默认时间本月第一天,截止到当天
Map<String,Object> result = new HashedMap();
if(wxCoupon.getStartdate() == null){
Map<String, Object> result = new HashedMap();
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
} }
if(wxCoupon.getEnddate() == null){
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
} }


PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon,pageNum,pageSize);
for (WxCouponStatisVo coupon:pageInfo.getList()) {
if(coupon.getSumSubsidy() == null){
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0); coupon.setSumSubsidy(0);
} }
if(coupon.getSumSubsidy() == null){
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0); coupon.setSumSubsidy(0);
} }
} }
@@ -329,10 +338,21 @@ public class WxCouponController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-砍价营销列表") @SystemControllerLog(description = "券投放-砍价营销列表")
public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
Map<String,Object> result = new HashedMap();
Map<String, Object> result = new HashedMap();
wxCoupon.setTenantId(getTenantId()); wxCoupon.setTenantId(getTenantId());
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,pageNum,pageSize);
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon, pageNum, pageSize);
return new ResultData(pages); return new ResultData(pages);
} }


@GetMapping("exportCouponPassword")
@SystemControllerLog(description = "卡券兑换码-导出数据")
public void exportCouponPassword(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) {
wxCouponPassword.setTenantId(getTenantId());
wxCouponPassword.setExpireDate(new Date());
if (wxCouponPassword.getCouponId() == null) {
wxCouponPassword.setCouponId(0L);
}
couponPasswordService.exportData(request, response, wxCouponPassword);
}

} }

+ 3
- 3
mallinkService/src/main/java/com/iformall/common/ErrorCode.java View File

@@ -222,9 +222,9 @@ public enum ErrorCode{
/** /**
* 卡密 * 卡密
*/ */
CARD_PASSWORD_NOT_FOUND(9501, "兑换码未找到"),
CARD_PASSWORD_HAD_USED(9502, "兑换码已失效"),
CARD_PASSWORD_IS_CANCELED(9503, "兑换码已失效"),
COUPON_PASSWORD_NOT_FOUND(9501, "兑换码未找到"),
COUPON_PASSWORD_HAD_USED(9502, "兑换码已失效"),
COUPON_PASSWORD_IS_CANCELED(9503, "兑换码已失效"),


/** /**
* 微信 * 微信


+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCouponPassword.java View File

@@ -1,5 +1,6 @@
package com.iformall.domain.po; package com.iformall.domain.po;


import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;


@@ -26,6 +27,7 @@ public class WxCouponPassword extends BaseEntity {
private Long couponId; private Long couponId;
@io.swagger.annotations.ApiModelProperty(value="卡券短ID",name="couponShort") @io.swagger.annotations.ApiModelProperty(value="卡券短ID",name="couponShort")
private String couponShort; private String couponShort;
@Excel(name = "兑换码", width = 20, orderNum = "1")
@io.swagger.annotations.ApiModelProperty(value="商户名称",name="password") @io.swagger.annotations.ApiModelProperty(value="商户名称",name="password")
private String password; private String password;
@io.swagger.annotations.ApiModelProperty(value="卡密状态: 0初始1信息发出中2信息已发出3已使用",name="status") @io.swagger.annotations.ApiModelProperty(value="卡密状态: 0初始1信息发出中2信息已发出3已使用",name="status")


+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCouponPasswordMapper.java View File

@@ -10,6 +10,8 @@ public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, L


List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword); List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword);


List<WxCouponPassword> findAvaPasswordListByCouponId(WxCouponPassword wxCouponPassword);

void insertCouponPasswds(List<WxCouponPassword> pwdlist); void insertCouponPasswds(List<WxCouponPassword> pwdlist);
int updateStatusByCouponId(Long couponId); int updateStatusByCouponId(Long couponId);
List<WxCouponPassword> findCouponGroupList(WxCouponPassword wxCouponPassword); List<WxCouponPassword> findCouponGroupList(WxCouponPassword wxCouponPassword);


+ 10
- 0
mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java View File

@@ -4,6 +4,8 @@ import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxCouponPassword; import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;


public interface WxCouponPasswordService { public interface WxCouponPasswordService {
@@ -59,4 +61,12 @@ public interface WxCouponPasswordService {


List<WxCouponPasswordCountInfoVO> findCouponList(String tenantId); List<WxCouponPasswordCountInfoVO> findCouponList(String tenantId);


/**
* 导出兑换码
* @param request
* @param response
* @param couponPassword
*/
void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponPassword couponPassword);

} }

+ 19
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java View File

@@ -9,12 +9,15 @@ import com.iformall.domain.vo.WxCouponPasswordCountInfoVO;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxCouponPasswordMapper; import com.iformall.mapper.WxCouponPasswordMapper;
import com.iformall.service.ExcelService;
import com.iformall.service.WxCouponPasswordService; import com.iformall.service.WxCouponPasswordService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -27,6 +30,9 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
@Autowired @Autowired
WxCouponPasswordMapper wxCouponPasswordMapper; WxCouponPasswordMapper wxCouponPasswordMapper;


@Autowired
ExcelService excelService;



@Override @Override
public PageInfo<WxCouponPassword> listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize) { public PageInfo<WxCouponPassword> listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize) {
@@ -42,7 +48,7 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
public WxCouponPassword getByObj(WxCouponPassword obj) { public WxCouponPassword getByObj(WxCouponPassword obj) {
List<WxCouponPassword> pwdList = wxCouponPasswordMapper.findList(obj); List<WxCouponPassword> pwdList = wxCouponPasswordMapper.findList(obj);
if (pwdList.size() <= 0) { if (pwdList.size() <= 0) {
throw new MallinkException(ErrorCode.CARD_PASSWORD_NOT_FOUND);
throw new MallinkException(ErrorCode.COUPON_PASSWORD_NOT_FOUND);
} }
WxCouponPassword password = null; WxCouponPassword password = null;
Integer errCode = EnumCouponPasswordStatus.INIT.getCode(); Integer errCode = EnumCouponPasswordStatus.INIT.getCode();
@@ -59,10 +65,10 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
if (password == null) { if (password == null) {
if (errCode.equals(EnumCouponPasswordStatus.USED.getCode())) { if (errCode.equals(EnumCouponPasswordStatus.USED.getCode())) {
logger.error("卡券已使用"); logger.error("卡券已使用");
throw new MallinkException(ErrorCode.CARD_PASSWORD_HAD_USED);
throw new MallinkException(ErrorCode.COUPON_PASSWORD_HAD_USED);
} else { } else {
logger.error("卡券已过期或已作废"); logger.error("卡券已过期或已作废");
throw new MallinkException(ErrorCode.CARD_PASSWORD_IS_CANCELED);
throw new MallinkException(ErrorCode.COUPON_PASSWORD_IS_CANCELED);
} }
} }
return password; return password;
@@ -145,6 +151,16 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService {
wxCouponPasswordMapper.insertCouponPasswds(couponPasswords); wxCouponPasswordMapper.insertCouponPasswds(couponPasswords);
} }


@Override
public void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponPassword couponPassword) {
List<WxCouponPassword> pwdList = wxCouponPasswordMapper.findAvaPasswordListByCouponId(couponPassword);
if (pwdList.isEmpty()) {
throw new MallinkException(ErrorCode.COUPON_PASSWORD_NOT_FOUND);
}
excelService.exportExcel(pwdList, null, "兑换码", WxCouponPassword.class, "卡兑换码.xlsx", response, false);

}

/* /*
public static void main(String[] args) { public static void main(String[] args) {
WxCouponPasswordServiceImpl ll = new WxCouponPasswordServiceImpl(); WxCouponPasswordServiceImpl ll = new WxCouponPasswordServiceImpl();


+ 16
- 0
mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml View File

@@ -74,6 +74,22 @@
<include refid="dynamicWhereConditions" /> <include refid="dynamicWhereConditions" />
</select> </select>


<select id="findAvaPasswordListByCouponId" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
select <include refid="allColumns" />
from wx_coupon_password
<where> `status` not in (3,4)
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != couponId ">
and `coupon_id` = #{couponId}
</if>
<if test=" null != expireDate ">
and `expire_date` > #{expireDate}
</if>
</where>
</select>

<insert id="insertCouponPasswds" parameterType="java.util.List"> <insert id="insertCouponPasswds" parameterType="java.util.List">
INSERT INTO wx_coupon_password (`id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`) INSERT INTO wx_coupon_password (`id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`)
VALUES VALUES


Loading…
Cancel
Save