|
|
@ -101,7 +101,12 @@ public class YunmeiServiceImpl implements YunmeiService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public JSONObject directBuyOrder(DirectBuyOrderDto params) { |
|
|
public JSONObject directBuyOrder(DirectBuyOrderDto params) { |
|
|
JSONObject resJSON = checkQualification(params.getChargeAccountNumber()); |
|
|
String type = "会员权益"; //权益类型 会员类
|
|
|
|
|
|
//检查是否有领取资格
|
|
|
|
|
|
if (10000153==params.getSkuId()) { //如果产品Id是10000153说明领取的是饿了么卷
|
|
|
|
|
|
type = "现金卷"; //现金卷
|
|
|
|
|
|
} |
|
|
|
|
|
JSONObject resJSON = checkQualification(params.getChargeAccountNumber(), type); |
|
|
if (resJSON.getString("code").equals("000000")) { |
|
|
if (resJSON.getString("code").equals("000000")) { |
|
|
long timeMillis = System.currentTimeMillis(); |
|
|
long timeMillis = System.currentTimeMillis(); |
|
|
String orderId = System.currentTimeMillis() + ""; |
|
|
String orderId = System.currentTimeMillis() + ""; |
|
|
@ -123,6 +128,7 @@ public class YunmeiServiceImpl implements YunmeiService { |
|
|
map.put("notify_url", yunmeiConfig.getNotifyUrl()); |
|
|
map.put("notify_url", yunmeiConfig.getNotifyUrl()); |
|
|
map.put("biz_content", bizContent); |
|
|
map.put("biz_content", bizContent); |
|
|
map.put("sign", sign); |
|
|
map.put("sign", sign); |
|
|
|
|
|
//发送请求进行领取
|
|
|
String res = HttpUtils.sendPostJSON(yunmeiConfig.getUrl() + YunmeiConstant.CREATE_ORDER, JSONObject.toJSONString(map)); |
|
|
String res = HttpUtils.sendPostJSON(yunmeiConfig.getUrl() + YunmeiConstant.CREATE_ORDER, JSONObject.toJSONString(map)); |
|
|
JSONObject result = null; |
|
|
JSONObject result = null; |
|
|
RightsOrderEntity rightsOrderEntity = new RightsOrderEntity(); |
|
|
RightsOrderEntity rightsOrderEntity = new RightsOrderEntity(); |
|
|
@ -131,7 +137,7 @@ public class YunmeiServiceImpl implements YunmeiService { |
|
|
rightsOrderEntity.setLinkId(1059); |
|
|
rightsOrderEntity.setLinkId(1059); |
|
|
rightsOrderEntity.setLinkName("推广链接"); |
|
|
rightsOrderEntity.setLinkName("推广链接"); |
|
|
rightsOrderEntity.setProductNumber(params.getSkuId().toString()); |
|
|
rightsOrderEntity.setProductNumber(params.getSkuId().toString()); |
|
|
rightsOrderEntity.setRightsType("会员权益"); |
|
|
rightsOrderEntity.setRightsType(type); |
|
|
rightsOrderEntity.setStatus(0); |
|
|
rightsOrderEntity.setStatus(0); |
|
|
rightsOrderEntity.setMobile(params.getChargeAccountNumber()); |
|
|
rightsOrderEntity.setMobile(params.getChargeAccountNumber()); |
|
|
if (!Objects.equals(res, "")) { |
|
|
if (!Objects.equals(res, "")) { |
|
|
@ -171,11 +177,13 @@ public class YunmeiServiceImpl implements YunmeiService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//检查是否有领取资格
|
|
|
//检查是否有领取资格
|
|
|
private JSONObject checkQualification(String mobile) { |
|
|
private JSONObject checkQualification(String mobile, String type) { |
|
|
JSONObject resJSON = new JSONObject(); |
|
|
JSONObject resJSON = new JSONObject(); |
|
|
String code = "10026"; |
|
|
String code = "10026"; |
|
|
String reason = "暂无领取资格"; |
|
|
String reason = "暂无领取资格"; |
|
|
AliPayOrderEntity aliPayOrderEntity = aliPayOrderService.getOne(new QueryWrapper<AliPayOrderEntity>().eq("mobile", mobile).eq("status",1).select("mobile,order_time").orderByDesc("order_time")); |
|
|
AliPayOrderEntity aliPayOrderEntity = aliPayOrderService.getOne(new QueryWrapper<AliPayOrderEntity>() |
|
|
|
|
|
.eq("mobile", mobile).eq("status", 1) |
|
|
|
|
|
.select("mobile,order_time").orderByDesc("order_time")); |
|
|
if (aliPayOrderEntity == null) { //如果没有支付记录说明没有领取资格
|
|
|
if (aliPayOrderEntity == null) { //如果没有支付记录说明没有领取资格
|
|
|
code = "10024"; |
|
|
code = "10024"; |
|
|
reason = "暂无支付订单"; |
|
|
reason = "暂无支付订单"; |
|
|
@ -183,45 +191,100 @@ public class YunmeiServiceImpl implements YunmeiService { |
|
|
resJSON.put("reason", reason); |
|
|
resJSON.put("reason", reason); |
|
|
return resJSON; |
|
|
return resJSON; |
|
|
} |
|
|
} |
|
|
if (isWithin31Days(aliPayOrderEntity.getOrderTime())) { //如果支付记录在31天内说明满足条件
|
|
|
if (isWithinDays(aliPayOrderEntity.getOrderTime(), 31)) { //如果支付记录在31天内说明满足条件
|
|
|
|
|
|
if ("会员权益".equals(type)) { |
|
|
|
|
|
resJSON = checkMonthVipRightsOrder(mobile); |
|
|
|
|
|
return resJSON; |
|
|
|
|
|
} |
|
|
|
|
|
if ("现金卷".equals(type)) { |
|
|
|
|
|
resJSON = checkCashRollVipRightsOrder(mobile); |
|
|
|
|
|
return resJSON; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
resJSON.put("code", code); |
|
|
|
|
|
resJSON.put("reason", reason); |
|
|
|
|
|
return resJSON; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//检查包月会员类的产品是否有领取的权限
|
|
|
|
|
|
private JSONObject checkMonthVipRightsOrder(String mobile) { |
|
|
|
|
|
JSONObject resJSON = new JSONObject(); |
|
|
|
|
|
String code; |
|
|
|
|
|
String reason; |
|
|
//如果有支付记录查询是否31天内有过领取记录
|
|
|
//如果有支付记录查询是否31天内有过领取记录
|
|
|
RightsOrderEntity rightsOrder = rightsOrderService.getOne(new QueryWrapper<RightsOrderEntity>().eq("mobile", mobile).select("mobile,order_time").orderByDesc("order_time")); |
|
|
RightsOrderEntity rightsOrder = rightsOrderService.getOne(new QueryWrapper<RightsOrderEntity>() |
|
|
if (rightsOrder == null) { //如果有领取记录说明可以领取
|
|
|
.eq("mobile", mobile).eq("rights_type", "会员权益") |
|
|
|
|
|
.select("mobile,order_time").orderByDesc("order_time")); |
|
|
|
|
|
if (rightsOrder == null) { //如果没有领取记录说明可以领取
|
|
|
code = "000000"; |
|
|
code = "000000"; |
|
|
reason = "可以领取"; |
|
|
reason = "可以领取"; |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("reason", reason); |
|
|
resJSON.put("reason", reason); |
|
|
return resJSON; |
|
|
return resJSON; |
|
|
} |
|
|
} |
|
|
if (isWithin31Days(rightsOrder.getOrderTime())) { //如果在31天已经领取过就不能再次领取
|
|
|
if (isWithinDays(rightsOrder.getOrderTime(), 31)) { //如果在31天已经领取过就不能再次领取
|
|
|
code = "10025"; |
|
|
code = "10025"; |
|
|
reason = "已经领取过了"; |
|
|
reason = "已经领取过了"; |
|
|
|
|
|
} else { |
|
|
|
|
|
code = "000000"; |
|
|
|
|
|
reason = "可以领取"; |
|
|
|
|
|
} |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("reason", reason); |
|
|
resJSON.put("reason", reason); |
|
|
return resJSON; |
|
|
return resJSON; |
|
|
}else { |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//检查包月会员类的产品是否有领取的权限
|
|
|
|
|
|
private JSONObject checkCashRollVipRightsOrder(String mobile) { |
|
|
|
|
|
JSONObject resJSON = new JSONObject(); |
|
|
|
|
|
String code = "10026"; |
|
|
|
|
|
String reason = "暂无领取资格"; |
|
|
|
|
|
//如果有支付记录查询是否31天内有过领取记录
|
|
|
|
|
|
RightsOrderEntity rightsOrder = rightsOrderService.getOne(new QueryWrapper<RightsOrderEntity>() |
|
|
|
|
|
.eq("mobile", mobile).eq("rights_type", "现金卷") |
|
|
|
|
|
.select("mobile,order_time").orderByDesc("order_time")); |
|
|
|
|
|
if (rightsOrder == null) { //如果没有领取记录说明可以领取
|
|
|
code = "000000"; |
|
|
code = "000000"; |
|
|
reason = "可以领取"; |
|
|
reason = "可以领取"; |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("reason", reason); |
|
|
resJSON.put("reason", reason); |
|
|
return resJSON; |
|
|
return resJSON; |
|
|
} |
|
|
} |
|
|
} |
|
|
if (isWithinDays(rightsOrder.getOrderTime(), 31)) { //如果在31天已经领取过就不能再次领取
|
|
|
|
|
|
code = "10025"; |
|
|
|
|
|
reason = "已经领取过了"; |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("code", code); |
|
|
resJSON.put("reason", reason); |
|
|
resJSON.put("reason", reason); |
|
|
return resJSON; |
|
|
return resJSON; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//最早的一次签约时间要距离现在4个月以内
|
|
|
|
|
|
AliPaySigningOrderEntity paySigningOrderEntity = aliPaySigningOrderService.getOne(new QueryWrapper<AliPaySigningOrderEntity>() |
|
|
|
|
|
.eq("mobile", mobile) |
|
|
|
|
|
.select("mobile,order_time").orderByAsc("order_time")); |
|
|
|
|
|
if (isWithinDays(paySigningOrderEntity.getOrderTime(), 4 * 31)) { |
|
|
|
|
|
code = "000000"; |
|
|
|
|
|
reason = "可以领取"; |
|
|
|
|
|
resJSON.put("code", code); |
|
|
|
|
|
resJSON.put("reason", reason); |
|
|
|
|
|
return resJSON; |
|
|
} |
|
|
} |
|
|
|
|
|
resJSON.put("code", code); |
|
|
|
|
|
resJSON.put("reason", reason); |
|
|
|
|
|
return resJSON; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isWithin31Days(LocalDateTime date) { |
|
|
public static boolean isWithinDays(LocalDateTime date, int compare_day) { |
|
|
LocalDateTime today = LocalDateTime.now(); |
|
|
LocalDateTime today = LocalDateTime.now(); |
|
|
long days = ChronoUnit.DAYS.between(date, today); |
|
|
long days = ChronoUnit.DAYS.between(date, today); |
|
|
return days <= 31; |
|
|
return days <= compare_day; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
boolean within31Days = isWithin31Days(LocalDateTime.now().plusDays(-2)); |
|
|
boolean within31Days = isWithinDays(LocalDateTime.now().plusMonths(-5),4*31); |
|
|
System.out.println(within31Days); |
|
|
System.out.println(within31Days); |
|
|
} |
|
|
} |
|
|
// @Override
|
|
|
// @Override
|
|
|
|