浏览代码

fix

master
winter 1年前
父节点
当前提交
2eee86313c
共有 18 个文件被更改,包括 1 次插入3086 次删除
  1. +0
    -321
      yqzjAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  2. +0
    -317
      yqzjAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java
  3. +0
    -189
      yqzjAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java
  4. +0
    -216
      yqzjAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java
  5. +0
    -275
      yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  6. +0
    -739
      yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  7. +0
    -175
      yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java
  8. +0
    -276
      yqzjAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java
  9. +0
    -192
      yqzjAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java
  10. +0
    -1
      yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjAIGCController.java
  11. +0
    -1
      yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjAboutUsController.java
  12. +0
    -1
      yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjCarController.java
  13. +0
    -1
      yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjIndexController.java
  14. +0
    -1
      yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjYuanYuZhouController.java
  15. +0
    -304
      yqzjService/src/main/java/com/iformall/service/WxCouponService.java
  16. +0
    -13
      yqzjService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java
  17. +1
    -61
      yqzjService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java
  18. +0
    -3
      yqzjService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java

+ 0
- 321
yqzjAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java 查看文件

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

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.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.utils.Constant;
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.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author gongbiao
*/
@RestController
@RequestMapping("merchantPoi")
public class TtMerchantPoiController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private String fmUploadDir;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private WxCouponChannelService wxCouponChannelService;

@Autowired
private WxCouponService wxCouponService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@Autowired
private AsyncTask asyncTask;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData list(@ModelAttribute TtMerchantPoi record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list");
if (null == record) record = new TtMerchantPoi();
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<TtMerchantPoi> page = ttMerchantPoiService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findById");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtMerchantPoi record = ttMerchantPoiService.getById(id);
return new ResultData(record);
}

@ApiOperation("更新商户接口")
@PostMapping("updateById")
@SystemControllerLog(description = "更新")
public ResultData updateById(@RequestBody TtMerchantPoi record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateById");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtMerchantPoi merchantPoi = ttMerchantPoiService.getById(record.getId());
if(merchantPoi == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到修改的数据");
}
if(!EnumSupplierMathStatus.match_update.getCode().equals(merchantPoi.getMatchStatus())
&& !EnumSupplierMathStatus.match_fail.getCode().equals(merchantPoi.getMatchStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改");
}
record.updateTenantInfo(getTenantInfo());
record.setMatchStatus(EnumSupplierMathStatus.match_update.getCode());
ttMerchantPoiService.updateById(record);
return new ResultData(record);
}

@ApiOperation("新建匹配任务")
@PostMapping("match")
@SystemControllerLog(description = "新建匹配任务")
public ResultData match(@RequestBody List<Long> ids) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::match");
if(ids == null || ids.isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.match(getTenantInfo(),ids);
}

@ApiOperation("重新匹配任务")
@PostMapping("matchAgain")
@SystemControllerLog(description = "重新匹配任务")
public ResultData matchAgain(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::matchAgain");
Long id = param.get("id");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.matchAgain(getTenantInfo(),id);
}

@ApiOperation("商铺同步")
@PostMapping("merchantSync")
@SystemControllerLog(description = "商铺同步")
public ResultData merchantSync(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantSync");
Long id = param.get("id");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.merchantSync(getTenantInfo(),id);
}

@ApiOperation("商铺同步结果")
@GetMapping("merchantQuery")
@SystemControllerLog(description = "商铺同步")
public ResultData merchantQuery(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantQuery");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.supplierQuery(getTenantInfo(),id);
}

// @ApiOperation("获取商品可用的POI")
// @GetMapping("/findPoi")
// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
// @SystemControllerLog(description = "查询")
// public ResultData findPoi(Long couponChannelId) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId);
// }

// @ApiOperation("商品同步")
// @PostMapping("spuSync")
// @SystemControllerLog(description = "商品同步")
// public ResultData spuSync(@RequestBody Map<String, String> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync");
// String couponChannelIdStr = param.get("couponChannelId");
// Long couponChannelId = null;
// try{
// couponChannelId = Long.parseLong(couponChannelIdStr);
// }catch(Exception e){
// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
// }
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
//// String merchantIdStr = param.get("merchantIds");
//// List<Long> merchantIds = new ArrayList<>();
//// try{
//// List<String> strings = Arrays.asList(merchantIdStr.split(","));
//// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
//// }catch(Exception e){
//// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
//// }
//// if(merchantIds == null || merchantIds.size() == 0){
//// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
//// }
// return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null);
// }

// @ApiOperation("商品同步查询")
// @GetMapping("spuGet")
// @SystemControllerLog(description = "商品同步查询")
// public ResultData spuGet(Long couponChannelId) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品状态同步")
// @PostMapping("spuStatusSync")
// @SystemControllerLog(description = "商品状态同步")
// public ResultData spuStatusSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品库存同步")
// @PostMapping("spuStockSync")
// @SystemControllerLog(description = "商品库存同步")
// public ResultData spuStockSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId);
// }

@TenantIgnore
@PostMapping(value = "/importPoi", consumes = "multipart/*")
@SystemControllerLog(description = "poi-导入数据")
public ResultData importPoi(@RequestParam("file") MultipartFile mFile) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi");
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importMemPrev + 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 = "poi" + Math.round(Math.random() * 100000000000L);
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.importExcelPoiData(lFile, user, importKey);

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

}

+ 0
- 317
yqzjAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java 查看文件

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


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.TtPoiTakeRate;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCpsPlanContentType;
import com.iformall.enums.EnumCpsPlanStatus;
import com.iformall.enums.EnumCpsPlanType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
* @author
*/
@RestController
@RequestMapping("poiPlan")
public class TtPoiPlanController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private TtCouponGoodsService ttCouponGoodsService;

@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("takeRateList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "列表")
public ResultData takeRateList(@ModelAttribute TtPoiTakeRate record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list");
if (null == record) record = new TtPoiTakeRate();
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<TtPoiTakeRate> page = ttCouponGoodsService.takeRateListAsPage(record, pageNum, pageSize);
if(page.getList() != null && !page.getList().isEmpty()){
List<Long> couponIds = page.getList().stream().map(cc -> cc.getCouponId()).collect(Collectors.toList());
Map<Long, WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds, getTenantInfo());
for (TtPoiTakeRate takeRate:page.getList()) {
takeRate.setCoupon(couponMap.get(takeRate.getCouponId()));
}
}
return new ResultData(page);
}

@ApiOperation("通过id获取")
@GetMapping("getTakeRate")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "列表")
public ResultData getTakeRate(Long id) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getTakeRate");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
TtPoiTakeRate takeRateById = ttCouponGoodsService.getTakeRateById(getTenantInfo(), id);
return new ResultData(takeRateById);
}

// @TenantIgnore
@ApiOperation("通用计划分页列表接口")
@GetMapping("list")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData list(Long couponId,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtPoiPlanController::list");
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(pageNum == null){
pageNum = 1;
}
if(pageSize == null){
pageSize = 100;
}
return ttCouponGoodsService.poiPlanList(getTenantInfo(),couponId,pageNum,pageSize);
}

@ApiOperation("定向计划分页列表接口")
@GetMapping("orientedList")
@ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData orientedList(Long couponId,Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] TtPoiPlanController::orientedList");
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(pageNum == null){
pageNum = 1;
}
if(pageSize == null){
pageSize = 100;
}
return ttCouponGoodsService.poiOrientedPlanList(getTenantInfo(),couponId,pageNum,pageSize);
}

@ApiOperation("发布修改通用佣金计划")
@PostMapping("save")
@SystemControllerLog(description = "更新")
public ResultData save(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::save");
if(record.getTakeRate() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空");
}
if(record.getTakeRate() < 100 || record.getTakeRate() > 2900){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位100-2900之间");
}

if(record.getContentType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空");
}
if(record.getCouponId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.poiPlanSave(record);
}

@ApiOperation("发布修改定向佣金计划")
@PostMapping("saveOrientedPlan")
@SystemControllerLog(description = "更新")
public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan");
if(StringUtils.isBlank(record.getName())){//不可修改
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空");
}
if(StringUtils.isBlank(record.getMerchantPhone())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划联系人为空");
}
if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空");
}
//达人去重
List<String> collect = record.getDouyinIdList().stream().distinct().collect(Collectors.toList());
record.setDouyinIdList(collect);

