From ebe1456da47427f61b7f1e52659ed264424d2cf2 Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 24 May 2021 16:14:18 +0800 Subject: [PATCH] tt --- .../service/impl/WxMerchantServiceImpl.java | 1 - .../iformall/service/tt/TtCouponService.java | 6 ++ .../service/tt/impl/TtCouponServiceImpl.java | 40 +++++++++++ .../service/tt/impl/TtOrderServiceImpl.java | 56 +++++++++------- .../iformall/controller/BaseController.java | 13 ++-- .../controller/TtCouponController.java | 66 ++++++++++++++++++- .../controller/TtOrderController.java | 2 - 7 files changed, 152 insertions(+), 32 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 73a729fdc..ad79dfc48 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -85,7 +85,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { WxCouponMerchantMapper wxCouponMerchantMapper; @Autowired - @Lazy WxRentContractService wxRentContractService; @Autowired diff --git a/mallinkService/src/main/java/com/iformall/service/tt/TtCouponService.java b/mallinkService/src/main/java/com/iformall/service/tt/TtCouponService.java index c848b132b..7ede74487 100644 --- a/mallinkService/src/main/java/com/iformall/service/tt/TtCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/tt/TtCouponService.java @@ -48,8 +48,14 @@ public interface TtCouponService { @Async void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id); + void cancelCollect(Long memberId, Long id); + + @Async + void followMerchant(TenantEntity tenantEntity, Long memberId, Long id); + void cancelFollow(Long memberId, Long id); ResultData auditPass(Long id); ResultData auditRejected(Long id); + } diff --git a/mallinkService/src/main/java/com/iformall/service/tt/impl/TtCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/tt/impl/TtCouponServiceImpl.java index 2033efb7b..6451dee0e 100644 --- a/mallinkService/src/main/java/com/iformall/service/tt/impl/TtCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/tt/impl/TtCouponServiceImpl.java @@ -10,6 +10,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.tt.TtCoupon; import com.iformall.domain.po.tt.TtUserCollect; +import com.iformall.domain.po.tt.TtUserFollow; import com.iformall.enums.EnumTtCouponStatus; import com.iformall.enums.EnumTtCouponType; import com.iformall.enums.EnumYesOrNo; @@ -42,6 +43,9 @@ public class TtCouponServiceImpl implements TtCouponService { @Autowired TtUserCollectMapper ttUserCollectMapper; + @Autowired + TtUserFollowMapper ttUserFollowMapper; + @Override public PageInfo listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { @@ -191,6 +195,42 @@ public class TtCouponServiceImpl implements TtCouponService { ttCouponMapper.addCollectCount(id); } + @Override + public void cancelCollect(Long memberId, Long id) { + TtUserCollect userCollect = new TtUserCollect(); + userCollect.setUserId(memberId); + userCollect.setCouponId(id); + int delete = ttUserCollectMapper.delete(new QueryWrapper<>(userCollect)); + if(delete > 0){ + ttCouponMapper.reduceCollectCount(id); + } + } + + @Override + public void followMerchant(TenantEntity tenantEntity, Long memberId, Long id) { + final IdWorker idWorker = IdWorker.get(); + TtUserFollow userFollow = new TtUserFollow(); + userFollow.setId(idWorker.nextId()); + userFollow.updateTenantInfo(tenantEntity); + userFollow.setUserId(memberId); + userFollow.setMerchernId(id); + userFollow.setCreateDate(new Date()); + userFollow.setUpdateDate(new Date()); + try { + ttUserFollowMapper.insert(userFollow); + } catch (Exception e) { +// e.printStackTrace(); + } + } + + @Override + public void cancelFollow(Long memberId, Long id) { + TtUserFollow userFollow = new TtUserFollow(); + userFollow.setUserId(memberId); + userFollow.setMerchernId(id); + int delete = ttUserFollowMapper.delete(new QueryWrapper<>(userFollow)); + } + @Override public ResultData auditPass(Long id) { TtCoupon byId = this.getById(id); diff --git a/mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java index 7bae86752..960352abf 100644 --- a/mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java @@ -7,6 +7,7 @@ import com.iformall.common.IdWorker; import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.po.tt.TtCUser; import com.iformall.domain.po.tt.TtCoupon; import com.iformall.domain.po.tt.TtOrder; import com.iformall.douyin.pay.DouYinPayHelper; @@ -16,6 +17,7 @@ import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; +import com.iformall.service.TtCUserService; import com.iformall.service.WxAppinfoService; import com.iformall.service.WxCUserBasicInfoService; import com.iformall.service.tt.TtCouponService; @@ -41,8 +43,11 @@ public class TtOrderServiceImpl implements TtOrderService { @Autowired private TtCouponService ttCouponService; +// @Autowired +// private WxCUserBasicInfoService wxCUserBasicInfoService; + @Autowired - private WxCUserBasicInfoService wxCUserBasicInfoService; + private TtCUserService ttCUserService; @Autowired private WxAppinfoService wxAppinfoService; @@ -55,8 +60,10 @@ public class TtOrderServiceImpl implements TtOrderService { @Override public ResultData saveOrder(Long couponId,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity) { logger.info("OrderSave: couponId:" + couponId + "---cUserId:"+cUserId); - WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,tenantEntity.getFinalTenantId()); - if(wxCUserBasicInfo == null){ + TtCUser byId = ttCUserService.getById(cUserId, tenantEntity.getTenantId()); +// WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,tenantEntity.getFinalTenantId()); +// if(wxCUserBasicInfo == null){ + if(byId == null){ return new ResultData(ErrorCode.USER_IS_EMPTY); } TtOrder orderQ = new TtOrder(); @@ -71,10 +78,10 @@ public class TtOrderServiceImpl implements TtOrderService { return new ResultData(ErrorCode.ORDER_IS_FIND); } - if (wxCUserBasicInfo.getStatus().equals(EnumCUserBasicInfoStatus.LOCKED.getCode())) { - logger.info("会员权益被锁定:cUserId:" + cUserId); - return new ResultData(ErrorCode.MEMBER_IS_LOCKED); - } +// if (wxCUserBasicInfo.getStatus().equals(EnumCUserBasicInfoStatus.LOCKED.getCode())) { +// logger.info("会员权益被锁定:cUserId:" + cUserId); +// return new ResultData(ErrorCode.MEMBER_IS_LOCKED); +// } TtCoupon coupon = ttCouponService.getById(couponId); if (null == coupon) { return new ResultData(ErrorCode.TTCOUPON_IS_EMPTY); @@ -93,7 +100,7 @@ public class TtOrderServiceImpl implements TtOrderService { TtOrder order = new TtOrder(); order.setId(idWorker.nextId()); order.updateTenantInfo(tenantEntity); - order.setCUserId(wxCUserBasicInfo.getId()); + order.setCUserId(cUserId); order.setProductId(coupon.getId()); order.setType(payWay.getCode()); order.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); @@ -176,14 +183,17 @@ public class TtOrderServiceImpl implements TtOrderService { if(!order.getCUserId().equals(memberId)){ return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); } - WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); - if ( null == wxCUserBasicInfo) { - logger.error("会员用户不存在."+memberId); - return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"会员用户不存在."+memberId); - } - if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { - return new ResultData(ErrorCode.MEMBER_IS_LOCKED); + TtCUser byId = ttCUserService.getById(memberId, tenantEntity.getTenantId()); +// WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); +// if ( null == wxCUserBasicInfo) { + if ( byId == null) { + logger.error("用户不存在."+memberId); + return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"用户不存在."+memberId); } +// if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { +// return new ResultData(ErrorCode.MEMBER_IS_LOCKED); +// } + // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); if(appInfo == null) { return new ResultData(ErrorCode.APP_ID_NOT_FOUND); @@ -258,14 +268,16 @@ public class TtOrderServiceImpl implements TtOrderService { if(!order.getCUserId().equals(memberId)){ return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); } - WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); - if ( null == wxCUserBasicInfo) { - logger.error("会员用户不存在."+memberId); - return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"会员用户不存在."+memberId); - } - if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { - return new ResultData(ErrorCode.MEMBER_IS_LOCKED); + TtCUser byId = ttCUserService.getById(memberId, tenantEntity.getTenantId()); +// WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); +// if ( null == wxCUserBasicInfo) { + if ( byId == null) { + logger.error("用户不存在."+memberId); + return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"用户不存在."+memberId); } +// if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { +// return new ResultData(ErrorCode.MEMBER_IS_LOCKED); +// } // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); if(appInfo == null) { return new ResultData(ErrorCode.APP_ID_NOT_FOUND); diff --git a/mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java index b46c99732..825ca6728 100644 --- a/mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java @@ -233,12 +233,13 @@ public class BaseController { } public Long getMemberId() { - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); - if(memberId == null){ - throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER); - } - return memberId; +// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); +// Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); +// if(memberId == null){ +// throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER); +// } +// return memberId; + return getTtCUser().getId(); } public String getIpAddr() { diff --git a/mallinkTTCApi/src/main/java/com/iformall/controller/TtCouponController.java b/mallinkTTCApi/src/main/java/com/iformall/controller/TtCouponController.java index 4e9615294..ec4952c76 100644 --- a/mallinkTTCApi/src/main/java/com/iformall/controller/TtCouponController.java +++ b/mallinkTTCApi/src/main/java/com/iformall/controller/TtCouponController.java @@ -2,9 +2,11 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.tt.TtCoupon; import com.iformall.enums.EnumTtCouponStatus; import com.iformall.exception.MallinkException; +import com.iformall.service.WxMerchantService; import com.iformall.service.tt.TtCouponService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -25,6 +27,9 @@ public class TtCouponController extends BaseController { @Autowired private TtCouponService ttCouponService; + @Autowired + private WxMerchantService wxMerchantService; + @ApiOperation("分页列表接口") @GetMapping("list") @ApiImplicitParams({ @@ -58,7 +63,7 @@ public class TtCouponController extends BaseController { } TtCoupon byId = ttCouponService.getById(id); if(byId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到课程"); + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到数据"); } Long memberId; try { @@ -70,4 +75,63 @@ public class TtCouponController extends BaseController { return new ResultData(); } + @ApiOperation("取消收藏") + @GetMapping("/cancelCollect") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData cancelCollect(@RequestParam Long id) { + logger.debug("[" + getIpAddr() + "] TtCouponController::collectCoupon"); + if (id == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + Long memberId; + try { + memberId = getMemberId(); + } catch (MallinkException e) { + return new ResultData(e.getErrorCode(), e.getMessage()); + } + ttCouponService.cancelCollect(memberId,id); + return new ResultData(); + } + + + @ApiOperation("关注") + @GetMapping("/followMerchant") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData followMerchant(@RequestParam Long id) { + logger.debug("[" + getIpAddr() + "] TtCouponController::followMerchant"); + if (id == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + WxMerchant byId = wxMerchantService.getById(id); + if(byId == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到数据"); + } + Long memberId; + try { + memberId = getMemberId(); + } catch (MallinkException e) { + return new ResultData(e.getErrorCode(), e.getMessage()); + } + ttCouponService.followMerchant(getTenantInfo(),memberId,byId.getId()); + return new ResultData(); + } + + @ApiOperation("取消关注") + @GetMapping("/cancelFollow") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData cancelFollow(@RequestParam Long id) { + logger.debug("[" + getIpAddr() + "] TtCouponController::cancelFollow"); + if (id == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + Long memberId; + try { + memberId = getMemberId(); + } catch (MallinkException e) { + return new ResultData(e.getErrorCode(), e.getMessage()); + } + ttCouponService.cancelFollow(memberId,id); + return new ResultData(); + } + } diff --git a/mallinkTTCApi/src/main/java/com/iformall/controller/TtOrderController.java b/mallinkTTCApi/src/main/java/com/iformall/controller/TtOrderController.java index 7901cb2d6..cb0843a60 100644 --- a/mallinkTTCApi/src/main/java/com/iformall/controller/TtOrderController.java +++ b/mallinkTTCApi/src/main/java/com/iformall/controller/TtOrderController.java @@ -35,8 +35,6 @@ public class TtOrderController extends BaseController { @Autowired private WxAppinfoService wxAppinfoService; - @Autowired - private WxCUserBasicInfoService wxCUserBasicInfoService; @ApiOperation("分页订单列表接口") @GetMapping("list")