| @@ -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<WxGame> 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<WxGameUserActionLogVo> 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<WxGameUserCount> page = wxGameService.listAsPageGameUserCount(gameUserCount, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -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") | |||
| @@ -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; | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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<WxGameActionLog, Str | |||
| int getAwardCount(WxGameActionLog wxGameActionLog); | |||
| int getPlayCreditCount(WxGameActionLog wxGameActionLog); | |||
| WxGameUserActionLogVo findUserSumList(WxGameActionLog wxGameActionLog); | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxGameUserCount; | |||
| import java.util.List; | |||
| public interface WxGameUserCountMapper extends CommonMapper<WxGameUserCount, String> { | |||
| List<WxGameUserCount> findList(WxGameUserCount wxGameUserCount); | |||
| Integer sumUserCount(WxGameUserCount wxGameUserCount); | |||
| } | |||
| @@ -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<WxGame> listAsPage(WxGame record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxGameUserActionLogVo> 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<WxGameUserCount> listAsPageGameUserCount(WxGameUserCount record, Integer pageIndex, Integer pageSize); | |||
| } | |||
| @@ -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<WxGameUserActionLogVo> listUserActionLogAsPage(WxGameActionLog record, Integer pageIndex, Integer pageSize) { | |||
| PageInfo<WxGameUserActionLogVo> 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<WxGameUserCount> listAsPageGameUserCount(WxGameUserCount record, Integer pageIndex, Integer pageSize) { | |||
| PageInfo<WxGameUserCount> 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; | |||
| } | |||
| } | |||
| @@ -150,5 +150,20 @@ | |||
| <include refid="dynamicCountWhereConditions" /> | |||
| and coupon_order_id != 0 | |||
| </select> | |||
| <resultMap id="userResultMap" type="com.iformall.domain.vo.WxGameUserActionLogVo"> | |||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||
| <result column="coupon_order_count" jdbcType="INTEGER" property="couponOrderCount" /> | |||
| <result column="add_credit_sum" jdbcType="INTEGER" property="addCreditSum" /> | |||
| <result column="use_credit_sum" jdbcType="INTEGER" property="useCreditSum" /> | |||
| </resultMap> | |||
| <select id="findUserSumList" parameterType="com.iformall.domain.po.WxGameActionLog" resultMap="userResultMap"> | |||
| select user_id, | |||
| SUM(CASE WHEN coupon_order_id > 0 THEN 1 ELSE 0 END) AS coupon_order_count, | |||
| sum(add_credit) as add_credit_sum,sum(used_credit) as use_credit_sum | |||
| from wx_game_action_log | |||
| where `tenant_id` = #{tenantId} and `game_id` = #{gameId} | |||
| group by user_id | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,76 @@ | |||
| <?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.WxGameUserCountMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxGameUserCount"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="game_id" jdbcType="BIGINT" property="gameId" /> | |||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||
| <result column="user_phone" jdbcType="VARCHAR" property="userPhone" /> | |||
| <result column="user_name" jdbcType="VARCHAR" property="userName" /> | |||
| <result column="user_nick_name" jdbcType="VARCHAR" property="userNickName" /> | |||
| <result column="add_count" jdbcType="INTEGER" property="addCount" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`game_id`,`user_id`,`user_phone`,`user_name`,`user_nick_name`,`add_count`,`create_time`,`update_time` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <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 != gameId "> | |||
| and `game_id` = #{gameId} | |||
| </if> | |||
| <if test=" null != userId "> | |||
| and `user_id` = #{userId} | |||
| </if> | |||
| <if test=" null != userPhone and '' != userPhone"> | |||
| and `user_phone` like concat('%', #{userPhone},'%') | |||
| </if> | |||
| <if test=" null != userName and '' != userName"> | |||
| and `user_name` like concat('%', #{userName},'%') | |||
| </if> | |||
| <if test=" null != userNickName and '' != userNickName"> | |||
| and `user_nick_name` like concat('%', #{userNickName},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxGameUserCount" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_game_user_count | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="sumUserCount" parameterType="com.iformall.domain.po.WxGameUserCount" resultType="Integer"> | |||
| select sum(add_count) | |||
| from wx_game_user_count where `tenant_id` = #{tenantId} and `game_id` = #{gameId} and `user_id` = #{userId} | |||
| </select> | |||
| </mapper> | |||