if(record.getCouponId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
if(record.getContentType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空");
}
EnumCpsPlanContentType planType = EnumCpsPlanContentType.getEnum(record.getContentType());
if(planType == null || (!planType.equals(EnumCpsPlanContentType.VIDEO) && !planType.equals(EnumCpsPlanContentType.LIVE))){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景错误");
}
if(planType.equals(EnumCpsPlanContentType.VIDEO)){
if(record.getStartTime() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划开始时间为空");
}
if(record.getEndTime() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划结束时间为空");
}
if(record.getCommissionDuration() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"佣金有效期为空");
}
}
if(record.getTakeRate() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空");
}
if(record.getTakeRate() < 0 || record.getTakeRate() > 2900){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间");
}

record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.saveOrientedPlan(record);
}

@ApiOperation("新增定向佣金达人合作")
@PostMapping("addOrientedPlanDouyin")
@SystemControllerLog(description = "更新")
public ResultData addOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::addOrientedPlanDouyin");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空");
}
if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"添加定向达人抖音号为空");
}

record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.addOrientedPlanDouyin(record);
}

@ApiOperation("取消定向佣金达人合作")
@PostMapping("cancelOrientedPlanDouyin")
@SystemControllerLog(description = "更新")
public ResultData cancelOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::cancelOrientedPlanDouyin");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空");
}
if(StringUtils.isBlank(record.getDouyinId())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"取消定向达人抖音号为空");
}
record.updateTenantInfo(getTenantInfo());
return ttCouponGoodsService.cancelOrientedPlanDouyin(record);
}

@ApiOperation("修改通用佣金计划状态")
@PostMapping("updateStatus")
@SystemControllerLog(description = "更新")
public ResultData updateStatus(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateStatus");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空");
}
if(record.getStatus() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空");
}
EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus());
if(planStatus == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法");
}
record.updateTenantInfo(getTenantInfo());

return ttCouponGoodsService.poiPlanUpdateStatus(record);
}

@ApiOperation("修改定向佣金计划状态")
@PostMapping("updateOrientedStatus")
@SystemControllerLog(description = "更新")
public ResultData updateOrientedStatus(@RequestBody TtPoiTakeRate record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateOrientedStatus");
if(record.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空");
}
if(record.getStatus() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空");
}
EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus());
if(!EnumCpsPlanStatus.OFF.equals(planStatus)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法");
}
record.updateTenantInfo(getTenantInfo());

return ttCouponGoodsService.poiOrientedPlanUpdateStatus(record);
}


@ApiOperation("获取佣金范围")
@PostMapping("getRateScope")
@SystemControllerLog(description = "获取")
public ResultData getRateScope(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getRateScope");

String couponIdStr = (String) param.get("couponId");
Integer planType = (Integer) param.get("planType");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);

EnumCpsPlanType anEnum = EnumCpsPlanType.getEnum(planType);
if(anEnum == null){
anEnum = EnumCpsPlanType.COMMON;
}

return ttCouponGoodsService.getRateScope(getTenantInfo(),couponId,anEnum);
}

@ApiOperation("设置总分佣率")
@PostMapping("setUpRateAll")
@SystemControllerLog(description = "更新")
public ResultData setUpAll(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setUpAll");

String couponIdStr = (String) param.get("couponId");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);
Integer mallRate = (Integer) param.get("mallRate");

if(mallRate == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"总分佣率为空");
}

return ttCouponGoodsService.setUpAll(getTenantInfo(),couponId,mallRate);
}

@ApiOperation("获取总分佣率及范围")
@PostMapping("getRateAll")
@SystemControllerLog(description = "获取")
public ResultData getAll(@RequestBody Map<String, Object> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getAll");

String couponIdStr = (String) param.get("couponId");
if(StringUtils.isBlank(couponIdStr)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空");
}
Long couponId = Long.parseLong(couponIdStr);
return ttCouponGoodsService.getAll(getTenantInfo(),couponId);
}

}

+ 0
- 189
yqzjAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java 查看文件

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

import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.TtCouponChannelVo;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.douyin.web.bean.GoodsTemplateGet;
import com.iformall.enums.*;
import com.iformall.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("ttgoods")
@Api(description = "抖音商品库")
public class TtCouponGoodsController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponService wxCouponService;

@Autowired
private TtCouponGoodsService ttCouponGoodsService;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private TtGoodsCategoryService ttGoodsCategoryService;

// @ApiOperation("分页列表接口")
// @GetMapping("couponList")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
// @SystemControllerLog(description = "-列表")
// public ResultData couponList(@ModelAttribute TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) {
// logger.debug("[" + getIpAddr() + "] WxCouponController::couponList");
// if (ttCouponVo == null) ttCouponVo = new TtCouponVo();
// ttCouponVo.updateTenantInfo(getTenantInfo());
// ttCouponVo.setType(EnumCouponType.COUPON_DOUYIN.getCode());
// if(StringUtils.isNotBlank(ttCouponVo.getSortColumn())){
// String coryColumn = "c."+ttCouponVo.getSortColumns();
// ttCouponVo.setSortColumns(coryColumn);
// ttCouponVo.setSortColumn(null);
// }else{
// ttCouponVo.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC);
// }
// if (ttCouponVo.getStatus() != null && ttCouponVo.getStatus() == -1)
// ttCouponVo.setStatus(null);
// return ttCouponGoodsService.couponList(ttCouponVo, pageNum, pageSize);
// }
//
// @ApiOperation("分页列表接口")
// @GetMapping("channelList")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
// @SystemControllerLog(description = "-列表")
// public ResultData channelList(@ModelAttribute TtCouponChannelVo ttChannelVo, Integer pageNum, Integer pageSize) {
// logger.debug("[" + getIpAddr() + "] WxCouponController::channelList");
// if (ttChannelVo == null) ttChannelVo = new TtCouponChannelVo();
// ttChannelVo.updateTenantInfo(getTenantInfo());
// ttChannelVo.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode());
// if(null == ttChannelVo.getSourceType()){
// ttChannelVo.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
// }
//
// if(StringUtils.isNotBlank(ttChannelVo.getSortColumn())){
// String coryColumn = "cc."+ttChannelVo.getSortColumns();
// ttChannelVo.setSortColumns(coryColumn);
// ttChannelVo.setSortColumn(null);
// }else{
// ttChannelVo.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
// }
//
// return ttCouponGoodsService.channelList(ttChannelVo, pageNum, pageSize);
// }

@ApiOperation("根据类目获取商品模板")
@GetMapping("getTemplate")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "根据类目获取商品模板")
public ResultData getGoodsTemplate(Long couponId,Integer categoryId,Integer productType) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getGoodsTemplate");
if(productType == null){
productType = 1;
}
if(couponId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCoupon coupon = wxCouponService.getAttrsById(couponId, getTenantInfo().getTenantId());
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

try {
GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType);
ttGoodsCategoryService.adminIsShow(goodsTemplateGet);
ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon);
return new ResultData(goodsTemplateGet);
} catch (WxErrorException e) {
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}

}

@TenantIgnore
@ApiOperation("提交审核")
@PostMapping("product/save")
@SystemControllerLog(description = "提交审核")
public ResultData productSave(@RequestBody WxCoupon wxCoupon) {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(), getTenantInfo().getTenantId());
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if(coupon.getSalePrice() == null || coupon.getSalePrice().intValue() == 0){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"免费券无需提审");
}

try {
return ttCouponGoodsService.productSave(coupon);
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
}

@ApiOperation("实时查询审核状态")
@GetMapping("product/draft")
@SystemControllerLog(description = "实时查询审核状态")
public ResultData productDraft(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productDraftGet(getTenantInfo(),id);
}

@ApiOperation("实时查询线上商品状态")
@GetMapping("product/online")
@SystemControllerLog(description = "实时查询审核状态")
public ResultData productOnline(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productOnlineGet(getTenantInfo(),id);
}

@ApiOperation("实时同步上下架状态")
@GetMapping("product/operate")
@SystemControllerLog(description = "实时同步上下架状态")
public ResultData productOperate(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productOperate(getTenantInfo(),id);
}

@ApiOperation("实时同步库存")
@GetMapping("product/stock/sync")
@SystemControllerLog(description = "实时同步库存")
public ResultData productStockSync(Long id) {
if (id == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
return ttCouponGoodsService.productStockSync(getTenantInfo(),id);
}



}

+ 0
- 216
yqzjAdmin/src/main/java/com/iformall/controller/market/WxCampaignController.java 查看文件

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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.WxCampaign;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.*;
import com.iformall.service.WxCampaignService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("wxCampaign")
@Api(description = "促销和banner接口")
public class WxCampaignController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCampaignService wxCampaignService;

@Autowired
WxCouponService wxCouponService;

