use of com.ikoori.vip.common.persistence.model.MemberCard 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";
}
use of com.ikoori.vip.common.persistence.model.MemberCard in project vip by guangdada.
the class MemberCardController method memberCardUpdate.
/**
* 跳转到修改领取记录
*/
@Permission
@RequestMapping("/memberCard_update/{memberCardId}")
public String memberCardUpdate(@PathVariable Long memberCardId, Model model) {
MemberCard memberCard = memberCardService.selectById(memberCardId);
model.addAttribute(memberCard);
return PREFIX + "memberCard_edit.html";
}
use of com.ikoori.vip.common.persistence.model.MemberCard 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.MemberCard in project vip by guangdada.
the class MemberServiceImpl method upgradeMemberCard.
/**
* 升级会员卡和权益
* @Title: upgradeMemCard
* @param member
* @param card
* @date: 2017年9月18日 下午1:51:33
* @author: chengxg
*/
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void upgradeMemberCard(Member member, Card card) {
MemberCard mc = getMemberCard(member.getId(), card.getId());
if (mc != null) {
log.info("已经有该级别会员卡");
// 已经有该级别会员卡
mc.setIsDefault(true);
memberCardMapper.updateById(mc);
} else {
log.info("没有该级别会员卡,发送一张");
// 没有该级别会员卡
MemberCard memCard = new MemberCard();
memCard.setCardId(card.getId());
memCard.setCardNumber(RandomUtil.generateCardNum(card.getCardNumberPrefix()));
memCard.setMemberId(member.getId());
memCard.setMerchantId(member.getMerchantId());
memCard.setState(MemCardState.USED.getCode());
memCard.setIsDefault(true);
memberCardMapper.insert(memCard);
// 获取会员卡权益
log.info("获取会员卡权益");
List<CardRight> cardRights = cardRightDao.selectByCardId(card.getId());
if (CollectionUtils.isNotEmpty(cardRights)) {
for (CardRight cardRight : cardRights) {
if (RightType.COUPON.getCode().equals(cardRight.getRightType())) {
log.info("赠送id=" + cardRight.getCouponId() + "的优惠券");
Coupon coupon = couponMapper.selectById(cardRight.getCouponId());
Integer number = cardRight.getNumber();
log.info("赠送数量为:" + number);
log.info("剩余数量为:" + coupon.getStock());
if (number != null) {
// 更新库存数
int us = couponDao.updateStock(coupon.getId(), number);
if (us == 0) {
log.info("修改库存失败");
continue;
}
// 跟新领取人数
int uu = couponDao.updateGetCountUser(coupon.getId(), member.getId());
if (uu == 0) {
log.info("修改领取人数失败:" + uu);
}
log.info("保存优惠券领取记录");
for (int i = 0; i < number.intValue(); i++) {
// 保存领取记录
couponFetchService.saveCouponFetch(member, coupon, null);
}
}
} else if (RightType.POINTS.getCode().equals(cardRight.getRightType())) {
log.info("赠送积分:" + cardRight.getPoints());
pointTradeService.savePointTrade(true, PointTradeType.CARD.getCode(), cardRight.getPoints(), member.getId(), null, member.getMerchantId(), null, "");
}
}
}
// 获得关注微信的积分规则
}
// 修改会员的默认会员卡
log.info("修改会员的默认会员卡");
updateDefaultCard(card.getId(), member.getId());
}
use of com.ikoori.vip.common.persistence.model.MemberCard 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;
}
Aggregations