use of com.ikoori.vip.common.persistence.model.Member 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);
}
}
}
}
use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.
the class MemberServiceImpl method deleteMember.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteMember(Long memberId) {
Member member = this.selectById(memberId);
MemberCard mc = new MemberCard();
mc.setMemberId(member.getId());
mc = memberCardMapper.selectOne(mc);
memberCardMapper.deleteById(mc.getId());
this.deleteById(memberId);
}
use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.
the class MemberCardApiImpl method selectByMemberId.
/**
* @Title: selectByMemberId
* @Description: 会员卡详情
* @date: 2017年9月20日 下午5:06:48
* @author: huanglin
* @throws
*/
@Override
public JSONObject selectByMemberId(String unionid) {
log.info("进入selectByMemberId>>unionid" + unionid);
Member member = memberDao.getMemberByUnionid(unionid);
if (member == null) {
log.info("member == null");
return null;
}
Map<String, Object> cardDetail = memberCardService.selectByMemberId(member.getId());
if (cardDetail == null) {
log.info("cardDetail == null");
return null;
}
JSONObject obj = new JSONObject();
obj.put("description", cardDetail.get("description"));
obj.put("servicePhone", cardDetail.get("servicePhone"));
obj.put("termType", cardDetail.get("termType"));
obj.put("termDays", cardDetail.get("termDays"));
obj.put("termStartAt", cardDetail.get("termStartAt"));
obj.put("termEndAt", cardDetail.get("termEndAt"));
log.info("结束selectByMemberId");
return obj;
}
use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.
the class MemberOrderApiImpl method getMemberOrderByUnionid.
/**
* <p>Title: getMemberOrderByUnionid</p>
* <p>Description: 获取会员订单</p>
* @param unionid
* @return
*/
@Override
public List<Map<String, Object>> getMemberOrderByUnionid(String unionid, int start, int pageSize) {
log.info("进入getMemberOrderByUnionid>>unionid=" + unionid);
Member member = memberDao.getMemberByUnionid(unionid);
if (member == null) {
log.info("member == null");
return null;
}
List<Map<String, Object>> orders = orderDao.selectOrderListByMemberId(member.getId(), start, pageSize);
if (orders == null) {
log.info("orders==null");
return null;
}
log.info("结束getMemberOrderByUnionid");
return orders;
}
use of com.ikoori.vip.common.persistence.model.Member in project vip by guangdada.
the class ShareApiImpl method saveShareLog.
/**
* 保存邀请记录
*
* @Title: saveShareLog
* @param shareUnionid
* 邀请人unionid
* @param receiveUnionid
* 受邀人unionid
* @param receiveIp
* 受邀人ip
* @throws Exception
* @date: 2017年10月9日 上午9:28:15
* @author: chengxg
*/
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
@Override
public void saveShareLog(String shareUnionid, String receiveUnionid, String receiveIp) throws Exception {
log.info("进入saveShareLog>>shareUnionid=" + shareUnionid);
log.info("进入saveShareLog>>receiveUnionid=" + receiveUnionid);
log.info("进入saveShareLog>>receiveIp=" + receiveIp);
// 邀请人不存在, 不处理
Member shareMem = memberDao.getMemberByUnionid(shareUnionid);
if (shareMem == null) {
log.info("邀请人不存在");
return;
}
// 受邀人不是会员 或者已激活不处理
Member receiveMem = memberDao.getMemberByUnionid(receiveUnionid);
if (receiveMem == null || receiveMem.isIsActive()) {
log.info("受邀人不存在");
return;
}
Wrapper<ShareLog> w = new EntityWrapper<ShareLog>();
w.eq("share_unionid", shareUnionid);
w.eq("receive_unionid", receiveUnionid);
int count = shareLogMapper.selectCount(w);
if (count > 0) {
log.info("已有邀请记录");
return;
}
ShareLog shareLog = new ShareLog();
shareLog.setShareUnionid(shareUnionid);
shareLog.setReceiveUnionid(receiveUnionid);
shareLog.setReceiveIp(receiveIp);
shareLog.setReceiveStatus(false);
shareLogMapper.insert(shareLog);
log.info("结束saveShareLog");
}
Aggregations