@Autowired
private WxCouponChannelService wxCouponChannelService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "宣传页-列表")
public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::list");
if (null == wxCampaign) wxCampaign = new WxCampaign();
if (wxCampaign.getStatus() != null && wxCampaign.getStatus() == -1) {
wxCampaign.setStatus(null);
}
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
wxCampaign.updateTenantInfo(getTenantInfo());
wxCampaign.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC);
final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "宣传页-新增")
public ResultData add(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::add");
if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) {
String[] arys = wxCampaign.getCouponIds().split(",");
wxCampaign.setCouponIds(JSON.toJSONString(arys));
} else {
wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0]));
}
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.saveOrUpdate(wxCampaign);
}

@ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填")
@PostMapping("addByPath")
@SystemControllerLog(description = "宣传页-新增")
public ResultData addByPath(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::addByPath");
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.addForPath(wxCampaign);
}

@ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填")
@PostMapping("addByAPPPath")
@SystemControllerLog(description = "宣传页-新增")
public ResultData addByAPPPath(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::addByAPPPath");
wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCampaign.updateTenantInfo(getTenantInfo());
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.addByAPPPath(wxCampaign);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "宣传页-id更新")
public ResultData update(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::update");

if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) {
String[] arys = wxCampaign.getCouponIds().split(",");
wxCampaign.setCouponIds(JSON.toJSONString(arys));
} else {
wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0]));
}
if(wxCampaign.getPlat() == null){
wxCampaign.setPlat(EnumAppPlat.WX.getCode());
}
return wxCampaignService.saveOrUpdate(wxCampaign);
}

@ApiOperation("根据id更新接口")
@PostMapping("updateStatus")
@SystemControllerLog(description = "宣传页-更新状态")
public ResultData updateStatus(@RequestBody WxCampaign wxCampaign) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::updateStatus");
WxCampaign campaign = wxCampaignService.getById(wxCampaign.getId());
// check coupon 状态
if (campaign.getType().equals(EnumCampaignType.STABLE.getCode())) {
if (campaign.getStatus().equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())
&& !wxCampaign.getStatus().equals(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode())) {
// 宣传页 - 下架不检查状态
List<String> ids = JSONArray.parseArray(campaign.getCouponIds(), String.class);
for (String couponIdStr : ids) {
Long couponId = Long.parseLong(couponIdStr);

WxCoupon wxCoupon = wxCouponService.getById(couponId,campaign.getTenantId());
if (wxCoupon == null) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}
if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}
}
}
}
wxCampaign.setPlat(campaign.getPlat());
return wxCampaignService.updateStatus(wxCampaign);
}

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

@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "宣传页-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::findById");
WxCampaign wxCampaign = wxCampaignService.getById(id);
if (wxCampaign != null) {
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.updateTenantInfo(wxCampaign);
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode());
wxCouponChannel.setSubTargetId(wxCampaign.getId());
wxCouponChannel.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
List<WxCouponChannelVo> voList = wxCouponChannelService.newfindListVo(wxCouponChannel);
wxCampaign.setCoupons(voList);
}
return new ResultData(Result.SUCCESS, "查询成功", wxCampaign);
}

@ApiOperation("调整顺序")
@GetMapping("/move")
@ApiImplicitParams({
@ApiImplicitParam(name = "sourceId", value = "", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "targetId", value = "", dataType = "Long", paramType = "query", required = true)})
@SystemControllerLog(description = "宣传页-调整顺序")
public ResultData move(Long sourceId, Long targetId) {
logger.debug("[" + getIpAddr() + "] WxCampaignController::move");
WxCampaign source = wxCampaignService.getById(sourceId);
WxCampaign target = wxCampaignService.getById(targetId);
if (source == null || target == null) {
return new ResultData(Result.ERROR, "调整顺序失败", null);
}
int temp = source.getSortNum();
source.setSortNum(target.getSortNum());
target.setSortNum(temp);
wxCampaignService.saveOrUpdate(source);
wxCampaignService.saveOrUpdate(target);
return new ResultData(Result.SUCCESS, "调整顺序成功", null);
}


}

+ 0
- 275
yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java 查看文件

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

import com.alibaba.fastjson.JSON;
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.domain.dto.WxCouponChannelDto;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponSourceType;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.util.CouponCacheUtils;
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.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

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


@RestController
@RequestMapping("wxCouponChannel")
@Api(description = "优惠券投放接口")
public class WxCouponChannelController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponChannelService wxCouponChannelService;
@Autowired
RedisLock redisLock;
@Autowired
private WxCouponService wxCouponService;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-列表")
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());

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

if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
//
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
}
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "券投放-更新")
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){
wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType());
}
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null);
return resultData;
}

@ApiOperation("预审核上架")
@PostMapping("updateOnline")
@SystemControllerLog(description = "预审核上架")
public ResultData updateOnline(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.updateTenantInfo(getTenantInfo());
if (wxCouponChannel.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
ResultData resultData = wxCouponChannelService.updateOnline(wxCouponChannel);
if(resultData.code == 200){
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null);
}

return resultData;
}



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

@TenantIgnore
@ApiOperation("批量新增")
@PostMapping("/addbatch")
@SystemControllerLog(description = "券投放-批量新增")
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(wxCouponChannelDto.getType(),ids, channelId, getTenantInfo(),
wxCouponChannelDto.getShowBeginTime(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime(),wxCouponChannelDto.getChannelPrice(),wxCouponChannelDto.getChannelStock());
if (null != channelId && channelId.length > 0 ) {
for (String chId: channelId) {
if (!StringUtils.isBlank(chId)) {
CouponCacheUtils.removeCouponChannelCache(redisTemplate, Long.parseLong(chId));
}
}
}
CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, this.getTenantInfo().getTenantId(), null, null);
return resultData;
}

@ApiOperation("根据id查询接口")
@GetMapping("/findChannelByCouponId")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
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));
}
@ApiOperation("设置库存")
@PostMapping("/setChannelStock")
@SystemControllerLog(description = "设置渠道库存")
public ResultData setChannelStock(@RequestBody WxCouponChannel wxCouponChannel) {
if (null == wxCouponChannel.getChannelStock() || wxCouponChannel.getChannelStock() <= 0) {
return new ResultData(Result.ERROR, "库存未设置或者库存小于0, 如不需要可点击解除锁定库存.");
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(), wxCouponChannel.getTenantId());
if (coupon.getRemainInventory().intValue() < wxCouponChannel.getChannelStock().intValue()) {
return new ResultData(Result.ERROR, "渠道库存不能大于券剩余总库存.");
}
try {
wxCouponChannelService.setChannelStock(wxCouponChannel, wxCouponChannel.getChannelStock());
redisLock.setCouponStock(wxCouponChannel.getCouponId(), coupon.getRemainInventory());
redisLock.setCouponChannelStock(wxCouponChannel.getId(), wxCouponChannel.getChannelStock());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelStock error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}

}
@ApiOperation("解除锁定库存")
@PostMapping("/releaseChannelStock")
@SystemControllerLog(description = "释放渠道锁定库存")
public ResultData releaseChannelStock(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.updateTenantInfo(getTenantInfo());
try {
wxCouponChannelService.releaseChannelStock(wxCouponChannel);
redisLock.removeCouponStock(wxCouponChannel.getCouponId());
redisLock.removeCouponChannelStock(wxCouponChannel.getId());
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseChannelStock error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}
}
@ApiOperation("设置价格")
@PostMapping("/setChannelPrice")
@SystemControllerLog(description = "设置渠道价格")
public ResultData setChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) {
if (null == wxCouponChannel.getChannelPrice() || wxCouponChannel.getChannelPrice() < 0) {
return new ResultData(Result.ERROR, "价格未设置或者价格小于0, 如不需要可点击解除价格设置.");
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
//免费券不能设置有价
WxCouponChannel cc = wxCouponChannelService.getById(wxCouponChannel.getId(), wxCouponChannel.getTenantId());
if (null == cc ) {
return new ResultData(Result.ERROR, "id无效.");
}
WxCoupon coupon = wxCouponService.getById(cc.getCouponId(), wxCouponChannel.getTenantId());
if (null == coupon ) {
return new ResultData(Result.ERROR, "优惠券不存在.");
}
if (coupon.getSalePrice() <= 0) {
return new ResultData(Result.ERROR, "免费券不能设置渠道价格.");
}
try {
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("setChannelPrice error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}
}
@ApiOperation("解除价格设置")
@PostMapping("/releaseSetChannelPrice")
@SystemControllerLog(description = "设置渠道价格")
public ResultData releaseSetChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.setChannelPrice(null);
wxCouponChannel.updateTenantInfo(getTenantInfo());
try {
wxCouponChannelService.setChannelPrice(wxCouponChannel);
CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId());
return new ResultData(Result.SUCCESS, "设置成功", "");
}catch(MallinkException e) {
logger.error("releaseSetChannelPrice error.",e);
return new ResultData(e.getErrorCode(),e.getMessage());
}catch(Exception e){
return new ResultData(Result.ERROR,e.getMessage());
}

}


}

