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

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

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
6f631bd722
8 измененных файлов: 585 добавлений и 27 удалений
  1. +14
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  2. +17
    -0
      mallinkAdmin/src/main/resources/db/migration/V202009041200__commercialPreferential.sql
  3. +132
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  4. +355
    -5
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  5. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
  6. +37
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumCouponSourceType.java
  7. +14
    -21
      mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java
  8. +13
    -1
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml

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

@@ -65,6 +65,9 @@ public class WxCouponController extends BaseController {
}else{
wxCoupon.updateTenantInfo(getTenantInfo());
}
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表
}

@@ -99,6 +102,10 @@ public class WxCouponController extends BaseController {
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.updateTenantInfo(tenantEntity);

if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}

ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon);
if (resultData.code != 200) {
return resultData;
@@ -122,6 +129,9 @@ public class WxCouponController extends BaseController {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
wxCoupon.updateTenantInfo(getTenantInfo());
if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){
WxCouponChannel query = new WxCouponChannel();
@@ -304,6 +314,7 @@ public class WxCouponController extends BaseController {
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSaleAmount() == null) {
@@ -336,6 +347,8 @@ public class WxCouponController extends BaseController {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}

wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());

PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSumSubsidy() == null) {
@@ -357,6 +370,7 @@ public class WxCouponController extends BaseController {
public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
Map<String,Object> result = new HashedMap();
wxCoupon.updateTenantInfo(getTenantInfo());
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,pageNum,pageSize);
return new ResultData(pages);
}


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

@@ -0,0 +1,17 @@
INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (646, '商户建券  ', 602, 'Y', NULL, 1, NULL, NULL, 'commercialPreferential', NULL, 0, 646);

update mall_sale_type set menus = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 201, 202, 203, 204, 205, 206, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004]' where id=1;
update mall_sale_type set menus = '[1, 2, 4, 5, 6, 7, 8, 9, 10, 50, 101, 102, 103, 104, 105, 106, 107, 201, 202, 203, 204, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932, 951, 961]' where id=2;
update mall_sale_type set menus = '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 592, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 711, 712, 713, 901, 902, 903, 931, 932]' where id=3;





ALTER TABLE `wx_c_user_basic_info`
MODIFY COLUMN `tenant_id` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '租户ID' AFTER `id`;



