Commit 923612a0 by chongli

分享或者使用券再赠券功能

parent 4ea4d164
......@@ -867,12 +867,40 @@ public class VoucherService {
voucherGetLog.setCreateTime(new Date());
voucherGetLog.setNewVoucherid(newVoucher.getId());
voucherGetLogDao.save(voucherGetLog);
//执行分享掉再送券活动
this.voucherUsedSend(voucher.getId(), voucherShareLog.getUid(), voucherShareLog.getId()+"", VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
//设置状态
response.setStatus(1);
response.setMessage("抢券成功");
response.setBody("success");
return response;
}
/**
* //执行用户券下单或者分享使用掉了券,再补发送券活动
* @param voucher 使用的券对象
* @param uid 券送给谁
* @param remark 本次发券备注:分享id,或者订单号
* @param source 券来源
*/
public void voucherUsedSend(int usedVoucherId,String uid,String remark,int source){
Voucher voucher = voucherDao.findById(usedVoucherId);
ClientConfig clientConfig = clientConfigDao.getByType("voucher_used_send");
JSONObject jsobj = JSONObject.parseObject(clientConfig.getMessage());
if(jsobj.get(voucher.getRuleId()+"")!=null){
String[] newRuleIds = jsobj.get(voucher.getRuleId()+"").toString().split(",");
for(String newRuleId:newRuleIds){
VoucherRule roucherRule = voucherRuleDao.findById(Integer.parseInt(newRuleId));
for(int i=0;i<roucherRule.getQuantity();i++){
Voucher againVoucher = this.getVoucherFromRule(roucherRule);
againVoucher.setNo("");
againVoucher.setUid(uid);
againVoucher.setSourceRemark(remark);
againVoucher.setSource(source);
voucherDao.save(againVoucher);
}
}
}
}
public Response<VoucherItemDTO> executeGetRedeemCodeForMallOrder(VoucherQueryDto query) {
Response<VoucherItemDTO> response = new Response<VoucherItemDTO>();
......
......@@ -28,6 +28,7 @@ import com.ctrip.fun.common.vo.ResponseStatusEnum;
import com.ctrip.fun.common.vo.basic.AbstractRuleConditionBean;
import com.ctrip.fun.common.vo.basic.MultipleCourseConditionBean;
import com.ctrip.fun.common.vo.basic.VipGradeEnum;
import com.ctrip.fun.common.vo.basic.VoucherSourceEnum;
import com.ctrip.fun.common.vo.order.AbstractOrderBean;
import com.ctrip.fun.common.vo.order.AbstractOrderListItemBean;
import com.ctrip.fun.common.vo.order.CustomerInfoBean;
......@@ -1104,6 +1105,9 @@ public abstract class AbstractOrderService<H extends AbstractOrderBean<T>, T> ex
if(usedCount != order.getVoucherCount()){
throw new OrderException(-100, "您的抵用劵使用错误");
}
for(VoucherItemBean bean: beanlist){
this.voucherService.voucherUsedSend(bean.getId(), order.getUid(), order.getOrderNo()+"", VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
}
}
}
if (order.getPrePayCardAmount().doubleValue() > 0) {
......
......@@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.common.core.exceptions.service.ServiceException;
import com.ctrip.fun.common.core.util.RSA;
import com.ctrip.fun.common.vo.basic.VoucherSourceEnum;
import com.ctrip.fun.common.vo.integral.IntegralLogTypeEnum;
import com.ctrip.fun.common.vo.order.OrderCategoryEnum;
import com.ctrip.fun.common.vo.order.OrderProcessEnum;
......@@ -277,6 +278,12 @@ public abstract class AbstractNotifyService extends CorePaymentService {
try {
this.voucherService.userVoucher(order.getVoucherCount(), order.getOrderNo(),
order.getVoucherIDList());
if(order.getVoucherIDList()!=null&&!"".equals(order.getVoucherIDList())){
for(String usedVoucherId: order.getVoucherIDList().split(",")){
this.voucherService.voucherUsedSend(Integer.parseInt(usedVoucherId), order.getUid(), order.getOrderNo()+"", VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
}
}
} catch (Exception e) {
logger.warn(e.getMessage(), e);
handPayException(order, e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment