|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
@ -62,6 +63,8 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getOrder() {
|
|
|
|
@ -76,6 +79,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject takeEncourageMoney(String orderId, String visitorOpenId) {
|
|
|
|
|
logger.info("=====takeEncourageMoney+"+orderId);
|
|
|
|
|
JSONObject config = currentEncourageConfig();
|
|
|
|
|
if (config != null) {
|
|
|
|
|
if (customerEncourageMoneyAccessLogMapper.findByOrderId(orderId) != null) {
|
|
|
|
@ -88,6 +92,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
JSONObject order = orderMapper.find(orderId);
|
|
|
|
|
String channel = order.getString("channel");
|
|
|
|
|
String openId = order.getString("customer_id");
|
|
|
|
|
Date tradeDate = DateUtils.truncate(order.getDate("create_time"), Calendar.DATE);
|
|
|
|
|
if (tradeDate.before(config.getDate("from_date")) || !tradeDate.before(config.getDate("to_date"))) {
|
|
|
|
@ -102,9 +107,12 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
|
|
|
|
|
logger.debug("测试模式,不是管理员");
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject member = customerMembershipMapper.findByPaymentOpenId(openId);
|
|
|
|
|
if (member == null) {
|
|
|
|
|
member = new JSONObject();
|
|
|
|
|
if ("Wechat".equals(channel)){
|
|
|
|
|
JSONObject relation = customerMapper.findCustomerByOpenId(openId);
|
|
|
|
|
if (relation == null) {
|
|
|
|
|
logger.debug("用户关系不存在");
|
|
|
|
@ -118,6 +126,22 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
|
|
|
|
|
member.put("encourage_balance", 0);
|
|
|
|
|
customerMembershipMapper.saveMember(member);
|
|
|
|
|
}
|
|
|
|
|
if ("Alipay".equals(channel)){
|
|
|
|
|
JSONObject relation = managerCustomerRelationAlipayMapper.findCustomerByUserId(openId);
|
|
|
|
|
if (relation == null) {
|
|
|
|
|
logger.debug("用户关系不存在");
|
|
|
|
|
return new JSONObject();
|
|
|
|
|
}
|
|
|
|
|
member.put("payment_openid", openId);
|
|
|
|
|
member.put("kanga_openid", openId.concat("-kanga_openid"));
|
|
|
|
|
member.put("redpack_openid", openId.concat("-redpack_openid"));
|
|
|
|
|
member.put("attend_time", new Date());
|
|
|
|
|
member.put("member_point", -1);
|
|
|
|
|
member.put("encourage_balance", 0);
|
|
|
|
|
customerMembershipMapper.saveMember(member);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
String memberId = member.getString("member_id");
|
|
|
|
|
int usedOrders = customerEncourageMoneyAccessLogMapper.countOrders(memberId, new Date());
|
|
|
|
|
if (usedOrders >= config.getIntValue("max_count")) {
|
|
|
|
|