+ 0
- 739
yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java 查看文件

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

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.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.douyin.web.bean.GoodsTemplateGet;
import com.iformall.enums.*;
import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.*;
import com.iformall.service.util.CouponCacheUtils;
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 me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("wxCoupon")
@Api(description = "优惠券接口")
public class WxCouponController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCouponPasswordService couponPasswordService;
@Autowired
private WxCouponChannelService wxCouponChannelService;
@Autowired
private WxFlowService wxFlowService;
@Autowired
private WxMallService wxMallService;
@Autowired
private WxCouponMallService wxCouponMallService;
@Autowired
RedisLock redisLock;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;

@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,Boolean isList) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(getTenantInfo());
return couponList(wxCoupon, pageNum, pageSize, isList);
}
@TenantIgnore
@ApiOperation("父券分页列表接口")
@GetMapping("parentCouponList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData parentCouponList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) {
logger.debug("[" + getIpAddr() + "] WxCouponController::list");
if (wxCoupon == null) wxCoupon = new WxCoupon();
TenantEntity mallTenantEntity = getTenantInfo();
wxCoupon.setTenantId(mallTenantEntity.getParentTenantId());
wxCoupon.setParentTenantId(null);
//平台券
if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == wxCoupon.getType()) {
//查询已经分配了的parentCouponList
WxCouponMall couponMall = new WxCouponMall();
couponMall.updateTenantInfo(wxCoupon);
couponMall.setMallTenantId(mallTenantEntity.getTenantId());
List<Long> couponIds = wxCouponMallService.listCouponIds(couponMall);
if (null != couponIds && couponIds.size() > 0 ) {
wxCoupon.setIds(couponIds);
}else {
wxCoupon.setId(-1L);
}
}
return couponList(wxCoupon, pageNum, pageSize, isList);
}
private ResultData couponList(WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) {
//默认A端建券
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
}
//排序处理
if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumns(coryColumn);
wxCoupon.setSortColumn(null);
}

//isList true 查全部 / 否则 只查询主动领取和定向投放的。
if(wxCoupon.getSendType() == null && !(isList == null?false:isList)){
Integer[] sendTypeArray = {
EnumCouponSendType.ACTIVE.getCode(),
EnumCouponSendType.PASSIVE.getCode(),};
wxCoupon.setSendTypes(Arrays.asList(sendTypeArray));
}

return wxCouponService.list(wxCoupon,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)})
@SystemControllerLog(description = "券投放-列表")
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_DOUYIN.getCode(),
EnumCouponType.COUPON_PRESS.getCode(),
EnumCouponType.COUPON_PREORDER.getCode()};

wxCoupon.setTypes(Arrays.asList(typeArray));

Integer[] sendTypeArray = {
EnumCouponSendType.ACTIVE.getCode(),
EnumCouponSendType.PASSIVE.getCode(),};

wxCoupon.setSendTypes(Arrays.asList(sendTypeArray));

if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumns(coryColumn);
wxCoupon.setSortColumn(null);
}
return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
}
@TenantIgnore
@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "券投放-新增")
public ResultData add(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::add");
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.updateTenantInfo(tenantEntity);

if(null == wxCoupon.getContentType()){
wxCoupon.setContentType(EnumCouponContentType.NORMAL.getCode());
}
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(), getUserId(), getUser().getName(), tenantEntity);
//修改coupon applyStatus状态为审核中
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
}
return resultData;
}

@TenantIgnore
@ApiOperation("根据id更新接口")
@PostMapping("update")
@SystemControllerLog(description = "券投放-更新")
public ResultData update(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
wxCoupon.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}

if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){
if(!EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(coupon.getStatus())){
return new ResultData(ResultData.ERROR, "请先作废,再进行删除。");
}
wxCouponService.deleteById(wxCoupon.getId(),wxCoupon.getTenantId());
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return new ResultData();
}

//启动审批流
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(), getUserId(), 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());
}
}

ResultData result = null;
if(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){
result = wxCouponService.disable(wxCoupon, wxCoupon.getId());
}else{
result = wxCouponService.saveOrUpdate(wxCoupon);
if(wxCoupon.getRemainInventory() != null){
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory());
}
}

CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新接口")
@PostMapping("continueAdd")
@SystemControllerLog(description = "继续添加")
public ResultData continueAdd(@RequestBody WxCoupon wxCoupon) {
logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if(wxCoupon.getProductType() == null || wxCoupon.getCategoryId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "缺少必要参数");
}

wxCoupon.updateTenantInfo(getTenantInfo());
WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
}

coupon.setProductType(wxCoupon.getProductType());
coupon.setCategoryId(wxCoupon.getCategoryId());
coupon.setProductAttrs(wxCoupon.getProductAttrs());
coupon.setSkuAttrs(wxCoupon.getSkuAttrs());

ResultData result = wxCouponService.updateTtProduct(coupon);
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId());
return result;
}

@ApiOperation("根据id更新库存及有效期接口")
@PostMapping("updateStokeAndValidDate")
@SystemControllerLog(description = "券投放-库存/有效期更新")
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) {
return new ResultData(ErrorCode.COUPON_IS_EMPTY);
}
if(EnumCouponSendType.GIFT.getCode().equals(coupon.getSendType())){
return new ResultData(ErrorCode.COUPON_GIFT_NOTUPD_INVENTORY);
}
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);
}
wxCoupon.setSalePrice(coupon.getSalePrice());
if(!wxCouponService.validCouponDate(wxCoupon)) {
return new ResultData(ResultData.ERROR,"券有效结束日期必须在30天以内。");
}
wxCoupon.setSalePrice(null);


//启动审批流
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(), getUserId(), 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);
}
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return new ResultData();
}

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

@TenantIgnore
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
TenantEntity tenantEntity = getTenantInfo();
return new ResultData(wxCouponService.getVoById(id,tenantEntity.getTenantId(),tenantEntity));
}
@TenantIgnore
@ApiOperation("根据id查询接口")
@GetMapping("/findParentCouponById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-查询")
public ResultData findParentCouponById(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::findById");
TenantEntity tenantEntity = getTenantInfo();
return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getParentTenantId(),tenantEntity));
}

@TenantIgnore
@ApiOperation("卡营销列表接口")
@GetMapping("findCardCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-卡营销列表")
public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
Map<String, Object> result = new HashedMap();
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
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,tenantEntitys, 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("/cardCountExportData")
@SystemControllerLog(description = "营销统计-卡营销数据导出")
public void cardCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
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());
wxCouponService.exportCardData(wxCoupon,tenantEntitys, request, response);
}

@TenantIgnore
@ApiOperation("券营销列表接口")
@GetMapping("findCouponCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-券营销列表")
public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
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, tenantEntitys, 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("/couponCountExportData")
@SystemControllerLog(description = "营销统计-券营销数据导出")
public void couponCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
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());
wxCouponService.exportCouponData(wxCoupon,tenantEntitys, request, response);
}

@TenantIgnore
@ApiOperation("砍价营销列表接口")
@GetMapping("findPressCountList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "券投放-砍价营销列表")
public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxCoupon.updateTenantInfo(tenantEntity);
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,tenantEntitys,pageNum,pageSize);
return new ResultData(pages);
}
@ApiOperation("砍价营销列表记录导出")
@GetMapping("/pressCountExportData")
@SystemControllerLog(description = "营销统计-券营销数据导出")
public void pressCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) {
//默认时间本月第一天,截止到当天
TenantEntity tenantEntity = getTenantInfo();
List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity);
wxCoupon.updateTenantInfo(tenantEntity);
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
wxCouponService.exportPressData(wxCoupon,tenantEntitys, request, response);
}

@GetMapping("exportCouponPassword")
@SystemControllerLog(description = "卡券兑换码-导出数据")
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);
if (null != wxCouponPassword.getCouponId()) {
CouponCacheUtils.removeCouponCache(redisTemplate, wxCouponPassword.getCouponId());
}
}

