Search in sources :

Example 6 with Member

use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.

the class MemberController method add.

/**
 * 新增会员
 */
@RequestMapping(value = "/add")
@Permission
@ResponseBody
public Object add(Member member, Long cardId) {
    // 添加会员, 判断账号是否重复
    Member memberRe = memberService.selectByMobile(member.getMobile());
    if (memberRe != null) {
        throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
    }
    memberService.saveMember(member, cardId);
    return super.SUCCESS_TIP;
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Member

use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.

the class MemberController method memberUpdate.

/**
 * 跳转到修改会员
 */
@Permission
@RequestMapping("/member_update/{memberId}")
public String memberUpdate(@PathVariable Long memberId, Model model) {
    Member member = memberService.selectById(memberId);
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    MemberCard memberCard = new MemberCard();
    memberCard.setMemberId(member.getId());
    memberCard.setIsDefault(true);
    memberCard = memberCardMapper.selectOne(memberCard);
    model.addAttribute("memberCard", memberCard);
    // 会员卡
    Merchant merchant = merchantService.getMerchantUserId(userId);
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    condition.put("inGrantType", new Object[] { CardGrantType.NO_RULE.getCode(), CardGrantType.SUB_WX.getCode() });
    List<Card> cards = cardService.selectByCondition(condition);
    model.addAttribute("cards", cards);
    model.addAttribute("member", member);
    return PREFIX + "member_edit.html";
}
Also used : MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) Member(com.ikoori.vip.common.persistence.model.Member) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Member

use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.

the class MemberServiceImpl method updateMember.

/**
 * <p>Title: updateMember</p>
 * <p>Description: 修改会员</p>
 * @param member
 * @param cardId 会员卡号
 * @param point  交易积分
 * @see com.ikoori.vip.server.modular.biz.service.IMemberService#updateMember(com.ikoori.vip.common.persistence.model.Member, java.lang.Long, int)
 */
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void updateMember(Member member, Long cardId, int point) {
    Member dbMember = selectById(member.getId());
    // 会员没激活,填手机号码,判断手机号码是否唯一
    if (!dbMember.isIsActive()) {
        // 修改会员, 判断账号是否重复
        Member memberRe = selectByMobile(member.getMobile());
        if (memberRe != null) {
            throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
        }
    }
    // 更新交易积分
    if (point != 0) {
        Boolean inOut = point > 0 ? true : false;
        pointTradeService.savePointTrade(inOut, PointTradeType.GIVE.getCode(), point, dbMember.getId(), null, dbMember.getMerchantId(), null, "");
    }
    // 更新会员信息
    member.setPoints(member.getPoints() + point);
    member.setIsActive(true);
    memberMapper.updateById(member);
    // 更新会员卡
    Card card = cardMapper.selectById(cardId);
    upgradeMemberCard(dbMember, card);
}
Also used : Member(com.ikoori.vip.common.persistence.model.Member) BussinessException(com.ikoori.vip.common.exception.BussinessException) Card(com.ikoori.vip.common.persistence.model.Card) MemberCard(com.ikoori.vip.common.persistence.model.MemberCard) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Member

use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.

the class MemberServiceImpl method updateUnionid.

public void updateUnionid() {
    String url = WeChatAPI.batchget + "?access_token=" + WeChatAPI.getAccesstoken();
    boolean c = true;
    List<Member> members = null;
    do {
        Wrapper<Member> w = new EntityWrapper<>();
        w.isNull("unionid");
        w.last(" limit 100");
        members = memberMapper.selectList(w);
        if (members != null && members.size() > 0) {
            JSONObject data = new JSONObject();
            JSONArray o = new JSONArray();
            for (Member m : members) {
                JSONObject sobj = new JSONObject();
                sobj.put("openid", m.getOpenId());
                sobj.put("lang", "zh_CN");
                o.add(sobj);
            }
            data.put("user_list", o);
            updateUnionid(url, data.toJSONString());
            System.out.println(data.toJSONString());
        }
        c = members == null || members.size() < 100 ? false : true;
        members = null;
    } while (c);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) JSONArray(com.alibaba.fastjson.JSONArray) Member(com.ikoori.vip.common.persistence.model.Member)

