| @@ -0,0 +1,61 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponSendConfig; | |||
| import com.iformall.service.WxCouponSendConfigService; | |||
| import io.swagger.annotations.Api; | |||
| 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; | |||
| @RestController | |||
| @RequestMapping("wxCouponSendConfig") | |||
| @Api(description = "停车发券和核销发劵接口") | |||
| public class WxCouponSendConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponSendConfigService wxCouponSendConfigService; | |||
| @ApiOperation("获取开关") | |||
| @GetMapping("getCouponSendConfig") | |||
| public ResultData getCouponSendConfig(@RequestAttribute WxCouponSendConfig wxCouponSendConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getCouponSendConfig"); | |||
| if (wxCouponSendConfig == null || wxCouponSendConfig.getSendType() != null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| wxCouponSendConfig.setTenantId(getTenantId()); | |||
| PageInfo<WxCouponSendConfig> page = wxCouponSendConfigService.listAsPage(wxCouponSendConfig, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| return new ResultData(page.getList().get(0)); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("updateCouponSendConfig") | |||
| @ApiOperation("修改开关") | |||
| public ResultData updateCouponSendConfig(@RequestBody WxCouponSendConfig wxCouponSendConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateStopCarConpon"); | |||
| if (wxCouponSendConfig == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxCouponSendConfig.getSendType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxCouponSendConfig.getValue() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| wxCouponSendConfig.setTenantId(getTenantId()); | |||
| wxCouponSendConfig.setUpdateTime(new Date()); | |||
| wxCouponSendConfigService.update(wxCouponSendConfig); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1,148 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMallConfig; | |||
| import com.iformall.service.WxMallConfigService; | |||
| import io.swagger.annotations.Api; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMallConfig") | |||
| @Api(description = "停车发券和核销发劵接口") | |||
| public class WxMallConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallConfigService wxMallConfigService; | |||
| @ApiOperation("获取停车劵开关") | |||
| @GetMapping("getStopCarCoupon") | |||
| public ResultData getStopCarConpon() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getStopCarConpon"); | |||
| WxMallConfig wxMallConfig = new WxMallConfig(); | |||
| wxMallConfig.setKey("stopCarCouponSwitch"); | |||
| wxMallConfig.setTenantId(getTenantId()); | |||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| WxMallConfig config = page.getList().get(0); | |||
| return new ResultData(config); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("获取核销劵开关") | |||
| @GetMapping("getVerifyCoupon") | |||
| public ResultData getVerifyConpon() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getVerifyConpon"); | |||
| WxMallConfig wxMallConfig = new WxMallConfig(); | |||
| wxMallConfig.setKey("verifyCouponSwitch"); | |||
| wxMallConfig.setTenantId(getTenantId()); | |||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| WxMallConfig config = page.getList().get(0); | |||
| return new ResultData(config); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("获取B端刷卡支付发劵开关") | |||
| @GetMapping("getMicroPayCouponSwitch") | |||
| public ResultData getMicroPayConpon() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getMicroPayConpon"); | |||
| WxMallConfig wxMallConfig = new WxMallConfig(); | |||
| wxMallConfig.setKey("microPayCouponSwitch"); | |||
| wxMallConfig.setTenantId(getTenantId()); | |||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| WxMallConfig config = page.getList().get(0); | |||
| return new ResultData(config); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("updateStopCarCoupon") | |||
| @ApiOperation("修改停车发券开关") | |||
| public ResultData updateStopCarConpon(@RequestBody WxMallConfig wxMallConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateStopCarConpon"); | |||
| WxMallConfig temp = new WxMallConfig(); | |||
| // temp.setKey("stopCarCouponSwitch"); | |||
| temp.setValue(wxMallConfig.getValue()); | |||
| temp.setId(wxMallConfig.getId()); | |||
| wxMallConfigService.saveOrUpdate(temp); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("updateVerifyCoupon") | |||
| @ApiOperation("修改核销发券开关") | |||
| public ResultData updateVerifyConpon(@RequestBody WxMallConfig wxMallConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateVerifyConpon"); | |||
| WxMallConfig temp = new WxMallConfig(); | |||
| // temp.setKey("verifyCouponSwitch"); | |||
| temp.setValue(wxMallConfig.getValue()); | |||
| temp.setId(wxMallConfig.getId()); | |||
| wxMallConfigService.saveOrUpdate(temp); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("updateMicroPayCouponSwitch") | |||
| @ApiOperation("修改刷卡支付发券开关") | |||
| public ResultData updateMicroPayCoupon(@RequestBody WxMallConfig wxMallConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateMicroPayCoupon"); | |||
| WxMallConfig temp = new WxMallConfig(); | |||
| // temp.setKey("verifyCouponSwitch"); | |||
| temp.setValue(wxMallConfig.getValue()); | |||
| temp.setId(wxMallConfig.getId()); | |||
| wxMallConfigService.saveOrUpdate(temp); | |||
| return new ResultData(); | |||
| } | |||
| // @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 WxMallConfig wxMallConfig,Integer pageNum, Integer pageSize) { | |||
| // if (null == wxMallConfig) wxMallConfig = new WxMallConfig(); | |||
| // final PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfig, pageNum, pageSize); | |||
| // return new ResultData(page); | |||
| // } | |||
| // | |||
| // @ApiOperation("新增接口") | |||
| // @PostMapping("add") | |||
| // public ResultData add(@RequestBody WxMallConfig wxMallConfig) { | |||
| // //Assert.notNull(wxMallConfig.getName(), "角色名不能为空"); | |||
| // //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| // wxMallConfigService.saveOrUpdate(wxMallConfig); | |||
| // return new ResultData(); | |||
| // } | |||
| // | |||
| // @ApiOperation("根据id更新接口") | |||
| // @PostMapping("update") | |||
| // public ResultData update(@RequestBody WxMallConfig wxMallConfig) { | |||
| // wxMallConfigService.saveOrUpdate(wxMallConfig); | |||
| // return new ResultData(); | |||
| // } | |||
| // | |||
| // @ApiOperation("根据id删除接口") | |||
| // @GetMapping("/del") | |||
| // @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| // public ResultData delete(Long id) { | |||
| // wxMallConfigService.deleteById(id); | |||
| // return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| // } | |||
| // | |||
| // @ApiOperation("根据id查询接口") | |||
| // @GetMapping("/findById") | |||
| // @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| // public ResultData findById(Long id) { | |||
| // return new ResultData(Result.SUCCESS,"查询成功",wxMallConfigService.getById(id)); | |||
| // } | |||
| } | |||
| @@ -54,6 +54,9 @@ public class WxCouponSend implements Serializable { | |||
| /*发券方式(1.主动领取,2.停车发券,3.核销发券)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="sendType") | |||
| private Integer sendType; | |||
| /*发券条件**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="发券条件",name="condition") | |||
| private String condition; | |||
| /*0:有效 1:无效**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="0:有效 1:无效",name="status") | |||
| private Integer status; | |||
| @@ -94,6 +97,15 @@ public class WxCouponSend implements Serializable { | |||
| public void setSendType(Integer _sendType) { | |||
| sendType = _sendType; | |||
| } | |||
| public String getCondition() { | |||
| return condition; | |||
| } | |||
| public void setCondition(String condition) { | |||
| this.condition = condition; | |||
| } | |||
| public Integer getStatus() { | |||
| return status; | |||
| } | |||
| @@ -8,7 +8,7 @@ import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_mall_config") | |||
| public class WxMallConfig implements Serializable { | |||
| public class WxCouponSendConfig implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| @@ -38,15 +38,13 @@ public class WxMallConfig implements Serializable { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*租户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") | |||
| private String tenantId; | |||
| /*配置**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="配置",name="key") | |||
| private String key; | |||
| @io.swagger.annotations.ApiModelProperty(value="配置",name="sendType") | |||
| private Integer sendType; | |||
| /*0:启用 1:停用**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="0:启用 1:停用",name="value") | |||
| private Integer value; | |||
| @@ -65,11 +63,11 @@ public class WxMallConfig implements Serializable { | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public String getKey() { | |||
| return key; | |||
| public Integer getSendType() { | |||
| return sendType; | |||
| } | |||
| public void setKey(String _key) { | |||
| key = _key; | |||
| public void setSendType(Integer _sendType) { | |||
| sendType = _sendType; | |||
| } | |||
| public Integer getValue() { | |||
| return value; | |||
| @@ -102,11 +100,11 @@ public class WxMallConfig implements Serializable { | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,Key_ASC("`key` ASC"),Key_DESC("`key` DESC") | |||
| ,SendType_ASC("`send_type` ASC"),SendType_DESC("`send_type` DESC") | |||
| ,Value_ASC("`value` ASC"),Value_DESC("`value` DESC") | |||
| ,Remark_ASC("`remark` ASC"),Remark_DESC("`remark` DESC") | |||
| ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") | |||
| ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") | |||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||
| ,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -124,7 +122,7 @@ public class WxMallConfig implements Serializable { | |||
| } | |||
| } | |||
| public void setSortColumns(WxMallConfig.Field... fields) | |||
| public void setSortColumns(WxCouponSendConfig.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| @@ -0,0 +1,16 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCouponSendConfig; | |||
| public interface WxCouponSendConfigMapper extends CommonMapper<WxCouponSendConfig, Long> { | |||
| List<WxCouponSendConfig> findList(WxCouponSendConfig wxMallConfig); | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxMallConfig; | |||
| public interface WxMallConfigMapper extends CommonMapper<WxMallConfig, Long> { | |||
| List<WxMallConfig> findList(WxMallConfig wxMallConfig); | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxCouponSendConfig; | |||
| public interface WxCouponSendConfigService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxCouponSendConfig> listAsPage(WxCouponSendConfig record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void update(WxCouponSendConfig record); | |||
| } | |||
| @@ -1,47 +0,0 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxMallConfig; | |||
| public interface WxMallConfigService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxMallConfig> listAsPage(WxMallConfig record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxMallConfig getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxMallConfig record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -0,0 +1,40 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxCouponSendConfig; | |||
| import com.iformall.mapper.WxCouponSendConfigMapper; | |||
| import com.iformall.service.WxCouponSendConfigService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| @Service | |||
| public class WxCouponSendConfigServiceImpl implements WxCouponSendConfigService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCouponSendConfigMapper wxMallConfigMapper; | |||
| @Override | |||
| public PageInfo<WxCouponSendConfig> listAsPage(WxCouponSendConfig record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallConfigMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void update(WxCouponSendConfig record) { | |||
| wxMallConfigMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCouponOrderMapper; | |||
| import com.iformall.mapper.WxCouponSendConfigMapper; | |||
| import com.iformall.mapper.WxCouponSendMapper; | |||
| import com.iformall.service.*; | |||
| import org.slf4j.Logger; | |||
| @@ -31,14 +32,11 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| @Autowired | |||
| WxCouponActionLogService wxCouponActionLogService; | |||
| @Autowired | |||
| WxMallConfigService wxMallConfigService; | |||
| WxCouponSendConfigMapper wxCouponSendConfigMapper; | |||
| @Autowired | |||
| WxOrderService wxOrderService; | |||
| @Autowired | |||
| WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Autowired | |||
| PushLimitService pushLimitService; | |||
| @@ -74,38 +72,16 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| @Transactional | |||
| public boolean sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type) { | |||
| //查询开关是否打开 | |||
| //查询停车或者核销的券 stopCarCouponSwitch, verifyCouponSwitch, microPayCouponSwitch | |||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | |||
| wxCouponSendQuery.setTenantId(tenantId); | |||
| wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| int actionType = EnumCouponSendSendType.UNKNOWN.getCode(); | |||
| String configKey = ""; | |||
| if (type == EnumCouponSendSendType.CAR_STOP) { | |||
| //停车 | |||
| actionType = EnumCouponSendSendType.CAR_STOP.getCode(); | |||
| wxCouponSendQuery.setSendType(actionType); | |||
| configKey = "stopCarCouponSwitch"; | |||
| } else if (type == EnumCouponSendSendType.COUPON_VERIFY) { | |||
| //核销 | |||
| actionType = EnumCouponSendSendType.COUPON_VERIFY.getCode(); | |||
| wxCouponSendQuery.setSendType(actionType); | |||
| configKey = "verifyCouponSwitch"; | |||
| } else if (type == EnumCouponSendSendType.B_MICROPAY) { | |||
| //B端刷卡发券 | |||
| actionType = EnumCouponSendSendType.B_MICROPAY.getCode(); | |||
| wxCouponSendQuery.setSendType(actionType); | |||
| configKey = "microPayCouponSwitch"; | |||
| }else { | |||
| return false; | |||
| } | |||
| WxMallConfig wxMallConfigQuery = new WxMallConfig(); | |||
| wxMallConfigQuery.setKey(configKey); | |||
| wxMallConfigQuery.setTenantId(tenantId); | |||
| PageInfo<WxMallConfig> page = wxMallConfigService.listAsPage(wxMallConfigQuery, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| WxMallConfig config = page.getList().get(0); | |||
| WxCouponSendConfig wxCouponSendConfig = new WxCouponSendConfig(); | |||
| wxCouponSendConfig.setSendType(type.getCode()); | |||
| wxCouponSendConfig.setTenantId(tenantId); | |||
| List<WxCouponSendConfig> configList = wxCouponSendConfigMapper.findList(wxCouponSendConfig); | |||
| if (configList.size() > 0) { | |||
| WxCouponSendConfig config = configList.get(0); | |||
| if (config.getValue() == EnumEnableType.Disable.getCode()) { | |||
| logger.info(configKey + ": disabled "); | |||
| logger.info(config.getSendType() + ": disabled "); | |||
| return false; | |||
| } | |||
| } | |||
| @@ -113,6 +89,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| boolean checkTime = false; | |||
| try { | |||
| checkTime = pushLimitService.checkSendTime(tenantId); | |||
| if (!checkTime) | |||
| return false; | |||
| } catch (MallinkException e) { | |||
| logger.error("push limit check time :" + e.getMessage()); | |||
| return false; | |||
| @@ -120,28 +98,31 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| boolean bRet = false; | |||
| if (checkTime) { | |||
| List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery); | |||
| for (WxCouponSend send : wxCouponSends) { | |||
| boolean checkLimit = false; | |||
| // 检查疲劳度 | |||
| try { | |||
| checkLimit = pushLimitService.checkCoupon(tenantId, cUserId, send.getCouponId()); | |||
| } catch (MallinkException e) { | |||
| logger.error("券达到limit: " + e.getMessage()); | |||
| } | |||
| if (!checkLimit) { | |||
| continue; | |||
| } | |||
| // 发放免费券 | |||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); | |||
| if (couponOrder != null) { | |||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), actionType, send.getId()); | |||
| bRet = true; | |||
| } | |||
| wxCouponService.reduceInventory(send.getCouponId(), 1); | |||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | |||
| wxCouponSendQuery.setTenantId(tenantId); | |||
| wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery); | |||
| for (WxCouponSend send : wxCouponSends) { | |||
| boolean checkLimit = false; | |||
| // 检查疲劳度 | |||
| try { | |||
| checkLimit = pushLimitService.checkCoupon(tenantId, cUserId, send.getCouponId()); | |||
| } catch (MallinkException e) { | |||
| logger.error("券达到limit: " + e.getMessage()); | |||
| } | |||
| if (!checkLimit) { | |||
| continue; | |||
| } | |||
| // 发放免费券 | |||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); | |||
| if (couponOrder != null) { | |||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); | |||
| bRet = true; | |||
| } | |||
| wxCouponService.reduceInventory(send.getCouponId(), 1); | |||
| } | |||
| return bRet; | |||
| } | |||
| @@ -1,56 +0,0 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxMallConfig; | |||
| import com.iformall.mapper.WxMallConfigMapper; | |||
| import com.iformall.service.WxMallConfigService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| @Service | |||
| public class WxMallConfigServiceImpl implements WxMallConfigService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMallConfigMapper wxMallConfigMapper; | |||
| @Override | |||
| public PageInfo<WxMallConfig> listAsPage(WxMallConfig record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallConfigMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxMallConfig getById(Long id) { | |||
| return wxMallConfigMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxMallConfig record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxMallConfigMapper.insertSelective(record); | |||
| } else { | |||
| wxMallConfigMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxMallConfigMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -1,10 +1,10 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxMallConfigMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMallConfig"> | |||
| <mapper namespace="com.iformall.mapper.WxCouponSendConfigMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponSendConfig"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="key" jdbcType="VARCHAR" property="key" /> | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType" /> | |||
| <result column="value" jdbcType="INTEGER" property="value" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||
| @@ -12,7 +12,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`key`,`value`,`remark`,`create_time`,`update_time` | |||
| `id`,`tenant_id`,`send_type`,`value`,`remark`,`create_time`,`update_time` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -29,7 +29,7 @@ | |||
| </if> | |||
| <if test=" null != key "> | |||
| and `key` like concat('%', #{key},'%') | |||
| and `send_type` = #{sendType} | |||
| </if> | |||
| @@ -61,8 +61,8 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxMallConfig" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_mall_config | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponSendConfig" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_send_config | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| @@ -7,13 +7,14 @@ | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType" /> | |||
| <result column="condition" jdbcType="VARCHAR" property="condition" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`coupon_id`,`title`,`send_type`,`status`,`create_date`,`update_date` | |||
| `id`,`tenant_id`,`coupon_id`,`title`,`send_type`,`condition`,`status`,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -76,7 +77,6 @@ | |||
| update wx_coupon_send set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | |||
| </update> | |||
| <update id="offExpiriedCouponSendByCouponStatus"> | |||
| update wx_coupon_send cs, wx_coupon c | |||
| set cs.status=1, cs.update_date = now() | |||