@ApiOperation("根据id获取富文本接口")
@GetMapping("/getHtml")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "券投放-富文本获取")
public ResultData getHtml(@RequestParam Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById");
return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId()));
}
@ApiOperation("卡延期")
@PostMapping("/cardDefer")
@SystemControllerLog(description = "卡延期")
public ResultData cardDefer(@RequestBody WxCoupon wxCoupon) {
if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id");
}
if (wxCoupon.getValidEndDate() == null) {
return new ResultData(ResultData.ERROR, "缺少validEndDate");
}
ResultData result = wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate());
CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId());
return result;
}
@ApiOperation("集团查询:查询平台券商场列表")
@GetMapping("/getPlatMallList")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData getPlatMallList(@RequestParam Long id) {
WxCouponMall wxCouponMall = new WxCouponMall();
wxCouponMall.updateTenantInfo(getTenantInfo());
wxCouponMall.setProductId(id);
return new ResultData(wxCouponMallService.list(wxCouponMall,true));
}
@TenantIgnore
@ApiOperation("平台券商场列表")
@GetMapping("/getCouponMall")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)})
public ResultData getCouponMall(Long id) {
//如果是集团查询,则查询所有的,如果是商场查询,则只查询商场的
WxCouponMall wxCouponMall = new WxCouponMall();
TenantEntity tenantEntity = getTenantInfo();
if (null == tenantEntity.getParentTenantId()) {
wxCouponMall.updateTenantInfo(tenantEntity);
wxCouponMall.setProductId(id);
}else {
wxCouponMall.setTenantId(tenantEntity.getParentTenantId());
//一个商场,每个平台券只有一条记录
wxCouponMall.setMallTenantId(tenantEntity.getTenantId());
wxCouponMall.setProductId(id);
}
List<WxCouponMall> mallList= wxCouponMallService.list(wxCouponMall,false);
if (null != mallList && mallList.size() > 0 ) {
boolean isComplete = true;
for (int i = 0 ; i < mallList.size(); i ++) {
WxCouponMall cm = mallList.get(i);
if (EnumCouponMallStatus.UNFINISED.getCode() == cm.getStatus()) {
isComplete = false;
break;
}
}
if (isComplete) {
return new ResultData("{\"isCompleted\":1}");
}else {
return new ResultData("{\"isCompleted\":0}");
}
}else {
return new ResultData("{\"isCompleted\":0}");
}
}
@TenantIgnore
@ApiOperation("商场设置平台券商户")
@PostMapping("/setParentCouponMerchants")
public ResultData setMallMerchants(@RequestBody WxCoupon wxCoupon) {
try {
wxCouponService.setParentCouponMallMerchants(getTenantInfo(),wxCoupon);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
return new ResultData();
}
@ApiOperation("自己券商户是否自动分账")
@PostMapping("/couponMerchantAutoShare")
public ResultData couponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) {
wxCoupon.updateTenantInfo(getTenantInfo());
try {
Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(wxCoupon,wxCoupon);
return new ResultData(map);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("父券商户是否自动分账")
@PostMapping("/parentCouponMerchantAutoShare")
public ResultData parentCouponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) {
TenantEntity tenantEntity = getTenantInfo();
wxCoupon.setTenantId(tenantEntity.getParentTenantId());
wxCoupon.setParentTenantId(null);
try {
Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(tenantEntity,wxCoupon);
return new ResultData(map);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("商场设置平台券已完成")
@PostMapping("/setPlatCouponFinished")
public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) {
try {
TenantEntity tenantEntity = getTenantInfo();
String mallTenantId = tenantEntity.getTenantId();
String tenantId = tenantEntity.getTenantId();
if (null != tenantEntity.getParentTenantId()) {
tenantId = tenantEntity.getParentTenantId();
}
wxCouponMallService.finised(tenantId, wxCoupon.getId(), mallTenantId);
return new ResultData();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@ApiOperation("商场设置平台券未完成")
@PostMapping("/setPlatCouponUnFinished")
public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) {
try {
if (null == wxCoupon.getType()) {
return new ResultData(Result.ERROR,"缺少参数");
}
TenantEntity tenantEntity = getTenantInfo();
String mallTenantId = tenantEntity.getTenantId();
String tenantId = tenantEntity.getTenantId();
if (null != tenantEntity.getParentTenantId()) {
tenantId = tenantEntity.getParentTenantId();
}
wxCouponMallService.unfinised(tenantId, wxCoupon.getId(),wxCoupon.getType(), mallTenantId);
return new ResultData();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}

}

+ 0
- 175
yqzjAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java 查看文件

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponSend;
import com.iformall.domain.vo.WxCouponSendVo;
import com.iformall.enums.EnumCouponSendSendType;
import com.iformall.enums.EnumCouponSendType;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCouponActionLogService;
import com.iformall.service.WxCouponSendService;
import com.iformall.service.WxCouponService;
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.Date;
import java.util.Objects;

@RestController
@RequestMapping("wxCouponSend")
@Api(description = "注劵接口")
public class WxCouponSendController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponSendService wxCouponSendService;
@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxCouponActionLogService wxCouponActionLogService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "merchantName", value = "商户名,模糊查询", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "merchantId", value = "商户Id", dataType = "String", paramType = "query"),
})
@SystemControllerLog(description = "注券-列表")
public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::list");
if (null == wxCouponSend) wxCouponSend = new WxCouponSend();
wxCouponSend.updateTenantInfo(getTenantInfo());

// if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSend.getSendType())) {
// if (Objects.nonNull(wxCouponSend.getStatus())) {
// valid = wxCouponSend.getStatus();
// } else {
// wxCouponSend.setStatus(null);
// }
// }
PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("注券-添加配置")
@GetMapping("config/add")
@ApiImplicitParams({
@ApiImplicitParam(name = "beforeDays", value = "提前n天发券", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true),
})
@SystemControllerLog(description = "注券-添加或更新配置")
public ResultData addConfig(Integer beforeDays, Integer sendType) {
if (!Objects.equals(sendType, EnumCouponSendSendType.BIRTHDAY.getCode())) {
return new ResultData(ErrorCode.COUPON_VALID_NOT_SUPPORTED);
}
try {
wxCouponSendService.saveOrUpdateConfig(beforeDays, sendType, getTenantInfo());
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, e.getMessage());
}
return new ResultData();
}

@ApiOperation("注券-获取配置")
@GetMapping("config/get")
@ApiImplicitParams({
@ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "注券-获取配置")
public ResultData getConfig(Integer sendType) {
WxCouponSend wxCouponSend = wxCouponSendService.getConfig(sendType, getTenantInfo());
return new ResultData(Objects.isNull(wxCouponSend) ? null : wxCouponSend.getConditions());
}

@ApiOperation("新增接口")
@PostMapping("add")
@SystemControllerLog(description = "注券-新增")
public ResultData add(@RequestBody WxCouponSend wxCouponSend) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::add");
if (null == wxCouponSend) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}

WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId(),getTenantInfo().getTenantId());
if (!EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(wxCoupon.getStatus())) {
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF);
}

if (!EnumCouponSendType.PASSIVE.getCode().equals(wxCoupon.getSendType())) {
return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE);
}

wxCouponSend.updateTenantInfo(wxCoupon);
wxCouponSend.setTitle(wxCoupon.getTitle());

wxCouponSend.setCreateDate(new Date());
wxCouponSend.setUpdateDate(new Date());

try {
wxCouponSend.setOperatorId(getUserId());
wxCouponSendService.saveOrUpdate(wxCouponSend);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
}

return new ResultData();
}

// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// @SystemControllerLog(description = "注券-更新")
// public ResultData update(@RequestBody WxCouponSend wxCouponSend) {
// logger.debug("[" + getIpAddr() + "] WxCouponSendController::update");
// wxCouponSend.updateTenantInfo(getTenantInfo());
// wxCouponSendService.saveOrUpdate(wxCouponSend);
// return new ResultData();
// }

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "sendType", value = "注券类型(会员生日券时必传)", dataType = "int", paramType = "query")
})
@SystemControllerLog(description = "注券-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::delete");
WxCouponSend wxCouponSend = wxCouponSendService.getById(id,getTenantInfo().getTenantId());
if (wxCouponSend == null) {
return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID);
}
try {
wxCouponSendService.updateInvalid(wxCouponSend);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
}
return new ResultData();
}

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


}

+ 0
- 276
yqzjAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java 查看文件

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxPressBatch;
import com.iformall.domain.po.WxPressBatchItem;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponChannelType;
import com.iformall.enums.EnumCouponContentType;
import com.iformall.enums.EnumCouponSourceType;
import com.iformall.enums.EnumCouponType;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxPressBatchService;
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.apache.commons.lang3.StringUtils;
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.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

