use of com.ikoori.vip.common.persistence.model.Card 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);
}
use of com.ikoori.vip.common.persistence.model.Card in project vip by guangdada.
the class MemberServiceImpl method saveMember.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveMember(Member member, Long cardId) {
// 当前登录账号
Long createUserId = Long.valueOf(ShiroKit.getUser().getId());
Merchant merchant = merchantService.getMerchantUserId(createUserId);
/*member.setIsActive(false);*/
this.insert(member);
// 获得会员卡
Card card = cardMapper.selectById(cardId);
// 会员卡
MemberCard mc = new MemberCard();
mc.setMemberId(member.getId());
mc.setMerchantId(merchant.getId());
mc.setCardId(cardId);
mc.setCardNumber(RandomUtil.generateCardNum(card.getCardNumberPrefix()));
memberCardMapper.insert(mc);
}
use of com.ikoori.vip.common.persistence.model.Card in project vip by guangdada.
the class CouponApiImpl method checkCouponFetch.
/**
* 验证是否符合领取条件
*
* @Title: checkCouponFetch
* @param obj
* @param coupon
* @param member
* @param count
* @throws Exception
* @date: 2017年9月18日 下午5:15:39
* @author: chengxg
*/
private void checkCouponFetch(JSONObject obj, Coupon coupon, Member member, Integer count) throws Exception {
log.info("进入checkCouponFetch");
// 优惠券领取会员等级限制
Long limitCardId = coupon.getCardId();
if (limitCardId != null) {
int c = getMemCardCountByCardId(member.getId(), limitCardId);
if (c == 0) {
Card card = cardMapper.selectById(limitCardId);
log.error("该优惠券只能“" + card.getName() + "”才能领哦");
obj.put("msg", "该优惠券只能“" + card.getName() + "”才能领哦");
throw new Exception(obj.toJSONString());
}
}
// 优惠券每人限领数量判断
Integer quota = coupon.getQuota();
if (quota != null) {
// 获得当前会员已经领取的数量
Integer getCount = getMemGetCount(coupon.getId(), member.getId());
if (getCount >= quota) {
log.error("该优惠券每人只能领" + quota + "张哦");
obj.put("msg", "该优惠券每人只能领" + quota + "张哦");
throw new Exception(obj.toJSONString());
}
}
// 更新优惠券库存和领取次数
if (count != 0 && couponDao.updateStock(coupon.getId(), 1) == 0) {
log.error("该优惠券已经领完啦");
obj.put("msg", "该优惠券已经领完啦");
throw new Exception(obj.toJSONString());
}
// 领取人数更新
couponDao.updateGetCountUser(coupon.getId(), member.getId());
log.info("结束checkCouponFetch");
}
use of com.ikoori.vip.common.persistence.model.Card in project vip by guangdada.
the class MemberCardApiImpl method getMemberCardByUnionid.
@Override
public JSONObject getMemberCardByUnionid(String unionid) {
log.info("进入getMemberCardByUnionid>>unionid=" + unionid);
Member member = memberDao.getMemberByUnionid(unionid);
if (member == null) {
log.info("member == null");
return null;
}
MemberCard memberCard = memberCardDao.getMemberCard(member.getId());
if (memberCard == null) {
log.info("memberCard == null");
return null;
}
Merchant merchant = memberCard.getMerchant();
Card card = memberCard.getCard();
if (merchant == null || card == null) {
log.info("merchant == null || card == null");
return null;
}
JSONObject obj = new JSONObject();
obj.put("coverType", card.getCoverType());
obj.put("coverPic", card.getCoverPic());
obj.put("colorCode", ColorType.valOf(card.getColorCode()));
obj.put("merchantName", merchant.getName());
obj.put("merchantLogo", merchant.getHeadImg());
obj.put("cardName", card.getName());
obj.put("cardNum", memberCard.getCardNumber());
log.info("结束getMemberCardByUnionid");
return obj;
}
use of com.ikoori.vip.common.persistence.model.Card in project vip by guangdada.
the class MemberServiceImpl method saveMember.
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveMember(UserInfo userInfo, boolean update) throws Exception {
log.info("进去saveMember>>userInfo:" + userInfo.toString());
if (userInfo.getUnionid() == null) {
log.info("微信用户unionid为空");
throw new Exception("微信用户unionid为空");
}
synchronized (userInfo.getUnionid().intern()) {
Member member = memberDao.getMemberByUnionid(userInfo.getUnionid());
if (member == null) {
// 保存微信用户
log.info("保存微信用户");
WxUser wxUser = new WxUser();
setWxUserInfo(userInfo, wxUser);
wxUserMapper.insert(wxUser);
// 保存会员
log.info("保存会员信息");
member = new Member();
member.setUnionid(wxUser.getUnionid());
member.setIsActive(false);
// 需要根据appid获得商户id
member.setMerchantId(gunsProperties.getMerchantId());
member.setPoints(0);
member.setSourceType(MemSourceType.wechat.getCode());
memberMapper.insert(member);
// 查询获取类型为“关注微信”的会员卡
log.info("查询获取类型为“关注微信”的会员卡");
Card card = cardDao.getCardByGrantTypeAndMerchantId(gunsProperties.getMerchantId(), CardGrantType.SUB_WX.getCode());
if (card == null) {
log.info("没有找到会员卡类型");
// throw new Exception(obj.toJSONString());
throw new Exception("没有找到会员卡类型");
}
log.info("保存会员卡领取记录");
upgradeMemberCard(member, card);
// 关注微信返回积分
Point point = pointDao.getSubscribeWx(member.getMerchantId());
if (point != null) {
pointTradeService.savePointTrade(true, PointTradeType.SUBSCRIBE_WX.getCode(), point.getPoints(), member.getId(), point.getId(), member.getMerchantId(), null, "");
}
} else {
// 小程序入口,不要更新openid
if (update) {
log.info("用户已经存在,开始更新微信账号信息");
WxUser wxUser = new WxUser();
wxUser.setUnionid(userInfo.getUnionid());
wxUser = wxUserMapper.selectOne(wxUser);
setWxUserInfo(userInfo, wxUser);
wxUserMapper.updateById(wxUser);
}
}
}
}
Aggregations