|
|
@@ -119,10 +119,10 @@ public class UserController {
|
|
|
.eq(OrderDon::getStatus, OrderDon.Status.noPayment).last("limit 1"));
|
|
|
personalView.setIsNoPayment(orderDon != null ? true : false);
|
|
|
//礼品卡可用数量
|
|
|
- Number numOfGiftCard = beanSearcher.searchCount(GiftCardUserRecord.class, MapUtils.builder()
|
|
|
- .field(GiftCardUserRecord::getToUserId, userId)
|
|
|
- .field(GiftCardUserRecord::getIsPay, true)
|
|
|
- .field(GiftCardUserRecord::getIsUsed, false)
|
|
|
+ Number numOfGiftCard = beanSearcher.searchCount(GiftCardUserRecordView.class, MapUtils.builder()
|
|
|
+ .put("uid", String.format("(user_id = %s or to_user_id = %s)", userId, userId))
|
|
|
+ .field(GiftCardUserRecordView::getIsPay, true)
|
|
|
+ .field(GiftCardUserRecordView::getIsUsed, false)
|
|
|
.build());
|
|
|
personalView.setNumOfGiftCard(numOfGiftCard.intValue());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(personalView);
|
|
|
@@ -348,20 +348,16 @@ public class UserController {
|
|
|
|
|
|
/**
|
|
|
* 个人礼品卡列表
|
|
|
- * @param type 1自购,2、获赠
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/get/giftCard")
|
|
|
- public Result<SearchResult<GiftCardUserPayFrontView>> getGiftCard(@RequestParam(defaultValue = "1") Integer type) {
|
|
|
+ public Result<SearchResult<GiftCardUserPayFrontView>> getGiftCard() {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
- String condition = StrUtil.EMPTY;
|
|
|
- if (type == 1) {
|
|
|
- condition += String.format("and user_id = %s", userId);
|
|
|
- } else {
|
|
|
- condition += String.format("and to_user_id = %s", userId);
|
|
|
- }
|
|
|
+ String condition = String.format("and (user_id = %s or to_user_id = %s)", userId, userId);
|
|
|
SearchResult<GiftCardUserPayFrontView> view = beanSearcher.search(GiftCardUserPayFrontView.class, MapUtils.builder()
|
|
|
.put("condition", condition)
|
|
|
+ .put("uid", userId)
|
|
|
+ .orderBy(GiftCardUserRecordView::getIsUsed).asc()
|
|
|
.orderBy(GiftCardUserPayFrontView::getId).desc().build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(view);
|
|
|
}
|