ALTER TABLE `mallink`.`wx_coupon`
ADD COLUMN `source_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1:A端发卷,2:B端发卷' AFTER `password_support`;

+ 132
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

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

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.WxCouponChannelDto;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumPayWay;
import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.QrCodeService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxFlowService;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api/wxCouponChannel")
@Api(description = "优惠券投放接口")
public class WxCouponChannelController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponChannelService wxCouponChannelService;
@Autowired
private WxCouponChannelMapper wxCouponChannelMapper;
@Autowired
private QrCodeService qrCodeService;
@Autowired
private WxFlowService wxFlowService;
@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::list");
if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel();
if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) {
wxCouponChannel.setStatus(null);
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::update");
wxCouponChannel.updateTenantInfo(getTenantInfo());

ResultData resultData = wxCouponChannelService.saveOrUpdate(wxCouponChannel);
WxCouponChannel couponChannel = (WxCouponChannel)resultData.data;
//生成二维码
if(couponChannel!=null){
String pageUrl = Constant.mainPageUrl;
String param = couponChannel.getWeappScene();
//此处只有微信二维码,别的二维码需要加字段
ResultData resultDataQ = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券",EnumPayWay.PAY_WAY_WECHAT);
Map<String,String> map = (Map)resultDataQ.data;
if(map!=null && map.get("url") !=null) {
String url = map.get("url");
couponChannel.setQrCode(url);
wxCouponChannelMapper.updateById(couponChannel);
}
}
return resultData;
}



@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponChannelService.getById(id));
}

@ApiOperation("批量新增")
@PostMapping("/addbatch")
public ResultData addbatch(@RequestBody WxCouponChannelDto wxCouponChannelDto) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::addbatch");
String[] ids = wxCouponChannelDto.getCouponIds().split(",");
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
ResultData resultData = wxCouponChannelService.addBatch(ids, channelId, getTenantInfo(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime());
return resultData;
}

@ApiOperation("根据id查询接口")
@GetMapping("/findChannelByCouponId")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findChannelByCouponId(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findChannelByCouponId");
List<Integer> channellist = new ArrayList<>();
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setStatus(0);
wxCouponChannel.setCouponId(id);
List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel, 1, 5).getList();
if (list.isEmpty()) {
return new ResultData(Result.SUCCESS, "查询成功", "");
}
for (WxCouponChannel temp : list) {
channellist.add(temp.getTargetAd());
}
return new ResultData(Result.SUCCESS, "查询成功", JSON.toJSONString(channellist));
}


}

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

@@ -1,17 +1,38 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.enums.*;
import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxFlowService;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/coupon")
@@ -21,12 +42,341 @@ public class WxCouponController extends BaseController {

@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCouponPasswordService couponPasswordService;
@Autowired
private WxCouponChannelMapper wxCouponChannelMapper;
@Autowired
private WxFlowService wxFlowService;
@Autowired
RedisLock redisLock;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize, Integer dataType) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(getTenantInfo());
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Bapi.getCode());
}
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表
}

@ApiOperation("分页列表接口")
@GetMapping("listWithTypePress")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData listWithTypePress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(getTenantInfo());
Integer[] typeArray = {
EnumCouponType.COUPON_MANJIAN.getCode(),
EnumCouponType.COUPON_DAIJIN.getCode(),
EnumCouponType.COUPON_TUANGOU.getCode(),
EnumCouponType.COUPON_LIPIN.getCode(),
EnumCouponType.COUPON_TINGCHE.getCode(),
EnumCouponType.COUPON_MULTIMCH.getCode(),
EnumCouponType.COUPON_PRESS.getCode()};

wxCoupon.setTypes(Arrays.asList(typeArray));
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::add");
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.updateTenantInfo(tenantEntity);

if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}

ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon);
if (resultData.code != 200) {
return resultData;
}
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
//启动投放审批
if(wxCoupon.getFlowParams() !=null && wxCoupon.getFlowParams().size()>0) {
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getBuserId(), getUser().getName(), tenantEntity);
//修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
return resultData;
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
wxCoupon.updateTenantInfo(getTenantInfo());
if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){
WxCouponChannel query = new WxCouponChannel();
query.updateTenantInfo(wxCoupon);
query.setCouponId(wxCoupon.getId());
query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
if (CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))) {
return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。");
}
}

WxCoupon coupon = wxCouponService.getById(wxCoupon.getId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}
redisLock.setCouponStock(wxCoupon.getId(), coupon.getRemainInventory());
//启动审批流
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) {
logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType"));
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getBuserId(), getUser().getName(), getTenantInfo());
//作废审批
if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) {
wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
return new ResultData(wxCoupon);
} else {
//投放审批
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
}

return wxCouponService.saveOrUpdate(wxCoupon);
}

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

WxCoupon coupon = wxCouponService.findById(wxCoupon);
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.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) &&
wxCoupon.getValidDays().equals(coupon.getValidDays()))
) {
return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR);
}

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

if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) {
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());
variables.add(map);
map = new HashedMap();
map.put("key", "remainInventory");
map.put("value", wxCoupon.getRemainInventory());
variables.add(map);
map = new HashedMap();
map.put("key", "type");
map.put("value", wxCoupon.getType());
variables.add(map);
map = new HashedMap();
map.put("key", "validEndDate");
map.put("value", wxCoupon.getValidEndDate());
map = new HashedMap();
map.put("key", "validStartDate");
map.put("value", wxCoupon.getValidStartDate());
map = new HashedMap();
map.put("key", "validType");
map.put("value", wxCoupon.getValidType());
variables.add(map);
map = new HashedMap();
map.put("key", "validDays");
map.put("value", wxCoupon.getValidDays());
variables.add(map);
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId());
wxFlowService.start(wxCoupon.getFlowParams(), getBuserId(), getUser().getName(), wxCoupon);
//更新状态
WxCoupon updateCoupon = new WxCoupon();
updateCoupon.updateTenantInfo(wxCoupon);
updateCoupon.setId(wxCoupon.getId());
updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
updateCoupon.setUpdateDate(new Date());
wxCouponService.update(updateCoupon);
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
} else {
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
return wxCouponService.updateCouponStockAndEndTime(wxCoupon);
}

return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxCouponService.getById(id));
public ResultData findById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
return new ResultData(wxCouponService.getVoById(id));
}


@ApiOperation("卡营销列表接口")
@GetMapping("findCardCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
Map<String, Object> result = new HashedMap();
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSaleAmount() == null) {
coupon.setSaleAmount(0);
}
if (coupon.getSumPayment() == null) {
coupon.setSumPayment(0);
}
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
}
result.put("list", pageInfo);
return new ResultData(result);
}

@ApiOperation("券营销列表接口")
@GetMapping("findCouponCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
Map<String, Object> result = new HashedMap();
if (wxCoupon.getStartdate() == null) {
wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth());
}
if (wxCoupon.getEnddate() == null) {
wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"));
}

wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());

PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, pageNum, pageSize);
for (WxCouponStatisVo coupon : pageInfo.getList()) {
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
if (coupon.getSumSubsidy() == null) {
coupon.setSumSubsidy(0);
}
}
return new ResultData(pageInfo);
}

@ApiOperation("砍价营销列表接口")
@GetMapping("findPressCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
Map<String,Object> result = new HashedMap();
wxCoupon.updateTenantInfo(getTenantInfo());
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,pageNum,pageSize);
return new ResultData(pages);
}

@GetMapping("exportCouponPassword")
public void exportCouponPassword(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) {
wxCouponPassword.updateTenantInfo(getTenantInfo());
if (wxCouponPassword.getCouponId() == null) {
wxCouponPassword.setCouponId(0L);
}
couponPasswordService.exportData(request, response, wxCouponPassword);
}

@ApiOperation("根据id获取富文本接口")
@GetMapping("/getHtml")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData getHtml(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById");
return new ResultData(wxCouponService.getHtmlById(id));
}


}

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

@@ -140,6 +140,9 @@ public class WxCoupon extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="卡密是否支持(0:不支持,1支持)",name="passwordSupport")
private Integer passwordSupport;

@io.swagger.annotations.ApiModelProperty(value="1:A端发卷,2:B端发卷",name="sourceType")
private Integer sourceType;

@TableField(exist = false)
private String merchantParams;



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

@@ -0,0 +1,37 @@
package com.iformall.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumCouponSourceType {

// 1:A端发卷,2:B端发卷
COUPONSource_Admin(1, "A端发卷"),
COUPONSource_Bapi(2, "B端发卷")
;

public static EnumCouponSourceType getEnum(Integer code) {
for (EnumCouponSourceType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumCouponSourceType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

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

@@ -3,16 +3,14 @@ package com.iformall.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxProjectConfig;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxMallBuilding;
import com.iformall.domain.po.WxMallFloor;
import com.iformall.mapper.WxMallBuildingMapper;
import com.iformall.mapper.WxMallFloorMapper;
import com.iformall.mapper.WxMallMapper;
import com.iformall.service.WxMallService;
import com.iformall.utils.Constant;
import com.iformall.utils.RedisCacheUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,8 +42,10 @@ public class WxMallServiceImpl implements WxMallService {
RedisTemplate<String, WxMall> mallRedisTemplate;

@Autowired
@Qualifier("subMallListRedisTemplate")
RedisTemplate<String, List<WxMall>> subMallListRedisTemplate;
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> subMallListRedisTemplate;



@Override
public String wxMallInit(WxProjectConfig wxProjectConfig) {
@@ -211,16 +211,13 @@ public class WxMallServiceImpl implements WxMallService {
@Override
public List<WxMall> getSubByParentTenantId(String parentTenantId) {
String key = Constant.subMallinfoPrev + parentTenantId;
ValueOperations<String, List<WxMall>> operations = subMallListRedisTemplate.opsForValue();
if(subMallListRedisTemplate.hasKey(key)) {
List<WxMall> wxMalls = operations.get(key);
return wxMalls;
List<WxMall> mallList = RedisCacheUtils.getCacheListObject(subMallListRedisTemplate, key, WxMall.class);
if(null == mallList || mallList.size() == 0){
WxMall q = new WxMall();
q.setParentTenantId(parentTenantId);
mallList = wxMallMapper.selectList(new QueryWrapper<>(q));
RedisCacheUtils.cache(subMallListRedisTemplate, key, mallList, 3600*24*7);
}
WxMall q = new WxMall();
q.setParentTenantId(parentTenantId);
List<WxMall> mallList = wxMallMapper.selectList(new QueryWrapper<>(q));

operations.set(key, mallList, 7, TimeUnit.DAYS);
return mallList;
}

@@ -243,14 +240,10 @@ public class WxMallServiceImpl implements WxMallService {
mallRedisTemplate.delete(key1);
}
String key2 = Constant.subMallinfoPrev + tenantEntity.getTenantId();
if(subMallListRedisTemplate.hasKey(key2)){
subMallListRedisTemplate.delete(key2);
}
RedisCacheUtils.removeCache(subMallListRedisTemplate, key2);
if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){
String key3 = Constant.subMallinfoPrev + tenantEntity.getParentTenantId();
if(subMallListRedisTemplate.hasKey(key3)){
subMallListRedisTemplate.delete(key3);
}
RedisCacheUtils.removeCache(subMallListRedisTemplate, key3);
}
}



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

@@ -47,6 +47,7 @@
<result column="password_support" property="passwordSupport"/>
<result column="content_type" property="contentType"/>
<result column="html" property="html"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>
</resultMap>
<resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo">
<id column="id" jdbcType="BIGINT" property="id"/>
@@ -93,6 +94,7 @@
<result column="sum_subsidy" property="sumSubsidy"/>
<result column="payment_rate" property="paymentRate"/>
<result column="change_rate" property="changeRate"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>
</resultMap>

<sql id="allColumns">
@@ -100,7 +102,7 @@
`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,
`remark`,`status`,`create_date`,`update_date`,`business`,`sub_business`,`support_transfer`,`subsidy_num`,`subsidy_type`,
`press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`,
`conditions`,approval_type,content_type
`conditions`,approval_type,content_type,source_type
</sql>

<sql id="statusColumns">
@@ -253,6 +255,10 @@
and `content_type` = #{contentType}
</if>

<if test=" null != sourceType ">
and `source_type` = #{sourceType}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
@@ -437,6 +443,10 @@
and c.`content_type` = #{contentType}
</if>

<if test=" null != sourceType ">
and `source_type` = #{sourceType}
</if>

<!--如果配置了审批模板,需要过滤投放审批状态-->
<if test="0 != filterCanPut or null ==filterCanPut ">
<if test=" null != pressModelId and 0l != pressModelId">
@@ -560,6 +570,7 @@
<result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
<result column="conditions" jdbcType="VARCHAR" property="conditions"/>
<result column="content_type" jdbcType="INTEGER" property="contentType"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>

<collection column="{productId=id}" property="merchantVoList"
ofType="com.iformall.domain.vo.WxMerchantVo"
@@ -603,6 +614,7 @@
<result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
<result column="conditions" jdbcType="VARCHAR" property="conditions"/>
<result column="content_type" jdbcType="INTEGER" property="contentType"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>
</resultMap>

<select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">


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