@RestController
@RequestMapping("pressBatch")
public class WxPressBatchController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxPressBatchService wxPressBatchService;
@Autowired
WxCouponService wxCouponService;
@Autowired
WxCouponChannelService wxCouponChannelService;

@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 WxPressBatch record, Integer pageNum, Integer pageSize) {
if (null == record) {
record = new WxPressBatch();
}
record.updateTenantInfo(getTenantInfo());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<WxPressBatch> page = wxPressBatchService.listAsPage(record, pageNum, pageSize);
return new ResultData(page);
}
@ApiOperation("新增&修改接口")
@PostMapping("saveOrUpdate")
public ResultData saveOrUpdate(@RequestBody WxPressBatch record) {
TenantEntity tenantEntity = getTenantInfo();
record.updateTenantInfo(tenantEntity);
wxPressBatchService.saveOrUpdate(record);
return new ResultData();
}
@ApiOperation("详情接口")
@GetMapping("detail")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)})
public ResultData detail(Long id) {
if (null == id) {
return new ResultData(Result.ERROR,"参数错误");
}
WxPressBatch order = wxPressBatchService.getById(id, getTenantInfo().getTenantId());
return new ResultData(order);
}
@ApiOperation("砍价券接口")
@GetMapping("itemList")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true),
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData itemList(Long id, Integer pageNum, Integer pageSize) {
if (null == id) {
return new ResultData(Result.ERROR,"参数错误");
}
TenantEntity tenantEntity = getTenantInfo();
PageInfo<WxPressBatchItem> itemPage = wxPressBatchService.getItemPage(id, tenantEntity.getTenantId(),pageNum,pageSize);
List<WxPressBatchItem> items = itemPage.getList();
if (null != items && items.size() > 0 ) {
List<Long> couponIdList = wxPressBatchService.getItemCouponIdList(id, tenantEntity.getTenantId());
WxCoupon record = new WxCoupon();
record.updateTenantInfo(getTenantInfo());
if (null != couponIdList && couponIdList.size() > 0 ) {
record.setIds(couponIdList);
}else {
record.setId(0L);
}
List<WxCoupon> list = wxCouponService.list(record);
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
if (null != list && list.size() > 0 ) {
for (WxCoupon c : list) {
couponMap.put(c.getId(), c);
}
}
for (WxPressBatchItem pbi : items) {
WxCoupon coupon = couponMap.get(pbi.getCouponId());
pbi.setCoupon(coupon);
}
}
return new ResultData(itemPage);
}
@ApiOperation("删除接口")
@PostMapping("delete")
public ResultData delete(@RequestBody WxPressBatch record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
wxPressBatchService.deleteBatch(record.getId(), getTenantInfo().getTenantId());
return new ResultData();
}
@ApiOperation("已投放砍价券列表接口")
@GetMapping("couponList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),})
public ResultData couponList(@ModelAttribute WxCoupon record, Integer pageNum, Integer pageSize) {
WxCouponChannel couponChannelQ = new WxCouponChannel();
couponChannelQ.updateTenantInfo(getTenantInfo());
couponChannelQ.setType(EnumCouponType.COUPON_PRESS.getCode());
couponChannelQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode());
couponChannelQ.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
List<Long> couponIds = wxCouponChannelService.findCouponIdList(couponChannelQ);
if (null == record) {
record = new WxCoupon();
}
record.updateTenantInfo(couponChannelQ);
if (null != couponIds && couponIds.size() > 0 ) {
record.setIds(couponIds);
}else {
record.setId(0L);
}
PageInfo<WxCoupon> page = wxCouponService.simplelistAsPage(record, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增items")
@PostMapping("addItems")
public ResultData addItems(@RequestBody WxPressBatch record) {
TenantEntity tenantEntity = getTenantInfo();
record.updateTenantInfo(tenantEntity);
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
String cidstr = record.getCouponIds();
if (StringUtils.isBlank(cidstr)) {
return new ResultData(Result.ERROR,"参数错误");
}
String[] cids = cidstr.split(",");
if (null == cids || cids.length <= 0 ) {
return new ResultData(Result.ERROR,"请选择砍价券");
}
List<Long> rcids = new ArrayList<Long>();
for (String cid: cids) {
rcids.add(Long.parseLong(cid));
}
//已经存在了的不能再加入
List<Long> arrayCouponIds = wxPressBatchService.getCouponIds(tenantEntity.getTenantId());
if (null != arrayCouponIds && arrayCouponIds.size() > 0 ) {
if (arrayCouponIds.containsAll(rcids)) {
return new ResultData(Result.ERROR,"所选择的券已经加入了一个批次,不能再加");
}
List<Long> extraCouponIds = new ArrayList<Long>();
extraCouponIds.addAll(rcids);
extraCouponIds.removeAll(arrayCouponIds);
List<Long> sameCouponIds = new ArrayList<Long>();
sameCouponIds.addAll(rcids);
sameCouponIds.removeAll(extraCouponIds);
if (sameCouponIds.size() > 0) {
WxCoupon couponQ = new WxCoupon();
couponQ.updateTenantInfo(tenantEntity);
couponQ.setIds(sameCouponIds);
List<WxCoupon> couponList = wxCouponService.list(couponQ);
if (null == couponList || couponList.size() <= 0 ) {
return new ResultData(Result.ERROR,"未查询到这些券");
}
Map<Long,String> couponNameMap = new HashMap<Long,String>();
for (WxCoupon c: couponList) {
couponNameMap.put(c.getId(),c.getTitle());
}
StringBuffer sb = new StringBuffer("已经存在一个批次的券:");
for (Long _cid: sameCouponIds) {
sb.append(couponNameMap.get(_cid)).append(",");
}
return new ResultData(Result.ERROR,sb.toString());
}
}
List<Long> batchCids = wxPressBatchService.getItemCouponIdList(record.getId(), tenantEntity.getTenantId());
if (null != cids && cids.length > 0 ) {
if (null != batchCids && batchCids.size() > 0 ) {
rcids.removeAll(batchCids);
}
WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId());
wxPressBatchService.saveItems(order, rcids);
}
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("deleteItem")
public ResultData deleteItem(@RequestBody WxPressBatchItem record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
wxPressBatchService.deleteItemById(record.getId(), getTenantInfo().getTenantId());
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("updateStatus")
public ResultData updateStatus(@RequestBody WxPressBatch record) {
if (null == record.getId() || null == record.getStatus()) {
return new ResultData(Result.ERROR,"参数错误");
}
record.updateTenantInfo(getTenantInfo());
wxPressBatchService.updateStatus(record);
return new ResultData();
}
@ApiOperation("详情接口")
@PostMapping("setRules")
public ResultData setRules(@RequestBody WxPressBatch record) {
if (null == record.getId()) {
return new ResultData(Result.ERROR,"参数错误");
}
WxPressBatch record1 = wxPressBatchService.getById(record.getId(), getTenantInfo().getTenantId());
record1.setPromoterLimitRule(record.getPromoterLimitRule());
record1.setPromoterAllowCount(record.getPromoterAllowCount());
record1.setBargainerAllowCount(record.getBargainerAllowCount());
record1.setBargainerAllowSame(record.getBargainerAllowSame());
wxPressBatchService.saveOrUpdate(record1);
return new ResultData();
}


}

+ 0
- 192
yqzjAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java 查看文件

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

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponChannelType;
import com.iformall.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.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;

@RestController
@RequestMapping("memCoupon")
@Api(description = "会员券相关接口")
public class MemCouponController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponChannelService couponChannelService;

@Autowired
private MemCouponFromDspService memCouponFromDspService;

@Autowired
private WxCouponService couponService;

@ApiOperation("已投放券列表接口")
@GetMapping("couponChannelList")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员券管理-已投放列表")
public ResultData couponChannelList(Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MemCouponController::list");
WxCouponChannel wxCouponChannel = new WxCouponChannel();
if (null == wxCouponChannel) {
wxCouponChannel = new WxCouponChannel();
}
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_H5.getCode());
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());


if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
// String coryColumn = "c."+wxCouponChannel.getSortColumns();
// wxCouponChannel.setSortColumns(coryColumn);
// wxCouponChannel.setSortColumn(null);
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
}
final PageInfo<WxCouponChannelVo> page = couponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("已发放券列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
@SystemControllerLog(description = "会员券管理-列表")
public ResultData list(@ModelAttribute MemCouponFromDsp memCouponFromDsp, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MemCouponController::list");
if (null == memCouponFromDsp) {
memCouponFromDsp = new MemCouponFromDsp();
} else {
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
memCouponFromDsp.setPhone(null);
}
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
memCouponFromDsp.setSortColumns(BaseEntity.SortField.CreateDate_DESC);
PageInfo<MemCouponFromDsp> page = memCouponFromDspService.listAsPage(memCouponFromDsp, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("检查用户购买券是否可用")
@PostMapping("checkMemCoupon")
@SystemControllerLog(description = "会员券管理-检查")
public ResultData checkMemCoupon(@RequestBody MemCouponFromDsp memCouponFromDsp) {
logger.debug("[" + getIpAddr() + "] MemCouponController::add");
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填");
}
if (memCouponFromDsp.getCouponChannelId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填");
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId());
if (memCouponFromDsp.getCouponId() == null) {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}
MemCouponFromDsp couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponQ.setStatus(0);
Integer couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getRemainInventory() <= couponCount) {
return new ResultData(ErrorCode.REMAIN_IS_EMPTY);
}
// 2. 检查此会员是否已超限, 达到券购买限制
couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setPhone(memCouponFromDsp.getPhone());
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getUseLimitQuantity() <= couponCount) {
return new ResultData(ErrorCode.ORDER_IS_LIMITED);
}
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("add")
@SystemControllerLog(description = "会员券管理-添加")
public ResultData add(@RequestBody MemCouponFromDsp memCouponFromDsp) {
logger.debug("[" + getIpAddr() + "] MemCouponController::add");
if (StringUtils.isBlank(memCouponFromDsp.getPhone())) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填");
}
if (memCouponFromDsp.getCouponChannelId() == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填");
}
memCouponFromDsp.updateTenantInfo(getTenantInfo());
WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId());
if (memCouponFromDsp.getCouponId() == null) {
memCouponFromDsp.setCouponId(couponChannel.getCouponId());
}
// 1. 检查券是否已超限, 无剩余库存
WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),couponChannel.getTenantId());
if (coupon == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId());
}
MemCouponFromDsp couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponQ.setStatus(0);
Integer couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getRemainInventory() <= couponCount) {
return new ResultData(ErrorCode.REMAIN_IS_EMPTY);
}
// 2. 检查此会员是否已超限, 达到券购买限制
couponQ = new MemCouponFromDsp();
couponQ.updateTenantInfo(memCouponFromDsp);
couponQ.setPhone(memCouponFromDsp.getPhone());
couponQ.setCouponId(memCouponFromDsp.getCouponId());
couponCount = memCouponFromDspService.countByInfo(couponQ);
if (coupon.getUseLimitQuantity() <= couponCount) {
return new ResultData(ErrorCode.ORDER_IS_LIMITED);
}
// 3. 保存
memCouponFromDsp.setStatus(0);
memCouponFromDspService.saveOrUpdate(memCouponFromDsp);
return new ResultData();
}

