| @@ -0,0 +1,148 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.ApiVersion; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.constant.SwaggerConstant; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.WxVtwoActivityCreditRule; | |||||
| import com.iformall.enums.EnumOfflineActivityAwardsMoneyRule; | |||||
| import com.iformall.enums.EnumOfflineActivityMerchantType; | |||||
| import com.iformall.enums.EnumOfflineActivityStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxVtwoActivitySpecialTopicService; | |||||
| import com.iformall.service.WxVtwoAmountGiftActivityService; | |||||
| 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.math.BigDecimal; | |||||
| /** | |||||
| * @author alascor | |||||
| * | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/specialTopic") | |||||
| @Api(description = "线下活动专题活动相关接口") | |||||
| public class WxVtwoActivitySpecialTopicController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxVtwoActivitySpecialTopicService wxVtwoActivitySpecialTopicService; | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @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 WxVtwoActivitySpecialTopic specialTopic, Integer pageNum, Integer pageSize) { | |||||
| if (null == specialTopic) specialTopic = new WxVtwoActivitySpecialTopic(); | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| specialTopic.updateTenantInfo(tenantInfo); | |||||
| specialTopic.setSortColumns(SortField.CreateDate_DESC); | |||||
| final PageInfo<WxVtwoActivitySpecialTopic> page = wxVtwoActivitySpecialTopicService.listAsPage(specialTopic, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("判断积分按钮状态") | |||||
| @PostMapping("getCreditStatus") | |||||
| public ResultData getCreditStatus(@RequestBody WxVtwoActivitySpecialTopic specialTopic) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| specialTopic.updateTenantInfo(tenantEntity); | |||||
| if(specialTopic.getStartTime() == null || specialTopic.getEndTime() == null){ | |||||
| return new ResultData(Result.ERROR,"活动时间为空"); | |||||
| } | |||||
| if(wxVtwoActivitySpecialTopicService.selectCreditCount(specialTopic) > 0){ | |||||
| return new ResultData(false); | |||||
| } | |||||
| return new ResultData(true); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("新增修改接口") | |||||
| @PostMapping("saveOrUpdate") | |||||
| public ResultData saveOrUpdate(@RequestBody WxVtwoActivitySpecialTopic specialTopic) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| specialTopic.updateTenantInfo(tenantEntity); | |||||
| if(specialTopic.getStartTime() == null || specialTopic.getEndTime() == null){ | |||||
| return new ResultData(Result.ERROR,"活动时间为空"); | |||||
| } | |||||
| if(specialTopic.getCreditOnOff() == null){ | |||||
| specialTopic.setCreditOnOff(EnumYesOrNo.NO.getCode()); | |||||
| } | |||||
| if(EnumYesOrNo.YES.getCode().equals(specialTopic.getCreditOnOff())){ | |||||
| WxVtwoActivityCreditRule creditConfigObject = specialTopic.getCreditConfigObject(); | |||||
| if(creditConfigObject == null){ | |||||
| return new ResultData(Result.ERROR,"积分配置错误"); | |||||
| } | |||||
| if(creditConfigObject.getStep().compareTo(BigDecimal.ZERO) <= 0 | |||||
| || creditConfigObject.getScore() <= 0){ | |||||
| return new ResultData(Result.ERROR,"积分配置不能为0"); | |||||
| } | |||||
| if(wxVtwoActivitySpecialTopicService.selectCreditCount(specialTopic) > 0){ | |||||
| return new ResultData(Result.ERROR,"活动时间内存在积分开启的活动"); | |||||
| } | |||||
| }else{ | |||||
| specialTopic.setCreditConfig("{}"); | |||||
| } | |||||
| if(specialTopic.getActivityList() == null || specialTopic.getActivityList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"包含活动不能为空"); | |||||
| } | |||||
| wxVtwoActivitySpecialTopicService.saveOrUpdate(specialTopic); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("上架") | |||||
| @PostMapping("online") | |||||
| public ResultData online(@RequestBody WxVtwoActivitySpecialTopic specialTopic) { | |||||
| if(specialTopic.getId() == null){ | |||||
| return new ResultData(Result.ERROR,"ID为空"); | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| specialTopic.updateTenantInfo(tenantEntity); | |||||
| specialTopic.setStatus(EnumOfflineActivityStatus.ON_LINE.getCode()); | |||||
| wxVtwoActivitySpecialTopicService.updateById(specialTopic); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("下架") | |||||
| @PostMapping("offline") | |||||
| public ResultData offline(@RequestBody WxVtwoActivitySpecialTopic specialTopic) { | |||||
| if(specialTopic.getId() == null){ | |||||
| return new ResultData(Result.ERROR,"ID为空"); | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| specialTopic.updateTenantInfo(tenantEntity); | |||||
| specialTopic.setStatus(EnumOfflineActivityStatus.OFF_LINE.getCode()); | |||||
| wxVtwoActivitySpecialTopicService.updateById(specialTopic); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("查询详情") | |||||
| @GetMapping("getInfoById") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData getInfoById(Long id) { | |||||
| TenantEntity tenantInfo = getTenantInfo(); | |||||
| WxVtwoActivitySpecialTopic specialTopic = wxVtwoActivitySpecialTopicService.getInfoById(id, tenantInfo.getTenantId()); | |||||
| return new ResultData(specialTopic); | |||||
| } | |||||
| } | |||||
| @@ -1,11 +1,16 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.IdType; | import com.baomidou.mybatisplus.annotation.IdType; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import com.iformall.domain.vo.WxVtwoActivityCreditRule; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| /** | /** | ||||
| @@ -47,10 +52,17 @@ public class WxVtwoActivitySpecialTopic extends TenantEntity { | |||||
| /** | /** | ||||
| * 积分配置 | * 积分配置 | ||||
| * | |||||
| * "step":, | |||||
| * "score": | |||||
| * | |||||
| */ | */ | ||||
| @TableField(value = "credit_config") | @TableField(value = "credit_config") | ||||
| private String creditConfig; | private String creditConfig; | ||||
| @TableField(exist = false) | |||||
| private WxVtwoActivityCreditRule creditConfigObject; | |||||
| /** | /** | ||||
| * 状态 | * 状态 | ||||
| */ | */ | ||||
| @@ -68,4 +80,20 @@ public class WxVtwoActivitySpecialTopic extends TenantEntity { | |||||
| */ | */ | ||||
| @TableField(value = "update_date") | @TableField(value = "update_date") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @TableField(exist = false) | |||||
| private List<WxVtwoSpecialTopicActivity> activityList; | |||||
| @TableField(exist = false) | |||||
| private Date begin; | |||||
| @TableField(exist = false) | |||||
| private Date end; | |||||
| /** | |||||
| * 是否过期 | |||||
| */ | |||||
| @TableField(exist = false) | |||||
| private Integer validStatus; | |||||
| @TableField(exist = false) | |||||
| private Integer activityCount; | |||||
| } | } | ||||
| @@ -0,0 +1,27 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| import java.io.Serializable; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.List; | |||||
| /** | |||||
| * 线下活动中奖规则 | |||||
| */ | |||||
| @Data | |||||
| public class WxVtwoActivityCreditRule implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| /** | |||||
| * 金额 | |||||
| */ | |||||
| private BigDecimal step; | |||||
| /** | |||||
| * 积分 | |||||
| */ | |||||
| private Integer score; | |||||
| } | |||||
| @@ -3,6 +3,9 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import io.lettuce.core.dynamic.annotation.Param; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| @@ -12,6 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
| */ | */ | ||||
| public interface WxVtwoActivitySpecialTopicMapper extends CommonMapper<WxVtwoActivitySpecialTopic, Long> { | public interface WxVtwoActivitySpecialTopicMapper extends CommonMapper<WxVtwoActivitySpecialTopic, Long> { | ||||
| List<WxVtwoActivitySpecialTopic> findList(WxVtwoActivitySpecialTopic specialTopic); | |||||
| int selectCreditCount(WxVtwoActivitySpecialTopic specialTopic); | |||||
| WxVtwoActivitySpecialTopic selectById(@Param("id") Long id, @Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -3,6 +3,9 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| @@ -12,6 +15,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
| */ | */ | ||||
| public interface WxVtwoSpecialTopicActivityMapper extends CommonMapper<WxVtwoSpecialTopicActivity, Long> { | public interface WxVtwoSpecialTopicActivityMapper extends CommonMapper<WxVtwoSpecialTopicActivity, Long> { | ||||
| void insertList(@Param("activityList") List<WxVtwoSpecialTopicActivity> activityList); | |||||
| List<WxVtwoSpecialTopicActivity> findList(WxVtwoSpecialTopicActivity specialTopicActivity); | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| @@ -10,4 +11,9 @@ import com.baomidou.mybatisplus.extension.service.IService; | |||||
| */ | */ | ||||
| public interface WxVtwoActivitySpecialTopicService extends IService<WxVtwoActivitySpecialTopic> { | public interface WxVtwoActivitySpecialTopicService extends IService<WxVtwoActivitySpecialTopic> { | ||||
| PageInfo<WxVtwoActivitySpecialTopic> listAsPage(WxVtwoActivitySpecialTopic specialTopic, Integer pageNum, Integer pageSize); | |||||
| int selectCreditCount(WxVtwoActivitySpecialTopic specialTopic); | |||||
| WxVtwoActivitySpecialTopic getInfoById(Long id, String tenantId); | |||||
| } | } | ||||
| @@ -1,7 +1,11 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | |||||
| import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| @@ -10,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService; | |||||
| */ | */ | ||||
| public interface WxVtwoSpecialTopicActivityService extends IService<WxVtwoSpecialTopicActivity> { | public interface WxVtwoSpecialTopicActivityService extends IService<WxVtwoSpecialTopicActivity> { | ||||
| void saveFromSpecialTopic(TenantEntity tenantEntity, Long specialTopicId, List<WxVtwoSpecialTopicActivity> activityList); | |||||
| } | } | ||||
| @@ -1,10 +1,31 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import com.iformall.domain.po.WxVtwoActivitySpecialTopic; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.vo.WxVtwoActivityCreditRule; | |||||
| import com.iformall.domain.vo.WxVtwoActivityOrderStatistics; | |||||
| import com.iformall.domain.vo.WxVtwoActivityRule; | |||||
| import com.iformall.domain.vo.WxVtwoActivityRuleDetail; | |||||
| import com.iformall.enums.EnumOfflineActivityMerchantType; | |||||
| import com.iformall.enums.EnumOfflineActivityRecordStatus; | |||||
| import com.iformall.enums.EnumOfflineActivityStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.mapper.WxVtwoSpecialTopicActivityMapper; | |||||
| import com.iformall.service.WxVtwoActivitySpecialTopicService; | import com.iformall.service.WxVtwoActivitySpecialTopicService; | ||||
| import com.iformall.mapper.WxVtwoActivitySpecialTopicMapper; | import com.iformall.mapper.WxVtwoActivitySpecialTopicMapper; | ||||
| import com.iformall.service.WxVtwoSpecialTopicActivityService; | |||||
| import jodd.util.StringUtil; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| @@ -15,6 +36,106 @@ import org.springframework.stereotype.Service; | |||||
| public class WxVtwoActivitySpecialTopicServiceImpl extends ServiceImpl<WxVtwoActivitySpecialTopicMapper, WxVtwoActivitySpecialTopic> | public class WxVtwoActivitySpecialTopicServiceImpl extends ServiceImpl<WxVtwoActivitySpecialTopicMapper, WxVtwoActivitySpecialTopic> | ||||
| implements WxVtwoActivitySpecialTopicService{ | implements WxVtwoActivitySpecialTopicService{ | ||||
| @Autowired | |||||
| private WxVtwoActivitySpecialTopicMapper wxVtwoActivitySpecialTopicMapper; | |||||
| @Autowired | |||||
| private WxVtwoSpecialTopicActivityMapper wxVtwoSpecialTopicActivityMapper; | |||||
| @Autowired | |||||
| private WxVtwoSpecialTopicActivityService wxVtwoSpecialTopicActivityService; | |||||
| @Override | |||||
| public PageInfo<WxVtwoActivitySpecialTopic> listAsPage(WxVtwoActivitySpecialTopic specialTopic, Integer pageNum, Integer pageSize) { | |||||
| handlerQuery(specialTopic); | |||||
| PageInfo<WxVtwoActivitySpecialTopic> activityPageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxVtwoActivitySpecialTopicMapper.findList(specialTopic)); | |||||
| handlerReturnList(activityPageInfo.getList()); | |||||
| return activityPageInfo; | |||||
| } | |||||
| private void handlerQuery(WxVtwoActivitySpecialTopic specialTopic) { | |||||
| if (null != specialTopic.getStatus()) { | |||||
| //已上架 | |||||
| if(EnumOfflineActivityStatus.ON_LINE.getCode().equals(specialTopic.getStatus())){ | |||||
| specialTopic.setValidStatus(EnumYesOrNo.NO.getCode()); | |||||
| } | |||||
| //已过期 | |||||
| else if(EnumOfflineActivityStatus.EXPIRE.getCode().equals(specialTopic.getStatus())){ | |||||
| specialTopic.setStatus(null); | |||||
| specialTopic.setValidStatus(EnumYesOrNo.YES.getCode()); | |||||
| } | |||||
| } | |||||
| } | |||||
| private void handlerReturnList(List<WxVtwoActivitySpecialTopic> list) { | |||||
| if (null != list && !list.isEmpty()) { | |||||
| Date now = new Date(); | |||||
| for (WxVtwoActivitySpecialTopic specialTopic : list) { | |||||
| if(now.after(specialTopic.getEndTime())){ | |||||
| specialTopic.setStatus(EnumOfflineActivityStatus.EXPIRE.getCode()); | |||||
| } | |||||
| WxVtwoSpecialTopicActivity specialTopicActivityQ = new WxVtwoSpecialTopicActivity(); | |||||
| specialTopicActivityQ.updateTenantInfo(specialTopic); | |||||
| specialTopicActivityQ.setSpecialTopicId(specialTopic.getId()); | |||||
| Integer activityCount = wxVtwoSpecialTopicActivityMapper.selectCount(new QueryWrapper<>(specialTopicActivityQ)); | |||||
| specialTopic.setActivityCount(activityCount); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public int selectCreditCount(WxVtwoActivitySpecialTopic specialTopic) { | |||||
| specialTopic.setCreditOnOff(EnumYesOrNo.YES.getCode()); | |||||
| return wxVtwoActivitySpecialTopicMapper.selectCreditCount(specialTopic); | |||||
| } | |||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public boolean saveOrUpdate(WxVtwoActivitySpecialTopic specialTopic) { | |||||
| handlerActivityRules(specialTopic); | |||||
| Date now = new Date(); | |||||
| if(specialTopic.getId() == null){ | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| specialTopic.setId(idWorker.nextId()); | |||||
| specialTopic.setCreateDate(now); | |||||
| specialTopic.setCreateDate(now); | |||||
| specialTopic.setStatus(EnumOfflineActivityStatus.OFF_LINE.getCode()); | |||||
| wxVtwoActivitySpecialTopicMapper.insert(specialTopic); | |||||
| } | |||||
| else{ | |||||
| specialTopic.setUpdateDate(now); | |||||
| wxVtwoActivitySpecialTopicMapper.updateById(specialTopic); | |||||
| } | |||||
| if(specialTopic.getActivityList() != null && !specialTopic.getActivityList().isEmpty()){ | |||||
| wxVtwoSpecialTopicActivityService.saveFromSpecialTopic(specialTopic,specialTopic.getId(),specialTopic.getActivityList()); | |||||
| } | |||||
| return true; | |||||
| } | |||||
| private void handlerActivityRules(WxVtwoActivitySpecialTopic specialTopic) { | |||||
| if(specialTopic.getCreditConfigObject() != null){ | |||||
| specialTopic.setCreditConfig(JSONObject.toJSONString(specialTopic.getCreditConfigObject())); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public WxVtwoActivitySpecialTopic getInfoById(Long id, String tenantId) { | |||||
| WxVtwoActivitySpecialTopic specialTopic = wxVtwoActivitySpecialTopicMapper.selectById(id, tenantId); | |||||
| if (specialTopic == null) { | |||||
| return null; | |||||
| } | |||||
| if(StringUtil.isNotBlank(specialTopic.getCreditConfig())){ | |||||
| specialTopic.setCreditConfigObject(JSONObject.parseObject(specialTopic.getCreditConfig(), WxVtwoActivityCreditRule.class)); | |||||
| } | |||||
| WxVtwoSpecialTopicActivity specialTopicActivityQ = new WxVtwoSpecialTopicActivity(); | |||||
| specialTopicActivityQ.setTenantId(tenantId); | |||||
| specialTopicActivityQ.setSpecialTopicId(id); | |||||
| List<WxVtwoSpecialTopicActivity> activityList = wxVtwoSpecialTopicActivityMapper.findList(specialTopicActivityQ); | |||||
| specialTopic.setActivityList(activityList); | |||||
| return specialTopic; | |||||
| } | |||||
| } | } | ||||
| @@ -1,11 +1,19 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxVtwoActivityAward; | |||||
| import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.service.WxVtwoSpecialTopicActivityService; | import com.iformall.service.WxVtwoSpecialTopicActivityService; | ||||
| import com.iformall.mapper.WxVtwoSpecialTopicActivityMapper; | import com.iformall.mapper.WxVtwoSpecialTopicActivityMapper; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| * @description 针对表【wx_vtwo_special_topic_activity(线下专题下的活动)】的数据库操作Service实现 | * @description 针对表【wx_vtwo_special_topic_activity(线下专题下的活动)】的数据库操作Service实现 | ||||
| @@ -15,6 +23,31 @@ import org.springframework.stereotype.Service; | |||||
| public class WxVtwoSpecialTopicActivityServiceImpl extends ServiceImpl<WxVtwoSpecialTopicActivityMapper, WxVtwoSpecialTopicActivity> | public class WxVtwoSpecialTopicActivityServiceImpl extends ServiceImpl<WxVtwoSpecialTopicActivityMapper, WxVtwoSpecialTopicActivity> | ||||
| implements WxVtwoSpecialTopicActivityService{ | implements WxVtwoSpecialTopicActivityService{ | ||||
| @Autowired | |||||
| private WxVtwoSpecialTopicActivityMapper wxVtwoSpecialTopicActivityMapper; | |||||
| @Override | |||||
| public void saveFromSpecialTopic(TenantEntity tenantEntity, Long specialTopicId, List<WxVtwoSpecialTopicActivity> activityList) { | |||||
| WxVtwoSpecialTopicActivity specialTopicActivityQ = new WxVtwoSpecialTopicActivity(); | |||||
| specialTopicActivityQ.updateTenantInfo(tenantEntity); | |||||
| specialTopicActivityQ.setSpecialTopicId(specialTopicId); | |||||
| wxVtwoSpecialTopicActivityMapper.delete(new QueryWrapper<>(specialTopicActivityQ)); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| Date now = new Date(); | |||||
| for (WxVtwoSpecialTopicActivity specialTopicActivity : activityList) { | |||||
| if(specialTopicActivity.getId() == null){ | |||||
| specialTopicActivity.setId(idWorker.nextId()); | |||||
| } | |||||
| specialTopicActivity.updateTenantInfo(tenantEntity); | |||||
| specialTopicActivity.setSpecialTopicId(specialTopicId); | |||||
| if(specialTopicActivity.getCreateDate() == null){ | |||||
| specialTopicActivity.setCreateDate(now); | |||||
| } | |||||
| specialTopicActivity.setUpdateDate(now); | |||||
| } | |||||
| wxVtwoSpecialTopicActivityMapper.insertList(activityList); | |||||
| } | |||||
| } | } | ||||
| @@ -54,6 +54,14 @@ | |||||
| and `credit_on_off` = #{creditOnOff} | and `credit_on_off` = #{creditOnOff} | ||||
| </if> | </if> | ||||
| <!-- 未过期 --> | |||||
| <if test=" 0 == validStatus"> | |||||
| and end_time >= now() | |||||
| </if> | |||||
| <!-- 已过期 --> | |||||
| <if test=" 1 == validStatus"> | |||||
| and end_time <= now() | |||||
| </if> | |||||
| <if test=" null != status "> | <if test=" null != status "> | ||||
| and `status` = #{status} | and `status` = #{status} | ||||
| </if> | </if> | ||||
| @@ -76,4 +84,28 @@ | |||||
| select <include refid="allColumns" /> from wx_vtwo_activity_special_topic | select <include refid="allColumns" /> from wx_vtwo_activity_special_topic | ||||
| where id = #{id} and tenant_id=#{tenantId} | where id = #{id} and tenant_id=#{tenantId} | ||||
| </select> | </select> | ||||
| <select id="selectCreditCount" parameterType="com.iformall.domain.po.WxVtwoActivitySpecialTopic" resultType="integer"> | |||||
| select count(1) from wx_vtwo_activity_special_topic | |||||
| where credit_on_off = #{creditOnOff} | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != id"> | |||||
| and `id` != #{id} | |||||
| </if> | |||||
| and ((`start_time` <= #{startTime} and `end_time` >= #{startTime}) | |||||
| or (`start_time` <= #{endTime} and `end_time` >= #{endTime})) | |||||
| </select> | |||||
| <select id="selectCreditOne" parameterType="java.util.HashMap" resultType="com.iformall.domain.po.WxOfflineActivity"> | |||||
| select <include refid="allColumns" /> from wx_vtwo_activity_special_topic | |||||
| where `tenant_id` = #{tenantId} | |||||
| and credit_on_off = #{creditOnOff} | |||||
| and `start_time` <= #{orderDate} | |||||
| and `end_time` >= #{orderDate} | |||||
| limit 1 | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -54,4 +54,21 @@ | |||||
| select <include refid="allColumns" /> from wx_vtwo_special_topic_activity | select <include refid="allColumns" /> from wx_vtwo_special_topic_activity | ||||
| where id = #{id} and tenant_id=#{tenantId} | where id = #{id} and tenant_id=#{tenantId} | ||||
| </select> | </select> | ||||
| <insert id="insertList" parameterType="java.util.List"> | |||||
| insert into wx_vtwo_activity_award | |||||
| (id, | |||||
| special_topic_id,activity_id,activity_type, | |||||
| activity_name,activity_create_date,activity_start_time, | |||||
| activity_end_time,activity_status,create_date, | |||||
| update_date) | |||||
| values | |||||
| <foreach collection="awardList" item="item" index="index" separator=","> | |||||
| (#{item.id,jdbcType=BIGINT}, | |||||
| #{item.specialTopicId,jdbcType=BIGINT},#{item.activityId,jdbcType=BIGINT},#{item.activityType,jdbcType=SMALLINT}, | |||||
| #{item.activityName,jdbcType=VARCHAR},#{item.activityCreateDate,jdbcType=TIMESTAMP},#{item.activityStartTime,jdbcType=TIMESTAMP}, | |||||
| #{item.activityEndTime,jdbcType=TIMESTAMP},#{item.activityStatus,jdbcType=SMALLINT},#{item.createDate,jdbcType=TIMESTAMP}, | |||||
| #{item.updateDate,jdbcType=TIMESTAMP}) | |||||
| </foreach> | |||||
| </insert> | |||||
| </mapper> | </mapper> | ||||