├── .DS_Store ├── marketing-rds ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ ├── .DS_Store │ │ │ ├── db │ │ │ │ └── .DS_Store │ │ │ ├── application-local.yml │ │ │ └── application-dev.yml │ │ ├── .DS_Store │ │ └── java │ │ │ └── lk │ │ │ └── project │ │ │ └── marketing │ │ │ └── rds │ │ │ └── MarketingRdsApplication.java │ └── .DS_Store ├── .DS_Store └── pom.xml ├── marketing-api ├── .DS_Store ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ ├── application-dev.yml │ │ ├── application-local.yml │ │ └── application-com.yml │ │ └── java │ │ └── lk │ │ └── project │ │ └── marketing │ │ └── api │ │ ├── MarketingApiApplication.java │ │ ├── config │ │ └── CorsConfig.java │ │ ├── controller │ │ ├── CouponReceiveController.java │ │ ├── CouponSummaryController.java │ │ └── SettleAccountController.java │ │ └── common │ │ └── BaseController.java └── Docker │ └── Dockerfile ├── 营销中心用例设计细则说明书V1.0.docx ├── marketing-base ├── .DS_Store └── src │ └── main │ └── java │ └── lk │ └── project │ └── marketing │ └── base │ ├── bo │ ├── CartBo.java │ ├── UseCouponBo.java │ ├── GetAvailableCouponSelectListBo.java │ ├── CouponSortBo.java │ ├── PagerBaseRespBo.java │ ├── OrderAvailableCouponsRespBo.java │ ├── OrderItemAvailableCouponsRespBo.java │ ├── CalcCouponReduceResultBo.java │ ├── SelectCouponUseBo.java │ ├── QRCodeBo.java │ ├── PagerBaseReqBo.java │ ├── SubTotalReduceInfoBo.java │ ├── CouponReceiveDetailInfoBo.java │ ├── CouponConsumeDetailBo.java │ ├── CouponReceiveBo.java │ ├── CalcTotalReduceByEachCouponReqBo.java │ ├── CouponReceiveReqBo.java │ ├── DynamicSelectCouponResultRespBo.java │ ├── CouponsReduceAmountBo.java │ ├── SelectCouponReceiveInfoBo.java │ ├── CouponConsumeBo.java │ ├── CouponTemplateInfoBo.java │ ├── CouponSummaryBo.java │ ├── QueryCouponReqBo.java │ ├── MemberBo.java │ ├── DynamicSelectCouponReqBo.java │ ├── CouponConsumeHistoryRespBo.java │ ├── CouponReceiveHistoryBo.java │ ├── QueryAccountRuleReqBo.java │ ├── DynamicCalcSelectedCouponBo.java │ ├── OrderBo.java │ ├── OrderItemBo.java │ ├── ProductBo.java │ ├── AccountRuleReqBo.java │ ├── OrderSettleResultBo.java │ ├── UserCouponConsumeProcessBo.java │ ├── CouponReqBo.java │ ├── CouponSummaryDetailBo.java │ ├── AvailableCouponDetailsBo.java │ └── ActivityReqBo.java │ ├── entity │ ├── CouponReceiveDetail.java │ ├── CouponConsumeDetail.java │ ├── PromotionRule.java │ └── CouponSummary.java │ └── enums │ ├── CouponStatusEnum.java │ ├── CouponUsageTypeEnum.java │ ├── PromotionRuleTypeEnum.java │ ├── CouponTypeEnum.java │ ├── CouponAccumulateTypeEnum.java │ ├── CouponConsumeStatusEnum.java │ ├── CouponReceiveStatusEnum.java │ ├── PromotionActivityStatusEnum.java │ └── AccountRuleThresholdTypeEnum.java ├── marketing-client ├── .DS_Store └── src │ └── main │ └── java │ ├── lk │ └── project │ │ └── marketing │ │ └── client │ │ ├── rpc │ │ ├── CouponSummaryManagementInterface.java │ │ ├── CouponInterface.java │ │ ├── ActivityManagementInterface.java │ │ ├── CouponReceiveInterface.java │ │ ├── CouponSummaryInterface.java │ │ ├── SettleAccountInterface.java │ │ ├── CouponManagementInterface.java │ │ ├── AccountRuleManagementInterface.java │ │ ├── CartInterface.java │ │ └── CouponConsumeInterface.java │ │ ├── dto │ │ ├── UserOrderSettleReqDto.java │ │ ├── QueryOrderConsumedCouponReqDto.java │ │ ├── UseCouponDto.java │ │ ├── GetAvailableCouponDetailListDto.java │ │ ├── ProduceCouponDto.java │ │ ├── CartDto.java │ │ ├── ConsumeCouponReqDto.java │ │ ├── OrderSettlementReqDto.java │ │ ├── BaseResultDto.java │ │ ├── QueryOrderMatchedCouponDto.java │ │ ├── SortAvailableMatchedCouponsReqDto.java │ │ ├── QueryItemMatchedCouponReqDto.java │ │ ├── PagerBaseResponseDto.java │ │ ├── OrderItemAvailableCouponsRespDto.java │ │ ├── PagerBaseRequestDto.java │ │ ├── UpdateCouponsResultDto.java │ │ ├── CouponReceiveReqDto.java │ │ ├── DynamicCalcSelectedCouponDto.java │ │ ├── QueryCouponReqDto.java │ │ ├── MemberDto.java │ │ ├── DynamicSelectCouponReqDto.java │ │ ├── AvailableCouponDetailsDto.java │ │ ├── QueryAccountRuleReqDto.java │ │ ├── SelectCouponReceiveInfoDto.java │ │ ├── CouponReduceInfoDto.java │ │ ├── OrderDto.java │ │ ├── OrderItemDto.java │ │ ├── ProductDto.java │ │ ├── CouponReqDto.java │ │ ├── AccountRuleReqDto.java │ │ └── ActivityReqDto.java │ │ └── utils │ │ └── JsonUtil.java │ └── MarketingClientApplication.java ├── marketing-service ├── .DS_Store ├── src │ ├── .DS_Store │ ├── main │ │ ├── .DS_Store │ │ ├── java │ │ │ └── lk │ │ │ │ └── project │ │ │ │ └── marketing │ │ │ │ ├── service │ │ │ │ ├── CouponManagerService.java │ │ │ │ ├── CouponBatchService.java │ │ │ │ ├── CouponConsumeDetailService.java │ │ │ │ ├── impl │ │ │ │ │ ├── ActivityServiceImpl.java │ │ │ │ │ ├── PromotionRuleServiceImpl.java │ │ │ │ │ └── CouponConsumeDetailServiceImpl.java │ │ │ │ ├── rpc │ │ │ │ │ ├── CouponInterfaceImpl.java │ │ │ │ │ ├── CouponSummaryInterfaceImpl.java │ │ │ │ │ ├── CouponReceiveInterfaceImpl.java │ │ │ │ │ └── pojo │ │ │ │ │ │ └── BaseResponse.java │ │ │ │ ├── SettleAccountService.java │ │ │ │ ├── ActivityService.java │ │ │ │ ├── CartService.java │ │ │ │ ├── CouponReceiveDetailService.java │ │ │ │ ├── CouponMemberCenterService.java │ │ │ │ ├── CouponService.java │ │ │ │ ├── CouponSummaryService.java │ │ │ │ └── CouponReceiveService.java │ │ │ │ ├── mapper │ │ │ │ ├── CouponConsumeMapper.java │ │ │ │ ├── AccountRuleMapper.java │ │ │ │ ├── PromotionRuleMapper.java │ │ │ │ ├── CouponConsumeDetailMapper.java │ │ │ │ ├── CouponMapper.java │ │ │ │ ├── CouponSummaryMapper.java │ │ │ │ ├── CouponReceiveDetailMapper.java │ │ │ │ ├── CouponReceiveMapper.java │ │ │ │ └── ActivityMapper.java │ │ │ │ ├── repository │ │ │ │ ├── AccountRuleRepository.java │ │ │ │ ├── PromotionRuleRepository.java │ │ │ │ ├── CouponRepository.java │ │ │ │ └── ActivityRepository.java │ │ │ │ ├── init │ │ │ │ └── MarketingServiceApplication.java │ │ │ │ └── config │ │ │ │ └── RedisConfig.java │ │ └── resources │ │ │ ├── application.yml │ │ │ ├── application-com.yml │ │ │ └── mapper │ │ │ ├── PromotionRule.xml │ │ │ ├── CouponConsume.xml │ │ │ └── CouponConsumeDetail.xml │ └── test │ │ ├── .DS_Store │ │ └── java │ │ ├── .DS_Store │ │ └── lk │ │ ├── .DS_Store │ │ └── project │ │ ├── .DS_Store │ │ └── marketing │ │ ├── .DS_Store │ │ ├── utils │ │ ├── DateConvertTimeTest.java │ │ └── MatrixToImageTest.java │ │ └── repository │ │ └── CouponWithdrawRepositoryTest.java └── Docker │ └── Dockerfile ├── marketing-backend-api ├── .DS_Store ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ ├── application-dev.yml │ │ ├── application-local.yml │ │ ├── application-com.yml │ │ └── config │ │ │ └── dubbo-consumer.xml │ │ └── java │ │ └── lk │ │ └── project │ │ └── marketing │ │ └── backend │ │ └── api │ │ ├── controller │ │ ├── CouponConsumeController.java │ │ ├── CouponReceiveController.java │ │ ├── SettleAccountController.java │ │ ├── CouponSummaryController.java │ │ ├── CouponManagementController.java │ │ └── AccountRuleManagementController.java │ │ ├── MarketingBackendApiApplication.java │ │ ├── config │ │ └── CorsConfig.java │ │ └── common │ │ └── BaseController.java └── Docker │ └── Dockerfile └── marketing-backend-service ├── .DS_Store ├── src ├── .DS_Store └── main │ ├── .DS_Store │ ├── java │ └── lk │ │ └── project │ │ └── marketing │ │ └── backend │ │ ├── service │ │ ├── rpc │ │ │ ├── ActivityManagementInterfaceImpl.java │ │ │ ├── CouponSummaryManagementInterfaceImpl.java │ │ │ └── pojo │ │ │ │ └── BaseResponse.java │ │ ├── CouponSummaryManagementService.java │ │ ├── PromotionRuleManagementService.java │ │ ├── SettleAccountManagementService.java │ │ ├── CouponConsumeManagementService.java │ │ ├── CouponReceiveManagementService.java │ │ ├── CouponMemberManagementService.java │ │ ├── impl │ │ │ ├── CouponConsumeManagementServiceImpl.java │ │ │ ├── SettleAccountManagementServiceImpl.java │ │ │ ├── PromotionRuleManagementServiceImpl.java │ │ │ ├── CouponReceiveManagementServiceImpl.java │ │ │ ├── CouponSummaryManagementServiceImpl.java │ │ │ └── ActivityManagementServiceImpl.java │ │ ├── ActivityManagementService.java │ │ ├── CouponManagementService.java │ │ └── AccountRuleManagementService.java │ │ ├── mapper │ │ ├── CouponConsumeManagementMapper.java │ │ ├── CouponManagementMapper.java │ │ ├── AccountRuleManagementMapper.java │ │ ├── PromotionRuleManagementMapper.java │ │ ├── CouponConsumeDetailManagementMapper.java │ │ ├── CouponSummaryManagementMapper.java │ │ ├── CouponReceiveDetailManagementMapper.java │ │ ├── CouponReceiveManagementMapper.java │ │ └── ActivityManagementMapper.java │ │ ├── repository │ │ ├── CouponReceiveManagementRepository.java │ │ ├── CouponConsumeDetailManagementRepository.java │ │ ├── CouponReceiveDetailManagementRepository.java │ │ ├── CouponManagementRepository.java │ │ ├── AccountRuleManagementRepository.java │ │ ├── PromotionRuleManagementRepository.java │ │ └── ActivityManagementRepository.java │ │ ├── init │ │ └── MarketingBackendServiceApplication.java │ │ └── config │ │ └── RedisConfig.java │ └── resources │ ├── application.yml │ ├── application-com.yml │ └── mapper │ ├── PromotionRuleManagement.xml │ └── CouponConsumeManagement.xml └── Docker └── Dockerfile /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/.DS_Store -------------------------------------------------------------------------------- /marketing-rds/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev -------------------------------------------------------------------------------- /marketing-api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-api/.DS_Store -------------------------------------------------------------------------------- /marketing-rds/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-rds/.DS_Store -------------------------------------------------------------------------------- /营销中心用例设计细则说明书V1.0.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/营销中心用例设计细则说明书V1.0.docx -------------------------------------------------------------------------------- /marketing-base/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-base/.DS_Store -------------------------------------------------------------------------------- /marketing-client/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-client/.DS_Store -------------------------------------------------------------------------------- /marketing-rds/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-rds/src/.DS_Store -------------------------------------------------------------------------------- /marketing-service/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/.DS_Store -------------------------------------------------------------------------------- /marketing-backend-api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-backend-api/.DS_Store -------------------------------------------------------------------------------- /marketing-rds/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-rds/src/main/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/.DS_Store -------------------------------------------------------------------------------- /marketing-backend-service/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-backend-service/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/main/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/test/.DS_Store -------------------------------------------------------------------------------- /marketing-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: local 4 | jackson: 5 | date-format: yyyy-MM-dd -------------------------------------------------------------------------------- /marketing-backend-service/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-backend-service/src/.DS_Store -------------------------------------------------------------------------------- /marketing-backend-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: com 4 | jackson: 5 | date-format: yyyy-MM-dd -------------------------------------------------------------------------------- /marketing-rds/src/main/resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-rds/src/main/resources/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/test/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/test/java/.DS_Store -------------------------------------------------------------------------------- /marketing-backend-service/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-backend-service/src/main/.DS_Store -------------------------------------------------------------------------------- /marketing-rds/src/main/resources/db/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-rds/src/main/resources/db/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/test/java/lk/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/project/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/test/java/lk/project/.DS_Store -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/project/marketing/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gupei2015/marketing-coupon/HEAD/marketing-service/src/test/java/lk/project/marketing/.DS_Store -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponSummaryManagementInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | public interface CouponSummaryManagementInterface { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/rpc/ActivityManagementInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.rpc; 2 | 3 | public class ActivityManagementInterfaceImpl { 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/UserOrderSettleReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | public class UserOrderSettleReqDto implements Serializable { 6 | } 7 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponManagerService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | /** 4 | * Created by gupei on 2018/9/18. 5 | * 优惠券后台管理接口 6 | */ 7 | public interface CouponManagerService { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponBatchService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | /** 4 | * Created by gupei on 2018/9/18. 5 | * 批量发券、用券;活动定时启动/停止失效 6 | */ 7 | public interface CouponBatchService { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/CouponSummaryManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * 优惠券汇总后台管理服务 5 | * Created by luchao on 2018/12/25. 6 | */ 7 | public interface CouponSummaryManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/PromotionRuleManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * 促销规则后台管理服务 5 | * Created by luchao on 2018/12/25. 6 | */ 7 | public interface PromotionRuleManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/SettleAccountManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * Created by luchao on 2018/12/25. 5 | * 订单结算相关后台服务 6 | */ 7 | public interface SettleAccountManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/CouponConsumeManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * 优惠券用劵相关后台管理服务 5 | * Created by luchao on 2018/12/25. 6 | */ 7 | public interface CouponConsumeManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/CouponReceiveManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * 优惠券领劵/发放后台管理服务 5 | * Created by luchao on 2018/12/25. 6 | */ 7 | public interface CouponReceiveManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/CouponMemberManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | /** 4 | * 优惠券会员中心后台管理服务(我的优惠券、积分) 5 | * Created by luchao on 2018/12/25. 6 | */ 7 | public interface CouponMemberManagementService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponConsumeDetailService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.entity.CouponConsumeDetail; 4 | 5 | /** 6 | * Created by zhanghongda on 2018/10/31. 7 | */ 8 | public interface CouponConsumeDetailService { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.vo.ResponseVO; 4 | 5 | /** 6 | * Created by alexlu on 2018/10/30. 7 | */ 8 | public interface CouponInterface { 9 | 10 | ResponseVO getUserCouponList(); 11 | } 12 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponConsumeMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponConsume; 5 | 6 | /** 7 | * Created by zhanghongda on 2018/10/31. 8 | */ 9 | public interface CouponConsumeMapper extends BaseMapper { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/impl/ActivityServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.impl; 2 | 3 | 4 | import lk.project.marketing.service.ActivityService; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by gupei on 2018/09/11. 9 | */ 10 | @Service 11 | public class ActivityServiceImpl implements ActivityService { 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/impl/PromotionRuleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.impl; 2 | 3 | import lk.project.marketing.service.PromotionRuleService; 4 | import org.springframework.stereotype.Service; 5 | 6 | 7 | /** 8 | * Created by alexlu on 2018/10/29. 9 | */ 10 | @Service 11 | public class PromotionRuleServiceImpl implements PromotionRuleService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/QueryOrderConsumedCouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | @Data 11 | public class QueryOrderConsumedCouponReqDto implements Serializable { 12 | /** 13 | * 订单ID 14 | */ 15 | private String orderId; 16 | } 17 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/UseCouponDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class UseCouponDto implements Serializable { 9 | /** 10 | * 消费优惠券(模板)ID 11 | */ 12 | private Long couponId; 13 | 14 | /** 15 | * 本次消费优惠券数量 16 | */ 17 | private Long couponQuantity; 18 | } 19 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponConsumeManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponConsume; 5 | 6 | /** 7 | * Created by zhanghongda on 2018/10/31. 8 | */ 9 | public interface CouponConsumeManagementMapper extends BaseMapper { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-rds/src/main/java/lk/project/marketing/rds/MarketingRdsApplication.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.rds; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MarketingRdsApplication { 8 | 9 | public static void main(String... args) { 10 | SpringApplication.run(MarketingRdsApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/GetAvailableCouponDetailListDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @Data 9 | public class GetAvailableCouponDetailListDto implements Serializable { 10 | 11 | /** 12 | * 可使用的优惠券列表 13 | */ 14 | private List availableCouponDetailList; 15 | } 16 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/rpc/CouponSummaryManagementInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.rpc; 2 | 3 | 4 | import lk.project.marketing.backend.service.rpc.pojo.BaseResponse; 5 | import lk.project.marketing.client.rpc.CouponSummaryManagementInterface; 6 | 7 | public class CouponSummaryManagementInterfaceImpl extends BaseResponse implements CouponSummaryManagementInterface { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/ProduceCouponDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class ProduceCouponDto implements Serializable { 9 | 10 | /** 11 | * 领券请求Dto 12 | */ 13 | private CouponReceiveReqDto couponReceiveReqDto; 14 | 15 | /** 16 | * 会员信息Dto 17 | */ 18 | private MemberDto memberDto; 19 | } 20 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/ActivityManagementInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.ActivityReqDto; 4 | import lk.project.marketing.client.vo.ResponseVO; 5 | 6 | public interface ActivityManagementInterface { 7 | 8 | /** 9 | * 新增或更新促销活动 10 | * @param activityReqDto 11 | * @return 12 | */ 13 | ResponseVO saveActivity(ActivityReqDto activityReqDto); 14 | } 15 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/CouponConsumeManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | import lk.project.marketing.backend.service.CouponConsumeManagementService; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * Created by alexlu on 2018/10/29. 8 | */ 9 | @Service 10 | public class CouponConsumeManagementServiceImpl implements CouponConsumeManagementService { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/SettleAccountManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | import lk.project.marketing.backend.service.SettleAccountManagementService; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * Created by alexlu on 2018/11/20. 8 | */ 9 | @Service 10 | public class SettleAccountManagementServiceImpl implements SettleAccountManagementService { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CartBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class CartBo { 9 | 10 | /** 11 | * 购物车所属商家id 12 | */ 13 | private String shopId; 14 | 15 | /** 16 | * 购物车所属商铺名称 17 | */ 18 | private String shopName; 19 | 20 | /** 21 | * 购物车下订单项列表 22 | */ 23 | private List productBoList; 24 | } 25 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/PromotionRuleManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | import lk.project.marketing.backend.service.PromotionRuleManagementService; 4 | import org.springframework.stereotype.Service; 5 | 6 | 7 | /** 8 | * Created by alexlu on 2018/10/29. 9 | */ 10 | @Service 11 | public class PromotionRuleManagementServiceImpl implements PromotionRuleManagementService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/rpc/CouponInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.rpc; 2 | 3 | import lk.project.marketing.client.rpc.CouponInterface; 4 | import lk.project.marketing.client.vo.ResponseVO; 5 | 6 | /** 7 | * Created by alexlu on 2018/11/15. 8 | */ 9 | public class CouponInterfaceImpl implements CouponInterface { 10 | 11 | @Override 12 | public ResponseVO getUserCouponList() { 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/CartDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class CartDto { 9 | 10 | /** 11 | * 购物车所属商家id 12 | */ 13 | private String shopId; 14 | 15 | /** 16 | * 购物车所属商铺名称 17 | */ 18 | private String shopName; 19 | 20 | /** 21 | * 购物车下订单项列表 22 | */ 23 | private List productDtoList; 24 | } 25 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/ConsumeCouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | @Data 11 | public class ConsumeCouponReqDto implements Serializable { 12 | /** 13 | * 用户基本信息 14 | */ 15 | private MemberDto memberDto; 16 | 17 | /** 18 | * 订单信息 19 | */ 20 | private OrderDto orderDto; 21 | } 22 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/UseCouponBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 待使用优惠券基本信息类 9 | * Created by gupei on 2018/9/18. 10 | */ 11 | @Data 12 | public class UseCouponBo implements Serializable { 13 | 14 | /** 15 | * 消费优惠券(模板)ID 16 | */ 17 | private Long couponId; 18 | 19 | /** 20 | * 本次消费优惠券数量 21 | */ 22 | private Long couponQuantity; 23 | } 24 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/OrderSettlementReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | @Data 11 | public class OrderSettlementReqDto implements Serializable { 12 | /** 13 | * 用户基本信息 14 | */ 15 | private MemberDto memberDto; 16 | 17 | /** 18 | * 订单信息 19 | */ 20 | private OrderDto orderDto; 21 | } 22 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/CouponConsumeController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @RequestMapping("/backend/couponConsume") 9 | public class CouponConsumeController extends BaseController{ 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/CouponReceiveController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @RequestMapping("/backend/couponReceive") 9 | public class CouponReceiveController extends BaseController { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/ActivityManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | import lk.project.marketing.base.bo.ActivityReqBo; 4 | 5 | /** 6 | * 促销活动相关后台管理服务 7 | * Created by luchao on 2018/12/25. 8 | */ 9 | public interface ActivityManagementService { 10 | 11 | /** 12 | * 新增或更新促销活动 13 | * @param activityReqBo 14 | * @return 15 | */ 16 | Boolean saveActivity(ActivityReqBo activityReqBo); 17 | } 18 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/BaseResultDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/15. 9 | */ 10 | @Data 11 | public class BaseResultDto implements Serializable { 12 | /** 13 | * 操作结果(默认为true) 14 | */ 15 | private Boolean operationResult = true; 16 | 17 | /** 18 | * 操作结果消息提示 19 | */ 20 | private String resultMsg; 21 | } 22 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/QueryOrderMatchedCouponDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | @Data 11 | public class QueryOrderMatchedCouponDto implements Serializable { 12 | /** 13 | * 用户基本信息 14 | */ 15 | private MemberDto memberDto; 16 | 17 | /** 18 | * 订单信息 19 | */ 20 | private OrderDto orderDto; 21 | } 22 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/SortAvailableMatchedCouponsReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by alexlu on 2018/11/23. 10 | */ 11 | @Data 12 | public class SortAvailableMatchedCouponsReqDto implements Serializable { 13 | /** 14 | * 可用的用户优惠券列表 15 | */ 16 | List availableCouponDetailsDtoList; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/GetAvailableCouponSelectListBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by alexlu on 2018/11/13. 10 | */ 11 | @Data 12 | public class GetAvailableCouponSelectListBo implements Serializable { 13 | /** 14 | * 可使用的优惠券列表 15 | * 按模板分组,可查看详情用户在每次活动领劵情况 16 | */ 17 | private List selectCouponUseList; 18 | } 19 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/impl/CouponConsumeDetailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.impl; 2 | 3 | import lk.project.marketing.base.entity.CouponConsumeDetail; 4 | import lk.project.marketing.service.CouponConsumeDetailService; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by zhanghongda on 2018/10/31. 9 | */ 10 | @Service 11 | public class CouponConsumeDetailServiceImpl implements CouponConsumeDetailService { 12 | 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponSortBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Created by alexlu on 2018/12/13. 7 | */ 8 | @Data 9 | public class CouponSortBo { 10 | /** 11 | * 消费优惠券(模板)ID 12 | */ 13 | private Long couponId; 14 | 15 | /** 16 | * 本次消费优惠券数量 17 | */ 18 | private Long couponQuantity; 19 | 20 | /** 21 | * 扣减类型排序值(用于设置顺序扣减) 22 | */ 23 | private Integer rewardTypeReduceSeqNo; 24 | } 25 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/PagerBaseRespBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * 基础分页结果响应类 10 | * Created by alexlu on 2018/6/22. 11 | */ 12 | @Data 13 | public class PagerBaseRespBo implements Serializable { 14 | /** 15 | * 总记录数 16 | */ 17 | private Long totalCount; 18 | 19 | /** 20 | * 分页(单页)数据 21 | */ 22 | private List pageData; 23 | } 24 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/QueryItemMatchedCouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | @Data 11 | public class QueryItemMatchedCouponReqDto implements Serializable { 12 | /** 13 | * 用户基本信息 14 | */ 15 | private MemberDto memberDto; 16 | 17 | /** 18 | * 订单项/商品信息 19 | */ 20 | private OrderItemDto orderItemDto; 21 | } 22 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/AccountRuleMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | /** 4 | * Created by zhanghongda on 2018/10/30. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.AccountRule; 9 | 10 | public interface AccountRuleMapper extends BaseMapper { 11 | 12 | /** 13 | * 通过id获得优惠券结算规则 14 | * @param id 15 | * @return 16 | */ 17 | AccountRule getAccountRuleById(Long id); 18 | } 19 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/CouponReceiveManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | import lk.project.marketing.backend.service.CouponReceiveManagementService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by Pei Gu on 2018/9/25. 9 | */ 10 | @Slf4j 11 | @Service 12 | public class CouponReceiveManagementServiceImpl implements CouponReceiveManagementService { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/CouponSummaryManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | import lk.project.marketing.backend.service.CouponSummaryManagementService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * Created by gupei on 2018/12/07. 9 | */ 10 | @Service 11 | @Slf4j 12 | public class CouponSummaryManagementServiceImpl implements CouponSummaryManagementService { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.Coupon; 9 | 10 | public interface CouponManagementMapper extends BaseMapper { 11 | 12 | /** 13 | * 根据id获取优惠券模板 14 | * @param id 15 | * @return 16 | */ 17 | Coupon getCouponById(Long id); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/PagerBaseResponseDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * 基础分页结果响应类 10 | * Created by alexlu on 2018/6/22. 11 | */ 12 | @Data 13 | public class PagerBaseResponseDto implements Serializable { 14 | /** 15 | * 总记录数 16 | */ 17 | private Long totalCount; 18 | 19 | /** 20 | * 分页(单页)数据 21 | */ 22 | private List pageData; 23 | } 24 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/OrderAvailableCouponsRespBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 查询订单可用优惠券结果类 9 | * Created by alexlu on 2018/11/13. 10 | */ 11 | @Data 12 | public class OrderAvailableCouponsRespBo extends GetAvailableCouponSelectListBo implements Serializable { 13 | /** 14 | * 订单ID 15 | */ 16 | private String orderId; 17 | 18 | /** 19 | * 订单编号 20 | */ 21 | private String orderNo; 22 | } 23 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/CouponReceiveManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.backend.mapper.CouponReceiveManagementMapper; 5 | import lk.project.marketing.base.entity.CouponReceive; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class CouponReceiveManagementRepository extends ServiceImpl { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/SettleAccountController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | 11 | @RestController 12 | @RequestMapping("/backend/couponSettle") 13 | public class SettleAccountController extends BaseController{ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/AccountRuleManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | /** 4 | * Created by zhanghongda on 2018/10/30. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.AccountRule; 9 | 10 | public interface AccountRuleManagementMapper extends BaseMapper { 11 | 12 | /** 13 | * 通过id获得优惠券结算规则 14 | * @param id 15 | * @return 16 | */ 17 | AccountRule getAccountRuleById(Long id); 18 | } 19 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/OrderItemAvailableCouponsRespBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 查询订单明细项(商品)可用优惠券结果类 9 | * Created by alexlu on 2018/11/13. 10 | */ 11 | @Data 12 | public class OrderItemAvailableCouponsRespBo extends GetAvailableCouponSelectListBo implements Serializable { 13 | /** 14 | * 商品/服务SKU ID 15 | */ 16 | private String skuId; 17 | 18 | /** 19 | * 商品/服务分类 20 | */ 21 | private String skuCategory; 22 | } 23 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponReceiveInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.CouponReceiveReqDto; 4 | import lk.project.marketing.client.dto.MemberDto; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | public interface CouponReceiveInterface { 8 | 9 | /** 10 | * 单次领券接口 11 | * @param couponReceiveReqDto 12 | * @param memberDto 13 | * @return 14 | */ 15 | ResponseVO produceCoupon(CouponReceiveReqDto couponReceiveReqDto, MemberDto memberDto); 16 | } 17 | -------------------------------------------------------------------------------- /marketing-api/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.19.248.200:30100/g_gov/centos_jdk:1.8.0_131 2 | MAINTAINER luchaob 3 | ADD target/LK-market-center-api.jar /opt/ 4 | WORKDIR /opt/ 5 | CMD java -Dfile.encoding=utf-8 -jar -Duser.timezone="Asia/Shanghai" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -server -Xmx1g -Xms128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=4m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 LK-market-center-api.jar 6 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/CouponConsumeDetailManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.backend.mapper.CouponConsumeDetailManagementMapper; 5 | import lk.project.marketing.base.entity.CouponConsumeDetail; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class CouponConsumeDetailManagementRepository extends ServiceImpl { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/CouponReceiveDetailManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.backend.mapper.CouponReceiveDetailManagementMapper; 5 | import lk.project.marketing.base.entity.CouponReceiveDetail; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class CouponReceiveDetailManagementRepository extends ServiceImpl { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/OrderItemAvailableCouponsRespDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class OrderItemAvailableCouponsRespDto extends GetAvailableCouponDetailListDto implements Serializable { 9 | 10 | /** 11 | * 订单明细项ID 12 | */ 13 | private String orderItemId; 14 | 15 | /** 16 | * 商品/服务SKU ID 17 | */ 18 | private String skuId; 19 | 20 | /** 21 | * 商品/服务分类 22 | */ 23 | private String skuCategory; 24 | } 25 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/PromotionRuleMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.PromotionRule; 9 | 10 | import java.util.List; 11 | 12 | public interface PromotionRuleMapper extends BaseMapper { 13 | 14 | /** 15 | * 根据促销活动id获得促销规则列表 16 | * @param activityId 17 | * @return 18 | */ 19 | List getPromotionRuleListByActivityId(Long activityId); 20 | } 21 | -------------------------------------------------------------------------------- /marketing-service/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.19.248.200:30100/g_gov/centos_jdk:1.8.0_131 2 | MAINTAINER luchaob 3 | ADD target/LK-market-center-service.jar /opt/ 4 | WORKDIR /opt/ 5 | CMD java -Dfile.encoding=utf-8 -jar -Duser.timezone="Asia/Shanghai" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -server -Xmx1g -Xms128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=4m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 LK-market-center-service.jar 6 | -------------------------------------------------------------------------------- /marketing-backend-api/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.19.248.200:30100/g_gov/centos_jdk:1.8.0_131 2 | MAINTAINER luchaob 3 | ADD target/LK-market-center-backend-api.jar /opt/ 4 | WORKDIR /opt/ 5 | CMD java -Dfile.encoding=utf-8 -jar -Duser.timezone="Asia/Shanghai" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -server -Xmx1g -Xms128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=4m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 LK-market-center-backend-api.jar 6 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/PagerBaseRequestDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by dell on 2017/11/1. 9 | */ 10 | @Data 11 | public class PagerBaseRequestDto implements Serializable { 12 | /** 13 | * 是否进行分页(0: 不分页(默认),1:分页) 14 | */ 15 | private Integer isPager = 0; 16 | 17 | /** 18 | * 分页页号(默认为第一页,索引为1) 19 | */ 20 | private Integer pageNum = 1; 21 | 22 | /** 23 | * 分页每页记录数(默认20) 24 | */ 25 | private Integer pageSize = 20; 26 | } 27 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponSummaryInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.vo.ResponseVO; 4 | 5 | 6 | public interface CouponSummaryInterface { 7 | 8 | /** 9 | * 获取用户优惠券列表 10 | * @param userId 用户ID 11 | * @return 12 | */ 13 | ResponseVO getUserCouponSummary(String userId); 14 | 15 | /** 16 | * 获取用户优惠券领取详情 17 | * @param userId 用户ID 18 | * @param couponId 优惠券ID 19 | * @return 20 | */ 21 | ResponseVO getUserCouponDetail(String userId, Long couponId ); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /marketing-backend-service/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.19.248.200:30100/g_gov/centos_jdk:1.8.0_131 2 | MAINTAINER luchaob 3 | ADD target/LK-market-center-backend-service.jar /opt/ 4 | WORKDIR /opt/ 5 | CMD java -Dfile.encoding=utf-8 -jar -Duser.timezone="Asia/Shanghai" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -server -Xmx1g -Xms128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=4m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 LK-market-center-backend-service.jar 6 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponConsumeDetailMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponConsumeDetail; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by zhanghongda on 2018/10/31. 10 | */ 11 | public interface CouponConsumeDetailMapper extends BaseMapper { 12 | 13 | /** 14 | * 根据用券id获取用券详情列表 15 | * @param consumeId 16 | * @return 17 | */ 18 | List getCouponConsumeDetailListByConsumeId(Long consumeId); 19 | } 20 | -------------------------------------------------------------------------------- /marketing-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: local 4 | datasource: 5 | type: com.alibaba.druid.pool.DruidDataSource 6 | druid: 7 | initial-size: 50 8 | max-active: 200 9 | max-idle: 200 10 | min-idle: 10 11 | test-on-borrow: true 12 | test-on-return: true 13 | test-while-idle: true 14 | time-between-eviction-runs-millis: 60000 15 | validation-query: SELECT 1 16 | idle-timeout: 120000 17 | connection-timeout: 6000 18 | maxIdleTime: 60 19 | mybatis: 20 | mapper-locations: classpath:mapper/*.xml 21 | server: 22 | port: 8077 -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/PromotionRuleManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.PromotionRule; 9 | 10 | import java.util.List; 11 | 12 | public interface PromotionRuleManagementMapper extends BaseMapper { 13 | 14 | /** 15 | * 根据促销活动id获得促销规则列表 16 | * @param activityId 17 | * @return 18 | */ 19 | List getPromotionRuleListByActivityId(Long activityId); 20 | } 21 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/CouponSummaryController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import lk.project.marketing.client.rpc.CouponSummaryManagementInterface; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @RequestMapping("/backend/couponSummary") 11 | public class CouponSummaryController extends BaseController { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: com 4 | datasource: 5 | type: com.alibaba.druid.pool.DruidDataSource 6 | druid: 7 | initial-size: 50 8 | max-active: 200 9 | max-idle: 200 10 | min-idle: 10 11 | test-on-borrow: true 12 | test-on-return: true 13 | test-while-idle: true 14 | time-between-eviction-runs-millis: 60000 15 | validation-query: SELECT 1 16 | idle-timeout: 120000 17 | connection-timeout: 6000 18 | maxIdleTime: 60 19 | mybatis: 20 | mapper-locations: classpath:mapper/*.xml 21 | server: 22 | port: 8079 -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CalcCouponReduceResultBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * Created by alexlu on 2018/12/3. 9 | */ 10 | @Data 11 | public class CalcCouponReduceResultBo { 12 | /** 13 | * 校验每种优惠券是否匹配结算递减的满减条件是否成功 14 | */ 15 | private Boolean calcCouponReduceSucceed; 16 | 17 | /** 18 | * 参与下一个劵种计算匹配递减规则后的总金额 19 | */ 20 | private BigDecimal calcResultTotalAmount; 21 | 22 | /** 23 | * 最终计算每种优惠券匹配递减后的实际总金额 24 | */ 25 | private BigDecimal finalTotalResultAmount; 26 | } 27 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/SelectCouponUseBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * 按模板分组的可使用优惠券列表 10 | * Created by alexlu on 2018/11/20. 11 | */ 12 | @Data 13 | public class SelectCouponUseBo extends CouponTemplateInfoBo implements Serializable { 14 | 15 | /** 16 | * 用户此类优惠券总共剩余数量 17 | */ 18 | private Long couponTotalRemainQuantity; 19 | 20 | /** 21 | * 用户此类优惠券各活动领劵记录列表 22 | * (点击详情后查看页面) 23 | */ 24 | List selectCouponReceiveInfoList; 25 | } 26 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/QRCodeBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | /** 9 | * 优惠券二维码编码对象 10 | * Created by gupei on 2018/11/15. 11 | */ 12 | public class QRCodeBo implements Serializable { 13 | 14 | /** 15 | * 促销活动Id 16 | */ 17 | private String activityId; 18 | 19 | /** 20 | * 优惠券编码 21 | */ 22 | private String couponNo; 23 | 24 | /** 25 | * 用户编号 26 | */ 27 | private String userId; 28 | 29 | /** 30 | * 微信跳转链接 31 | */ 32 | private String returnUrl; 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/PagerBaseReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.constant.CommonConstants; 4 | import lombok.Data; 5 | 6 | /** 7 | * Created by dell on 2017/11/1. 8 | */ 9 | @Data 10 | public class PagerBaseReqBo { 11 | /** 12 | * 是否进行分页(0: 不分页(默认),1:分页) 13 | */ 14 | private Integer isPager = 0; 15 | 16 | /** 17 | * 分页页号(默认为第一页,索引为0) 18 | */ 19 | private Integer pageNum = CommonConstants.DEFAULT_LIST_PAGE_INDEX; 20 | 21 | /** 22 | * 分页每页记录数(默认20) 23 | */ 24 | private Integer pageSize = CommonConstants.DEFAULT_LIST_PAGE_SIZE; 25 | } 26 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/MarketingClientApplication.java: -------------------------------------------------------------------------------- 1 | import org.springframework.boot.SpringApplication; 2 | import org.springframework.boot.autoconfigure.SpringBootApplication; 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 4 | 5 | /** 6 | * Created by Administrator on 2018/8/20/020. 7 | */ 8 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 9 | public class MarketingClientApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(MarketingClientApplication.class, args); 12 | System.out.println("...MarketingClientApplication started......."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponConsumeDetailManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponConsumeDetail; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by zhanghongda on 2018/10/31. 10 | */ 11 | public interface CouponConsumeDetailManagementMapper extends BaseMapper { 12 | 13 | /** 14 | * 根据用券id获取用券详情列表 15 | * @param consumeId 16 | * @return 17 | */ 18 | List getCouponConsumeDetailListByConsumeId(Long consumeId); 19 | } 20 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.bo.CouponReqBo; 9 | import lk.project.marketing.base.entity.Coupon; 10 | 11 | public interface CouponMapper extends BaseMapper { 12 | 13 | /** 14 | * 根据id获取优惠券模板 15 | * @param id 16 | * @return 17 | */ 18 | Coupon getCouponById(Long id); 19 | 20 | /** 21 | * 根据id更新促销活动记录 22 | * @param coupon 23 | * @return 24 | */ 25 | Boolean updateCouponById(Coupon coupon); 26 | } 27 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/SubTotalReduceInfoBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * Created by alexlu on 2018/12/3. 9 | */ 10 | @Data 11 | public class SubTotalReduceInfoBo { 12 | /** 13 | * 满减条件扣减金额小计 14 | */ 15 | private BigDecimal subTotalFullConditionReduceAmount; 16 | 17 | /** 18 | * 折扣条件扣减金额小计 19 | */ 20 | private BigDecimal subTotalDiscountReduceAmount; 21 | 22 | /** 23 | * 积分兑换扣减金额小计 24 | */ 25 | private BigDecimal subTotalCreditExchangeReduceAmount; 26 | 27 | /** 28 | * (单品)一口价/优惠价条件扣减金额小计 29 | */ 30 | private BigDecimal subTotalOnceReduceAmount; 31 | } 32 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/UpdateCouponsResultDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @Data 9 | public class UpdateCouponsResultDto implements Serializable { 10 | /** 11 | * 订单ID 12 | */ 13 | private String orderId; 14 | 15 | /** 16 | * 订单编号 17 | */ 18 | private String orderNo; 19 | 20 | /** 21 | * 商品ID 22 | */ 23 | private String skuId; 24 | 25 | /** 26 | * 会员Dto对象 27 | */ 28 | private MemberDto memberDto; 29 | 30 | /** 31 | * 使用的优惠券详情列表 32 | */ 33 | private List availableCouponDetailsList; 34 | } 35 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponReceiveDetailInfoBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.entity.BaseEntity; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * Created by alexlu on 2018/11/13. 11 | * 领券/发券详情 12 | */ 13 | @Data 14 | public class CouponReceiveDetailInfoBo extends BaseEntity implements Serializable { 15 | /** 16 | * 优惠券编码,发券时按规则生成 17 | */ 18 | private Long couponNo; 19 | 20 | /** 21 | * 券额(积分数,金额,折扣率等) 22 | */ 23 | private BigDecimal couponAmount; 24 | 25 | /** 26 | * 优惠券二维码地址URL 27 | */ 28 | private String couponQrCodeUrl; 29 | } 30 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponConsumeDetailBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by alexlu on 2018/10/29. 9 | */ 10 | @Data 11 | public class CouponConsumeDetailBo implements Serializable { 12 | /** 13 | * 消费优惠券ID 14 | */ 15 | private Long couponConsumeId; 16 | 17 | /** 18 | * 发放优惠券ID 19 | */ 20 | private Long couponReceiveId; 21 | 22 | /** 23 | * 发放优惠券明细ID集合(逗号间隔 24 | */ 25 | private String couponReceiveDetailIds; 26 | 27 | /** 28 | * 促销活动ID 29 | */ 30 | private Long activityId; 31 | 32 | /** 33 | * 本次使用数量 34 | */ 35 | private Long consumeQuantity; 36 | } 37 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponReceiveBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.entity.CouponReceive; 4 | import lk.project.marketing.base.entity.CouponReceiveDetail; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by gupei on 2018/9/18. 12 | * 优惠券发放对象 13 | */ 14 | @Data 15 | public class CouponReceiveBo implements Serializable { 16 | 17 | /** 18 | * 租户ID 19 | */ 20 | private Integer companyId; 21 | 22 | /** 23 | * 领券/发券主记录信息 24 | */ 25 | private CouponReceive couponReceive; 26 | 27 | /** 28 | * 领券/发券明细信息 29 | */ 30 | private List couponReceiveDetails; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/SettleAccountService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.*; 4 | 5 | /** 6 | * Created by gupei on 2018/9/18. 7 | * 订单结算接口 8 | */ 9 | public interface SettleAccountService { 10 | 11 | /** 12 | * 订单结算 13 | * @param memberReqBo 用户信息 14 | * @param order 订单和商品信息(包含使用的优惠券) 15 | * @return 订单结算结果对象 16 | */ 17 | OrderSettleResultBo orderSettlement(MemberBo memberReqBo, OrderBo order) throws Exception; 18 | 19 | /** 20 | * 动态返回用户选中的优惠券数据及其金额 21 | * @param dynamicSelectCouponReqBo 22 | * @return 23 | */ 24 | DynamicSelectCouponResultRespBo selectCoupon(DynamicSelectCouponReqBo dynamicSelectCouponReqBo) throws Exception; 25 | } 26 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CalcTotalReduceByEachCouponReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.entity.AccountRule; 4 | import lombok.Data; 5 | 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * 计算订单或商品的每种优惠券本次应扣结算规则信息 10 | * Created by alexlu on 2018/12/3. 11 | */ 12 | @Data 13 | public class CalcTotalReduceByEachCouponReqBo { 14 | /** 15 | * 结算规则信息 16 | */ 17 | private AccountRule accountRuleInfo; 18 | 19 | /** 20 | * 优惠券使用数量 21 | */ 22 | private Long couponQuantity; 23 | 24 | /** 25 | * 商品/服务销售原单价 26 | */ 27 | private BigDecimal goodsSalePrice; 28 | 29 | /** 30 | * 临时变量(当前商品或订单的总金额) 31 | */ 32 | private BigDecimal tmpTotalAmount; 33 | } 34 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponReceiveReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by gupei on 2018/10/10. 9 | * 优惠券发放对象 10 | */ 11 | @Data 12 | public class CouponReceiveReqBo implements Serializable { 13 | 14 | /** 15 | * 优惠券模版ID,当不指定促销活动ID时,按该优惠券模版默认有效活动发券 16 | */ 17 | private Long couponId; 18 | 19 | /** 20 | * 促销活动ID 21 | */ 22 | private Long activityId; 23 | 24 | /** 25 | * 领券数量 26 | */ 27 | private Integer requestQuantity; 28 | 29 | /** 30 | * 领券场景描述 31 | */ 32 | private String sceneDesc; 33 | 34 | private OrderBo orderBo; 35 | 36 | private OrderItemBo orderItemBo; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponSummaryMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.bo.CouponHistoryInfoBo; 5 | import lk.project.marketing.base.entity.CouponSummary; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zhanghongda on 2018/10/31. 12 | */ 13 | public interface CouponSummaryMapper extends BaseMapper { 14 | 15 | /** 16 | * 查询用户订单的用劵历史记录列表 17 | * @param userId 用户ID 18 | * @param orderId 订单ID 19 | * @return 20 | */ 21 | List getCouponHistoryDetailsByUserOrder(@Param("userId") String userId, @Param("orderId") String orderId); 22 | } 23 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/DynamicSelectCouponResultRespBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * 动态计算实际可用劵返回类 11 | * Created by alexlu on 2018/11/22. 12 | */ 13 | @Data 14 | public class DynamicSelectCouponResultRespBo extends CouponReduceInfoBo implements Serializable { 15 | /** 16 | * 动态返回每次操作计算后的实际可用劵 17 | * 18 | */ 19 | List dynamicCalcSelectedCouponList; 20 | 21 | /** 22 | * 当前计算的(订单或单个商品)最终实付总金额 23 | */ 24 | private BigDecimal finalTotalAmount; 25 | 26 | /** 27 | * 参与满减条件计算的虚拟总金额 28 | */ 29 | private BigDecimal virtualCalcTotalAmount; 30 | } 31 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/CouponReceiveReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class CouponReceiveReqDto implements Serializable { 9 | 10 | /** 11 | * 优惠券模版ID,当不指定促销活动ID时,按该优惠券模版默认有效活动发券 12 | */ 13 | private Long couponId; 14 | 15 | /** 16 | * 促销活动ID 17 | */ 18 | private Long activityId; 19 | 20 | /** 21 | * 用户ID 22 | */ 23 | private String userId; 24 | 25 | /** 26 | * 领券数量 27 | */ 28 | private Integer requestQuantity; 29 | 30 | /** 31 | * 领券场景描述 32 | */ 33 | private String sceneDesc; 34 | 35 | private OrderDto orderDto; 36 | 37 | private OrderItemDto orderItemDto; 38 | } 39 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponReceiveDetailMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.bo.CouponSummaryDetailBo; 5 | import lk.project.marketing.base.entity.CouponReceiveDetail; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zhanghongda on 2018/10/31. 12 | */ 13 | public interface CouponReceiveDetailMapper extends BaseMapper { 14 | 15 | /** 16 | * 查询用户优惠券详情 17 | * @param couponId 18 | * @param userId 19 | * @return 20 | */ 21 | List getUserCouponReceiveDetailListByCouponId(@Param("couponID") Long couponId, @Param("userID") String userId); 22 | } 23 | -------------------------------------------------------------------------------- /marketing-api/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8118 3 | dubbo: 4 | application: 5 | name: lk-project-marketing-api 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: zookeeper://localhost:2181 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 60000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20880 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 60000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 60000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | 37 | -------------------------------------------------------------------------------- /marketing-api/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8118 3 | dubbo: 4 | application: 5 | name: lk-project-marketing-api 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: zookeeper://localhost:2181 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 60000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20880 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 60000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 60000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | 37 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8119 3 | dubbo: 4 | application: 5 | name: lk-project-marketing-backend-api 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: zookeeper://localhost:2181 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 60000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20881 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 60000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 60000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | 37 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponSummaryManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponSummary; 5 | import lk.project.marketing.base.bo.CouponHistoryInfoBo; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zhanghongda on 2018/10/31. 12 | */ 13 | public interface CouponSummaryManagementMapper extends BaseMapper { 14 | 15 | /** 16 | * 查询用户订单的用劵历史记录列表 17 | * @param userId 用户ID 18 | * @param orderId 订单ID 19 | * @return 20 | */ 21 | List getCouponHistoryDetailsByUserOrder(@Param("userId") String userId, @Param("orderId") String orderId); 22 | } 23 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8119 3 | dubbo: 4 | application: 5 | name: lk-project-marketing-backend-api 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: zookeeper://localhost:2181 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 60000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20881 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 60000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 60000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | 37 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponsReduceAmountBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * Created by alexlu on 2018/12/11. 9 | */ 10 | @Data 11 | public class CouponsReduceAmountBo { 12 | /** 13 | * 扣减优惠券ID 14 | */ 15 | private Long couponId; 16 | 17 | /** 18 | * 扣减优惠券金额 19 | */ 20 | private BigDecimal couponReduceAmount; 21 | 22 | /** 23 | * 扣减优惠券后支付金额 24 | */ 25 | private BigDecimal paymentAmount; 26 | 27 | /** 28 | * 赠送优惠券活动Id 29 | */ 30 | private Long rewardCouponActivityId; 31 | 32 | /** 33 | * 赠送商品或服务ID 34 | */ 35 | private String rewardProductId; 36 | 37 | /** 38 | * 赠品描述 39 | */ 40 | private String rewardDesc; 41 | } 42 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponReceiveDetailManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponReceiveDetail; 5 | import lk.project.marketing.base.bo.CouponSummaryDetailBo; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zhanghongda on 2018/10/31. 12 | */ 13 | public interface CouponReceiveDetailManagementMapper extends BaseMapper { 14 | 15 | /** 16 | * 查询用户优惠券详情 17 | * @param couponId 18 | * @param userId 19 | * @return 20 | */ 21 | List getUserCouponReceiveDetailListByCouponId(@Param("couponID") Long couponId, @Param("userID") String userId); 22 | } 23 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/SelectCouponReceiveInfoBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.sql.Date; 7 | 8 | /** 9 | * Created by alexlu on 2018/11/20. 10 | */ 11 | @Data 12 | public class SelectCouponReceiveInfoBo extends CouponTemplateInfoBo implements Serializable { 13 | /** 14 | * 优惠券领劵主记录ID 15 | */ 16 | private Long couponReceiveId; 17 | 18 | /** 19 | * 优惠券领劵剩余数量 20 | */ 21 | private Long couponReceiveRemainQuantity; 22 | 23 | /** 24 | * 优惠券领劵记录状态(0-已领取未使用,1-已使用,2-使用中,3-已过期) 25 | */ 26 | private Integer couponReceiveStatus; 27 | 28 | /** 29 | * 优惠券使用截至日期 30 | */ 31 | // @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8") 32 | private Date couponEndDate; 33 | } 34 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponConsumeBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by gupei on 2018/9/18. 11 | * 优惠券使用对象 12 | */ 13 | @Data 14 | public class CouponConsumeBo implements Serializable { 15 | 16 | /** 17 | * 订单ID 18 | */ 19 | private String orderId; 20 | 21 | /** 22 | * 订单编号 23 | */ 24 | private String orderNo; 25 | 26 | /** 27 | * 原订单金额 28 | */ 29 | private BigDecimal originalAmount; 30 | 31 | /** 32 | * 优惠后订单实际支付金额 33 | */ 34 | private BigDecimal finalPayAmount; 35 | 36 | 37 | /** 38 | * 使用优惠券明细记录列表 39 | */ 40 | private List couponConsumeDetailList; 41 | } 42 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/SettleAccountInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.DynamicSelectCouponReqDto; 4 | import lk.project.marketing.client.dto.OrderSettlementReqDto; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | /** 8 | * Created by alexlu on 2018/11/23. 9 | */ 10 | public interface SettleAccountInterface { 11 | /** 12 | * 订单结算 13 | * @param orderSettlementReqDto 14 | * @return 订单结算结果对象 15 | */ 16 | ResponseVO orderSettlement(OrderSettlementReqDto orderSettlementReqDto) throws Exception; 17 | 18 | /** 19 | * 动态返回用户选中的优惠券数据及其金额 20 | * @param dynamicSelectCouponReqDto 21 | * @return 22 | */ 23 | ResponseVO selectCoupon(DynamicSelectCouponReqDto dynamicSelectCouponReqDto) throws Exception; 24 | } 25 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/DynamicCalcSelectedCouponDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * Created by alexlu on 2018/11/22. 10 | */ 11 | @Data 12 | public class DynamicCalcSelectedCouponDto implements Serializable { 13 | /** 14 | * 优惠券ID 15 | */ 16 | private Long couponId; 17 | 18 | /** 19 | * 用户选择的优惠券使用数量 20 | */ 21 | private Long couponSelectQuantity; 22 | 23 | /** 24 | * 券额(积分数,金额,折扣率等) 25 | */ 26 | private BigDecimal couponAmount; 27 | 28 | /** 29 | * 当前最新状态(0-未选中,1-已选中,2-不可使用) 30 | * UI传入和后台返回通用 31 | */ 32 | private Integer status; 33 | 34 | /** 35 | * 优惠券扣除的金额 36 | */ 37 | private BigDecimal couponReducedAmount; 38 | } 39 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/CouponManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.Coupon; 5 | import lk.project.marketing.backend.mapper.CouponManagementMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public class CouponManagementRepository extends ServiceImpl { 11 | 12 | @Autowired 13 | CouponManagementMapper couponManagementMapper; 14 | 15 | /** 16 | * 根据优惠券模板ID获取优惠券模板 17 | * @param id 18 | * @return 19 | */ 20 | public Coupon getCouponById(Long id){ 21 | return couponManagementMapper.getCouponById(id); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/QueryCouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class QueryCouponReqDto extends PagerBaseRequestDto implements Serializable { 9 | 10 | /** 11 | * 优惠券模板ID 12 | */ 13 | private Long id; 14 | 15 | /** 16 | * 公司,租户ID 17 | */ 18 | private Integer companyId; 19 | 20 | /** 21 | * 所属类型, 0:积分;1:满减(包括现金抵扣和折扣,参考满减规则),2:赠送赠品 22 | */ 23 | private Integer couponType; 24 | 25 | /** 26 | * 使用该优惠券产生的扣减是否计入满减条件的支付总量 27 | */ 28 | protected Boolean accumulated; 29 | 30 | /** 31 | * 优惠券使用规则之间关系,0:排他;1:并存(累计);2:择优 32 | */ 33 | private Integer accumulateType; 34 | 35 | /** 36 | * 状态,0已启用,1未启用 37 | */ 38 | private Integer status; 39 | } 40 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/ActivityService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.entity.PromotionActivity; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by gupei on 2018/9/12. 9 | */ 10 | public interface ActivityService { 11 | 12 | /** 13 | * 当前是否活动发券有效期间校验 14 | * @param activePromotion 15 | * @return 16 | */ 17 | static boolean verifyActivityPeriod(PromotionActivity activePromotion){ 18 | 19 | Date currentDate = new Date(); 20 | Date startDate = activePromotion.getActivityStart(); 21 | Date endDate = activePromotion.getActivityEnd(); 22 | 23 | if (startDate!=null&&startDate.after(currentDate)) return false; 24 | if (endDate!=null&&endDate.before(currentDate)) return false; 25 | return true; 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/CouponReceiveMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponReceive; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by alexlu on 2018/10/29. 11 | */ 12 | public interface CouponReceiveMapper extends BaseMapper { 13 | /** 14 | *根据发券id列表获得促销活动id列表 15 | * @param couponReceiveIds 16 | * @return 17 | */ 18 | List getCouponActivityIdsByReceiveIds(List couponReceiveIds); 19 | 20 | /** 21 | * 获得指定用户某次活动领取优惠券数量 22 | * @param userId 23 | * @param activityId 24 | * @return 25 | */ 26 | Long getReceivedCouponQuantities(@Param("userId") String userId, @Param("activityId") Long activityId); 27 | } 28 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/MemberDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class MemberDto implements Serializable { 9 | 10 | /** 11 | * 用户ID 12 | */ 13 | private String userId; 14 | 15 | /** 16 | * 用户编号 17 | */ 18 | private String userCode; 19 | 20 | /** 21 | * 用户名 22 | */ 23 | private String userName; 24 | 25 | /** 26 | * 用户等级 27 | */ 28 | private Integer level; 29 | 30 | /** 31 | * 用户经验值 32 | */ 33 | private Long expValue; 34 | 35 | /** 36 | * 用户年龄 37 | */ 38 | private Integer age; 39 | 40 | /** 41 | * 用户性别 42 | */ 43 | private Integer gender; 44 | 45 | /** 46 | * 联系电话 47 | */ 48 | private String phoneNumber; 49 | } 50 | -------------------------------------------------------------------------------- /marketing-rds/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | flyway: 2 | # locations: classpath:db/migration,db-dev/migration 3 | locations: classpath:db/migration 4 | baseline-on-migrate: true 5 | 6 | 7 | # not working, moved to jenkin config 8 | spring: 9 | application: 10 | name: marketing-rds 11 | datasource: 12 | url: jdbc:mysql://localhost:3306/lk-p-marketing?characterEncoding=utf-8&autoReconnect=true&useSSL=false 13 | username: root 14 | password: root123 15 | 16 | #数据库连接池配置 17 | max-active: 200 18 | max-idle: 100 19 | min-idle: 50 20 | initial-size: 20 21 | test-on-borrow: false 22 | test-on-return: false 23 | test-while-idle: true 24 | validation-query: select 1 25 | #每10分钟收集空闲连接,单位毫秒 26 | time-between-eviction-runs-millis: 600000 27 | #连接的最大空闲时间,单位毫秒,60分钟 28 | min-evictable-idle-time-millis: 3600000 29 | max-wait: 60000 30 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponTemplateInfoBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * Created by alexlu on 2018/11/28. 10 | */ 11 | @Data 12 | public class CouponTemplateInfoBo implements Serializable { 13 | /** 14 | * 消费优惠券(模板)记录ID 15 | */ 16 | private Long couponId; 17 | 18 | /** 19 | * 消费优惠券(模板)名称 20 | */ 21 | private String couponName; 22 | 23 | /** 24 | * 消费优惠券(模板)描述 25 | */ 26 | private String couponDesc; 27 | 28 | /** 29 | * 消费优惠券(模板)图标URL 30 | */ 31 | private String couponIcon; 32 | 33 | /** 34 | * 券额(积分数,金额,折扣率等) 35 | */ 36 | private BigDecimal couponAmount; 37 | 38 | /** 39 | * 权重值,数值小表示优先 40 | */ 41 | private Integer couponWeight; 42 | } 43 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/DynamicSelectCouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by alexlu on 2018/11/23. 11 | */ 12 | @Data 13 | public class DynamicSelectCouponReqDto implements Serializable { 14 | /** 15 | * 动态计算用户选中的优惠券列表 16 | * 返回计算后的实际可用劵列表 17 | */ 18 | List dynamicCalcSelectedCouponList; 19 | 20 | /** 21 | * 当前最新的总金额 22 | */ 23 | private BigDecimal totalAmount; 24 | 25 | /** 26 | * 用户信息 27 | */ 28 | private MemberDto memberDto; 29 | 30 | /** 31 | * 订单信息 32 | */ 33 | private OrderDto orderDto; 34 | 35 | /** 36 | * 订单项信息 37 | */ 38 | private OrderItemDto orderItemDto; 39 | } 40 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponManagementInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.CouponReqDto; 4 | import lk.project.marketing.client.dto.QueryCouponReqDto; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | /** 8 | * Created by alexlu on 2018/10/30. 9 | */ 10 | public interface CouponManagementInterface { 11 | 12 | /** 13 | * 添加或更新优惠券模板 14 | * @param couponReqDto 15 | * @return 16 | */ 17 | ResponseVO saveCoupon(CouponReqDto couponReqDto); 18 | 19 | /** 20 | * 删除优惠券模板 21 | * @param couponId 22 | * @return 23 | */ 24 | ResponseVO deleteCoupon(Long couponId); 25 | 26 | /** 27 | * 查询满足条件的优惠券模板 28 | * @param queryCouponReqDto 29 | * @return 30 | */ 31 | ResponseVO queryCoupon(QueryCouponReqDto queryCouponReqDto); 32 | } 33 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/repository/AccountRuleRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.AccountRule; 5 | import lk.project.marketing.mapper.AccountRuleMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * Created by zhanghongda on 2018/11/8. 11 | */ 12 | @Repository 13 | public class AccountRuleRepository extends ServiceImpl { 14 | 15 | @Autowired 16 | AccountRuleMapper accountRuleMapper; 17 | 18 | /** 19 | * 根据id获取优惠券结算规则相关信息 20 | * @param id 21 | * @return 22 | */ 23 | public AccountRule getAccountRuleById(Long id) { 24 | return accountRuleMapper.getAccountRuleById(id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponSummaryBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by gupei on 2018/9/18. 9 | * 用户优惠券汇总对象 10 | */ 11 | @Data 12 | public class CouponSummaryBo implements Serializable { 13 | 14 | /** 15 | * 租户ID 16 | */ 17 | private Integer companyId; 18 | 19 | /** 20 | * 类型(0:积分;1:满减(包括现金抵扣和折扣,参考满减规则),2:赠送赠品) 21 | */ 22 | private Integer couponType; 23 | 24 | /** 25 | * 优惠券名称 26 | */ 27 | private String couponName; 28 | 29 | /** 30 | * 优惠券使用规则描述 31 | */ 32 | private String couponDesc; 33 | 34 | /** 35 | * 优惠券图标的URL地址 36 | */ 37 | private String icon; 38 | 39 | /** 40 | * 用户优惠券汇总信息 41 | */ 42 | private lk.project.marketing.base.entity.CouponSummary CouponSummary; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/AccountRuleManagementInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.AccountRuleReqDto; 4 | import lk.project.marketing.client.dto.QueryAccountRuleReqDto; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | public interface AccountRuleManagementInterface { 8 | 9 | /** 10 | * 新增或更新优惠券结算规则 11 | * @param accountRuleReqDto 12 | * @return 13 | */ 14 | ResponseVO saveAccountRule(AccountRuleReqDto accountRuleReqDto); 15 | 16 | /** 17 | * 逻辑删除优惠券结算规则 18 | * @param accountRuleId 19 | * @return 20 | */ 21 | ResponseVO deleteAccountRule(Long accountRuleId); 22 | 23 | /** 24 | * 根据条件分页查询优惠券结算规则 25 | * @param queryAccountRuleReqDto 26 | * @return 27 | */ 28 | ResponseVO queryAccountRule(QueryAccountRuleReqDto queryAccountRuleReqDto); 29 | } 30 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/CouponReceiveManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | import com.baomidou.mybatisplus.mapper.BaseMapper; 4 | import lk.project.marketing.base.entity.CouponReceive; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by alexlu on 2018/10/29. 11 | */ 12 | public interface CouponReceiveManagementMapper extends BaseMapper { 13 | /** 14 | *根据发券id列表获得促销活动id列表 15 | * @param couponReceiveIds 16 | * @return 17 | */ 18 | List getCouponActivityIdsByReceiveIds(List couponReceiveIds); 19 | 20 | /** 21 | * 获得指定用户某次活动领取优惠券数量 22 | * @param userId 23 | * @param activityId 24 | * @return 25 | */ 26 | Long getReceivedCouponQuantities(@Param("userId") String userId, @Param("activityId") Long activityId); 27 | } 28 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/QueryCouponReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by gupei on 2018/9/18. 9 | * 优惠券模板查询接口对象 10 | */ 11 | @Data 12 | public class QueryCouponReqBo extends PagerBaseReqBo implements Serializable { 13 | 14 | /** 15 | * 优惠券模板ID 16 | */ 17 | private Long id; 18 | 19 | /** 20 | * 公司,租户ID 21 | */ 22 | private Integer companyId; 23 | 24 | /** 25 | * 所属类型, 0:积分;1:满减(包括现金抵扣和折扣,参考满减规则),2:赠送赠品 26 | */ 27 | private Integer couponType; 28 | 29 | /** 30 | * 使用该优惠券产生的扣减是否计入满减条件的支付总量 31 | */ 32 | protected Boolean accumulated; 33 | 34 | /** 35 | * 优惠券使用规则之间关系,0:排他;1:并存(累计);2:择优 36 | */ 37 | private Integer accumulateType; 38 | 39 | /** 40 | * 状态,0已启用,1未启用 41 | */ 42 | private Integer status; 43 | } 44 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/MemberBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by gupei on 2018/9/18. 9 | * 用户会员接口对象 10 | */ 11 | @Data 12 | public class MemberBo implements Serializable { 13 | 14 | /** 15 | * 用户ID 16 | */ 17 | private String userId; 18 | 19 | /** 20 | * 用户编号 21 | */ 22 | private String userCode; 23 | 24 | /** 25 | * 用户名 26 | */ 27 | private String userName; 28 | 29 | /** 30 | * 用户等级 31 | */ 32 | private Integer level; 33 | 34 | /** 35 | * 用户经验值 36 | */ 37 | private Long expValue; 38 | 39 | /** 40 | * 用户年龄 41 | */ 42 | private Integer age; 43 | 44 | /** 45 | * 用户性别 46 | */ 47 | private Integer gender; 48 | 49 | /** 50 | * 联系电话 51 | */ 52 | private String phoneNumber; 53 | } 54 | -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/project/marketing/utils/DateConvertTimeTest.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.utils; 2 | 3 | import lk.project.marketing.init.MarketingServiceApplication; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import java.util.Date; 10 | import java.util.stream.Stream; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest(classes = MarketingServiceApplication.class) 14 | public class DateConvertTimeTest { 15 | 16 | @Test 17 | public void testDateConvertTime(){ 18 | Date startDate = new Date("2018/11/1"); 19 | Date endDate = new Date("2019/2/15"); 20 | long startTime = startDate.getTime(); 21 | long endTime = endDate.getTime(); 22 | System.out.println(startTime); 23 | System.out.println(endTime); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /marketing-api/src/main/resources/application-com.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8118 3 | dubbo: 4 | application: 5 | name: ${DUBBO_APPLICATION_NAME} 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: ${DUBBO_REGISTRY_ADDRESS} 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 10000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20880 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 10000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 10000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | service: 37 | retries: 2 38 | timeout: 10000 39 | loadbalance: consistenthash 40 | admin: 41 | username: root 42 | password: root -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/repository/PromotionRuleRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.PromotionRule; 5 | import lk.project.marketing.mapper.PromotionRuleMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | 12 | @Repository 13 | public class PromotionRuleRepository extends ServiceImpl { 14 | 15 | @Autowired 16 | PromotionRuleMapper promotionRuleMapper; 17 | 18 | /** 19 | * 根据促销活动id获得促销规则列表 20 | * @param activityId 促销活动ID 21 | * @return 22 | */ 23 | public List getPromotionRuleListByActivityId(Long activityId){ 24 | return promotionRuleMapper.getPromotionRuleListByActivityId(activityId); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/MarketingApiApplication.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.ImportResource; 8 | 9 | /** 10 | * Created by Administrator on 2018/8/20/020. 11 | */ 12 | @ImportResource(value = {"classpath:/config/*.xml"}) 13 | @ComponentScan(basePackages = {"lk.project.marketing.*"}) 14 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 15 | public class MarketingApiApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(MarketingApiApplication.class, args); 18 | System.out.println("...MarketingApiApplication started......."); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/resources/application-com.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8119 3 | dubbo: 4 | application: 5 | name: ${DUBBO_APPLICATION_NAME} 6 | owner: bill 7 | logger: slf4j 8 | registry: 9 | address: ${DUBBO_REGISTRY_ADDRESS} 10 | protocol: zookeeper 11 | check: false 12 | subscribe: true 13 | timeout: 10000 14 | group: dubbo 15 | monitor: 16 | protocol: registry 17 | protocol: 18 | name: dubbo 19 | port: 20881 20 | threadpool: fixed 21 | threads: 100 22 | accepts: 1000 23 | charset: UTF-8 24 | dispatcher: all 25 | payload: 104857600 26 | timeout: 10000 27 | check: false 28 | token: false 29 | provider: 30 | timeout: 10000 31 | check: false 32 | token: false 33 | consumer: 34 | timeout: 60000 35 | check: false 36 | service: 37 | retries: 2 38 | timeout: 10000 39 | loadbalance: consistenthash 40 | admin: 41 | username: root 42 | password: root -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/CouponManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | import lk.project.marketing.base.bo.CouponReqBo; 4 | import lk.project.marketing.base.bo.PagerBaseRespBo; 5 | import lk.project.marketing.base.bo.QueryCouponReqBo; 6 | import lk.project.marketing.base.entity.Coupon; 7 | 8 | /** 9 | * 优惠券模板基础信息后台管理服务 10 | * Created by luchao on 2018/12/25. 11 | */ 12 | public interface CouponManagementService { 13 | 14 | /** 15 | * 创建或更新优惠券模板 16 | * @param couponRequest 17 | */ 18 | Boolean saveCoupon(CouponReqBo couponRequest); 19 | 20 | /** 21 | * 查询满足条件的优惠券模板 22 | * @param queryCouponReqBo 23 | * @return 24 | */ 25 | PagerBaseRespBo queryCoupon(QueryCouponReqBo queryCouponReqBo); 26 | 27 | /** 28 | * 删除优惠券模板 29 | * @param couponId 30 | * @return 31 | */ 32 | Boolean deleteCoupon(Long couponId); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/AvailableCouponDetailsDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.sql.Date; 8 | 9 | @Data 10 | public class AvailableCouponDetailsDto implements Serializable { 11 | 12 | /** 13 | * 消费优惠券(模板)记录ID 14 | */ 15 | private Long couponId; 16 | 17 | /** 18 | * 消费优惠券领劵明细记录ID 19 | */ 20 | private Long couponDetailId; 21 | 22 | /** 23 | * 优惠券编码,发券时按规则生成 24 | */ 25 | private Long couponNo; 26 | 27 | /** 28 | * 券额(积分数,金额,折扣率等) 29 | */ 30 | private BigDecimal couponAmount; 31 | 32 | /** 33 | * 优惠券二维码地址URL 34 | */ 35 | private String couponQrCodeUrl; 36 | 37 | /** 38 | * 权重值,数值小表示优先 39 | */ 40 | private Integer couponWeight; 41 | 42 | /** 43 | * 优惠券使用截至日期 44 | */ 45 | private Date couponEndDate; 46 | } 47 | -------------------------------------------------------------------------------- /marketing-rds/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | flyway: 2 | # locations: classpath:db/migration,db-dev/migration 3 | locations: classpath:db/migration 4 | baseline-on-migrate: true 5 | 6 | # not working, moved to jenkin config 7 | spring: 8 | application: 9 | name: marketing-rds 10 | datasource: 11 | url: jdbc:mysql://10.19.248.200:30057/lk-p-marketing?characterEncoding=utf-8&autoReconnect=true&useSSL=false 12 | username: root 13 | password: root 14 | 15 | #数据库连接池配置 16 | max-active: 200 17 | max-idle: 100 18 | min-idle: 50 19 | initial-size: 20 20 | test-on-borrow: false 21 | test-on-return: false 22 | test-while-idle: true 23 | validation-query: select 1 24 | #每10分钟收集空闲连接,单位毫秒 25 | time-between-eviction-runs-millis: 600000 26 | #连接的最大空闲时间,单位毫秒,60分钟 27 | min-evictable-idle-time-millis: 3600000 28 | max-wait: 60000 29 | 30 | # jpa: 31 | # show-sql: false 32 | # hibernate: 33 | # ddl-auto: validate 34 | 35 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/repository/CouponRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.Coupon; 5 | import lk.project.marketing.mapper.CouponMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | @Repository 10 | public class CouponRepository extends ServiceImpl { 11 | 12 | @Autowired 13 | CouponMapper couponMapper; 14 | 15 | /** 16 | * 根据优惠券模板ID获取优惠券模板 17 | * @param id 18 | * @return 19 | */ 20 | public Coupon getCouponById(Long id){ 21 | return couponMapper.getCouponById(id); 22 | } 23 | 24 | /** 25 | * 更新优惠券模板 26 | * @param 27 | * @return 28 | */ 29 | public Boolean updateCouponById(Coupon coupon){ 30 | return couponMapper.updateCouponById(coupon); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/AccountRuleManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.AccountRule; 5 | import lk.project.marketing.backend.mapper.AccountRuleManagementMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * Created by zhanghongda on 2018/11/8. 11 | */ 12 | @Repository 13 | public class AccountRuleManagementRepository extends ServiceImpl { 14 | 15 | @Autowired 16 | AccountRuleManagementMapper accountRuleManagementMapper; 17 | 18 | /** 19 | * 根据id获取优惠券结算规则相关信息 20 | * @param id 21 | * @return 22 | */ 23 | public AccountRule getAccountRuleById(Long id) { 24 | return accountRuleManagementMapper.getAccountRuleById(id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CartService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.*; 4 | 5 | import java.util.List; 6 | 7 | public interface CartService { 8 | 9 | /** 10 | * 添加商品到购物车列表 11 | * @param productBo 12 | * @param memberBo 13 | * @return 14 | */ 15 | Boolean addGoodsToCartList(ProductBo productBo, MemberBo memberBo); 16 | 17 | /** 18 | * 获得指定用户的购物车列表 19 | * @param userId 20 | * @return 21 | */ 22 | List getCartListFromRedis(String userId); 23 | 24 | /** 25 | * 将本地购物车合并到用户购物车当中 26 | * @param cartBoList 27 | * @param memberBo 28 | * @return 29 | */ 30 | Boolean mergeCartList(List cartBoList, MemberBo memberBo); 31 | 32 | /** 33 | * 获得用户可用优惠券列表 34 | * @param memberBo 35 | * @return 36 | */ 37 | List getAvailableCouponDetailList(MemberBo memberBo); 38 | } 39 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/DynamicSelectCouponReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * 动态计算实际可用劵请求类 11 | * Created by alexlu on 2018/11/22. 12 | */ 13 | @Data 14 | public class DynamicSelectCouponReqBo implements Serializable { 15 | /** 16 | * 动态计算用户选中的优惠券列表 17 | * 返回计算后的实际可用劵列表 18 | */ 19 | List dynamicCalcSelectedCouponList; 20 | 21 | /** 22 | * 当前最新的总金额 23 | */ 24 | private BigDecimal totalAmount; 25 | 26 | /** 27 | * 参与满减条件计算的虚拟总金额 28 | */ 29 | private BigDecimal virtualCalcTotalAmount; 30 | 31 | /** 32 | * 用户信息 33 | */ 34 | private MemberBo memberBo; 35 | 36 | /** 37 | * 订单信息 38 | */ 39 | private OrderBo orderBo; 40 | 41 | /** 42 | * 订单项信息 43 | */ 44 | private OrderItemBo orderItemBo; 45 | } 46 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/MarketingBackendApiApplication.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.ImportResource; 8 | 9 | /** 10 | * Created by Administrator on 2018/8/20/020. 11 | */ 12 | @ImportResource(value = {"classpath:/config/*.xml"}) 13 | @ComponentScan(basePackages = {"lk.project.marketing.*"}) 14 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 15 | public class MarketingBackendApiApplication { 16 | public static void main(String[] args) { 17 | SpringApplication.run(MarketingBackendApiApplication.class, args); 18 | System.out.println("...MarketingBackendApiApplication started......."); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponConsumeHistoryRespBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * 用劵历史信息 11 | * Created by alexlu on 2018/11/2. 12 | */ 13 | @Data 14 | public class CouponConsumeHistoryRespBo implements Serializable { 15 | // /** 16 | // * 租户ID 17 | // */ 18 | // private Long companyId; 19 | 20 | /** 21 | * 订单ID 22 | */ 23 | private String orderId; 24 | 25 | /** 26 | * 订单编号 27 | */ 28 | private String orderNo; 29 | 30 | /** 31 | * 卖家商户供应商ID 32 | */ 33 | private String shopId; 34 | 35 | /** 36 | * 原订单或商品项金额 37 | */ 38 | private BigDecimal originalAmount; 39 | 40 | /** 41 | * 优惠后订单或商品项实际支付金额 42 | */ 43 | private BigDecimal finalPayAmount; 44 | 45 | /** 46 | * 使用优惠券模板相关明细列表 47 | */ 48 | private List couponHistoryInfoBoList; 49 | } 50 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponReceiveDetailService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | 4 | import lk.project.marketing.base.entity.CouponReceive; 5 | import lk.project.marketing.base.entity.CouponReceiveDetail; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by zhanghongda on 2018/10/31. 11 | */ 12 | public interface CouponReceiveDetailService { 13 | 14 | /** 15 | * 根据领券/发券业务请求信息对象生成领券明细信息 16 | * @param couponReceive 领券主记录信息 17 | * @return 领券明细对象数据集 18 | */ 19 | List buildCouponReceiveDetails(CouponReceive couponReceive); 20 | 21 | /** 22 | * 根据领券明细序列号生成优惠券码 23 | * @param sequenceId 明细序列号 24 | * @return 优惠券码 25 | */ 26 | String generateCouponNo(Long sequenceId); 27 | 28 | /** 29 | * 根据领券信息生成优惠券二维码 30 | * @param couponReceive 领券主记录信息 31 | * @param couponReceiveDetail 领券明细记录信息 32 | */ 33 | void generateQrCode(CouponReceive couponReceive, CouponReceiveDetail couponReceiveDetail); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/PromotionRuleManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.backend.mapper.PromotionRuleManagementMapper; 5 | import lk.project.marketing.base.entity.PromotionRule; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | 12 | @Repository 13 | public class PromotionRuleManagementRepository extends ServiceImpl { 14 | 15 | @Autowired 16 | PromotionRuleManagementMapper promotionRuleManagementMapper; 17 | 18 | /** 19 | * 根据促销活动id获得促销规则列表 20 | * @param activityId 促销活动ID 21 | * @return 22 | */ 23 | public List getPromotionRuleListByActivityId(Long activityId){ 24 | return promotionRuleManagementMapper.getPromotionRuleListByActivityId(activityId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CartInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | 4 | import lk.project.marketing.client.dto.*; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | import java.util.List; 8 | 9 | public interface CartInterface { 10 | 11 | /** 12 | * 添加商品到购物车列表 13 | * @param productDto 14 | * @param memberDto 15 | * @return 16 | */ 17 | ResponseVO addGoodsToCartList(ProductDto productDto, MemberDto memberDto); 18 | 19 | /** 20 | * 获得指定用户的购物车列表 21 | * @param userId 22 | * @return 23 | */ 24 | ResponseVO getCartListFromRedis(String userId); 25 | 26 | /** 27 | * 将本地购物车合并到用户购物车当中 28 | * @param cartDtoList 29 | * @param memberDto 30 | * @return 31 | */ 32 | ResponseVO mergeCartList(List cartDtoList, MemberDto memberDto); 33 | 34 | /** 35 | * 获得用户可用优惠券列表 36 | * @param memberDto 37 | * @return 38 | */ 39 | ResponseVO getAvailableCouponDetailList(MemberDto memberDto); 40 | } 41 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponReceiveHistoryBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.entity.CouponReceiveDetail; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * 发劵历史信息 13 | * Created by alexlu on 2018/11/2. 14 | */ 15 | @Data 16 | public class CouponReceiveHistoryBo implements Serializable { 17 | /** 18 | * 租户ID 19 | */ 20 | private Long companyId; 21 | 22 | /** 23 | * 订单ID 24 | */ 25 | private String orderId; 26 | 27 | /** 28 | * 订单编号 29 | */ 30 | private String orderNo; 31 | 32 | /** 33 | * 原订单或商品项金额 34 | */ 35 | private BigDecimal originalAmount; 36 | 37 | /** 38 | * 优惠后订单或商品项实际支付金额 39 | */ 40 | private BigDecimal finalPayAmount; 41 | 42 | /** 43 | * 发领优惠券模板相关明细列表 44 | */ 45 | private Map> couponReceiveHistoryDataList; 46 | } 47 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/QueryAccountRuleReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class QueryAccountRuleReqBo extends PagerBaseReqBo implements Serializable { 10 | 11 | /** 12 | * 结算规则ID 13 | */ 14 | private Long id; 15 | 16 | /** 17 | * 满减条件类型 0:无条件;1:满金额;2:满数量;3:优惠价 18 | */ 19 | private Integer thresholdType; 20 | 21 | /** 22 | * 满减条件阈值, 0表示无条件阈值 23 | */ 24 | private BigDecimal rewardThreshold; 25 | 26 | /** 27 | * 扣减类型 0:积分;1:抵扣金额;2:折扣;3:其他赠品 28 | */ 29 | private Integer rewardType; 30 | 31 | /** 32 | * 扣减数,包括扣减积分数,金额,折扣率 33 | */ 34 | private BigDecimal rewardAmount; 35 | 36 | /** 37 | * 赠送商品或服务ID 38 | */ 39 | private String rewardProduct; 40 | 41 | /** 42 | * 赠送优惠券ID 43 | */ 44 | private Long rewardActivityId; 45 | 46 | /** 47 | *优惠价 48 | */ 49 | private BigDecimal promotionPrice; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/utils/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.utils; 2 | 3 | /** 4 | * @Title: JasonUtil.java 5 | * @Description: JsonUtil 6 | * @author alexlu 7 | * @date 2017年4月28日 8 | */ 9 | 10 | public class JsonUtil { 11 | // public static List formatList(String jaosnStr,Class clazz){ 12 | // List list = null; 13 | // try{ 14 | // if(StringUtils.isEmpty(jaosnStr)){ 15 | // return null; 16 | // } 17 | // 18 | // List lst = JsonFormatter.toObject(jaosnStr,List.class); 19 | // if(lst.size() > 0){ 20 | // list = lst.stream().map(j->formatObject(j, clazz)).collect(Collectors.toList()); 21 | // } 22 | // }catch(Exception e){ 23 | // e.printStackTrace(); 24 | // return null; 25 | // } 26 | // return list; 27 | // } 28 | 29 | public static T formatObject(Object obj,Class clazz){ 30 | T t = null; 31 | try{ 32 | t = JsonFormatter.toObject(JsonFormatter.toJsonString(obj), clazz); 33 | }catch(Exception e){ 34 | return null; 35 | } 36 | return t; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/QueryAccountRuleReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class QueryAccountRuleReqDto extends PagerBaseRequestDto implements Serializable { 10 | 11 | /** 12 | * 结算规则ID 13 | */ 14 | private Long id; 15 | 16 | /** 17 | * 满减条件类型 0:无条件;1:满金额;2:满数量;3:优惠价 18 | */ 19 | private Integer thresholdType; 20 | 21 | /** 22 | * 满减条件阈值, 0表示无条件阈值 23 | */ 24 | private BigDecimal rewardThreshold; 25 | 26 | /** 27 | * 扣减类型 0:积分;1:抵扣金额;2:折扣;3:其他赠品 28 | */ 29 | private Integer rewardType; 30 | 31 | /** 32 | * 扣减数,包括扣减积分数,金额,折扣率 33 | */ 34 | private BigDecimal rewardAmount; 35 | 36 | /** 37 | * 赠送商品或服务ID 38 | */ 39 | private String rewardProduct; 40 | 41 | /** 42 | * 赠送优惠券ID 43 | */ 44 | private Long rewardActivityId; 45 | 46 | /** 47 | *优惠价 48 | */ 49 | private BigDecimal promotionPrice; 50 | } 51 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponMemberCenterService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.*; 4 | import lk.project.marketing.base.entity.Coupon; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by gupei on 2018/9/18. 10 | * 优惠券会员中心接口, 我的优惠券、积分 11 | */ 12 | public interface CouponMemberCenterService { 13 | 14 | /** 15 | * 查询会员可以获得的优惠券 16 | * @param memberReqBo 会员信息 17 | * @return 18 | */ 19 | List queryMemberQualifiedCoupon(MemberBo memberReqBo); 20 | 21 | /** 22 | * 查询用户优惠券领取记录 23 | * @param userId 用户Id 24 | * @returns 实际发放的优惠券记录 25 | */ 26 | List queryReceivedCoupon( long userId); 27 | 28 | /** 29 | * 查询用户优惠券使用记录 30 | * @param userId 用户Id 31 | * @return 已使用的优惠券 32 | */ 33 | List queryConsumedCoupon(long userId); 34 | 35 | /** 36 | * 查询用户可用优惠券 37 | * @param userId 用户Id 38 | * @return 用户可用优惠券信息 39 | */ 40 | List queryAvailableCoupon(long userId); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/mapper/ActivityMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.PromotionActivity; 9 | 10 | import java.util.List; 11 | 12 | public interface ActivityMapper extends BaseMapper { 13 | 14 | 15 | /** 16 | * 根据优惠券ID获取对应的活动列表 17 | * @param couponId 优惠券ID 18 | * @return 19 | */ 20 | List getActivityListByCouponId(Long couponId); 21 | 22 | /** 23 | * 根据优惠券ID集合获取对应的活动ID集合 24 | * @param couponIdList 25 | * @return 26 | */ 27 | List getActivityIdListByCouponIdList(List couponIdList); 28 | 29 | /** 30 | * 根据促销活动id获取促销活动实体 31 | * @param id 32 | * @return 33 | */ 34 | PromotionActivity getActivityById(Long id); 35 | 36 | /** 37 | * 更新促销活动记录 38 | * @param promotionActivity 39 | * @return 40 | */ 41 | Boolean updateActivity(PromotionActivity promotionActivity); 42 | } 43 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/rpc/CouponSummaryInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.rpc; 2 | 3 | 4 | import lk.project.marketing.client.rpc.CouponSummaryInterface; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | import lk.project.marketing.service.rpc.pojo.BaseResponse; 7 | import lk.project.marketing.service.CouponSummaryService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | public class CouponSummaryInterfaceImpl extends BaseResponse implements CouponSummaryInterface { 11 | 12 | @Autowired 13 | CouponSummaryService couponSummaryService; 14 | 15 | /** 16 | * 获取用户优惠券列表 17 | * @param userId 用户ID 18 | * @return 19 | */ 20 | @Override 21 | public ResponseVO getUserCouponSummary(String userId){ 22 | return getFromData(couponSummaryService.getUserCouponSummary(userId)); 23 | } 24 | 25 | @Override 26 | public ResponseVO getUserCouponDetail(String userId, Long couponId) { 27 | return getFromData(couponSummaryService.getUserCouponDetail(userId, couponId)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/DynamicCalcSelectedCouponBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lk.project.marketing.base.entity.Coupon; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * 用户每次选择优惠券操作信息 11 | * (对应传入的(查询可使用的优惠券接口返回的)SelectCouponUseBo对象) 12 | * Created by alexlu on 2018/11/22. 13 | */ 14 | @Data 15 | public class DynamicCalcSelectedCouponBo implements Serializable { 16 | /** 17 | * 优惠券ID 18 | */ 19 | private Long couponId; 20 | 21 | /** 22 | * 用户选择的优惠券使用数量 23 | */ 24 | private Long couponSelectQuantity = 0L; 25 | 26 | /** 27 | * 券额(积分数,金额,折扣率等) 28 | */ 29 | private BigDecimal couponAmount; 30 | 31 | /** 32 | * 当前可用优惠券项最新状态(0-未选中,1-已选中,2-不可使用) 33 | * UI传入和后台返回通用 34 | */ 35 | private Integer status; 36 | 37 | /** 38 | * 优惠券扣除的金额 39 | */ 40 | private BigDecimal couponReducedAmount; 41 | 42 | /** 43 | * 用户当前实时可用优惠券数量 44 | */ 45 | private Long couponAvailableQuantity; 46 | 47 | private Coupon coupon; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/AccountRuleManagementService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service; 2 | 3 | 4 | import lk.project.marketing.base.bo.AccountRuleReqBo; 5 | import lk.project.marketing.base.bo.PagerBaseRespBo; 6 | import lk.project.marketing.base.bo.QueryAccountRuleReqBo; 7 | import lk.project.marketing.base.entity.AccountRule; 8 | import lk.project.marketing.client.dto.PagerBaseResponseDto; 9 | 10 | /** 11 | * 结算规则相关后台管理服务 12 | * Created by luchao on 2018/12/25. 13 | */ 14 | public interface AccountRuleManagementService { 15 | 16 | /** 17 | * 新增或更新优惠券结算规则 18 | * @param accountRuleReqBo 19 | * @return 20 | */ 21 | Boolean saveAccountRule(AccountRuleReqBo accountRuleReqBo); 22 | 23 | /** 24 | * 逻辑删除优惠券结算规则 25 | * @param accountRuleId 26 | * @return 27 | */ 28 | Boolean deleteAccountRule(Long accountRuleId); 29 | 30 | /** 31 | * 分页根据条件查询优惠券结算规则 32 | * @param queryAccountRuleReqBo 33 | * @return 34 | */ 35 | PagerBaseRespBo queryAccountRule(QueryAccountRuleReqBo queryAccountRuleReqBo); 36 | } 37 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/SelectCouponReceiveInfoDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | import java.sql.Date; 9 | 10 | @Data 11 | public class SelectCouponReceiveInfoDto implements Serializable { 12 | 13 | /** 14 | * 优惠券领劵主记录ID 15 | */ 16 | private Long couponReceiveId; 17 | 18 | /** 19 | * 消费优惠券(模板)记录ID 20 | */ 21 | private Long couponId; 22 | 23 | /** 24 | * 优惠券领劵剩余数量 25 | */ 26 | private Long couponReceiveRemainQuantity; 27 | 28 | /** 29 | * 券额,包含积分数,金额,折扣率 30 | */ 31 | private BigDecimal couponAmount; 32 | 33 | /** 34 | * 优惠券领劵记录状态(0-已领取未使用,1-已使用,2-使用中,3-已过期) 35 | */ 36 | private Integer couponReceiveStatus; 37 | 38 | /** 39 | * 权重值,数值小表示优先 40 | */ 41 | private Integer couponWeight; 42 | 43 | /** 44 | * 优惠券使用截至日期 45 | */ 46 | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") 47 | private Date couponEndDate; 48 | } 49 | -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api.config; 2 | import org.springframework.context.annotation.Bean; 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.cors.CorsConfiguration; 5 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 6 | import org.springframework.web.filter.CorsFilter; 7 | 8 | /** 9 | * 全局跨域设置 10 | * Created by alexlu 11 | * 2018/11/27. 12 | */ 13 | 14 | @Configuration 15 | public class CorsConfig { 16 | private CorsConfiguration buildConfig() { 17 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 18 | corsConfiguration.addAllowedOrigin("*"); 19 | corsConfiguration.addAllowedHeader("*"); 20 | corsConfiguration.addAllowedMethod("*"); 21 | return corsConfiguration; 22 | } 23 | 24 | @Bean 25 | public CorsFilter corsFilter() { 26 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 27 | source.registerCorsConfiguration("/**", buildConfig()); 28 | return new CorsFilter(source); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/CouponReduceInfoDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * 优惠券扣减信息DTO 10 | * Created by alexlu on 2018/11/22. 11 | */ 12 | @Data 13 | public class CouponReduceInfoDto implements Serializable { 14 | /** 15 | * 用户ID 16 | */ 17 | private String userId; 18 | 19 | /** 20 | * 优惠券扣减目标类型(1-订单,2-商品) 21 | */ 22 | private Integer couponReduceTargetFlag; 23 | 24 | /** 25 | * 订单ID 26 | */ 27 | private String orderId; 28 | 29 | /** 30 | * 订单编号 31 | */ 32 | private String orderNo; 33 | 34 | /** 35 | * 订单明细项ID 36 | */ 37 | private String orderItemId; 38 | 39 | /** 40 | * 商品/服务SKU ID 41 | */ 42 | private String skuId; 43 | 44 | /** 45 | * 商品/服务销售单价 46 | */ 47 | private BigDecimal goodsSalePrice; 48 | 49 | /** 50 | * 商品/服务数量 51 | */ 52 | private Long goodsQuantity; 53 | 54 | /** 55 | * 商家ID 56 | */ 57 | private String shopId; 58 | } 59 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/mapper/ActivityManagementMapper.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.mapper; 2 | 3 | /** 4 | * Created by Pei Gu on 2018/9/13. 5 | */ 6 | 7 | import com.baomidou.mybatisplus.mapper.BaseMapper; 8 | import lk.project.marketing.base.entity.PromotionActivity; 9 | 10 | import java.util.List; 11 | 12 | public interface ActivityManagementMapper extends BaseMapper { 13 | 14 | 15 | /** 16 | * 根据优惠券ID获取对应的活动列表 17 | * @param couponId 优惠券ID 18 | * @return 19 | */ 20 | List getActivityListByCouponId(Long couponId); 21 | 22 | /** 23 | * 根据优惠券ID集合获取对应的活动ID集合 24 | * @param couponIdList 25 | * @return 26 | */ 27 | List getActivityIdListByCouponIdList(List couponIdList); 28 | 29 | /** 30 | * 根据促销活动id获取促销活动实体 31 | * @param id 32 | * @return 33 | */ 34 | PromotionActivity getActivityById(Long id); 35 | 36 | /** 37 | * 更新促销活动记录 38 | * @param promotionActivity 39 | * @return 40 | */ 41 | Boolean updateActivity(PromotionActivity promotionActivity); 42 | } 43 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/entity/CouponReceiveDetail.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * Created by gupei on 2018/09/20. 11 | * 领券/发券详情实体对象 12 | */ 13 | @TableName("t_coupon_receive_detail") 14 | @Data 15 | public class CouponReceiveDetail extends BaseEntity { 16 | /** 17 | * 优惠券领取ID 18 | */ 19 | @TableField("coupon_receive_id") 20 | private Long couponReceiveId; 21 | 22 | /** 23 | * 优惠券编码,发券时按规则生成 24 | */ 25 | @TableField("coupon_no") 26 | private String couponNo; 27 | 28 | /** 29 | * 券额(积分数,金额,折扣率等) 30 | */ 31 | @TableField("coupon_amount") 32 | private BigDecimal couponAmount; 33 | 34 | /** 35 | * 优惠券二维码地址URL 36 | */ 37 | @TableField("coupon_qr_code_url") 38 | private String couponQrCodeUrl; 39 | 40 | /** 41 | * 状态,0为已领取未使用,1为已使用,2为使用中,3为已过期 42 | */ 43 | @TableField("status") 44 | private Integer status; 45 | } 46 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.config; 2 | import org.springframework.context.annotation.Bean; 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.cors.CorsConfiguration; 5 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 6 | import org.springframework.web.filter.CorsFilter; 7 | 8 | /** 9 | * 全局跨域设置 10 | * Created by alexlu 11 | * 2018/11/27. 12 | */ 13 | 14 | @Configuration 15 | public class CorsConfig { 16 | private CorsConfiguration buildConfig() { 17 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 18 | corsConfiguration.addAllowedOrigin("*"); 19 | corsConfiguration.addAllowedHeader("*"); 20 | corsConfiguration.addAllowedMethod("*"); 21 | return corsConfiguration; 22 | } 23 | 24 | @Bean 25 | public CorsFilter corsFilter() { 26 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 27 | source.registerCorsConfiguration("/**", buildConfig()); 28 | return new CorsFilter(source); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/OrderDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.sql.Time; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | @Data 12 | public class OrderDto implements Serializable { 13 | /** 14 | * 订单ID 15 | */ 16 | private String orderId; 17 | 18 | /** 19 | * 订单编号 20 | */ 21 | private String orderNo; 22 | 23 | /** 24 | * 订单总金额(动态选劵后参与满减条件计算的虚拟总金额) 25 | */ 26 | private BigDecimal totalOrderAmount; 27 | 28 | /** 29 | * 订单原始(优惠前)总金额 30 | */ 31 | private BigDecimal originOrderAmount; 32 | 33 | /** 34 | * 结算后实际应付金额 35 | */ 36 | private BigDecimal payOrderAmount; 37 | 38 | /** 39 | * 下单时间 40 | */ 41 | private Date orderDate; 42 | 43 | /** 44 | * 预约时间 45 | */ 46 | private Time reserveTime; 47 | 48 | /** 49 | * 订单明细项 50 | */ 51 | private List orderItemList; 52 | 53 | /** 54 | * 订单所使用的优惠券 55 | */ 56 | private List useCoupons; 57 | } 58 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.CouponReqBo; 4 | import lk.project.marketing.base.bo.QueryCouponReqBo; 5 | import lk.project.marketing.base.bo.UseCouponBo; 6 | import lk.project.marketing.base.entity.Coupon; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by gupei on 2018/9/12. 12 | */ 13 | public interface CouponService { 14 | 15 | /** 16 | * 创建优惠券及相关规则 17 | * @param couponRequest 18 | */ 19 | Boolean createCoupon(CouponReqBo couponRequest); 20 | 21 | /** 22 | * 更新优惠券及相关规则 23 | * @param couponRequest 24 | */ 25 | Boolean updateCoupon(CouponReqBo couponRequest); 26 | 27 | /** 28 | * 查询满足条件的优惠券 29 | * @param queryCouponReq 30 | * @return 31 | */ 32 | List queryCoupon(QueryCouponReqBo queryCouponReq); 33 | 34 | /** 35 | * 按扣减类型排序用户请求劵列表 36 | * 依次扣减满减金额、折扣、积分 37 | * @param originUserRequestCouponList 原始用户请求劵列表 38 | * @return 已排序的用户请求劵列表 39 | */ 40 | List sortUserRequestCouponsByRewardType(List originUserRequestCouponList); 41 | } 42 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/OrderItemDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | @Data 10 | public class OrderItemDto implements Serializable { 11 | 12 | /** 13 | * 订单明细项ID 14 | */ 15 | private String orderItemId; 16 | 17 | /** 18 | * 商品/服务SKU ID 19 | */ 20 | private String skuId; 21 | 22 | /** 23 | * 商家ID 24 | */ 25 | private String shopId; 26 | 27 | /** 28 | * 商铺名称 29 | */ 30 | private String shopName; 31 | 32 | /** 33 | * 商品/服务分类 34 | */ 35 | private String skuCategory; 36 | 37 | /** 38 | * 商品/服务销售单价 39 | */ 40 | private BigDecimal goodsSalePrice; 41 | 42 | /** 43 | * 商品/服务数量 44 | */ 45 | private Long goodsQuantity; 46 | 47 | /** 48 | * 商品/服务原始金额 49 | */ 50 | private BigDecimal totalGoodsAmount; 51 | 52 | /** 53 | * 结算后实际应付金额 54 | */ 55 | private BigDecimal payGoodsAmount; 56 | 57 | /** 58 | * 所使用的优惠券 59 | */ 60 | private List useCoupons; 61 | } 62 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/entity/CouponConsumeDetail.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import lombok.Data; 6 | 7 | /** 8 | * Created by alexlu on 2018/10/29. 9 | */ 10 | @Data 11 | @TableName("t_coupon_consume_detail") 12 | public class CouponConsumeDetail extends BaseEntity { 13 | /** 14 | * 消费优惠券ID 15 | */ 16 | @TableField("coupon_consume_id") 17 | private Long couponConsumeId; 18 | 19 | /** 20 | * 发放优惠券ID 21 | */ 22 | @TableField("coupon_receive_id") 23 | private Long couponReceiveId; 24 | 25 | /** 26 | * 发放优惠券明细ID集合(逗号间隔 27 | */ 28 | @TableField("coupon_receive_detail_ids") 29 | private String couponReceiveDetailIds; 30 | 31 | /** 32 | * 促销活动ID 33 | */ 34 | @TableField("activity_id") 35 | private Long activityId; 36 | 37 | /** 38 | * 本次使用数量 39 | */ 40 | @TableField("consume_quantity") 41 | private Long consumeQuantity; 42 | 43 | // /** 44 | // *发券信息 45 | // */ 46 | // private CouponReceive couponReceive; 47 | } 48 | -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/controller/CouponReceiveController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api.controller; 2 | 3 | import lk.project.marketing.api.common.BaseController; 4 | import lk.project.marketing.client.dto.ProduceCouponDto; 5 | import lk.project.marketing.client.rpc.CouponReceiveInterface; 6 | import lk.project.marketing.client.vo.ResponseVO; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @RestController 13 | @RequestMapping("/couponReceive") 14 | public class CouponReceiveController extends BaseController { 15 | 16 | @Autowired 17 | CouponReceiveInterface couponReceiveInterface; 18 | 19 | /** 20 | * 单次领券接口 21 | * @param produceCouponDto 22 | * @return 23 | */ 24 | @RequestMapping("/produceCoupon") 25 | public ResponseVO produceCoupon(@RequestBody ProduceCouponDto produceCouponDto){ 26 | return couponReceiveInterface.produceCoupon(produceCouponDto.getCouponReceiveReqDto(),produceCouponDto.getMemberDto()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/impl/ActivityManagementServiceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.impl; 2 | 3 | 4 | import lk.project.marketing.backend.repository.ActivityManagementRepository; 5 | import lk.project.marketing.backend.service.ActivityManagementService; 6 | import lk.project.marketing.base.bo.ActivityReqBo; 7 | import lk.project.marketing.base.entity.PromotionActivity; 8 | import org.springframework.beans.BeanUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * Created by gupei on 2018/09/11. 14 | */ 15 | @Service 16 | public class ActivityManagementServiceImpl implements ActivityManagementService { 17 | 18 | @Autowired 19 | ActivityManagementRepository activityManagementRepository; 20 | 21 | /** 22 | * 新增或更新促销活动 23 | * @param activityReqBo 24 | * @return 25 | */ 26 | @Override 27 | public Boolean saveActivity(ActivityReqBo activityReqBo){ 28 | PromotionActivity activity = new PromotionActivity(); 29 | BeanUtils.copyProperties(activityReqBo,activity); 30 | return activityManagementRepository.insertOrUpdate(activity); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponSummaryService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.*; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by gupei on 2018/12/07. 10 | */ 11 | public interface CouponSummaryService { 12 | 13 | /** 14 | * 获取用户优惠券列表 15 | * @param userId 用户ID 16 | * @return 17 | */ 18 | List getUserCouponSummary(String userId); 19 | 20 | /** 21 | * 获取用户优惠券领取详情 22 | * @param userId 用户ID 23 | * @param couponId 优惠券ID 24 | * @return 25 | */ 26 | List getUserCouponDetail(String userId, Long couponId ); 27 | 28 | /** 29 | * 获取用户下单时指定优惠券的可用数量 30 | * @param couponId 优惠券Id 31 | * @param orderReqBo 订单信息 32 | * @param orderItemReqBo 订单明细项信息 33 | * @param memberReqBo 用户会员信息 34 | * @return 35 | */ 36 | Long getCouponAvailableQuantityForOrder(Long couponId, 37 | OrderBo orderReqBo, 38 | OrderItemBo orderItemReqBo, 39 | MemberBo memberReqBo); 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/OrderBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.sql.Time; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by gupei on 2018/9/18. 13 | * 订单接口对象, 包含购买商品/服务明细及使用优惠券信息 .供结算使用 14 | */ 15 | @Data 16 | public class OrderBo implements Serializable { 17 | /** 18 | * 订单ID 19 | */ 20 | private String orderId; 21 | 22 | /** 23 | * 订单编号 24 | */ 25 | private String orderNo; 26 | 27 | /** 28 | * 订单参与计算总金额(动态选劵后参与满减条件计算的虚拟总金额) 29 | */ 30 | private BigDecimal totalOrderAmount; 31 | 32 | /** 33 | * 订单原始(优惠前)总金额 34 | */ 35 | private BigDecimal originOrderAmount; 36 | 37 | /** 38 | * 结算后实际应付金额 39 | */ 40 | private BigDecimal payOrderAmount; 41 | 42 | /** 43 | * 下单时间 44 | */ 45 | private Date orderDate; 46 | 47 | /** 48 | * 预约时间 49 | */ 50 | private Time reserveTime; 51 | 52 | /** 53 | * 订单明细项 54 | */ 55 | private List orderItemList; 56 | 57 | /** 58 | * 订单所使用的优惠券 59 | */ 60 | private List useCoupons; 61 | } 62 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/OrderItemBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by gupei on 2018/9/18. 11 | * 订单接口对象, 包含购买商品/服务明细及使用优惠券信息 .供结算使用 12 | */ 13 | @Data 14 | public class OrderItemBo implements Serializable { 15 | 16 | /** 17 | * 订单明细项ID 18 | */ 19 | private String orderItemId; 20 | 21 | /** 22 | * 商品/服务SKU ID 23 | */ 24 | private String skuId; 25 | 26 | /** 27 | * 商家ID 28 | */ 29 | private String shopId; 30 | 31 | /** 32 | * 商铺名称 33 | */ 34 | private String shopName; 35 | 36 | /** 37 | * 商品/服务分类 38 | */ 39 | private String skuCategory; 40 | 41 | /** 42 | * 商品/服务销售单价 43 | */ 44 | private BigDecimal goodsSalePrice; 45 | 46 | /** 47 | * 商品/服务原始金额 48 | */ 49 | private BigDecimal totalGoodsAmount; 50 | 51 | /** 52 | * 商品/服务数量 53 | */ 54 | private Long goodsQuantity; 55 | 56 | /** 57 | * 结算后实际应付金额 58 | */ 59 | private BigDecimal payGoodsAmount; 60 | 61 | /** 62 | * 所使用的优惠券 63 | */ 64 | private List useCoupons; 65 | } 66 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/ProductDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class ProductDto implements Serializable { 10 | 11 | /** 12 | * 商品id 13 | */ 14 | private String skuId; 15 | 16 | /** 17 | * 商品标题 18 | */ 19 | private String productTitle; 20 | 21 | /** 22 | * 商品名称 23 | */ 24 | private String productName; 25 | 26 | /** 27 | * 商家id 28 | */ 29 | private String shopId; 30 | 31 | /** 32 | * 商铺名称 33 | */ 34 | private String shopName; 35 | 36 | /** 37 | * 商品价格 38 | */ 39 | private BigDecimal originPrice; 40 | 41 | /** 42 | * 优惠后价格 43 | */ 44 | private BigDecimal actualPrice; 45 | 46 | /** 47 | * 购买数量 48 | */ 49 | private Long purchaseQuantity; 50 | 51 | /** 52 | * 库存数量 53 | */ 54 | private Long stockQuantity; 55 | 56 | /** 57 | * 商品/服务分类 58 | */ 59 | private String skuCategoryName; 60 | 61 | /** 62 | * 商品型号 63 | */ 64 | private String productModelNo; 65 | 66 | /** 67 | * 商品规格 68 | */ 69 | private String productSpec; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/init/MarketingServiceApplication.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.init; 2 | 3 | import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.ImportResource; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | /** 13 | * Created by Gupei on 2018/10/31. 14 | */ 15 | @ImportResource(value = {"classpath:/config/*.xml"}) 16 | @ComponentScan(basePackages = {"lk.project.marketing"}) 17 | @EnableTransactionManagement(proxyTargetClass = true) 18 | @SpringBootApplication 19 | @Slf4j 20 | public class MarketingServiceApplication { 21 | public static void main(String... args) { 22 | SpringApplication.run(MarketingServiceApplication.class, args); 23 | System.out.println("ServiceApplication started......."); 24 | } 25 | 26 | @Bean 27 | public OptimisticLockerInterceptor optimisticLockerInterceptor() { 28 | return new OptimisticLockerInterceptor(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/ProductBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class ProductBo implements Serializable { 10 | 11 | /** 12 | * 商品id 13 | */ 14 | private String skuId; 15 | 16 | /** 17 | * 商品标题 18 | */ 19 | private String title; 20 | 21 | /** 22 | * 商品名称 23 | */ 24 | private String goodsName; 25 | 26 | /** 27 | * 商家id 28 | */ 29 | private String shopId; 30 | 31 | /** 32 | * 商铺名称 33 | */ 34 | private String shopName; 35 | 36 | /** 37 | * 商品价格 38 | */ 39 | private BigDecimal price; 40 | 41 | /** 42 | * 优惠后价格 43 | */ 44 | private BigDecimal costPrice; 45 | 46 | /** 47 | * 购买数量 48 | */ 49 | private Long quantity; 50 | 51 | /** 52 | * 库存数量 53 | */ 54 | private Long stockCount; 55 | 56 | /** 57 | * 商品/服务分类 58 | */ 59 | private String skuCategory; 60 | 61 | /** 62 | * 商品型号 63 | */ 64 | private String productModelNo; 65 | 66 | /** 67 | * 商品规格 68 | */ 69 | private String specification; 70 | 71 | /** 72 | * 商品图片地址 73 | */ 74 | private String imageUrl; 75 | } 76 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/init/MarketingBackendServiceApplication.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.init; 2 | 3 | import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.ImportResource; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | /** 13 | * Created by Gupei on 2018/10/31. 14 | */ 15 | @ImportResource(value = {"classpath:/config/*.xml"}) 16 | @ComponentScan(basePackages = {"lk.project.marketing"}) 17 | @EnableTransactionManagement(proxyTargetClass = true) 18 | @SpringBootApplication 19 | @Slf4j 20 | public class MarketingBackendServiceApplication { 21 | public static void main(String... args) { 22 | SpringApplication.run(MarketingBackendServiceApplication.class, args); 23 | System.out.println("ServiceApplication started......."); 24 | } 25 | 26 | @Bean 27 | public OptimisticLockerInterceptor optimisticLockerInterceptor() { 28 | return new OptimisticLockerInterceptor(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/CouponReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class CouponReqDto implements Serializable { 9 | 10 | /** 11 | * 优惠券模板ID 12 | */ 13 | private Long id; 14 | 15 | /** 16 | * 结算规则ID 17 | */ 18 | private Long accountRuleId; 19 | 20 | /** 21 | * 公司,租户ID 22 | */ 23 | private Integer companyId; 24 | 25 | /** 26 | * 所属类型, 0:积分;1:满减(包括现金抵扣和折扣,参考满减规则),2:赠送赠品 27 | */ 28 | private Integer couponType; 29 | 30 | /** 31 | * 使用该优惠券产生的扣减是否计入满减条件的支付总量 32 | */ 33 | protected Boolean accumulated; 34 | 35 | /** 36 | * 优惠券名称 37 | */ 38 | private String couponName; 39 | 40 | /** 41 | * 优惠券活动描述 42 | */ 43 | private String couponDesc; 44 | 45 | /** 46 | * 优惠券图标的URL地址 47 | */ 48 | private String icon; 49 | 50 | /** 51 | * 优惠券使用规则之间关系,0:排他;1:并存(累计);2:择优 52 | */ 53 | private Integer accumulateType; 54 | 55 | /** 56 | * 权重值,数值小表示优先 57 | */ 58 | private Integer weight; 59 | 60 | /** 61 | * 退款时是否支持退回 62 | */ 63 | private Boolean supportReturn; 64 | 65 | /** 66 | * 状态,0已启用,1未启用 67 | */ 68 | private Integer status; 69 | } 70 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/AccountRuleReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Data 8 | public class AccountRuleReqBo extends PagerBaseReqBo{ 9 | 10 | /** 11 | * 结算规则ID 12 | */ 13 | private Long id; 14 | 15 | /** 16 | * 结算规则名称 17 | */ 18 | private String ruleName; 19 | 20 | /** 21 | * 规则描述 22 | */ 23 | private String ruleDesc; 24 | 25 | /** 26 | * 满减条件类型 0:无条件;1:满金额;2:满数量;3:优惠价 27 | */ 28 | private Integer thresholdType; 29 | 30 | /** 31 | * 满减条件阈值, 0表示无条件阈值 32 | */ 33 | private BigDecimal rewardThreshold; 34 | 35 | /** 36 | * 扣减类型 0:积分;1:抵扣金额;2:折扣;3:其他赠品 37 | */ 38 | private Integer rewardType; 39 | 40 | /** 41 | * 扣减数,包括扣减积分数,金额,折扣率 42 | */ 43 | private BigDecimal rewardAmount; 44 | 45 | /** 46 | * 赠送商品或服务ID 47 | */ 48 | private String rewardProduct; 49 | 50 | /** 51 | * 赠送优惠券ID 52 | */ 53 | private Long rewardActivityId; 54 | 55 | /** 56 | * 赠品描述 57 | */ 58 | private String rewardDesc; 59 | 60 | /** 61 | *优惠价 62 | */ 63 | private BigDecimal promotionPrice; 64 | 65 | /** 66 | * 金额兑换积分比例,积分除以该比例等于金额 67 | */ 68 | private BigDecimal exchangeRatio; 69 | } 70 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/OrderSettleResultBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * 订单结算结果类 10 | * Created by alexlu on 2018/11/20. 11 | */ 12 | @Data 13 | public class OrderSettleResultBo implements Serializable { 14 | 15 | /** 16 | * 订单ID 17 | */ 18 | private String orderId; 19 | 20 | /** 21 | * 订单编号 22 | */ 23 | private String orderNo; 24 | 25 | /** 26 | * 订单参与计算总金额(动态选劵后参与满减条件计算的虚拟总金额) 27 | */ 28 | private BigDecimal totalOrderAmount; 29 | 30 | /** 31 | * 订单原始(优惠前)总金额 32 | */ 33 | private BigDecimal originOrderAmount; 34 | 35 | /** 36 | * 结算后实际应付金额 37 | */ 38 | private BigDecimal payOrderAmount; 39 | 40 | /** 41 | * 订单总优惠金额 42 | */ 43 | private BigDecimal totalReduceAmount; 44 | 45 | /** 46 | * 优惠劵满减扣减金额 47 | */ 48 | private BigDecimal subTotalFullConditionReduceAmount; 49 | 50 | /** 51 | * 优惠劵折扣扣减金额 52 | */ 53 | private BigDecimal subTotalDiscountReduceAmount; 54 | 55 | /** 56 | * 优惠劵积分兑换金额 57 | */ 58 | private BigDecimal subTotalCreditExchangeReduceAmount; 59 | 60 | /** 61 | * 优惠劵一次性扣减(一口价单价商品)金额 62 | */ 63 | private BigDecimal subTotalOnceReduceAmount; 64 | } 65 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/UserCouponConsumeProcessBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.List; 8 | 9 | /** 10 | * 用户使用优惠券处理操作类 11 | * Created by alexlu on 2018/11/7. 12 | */ 13 | @Data 14 | public class UserCouponConsumeProcessBo implements Serializable { 15 | /** 16 | * 用户ID 17 | */ 18 | private String userId; 19 | 20 | /** 21 | * 用户编号 22 | */ 23 | private String userCode; 24 | 25 | /** 26 | * 商家店铺ID 27 | */ 28 | private String shopId; 29 | 30 | /** 31 | * 订单ID 32 | */ 33 | private String orderId; 34 | 35 | /** 36 | * 订单编号 37 | */ 38 | private String orderNo; 39 | 40 | /** 41 | * 订单明细项ID 42 | */ 43 | private String orderItemId; 44 | 45 | // /** 46 | // * 商品/服务ID 47 | // */ 48 | // private String skuId; 49 | 50 | /** 51 | * 订单项/商品购买数量 52 | */ 53 | private Long goodsQuantity; 54 | 55 | /** 56 | * 原订单或商品项金额 57 | */ 58 | private BigDecimal originalAmount; 59 | 60 | /** 61 | * 优惠后订单或商品项实际支付金额 62 | */ 63 | private BigDecimal finalPayAmount; 64 | 65 | /** 66 | * 各种优惠券扣减金额信息 67 | */ 68 | private List couponReduceAmountList; 69 | } 70 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/entity/PromotionRule.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import lombok.Data; 6 | 7 | /** 8 | * Created by gupei on 2018/09/13. 9 | * 活动规则 10 | */ 11 | @TableName("t_promotion_rule") 12 | @Data 13 | public class PromotionRule extends BaseEntity { 14 | 15 | /** 16 | * 促销活动ID 17 | */ 18 | @TableField("activity_id") 19 | private Long activityId; 20 | 21 | /** 22 | * 规则名称 23 | */ 24 | @TableField("rule_name") 25 | private String ruleName; 26 | 27 | /** 28 | * 规则类型 0:发放规则;1:使用规则 29 | */ 30 | @TableField("rule_type") 31 | private Integer ruleType; 32 | 33 | /** 34 | * 用户适用条件 json字符串 35 | */ 36 | @TableField("user_condition") 37 | private String userCondition; 38 | 39 | /** 40 | * 商品或服务适用条件 json字符串 41 | */ 42 | @TableField("sku_condition") 43 | private String skuCondition; 44 | 45 | @TableField("order_condition") 46 | private String orderCondition; 47 | 48 | /** 49 | * 适用时间范围条件 条件表达式 50 | */ 51 | @TableField("time_condition") 52 | private String timeCondition; 53 | 54 | /** 55 | * 其他使用范围条件 json字符串 56 | */ 57 | @TableField("extras_condition") 58 | private String extrasCondition; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/AccountRuleReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class AccountRuleReqDto extends PagerBaseRequestDto implements Serializable { 10 | 11 | /** 12 | * 结算规则ID 13 | */ 14 | private Long id; 15 | 16 | /** 17 | * 结算规则名称 18 | */ 19 | private String ruleName; 20 | 21 | /** 22 | * 规则描述 23 | */ 24 | private String ruleDesc; 25 | 26 | /** 27 | * 满减条件类型 0:无条件;1:满金额;2:满数量;3:优惠价 28 | */ 29 | private Integer thresholdType; 30 | 31 | /** 32 | * 满减条件阈值, 0表示无条件阈值 33 | */ 34 | private BigDecimal rewardThreshold; 35 | 36 | /** 37 | * 扣减类型 0:积分;1:抵扣金额;2:折扣;3:其他赠品 38 | */ 39 | private Integer rewardType; 40 | 41 | /** 42 | * 扣减数,包括扣减积分数,金额,折扣率 43 | */ 44 | private BigDecimal rewardAmount; 45 | 46 | /** 47 | * 赠送商品或服务ID 48 | */ 49 | private String rewardProduct; 50 | 51 | /** 52 | * 赠送优惠券ID 53 | */ 54 | private Long rewardActivityId; 55 | 56 | /** 57 | * 赠品描述 58 | */ 59 | private String rewardDesc; 60 | 61 | /** 62 | *优惠价 63 | */ 64 | private BigDecimal promotionPrice; 65 | 66 | /** 67 | * 金额兑换积分比例,积分除以该比例等于金额 68 | */ 69 | private BigDecimal exchangeRatio; 70 | } 71 | -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/controller/CouponSummaryController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api.controller; 2 | 3 | import lk.project.marketing.api.common.BaseController; 4 | import lk.project.marketing.client.rpc.CouponSummaryInterface; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("/couponSummary") 13 | public class CouponSummaryController extends BaseController { 14 | 15 | @Autowired 16 | CouponSummaryInterface couponSummaryInterface; 17 | 18 | /** 19 | * 获取用户优惠券列表 20 | * @param userId 21 | * @return 22 | */ 23 | @RequestMapping("/getUserCoupon") 24 | public ResponseVO produceCoupon(@RequestParam String userId){ 25 | return couponSummaryInterface.getUserCouponSummary(userId); 26 | } 27 | 28 | /** 29 | * 获取用户优惠券领取详情 30 | * @param userId 用户ID 31 | * @param couponId 优惠券ID 32 | * @return 33 | */ 34 | @RequestMapping("/getUserCouponDetail") 35 | public ResponseVO produceCoupon(@RequestParam String userId,@RequestParam Long couponId){ 36 | return couponSummaryInterface.getUserCouponDetail(userId,couponId); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/rpc/CouponConsumeInterface.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.rpc; 2 | 3 | import lk.project.marketing.client.dto.*; 4 | import lk.project.marketing.client.vo.ResponseVO; 5 | 6 | public interface CouponConsumeInterface { 7 | 8 | /** 9 | * 查询订单关联的优惠券使用记录 10 | * @param queryOrderConsumedCouponReqDto 11 | * @return 12 | */ 13 | ResponseVO queryOrderConsumedCoupon(QueryOrderConsumedCouponReqDto queryOrderConsumedCouponReqDto); 14 | 15 | /** 16 | * 查询会员购买单项商品/服务可使用的优惠券 17 | * @param queryItemMatchedCouponReqDto 18 | * @return 19 | */ 20 | ResponseVO queryMatchedCouponForPurchaseItem(QueryItemMatchedCouponReqDto queryItemMatchedCouponReqDto); 21 | 22 | /** 23 | * 查询会员/用户下单可使用的优惠券 24 | * @param queryOrderMatchedCouponDto 25 | * @return 26 | */ 27 | ResponseVO queryMatchedCouponForOrder(QueryOrderMatchedCouponDto queryOrderMatchedCouponDto); 28 | 29 | /** 30 | * 将可用优惠券明细列表按优先使用策略排序 31 | * @param sortAvailableMatchedCouponsReqDto 32 | * @return 33 | */ 34 | ResponseVO sortAvailableMatchedCoupons(SortAvailableMatchedCouponsReqDto sortAvailableMatchedCouponsReqDto); 35 | 36 | /** 37 | * 校验用券信息,每一种优惠券按使用策略顺序更新领券记录状态,并更新用户中心优惠券信息 38 | * @param consumeCouponReqDto 39 | * @return 40 | */ 41 | ResponseVO consumeCoupon(ConsumeCouponReqDto consumeCouponReqDto)throws Exception; 42 | } 43 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/CouponReceiveService.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service; 2 | 3 | import lk.project.marketing.base.bo.CouponReceiveBo; 4 | import lk.project.marketing.base.bo.CouponReceiveReqBo; 5 | import lk.project.marketing.base.bo.MemberBo; 6 | import lk.project.marketing.base.bo.OrderBo; 7 | import lk.project.marketing.base.entity.Coupon; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by gupei on 2018/9/18. 13 | * 优惠券发放接口 14 | */ 15 | public interface CouponReceiveService { 16 | 17 | /** 18 | * 单次领券接口 19 | * @param couponReceiveReqBo 领券请求对象 20 | * @param memberReqBo 会员信息 21 | * @returns 22 | */ 23 | CouponReceiveBo produceCoupon(CouponReceiveReqBo couponReceiveReqBo,MemberBo memberReqBo); 24 | 25 | /** 26 | * 根据订单生成可发放的优惠券 27 | * @param qualifiedCoupons 有资格获得的优惠券 28 | * @param memberReqBo 会员信息 29 | * @param orderReqBo 订单信息 30 | * @returns 31 | */ 32 | List produceCouponForOrder(List qualifiedCoupons, 33 | MemberBo memberReqBo, 34 | OrderBo orderReqBo); 35 | 36 | /** 37 | * 优惠券退回接口 38 | * 判断优惠券是否可以退回;更新用户优惠券状态及用户优惠券汇总信息 39 | * @param refundCoupons 待退回的优惠券 40 | * @return 退回的优惠券 41 | */ 42 | List getRefundCoupon(List refundCoupons); 43 | } 44 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Created by gupei on 2018/9/18. 10 | * 优惠券模板保存接口对象 11 | */ 12 | @Data 13 | public class CouponReqBo implements Serializable { 14 | 15 | /** 16 | * 优惠券模板ID 17 | */ 18 | private Long id; 19 | 20 | /** 21 | * 结算规则ID 22 | */ 23 | private Long accountRuleId; 24 | 25 | /** 26 | * 公司,租户ID 27 | */ 28 | private Integer companyId; 29 | 30 | /** 31 | * 所属类型, 0:积分;1:满减(包括现金抵扣和折扣,参考满减规则),2:赠送赠品 32 | */ 33 | private Integer couponType; 34 | 35 | /** 36 | * 使用该优惠券产生的扣减是否计入满减条件的支付总量 37 | */ 38 | protected Boolean accumulated; 39 | 40 | /** 41 | * 优惠券名称 42 | */ 43 | private String couponName; 44 | 45 | /** 46 | * 优惠券活动描述 47 | */ 48 | private String couponDesc; 49 | 50 | /** 51 | * 优惠券图标的URL地址 52 | */ 53 | private String icon; 54 | 55 | /** 56 | * 优惠券使用规则之间关系,0:排他;1:并存(累计);2:择优 57 | */ 58 | private Integer accumulateType; 59 | 60 | /** 61 | * 权重值,数值小表示优先 62 | */ 63 | private Integer weight; 64 | 65 | /** 66 | * 退款时是否支持退回 67 | */ 68 | private Boolean supportReturn; 69 | 70 | /** 71 | * 状态,0已启用,1未启用 72 | */ 73 | private Integer status; 74 | } 75 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponStatusEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 优惠券状态枚举 5 | */ 6 | public enum CouponStatusEnum { 7 | USED(0, "已启用"), 8 | NOT_USED(1, "未启用"); 9 | 10 | /** 11 | * 优惠券状态编码 12 | */ 13 | private Integer code; 14 | 15 | /** 16 | * 状态名称 17 | */ 18 | private String statusName; 19 | 20 | 21 | /** 22 | * 使用优惠券状态码和优惠券状态名称构造枚举 23 | * 24 | * @param code 优惠券状态编码 25 | * @param statusName 优惠券状态名称 26 | */ 27 | CouponStatusEnum(Integer code, String statusName) { 28 | this.code = code; 29 | this.statusName = statusName != null ? statusName : ""; 30 | } 31 | 32 | /** 33 | * 获取优惠券类型号 34 | * 35 | * @return Integer 36 | */ 37 | public Integer getCode() { 38 | return code; 39 | } 40 | 41 | /** 42 | * 获取优惠券类型名称 43 | * 44 | * @return String 45 | */ 46 | public String getStatusName() { 47 | return statusName; 48 | } 49 | 50 | /** 51 | * 根据Code获取枚举对象 52 | * @param code 53 | * @return 54 | */ 55 | public static CouponStatusEnum getValueByCode(Integer code){ 56 | for(CouponStatusEnum couponStatusEnum : CouponStatusEnum.values()){ 57 | if(couponStatusEnum.getCode().equals(code)){ 58 | return couponStatusEnum; 59 | } 60 | } 61 | 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/CouponSummaryDetailBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.sql.Date; 8 | import java.sql.Timestamp; 9 | 10 | /** 11 | * Created by gupei on 2018/12/06. 12 | * 用户优惠券详情对象 13 | */ 14 | @Data 15 | public class CouponSummaryDetailBo implements Serializable { 16 | 17 | /** 18 | * 领券ID 19 | */ 20 | private Long receiveId; 21 | 22 | /** 23 | * 用户ID 24 | */ 25 | private String userID; 26 | 27 | /** 28 | * 用户编号 29 | */ 30 | private String userCode; 31 | 32 | /** 33 | * 优惠券ID 34 | */ 35 | private Long couponID; 36 | 37 | /** 38 | * 活动Id 39 | */ 40 | private Long activityID; 41 | 42 | /** 43 | * 未使用数量 44 | */ 45 | private Long remainQuantity; 46 | 47 | /** 48 | * 生效日期 49 | */ 50 | private Date startDate; 51 | 52 | /** 53 | * 截止日期 54 | */ 55 | private Date endDate; 56 | 57 | /** 58 | * 领取场景描述 59 | */ 60 | private String remark; 61 | 62 | /** 63 | * 领取时间 64 | */ 65 | private Timestamp createAt; 66 | 67 | /** 68 | * 优惠券编码 69 | */ 70 | private String couponNo; 71 | 72 | /** 73 | * 券额 74 | */ 75 | private BigDecimal couponAmount; 76 | 77 | /** 78 | * 优惠券二维码地址 79 | */ 80 | private String qrCodeUrl; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/AvailableCouponDetailsBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.sql.Date; 8 | 9 | /** 10 | * 待使用优惠券明细信息类 11 | * Created by alexlu on 2018/11/13. 12 | */ 13 | @Data 14 | public class AvailableCouponDetailsBo implements Serializable { 15 | /** 16 | * 消费优惠券(模板)记录ID 17 | */ 18 | private Long couponId; 19 | 20 | /** 21 | * 优惠券领劵主记录ID 22 | */ 23 | private Long couponReceiveId; 24 | 25 | /** 26 | * 优惠券领劵剩余数量 27 | */ 28 | private Long couponReceiveRemainQuantity; 29 | 30 | /** 31 | * 优惠券领劵记录状态(0-已领取未使用,1-已使用,2-使用中,3-已过期) 32 | */ 33 | private Integer couponReceiveStatus; 34 | 35 | /** 36 | * 消费优惠券领劵明细记录ID 37 | */ 38 | private Long couponReceiveDetailId; 39 | 40 | /** 41 | * 优惠券领劵明细记录状态(0-已领取未使用,1-已使用,2-使用中,3-已过期) 42 | */ 43 | private Integer couponReceiveDetailStatus; 44 | 45 | /** 46 | * 优惠券编码,发券时按规则生成 47 | */ 48 | private Long couponNo; 49 | 50 | /** 51 | * 券额(积分数,金额,折扣率等) 52 | */ 53 | private BigDecimal couponAmount; 54 | 55 | /** 56 | * 优惠券二维码地址URL 57 | */ 58 | private String couponQrCodeUrl; 59 | 60 | /** 61 | * 权重值,数值小表示优先 62 | */ 63 | private Integer couponWeight; 64 | 65 | /** 66 | * 优惠券使用截至日期 67 | */ 68 | private Date couponEndDate; 69 | } 70 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/entity/CouponSummary.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableField; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import lombok.Data; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * Created by gupei on 2018/09/20. 11 | * 我的优惠券实体对象 12 | */ 13 | @TableName("t_coupon_summary") 14 | @Data 15 | public class CouponSummary extends BaseEntity { 16 | 17 | /** 18 | * 用户买家ID 19 | */ 20 | @TableField("user_id") 21 | private String userId; 22 | 23 | /** 24 | * 用户买家编号 25 | */ 26 | @TableField("user_code") 27 | private String userCode; 28 | 29 | /** 30 | * 优惠券编号ID 31 | */ 32 | @TableField("coupon_id") 33 | private Long couponId; 34 | 35 | /** 36 | * 券额,金额,折扣率 37 | */ 38 | @TableField("coupon_amount") 39 | private BigDecimal couponAmount; 40 | 41 | /** 42 | * 历史领取总数 43 | */ 44 | @TableField("received_quantity") 45 | private Long receivedQuantity; 46 | 47 | /** 48 | * 历史使用总数 49 | */ 50 | @TableField("consumed_quantity") 51 | private Long consumedQuantity; 52 | 53 | /** 54 | * 历史回馈扣减/优惠总金额 55 | */ 56 | @TableField("reward_amount") 57 | private BigDecimal rewardAmount; 58 | 59 | /** 60 | * 可用优惠券张数/积分数量 61 | */ 62 | @TableField("coupon_quantity") 63 | private Long couponQuantity; 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/project/marketing/repository/CouponWithdrawRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.repository; 2 | 3 | import lk.project.marketing.init.MarketingServiceApplication; 4 | import org.junit.FixMethodOrder; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.MethodSorters; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import javax.annotation.Resource; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest(classes = MarketingServiceApplication.class) 17 | @FixMethodOrder( MethodSorters.NAME_ASCENDING) 18 | public class CouponWithdrawRepositoryTest { 19 | private final static Logger log = LoggerFactory.getLogger(CouponWithdrawRepositoryTest.class); 20 | 21 | @Resource 22 | CouponWithdrawRepository couponWithdrawRepository; 23 | 24 | /** 25 | * 用户退款后回滚用户使用的优惠券记录(逻辑删除) 26 | */ 27 | @Test 28 | public void test001WithdrawCouponReceive(){ 29 | couponWithdrawRepository.withdrawCouponReceive(95L,0); 30 | } 31 | 32 | /** 33 | * 用户退款后回滚用户使用的优惠券记录 34 | */ 35 | @Test 36 | public void test002WithdrawCouponReceive(){ 37 | try { 38 | couponWithdrawRepository.withdrawCouponReceive(95L,0,false); 39 | } catch (Exception e) { 40 | log.error("校验回滚优惠券记录失败",e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/common/BaseController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api.common; 2 | 3 | 4 | import lk.project.marketing.client.vo.ResponseVO; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * 父级controller 10 | * Created by alexlu on 2017/1/24. 11 | */ 12 | public class BaseController { 13 | 14 | protected ResponseVO getSuccess(){ 15 | return new ResponseVO(20000,"Succeed!"); 16 | } 17 | 18 | protected ResponseVO getFromData(Object data){ 19 | ResponseVO responseVO = getSuccess(); 20 | responseVO.setData(data); 21 | return responseVO; 22 | } 23 | 24 | protected ResponseVO getFailure(){ 25 | return new ResponseVO(40000,"Failed!"); 26 | } 27 | 28 | protected ResponseVO getFailure(String msg){ 29 | return new ResponseVO(40000,msg); 30 | } 31 | 32 | protected ResponseVO getFailure(Integer errorCode, String msg){ 33 | return new ResponseVO(errorCode, msg); 34 | } 35 | 36 | protected ResponseVO getFailureWithMap(Integer errorCode, Map errMsgMap){ 37 | StringBuilder stb = new StringBuilder(); 38 | for (String errMsg : errMsgMap.values()){ 39 | stb.append(errMsg); 40 | } 41 | return new ResponseVO(errorCode, stb.toString()); 42 | } 43 | 44 | protected ResponseVO getResponse(Object data){ 45 | ResponseVO responseVO = getSuccess(); 46 | responseVO.setData(data); 47 | return responseVO; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/rpc/CouponReceiveInterfaceImpl.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.rpc; 2 | 3 | import lk.project.marketing.base.bo.CouponReceiveReqBo; 4 | import lk.project.marketing.base.bo.MemberBo; 5 | import lk.project.marketing.client.dto.CouponReceiveReqDto; 6 | import lk.project.marketing.client.dto.MemberDto; 7 | import lk.project.marketing.client.rpc.CouponReceiveInterface; 8 | import lk.project.marketing.client.vo.ResponseVO; 9 | import lk.project.marketing.service.rpc.pojo.BaseResponse; 10 | import lk.project.marketing.service.CouponReceiveService; 11 | import org.springframework.beans.BeanUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | 14 | public class CouponReceiveInterfaceImpl extends BaseResponse implements CouponReceiveInterface { 15 | 16 | @Autowired 17 | CouponReceiveService couponReceiveService; 18 | 19 | /** 20 | * 单次领券接口 21 | * @param couponReceiveReqDto 22 | * @param memberDto 23 | * @return 24 | */ 25 | @Override 26 | public ResponseVO produceCoupon(CouponReceiveReqDto couponReceiveReqDto, MemberDto memberDto){ 27 | CouponReceiveReqBo couponReceiveReqBo = new CouponReceiveReqBo(); 28 | MemberBo memberBo = new MemberBo(); 29 | BeanUtils.copyProperties(couponReceiveReqDto,couponReceiveReqBo); 30 | BeanUtils.copyProperties(memberDto,memberBo); 31 | return getFromData(couponReceiveService.produceCoupon(couponReceiveReqBo,memberBo)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponUsageTypeEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 优惠券使用类型枚举 5 | */ 6 | public enum CouponUsageTypeEnum { 7 | ORDER_COUPON(1, "订单使用优惠券"), 8 | ORDER_ITEM_COUPON(2, "订单明细/商品/服务使用优惠券"); 9 | 10 | /** 11 | * 优惠券类型编码 12 | */ 13 | private Integer code; 14 | 15 | /** 16 | * 优惠券类型名称 17 | */ 18 | private String typeName; 19 | 20 | 21 | /** 22 | * 使用优惠券类型号和优惠券类型名称构造枚举 23 | * 24 | * @param code 优惠券类型号 25 | * @param typeName 优惠券类型名称 26 | */ 27 | CouponUsageTypeEnum(Integer code, String typeName) { 28 | this.code = code; 29 | this.typeName = typeName != null ? typeName : ""; 30 | } 31 | 32 | /** 33 | * 获取优惠券使用类型号 34 | * 35 | * @return int 36 | */ 37 | public Integer getCode() { 38 | return code; 39 | } 40 | 41 | /** 42 | * 获取优惠券使用类型名称 43 | * 44 | * @return String 45 | */ 46 | public String getTypeName() { 47 | return typeName; 48 | } 49 | 50 | /** 51 | * 根据Code获取枚举对象 52 | * @param code 53 | * @return 54 | */ 55 | public static CouponUsageTypeEnum getValueByCode(Integer code){ 56 | for(CouponUsageTypeEnum couponUsageTypeEnum : CouponUsageTypeEnum.values()){ 57 | if(couponUsageTypeEnum.getCode().equals(code)){ 58 | return couponUsageTypeEnum; 59 | } 60 | } 61 | 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/PromotionRuleTypeEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 促销规则类型 5 | */ 6 | public enum PromotionRuleTypeEnum { 7 | ISSUE(0, "发放规则"), 8 | USE(1, "使用规则"); 9 | 10 | 11 | /** 12 | * 促销规则类型状态编码 13 | */ 14 | private Integer code; 15 | 16 | /** 17 | * 促销规则类型名称 18 | */ 19 | private String typeName; 20 | 21 | 22 | /** 23 | * 使用促销规则类型状态码和促销规则类型名称构造枚举 24 | * 25 | * @param code 促销规则类型状态编码 26 | * @param typeName 促销规则类型名称 27 | */ 28 | PromotionRuleTypeEnum(Integer code, String typeName) { 29 | this.code = code; 30 | this.typeName = typeName != null ? typeName : ""; 31 | } 32 | 33 | /** 34 | * 获取促销规则类型号 35 | * 36 | * @return Integer 37 | */ 38 | public Integer getCode() { 39 | return code; 40 | } 41 | 42 | /** 43 | * 获取促销规则类型名称 44 | * 45 | * @return String 46 | */ 47 | public String getTypeName() { 48 | return typeName; 49 | } 50 | 51 | /** 52 | * 根据Code获取枚举对象 53 | * @param code 54 | * @return 55 | */ 56 | public static PromotionRuleTypeEnum getValueByCode(Integer code){ 57 | for(PromotionRuleTypeEnum promotionRuleTypeEnum : PromotionRuleTypeEnum.values()){ 58 | if(promotionRuleTypeEnum.getCode().equals(code)){ 59 | return promotionRuleTypeEnum; 60 | } 61 | } 62 | 63 | return null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/common/BaseController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.common; 2 | 3 | 4 | import lk.project.marketing.client.vo.ResponseVO; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * 父级controller 10 | * Created by alexlu on 2017/1/24. 11 | */ 12 | public class BaseController { 13 | 14 | protected ResponseVO getSuccess(){ 15 | return new ResponseVO(20000,"Succeed!"); 16 | } 17 | 18 | protected ResponseVO getFromData(Object data){ 19 | ResponseVO responseVO = getSuccess(); 20 | responseVO.setData(data); 21 | return responseVO; 22 | } 23 | 24 | protected ResponseVO getFailure(){ 25 | return new ResponseVO(40000,"Failed!"); 26 | } 27 | 28 | protected ResponseVO getFailure(String msg){ 29 | return new ResponseVO(40000,msg); 30 | } 31 | 32 | protected ResponseVO getFailure(Integer errorCode, String msg){ 33 | return new ResponseVO(errorCode, msg); 34 | } 35 | 36 | protected ResponseVO getFailureWithMap(Integer errorCode, Map errMsgMap){ 37 | StringBuilder stb = new StringBuilder(); 38 | for (String errMsg : errMsgMap.values()){ 39 | stb.append(errMsg); 40 | } 41 | return new ResponseVO(errorCode, stb.toString()); 42 | } 43 | 44 | protected ResponseVO getResponse(Object data){ 45 | ResponseVO responseVO = getSuccess(); 46 | responseVO.setData(data); 47 | return responseVO; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponTypeEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 优惠券(模板)类型枚举 5 | */ 6 | public enum CouponTypeEnum { 7 | POINTS(0, "积分"), 8 | /** 9 | * 包括现金抵扣和折扣,参考满减规则 10 | */ 11 | DISCOUNT(1, "满减折扣"), 12 | GIFT(2, "赠送赠品"); 13 | 14 | /** 15 | * 优惠券类型编码 16 | */ 17 | private Integer code; 18 | 19 | /** 20 | * 优惠券类型名称 21 | */ 22 | private String typeName; 23 | 24 | 25 | /** 26 | * 使用优惠券类型号和优惠券类型名称构造枚举 27 | * 28 | * @param code 优惠券类型号 29 | * @param typeName 优惠券类型名称 30 | */ 31 | CouponTypeEnum(Integer code, String typeName) { 32 | this.code = code; 33 | this.typeName = typeName != null ? typeName : ""; 34 | } 35 | 36 | /** 37 | * 获取优惠券类型号 38 | * 39 | * @return Integer 40 | */ 41 | public Integer getCode() { 42 | return code; 43 | } 44 | 45 | /** 46 | * 获取优惠券类型名称 47 | * 48 | * @return String 49 | */ 50 | public String getTypeName() { 51 | return typeName; 52 | } 53 | 54 | /** 55 | * 根据Code获取枚举对象 56 | * @param code 57 | * @return 58 | */ 59 | public static CouponTypeEnum getValueByCode(Integer code){ 60 | for(CouponTypeEnum couponTypeEnum : CouponTypeEnum.values()){ 61 | if(couponTypeEnum.getCode().equals(code)){ 62 | return couponTypeEnum; 63 | } 64 | } 65 | 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponAccumulateTypeEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 优惠券使用规则枚举 5 | */ 6 | public enum CouponAccumulateTypeEnum { 7 | 8 | EXCLUSIVE(0, "排他"), 9 | ACCUMULATE(1, "累计"), 10 | PRIORITIZING(2, "择优"); 11 | 12 | /** 13 | * 优惠券使用规则号码 14 | */ 15 | private Integer code; 16 | /** 17 | * 优惠券使用规则名称 18 | */ 19 | private String typeName; 20 | 21 | /** 22 | * 使用优惠券规则编码和名称构造枚举 23 | * 24 | * @param code 优惠券使用规则编码 25 | * @param typeName 优惠券使用规则名称 26 | */ 27 | CouponAccumulateTypeEnum(Integer code, String typeName) { 28 | this.code = code; 29 | this.typeName = typeName != null ? typeName : ""; 30 | } 31 | 32 | /** 33 | * 获取优惠券使用规则号码 34 | * 35 | * @return Integer 36 | */ 37 | public Integer getCode() { 38 | return code; 39 | } 40 | 41 | /** 42 | * 获取优惠券使用规则名称 43 | * 44 | * @return String 45 | */ 46 | public String getTypeName() { 47 | return typeName; 48 | } 49 | 50 | /** 51 | * 根据Code获取枚举对象 52 | * @param code 53 | * @return 54 | */ 55 | public static CouponAccumulateTypeEnum getValueByCode(Integer code){ 56 | for(CouponAccumulateTypeEnum couponAccumulateTypeEnum : CouponAccumulateTypeEnum.values()){ 57 | if(couponAccumulateTypeEnum.getCode().equals(code)){ 58 | return couponAccumulateTypeEnum; 59 | } 60 | } 61 | 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponConsumeStatusEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 优惠券消费状态枚举 5 | */ 6 | public enum CouponConsumeStatusEnum { 7 | USED_WITH_PAYED(0, "已支付使用劵完毕"), 8 | RETURN_BACK(1, "退回优惠券"); 9 | 10 | /** 11 | * 优惠券消费状态编码 12 | */ 13 | private Integer code; 14 | 15 | /** 16 | * 状态名称 17 | */ 18 | private String statusName; 19 | 20 | 21 | /** 22 | * 使用优惠券消费状态码和优惠券消费状态名称构造枚举 23 | * 24 | * @param code 优惠券消费状态编码 25 | * @param statusName 优惠券消费状态名称 26 | */ 27 | CouponConsumeStatusEnum(Integer code, String statusName) { 28 | this.code = code; 29 | this.statusName = statusName != null ? statusName : ""; 30 | } 31 | 32 | /** 33 | * 获取优惠券消费状态号 34 | * 35 | * @return Integer 36 | */ 37 | public Integer getCode() { 38 | return code; 39 | } 40 | 41 | /** 42 | * 获取优惠券消费状态名称 43 | * 44 | * @return String 45 | */ 46 | public String getStatusName() { 47 | return statusName; 48 | } 49 | 50 | /** 51 | * 根据Code获取枚举对象 52 | * @param code 53 | * @return 54 | */ 55 | public static CouponConsumeStatusEnum getValueByCode(Integer code){ 56 | for(CouponConsumeStatusEnum couponConsumeStatusEnum : CouponConsumeStatusEnum.values()){ 57 | if(couponConsumeStatusEnum.getCode().equals(code)){ 58 | return couponConsumeStatusEnum; 59 | } 60 | } 61 | 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/CouponReceiveStatusEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 领取优惠券状态枚举 5 | */ 6 | public enum CouponReceiveStatusEnum { 7 | NOT_USED(0, "未使用"), 8 | USED(1, "已使用"), 9 | PARTIAL_USED(2, "部分使用"), 10 | INVALID(3, "已失效"); 11 | 12 | /** 13 | * 领取优惠券状态编码 14 | */ 15 | private Integer code; 16 | 17 | /** 18 | * 状态名称 19 | */ 20 | private String statusName; 21 | 22 | 23 | /** 24 | * 领取优惠券状态码和优惠券状态名称构造枚举 25 | * 26 | * @param code 优惠券状态编码 27 | * @param statusName 优惠券状态名称 28 | */ 29 | CouponReceiveStatusEnum(Integer code, String statusName) { 30 | this.code = code; 31 | this.statusName = statusName != null ? statusName : ""; 32 | } 33 | 34 | /** 35 | * 获取优惠券类型号 36 | * 37 | * @return Integer 38 | */ 39 | public Integer getCode() { 40 | return code; 41 | } 42 | 43 | /** 44 | * 获取优惠券类型名称 45 | * 46 | * @return String 47 | */ 48 | public String getStatusName() { 49 | return statusName; 50 | } 51 | 52 | /** 53 | * 根据Code获取枚举对象 54 | * @param code 55 | * @return 56 | */ 57 | public static CouponReceiveStatusEnum getValueByCode(Integer code){ 58 | for(CouponReceiveStatusEnum couponReceiveStatusEnum : CouponReceiveStatusEnum.values()){ 59 | if(couponReceiveStatusEnum.getCode().equals(code)){ 60 | return couponReceiveStatusEnum; 61 | } 62 | } 63 | 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/PromotionActivityStatusEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 促销活动状态枚举 5 | */ 6 | public enum PromotionActivityStatusEnum { 7 | NOT_STARTED(0, "未开始"), 8 | STARTING(1, "进行中"), 9 | END(2, "已结束"); 10 | 11 | /** 12 | * 促销活动状态编码 13 | */ 14 | private Integer code; 15 | 16 | /** 17 | * 状态名称 18 | */ 19 | private String statusName; 20 | 21 | 22 | /** 23 | * 使用促销活动状态码和促销活动状态名称构造枚举 24 | * 25 | * @param code 促销活动状态编码 26 | * @param statusName 促销活动状态名称 27 | */ 28 | PromotionActivityStatusEnum(Integer code, String statusName) { 29 | this.code = code; 30 | this.statusName = statusName != null ? statusName : ""; 31 | } 32 | 33 | /** 34 | * 获取促销活动类型号 35 | * 36 | * @return Integer 37 | */ 38 | public Integer getCode() { 39 | return code; 40 | } 41 | 42 | /** 43 | * 获取促销活动类型名称 44 | * 45 | * @return String 46 | */ 47 | public String getStatusName() { 48 | return statusName; 49 | } 50 | 51 | /** 52 | * 根据Code获取枚举对象 53 | * @param code 54 | * @return 55 | */ 56 | public static PromotionActivityStatusEnum getValueByCode(Integer code){ 57 | for(PromotionActivityStatusEnum promotionActivityStatusEnum : PromotionActivityStatusEnum.values()){ 58 | if(promotionActivityStatusEnum.getCode().equals(code)){ 59 | return promotionActivityStatusEnum; 60 | } 61 | } 62 | 63 | return null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /marketing-service/src/test/java/lk/project/marketing/utils/MatrixToImageTest.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.utils; 2 | 3 | import com.google.gson.Gson; 4 | import lk.project.marketing.base.bo.QRCodeBo; 5 | import lk.project.marketing.base.utils.MatrixToImage; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | 10 | public class MatrixToImageTest { 11 | 12 | private QRCodeBo qrCodeBo; 13 | 14 | private String qrCodeText; 15 | 16 | private static final String TEST_QR_FILE = "testQR.jpg"; 17 | 18 | private String fileURL; 19 | 20 | @Before 21 | public void setUp()throws Exception{ 22 | 23 | fileURL = MatrixToImage.class.getResource("").getPath(); 24 | fileURL = fileURL + TEST_QR_FILE; 25 | 26 | qrCodeBo = new QRCodeBo(); 27 | qrCodeBo.setActivityId("1"); 28 | qrCodeBo.setCouponNo("DXVDGEGBWEWRDDE"); 29 | qrCodeBo.setUserId("20116"); 30 | qrCodeBo.setReturnUrl("http://localhost://coupon/consume?activityId=1"); 31 | Gson gson = new Gson(); 32 | qrCodeText = gson.toJson(qrCodeBo); 33 | 34 | } 35 | 36 | @Test 37 | public void writeInfoToJpgFile() throws Exception { 38 | MatrixToImage.writeInfoToJpgFile(qrCodeText, fileURL); 39 | 40 | } 41 | // 42 | // @Test 43 | // public void decodeQR() throws Exception { 44 | // 45 | // File qrCodeFile = new File(fileURL); 46 | // if (qrCodeFile.exists()) { 47 | // String decodeResult = MatrixToImage.decodeQR(fileURL); 48 | // Assert.assertEquals(qrCodeText, decodeResult); 49 | // qrCodeFile.delete(); 50 | // } 51 | // } 52 | 53 | } -------------------------------------------------------------------------------- /marketing-backend-api/src/main/resources/config/dubbo-consumer.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/enums/AccountRuleThresholdTypeEnum.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.enums; 2 | 3 | /** 4 | * 结算规则满减条件类型 5 | */ 6 | public enum AccountRuleThresholdTypeEnum { 7 | UNCONDITIONAL(0, "无条件"), 8 | AMOUNT(1, "满金额"), 9 | QUANTITY(2, "满数量"), 10 | PREFERENTIAL(3, "优惠价"); 11 | 12 | /** 13 | * 满减条件类型状态编码 14 | */ 15 | private Integer code; 16 | 17 | /** 18 | * 满减条件类型名称 19 | */ 20 | private String typeName; 21 | 22 | 23 | /** 24 | * 使用满减条件类型状态码和满减条件类型名称构造枚举 25 | * 26 | * @param code 满减条件类型状态编码 27 | * @param typeName 满减条件类型名称 28 | */ 29 | AccountRuleThresholdTypeEnum(Integer code, String typeName) { 30 | this.code = code; 31 | this.typeName = typeName != null ? typeName : ""; 32 | } 33 | 34 | /** 35 | * 获取满减条件类型号 36 | * 37 | * @return Integer 38 | */ 39 | public Integer getCode() { 40 | return code; 41 | } 42 | 43 | /** 44 | * 获取满减条件类型名称 45 | * 46 | * @return String 47 | */ 48 | public String getTypeName() { 49 | return typeName; 50 | } 51 | 52 | /** 53 | * 根据Code获取枚举对象 54 | * @param code 55 | * @return 56 | */ 57 | public static AccountRuleThresholdTypeEnum getValueByCode(Integer code){ 58 | for(AccountRuleThresholdTypeEnum accountRuleThresholdTypeEnum : AccountRuleThresholdTypeEnum.values()){ 59 | if(accountRuleThresholdTypeEnum.getCode().equals(code)){ 60 | return accountRuleThresholdTypeEnum; 61 | } 62 | } 63 | 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.config; 2 | 3 | import org.springframework.cache.CacheManager; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.redis.cache.DefaultRedisCachePrefix; 7 | import org.springframework.data.redis.cache.RedisCacheManager; 8 | import org.springframework.data.redis.connection.RedisConnectionFactory; 9 | import org.springframework.data.redis.core.RedisTemplate; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Created on 16/7/19. 16 | * 17 | * @author gu pei 18 | */ 19 | @SuppressWarnings("unused") 20 | @Configuration 21 | 22 | public class RedisConfig { 23 | 24 | /** 25 | * 获取缓存管理实例 26 | * 27 | * @return 28 | */ 29 | @Bean 30 | RedisTemplate redisTemplate(RedisConnectionFactory factory) { 31 | RedisTemplate redisTemplate = new RedisTemplate(); 32 | redisTemplate.setConnectionFactory(factory); 33 | return redisTemplate; 34 | } 35 | 36 | 37 | @Bean 38 | public CacheManager cacheManager(RedisTemplate redisTemplate) { 39 | Map expires = new HashMap(); 40 | RedisCacheManager redisCacheManager = new RedisCacheManager(redisTemplate); 41 | redisCacheManager.setDefaultExpiration(1200L); 42 | redisCacheManager.setExpires(expires); 43 | redisCacheManager.setUsePrefix(true); 44 | redisCacheManager.setCachePrefix(new DefaultRedisCachePrefix("_coupon:")); 45 | return redisCacheManager; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/repository/ActivityRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.PromotionActivity; 5 | import lk.project.marketing.mapper.ActivityMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public class ActivityRepository extends ServiceImpl { 13 | 14 | @Autowired 15 | ActivityMapper activityMapper; 16 | 17 | /** 18 | * 根据优惠券ID获取对应的活动列表 19 | * @param couponId 优惠券ID 20 | * @return 21 | */ 22 | public List getActivityListByCouponId(Long couponId) { 23 | return activityMapper.getActivityListByCouponId(couponId); 24 | } 25 | 26 | /** 27 | * 根据促销活动id获得促销活动实体 28 | * @param id 29 | * @return 30 | */ 31 | public PromotionActivity getActivityById(Long id){ 32 | return activityMapper.getActivityById(id); 33 | } 34 | 35 | /** 36 | * 根据优惠券ID集合获取对应的活动ID集合 37 | * @param couponIdList 38 | * @return 39 | */ 40 | public List getActivityIdListByCouponIdList(List couponIdList){ 41 | return activityMapper.getActivityIdListByCouponIdList(couponIdList); 42 | } 43 | 44 | /** 45 | * 更新促销活动记录 46 | * @param promotionActivity 47 | * @return 48 | */ 49 | public Boolean updateActivity(PromotionActivity promotionActivity){ 50 | return activityMapper.updateActivity(promotionActivity); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /marketing-service/src/main/java/lk/project/marketing/service/rpc/pojo/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.service.rpc.pojo; 2 | 3 | 4 | import lk.project.marketing.base.enums.SystemErrorCodeEnum; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * 父级controller 11 | * Created by alexlu on 2017/1/24. 12 | */ 13 | public class BaseResponse { 14 | 15 | protected ResponseVO getSuccess(){ 16 | return new ResponseVO(SystemErrorCodeEnum.SUCCESS.getCode(),"Succeed!"); 17 | } 18 | 19 | protected ResponseVO getFromData(Object data){ 20 | ResponseVO responseVO = getSuccess(); 21 | responseVO.setData(data); 22 | return responseVO; 23 | } 24 | 25 | protected ResponseVO getFailure(){ 26 | return new ResponseVO(SystemErrorCodeEnum.SYSTEM_ERROR.getCode(),"Failed!"); 27 | } 28 | 29 | protected ResponseVO getFailure(String msg){ 30 | return new ResponseVO(SystemErrorCodeEnum.SYSTEM_ERROR.getCode(),msg); 31 | } 32 | 33 | protected ResponseVO getFailure(Integer errorCode, String msg){ 34 | return new ResponseVO(errorCode, msg); 35 | } 36 | 37 | protected ResponseVO getFailureWithMap(Integer errorCode, Map errMsgMap){ 38 | StringBuilder stb = new StringBuilder(); 39 | for (String errMsg : errMsgMap.values()){ 40 | stb.append(errMsg); 41 | } 42 | return new ResponseVO(errorCode, stb.toString()); 43 | } 44 | 45 | protected ResponseVO getResponse(Object data){ 46 | ResponseVO responseVO = getSuccess(); 47 | responseVO.setData(data); 48 | return responseVO; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.config; 2 | 3 | import org.springframework.cache.CacheManager; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.redis.cache.DefaultRedisCachePrefix; 7 | import org.springframework.data.redis.cache.RedisCacheManager; 8 | import org.springframework.data.redis.connection.RedisConnectionFactory; 9 | import org.springframework.data.redis.core.RedisTemplate; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Created on 16/7/19. 16 | * 17 | * @author gu pei 18 | */ 19 | @SuppressWarnings("unused") 20 | @Configuration 21 | 22 | public class RedisConfig { 23 | 24 | /** 25 | * 获取缓存管理实例 26 | * 27 | * @return 28 | */ 29 | @Bean 30 | RedisTemplate redisTemplate(RedisConnectionFactory factory) { 31 | RedisTemplate redisTemplate = new RedisTemplate(); 32 | redisTemplate.setConnectionFactory(factory); 33 | return redisTemplate; 34 | } 35 | 36 | 37 | @Bean 38 | public CacheManager cacheManager(RedisTemplate redisTemplate) { 39 | Map expires = new HashMap(); 40 | RedisCacheManager redisCacheManager = new RedisCacheManager(redisTemplate); 41 | redisCacheManager.setDefaultExpiration(1200L); 42 | redisCacheManager.setExpires(expires); 43 | redisCacheManager.setUsePrefix(true); 44 | redisCacheManager.setCachePrefix(new DefaultRedisCachePrefix("_coupon:")); 45 | return redisCacheManager; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/CouponManagementController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import lk.project.marketing.client.dto.CouponReqDto; 5 | import lk.project.marketing.client.dto.QueryCouponReqDto; 6 | import lk.project.marketing.client.rpc.CouponManagementInterface; 7 | import lk.project.marketing.client.vo.ResponseVO; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("/backend/couponManagement") 13 | public class CouponManagementController extends BaseController { 14 | 15 | @Autowired 16 | CouponManagementInterface couponManagementInterface; 17 | 18 | /** 19 | * 新增优惠券模板 20 | * @param couponReqDto 21 | * @return 22 | */ 23 | @PostMapping("/saveCoupon") 24 | public ResponseVO saveCoupon(@RequestBody CouponReqDto couponReqDto){ 25 | return couponManagementInterface.saveCoupon(couponReqDto); 26 | } 27 | 28 | /** 29 | * 删除优惠券模板 30 | * @param couponId 31 | * @return 32 | */ 33 | @GetMapping("/deleteCoupon") 34 | public ResponseVO deleteCoupon(@RequestParam Long couponId){ 35 | return couponManagementInterface.deleteCoupon(couponId); 36 | } 37 | 38 | /** 39 | * 查询满足条件的优惠券模板 40 | * @param queryCouponReqDto 41 | * @return 42 | */ 43 | @PostMapping("/queryCoupon") 44 | public ResponseVO queryCoupon(@RequestBody QueryCouponReqDto queryCouponReqDto){ 45 | return couponManagementInterface.queryCoupon(queryCouponReqDto); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/service/rpc/pojo/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.service.rpc.pojo; 2 | 3 | 4 | import lk.project.marketing.base.enums.SystemErrorCodeEnum; 5 | import lk.project.marketing.client.vo.ResponseVO; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * 父级controller 11 | * Created by alexlu on 2017/1/24. 12 | */ 13 | public class BaseResponse { 14 | 15 | protected ResponseVO getSuccess(){ 16 | return new ResponseVO(SystemErrorCodeEnum.SUCCESS.getCode(),"Succeed!"); 17 | } 18 | 19 | protected ResponseVO getFromData(Object data){ 20 | ResponseVO responseVO = getSuccess(); 21 | responseVO.setData(data); 22 | return responseVO; 23 | } 24 | 25 | protected ResponseVO getFailure(){ 26 | return new ResponseVO(SystemErrorCodeEnum.SYSTEM_ERROR.getCode(),"Failed!"); 27 | } 28 | 29 | protected ResponseVO getFailure(String msg){ 30 | return new ResponseVO(SystemErrorCodeEnum.SYSTEM_ERROR.getCode(),msg); 31 | } 32 | 33 | protected ResponseVO getFailure(Integer errorCode, String msg){ 34 | return new ResponseVO(errorCode, msg); 35 | } 36 | 37 | protected ResponseVO getFailureWithMap(Integer errorCode, Map errMsgMap){ 38 | StringBuilder stb = new StringBuilder(); 39 | for (String errMsg : errMsgMap.values()){ 40 | stb.append(errMsg); 41 | } 42 | return new ResponseVO(errorCode, stb.toString()); 43 | } 44 | 45 | protected ResponseVO getResponse(Object data){ 46 | ResponseVO responseVO = getSuccess(); 47 | responseVO.setData(data); 48 | return responseVO; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /marketing-service/src/main/resources/application-com.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: ${MYSQL_DB_URL} 4 | username: ${MYSQL_DB_USER} 5 | password: ${MYSQL_DB_PW} 6 | driver-class-name: com.mysql.jdbc.Driver 7 | redis: 8 | database: 2 # Database index used by the connection factory. 9 | cluster: 10 | nodes: 11 | ${REDIS_CLUST_HOST} 12 | password: 13 | pool: 14 | use: true 15 | max-active: 20 16 | max-idle: 10 17 | dubbo: 18 | application: 19 | name: ${DUBBO_APPLICATION_NAME} 20 | owner: bill 21 | logger: slf4j 22 | registry: 23 | address: ${DUBBO_REGISTRY_ADDRESS} 24 | protocol: zookeeper 25 | check: false 26 | subscribe: true 27 | timeout: 10000 28 | group: dubbo 29 | monitor: 30 | protocol: registry 31 | protocol: 32 | name: dubbo 33 | port: 20880 34 | threadpool: fixed 35 | threads: 100 36 | accepts: 1000 37 | charset: UTF-8 38 | dispatcher: all 39 | payload: 104857600 40 | timeout: 10000 41 | check: false 42 | token: false 43 | provider: 44 | timeout: 10000 45 | check: false 46 | token: false 47 | consumer: 48 | timeout: 10000 49 | check: false 50 | service: 51 | retries: 2 52 | timeout: 10000 53 | loadbalance: consistenthash 54 | admin: 55 | username: root 56 | password: root 57 | lk: 58 | # redis: 59 | # clusterHost: ${REDIS_CLUST_HOST} 60 | # clusterPort: ${REDIS_CLUST_PORT} 61 | # redisPassword: 62 | # expireTime: 3600 63 | storage: 64 | accessKey: ${CEPH_ACCESS_KEY} 65 | secretKey: ${CEPH_SECRET_KEY} 66 | endpointAddr: ${CEPH_ENDPOINT_ADDRESS} 67 | baseUrl: ${CEPH_BASE_URL} 68 | bucketNamePrefix: ${CEPH_BUCKET_NAME_PREFIX} -------------------------------------------------------------------------------- /marketing-backend-service/src/main/resources/application-com.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: ${MYSQL_DB_URL} 4 | username: ${MYSQL_DB_USER} 5 | password: ${MYSQL_DB_PW} 6 | driver-class-name: com.mysql.jdbc.Driver 7 | redis: 8 | database: 2 # Database index used by the connection factory. 9 | cluster: 10 | nodes: 11 | ${REDIS_CLUST_HOST} 12 | password: 13 | pool: 14 | use: true 15 | max-active: 20 16 | max-idle: 10 17 | dubbo: 18 | application: 19 | name: ${DUBBO_APPLICATION_NAME} 20 | owner: bill 21 | logger: slf4j 22 | registry: 23 | address: ${DUBBO_REGISTRY_ADDRESS} 24 | protocol: zookeeper 25 | check: false 26 | subscribe: true 27 | timeout: 10000 28 | group: dubbo 29 | monitor: 30 | protocol: registry 31 | protocol: 32 | name: dubbo 33 | port: 20881 34 | threadpool: fixed 35 | threads: 100 36 | accepts: 1000 37 | charset: UTF-8 38 | dispatcher: all 39 | payload: 104857600 40 | timeout: 10000 41 | check: false 42 | token: false 43 | provider: 44 | timeout: 10000 45 | check: false 46 | token: false 47 | consumer: 48 | timeout: 10000 49 | check: false 50 | service: 51 | retries: 2 52 | timeout: 10000 53 | loadbalance: consistenthash 54 | admin: 55 | username: root 56 | password: root 57 | lk: 58 | # redis: 59 | # clusterHost: ${REDIS_CLUST_HOST} 60 | # clusterPort: ${REDIS_CLUST_PORT} 61 | # redisPassword: 62 | # expireTime: 3600 63 | storage: 64 | accessKey: ${CEPH_ACCESS_KEY} 65 | secretKey: ${CEPH_SECRET_KEY} 66 | endpointAddr: ${CEPH_ENDPOINT_ADDRESS} 67 | baseUrl: ${CEPH_BASE_URL} 68 | bucketNamePrefix: ${CEPH_BUCKET_NAME_PREFIX} -------------------------------------------------------------------------------- /marketing-api/src/main/java/lk/project/marketing/api/controller/SettleAccountController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.api.controller; 2 | 3 | import lk.project.marketing.api.common.BaseController; 4 | import lk.project.marketing.client.dto.DynamicSelectCouponReqDto; 5 | import lk.project.marketing.client.dto.OrderSettlementReqDto; 6 | import lk.project.marketing.client.rpc.SettleAccountInterface; 7 | import lk.project.marketing.client.vo.ResponseVO; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | /** 15 | * Created by alexlu on 2018/11/23. 16 | */ 17 | 18 | @RestController 19 | @RequestMapping("/couponSettle") 20 | public class SettleAccountController extends BaseController{ 21 | @Autowired 22 | SettleAccountInterface settleAccountInterface; 23 | 24 | /** 25 | * 订单结算 26 | * @param orderSettlementReqDto 27 | * @return 订单结算结果对象 28 | */ 29 | @PostMapping("/order/settlement") 30 | public ResponseVO orderSettlement(@RequestBody OrderSettlementReqDto orderSettlementReqDto) throws Exception{ 31 | return settleAccountInterface.orderSettlement(orderSettlementReqDto); 32 | } 33 | 34 | /** 35 | * 动态返回用户选中的优惠券数据及其金额 36 | * @param dynamicSelectCouponReqDto 37 | * @return 38 | */ 39 | @PostMapping("/dynamicSelect") 40 | public ResponseVO selectCoupon(@RequestBody DynamicSelectCouponReqDto dynamicSelectCouponReqDto) throws Exception{ 41 | return settleAccountInterface.selectCoupon(dynamicSelectCouponReqDto); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /marketing-rds/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coupon 7 | coupon-marketing 8 | 1.0-SNAPSHOT 9 | 10 | 11 | 4.0.0 12 | coupon-marketing-rds 13 | coupon-marketing-rds 14 | 0.0.1-SNAPSHOT 15 | jar 16 | 17 | coupon-marketing-rds 18 | Marketing DB migration 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter 24 | 25 | 26 | mysql 27 | mysql-connector-java 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.flywaydb 35 | flyway-core 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-archetype-plugin 48 | 2.2 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/java/lk/project/marketing/backend/repository/ActivityManagementRepository.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.repository; 2 | 3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 4 | import lk.project.marketing.base.entity.PromotionActivity; 5 | import lk.project.marketing.backend.mapper.ActivityManagementMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public class ActivityManagementRepository extends ServiceImpl { 13 | 14 | @Autowired 15 | ActivityManagementMapper activityManagementMapper; 16 | 17 | /** 18 | * 根据优惠券ID获取对应的活动列表 19 | * @param couponId 优惠券ID 20 | * @return 21 | */ 22 | public List getActivityListByCouponId(Long couponId) { 23 | return activityManagementMapper.getActivityListByCouponId(couponId); 24 | } 25 | 26 | /** 27 | * 根据促销活动id获得促销活动实体 28 | * @param id 29 | * @return 30 | */ 31 | public PromotionActivity getActivityById(Long id){ 32 | return activityManagementMapper.getActivityById(id); 33 | } 34 | 35 | /** 36 | * 根据优惠券ID集合获取对应的活动ID集合 37 | * @param couponIdList 38 | * @return 39 | */ 40 | public List getActivityIdListByCouponIdList(List couponIdList){ 41 | return activityManagementMapper.getActivityIdListByCouponIdList(couponIdList); 42 | } 43 | 44 | /** 45 | * 更新促销活动记录 46 | * @param promotionActivity 47 | * @return 48 | */ 49 | public Boolean updateActivity(PromotionActivity promotionActivity){ 50 | return activityManagementMapper.updateActivity(promotionActivity); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /marketing-base/src/main/java/lk/project/marketing/base/bo/ActivityReqBo.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.base.bo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.sql.Date; 7 | import java.sql.Time; 8 | import java.sql.Timestamp; 9 | 10 | @Data 11 | public class ActivityReqBo implements Serializable { 12 | 13 | /** 14 | * 促销活动ID 15 | */ 16 | private Long id; 17 | 18 | /** 19 | * 基础优惠券id 20 | */ 21 | private Long couponId; 22 | 23 | /** 24 | * 促销活动名称 25 | */ 26 | private String activityName; 27 | 28 | /** 29 | * 促销活动描述 30 | */ 31 | private String activityDesc; 32 | 33 | /** 34 | * 优惠券活动开始日期 35 | */ 36 | private Date activityStart; 37 | 38 | /** 39 | * 优惠券活动结束日期 40 | */ 41 | private Date activityEnd; 42 | 43 | /** 44 | * 优惠券生效日期 45 | */ 46 | private Date effectDate; 47 | 48 | /** 49 | * 优惠券有效天数,用于发券开始计算有效截至期 50 | */ 51 | private Integer effectDays; 52 | 53 | /** 54 | * 优惠券使用开始时间 55 | */ 56 | private Time startTime; 57 | 58 | /** 59 | * 优惠券使用结束时间 60 | */ 61 | private Time endTime; 62 | 63 | /** 64 | * 数量限制,无限制则不需要发券,自动用券 65 | */ 66 | private Boolean quantityLimit; 67 | 68 | /** 69 | * 总发放数量 70 | */ 71 | private Long issueQuantity; 72 | 73 | /** 74 | * 已发放数量 75 | */ 76 | private Long receivedQuantity; 77 | 78 | /** 79 | * 每人最多领取数量 80 | */ 81 | private Long limitQuantity; 82 | 83 | /** 84 | * 自动发放数量 85 | */ 86 | private Integer autoIssueQuantity; 87 | 88 | /** 89 | * 自动发放时间 90 | */ 91 | private Timestamp autoIssueTime; 92 | 93 | /** 94 | * 状态,0表示未开始,1表示进行中,2表示结束 95 | */ 96 | private Integer status; 97 | } 98 | -------------------------------------------------------------------------------- /marketing-client/src/main/java/lk/project/marketing/client/dto/ActivityReqDto.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.client.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.sql.Date; 7 | import java.sql.Time; 8 | import java.sql.Timestamp; 9 | 10 | @Data 11 | public class ActivityReqDto implements Serializable { 12 | 13 | /** 14 | * 促销活动ID 15 | */ 16 | private Long id; 17 | 18 | /** 19 | * 基础优惠券id 20 | */ 21 | private Long couponId; 22 | 23 | /** 24 | * 促销活动名称 25 | */ 26 | private String activityName; 27 | 28 | /** 29 | * 促销活动描述 30 | */ 31 | private String activityDesc; 32 | 33 | /** 34 | * 优惠券活动开始日期 35 | */ 36 | private Date activityStart; 37 | 38 | /** 39 | * 优惠券活动结束日期 40 | */ 41 | private Date activityEnd; 42 | 43 | /** 44 | * 优惠券生效日期 45 | */ 46 | private Date effectDate; 47 | 48 | /** 49 | * 优惠券有效天数,用于发券开始计算有效截至期 50 | */ 51 | private Integer effectDays; 52 | 53 | /** 54 | * 优惠券使用开始时间 55 | */ 56 | private Time startTime; 57 | 58 | /** 59 | * 优惠券使用结束时间 60 | */ 61 | private Time endTime; 62 | 63 | /** 64 | * 数量限制,无限制则不需要发券,自动用券 65 | */ 66 | private Boolean quantityLimit; 67 | 68 | /** 69 | * 总发放数量 70 | */ 71 | private Long issueQuantity; 72 | 73 | /** 74 | * 已发放数量 75 | */ 76 | private Long receivedQuantity; 77 | 78 | /** 79 | * 每人最多领取数量 80 | */ 81 | private Long limitQuantity; 82 | 83 | /** 84 | * 自动发放数量 85 | */ 86 | private Integer autoIssueQuantity; 87 | 88 | /** 89 | * 自动发放时间 90 | */ 91 | private Timestamp autoIssueTime; 92 | 93 | /** 94 | * 状态,0表示未开始,1表示进行中,2表示结束 95 | */ 96 | private Integer status; 97 | } 98 | -------------------------------------------------------------------------------- /marketing-service/src/main/resources/mapper/PromotionRule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | id, activity_id, rule_name, rule_type, user_condition, sku_condition, order_condition, time_condition, 25 | extras_condition, is_delete, creator_id, created_at, modifier_id, modified_at 26 | 27 | 28 | 33 | -------------------------------------------------------------------------------- /marketing-backend-api/src/main/java/lk/project/marketing/backend/api/controller/AccountRuleManagementController.java: -------------------------------------------------------------------------------- 1 | package lk.project.marketing.backend.api.controller; 2 | 3 | import lk.project.marketing.backend.api.common.BaseController; 4 | import lk.project.marketing.client.dto.AccountRuleReqDto; 5 | import lk.project.marketing.client.dto.QueryAccountRuleReqDto; 6 | import lk.project.marketing.client.rpc.AccountRuleManagementInterface; 7 | import lk.project.marketing.client.vo.ResponseVO; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("/backend/accountRule") 13 | public class AccountRuleManagementController extends BaseController { 14 | 15 | @Autowired 16 | AccountRuleManagementInterface accountRuleManagementInterface; 17 | 18 | /** 19 | * 新增或修改优惠券结算规则 20 | * @param accountRuleReqDto 21 | * @return 22 | */ 23 | @PostMapping("/saveAccountRule") 24 | public ResponseVO saveAccountRule(@RequestBody AccountRuleReqDto accountRuleReqDto){ 25 | return accountRuleManagementInterface.saveAccountRule(accountRuleReqDto); 26 | } 27 | 28 | /** 29 | * 逻辑删除优惠券结算规则 30 | * @param accountRuleId 31 | * @return 32 | */ 33 | @GetMapping("/deleteAccountRule") 34 | public ResponseVO deleteAccountRule(@RequestParam Long accountRuleId){ 35 | return accountRuleManagementInterface.deleteAccountRule(accountRuleId); 36 | } 37 | 38 | /** 39 | * 根据条件分页查询优惠券结算规则 40 | * @param queryAccountRuleReqDto 41 | * @return 42 | */ 43 | @PostMapping("/queryAccountRule") 44 | public ResponseVO queryAccountRule(@RequestBody QueryAccountRuleReqDto queryAccountRuleReqDto){ 45 | return accountRuleManagementInterface.queryAccountRule(queryAccountRuleReqDto); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /marketing-service/src/main/resources/mapper/CouponConsume.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /marketing-service/src/main/resources/mapper/CouponConsumeDetail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | id, coupon_consume_id, coupon_receive_id, coupon_receive_detail_ids, activity_id, 23 | consume_quantity, is_delete, creator_id, created_at, modifier_id, modified_at 24 | 25 | 30 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/resources/mapper/PromotionRuleManagement.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | id, activity_id, rule_name, rule_type, user_condition, sku_condition, order_condition, time_condition, 25 | extras_condition, is_delete, creator_id, created_at, modifier_id, modified_at 26 | 27 | 28 | 33 | -------------------------------------------------------------------------------- /marketing-backend-service/src/main/resources/mapper/CouponConsumeManagement.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | --------------------------------------------------------------------------------