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;
}
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";
}
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);
}
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);
}
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;
}
Aggregations