Example 10 with Member

use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.

the class CouponApiImpl method activeCoupon.

/**
 * 根据券号,激活优惠券
 *
 * @Title: activeCoupon
 * @param verifyCode
 * @param unionid
 * @date: 2017年9月18日 下午4:18:12
 * @author: chengxg
 * @throws Exception
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public JSONObject activeCoupon(String verifyCode, String unionid) throws Exception {
    log.info("进入activeCoupon");
    log.info("进入activeCoupon>>verifyCode=" + verifyCode);
    log.info("进入activeCoupon>>unionid=" + unionid);
    JSONObject obj = new JSONObject();
    obj.put("code", true);
    obj.put("msg", "领取成功");
    // unionid获得会员
    // 判断会员卡是否过期
    Member member = memberDao.getMemberByUnionid(unionid);
    if (member == null) {
        log.error("您还不是会员哦");
        obj.put("msg", "您还不是会员哦");
        throw new Exception(obj.toJSONString());
    }
    if (!member.isIsActive() || StringUtils.isBlank(member.getMobile())) {
        log.error("您还没有激活会员卡哦");
        obj.put("msg", "您还没有激活会员卡哦");
        throw new Exception(obj.toJSONString());
    }
    synchronized (verifyCode.intern()) {
        CouponCode couponCode = getCouponCode(verifyCode);
        if (couponCode == null) {
            log.error("没有找到该现金券哦" + verifyCode);
            obj.put("msg", "没有找到该现金券哦");
            throw new Exception(obj.toJSONString());
        }
        if (couponCode.getUseStatus() != CouponCodeStatus.publish.getCode()) {
            log.error("该现金券还没有发行哦");
            obj.put("msg", "该现金券还没有发行哦");
            throw new Exception(obj.toJSONString());
        }
        Coupon coupon = couponMapper.selectById(couponCode.getCouponId());
        if (coupon == null || !coupon.isIsExpired() || !coupon.isIsInvalid()) {
            log.error("该现金券已经过期啦");
            obj.put("msg", "该现金券已经过期啦");
            throw new Exception(obj.toJSONString());
        }
        // 判断是否符合领取条件
        checkCouponFetch(obj, coupon, member, 1);
        // 保存领取记录
        couponFetchService.saveCouponFetch(member, coupon, couponCode.getVerifyCode());
        // 修改券码状态为“已激活”
        couponCode.setUseStatus(CouponCodeStatus.active.getCode());
        couponCodeMapper.updateById(couponCode);
    }
    log.info("结束activeCoupon");
    return obj;
}
Also used : Coupon(com.ikoori.vip.common.persistence.model.Coupon) CouponCode(com.ikoori.vip.common.persistence.model.CouponCode) JSONObject(com.alibaba.fastjson.JSONObject) Member(com.ikoori.vip.common.persistence.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Member (com.ikoori.vip.common.persistence.model.Member)23 JSONObject (com.alibaba.fastjson.JSONObject)12 Transactional (org.springframework.transaction.annotation.Transactional)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Card (com.ikoori.vip.common.persistence.model.Card)5 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)5 HashMap (java.util.HashMap)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 BussinessException (com.ikoori.vip.common.exception.BussinessException)4 Coupon (com.ikoori.vip.common.persistence.model.Coupon)4 ApiOperation (io.swagger.annotations.ApiOperation)4 JSONArray (com.alibaba.fastjson.JSONArray)3 Date (java.util.Date)3 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)2 Permission (com.ikoori.vip.common.annotion.Permission)2 Merchant (com.ikoori.vip.common.persistence.model.Merchant)2 Point (com.ikoori.vip.common.persistence.model.Point)2 ShareLog (com.ikoori.vip.common.persistence.model.ShareLog)2 WxUser (com.ikoori.vip.common.persistence.model.WxUser)2 BigDecimal (java.math.BigDecimal)2