diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxGameController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxGameController.java index 667eefec8..4fb8fa066 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxGameController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxGameController.java @@ -8,7 +8,10 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.WxGame; +import com.iformall.domain.po.WxGameActionLog; +import com.iformall.domain.po.WxGameUserCount; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.vo.WxGameUserActionLogVo; import com.iformall.enums.EnumGameStatus; import com.iformall.exception.MallinkException; import com.iformall.service.WxGameService; @@ -36,7 +39,6 @@ public class WxGameController extends BaseController { @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 WxGame wxGame, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxGameController::list"); if (null == wxGame) wxGame = new WxGame(); @@ -45,6 +47,22 @@ public class WxGameController extends BaseController { final PageInfo page = wxGameService.listAsPage(wxGame, pageNum, pageSize); return new ResultData(page); } + + @ApiOperation("用户中奖记录接口") + @GetMapping("userRecordlist") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData userRecordlist(@ModelAttribute WxGameActionLog wxGameLog, Integer pageNum, Integer pageSize) { + if (null == wxGameLog) wxGameLog = new WxGameActionLog(); + if (null == wxGameLog.getGameId()) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"参数无效"); + } + wxGameLog.updateTenantInfo(getTenantInfo()); + wxGameLog.setSortColumns("user_id asc"); + final PageInfo page = wxGameService.listUserActionLogAsPage(wxGameLog, pageNum, pageSize); + return new ResultData(page); + } @ApiOperation("新增接口") @PostMapping("add") @@ -113,11 +131,40 @@ public class WxGameController extends BaseController { @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() + "] WxGameController::findById"); return new ResultData(Result.SUCCESS, "查询成功", wxGameService.getById(id)); } + + @ApiOperation("定向发送") + @PostMapping("addUserCount") + @SystemControllerLog(description = "游戏-定向发放") + public ResultData addUserCount(@RequestBody WxGameUserCount gameUserCount) { + if (null == gameUserCount.getGameId() || null == gameUserCount.getUserId() + || StringUtils.isBlank(gameUserCount.getUserPhone())) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"参数错误"); + } + gameUserCount.updateTenantInfo(getTenantInfo()); + try{ + wxGameService.saveOrUpdateGameUserCount(gameUserCount); + return new ResultData(); + }catch(MallinkException e){ + return new ResultData(e.getErrorCode(),e.getMessage()); + } + } + + @ApiOperation("定向发送列表接口") + @GetMapping("userCountlist") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData userCountlist(@ModelAttribute WxGameUserCount gameUserCount, Integer pageNum, Integer pageSize) { + if (null == gameUserCount) gameUserCount = new WxGameUserCount(); + gameUserCount.updateTenantInfo(getTenantInfo()); + gameUserCount.setSortColumns(BaseEntity.SortField.CreateTime_DESC); + final PageInfo page = wxGameService.listAsPageGameUserCount(gameUserCount, pageNum, pageSize); + return new ResultData(page); + } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java b/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java index 1165739ce..b785912db 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java @@ -31,7 +31,7 @@ public class WxGame extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "有效日期-结束", name = "validEndDate") private Date validEndDate; - @io.swagger.annotations.ApiModelProperty(value = "触发条件(-1:不受限制,1:登录触发, 2:主页固定入口,3:购买触发,4:核销触发,5:公众号链接触发,6:二维码触发)", name = "triggleAction") + @io.swagger.annotations.ApiModelProperty(value = "触发条件(-1:不受限制,1:登录触发, 2:主页固定入口,3:购买触发,4:核销触发,5:公众号链接触发,6:二维码触发,7:定向发送)", name = "triggleAction") private Integer triggleAction; @io.swagger.annotations.ApiModelProperty(value = "限玩免费次数(-1:不能免费玩,0:不受限制,n:限玩次数)", name = "playLimit") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxGameUserCount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxGameUserCount.java new file mode 100644 index 000000000..57037596b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxGameUserCount.java @@ -0,0 +1,42 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +@TableName(value = "wx_game_user_count") +@Data +@EqualsAndHashCode(callSuper = true) +public class WxGameUserCount extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="游戏ID",name="gameId") + private Long gameId; + + @io.swagger.annotations.ApiModelProperty(value="",name="userId") + private Long userId; + + @io.swagger.annotations.ApiModelProperty(value="",name="userPhone") + private String userPhone; + + @io.swagger.annotations.ApiModelProperty(value="",name="userName") + private String userName; + + @io.swagger.annotations.ApiModelProperty(value="",name="userNickName") + private String userNickName; + + @io.swagger.annotations.ApiModelProperty(value = "", name = "addCount") + private Integer addCount; + + @io.swagger.annotations.ApiModelProperty(value="",name="createTime") + private Date createTime; + + @io.swagger.annotations.ApiModelProperty(value="",name="updateTime") + private Date updateTime; + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxGameUserActionLogVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxGameUserActionLogVo.java new file mode 100644 index 000000000..82ec3bdbf --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxGameUserActionLogVo.java @@ -0,0 +1,18 @@ +package com.iformall.domain.vo; + +import com.iformall.domain.po.WxCouponBatch; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class WxGameUserActionLogVo implements Serializable{ + + private static final long serialVersionUID = 4494858079134918638L; + //核销金额记录 + private Long userId; + private Integer couponOrderCount; + private Integer addCreditSum; + private Integer useCreditSum; +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java index 2521c0d7d..f382d1ab6 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxGameActionLog; +import com.iformall.domain.vo.WxGameUserActionLogVo; import java.util.List; @@ -12,4 +13,7 @@ public interface WxGameActionLogMapper extends CommonMapper { + + List findList(WxGameUserCount wxGameUserCount); + + Integer sumUserCount(WxGameUserCount wxGameUserCount); +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxGameService.java b/mallinkService/src/main/java/com/iformall/service/WxGameService.java index d71819809..dcb30f434 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxGameService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxGameService.java @@ -3,7 +3,10 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.WxGame; +import com.iformall.domain.po.WxGameActionLog; +import com.iformall.domain.po.WxGameUserCount; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.WxGameUserActionLogVo; public interface WxGameService { @@ -16,6 +19,8 @@ public interface WxGameService { * @return */ PageInfo listAsPage(WxGame record, Integer pageIndex, Integer pageSize); + + PageInfo listUserActionLogAsPage(WxGameActionLog record, Integer pageIndex, Integer pageSize); /** * 获取用户要玩的游戏信息 @@ -48,6 +53,8 @@ public interface WxGameService { * @param record */ void saveOrUpdate(WxGame record); + + void saveOrUpdateGameUserCount(WxGameUserCount gameUserCount); /** * 根据Id删除实体 @@ -60,4 +67,6 @@ public interface WxGameService { ResultData luckDraw(Long gameId, Long userId,Integer userCredit); ResultData cridetLuckDraw(Long gameIdL, Long memberId); + + PageInfo listAsPageGameUserCount(WxGameUserCount record, Integer pageIndex, Integer pageSize); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index c82ab143a..6e56db837 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -16,12 +16,14 @@ import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponChannelVo; +import com.iformall.domain.vo.WxGameUserActionLogVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxCouponChannelMapper; import com.iformall.mapper.WxCouponOrderMapper; import com.iformall.mapper.WxGameActionLogMapper; import com.iformall.mapper.WxGameMapper; +import com.iformall.mapper.WxGameUserCountMapper; import com.iformall.service.*; import com.iformall.service.order.entity.WxComposeOrder; import com.iformall.utils.Constant; @@ -49,6 +51,9 @@ public class WxGameServiceImpl implements WxGameService { @Autowired WxGameMapper wxGameMapper; + + @Autowired + WxGameUserCountMapper wxGameUserCountMapper; @Autowired WxCouponChannelMapper wxCouponChannelMapper; @@ -92,6 +97,17 @@ public class WxGameServiceImpl implements WxGameService { } return page; } + + @Override + public PageInfo listUserActionLogAsPage(WxGameActionLog record, Integer pageIndex, Integer pageSize) { + PageInfo page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxGameActionLogMapper.findUserSumList(record)); + if (null != page && null != page.getList() && page.getList().size() > 0) { + for (int i = 0 ; i < page.getList().size() ; i ++) { + WxGameUserActionLogVo vo = page.getList().get(i); + } + } + return page; + } @Override public WxGame getOne(WxGame wxGame) { @@ -180,6 +196,19 @@ public class WxGameServiceImpl implements WxGameService { wxGameActionLog.setGameId(gameId); int playLimit = wxGame.getPlayLimit(); + if (wxGame.getTriggleAction().intValue() == 7) { + //如果是定向发送,则根据定向的次数来。 + WxGameUserCount gucq = new WxGameUserCount(); + gucq.updateTenantInfo(wxGameActionLog); + gucq.setGameId(gameId); + gucq.setUserId(userId);; + Integer ugs = wxGameUserCountMapper.sumUserCount(gucq); + if (null == ugs ) { + ugs = 0; + } + playLimit = ugs.intValue(); + } + int playCreditLimit = wxGame.getPlayCreditLimit(); int playCredit = 0; if(playCreditLimit >= 0){ @@ -437,6 +466,22 @@ public class WxGameServiceImpl implements WxGameService { wxCouponChannelService.updateQrCode(wxCouponChannel,wxCouponChannel.getId(),wxCouponChannel.getType()); } } + + + @Override + public void saveOrUpdateGameUserCount(WxGameUserCount record) { + if (record.getId() == null) { + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + record.setCreateTime(new Date()); + record.setUpdateTime(new Date()); + wxGameUserCountMapper.insert(record); + } else { + record.setUpdateTime(new Date()); + wxGameUserCountMapper.updateById(record); + } + + } @Override public void deleteById(Long id) { @@ -564,4 +609,16 @@ public class WxGameServiceImpl implements WxGameService { return new ResultData(ErrorCode.GAME_NOT_C_COUNT); } } + + @Override + public PageInfo listAsPageGameUserCount(WxGameUserCount record, Integer pageIndex, Integer pageSize) { + PageInfo page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxGameUserCountMapper.findList(record)); +// if (null != page && null != page.getList() && page.getList().size() > 0) { +// for (int i = 0 ; i < page.getList().size() ; i++) { +// WxGameUserCount guc = page.getList().get(i);) +// game.setGameTemplate(wxGameTemplateService.getById(game.getGameId())); +// } +// } + return page; + } } diff --git a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml index 772fde1ba..b8760b911 100644 --- a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml @@ -150,5 +150,20 @@ and coupon_order_id != 0 + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxGameUserCountMapper.xml b/mallinkService/src/main/resources/mapper/WxGameUserCountMapper.xml new file mode 100644 index 000000000..c9dff068c --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxGameUserCountMapper.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`game_id`,`user_id`,`user_phone`,`user_name`,`user_nick_name`,`add_count`,`create_time`,`update_time` + + + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `game_id` = #{gameId} + + + + and `user_id` = #{userId} + + + + and `user_phone` like concat('%', #{userPhone},'%') + + + + and `user_name` like concat('%', #{userName},'%') + + + + and `user_nick_name` like concat('%', #{userNickName},'%') + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + +