| | |
| | | try { |
| | | vipCenterService.saveManageWeb(t); |
| | | return ResultUtils.loadTrue(); |
| | | } catch (VipCenterException e) { |
| | | return ResultUtils.loadFalse(e.getCode(),e.getMsg()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtils.loadFalse("保存失败!"); |
| | |
| | | import com.ks.app.pojo.VO.Result; |
| | | import com.ks.app.util.ResultUtils; |
| | | import com.ks.vip.exception.VipGradePotenceException; |
| | | import com.ks.vip.pojo.DO.VipCenter; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "save") |
| | | public Result save(VipGradePotence t, HttpServletRequest request) { |
| | | @RequestMapping(value = "add") |
| | | public Result add(VipGradePotence t, HttpServletRequest request) { |
| | | try { |
| | | vipGradePotenceService.save(t); |
| | | vipGradePotenceService.add(t); |
| | | return ResultUtils.loadTrue(); |
| | | } catch (VipGradePotenceException e) { |
| | | return ResultUtils.loadFalse(e.getMsg()); |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "getByGradeId") |
| | | public Result getByGradeId(Long gradeId, HttpServletRequest request) { |
| | | @RequestMapping(value = "modify") |
| | | public Result modify(VipGradePotence t, HttpServletRequest request) { |
| | | try { |
| | | VipGradePotence t = vipGradePotenceService.getPotenceByGradeId(gradeId); |
| | | return ResultUtils.loadTrue(t); |
| | | vipGradePotenceService.updateByPrimaryKeySelective(t); |
| | | return ResultUtils.loadTrue(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtils.loadFalse("查询失败!"); |
| | | return ResultUtils.loadFalse("保存失败!"); |
| | | } |
| | | } |
| | | |
| | | // @ResponseBody |
| | | // @RequestMapping(value = "getByGradeId") |
| | | // public Result getByGradeId(Long gradeId, HttpServletRequest request) { |
| | | // try { |
| | | // VipGradePotence t = vipGradePotenceService.getPotenceByGradeId(gradeId); |
| | | // return ResultUtils.loadTrue(t); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // return ResultUtils.loadFalse("查询失败!"); |
| | | // } |
| | | // } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "delete") |
| | | public Result delete(String ids, HttpServletRequest request) { |
| | |
| | | <script> |
| | | |
| | | function openPotencePage(id) { |
| | | xadmin.open('账号管理','gradePotence-add.html?pid='+ id,500,480,false); |
| | | xadmin.open('账号管理','gradePotence-list.html?pid='+ id,null,null,true); |
| | | } |
| | | |
| | | function member_del(obj, index, id) { |
| | |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="effectiveTime" class="layui-form-label"> |
| | | 生效时间</label> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" class="layui-input" id="effectiveTime" name="effectiveTime" placeholder="yyyy-MM-dd HH:mm:ss"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <!-- <label for="L_remarks" class="layui-form-label"></label>--> |
| | | <button class="layui-btn" lay-filter="add" lay-submit="">保存</button> |
| | | </div> |
| | |
| | | $("#gradeId").val(gradeId); |
| | | |
| | | |
| | | $.ajax({ |
| | | url: "/admin/api/vip/vipGradePotence/getByGradeId", |
| | | type: "POST", |
| | | data: {"gradeId":gradeId}, |
| | | success: function(data) { |
| | | if(data.code == 0) { |
| | | $("#id").val(data.data.id); |
| | | $("#rebatePercent").val(data.data.rebatePercent); |
| | | $("#taolijinPercent").val(data.data.taolijinPercent); |
| | | $("#taolijinMaxNumber").val(data.data.taolijinMaxNumber); |
| | | $("#taolijinMaxMoney").val(data.data.taolijinMaxMoney); |
| | | } else { |
| | | alert(data.msg); |
| | | } |
| | | } |
| | | }) |
| | | // $.ajax({ |
| | | // url: "/admin/api/vip/vipGradePotence/getByGradeId", |
| | | // type: "POST", |
| | | // data: {"gradeId":gradeId}, |
| | | // success: function(data) { |
| | | // if(data.code == 0) { |
| | | // $("#id").val(data.data.id); |
| | | // $("#rebatePercent").val(data.data.rebatePercent); |
| | | // $("#taolijinPercent").val(data.data.taolijinPercent); |
| | | // $("#taolijinMaxNumber").val(data.data.taolijinMaxNumber); |
| | | // $("#taolijinMaxMoney").val(data.data.taolijinMaxMoney); |
| | | // } else { |
| | | // alert(data.msg); |
| | | // } |
| | | // } |
| | | // }) |
| | | |
| | | |
| | | |
| | |
| | | function (data) { |
| | | console.log(data.field); |
| | | //发异步,把数据提交给php |
| | | ksapp.post('/admin/api/vip/vipGradePotence/save', data.field, function (res) { |
| | | ksapp.post('/admin/api/vip/vipGradePotence/add', data.field, function (res) { |
| | | if (res.code == 0) { |
| | | layer.alert("保存成功", { |
| | | icon: 6 |
| | |
| | | |
| | | }); |
| | | |
| | | layui.use('laydate', function() { |
| | | var laydate = layui.laydate; |
| | | laydate.render({ |
| | | elem: '#effectiveTime' |
| | | , type: 'datetime' |
| | | ,trigger: 'click' |
| | | }); |
| | | }); |
| | | |
| | | |
| | | </script> |
| | |
| | | </body> |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn" onclick="xadmin.open('添加权益','gradePotence-add.html',500,480)"><i class="layui-icon"></i>添加 |
| | | <button class="layui-btn" onclick="openAddViews()"><i class="layui-icon"></i>添加 |
| | | </button> |
| | | </div> |
| | | </script> |
| | |
| | | <div>{{layui.util.toDateString(d.updateTime, 'yyyy-MM-dd HH:mm:ss')}}</div> |
| | | </script> |
| | | |
| | | |
| | | <script type="text/html" id="switchTpl"> |
| | | <input type="checkbox" name="sex" value="{{d.id}}" lay-skin="switch" lay-text="启用|停用" lay-filter="stateBox" {{ d.state== 1 ? 'checked': ''}} > |
| | | <script type="text/html" id="dateFomat1"> |
| | | <div>{{layui.util.toDateString(d.effectiveTime, 'yyyy-MM-dd HH:mm:ss')}}</div> |
| | | </script> |
| | | |
| | | |
| | | |
| | | <script> |
| | | layui.use('laydate', |
| | |
| | | </script> |
| | | |
| | | <script> |
| | | |
| | | var gradeId= GetQueryString("pid"); // 上级did |
| | | |
| | | //封装GetQueryString()方法来获取URL后面的value值 |
| | | function GetQueryString(name) { |
| | | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); |
| | | var r = window.location.search.substr(1).match(reg); |
| | | if (r != null) |
| | | return decodeURI(r[2]); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | function openAddViews() { |
| | | xadmin.open('新增链接信息','gradePotence-add.html?pid='+ gradeId,500,480); |
| | | } |
| | | |
| | | |
| | | var app = null; |
| | | layui.use('table', function () { |
| | | //搜索表单的vue赋值 |
| | |
| | | cols: [ |
| | | [{type: 'checkbox', title: "ID"}, |
| | | {field: 'id', width: 80, sort: true, title: "ID"}, |
| | | {field: 'state', width: 80, title: "状态", templet: "#switchTpl"}, |
| | | {field: 'gradeId', edit: 'text', width: 150, title: "等级名称"}, |
| | | {field: 'name',edit: 'text', width: 120, sort: true, title: "等级图标"}, |
| | | {field: 'icon', edit: 'text', width: 150, title: "等级序号"}, |
| | | {field: 'rebatePercent', edit: 'text', width: 150, title: "返利比例"}, |
| | | {field: 'taolijinPercent',edit: 'text', width: 150, sort: true, title: "淘礼金比例"}, |
| | | {field: 'taolijinMaxNumber', edit: 'text', width: 150, title: "每日创建淘礼金的次数"}, |
| | | {field: 'taolijinMaxMoney', edit: 'text', width: 150, title: "每日创建淘礼金的最大金额"}, |
| | | {field: 'effectiveTime', sort: true, width: 150, title: "生效时间", templet:"#dateFomat1"}, |
| | | {field: 'updateTime', sort: true, width: 150, title: "修改时间", templet:"#dateFomat"}, |
| | | {fixed: 'right', width: 250, title: "操作", toolbar: '#barAction'}, |
| | | ] |
| | |
| | | }; |
| | | }); |
| | | |
| | | |
| | | //监听状态操作 |
| | | layui.form.on('switch(stateBox)', function(obj){ |
| | | var state = 0; |
| | | if (obj.elem.checked) { |
| | | state = 1; |
| | | } |
| | | var params = {id: this.value, state: state}; |
| | | app.update(this.value, params); |
| | | }); |
| | | |
| | | });</script> |
| | | </html> |
| | |
| | | package com.ks.vip.pojo.DO; |
| | | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.yeshi.utils.generater.mybatis.Column; |
| | | import org.yeshi.utils.generater.mybatis.Table; |
| | | |
| | |
| | | |
| | | @Column(name = "pc_taolijin_max_money") |
| | | private BigDecimal taolijinMaxMoney; |
| | | |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @Column(name = "pc_effective_time") |
| | | private Date effectiveTime; |
| | | |
| | | |
| | | @Column(name = "pc_creator_id") |
| | | private Long creatorId; |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public Date getEffectiveTime() { |
| | | return effectiveTime; |
| | | } |
| | | |
| | | public void setEffectiveTime(Date effectiveTime) { |
| | | this.effectiveTime = effectiveTime; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 根据时间问题 |
| | | * @param uid |
| | | * @param time |
| | | * @return |
| | | */ |
| | | public VipGradePotence getVipPotenceByTime(String uid, Date time); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取当前用户会员权益 |
| | | * |
| | | * @param uid |
| | |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface VipGradePotenceService { |
| | |
| | | public void delete(Long id); |
| | | |
| | | /** |
| | | * 根据等级Id查询权益 |
| | | * 查询权限: 根据时间筛选 |
| | | * @param gradeId |
| | | * @param time |
| | | * @return |
| | | */ |
| | | public VipGradePotence getByGradeIdAndTime(Long gradeId, Date time); |
| | | |
| | | |
| | | /** |
| | | * 查询当前等级权利 |
| | | * @param gradeId |
| | | * @return |
| | | */ |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId); |
| | | public VipGradePotence getCurrentByGradeId(Long gradeId); |
| | | |
| | | |
| | | /** |
| | |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum); |
| | | |
| | | /** |
| | | * 根据会员类型查询权益-以及时间查询 |
| | | * @param vipEnum |
| | | * @param time |
| | | * @return |
| | | */ |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum, Date time); |
| | | |
| | | /** |
| | | * 保存 |
| | | * @param t |
| | | * @throws VipGradePotenceException |
| | | */ |
| | | public void save(VipGradePotence t) throws VipGradePotenceException; |
| | | public void add(VipGradePotence t) throws VipGradePotenceException; |
| | | } |
| | |
| | | import com.ks.vip.query.VipGradePotenceQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface VipGradePotenceMapper extends BaseMapper<VipGradePotence> { |
| | |
| | | long count(@Param("query")VipGradePotenceQuery query); |
| | | |
| | | |
| | | VipGradePotence getByGradeId(@Param("gradeId")Long gradeId); |
| | | VipGradePotence getByGradeId(@Param("gradeId")Long gradeId, @Param("queryTime")Date queryTime); |
| | | } |
| | |
| | | if (vipCenter != null && vipCenter.getGradeId() != null) { |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | potence = vipGradePotenceService.getPotenceByGradeId(vipCenter.getGradeId()); |
| | | potence = vipGradePotenceService.getCurrentByGradeId(vipCenter.getGradeId()); |
| | | } |
| | | } |
| | | if (potence == null) { |
| | | potence = vipGradePotenceService.getDefaultGradePotence(); |
| | | } |
| | | return potence; |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getVipPotenceByTime(String uid, Date time) { |
| | | VipGradePotence potence = null; |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter != null && vipCenter.getGradeId() != null) { |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | potence = vipGradePotenceService.getByGradeIdAndTime(vipCenter.getGradeId(), time); |
| | | } |
| | | } |
| | | if (potence == null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId); |
| | | public VipGradePotence getByGradeIdAndTime(Long gradeId, Date time) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId, time); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getCurrentByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId, new Date()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void save(VipGradePotence t) throws VipGradePotenceException { |
| | | public void add(VipGradePotence t) throws VipGradePotenceException { |
| | | Long gradeId = t.getGradeId(); |
| | | if (gradeId == null) { |
| | | throw new VipGradePotenceException(1, "等级ID为空"); |
| | | } |
| | | |
| | | if(t.getId() != null && t.getId().longValue() > 0) { |
| | | t.setUpdateTime(new Date()); |
| | | vipGradePotenceMapper.updateByPrimaryKeySelective(t); |
| | | } else { |
| | | VipGradePotence obj = vipGradePotenceMapper.getByGradeId(gradeId); |
| | | if (obj == null) { |
| | | t.setCreateTime(new Date()); |
| | | vipGradePotenceMapper.insertSelective(t); |
| | | } else { |
| | | t.setId(obj.getId()); |
| | | t.setUpdateTime(new Date()); |
| | | vipGradePotenceMapper.updateByPrimaryKeySelective(t); |
| | | } |
| | | if (t.getEffectiveTime() == null) { |
| | | t.setEffectiveTime(new Date()); |
| | | } |
| | | t.setCreateTime(new Date()); |
| | | vipGradePotenceMapper.insertSelective(t); |
| | | } |
| | | |
| | | |
| | |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId(), new Date()); |
| | | } |
| | | |
| | | |
| | |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | return getCurrentByGradeId(grade.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum, Date time) { |
| | | VipGrade grade = vipGradeService.getByVipEnum(vipEnum); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return getByGradeIdAndTime(grade.getId(), time); |
| | | } |
| | | } |
| | |
| | | <result column="pc_taolijin_percent" property="taolijinPercent" jdbcType="DECIMAL"/> |
| | | <result column="pc_taolijin_max_number" property="taolijinMaxNumber" jdbcType="INTEGER"/> |
| | | <result column="pc_taolijin_max_money" property="taolijinMaxMoney" jdbcType="DECIMAL"/> |
| | | <result column="pc_effective_time" property="effectiveTime" jdbcType="TIMESTAMP"/> |
| | | <result column="pc_creator_id" property="creatorId" jdbcType="BIGINT"/> |
| | | <result column="pc_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="pc_updator_id" property="updatorId" jdbcType="BIGINT"/> |
| | | <result column="pc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time</sql> |
| | | <sql id="Base_Column_List">pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_effective_time,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from vip_grade_potence where pc_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from vip_grade_potence where pc_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence (pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time) values (#{id,jdbcType=BIGINT},#{gradeId,jdbcType=BIGINT},#{rebatePercent,jdbcType=DECIMAL},#{taolijinPercent,jdbcType=DECIMAL},#{taolijinMaxNumber,jdbcType=INTEGER},#{taolijinMaxMoney,jdbcType=DECIMAL},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence (pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_effective_time,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time) values (#{id,jdbcType=BIGINT},#{gradeId,jdbcType=BIGINT},#{rebatePercent,jdbcType=DECIMAL},#{taolijinPercent,jdbcType=DECIMAL},#{taolijinMaxNumber,jdbcType=INTEGER},#{taolijinMaxMoney,jdbcType=DECIMAL},#{effectiveTime},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">pc_id,</if> |
| | |
| | | <if test="taolijinPercent != null">pc_taolijin_percent,</if> |
| | | <if test="taolijinMaxNumber != null">pc_taolijin_max_number,</if> |
| | | <if test="taolijinMaxMoney != null">pc_taolijin_max_money,</if> |
| | | <if test="effectiveTime != null">pc_effective_time,</if> |
| | | <if test="creatorId != null">pc_creator_id,</if> |
| | | <if test="createTime != null">pc_create_time,</if> |
| | | <if test="updatorId != null">pc_updator_id,</if> |
| | |
| | | <if test="taolijinPercent != null">#{taolijinPercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinMaxNumber != null">#{taolijinMaxNumber,jdbcType=INTEGER},</if> |
| | | <if test="taolijinMaxMoney != null">#{taolijinMaxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="effectiveTime != null">#{effectiveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="creatorId != null">#{creatorId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updatorId != null">#{updatorId,jdbcType=BIGINT},</if> |
| | |
| | | <if test="taolijinPercent != null">pc_taolijin_percent=#{taolijinPercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinMaxNumber != null">pc_taolijin_max_number=#{taolijinMaxNumber,jdbcType=INTEGER},</if> |
| | | <if test="taolijinMaxMoney != null">pc_taolijin_max_money=#{taolijinMaxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="effectiveTime != null">pc_effective_time=#{effectiveTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="creatorId != null">pc_creator_id=#{creatorId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">pc_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updatorId != null">pc_updator_id=#{updatorId,jdbcType=BIGINT},</if> |
| | |
| | | |
| | | <select id="getByGradeId" resultMap="BaseResultMap"> |
| | | select <include refid="Base_Column_List"/> from vip_grade_potence |
| | | where pc_grade_id = #{gradeId} |
| | | where pc_grade_id = #{gradeId} and #{queryTime} >= pc_effective_time |
| | | order by pc_effective_time desc |
| | | limit 1 |
| | | </select> |
| | | |