订单 累计
This commit is contained in:
@@ -147,32 +147,4 @@ public class NotifyController {
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "<xml><ToUserName><![CDATA[gh_11fc27b7ef34]]></ToUserName><FromUserName><![CDATA[owWHW7Tzeh2gx3WmFsFSxBq2JUTk]]></FromUserName><CreateTime>1761095747</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[subscribe]]></Event><EventKey><![CDATA[qrscene_275]]></EventKey><Ticket><![CDATA[gQGF8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUTZDVHRTMXhmbUoxYUlYdk5GY2sAAgSsLvhoAwQAjScA]]></Ticket></xml>";
|
||||
// 2. 解析 XML 为 Map(便于获取字段)
|
||||
Map<String, String> messageMap = new HashMap<>();
|
||||
try {
|
||||
messageMap = parseXmlToMap(str);
|
||||
} catch (DocumentException e) {
|
||||
log.error("XML 解析失败,", e);
|
||||
}
|
||||
log.info("微信 POST 消息内容: {}", messageMap);
|
||||
//携带参数
|
||||
String eventKey = messageMap.get("EventKey");
|
||||
Long userId = null;
|
||||
if (eventKey != null && eventKey.startsWith("qrscene_")) {
|
||||
try {
|
||||
// 截取 "qrscene_" 前缀后的字符串(长度为 8),并转为 Long
|
||||
String numberStr = eventKey.substring("qrscene_".length());
|
||||
userId = Long.parseLong(numberStr);
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("EventKey 后缀不是有效数字,eventKey: {}", eventKey, e);
|
||||
}
|
||||
}
|
||||
System.out.println("userId: " + userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.czg.order.service;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付详情 服务层。
|
||||
*
|
||||
@@ -11,4 +13,5 @@ import com.czg.order.entity.OrderPayment;
|
||||
*/
|
||||
public interface OrderPaymentService extends IService<OrderPayment> {
|
||||
|
||||
BigDecimal countMemberInAmount(Long shopId, Long shopUserId);
|
||||
}
|
||||
|
||||
@@ -124,20 +124,16 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
|
||||
break;
|
||||
case "COST_AMOUNT":
|
||||
conditionMap.put("COST_AMOUNT", orderInfoService.getOneAs(query().select("IFNULL(sum(pay_amount), 0) as total_amount ").eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getUserId, shopUserInfo.getUserId())
|
||||
conditionMap.put("COST_AMOUNT", orderInfoService.getOneAs(query()
|
||||
.select("IFNULL(sum(pay_amount), 0) as total_amount ")
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.eq(OrderInfo::getUserId, shopUserInfo.getUserId())
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0);
|
||||
|
||||
break;
|
||||
case "RECHARGE_AMOUNT":
|
||||
conditionMap.put("RECHARGE_AMOUNT", paymentService.getOneAs(query().select("IFNULL(sum(amount), 0) as total_amount ")
|
||||
.eq(OrderPayment::getShopId, shopId)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, shopUserInfo.getId())
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class)
|
||||
conditionMap.put("RECHARGE_AMOUNT", paymentService.countMemberInAmount(shopId, shopUserInfo.getId())
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0);
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new CzgException("会员开通条件类型错误");
|
||||
@@ -422,12 +418,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()), BigDecimal.class)
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
case "RECHARGE_AMOUNT" ->
|
||||
paymentService.getOneAs(query().select("IFNULL(sum(amount), 0) as total_amount")
|
||||
.eq(OrderPayment::getShopId, shopId)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, shopUser.getId())
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class)
|
||||
paymentService.countMemberInAmount(shopId, shopUser.getId())
|
||||
.compareTo(new BigDecimal(item.getValue())) >= 0;
|
||||
default -> throw new CzgException("会员开通条件类型错误");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user