@ApiOperation("根据手机号查询接口")
@GetMapping("/findByPhone")
@ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true)
@SystemControllerLog(description = "会员券管理-根据手机号查询接口")
public ResultData findByPhone(String phone) {
logger.debug("[" + getIpAddr() + "] MemCouponController::findByPhone");
if (StringUtils.isEmpty(phone)) {
return new ResultData(new ArrayList<MemCouponFromDsp>());
}
MemCouponFromDsp memQ = new MemCouponFromDsp();
memQ.updateTenantInfo(getTenantInfo());
memQ.setPhone(phone);
List<MemCouponFromDsp> memCouponFromDsps = memCouponFromDspService.getList(memQ);
return new ResultData(memCouponFromDsps);
}
}

+ 0
- 1
yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjAIGCController.java 查看文件

@@ -24,7 +24,6 @@ import com.iformall.enums.yqzj.EnumYqzjLunboType;
import com.iformall.enums.yqzj.EnumYqzjNewsType;
import com.iformall.enums.yqzj.EnumYqzjVideoType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import com.iformall.service.YqzjService;

import io.swagger.annotations.ApiImplicitParam;


+ 0
- 1
yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjAboutUsController.java 查看文件

@@ -24,7 +24,6 @@ import com.iformall.enums.yqzj.EnumYqzjLunboType;
import com.iformall.enums.yqzj.EnumYqzjNewsType;
import com.iformall.enums.yqzj.EnumYqzjVideoType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import com.iformall.service.YqzjService;

import io.swagger.annotations.ApiImplicitParam;


+ 0
- 1
yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjCarController.java 查看文件

@@ -24,7 +24,6 @@ import com.iformall.enums.yqzj.EnumYqzjLunboType;
import com.iformall.enums.yqzj.EnumYqzjNewsType;
import com.iformall.enums.yqzj.EnumYqzjVideoType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import com.iformall.service.YqzjService;

import io.swagger.annotations.ApiImplicitParam;


+ 0
- 1
yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjIndexController.java 查看文件

@@ -24,7 +24,6 @@ import com.iformall.enums.yqzj.EnumYqzjLunboType;
import com.iformall.enums.yqzj.EnumYqzjNewsType;
import com.iformall.enums.yqzj.EnumYqzjPageNewsType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import com.iformall.service.YqzjService;

import io.swagger.annotations.ApiImplicitParam;


+ 0
- 1
yqzjAdmin/src/main/java/com/iformall/controller/yqzj/YqzjYuanYuZhouController.java 查看文件

@@ -24,7 +24,6 @@ import com.iformall.enums.yqzj.EnumYqzjLunboType;
import com.iformall.enums.yqzj.EnumYqzjNewsType;
import com.iformall.enums.yqzj.EnumYqzjVideoType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.WxCouponService;
import com.iformall.service.YqzjService;

import io.swagger.annotations.ApiImplicitParam;


+ 0
- 304
yqzjService/src/main/java/com/iformall/service/WxCouponService.java 查看文件

@@ -1,304 +0,0 @@
package com.iformall.service;

import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.TtCouponChannelPoi;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.TtCouponVo;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.domain.vo.WxMerchantVo;

public interface WxCouponService {

ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize);
List<WxCoupon> list(WxCoupon wxCoupon);

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

/**
* 卡类列表,包括统计
* @param record
* @param tenantEntitys
* @return
*/
PageInfo<WxCouponStatisVo> findCountData(WxCoupon record, List<TenantEntity> tenantEntitys, Integer pageNum, Integer pageSize);
void exportCardData(WxCoupon record, List<TenantEntity> tenantEntitys, HttpServletRequest request, HttpServletResponse response);

/**
* 券列表,包括统计
* @param record
* @param tenantEntitys
* @return
*/
PageInfo<WxCouponStatisVo> findCouponData(WxCoupon record, List<TenantEntity> tenantEntitys, Integer pageNum, Integer pageSize);
void exportCouponData(WxCoupon record, List<TenantEntity> tenantEntitys, HttpServletRequest request, HttpServletResponse response);

/**
* 砍价列表,包括统计
* @param record
* @param tenantEntitys
* @param pageNum
* @param pageSize
* @return
*/
PageInfo<WxCouponStatisVo> findPressData(WxCoupon record, List<TenantEntity> tenantEntitys, Integer pageNum, Integer pageSize);

void exportPressData(WxCoupon record, List<TenantEntity> tenantEntitys, HttpServletRequest request, HttpServletResponse response);
/**
* 根据Id获得实体
*
* @param id
* @return
*/
WxCoupon getById(Long id,String tenantId);
WxCoupon getPriceAndStock(Long id,String tenantId);
List<WxCoupon> getPriceAndStock(List<Long> id,String tenantId);

WxCoupon getHtmlById(Long id,String tenantId);


WxCouponCVo getVoById(Long id,String couponTenantId,TenantEntity mallTenantEntity);

WxCouponCVo getVoStatusById(Long id,String tenantId);

WxCoupon getAttrsById(Long couponId, String tenantId);
/**
* 保存或更新实体
*
* @param record
*/
ResultData saveOrUpdate(WxCoupon record);

ResultData updateTtProduct(WxCoupon wxCoupon);
/**
* 更新实体
*
* @param record
*/
void update(WxCoupon record);
/**
* 根据Id删除实体
*
* @param id
*/
void deleteById(Long id,String tenantId);


