Commit 2d2b6f9e by chongli

针对指定的券可以配置其在下单和分享时送券。

parent ee363c4c
......@@ -868,7 +868,7 @@ public class VoucherService {
voucherGetLog.setNewVoucherid(newVoucher.getId());
voucherGetLogDao.save(voucherGetLog);
//执行分享掉再送券活动
this.voucherUsedSend(voucher.getId(), voucherShareLog.getUid(), voucherShareLog.getId()+"", VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
this.voucherUsedSend(voucher.getId(), voucherShareLog.getUid(), voucherShareLog.getId()+"", 2);
//设置状态
response.setStatus(1);
response.setMessage("抢券成功");
......@@ -877,27 +877,34 @@ public class VoucherService {
}
/**
* //执行用户券下单或者分享使用掉了券,再补发送券活动
* @param voucher 使用的券对象
* @param usedVoucherId 使用的券对象
* @param uid 券送给谁
* @param remark 本次发券备注:分享id,或者订单号
* @param source 券来源
* @param usedWay 使用方式1:下单 2:分享
*/
public void voucherUsedSend(int usedVoucherId,String uid,String remark,int source){
public void voucherUsedSend(int usedVoucherId,String uid,String remark,int usedWay){
Voucher voucher = voucherDao.findById(usedVoucherId);
//voucher_used_send {"1722":"1723_2","1723":"1724_1","1724":"1725_0"}
//解释:1722分享时送1723的券;1723下单时送1724的券;1724下单和分享时送1725的券
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);
}
String[] conf = newRuleId.split("_");
//0是分享和使用都赠送;其它是使用方式和配置方式相同才送券
if(Integer.parseInt(conf[1])==0||Integer.parseInt(conf[1])==usedWay){
VoucherRule roucherRule = voucherRuleDao.findById(Integer.parseInt(conf[0]));
for(int i=0;i<roucherRule.getQuantity();i++){
Voucher againVoucher = this.getVoucherFromRule(roucherRule);
againVoucher.setNo("");
againVoucher.setUid(uid);
againVoucher.setSourceRemark(remark);
againVoucher.setSource(VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
voucherDao.save(againVoucher);
}
}
}
}
}
......
......@@ -1106,7 +1106,7 @@ public abstract class AbstractOrderService<H extends AbstractOrderBean<T>, T> ex
throw new OrderException(-100, "您的抵用劵使用错误");
}
for(VoucherItemBean bean: beanlist){
//this.voucherService.voucherUsedSend(bean.getId(), order.getUid(), order.getOrderNo()+"", VoucherSourceEnum.RULE_VOUCHERUSED_PRESENT.getValue());
this.voucherService.voucherUsedSend(bean.getId(), order.getUid(), order.getOrderNo()+"", 1);
}
}
}
......
......@@ -280,7 +280,7 @@ public abstract class AbstractNotifyService extends CorePaymentService {
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());
this.voucherService.voucherUsedSend(Integer.parseInt(usedVoucherId), order.getUid(), order.getOrderNo()+"", 1);
}
}
......
......@@ -31,6 +31,7 @@ import com.ctrip.fun.golf.domain.basic.MobileInfo;
import com.ctrip.fun.golf.domain.market.EventGameGroup;
import com.ctrip.fun.golf.domain.order.Order;
import com.ctrip.fun.golf.domain.product.BuyVoucherActivity;
import com.ctrip.fun.golf.service.basic.VoucherService;
import com.ctrip.fun.golf.service.market.EventGameGroupService;
import com.ctrip.fun.golf.service.market.EventGamePlayerService;
import com.ctrip.fun.golf.service.market.EventGameService;
......@@ -62,6 +63,9 @@ public class UserOrderBehaviourStatisticsDaoTest {
@Autowired
private CommuneOrderService communeOrderService;
@Autowired
private VoucherService voucherService;
public static void main(String[] args) {
......@@ -80,8 +84,7 @@ public class UserOrderBehaviourStatisticsDaoTest {
}
@Test
public void testOrderUpdate() throws Exception {
long list = orderDao.queryVoucherPayedOrder("15021268738",1);
System.out.println(list);
voucherService.voucherUsedSend(1106088, "15021270276", "lichong", 1);
}
......
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