use of com.ikoori.vip.common.persistence.model.Redpack in project vip by guangdada.
the class RedpackServiceImpl method saveRedPack.
@Override
public void saveRedPack(Redpack redpack) {
// 根据发放类型,清除金额
BigDecimal cleanAmount = new BigDecimal("0");
if (redpack.getSendType().intValue() == RedpackSendType.fixed.getCode()) {
redpack.setMinAmount(cleanAmount);
redpack.setMaxAmount(cleanAmount);
} else {
redpack.setAmount(cleanAmount);
}
// 根据红包类型查找红包规则记录
Redpack rpack = new Redpack();
rpack.setPackType(redpack.getPackType());
rpack.setStatus(1);
rpack = redpackMapper.selectOne(rpack);
if (redpack.getId() == null) {
if (rpack != null) {
throw new BussinessException(BizExceptionEnum.EXISTED_PACKTYPE);
} else {
redpackMapper.insert(redpack);
}
} else {
Redpack repack = this.selectById(redpack.getId());
if (redpack.getPackType() == repack.getPackType()) {
redpackMapper.updateById(redpack);
} else {
if (rpack == null) {
redpackMapper.updateById(redpack);
} else {
throw new BussinessException(BizExceptionEnum.EXISTED_PACKTYPE);
}
}
}
}
use of com.ikoori.vip.common.persistence.model.Redpack in project vip by guangdada.
the class RedpackLogController method index.
/**
* 跳转到红包记录首页
*/
@RequestMapping("")
@Permission
public String index(Model model) {
Long userId = Long.valueOf(ShiroKit.getUser().getId());
Merchant merchant = merchantService.getMerchantUserId(userId);
List<Redpack> redpacks = redpackService.selectByMerchantId(merchant.getId());
model.addAttribute("sendStatus", RedPackSendStatus.values());
model.addAttribute("redpacks", redpacks);
return PREFIX + "redpackLog.html";
}
use of com.ikoori.vip.common.persistence.model.Redpack in project vip by guangdada.
the class MemberInfoApiImpl method activeMemberByUnionid.
/**
* 激活会员
*
* @Title: activeMemberByUnionid
* @param unionid
* @param mobile
* @param ip
* @param sendPack 发送红包
* @return
* @date: 2017年10月9日 上午10:54:16
* @author: chengxg
*/
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public int activeMemberByUnionid(String unionid, String mobile, String ip, boolean sendPack) {
synchronized (mobile.intern()) {
log.info("进入activeMemberByUnionid>>unionid=" + unionid);
log.info("进入activeMemberByUnionid>>mobile=" + mobile);
int count = memberDao.registerMember(unionid, mobile);
if (count > 0) {
Member receiveMem = memberDao.getMemberByUnionid(unionid);
shareService.activeShare(receiveMem);
if (sendPack) {
Redpack redpack = redpackService.selectByPackType(RedpackType.re.getCode(), receiveMem.getMerchantId());
if (redpack != null) {
Integer amount = redpack.getAmount().multiply(new BigDecimal(100)).intValue();
if (redpack.getSendType().intValue() == RedpackSendType.random.getCode()) {
int max = redpack.getMaxAmount().multiply(new BigDecimal(100)).intValue();
int min = redpack.getMinAmount().multiply(new BigDecimal(100)).intValue();
amount = (int) (Math.random() * (max - min + 1) + min);
}
WxUser wxuser = new WxUser();
wxuser.setUnionid(unionid);
wxuser = wxUserMapper.selectOne(wxuser);
if (wxuser != null) {
redpackLogService.saveRedPackLog(amount, unionid, wxuser.getOpenid(), ip, receiveMem.getMerchantId(), redpack.getId(), redpack.getActName(), redpack.getRemark(), redpack.getWishing());
}
}
}
}
log.info("结束activeMemberByUnionid");
return count;
}
}
use of com.ikoori.vip.common.persistence.model.Redpack in project vip by guangdada.
the class RedpackController method redpackUpdate.
/**
* 跳转到修改红包
*/
@RequestMapping("/redpack_update/{redpackId}")
public String redpackUpdate(@PathVariable Long redpackId, Model model) {
Redpack redpack = redpackService.selectById(redpackId);
if (redpack == null) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
// model.addAttribute("amount", redpack.getAmount() == null ? "" : redpack.getAmount() / 100);
// model.addAttribute("minAmount", redpack.getMinAmount() == null ? "" : redpack.getMinAmount() / 100);
// model.addAttribute("maxAmount", redpack.getMaxAmount() == null ? "" : redpack.getMaxAmount() / 100);
model.addAttribute("packType", RedpackType.values());
model.addAttribute(redpack);
return PREFIX + "redpack_edit.html";
}
Aggregations