/**
* 查询时间段内销售金额
*
* @param tenantEntitys
* @param wxCoupon
* @return
*/
List<WxCouponStatisVo> findSaleMoneyByDate(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 查询时间段内核销金额
*
* @param tenantEntitys
* @param wxCoupon
* @return
*/
List<WxCouponStatisVo> findPaymentByDate(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 查询售出卡数量
* @return
*/
Long findSaleCardCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 查询转增数量
* @return
*/
Long findTranCardCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 查询补贴金额
* @return
*/
String findSubsidyMoney(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

//----------------券--------------
/**
* 券发放数量
* @return
*/
//List<WxCoupon> findCouponSendCount(WxCoupon wxCoupon);

/**
* 券购买数量
* @return
*/
List<WxCouponStatisVo> findCouponOrderCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 券领取数量
* @return
*/
//List<WxCoupon> findCouponGetCount(WxCoupon wxCoupon);

/**
* 券核销数量
* @return
*/
List<WxCouponStatisVo> findCouponPaymentCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 有价券销售数量
* @return
*/
List<WxCouponStatisVo> priceCouponSaleCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 有价券核销数量
* @return
*/
List<WxCouponStatisVo> priceCouponPaymentCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 有价券退款数量
* @return
*/
Long priceCouponCancelCount(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 有价券销售总额
*
* @param tenantEntitys
* @param wxCoupon
* @return
*/
String findSumPriceSaleMoney(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);
String findSumPricePayMent(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);
String findSumSubsidyMoney(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);


/**
* 砍价发起次数走势
* @return
*/
List<WxCouponStatisVo> pressSendHistory(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);
/**
* 砍价成功次数走势
* @return
*/
List<WxCouponStatisVo> pressSuccHistory(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);
/**
* 砍价核销数量走势
* @return
*/
List<WxCouponStatisVo> pressPaymentHistory(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);
/**
* 砍价转化率
* @return
*/
String pressSuccRate(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 砍价参与人数
* @return
*/
Long sumJoin(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);



/**
* 查询售出卡数量历史
* @return
*/
List<WxCouponStatisVo> findSaleCardCountHistory(List<TenantEntity> tenantEntitys, WxCoupon wxCoupon);

/**
* 增加库存及修改有效时间
*/
ResultData updateCouponStockAndEndTime(WxCoupon wxCoupon);

WxCoupon findById(WxCoupon wxCoupon);

/**
* 库存减少
*
* @param id 券ID
* @param number 减少数量
* @param remainInventory 当前库存
*/
void reduceRemainInventory(TenantEntity tenantEntity,Long id, Integer number);

/**
* 库存退回
*
* @param id 券ID
* @param number 回退数量
* @param remainInventory 当前库存
*/
void backRemainInventory(TenantEntity tenantEntity,Long id, Integer number, Integer remainInventory);
/**
* 卡延期
* @param wxCoupon
* @return
*/
ResultData cardDefer(Long id,String tenantId,Date validEndDate);


boolean validCouponDate(WxCoupon wxCoupon);
ResultData validGiftCouponDate(WxCoupon wxCoupon);

/**
* 获取券商户map
*
*/
Map<Long,String> getCouponMerchantMap(List<Long> couponIds,TenantEntity tenantEntity,boolean onlyOneMerchantCoupons);

Map<Long, WxCoupon> getCouponMap(List<Long> couponIds, TenantEntity tenantEntity);

Map<String,List<WxMerchantVo>> getCouponMerchantList(TenantEntity tenantInfo, Long couponId);

/**
* 作废卷
* @param tenantInfo
* @param couponId
* @return
*/
ResultData disable(TenantEntity tenantInfo, Long couponId);
void setParentCouponMallMerchants(TenantEntity mallTenantEntity,WxCoupon wxCoupon) throws Exception;
Map<Long,Boolean> couponMerchantAutoShare(TenantEntity tenantEntity,WxCoupon wxCoupon) throws Exception;

/**
* 判断门店商户是否可用
* @param couponId
* @param couponType
* @param couponTenantEntity
* @return
*/
boolean isCouponMerchantValid(Long couponId,Integer couponType,TenantEntity couponTenantEntity);
}

+ 0
- 13
yqzjService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java 查看文件

@@ -48,9 +48,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
@Autowired
WxCouponMapper wxCouponMapper;

@Autowired
WxCouponService wxCouponService;

@Autowired
WxCouponMerchantMapper wxCouponMerchantMapper;

@@ -167,16 +164,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券状态不允许提交审核");
}

WxCoupon ttattrs = wxCouponService.getAttrsById(coupon.getId(), coupon.getTenantId());
if(ttattrs.getProductType() == null || ttattrs.getCategoryId() == null
|| ttattrs.getProductAttrKeyValueMap().isEmpty()
|| ttattrs.getSkuAttrKeyValueMap().isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券缺少必要属性");
}
if(coupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) {
return new ResultData(ErrorCode.COUPON_ORDER_IS_INVALID);
}


return new ResultData();


+ 1
- 61
yqzjService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java 查看文件

@@ -18,7 +18,6 @@ import com.iformall.mapper.WxQuestionOneselfMapper;
import com.iformall.service.QrCodeService;
import com.iformall.service.WxCampaignService;
import com.iformall.service.WxCouponChannelService;
import com.iformall.service.WxCouponService;
import com.iformall.utils.Constant;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -48,8 +47,6 @@ public class WxCampaignServiceImpl implements WxCampaignService {
@Autowired
WxCouponChannelMapper wxCouponChannelMapper;

@Autowired
WxCouponService wxCouponService;

@Autowired
QrCodeService qrCodeService;
@@ -277,64 +274,7 @@ public class WxCampaignServiceImpl implements WxCampaignService {

public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxCampaign record){

WxCoupon wxCoupon = wxCouponService.getById(couponId,record.getTenantId());
if (wxCoupon == null) {
return;
}
if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) {
return;
}
if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) {
return;
}

Date beginTime = null;
Date endTime = null;
if(wxCoupon.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())){
beginTime = wxCoupon.getValidStartDate();
}else{
beginTime = new Date();
}
endTime = wxCoupon.getValidEndDate();

// 已有的couponChannel, 更新
WxCouponChannel wxCouponChannel = wxCouponChannelsMap.get(couponId);
if (wxCouponChannel != null) {
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
wxCouponChannel.setBeginTime(beginTime);
wxCouponChannel.setEndTime(endTime);
wxCouponChannel.setUpdateDate(new Date());
wxCouponChannelMapper.updateById(wxCouponChannel);
wxCouponChannelsMap.remove(couponId);
} else {
WxCouponChannel wxCouponChannelQ = new WxCouponChannel();
wxCouponChannelQ.updateTenantInfo(wxCoupon);
wxCouponChannelQ.setCouponId(couponId);
wxCouponChannelQ.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode());
wxCouponChannelQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode());
List<WxCouponChannel> voList = wxCouponChannelMapper.newfindCList(wxCouponChannelQ);
// 不存在的, 新增
wxCouponChannel = new WxCouponChannel();
if(voList != null && voList.size() > 0){
wxCouponChannel.setShowBeginTime(voList.get(0).getShowBeginTime());
}
wxCouponChannel.setBeginTime(beginTime);
wxCouponChannel.setEndTime(endTime);
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
wxCouponChannel.setCouponId(couponId);
wxCouponChannel.setMakeMerchantId(wxCoupon.getMakeMerchantId());
wxCouponChannel.setType(wxCoupon.getType());
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode());
wxCouponChannel.updateTenantInfo(wxCoupon);
wxCouponChannel.setBusiness(wxCoupon.getBusiness());
wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness());
wxCouponChannel.setTitle(wxCoupon.getTitle());
wxCouponChannel.setSubTargetId(record.getId());
final IdWorker idWorker = IdWorker.get();
wxCouponChannel.setId(idWorker.nextId());
wxCouponChannelMapper.insert(wxCouponChannel);

}
}

@Override


+ 0
- 3
yqzjService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java 查看文件

@@ -89,8 +89,6 @@ public class WxFlowServiceImpl implements WxFlowService {
@Autowired
private WxCouponMapper wxCouponMapper;
@Autowired
private WxCouponService wxCouponService;
@Autowired
private WxRentContractMapper wxRentContractMapper;
@Autowired
private WxBillSettleMapper wxBillSettleMapper;
@@ -427,7 +425,6 @@ public class WxFlowServiceImpl implements WxFlowService {
wxCoupon.setType(type);
wxCoupon.setValidType(validType);
wxCoupon.updateTenantInfo(wxCoupon);
wxCouponService.updateCouponStockAndEndTime(wxCoupon);
}
}else if(EnumCouponAppType.CANCLE.getCode().equals(operateType)){
wxCoupon.setCancleApplyStatus(applyStatus);


正在加载...
取消
保存