| @@ -85,7 +85,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| WxCouponMerchantMapper wxCouponMerchantMapper; | WxCouponMerchantMapper wxCouponMerchantMapper; | ||||
| @Autowired | @Autowired | ||||
| @Lazy | |||||
| WxRentContractService wxRentContractService; | WxRentContractService wxRentContractService; | ||||
| @Autowired | @Autowired | ||||
| @@ -48,8 +48,14 @@ public interface TtCouponService { | |||||
| @Async | @Async | ||||
| void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id); | 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 auditPass(Long id); | ||||
| ResultData auditRejected(Long id); | ResultData auditRejected(Long id); | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import com.iformall.domain.po.tt.TtUserCollect; | import com.iformall.domain.po.tt.TtUserCollect; | ||||
| import com.iformall.domain.po.tt.TtUserFollow; | |||||
| import com.iformall.enums.EnumTtCouponStatus; | import com.iformall.enums.EnumTtCouponStatus; | ||||
| import com.iformall.enums.EnumTtCouponType; | import com.iformall.enums.EnumTtCouponType; | ||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| @@ -42,6 +43,9 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| @Autowired | @Autowired | ||||
| TtUserCollectMapper ttUserCollectMapper; | TtUserCollectMapper ttUserCollectMapper; | ||||
| @Autowired | |||||
| TtUserFollowMapper ttUserFollowMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -191,6 +195,42 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| ttCouponMapper.addCollectCount(id); | 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 | @Override | ||||
| public ResultData auditPass(Long id) { | public ResultData auditPass(Long id) { | ||||
| TtCoupon byId = this.getById(id); | TtCoupon byId = this.getById(id); | ||||
| @@ -7,6 +7,7 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | 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.TtCoupon; | ||||
| import com.iformall.domain.po.tt.TtOrder; | import com.iformall.domain.po.tt.TtOrder; | ||||
| import com.iformall.douyin.pay.DouYinPayHelper; | import com.iformall.douyin.pay.DouYinPayHelper; | ||||
| @@ -16,6 +17,7 @@ import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.TtCUserService; | |||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.tt.TtCouponService; | import com.iformall.service.tt.TtCouponService; | ||||
| @@ -41,8 +43,11 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| @Autowired | @Autowired | ||||
| private TtCouponService ttCouponService; | private TtCouponService ttCouponService; | ||||
| // @Autowired | |||||
| // private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| private TtCUserService ttCUserService; | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @@ -55,8 +60,10 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| @Override | @Override | ||||
| public ResultData saveOrder(Long couponId,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity) { | public ResultData saveOrder(Long couponId,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity) { | ||||
| logger.info("OrderSave: couponId:" + couponId + "---cUserId:"+cUserId); | 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); | return new ResultData(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| TtOrder orderQ = new TtOrder(); | TtOrder orderQ = new TtOrder(); | ||||
| @@ -71,10 +78,10 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| return new ResultData(ErrorCode.ORDER_IS_FIND); | 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); | TtCoupon coupon = ttCouponService.getById(couponId); | ||||
| if (null == coupon) { | if (null == coupon) { | ||||
| return new ResultData(ErrorCode.TTCOUPON_IS_EMPTY); | return new ResultData(ErrorCode.TTCOUPON_IS_EMPTY); | ||||
| @@ -93,7 +100,7 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| TtOrder order = new TtOrder(); | TtOrder order = new TtOrder(); | ||||
| order.setId(idWorker.nextId()); | order.setId(idWorker.nextId()); | ||||
| order.updateTenantInfo(tenantEntity); | order.updateTenantInfo(tenantEntity); | ||||
| order.setCUserId(wxCUserBasicInfo.getId()); | |||||
| order.setCUserId(cUserId); | |||||
| order.setProductId(coupon.getId()); | order.setProductId(coupon.getId()); | ||||
| order.setType(payWay.getCode()); | order.setType(payWay.getCode()); | ||||
| order.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | order.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | ||||
| @@ -176,14 +183,17 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| if(!order.getCUserId().equals(memberId)){ | if(!order.getCUserId().equals(memberId)){ | ||||
| return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); | 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); | // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | ||||
| if(appInfo == null) { | if(appInfo == null) { | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| @@ -258,14 +268,16 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| if(!order.getCUserId().equals(memberId)){ | if(!order.getCUserId().equals(memberId)){ | ||||
| return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); | 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); | // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | ||||
| if(appInfo == null) { | if(appInfo == null) { | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| @@ -233,12 +233,13 @@ public class BaseController { | |||||
| } | } | ||||
| public Long getMemberId() { | 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() { | public String getIpAddr() { | ||||
| @@ -2,9 +2,11 @@ package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import com.iformall.enums.EnumTtCouponStatus; | import com.iformall.enums.EnumTtCouponStatus; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.tt.TtCouponService; | import com.iformall.service.tt.TtCouponService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -25,6 +27,9 @@ public class TtCouponController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private TtCouponService ttCouponService; | private TtCouponService ttCouponService; | ||||
| @Autowired | |||||
| private WxMerchantService wxMerchantService; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -58,7 +63,7 @@ public class TtCouponController extends BaseController { | |||||
| } | } | ||||
| TtCoupon byId = ttCouponService.getById(id); | TtCoupon byId = ttCouponService.getById(id); | ||||
| if(byId == null){ | if(byId == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到课程"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到数据"); | |||||
| } | } | ||||
| Long memberId; | Long memberId; | ||||
| try { | try { | ||||
| @@ -70,4 +75,63 @@ public class TtCouponController extends BaseController { | |||||
| return new ResultData(); | 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(); | |||||
| } | |||||
| } | } | ||||
| @@ -35,8 +35,6 @@ public class TtOrderController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @ApiOperation("分页订单列表接口") | @ApiOperation("分页订单列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||