| | |
| | | @Autowired |
| | | private IntegralService integralService; |
| | | |
| | | @Autowired |
| | | private MemberCouponService memberCouponService; |
| | | |
| | | /** |
| | | * 是否开发者 |
| | | */ |
| | |
| | | /** |
| | | * 定时取消 未支付订单信息 |
| | | */ |
| | | // @Scheduled(fixedDelay = 1000L * 10L ) |
| | | @Scheduled(fixedDelay = 1000L * 10L ) |
| | | public void cancelGoodsOrder(){ |
| | | goodsorderService.autoCancel(); |
| | | goodsorderService.autoCancelOrder(); |
| | | } |
| | | |
| | | /** |
| | |
| | | activitySignService.autoCancelSign(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 定时通知用户优惠券即将过期 |
| | | * 每天早上 9 点执行,通知 7 天内即将过期的优惠券 |
| | | */ |
| | | @Scheduled(cron = "0 0 9 * * ?") |
| | | public void notifyCouponExpired() { |
| | | if (timing) { |
| | | System.out.println("开始执行优惠券过期通知任务--------Begin------"); |
| | | try { |
| | | // 提前 3 天通知 |
| | | memberCouponService.notifyExpiredCoupon(7); |
| | | System.out.println("优惠券过期通知任务执行成功--------End------"); |
| | | } catch (Exception e) { |
| | | System.out.println("优惠券过期通知任务执行失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发送get请求 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时处理积分过期 |
| | | * 每天凌晨 2 点执行 |
| | | */ |
| | | @Scheduled(cron = "0 0 2 1 * ?") |
| | | public void autoExpiredIntegral() { |
| | | if (timing) { |
| | | System.out.println("开始执行积分过期处理任务--------Begin------"); |
| | | try { |
| | | integralService.expiredIntegral(); |
| | | System.out.println("积分过期处理任务执行成功--------End------"); |
| | | } catch (Exception e) { |
| | | System.out.println("积分过期处理任务执行失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时发送积分即将过期通知 |
| | | * 每天凌晨 2 点执行 |
| | | */ |
| | | @Scheduled(cron = "0 0 2 25 * ?") |
| | | public void autoExpiredIntegralNotice() { |
| | | if (timing) { |
| | | System.out.println("开始执行积分即将过期通知处理任务--------Begin------"); |
| | | try { |
| | | integralService.expiredIntegralNotice(); |
| | | System.out.println("积分即将过期通知处理任务执行成功--------End------"); |
| | | } catch (Exception e) { |
| | | System.out.println("积分即将过期通知处理任务执行失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.MemberCoupon; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | |
| | | |
| | | |
| | | EXPIRE_INTEGRAL(40,"积分过期提醒",3,0,"积分即将过期","您有{param}积分即将过期"), |
| | | EXPIRE_COUPON(41,"优惠券发放",3,0,"优惠券发放","您有{param}张优惠券将在{param2}过期"), |
| | | EXPIRE_COUPON(41,"优惠券过期提醒",3,0,"优惠券过期提醒","您有{param}张优惠券将在{param1}过期"), |
| | | |
| | | COMMENT(50,"社区消息",4,1,"收到评论","{param}回复了您的评论"), |
| | | |
| | | ; |
| | | |
| | | private Integer key; |
| | |
| | | MEMBER_ORDER_REFUND(28,"订单退款","订单退款,返还订单消耗${param}积分",0,0), |
| | | MEMBER_ORDER(9,"下单抵扣","消费抵扣,消耗${param}积分",1,0), |
| | | ORDER_DONATE(15,"消费返积分","购物成功,获得${param}积分",0,0), |
| | | SHOP_YEAR_SETTLEMENT(18,"积分过期","积分过期,消耗${param}积分",0,0), |
| | | MEMBER_YEAR_SETTLEMENT(18,"积分过期","积分过期,消耗${param}积分",0,0), |
| | | MEMBER_ORDER_REFUND_RETURN(27,"订单退款","订单退款,扣除订单返还${param}积分",0,0), |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public static String getCouponInfo(MemberCoupon mc, Integer num){ |
| | | String info = Constants.equalsInteger(mc.getCouponType(),Constants.ZERO)? |
| | | "满"+mc.getLimitPrice()+"元减"+mc.getPrice()+"元抵扣券*"+num: |
| | | "满"+mc.getLimitPrice()+"元享"+mc.getPrice()+"折券*"+num; |
| | | return info; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | Date date = new Date(); |
| | | Long l = date.getTime()+1000*60*60*24*days; |
| | | date.setTime(l); |
| | | return DateToStr(date, "yyyyMMdd"); |
| | | return DateToStr(date, "yyyy-MM-dd"); |
| | | } |
| | | |
| | | public static String beforeDateToStr(Integer days){ |
| | |
| | | |
| | | |
| | | |
| | | @Select(" select g.* , " + |
| | | /*@Select(" select g.* , " + |
| | | "(( select count(1) from goodsorder_detail gd inner join goods_sku gs on gd.GOODS_SKU_ID = gs.id where gs.GOODS_ID = g.`id` )+ g.SALENUM) as realSaleNum ," + |
| | | //"( select gs.id from goods_sku gs where gs.GOODS_ID = g.id limit 1 ) as realSaleNum ," + |
| | | " ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = g.id ),0) as minPrice " + |
| | |
| | | " ifnull(( select sum(gd.NAME) from goodsorder_detail gd inner join goodsorder go on gd.ORDER_ID = go.id where gd.GOODS_SKU_ID = gs.`id` and go.DISTRIBUTION_SHOP_ID = #{shopId} ),0) as realSaleNum " + |
| | | " from goods g left join goods_sku gs on g.id = gs.GOODS_ID " + |
| | | " ${ew.customSqlSegment} ") |
| | | IPage<GoodsInfoResponse> goodsPageForShop(IPage<GoodsRequest> page, @Param(Constants.WRAPPER) Wrapper wrapper,@Param("shopId") Integer shopId); |
| | | IPage<GoodsInfoResponse> goodsPageForShop(IPage<GoodsRequest> page, @Param(Constants.WRAPPER) Wrapper wrapper,@Param("shopId") Integer shopId);*/ |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @Select(" select g.CODE AS code , g.id as orderId , g.CREATE_DATE as createDate , g.TYPE as orderType , g.STATUS as orderStatus , g.IS_COMMENT as isComment , g.PAY_STATUS as payStatus ," + |
| | | " g.COUPON_PRICE as couponPrice , g.price , g.LINKNAME as linkName , g.LINKPHONE as linkPhone , g.LINKADDR as linkAddress , " + |
| | | "g.KD_DATE as kdDate , g.KD_NAME as kdName , g.KD_CODE as kdCode , g.INTEGRAL as integral , SUBDATE(g.CREATE_DATE,interval - 15 minute) as cancelDate , g.PAY_DATE AS payDate , g.DONE_DATE as doneDate " + |
| | | "g.KD_DATE as kdDate , g.KD_NAME as kdName , g.KD_CODE as kdCode , g.INTEGRAL as integral , g.CANCEL_DATE AS cancelDate ,SUBDATE(g.CREATE_DATE,interval - 15 minute) as cancelOptDate , g.PAY_DATE AS payDate , g.DONE_DATE as doneDate " + |
| | | " , g.MEMBER_INFO , g.RECEIVE_TYPE as receiveType, s.name as shopName,s.phone as shopPhone ,s.id as shopId ,g.exchange_code as exchangeCode " + |
| | | " from goodsorder g left join shop s on g.PICK_UP_SHOP_ID = s.id " + |
| | | " ${ew.customSqlSegment} ") |
| | |
| | | |
| | | @Select(" select g.CODE AS code , g.pay_Method , g.MEMBER_INFO as memberInfo , g.PAY_ORDER_ID as payOrderId , g.REFUND_MONEY refundMoney , g.REFUND_TIME as refundTime, g.REFUND_INFO as refundInfo, g.id as orderId , g.MEMBER_ID as memberId , g.CREATE_DATE as createDate , g.TYPE as orderType , g.STATUS as orderStatus , g.IS_COMMENT as isComment , g.PAY_STATUS as payStatus ," + |
| | | " g.COUPON_PRICE as couponPrice , g.price , g.LINKNAME as linkName , g.LINKPHONE as linkPhone , g.LINKADDR as linkAddress , " + |
| | | "g.KD_DATE as kdDate , g.KD_NAME as kdName , g.KD_CODE as kdCode , g.INTEGRAL as integral , SUBDATE(g.CREATE_DATE,interval - 15 minute) as cancelDate , g.PAY_DATE AS payDate , g.DONE_DATE as doneDate " + |
| | | "g.KD_DATE as kdDate , g.KD_NAME as kdName , g.KD_CODE as kdCode , g.INTEGRAL as integral , g.CANCEL_DATE AS cancelDate ,SUBDATE(g.CREATE_DATE,interval - 15 minute) as cancelOptDate , g.PAY_DATE AS payDate , g.DONE_DATE as doneDate " + |
| | | " , g.MEMBER_INFO , g.RECEIVE_TYPE as receiveType, s.name as shopName,s.phone as shopPhone ,s.id as shopId,g.exchange_code as exchangeCode , g.mail_price as mailPrice , g.TOTAL_PRICE as totalPrice " + |
| | | " from goodsorder g left join shop s on g.PICK_UP_SHOP_ID = s.id " + |
| | | " where g.id = #{id} ") |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import com.doumee.dao.web.dto.MultiFileDTO; |
| | | import com.doumee.dao.web.response.goods.GoodsSkuResponse; |
| | | import com.doumee.dao.web.response.goods.SkuResponse; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | |
| | | @ApiModelProperty(value = "专区编码" ) |
| | | @TableField(exist = false) |
| | | private Integer zhuanquId; |
| | | |
| | | @ApiModelProperty(value = "商家供货价" ) |
| | | @TableField(exist = false) |
| | | private BigDecimal shopPrice; |
| | | |
| | | @ApiModelProperty(value = "销量" ) |
| | | @TableField(exist = false) |
| | | private Integer realSaleNum; |
| | | |
| | | @ApiModelProperty(value = "最低价" ) |
| | | @TableField(exist = false) |
| | | private BigDecimal minPrice; |
| | | |
| | | @ApiModelProperty(value = "划线价" ) |
| | | @TableField(exist = false) |
| | | private BigDecimal linePrice; |
| | | |
| | | @ApiModelProperty(value = "供货价") |
| | | @TableField(exist = false) |
| | | private BigDecimal exFactoryPrice; |
| | | |
| | | @ApiModelProperty(value = "适用品牌名称") |
| | | @TableField(exist = false) |
| | | private String brandNames ; |
| | | |
| | | @ApiModelProperty(value = "真实库存") |
| | | @TableField(exist = false) |
| | | private Integer stock; |
| | | |
| | | @ApiModelProperty(value = "收藏状态:0=未收藏;1=已收藏") |
| | | @TableField(exist = false) |
| | | private Integer collectStatus; |
| | | |
| | | @ApiModelProperty(value = "商品规格列表") |
| | | @TableField(exist = false) |
| | | private List<GoodsSkuResponse> goodsSkuResponseList; |
| | | |
| | | |
| | | @ApiModelProperty(value = "商品商品SKU信息列表") |
| | | @TableField(exist = false) |
| | | private List<SkuResponse> skuResponsesList; |
| | | |
| | | @ApiModelProperty(value = "商品分类") |
| | | @TableField(exist = false) |
| | | private Labels categoryLabels; |
| | | |
| | | |
| | | @ApiModelProperty(value = "品牌") |
| | | @TableField(exist = false) |
| | | private Labels brandLabels; |
| | | |
| | | @ApiModelProperty(value = "商品轮播图") |
| | | @TableField(exist = false) |
| | | private List<MultiFileDTO> goodBannerMultiFiles; |
| | | } |
| | |
| | | @ApiModelProperty(value = "折扣卷满减上限金额") |
| | | private BigDecimal maxPrice; |
| | | |
| | | @ApiModelProperty(value = "过期通知:0=未通知;1=已通知", example = "1") |
| | | private Integer noticeStatus; |
| | | |
| | | @ApiModelProperty(value = "通知时间", example = "1") |
| | | private Date noticeTime; |
| | | |
| | | @ApiModelProperty(value = "昵称") |
| | | @TableField(exist = false) |
| | | @ExcelColumn(name="用户",width = 10,index = 1) |
| | |
| | | |
| | | |
| | | |
| | | public Notice notice(Constants.NoticeType noticeType,Integer memberId,Integer objId){ |
| | | public static Notice getNotice(Constants.NoticeType noticeType,Integer memberId,Integer objId){ |
| | | Notice notice = new Notice(); |
| | | notice.setCreateDate(new Date()); |
| | | notice.setIsdeleted(Constants.ZERO); |
| | | notice.setMemberId(memberId); |
| | | notice.setTitle(noticeType.getTitle()); |
| | | notice.setContent(noticeType.getContent()); |
| | | notice.setType(noticeType.getNoticeType()); |
| | | notice.setObjId(objId); |
| | | notice.setObjType(noticeType.getObjType()); |
| | | |
| | | |
| | | notice.setType(noticeType.getNoticeType()); |
| | | notice.setStatus(Constants.ZERO); |
| | | return notice; |
| | | } |
| | | |
| | |
| | | @ApiModelProperty(value = "倒计时", example = "1") |
| | | private Long countdown; |
| | | |
| | | @ApiModelProperty(value = "取消时间", example = "1") |
| | | @ApiModelProperty(value = "订单取消时间", example = "1") |
| | | private Date cancelDate; |
| | | |
| | | |
| | | @ApiModelProperty(value = "取消时间(自动取消使用)", example = "1") |
| | | private Date cancelOptDate; |
| | | |
| | | |
| | | @ApiModelProperty(value = "创建时间", example = "1") |
| | | private Date createDate; |
| | | |
| | |
| | | @ApiModelProperty(value = "微信调起业务") |
| | | private Object response; |
| | | |
| | | @ApiModelProperty(value = "锁定编号",hidden = true) |
| | | private String lockKey; |
| | | |
| | | } |
| | |
| | | void autoDone(); |
| | | |
| | | void afterSaleApply(AfterSaleApplyRequest afterSaleApplyRequest); |
| | | |
| | | } |
| | |
| | | * @param pageWrap |
| | | * @return |
| | | */ |
| | | IPage<GoodsInfoResponse> getGoodsPage(PageWrap<GoodsRequest> pageWrap); |
| | | IPage<Goods> getGoodsPage(PageWrap<GoodsRequest> pageWrap); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | GoodsInfoResponse getGoodsInfo(Integer goodsId,Integer memberId); |
| | | Goods getGoodsInfo(Integer goodsId,Integer memberId); |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | String createExchangeCode(); |
| | | |
| | | |
| | | void autoCancelOrder(); |
| | | |
| | | } |
| | |
| | | IntegralDataResponse getIntegralData(IntegralRecordDTO model); |
| | | |
| | | void updateIntegral(Integral param); |
| | | |
| | | /** |
| | | * 积分过期处理(定时任务) |
| | | */ |
| | | void expiredIntegral(); |
| | | |
| | | |
| | | /** |
| | | * 积分即将过期通知 |
| | | */ |
| | | void expiredIntegralNotice(); |
| | | } |
| | | |
| | |
| | | List<MemberCoupon> getApplyCoupon(List<PayDetailRequest> requestList, Integer memberId); |
| | | |
| | | String addBatch(MemberCouponAddDTO memberCoupon); |
| | | |
| | | /** |
| | | * 定时通知用户优惠券即将过期 |
| | | * @param days 提前通知天数 |
| | | */ |
| | | void notifyExpiredCoupon(Integer days); |
| | | } |
| | |
| | | @Autowired |
| | | private GoodsorderMapper goodsorderMapper; |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | @Autowired |
| | | private ShopMapper shopMapper; |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | |
| | | if(Constants.equalsInteger(goodsorder.getReceiveType(),Constants.ONE)&&StringUtils.isNotBlank(goodsorder.getExchangeCode())){ |
| | | RedisUtil.deleteObject(redisTemplate,Constants.RedisKeys.EXCHANGE_KEY+goodsorder.getExchangeCode()); |
| | | } |
| | | |
| | | |
| | | //发送订单退款站内信 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.NOTICE_ORDER_REFUND, |
| | | goodsorder.getMemberId(), |
| | | goodsorder.getId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",goodsorder.getCode().toString())); |
| | | noticeMapper.insert(notice); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | BannerDTO dto = new BannerDTO(); |
| | | BeanUtils.copyProperties(s, dto); |
| | | dto.setImgurl(path + s.getImgurl()); |
| | | if (Constants.equalsInteger(dto.getType(),Constants.ZERO)){ |
| | | dto.setContent(null); |
| | | } |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | return collect; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<GoodsInfoResponse> getGoodsPage(PageWrap<GoodsRequest> pageWrap) { |
| | | public IPage<Goods> getGoodsPage(PageWrap<GoodsRequest> pageWrap) { |
| | | GoodsRequest model = pageWrap.getModel(); |
| | | QueryWrapper<GoodsRequest> wrapper = new QueryWrapper<GoodsRequest>() |
| | | .eq("g.ISDELETED",Constants.ZERO) |
| | | MPJLambdaWrapper<Goods> wrapper = new MPJLambdaWrapper<Goods>() |
| | | .selectAll(Goods.class) |
| | | .select(" ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getMinPrice) |
| | | .leftJoin(SystemUser.class, SystemUser::getId, Goods::getCreator) |
| | | .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | .eq(!Objects.isNull(model) && Objects.nonNull(model.getCategoryId()), |
| | | "g.CATEGORY_ID", model.getCategoryId()) |
| | | Goods::getCategoryId, model.getCategoryId()) |
| | | //适用品牌 适用系列 |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getApplicableBrandId()), |
| | | " find_in_set( '["+model.getApplicableBrandId()+"]' , g.BRAND_IDS ) ") |
| | | " find_in_set( '["+model.getApplicableBrandId()+"]' , t.BRAND_IDS ) ") |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getSeriesBrandId()), |
| | | " find_in_set( '["+model.getSeriesBrandId()+"]' , g.SERIAL_IDS ) ") |
| | | .eq("g.STATUS", Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(model.getGoodsName()),"g.NAME",model.getGoodsName()); |
| | | " find_in_set( '["+model.getSeriesBrandId()+"]' , t.SERIAL_IDS ) ") |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getQualityId()), |
| | | " find_in_set( '["+model.getQualityId()+"]' , t.ZHUANQU_IDS ) ") |
| | | .eq(Goods::getStatus, Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(model.getGoodsName()),Goods::getName,model.getGoodsName()); |
| | | if(Objects.nonNull(model.getShopId())){ |
| | | wrapper.select(" ifnull( ( select sgr.PRICE from shop_goods_relation sgr where sgr.GOODS_ID = t.ID and sgr.ISDELETED = 0 and sgr.`STATUS` = 0 and sgr.SHOP_ID = "+model.getShopId()+" ) ,0) ",Goods::getExFactoryPrice); |
| | | wrapper.select(" ifnull(( select sum(gd.GOODS_NUM) from goodsorder_detail gd inner join goodsorder go on gd.ORDER_ID = go.id where gd.GOODS_ID = t.`id` and go.DISTRIBUTION_SHOP_ID = "+model.getShopId()+" ),0) ",Goods::getRealSaleNum); |
| | | |
| | | if(Objects.nonNull(model.getSortInfo())){ |
| | | //排序方式:0=综合排序;1=销量由低到高 ;2=价格由低到高;3=销量由高到低;4=价格由高到低 |
| | | if(Constants.equalsInteger(model.getSortInfo(),Constants.ZERO)){ |
| | | wrapper.orderByDesc("g.CREATE_DATE"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.ONE)){ |
| | | wrapper.orderByAsc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.TWO)){ |
| | | wrapper.orderByAsc("g.price"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.THREE)){ |
| | | wrapper.orderByDesc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.FOUR)){ |
| | | wrapper.orderByDesc("g.price"); |
| | | } |
| | | } |
| | | IPage<GoodsInfoResponse> page = |
| | | Objects.isNull(model.getShopId())? |
| | | goodsMapper.goodsPage(pageWrap.toPage(),wrapper) |
| | | : |
| | | goodsMapper.goodsPageForShop(pageWrap.toPage(),wrapper,model.getShopId()) ; |
| | | }else{ |
| | | wrapper.select(" (( select ifnull(sum(GOODS_NUM),0) from goodsorder_detail gd where gd.GOODS_ID = t.id )) ",Goods::getRealSaleNum); |
| | | } |
| | | |
| | | if(Objects.nonNull(model.getSortInfo())){ |
| | | //排序方式:0=综合排序;1=销量由低到高 ;2=价格由低到高;3=销量由高到低;4=价格由高到低 |
| | | if(Constants.equalsInteger(model.getSortInfo(),Constants.ZERO)){ |
| | | wrapper.orderByDesc("t.CREATE_DATE"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.ONE)){ |
| | | wrapper.orderByAsc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.TWO)){ |
| | | wrapper.orderByAsc("t.price"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.THREE)){ |
| | | wrapper.orderByDesc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.FOUR)){ |
| | | wrapper.orderByDesc("t.price"); |
| | | } |
| | | } |
| | | IPage<Goods> page = |
| | | goodsMapper.selectJoinPage(pageWrap.toPage(), Goods.class, wrapper); |
| | | if (!CollectionUtils.isEmpty(page.getRecords())){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.GOODS_FILE); |
| | | |
| | | |
| | | for (GoodsInfoResponse goodsInfoResponse:page.getRecords() |
| | | ) { |
| | | for (Goods goodsInfoResponse:page.getRecords()) { |
| | | goodsInfoResponse.setImgurl(StringUtils.isNotBlank(goodsInfoResponse.getImgurl())?(preFixPath+goodsInfoResponse.getImgurl()):null); |
| | | if(Objects.isNull(model.getShopId())){ |
| | | //sku基础信息 |
| | |
| | | * @param goodsResponse |
| | | * @return |
| | | */ |
| | | public void getSkuInfo(GoodsInfoResponse goodsResponse) { |
| | | public void getSkuInfo(Goods goodsResponse) { |
| | | |
| | | List<GoodsSkuResponse> goodsSkuResponseList = goodsSkuMapper.getSkuResponseList(goodsResponse.getId()); |
| | | |
| | | // String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | // systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | | Integer sumStock = Constants.ZERO; |
| | | for (GoodsSkuResponse goodsSkuResponse:goodsSkuResponseList) { |
| | | goodsSkuResponse.setStock(Objects.isNull(goodsSkuResponse.getStock())?Constants.ZERO:goodsSkuResponse.getStock()); |
| | | // if(StringUtils.isBlank(goodsSkuResponse.getImgurl())){ |
| | | // goodsSkuResponse.setImgurl(fullUrl + goodsSkuResponse.getGoodsImgUrl()); |
| | | // }else{ |
| | | // goodsSkuResponse.setImgurl(fullUrl + goodsSkuResponse.getImgurl()); |
| | | // } |
| | | // //处理数据下标 |
| | | // String goodsSkuName = goodsSkuResponse.getName(); |
| | | // List<String> strList = Arrays.asList(goodsSkuName.split(";")); |
| | | // StringBuffer indexData = new StringBuffer(); |
| | | // for (int i = 0; i < strList.size(); i++) { |
| | | // //查询sku信息 |
| | | // Sku sku = skuMapper.selectOne(new QueryWrapper<Sku>() |
| | | // .eq("GOODS_ID",goodsResponse.getId()) |
| | | // .eq("SORTNUM",i) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // if(Objects.isNull(sku)){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"SKU信息异常,请刷新查看"); |
| | | // } |
| | | // //查询SKU_ATTR |
| | | // SkuAttr skuAttr = skuAttrMapper.selectOne(new QueryWrapper<SkuAttr>() |
| | | // .eq("SKU_ID",sku.getId()) |
| | | // .eq("NAME",strList.get(i)) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // if(Objects.isNull(skuAttr)){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"SKU信息异常,请刷新查看"); |
| | | // } |
| | | // indexData.append("," + ( skuAttr.getSortnum()-1)); |
| | | // } |
| | | // goodsSkuResponse.setIndexData(indexData.toString().substring(1)); |
| | | sumStock = sumStock + goodsSkuResponse.getStock(); |
| | | } |
| | | //真实销量 = realSaleNum - saleNum; |
| | | //真实库存= sumStock - (realSaleNum - saleNum) |
| | | goodsResponse.setStock(sumStock - goodsResponse.getRealSaleNum() + goodsResponse.getSaleNum()); |
| | | goodsResponse.setStock(sumStock); |
| | | goodsResponse.setRealSaleNum(goodsResponse.getRealSaleNum()+sumStock); |
| | | goodsResponse.setGoodsSkuResponseList(goodsSkuResponseList); |
| | | //Sku基础信息 |
| | | List<SkuResponse> skuResponseList = skuMapper.getSkuResponseList(goodsResponse.getId()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GoodsInfoResponse getGoodsInfo(Integer goodsId,Integer memberId) { |
| | | public Goods getGoodsInfo(Integer goodsId,Integer memberId) { |
| | | String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | | GoodsInfoResponse goodsResponse = goodsMapper.getGoodsInfo(goodsId); |
| | | // GoodsInfoResponse goodsResponse = goodsMapper.getGoodsInfo(goodsId); |
| | | Goods goodsResponse = goodsMapper.selectOne( |
| | | new MPJLambdaWrapper<Goods>() |
| | | .selectAll(Goods.class) |
| | | .select(" (( select ifnull(sum(GOODS_NUM),0) from goodsorder_detail gd where gd.GOODS_ID = t.id )) ",Goods::getRealSaleNum) |
| | | .select(" ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getMinPrice) |
| | | .select(" ifnull(( select min(gs.SHOW_PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getLinePrice) |
| | | .leftJoin(SystemUser.class, SystemUser::getId, Goods::getCreator) |
| | | // .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | // .eq(Goods::getStatus, Constants.ZERO) |
| | | .eq(Goods::getId,goodsId) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(goodsResponse)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import java.net.UnknownHostException; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private IntegralMapper integralMapper; |
| | | |
| | | |
| | | private final static String GOODS_ORDER_CREATE_LOCK = "goods:order:create:lock:"; |
| | | |
| | | @Override |
| | | public Integer create(Goodsorder goodsorder) { |
| | |
| | | goodsorder.getKdName()+"(单号:"+goodsorder.getKdCode()+")"); |
| | | |
| | | } |
| | | |
| | | //发送发货站内信 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.NOTICE_ORDER_SEND, |
| | | goodsorder.getMemberId(), |
| | | goodsorder.getId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",goodsorder.getCode().toString())); |
| | | noticeMapper.insert(notice); |
| | | |
| | | |
| | | /* // TODO 发送微信模板消息 |
| | | Member member=memberMapper.selectById(query.getMemberId()); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public PayResponse orderPay(ShopOrderPayRequest orderPayRequest,MemberCouponServiceImpl memberCouponService){ |
| | | String lockKey = GOODS_ORDER_CREATE_LOCK + orderPayRequest.getMemberId(); |
| | | //判断前端是否在同一页面创建了两次订单 |
| | | if (redisTemplate.hasKey(lockKey)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"正在创建订单,请勿重复调用!"); |
| | | } else { |
| | | redisTemplate.opsForValue().set(lockKey, "", 5, TimeUnit.SECONDS); |
| | | } |
| | | Member member = memberMapper.selectById(orderPayRequest.getMemberId()); |
| | | |
| | | Goodsorder goodsorder = new Goodsorder(); |
| | |
| | | } |
| | | goodsorder.setPrice(orderPayConfirmResponse.getPayAmount()); |
| | | goodsorder.setTotalPrice(orderPayConfirmResponse.getAmount()); |
| | | goodsorder.setUseIntegral(orderPayConfirmResponse.getDeductIntegral()); |
| | | goodsorder.setIntegral(orderPayConfirmResponse.getIntegralAmount()); |
| | | goodsorder.setUseIntegral(Constants.equalsInteger(orderPayRequest.getUseIntegral(),Constants.ONE)?orderPayConfirmResponse.getDeductIntegral():BigDecimal.ZERO); |
| | | goodsorder.setIntegral(Constants.equalsInteger(orderPayRequest.getUseIntegral(),Constants.ONE)?orderPayConfirmResponse.getIntegralAmount():BigDecimal.ZERO); |
| | | goodsorder.setMailPrice(orderPayConfirmResponse.getMailAmount()); |
| | | goodsorder.setPayMethod(goodsorder.getPrice().compareTo(BigDecimal.ZERO)>Constants.ZERO?Constants.ZERO:Constants.ONE); |
| | | goodsorder.setGoodsNum(orderPayRequest.getPayDetailRequestList().stream().mapToInt(PayDetailRequest::getGoodsNum).sum()); |
| | |
| | | for (OrderGoodsCalculateResponse payDetailRequest:goodsCalculateList) { |
| | | //查询商品 |
| | | GoodsSku goodsSku = goodsSkuMapper.selectById(payDetailRequest.getSkuId()); |
| | | if(Objects.isNull(goodsSku)){ |
| | | if(Objects.isNull(goodsSku)||!Constants.equalsInteger(goodsSku.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品SKU信息!"); |
| | | } |
| | | Goods goods = goodsMapper.selectById(goodsSku.getGoodsId()); |
| | | if(Objects.isNull(goods)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品信息!"); |
| | | } |
| | | if(goods.getStatus().equals(Constants.ONE)){ |
| | | if(!Constants.equalsInteger(goods.getStatus(),Constants.ZERO)||!Constants.equalsInteger(goods.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在商品已删除或已下架,无法下单"); |
| | | } |
| | | if(goodsSku.getStock().compareTo(new BigDecimal(Constants.formatIntegerNum(payDetailRequest.getGoodsNum())))<Constants.ZERO){ |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品价格发生变化,请刷新后重新支付!"); |
| | | } |
| | | |
| | | |
| | | //存在现金支付 |
| | | if(Constants.equalsInteger(goodsorder.getPayMethod(),Constants.ZERO)){ |
| | | return this.wxPay(goodsorder,member); |
| | | PayResponse payResponse = this.wxPay(goodsorder,member); |
| | | payResponse.setLockKey(lockKey); |
| | | return payResponse; |
| | | } |
| | | //无现金支付 |
| | | goodsorderMapper.update(null,new UpdateWrapper<Goodsorder>().lambda() |
| | |
| | | PayResponse payResponse = new PayResponse(); |
| | | payResponse.setOrderId(goodsorder.getId()); |
| | | payResponse.setPayType(Constants.ONE); |
| | | //发送通知 |
| | | if(Objects.nonNull(goodsorder.getPickUpShopId())){ |
| | | //发送站内信 - 经销商 |
| | | noticeService.orderPayNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getReceiveType()); |
| | | } |
| | | |
| | | payResponse.setLockKey(lockKey); |
| | | // //发送通知 |
| | | // if(Objects.nonNull(goodsorder.getPickUpShopId())){ |
| | | // //发送站内信 - 经销商 |
| | | // noticeService.orderPayNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getReceiveType()); |
| | | // } |
| | | |
| | | return payResponse; |
| | | } |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到订单信息"); |
| | | } |
| | | if(memberOrderResponse.getOrderStatus().equals(Constants.OrderStatus.WAIT_PAY.getKey())){ |
| | | memberOrderResponse.setCountdown(memberOrderResponse.getCancelDate().getTime()>System.currentTimeMillis()?memberOrderResponse.getCancelDate().getTime()-System.currentTimeMillis():Constants.ZERO); |
| | | memberOrderResponse.setCountdown(memberOrderResponse.getCancelOptDate().getTime()>System.currentTimeMillis()?memberOrderResponse.getCancelOptDate().getTime()-System.currentTimeMillis():Constants.ZERO); |
| | | } |
| | | String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void cancelOrderNew(Integer orderId,Integer optUserId,String cancelInfo){ |
| | | if(Objects.isNull(orderId)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(orderId); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | || Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.PAY_DONE.getKey()) )){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单取消失败:订单状态已流转!"); |
| | | } |
| | | public void cancel(Goodsorder goodsorder,Integer optUserId,String cancelInfo){ |
| | | if(Constants.formatBigdecimal(goodsorder.getPrice()).compareTo(BigDecimal.ZERO)>Constants.ZERO |
| | | && Constants.equalsObject(goodsorder.getPayStatus(),Constants.ONE) ){ |
| | | //微信现金退款 |
| | |
| | | fundMapper.insert(fund); |
| | | } |
| | | //订单已支付状态 , 使用了积分 且积分使用大于0 |
| | | if(goodsorder.getIntegral().compareTo(BigDecimal.ZERO)>Constants.ZERO){ |
| | | if(goodsorder.getUseIntegral().compareTo(BigDecimal.ZERO)>Constants.ZERO){ |
| | | //更新余额信息 添加积分变动记录 |
| | | DealIntegralRequest dealIntegralRequest = new DealIntegralRequest(); |
| | | dealIntegralRequest.setIntegralNum(goodsorder.getIntegral()); |
| | | dealIntegralRequest.setIntegralNum(goodsorder.getUseIntegral()); |
| | | dealIntegralRequest.setDealType(Constants.ZERO); |
| | | dealIntegralRequest.setMemberId(goodsorder.getMemberId()); |
| | | dealIntegralRequest.setObjId(goodsorder.getId()); |
| | |
| | | } |
| | | |
| | | // 用户主动取消 发送经销商站内消息 |
| | | if(Objects.nonNull(goodsorder.getPickUpShopId())&&StringUtils.isBlank(cancelInfo)){ |
| | | noticeService.orderCancelNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getCode().toString()); |
| | | } |
| | | // if(Objects.nonNull(goodsorder.getPickUpShopId())&&StringUtils.isBlank(cancelInfo)){ |
| | | // noticeService.orderCancelNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getCode().toString()); |
| | | // } |
| | | |
| | | //查询优惠券信息记录 |
| | | if(!Objects.isNull(goodsorder.getCouponId())){ |
| | |
| | | memberCouponMapper.updateById(memberCoupon); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void cancelOrderNew(Integer orderId,Integer optUserId,String cancelInfo){ |
| | | if(Objects.isNull(orderId)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(orderId); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | || Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.PAY_DONE.getKey()) )){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单取消失败:订单状态已流转!"); |
| | | } |
| | | this.cancel(goodsorder,optUserId,cancelInfo); |
| | | |
| | | } |
| | | |
| | | public BigDecimal getDeductAmount(List<PayDetailRequest> requestList){ |
| | |
| | | this.orderAddMemberIntegral(goodsorder); |
| | | //经销商 结算金额 |
| | | this.orderAddShopCash(goodsorder); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | couponNoticeRequest.setMemberCoupon(memberCoupon); |
| | | couponNoticeRequest.setNum(num); |
| | | requestList.add(couponNoticeRequest); |
| | | |
| | | Notice notice = Notice.getNotice(Constants.NoticeType.COUPON, |
| | | member.getId(),null); |
| | | notice.setContent(notice.getContent().replace("{param}",Constants.getCouponInfo(memberCoupon,num))); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberCouponList)){ |
| | | memberCouponJoinMapper.insert(memberCouponList); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(requestList)){ |
| | | //发送站内信 |
| | | noticeService.couponNotice(inviteMember.getId(),requestList); |
| | | } |
| | | // if(CollectionUtils.isNotEmpty(requestList)){ |
| | | // //发送站内信 |
| | | // noticeService.couponNotice(inviteMember.getId(),requestList); |
| | | // } |
| | | } |
| | | inviteRecordMapper.update(new UpdateWrapper<InviteRecord>().lambda() |
| | | .set(InviteRecord::getFirstOrderStatus,Constants.ONE) |
| | |
| | | //经销商 结算金额 |
| | | this.orderAddShopCash(goodsorder); |
| | | } |
| | | //发送核销通知 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.NOTICE_ORDER_WRITE_OFF, |
| | | goodsorder.getMemberId(), |
| | | goodsorder.getId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",goodsorder.getCode().toString())); |
| | | noticeMapper.insert(notice); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单未支付超时自动取消 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void autoCancelOrder(){ |
| | | List<Goodsorder> goodsorderList = goodsorderMapper.selectList(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getIsdeleted, Constants.ZERO) |
| | | .eq(Goodsorder::getStatus, Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | .ge(Goodsorder::getCreateDate, "DATE_SUB(NOW(), INTERVAL 15 MINUTE)") |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(goodsorderList)){ |
| | | for (Goodsorder goodsorder:goodsorderList) { |
| | | this.cancel(goodsorder,null,"订单未支付超时自动取消"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private NoticeService noticeService; |
| | | |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | @Transactional(rollbackFor = {Exception.class, BusinessException.class}) |
| | | @Override |
| | |
| | | integral.setIsdeleted(Constants.ZERO); |
| | | integral.setTitle(dealIntegralRequest.getIntegralObjType().getName()); |
| | | String info = dealIntegralRequest.getIntegralObjType().getNoteinfo(); |
| | | info = info.replace("${param}",dealIntegralRequest.getIntegralNum().toString()); |
| | | info = info.replace("${param}",dealIntegralRequest.getIntegralNum().intValue()+""); |
| | | if(StringUtils.isNotBlank(dealIntegralRequest.getParam1())){ |
| | | info = info .replace("${param1}",dealIntegralRequest.getParam1()); |
| | | } |
| | |
| | | integral.setObjType(dealIntegralRequest.getIntegralObjType().getKey()); |
| | | integral.setType(dealIntegralRequest.getDealType()); |
| | | integral.setNum(dealIntegralRequest.getIntegralNum()); |
| | | integral.setTotalNum(dealIntegralRequest.getDealType().equals(Constants.ZERO)? member.getIntegral().add(integral.getNum()):member.getIntegral().subtract(integral.getNum())); |
| | | integral.setTotalNum(dealIntegralRequest.getDealType().equals(Constants.ZERO)? Objects.nonNull(member.getIntegral())?member.getIntegral():BigDecimal.ZERO.add(integral.getNum()):Objects.nonNull(member.getIntegral())?member.getIntegral():BigDecimal.ZERO.subtract(integral.getNum())); |
| | | integral.setOrderCode(dealIntegralRequest.getOrderCode()); |
| | | integral.setUserType(Constants.ZERO); |
| | | integralMapper.insert(integral); |
| | |
| | | |
| | | //站内信 |
| | | noticeService.saveMemberIntegralNotice( |
| | | dealIntegralRequest.getIntegralObjType(),Constants.ZERO,member.getId(),dealIntegralRequest.getIntegralNum(), |
| | | dealIntegralRequest.getIntegralObjType(),Constants.ONE,member.getId(),dealIntegralRequest.getIntegralNum(), |
| | | integral.getId(), info |
| | | ); |
| | | return integral.getId(); |
| | |
| | | |
| | | @Override |
| | | public Integer dealShopIntegral(DealIntegralRequest dealIntegralRequest,Shop shop) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(shop ==null){ |
| | | shop = shopMapper.selectById(dealIntegralRequest.getMemberId()); |
| | | } |
| | |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .eq(Shop::getId,shop.getId()) |
| | | .set(Shop::getEditDate,new Date()) |
| | | .set(Shop::getEditor,user!=null ? user.getId():null) |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ZERO),"total_integral = ifnull(total_integral,0)+" + dealIntegralRequest.getIntegralNum())//累计增加 |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ZERO),"integral = ifnull(integral,0)+" + dealIntegralRequest.getIntegralNum()) |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ONE),"integral = ifnull(integral,0)-" + dealIntegralRequest.getIntegralNum())); |
| | | /* if(dealIntegralRequest.getDealType().equals(Constants.ZERO)){ |
| | | shopMapper.addIntegral(shop.getId(),dealIntegralRequest.getIntegralNum(), |
| | | dealIntegralRequest.getIntegralObjType().getAddTitle()==Constants.ZERO?dealIntegralRequest.getIntegralNum():BigDecimal.ZERO); |
| | | }else{ |
| | | |
| | | shopMapper.subtractIntegral(shop.getId(),dealIntegralRequest.getIntegralNum()); |
| | | }*/ |
| | | |
| | | //站内信 |
| | | noticeService.saveMemberIntegralNotice( |
| | | dealIntegralRequest.getIntegralObjType(),Constants.ZERO,shop.getId(),dealIntegralRequest.getIntegralNum(), |
| | | integral.getId(), info |
| | | ); |
| | | // //站内信 |
| | | // noticeService.saveMemberIntegralNotice( |
| | | // dealIntegralRequest.getIntegralObjType(),Constants.ZERO,shop.getId(),dealIntegralRequest.getIntegralNum(), |
| | | // integral.getId(), info |
| | | // ); |
| | | return integral.getId(); |
| | | } |
| | | |
| | |
| | | integral.setUserType(Constants.TWO); |
| | | integralMapper.insert(integral); |
| | | |
| | | LoginUserInfo user =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .eq(Shop::getId,shop.getId()) |
| | | .set(Shop::getEditDate,new Date()) |
| | | .set(Shop::getEditor,user!=null ? user.getId():null) |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ZERO),"total_integral = ifnull(total_integral,0)+" + dealIntegralRequest.getIntegralNum())//累计增加 |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ZERO),"integral = ifnull(integral,0)+" + dealIntegralRequest.getIntegralNum()) |
| | | .setSql(dealIntegralRequest.getDealType().equals(Constants.ONE),"integral = ifnull(integral,0)-" + dealIntegralRequest.getIntegralNum())); |
| | | |
| | | |
| | | /* if(dealIntegralRequest.getDealType().equals(Constants.ZERO)){ |
| | | shopMapper.addAmount(shop.getId(),dealIntegralRequest.getIntegralNum(), |
| | | dealIntegralRequest.getIntegralObjType().getAddTitle()==Constants.ZERO?dealIntegralRequest.getIntegralNum():BigDecimal.ZERO); |
| | | }else{ |
| | | shopMapper.subtractAmount(shop.getId(),dealIntegralRequest.getIntegralNum()); |
| | | }*/ |
| | | return integral.getId(); |
| | | } |
| | | |
| | |
| | | IntegralDataResponse integralDataResponse = new IntegralDataResponse(); |
| | | integralDataResponse.setSurplusIntegral(BigDecimal.ZERO); |
| | | integralDataResponse.setExpiredIntegral(BigDecimal.ZERO); |
| | | Shop shop = shopMapper.selectById(model.getMemberId()); |
| | | if (Objects.nonNull(shop)) { |
| | | integralDataResponse.setSurplusIntegral( |
| | | Constants.equalsInteger(model.getUserType(),Constants.TWO)?shop.getAmount():shop.getIntegral()); |
| | | //用户积分 |
| | | if(Constants.equalsInteger(model.getUserType(),Constants.ZERO)){ |
| | | Member member = memberMapper.selectById(model.getMemberId()); |
| | | integralDataResponse.setSurplusIntegral(member.getIntegral()); |
| | | }else{ |
| | | //商户积分/余额 |
| | | Shop shop = shopMapper.selectById(model.getMemberId()); |
| | | if (Objects.nonNull(shop)) { |
| | | integralDataResponse.setSurplusIntegral( |
| | | Constants.equalsInteger(model.getUserType(),Constants.TWO)?shop.getAmount():shop.getIntegral()); |
| | | } |
| | | } |
| | | List<Integral> list = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Objects.nonNull(model.getUserType()),Integral::getUserType,model.getUserType()) |
| | |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ); |
| | | } |
| | | //积分失效方式 0长期有效 1按积分产生时间失效 |
| | | Integer type = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDTYPE).getCode()); |
| | | //消费者积分 需要查询即将过期积分 |
| | | if(Constants.equalsInteger(type,Constants.ONE)&& Constants.equalsInteger(model.getUserType(),Constants.ONE)){ |
| | | Integer validYear = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDCIRCLE).getCode()); |
| | | if(validYear.compareTo(Constants.ZERO)>Constants.ZERO){ |
| | | list = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Objects.nonNull(model.getUserType()),Integral::getUserType,model.getUserType()) |
| | | .eq(Objects.nonNull(model.getType()),Integral::getType,model.getType()) |
| | | .eq(Integral::getMemberId,model.getMemberId()) |
| | | .apply(" CREATE_DATE >= DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL "+(validYear*12)+1+" MONTH) ") |
| | | .orderByDesc(Integral::getCreateDate)); |
| | | BigDecimal newIntegral = list.stream().map(i->i.getNum().multiply(new BigDecimal(i.getType().toString())) |
| | | ).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | integralDataResponse.setExpiredIntegral( |
| | | integralDataResponse.getSurplusIntegral().compareTo(newIntegral)>Constants.ZERO?integralDataResponse.getSurplusIntegral().subtract(newIntegral):BigDecimal.ZERO |
| | | ); |
| | | if(Constants.equalsInteger(model.getUserType(),Constants.ZERO)){ |
| | | //积分失效方式 0长期有效 1按积分产生时间失效 |
| | | Integer type = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDTYPE).getCode()); |
| | | //消费者积分 需要查询即将过期积分 |
| | | if(Constants.equalsInteger(type,Constants.ONE)&& Constants.equalsInteger(model.getUserType(),Constants.ZERO)){ |
| | | Integer validYear = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDCIRCLE).getCode()); |
| | | if(validYear.compareTo(Constants.ZERO)>Constants.ZERO){ |
| | | List<Integral> expiredIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | .eq(Integral::getMemberId,model.getMemberId()) |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date < ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | |
| | | |
| | | //查询过期日期后的消耗积分 |
| | | List<Integral> useIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | .eq(Integral::getType, Constants.ONE) // 使用的积分 |
| | | .eq(Integral::getMemberId,model.getMemberId()) |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date >= ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | BigDecimal totalExpiredNum = expiredIntegrals.stream().map(i->i.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | |
| | | BigDecimal afterUseIntegral = useIntegrals.stream().map(i->i.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | |
| | | if(afterUseIntegral.compareTo(totalExpiredNum)>=Constants.ZERO){ |
| | | integralDataResponse.setExpiredIntegral(BigDecimal.ZERO); |
| | | }else{ |
| | | integralDataResponse.setExpiredIntegral(totalExpiredNum.subtract(afterUseIntegral)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | String info = systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALRULEINFO).getCode(); |
| | | integralDataResponse.setInfo(info); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 积分过期处理(定时任务) |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void expiredIntegral() { |
| | | // 积分失效方式 0 长期有效 1 按积分产生时间失效 |
| | | Integer type = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDTYPE).getCode()); |
| | | // 只有配置为按时间失效时才执行 |
| | | if (Constants.equalsInteger(type, Constants.ONE)) { |
| | | Integer validYear = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDCIRCLE).getCode()); |
| | | |
| | | if (validYear != null && validYear.compareTo(Constants.ZERO) > 0) { |
| | | // 查询所有需要处理的用户积分记录 |
| | | // 查询所有已过期但还未处理的积分记录 |
| | | List<Integral> expiredIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date < ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | |
| | | |
| | | //查询过期日期后的消耗积分 |
| | | List<Integral> useIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | .eq(Integral::getType, Constants.ONE) // 使用的积分 |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date >= ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | |
| | | if (CollectionUtils.isEmpty(expiredIntegrals)) { |
| | | return; |
| | | } |
| | | // 按会员分组统计过期积分 |
| | | Map<Integer, List<Integral>> memberIntegralMap = expiredIntegrals.stream() |
| | | .collect(Collectors.groupingBy(Integral::getMemberId)); |
| | | // 遍历每个用户的过期积分进行处理 |
| | | for (Map.Entry<Integer, List<Integral>> entry : memberIntegralMap.entrySet()) { |
| | | Integer memberId = entry.getKey(); |
| | | List<Integral> integrals = entry.getValue(); |
| | | // 统计该用户的总过期积分 |
| | | BigDecimal totalExpiredNum = integrals.stream() |
| | | .map(Integral::getNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (totalExpiredNum.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | // 查询用户当前积分 |
| | | Member member = memberMapper.selectById(memberId); |
| | | if (member == null || member.getIsdeleted() == Constants.ONE) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal afterUseIntegral = useIntegrals.stream().filter(i->Constants.equalsInteger(memberId,i.getMemberId())).map(i->i.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(afterUseIntegral.compareTo(totalExpiredNum)>=Constants.ZERO){ |
| | | continue; |
| | | } |
| | | DealIntegralRequest dealIntegralRequest = new DealIntegralRequest(); |
| | | dealIntegralRequest.setIntegralObjType(Constants.IntegralObjType.MEMBER_YEAR_SETTLEMENT); |
| | | dealIntegralRequest.setIntegralNum(totalExpiredNum.subtract(afterUseIntegral)); |
| | | dealIntegralRequest.setMemberId(memberId); |
| | | dealIntegralRequest.setDealType(Constants.ONE); |
| | | this.dealIntegral(dealIntegralRequest,member); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 积分即将过期通知 |
| | | */ |
| | | @Override |
| | | public void expiredIntegralNotice() { |
| | | // 积分失效方式 0 长期有效 1 按积分产生时间失效 |
| | | Integer type = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDTYPE).getCode()); |
| | | // 只有配置为按时间失效时才执行 |
| | | if (Constants.equalsInteger(type, Constants.ONE)) { |
| | | Integer validYear = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET, Constants.INTERALSET_INTEGRALINVALIDCIRCLE).getCode()); |
| | | |
| | | if (validYear != null && validYear.compareTo(Constants.ZERO) > 0) { |
| | | // 查询所有需要处理的用户积分记录 |
| | | // 查询所有已过期但还未处理的积分记录 |
| | | List<Integral> expiredIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date < ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | |
| | | //查询过期日期后的消耗积分 |
| | | List<Integral> useIntegrals = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getUserType, Constants.ZERO) // 消费者积分 |
| | | .eq(Integral::getIsdeleted, Constants.ZERO) // 未删除 |
| | | .eq(Integral::getType, Constants.ONE) // 使用的积分 |
| | | // 查找超过有效期的积分(创建日期早于当前日期减去有效年限) |
| | | .apply( " create_date >= ( DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'),INTERVAL " + ((validYear * 12) + 1) + " MONTH) ) ") // 已过期 |
| | | .orderByAsc(Integral::getCreateDate)); |
| | | |
| | | if (CollectionUtils.isEmpty(expiredIntegrals)) { |
| | | return; |
| | | } |
| | | // 按会员分组统计过期积分 |
| | | Map<Integer, List<Integral>> memberIntegralMap = expiredIntegrals.stream() |
| | | .collect(Collectors.groupingBy(Integral::getMemberId)); |
| | | // 遍历每个用户的过期积分进行处理 |
| | | for (Map.Entry<Integer, List<Integral>> entry : memberIntegralMap.entrySet()) { |
| | | Integer memberId = entry.getKey(); |
| | | List<Integral> integrals = entry.getValue(); |
| | | // 统计该用户的总过期积分 |
| | | BigDecimal totalExpiredNum = integrals.stream() |
| | | .map(Integral::getNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | BigDecimal afterUseIntegral = useIntegrals.stream().filter(i->Constants.equalsInteger(memberId,i.getMemberId())).map(i->i.getNum()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | |
| | | if (totalExpiredNum.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | // 查询用户当前积分 |
| | | Member member = memberMapper.selectById(memberId); |
| | | if (member == null || member.getIsdeleted() == Constants.ONE) { |
| | | continue; |
| | | } |
| | | if(afterUseIntegral.compareTo(totalExpiredNum)>=Constants.ZERO){ |
| | | continue; |
| | | } |
| | | //发送发货站内信 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.EXPIRE_INTEGRAL, |
| | | memberId, |
| | | null |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}", totalExpiredNum.subtract(afterUseIntegral).intValue()+"")); |
| | | noticeMapper.insert(notice); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.dto.CouponDTO; |
| | | import com.doumee.dao.web.dto.MemberCouponDTO; |
| | | import com.doumee.dao.web.request.CouponNoticeRequest; |
| | | import com.doumee.dao.web.request.PayDetailRequest; |
| | | import com.doumee.dao.web.response.MemberCouponResponse; |
| | | import com.doumee.dao.web.response.goods.OrderGoodsCalculateResponse; |
| | |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public String addBatch(MemberCouponAddDTO memberCouponAddDTO){ |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+index+"】个优惠券查询无效,请刷新页面重新!"); |
| | | } |
| | | for(Member member : memberList){ |
| | | MemberCoupon memberCoupon = MemberCoupon.couponToBean(coupon,member,now,Constants.TWO,loginUserInfo); |
| | | for (int i = 0; i < Constants.formatLongNum(param.getNum()); i++) { |
| | | MemberCoupon memberCoupon = MemberCoupon.couponToBean(coupon,member,now,Constants.TWO,loginUserInfo); |
| | | //满减卷不会生成maxPrice 需要根据优惠券减少金额设置 |
| | | if(Constants.equalsInteger(coupon.getCouponType(),Constants.ZERO)){ |
| | | memberCoupon.setMaxPrice(coupon.getPrice()); |
| | |
| | | //挨个送 |
| | | addList.add(memberCoupon); |
| | | } |
| | | //优惠券发放通知 |
| | | Notice notice = Notice.getNotice(Constants.NoticeType.COUPON, |
| | | member.getId(),null); |
| | | notice.setContent(notice.getContent().replace("{param}",Constants.getCouponInfo(memberCoupon, (int) Constants.formatLongNum(param.getNum())))); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | index++; |
| | | } |
| | |
| | | .in(GoodsSku::getId,requestList.stream().map(i->i.getGoodsSkuId()).collect(Collectors.toList())) |
| | | ); |
| | | if(CollectionUtils.isEmpty(goodsSkuList)||!Constants.equalsInteger(goodsSkuList.size(),requestList.size())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品SKU信息错误,请刷新重试"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品SKU信息已失效,请刷新重试"); |
| | | } |
| | | //查询商品列表 |
| | | List<Goods> goodsList = goodsMapper.selectJoinList(Goods.class, |
| | |
| | | List<MemberCoupon> allCoupon = memberCouponMapper.selectList(new QueryWrapper<MemberCoupon>().lambda() |
| | | .eq(MemberCoupon::getIsdeleted,Constants.ZERO) |
| | | .eq(MemberCoupon::getStatus,Constants.ZERO) |
| | | .eq(MemberCoupon::getMemberId,memberId) |
| | | .apply(" LIMIT_PRICE <= " + totalAmount) |
| | | .apply(" now() between START_DATE and END_DATE ")); |
| | | |
| | |
| | | //适用类型:0=全场;1=品类;2=指定商品 |
| | | if(Constants.equalsInteger(memberCoupon.getApplyType(),Constants.ZERO)){ |
| | | memberCoupon.setValidAmount(memberCoupon.getPrice()); |
| | | memberCouponList.add(memberCoupon); |
| | | }else{ |
| | | List<String> applyIdList = Arrays.asList(memberCoupon.getApplyIds().split(",")); |
| | | //获取有效可以使用优惠券的数据 |
| | | isVaildUse(applyIdList,goodsCalculateList, |
| | | Constants.equalsInteger(memberCoupon.getApplyType(),Constants.ONE)?Constants.ONE:Constants.ZERO); |
| | | isVaildUse(applyIdList,goodsCalculateList,memberCoupon.getApplyType()); |
| | | BigDecimal skuAmount = goodsCalculateList.stream().filter(i->i.getUseCoupon()).map(i->i.getSkuAmount()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(skuAmount.compareTo(memberCoupon.getLimitPrice())>=Constants.ZERO){ |
| | | //根据金额计算实际折扣金额 |
| | |
| | | .in(GoodsSku::getId,requestList.stream().map(i->i.getGoodsSkuId()).collect(Collectors.toList())) |
| | | ); |
| | | if(CollectionUtils.isEmpty(goodsSkuList)||!Constants.equalsInteger(goodsSkuList.size(),requestList.size())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品SKU信息错误,请刷新重试"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品SKU信息已失效,请刷新重试"); |
| | | } |
| | | //查询商品列表 |
| | | List<Goods> goodsList = goodsMapper.selectJoinList(Goods.class, |
| | |
| | | //根据优惠券类型 计算可以使用优惠券的商品信息 适用类型:0=全场;1=品类;2=指定商品 |
| | | if(!Constants.equalsInteger(coupon.getApplyType(),Constants.ZERO)){ |
| | | List<String> applyIdList = Arrays.asList(coupon.getApplyIds().split(",")); |
| | | isVaildUse(applyIdList,goodsCalculateList, |
| | | Constants.equalsInteger(coupon.getApplyType(),Constants.ONE)?Constants.ONE:Constants.ZERO); |
| | | isVaildUse(applyIdList,goodsCalculateList,coupon.getApplyType()); |
| | | //Constants.equalsInteger(coupon.getApplyType(),Constants.ONE)?Constants.ONE:Constants.ZERO); |
| | | }else{ |
| | | isVaildUse(null,goodsCalculateList,coupon.getApplyType()); |
| | | } |
| | | //使用了优惠券的商品数量 |
| | | Integer countCouponNum = goodsCalculateList.stream().filter(i->i.getUseCoupon()).collect(Collectors.toList()).size(); |
| | |
| | | * 判断是否可以有效使用 |
| | | * @param idList |
| | | * @param goodsList |
| | | * @param vaildType 0=商品;1=品类 |
| | | * @param vaildType 0=全场;1=品类;2=指定商品 |
| | | * @return |
| | | */ |
| | | public void isVaildUse(List<String> idList,List<OrderGoodsCalculateResponse> goodsList,Integer vaildType){ |
| | | for (OrderGoodsCalculateResponse response:goodsList) { |
| | | response.setUseCoupon(idList.contains(Constants.equalsInteger(vaildType,Constants.ZERO)?response.getId().toString():response.getCategoryId().toString())?true:false); |
| | | if(Constants.equalsInteger(vaildType,Constants.ZERO)){ |
| | | for (OrderGoodsCalculateResponse response:goodsList) { |
| | | response.setUseCoupon(true); |
| | | } |
| | | }else{ |
| | | for (OrderGoodsCalculateResponse response:goodsList) { |
| | | response.setUseCoupon(idList.contains(Constants.equalsInteger(vaildType,Constants.TWO)?response.getId().toString():response.getCategoryId().toString())?true:false); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // } |
| | | // return new HashSet<>(); |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public void notifyExpiredCoupon(Integer days) { |
| | | if (days == null || days <= 0) { |
| | | days = 3; // 默认提前 3 天通知 |
| | | } |
| | | String afterDate = DateUtil.afterDateToStr(days); |
| | | // 查询即将过期的优惠券(未使用且在目标日期范围内过期) |
| | | List<MemberCoupon> expiredCoupons = memberCouponMapper.selectList( |
| | | new QueryWrapper<MemberCoupon>().lambda() |
| | | .eq(MemberCoupon::getIsdeleted, Constants.ZERO) |
| | | .eq(MemberCoupon::getStatus, Constants.ZERO) // 未使用 |
| | | .eq(MemberCoupon::getNoticeStatus,Constants.ZERO)// 未通知数据 |
| | | .ge(MemberCoupon::getEndDate, DateUtil.getCurrDateTime()) // 大于等于开始时间 |
| | | .lt(MemberCoupon::getEndDate, (afterDate+" 23:59:59") ) // 小于结束时间 |
| | | ); |
| | | if (CollectionUtils.isEmpty(expiredCoupons)) { |
| | | return; |
| | | } |
| | | // 按用户分组统计 |
| | | Map<Integer, List<MemberCoupon>> memberCouponMap = expiredCoupons.stream() |
| | | .collect(Collectors.groupingBy(MemberCoupon::getMemberId)); |
| | | |
| | | // 遍历每个用户的优惠券发送通知 |
| | | for (Map.Entry<Integer, List<MemberCoupon>> entry : memberCouponMap.entrySet()) { |
| | | Integer memberId = entry.getKey(); |
| | | List<MemberCoupon> coupons = entry.getValue(); |
| | | if (CollectionUtils.isEmpty(coupons)) { |
| | | continue; |
| | | } |
| | | // 查询用户信息 |
| | | Member member = memberMapper.selectById(memberId); |
| | | if (member == null || member.getIsdeleted() == Constants.ONE) { |
| | | continue; |
| | | } |
| | | // 统计优惠券数量和类型 |
| | | long count = coupons.size(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | List<Integer> couponIds = coupons.stream().map(MemberCoupon::getId).collect(Collectors.toList()); |
| | | //发送站内信 优惠券即将过期 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.EXPIRE_COUPON, |
| | | member.getId(), |
| | | null |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",Long.toString(count)).replace("{param1}",afterDate)); |
| | | noticeMapper.insert(notice); |
| | | memberCouponMapper.update(new UpdateWrapper<MemberCoupon>().lambda() |
| | | .set(MemberCoupon::getNoticeStatus,Constants.ONE) |
| | | .set(MemberCoupon::getNoticeTime,DateUtil.getCurrDateTime()) |
| | | .in(MemberCoupon::getId,couponIds) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.checkerframework.checker.units.qual.N; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | |
| | | private ShopMapper shopMapper; |
| | | @Autowired |
| | | private UserActionMapper userActionMapper; |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | if(!this.checkIsCreateInvite(phone)){ |
| | | member.setRecId(wxPhoneRequest.getRecId()); |
| | | } |
| | | member.setIntegral(BigDecimal.ZERO); |
| | | member.setPhone(phone); |
| | | member.setStatus(Constants.ZERO); |
| | | } |
| | |
| | | dealIntegralRequest.setDealType(Constants.ZERO); |
| | | dealIntegralRequest.setMemberId(member.getId()); |
| | | dealIntegralRequest.setIntegralObjType(Constants.IntegralObjType.REGISTER); |
| | | integralService.dealIntegral(dealIntegralRequest,null); |
| | | integralService.dealIntegral(dealIntegralRequest,member); |
| | | } |
| | | //开启注册送优惠券 |
| | | if(Constants.equalsInteger(platformConfigDTO.getRegCouponRewardStatus(),Constants.ZERO)){ |
| | |
| | | } |
| | | memberCouponList.add(memberCoupon); |
| | | } |
| | | Notice notice = Notice.getNotice(Constants.NoticeType.COUPON, |
| | | member.getId(),null); |
| | | notice.setContent(notice.getContent().replace("{param}",Constants.getCouponInfo(memberCoupon,num))); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberCouponList)){ |
| | | memberCouponJoinMapper.insert(memberCouponList); |
| | |
| | | dealIntegralRequest.setMemberId(member.getRecId()); |
| | | dealIntegralRequest.setIntegralObjType(Constants.IntegralObjType.INVITENEWUSER); |
| | | dealIntegralRequest.setParam1(member.getNickname()); |
| | | integralService.dealIntegral(dealIntegralRequest,null); |
| | | integralService.dealIntegral(dealIntegralRequest,member); |
| | | //添加消息记录 |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | Notice notice = pageWrap.getModel(); |
| | | |
| | | queryWrapper.ne(Objects.nonNull(notice.getQueryType())&&Constants.equalsInteger(notice.getQueryType(),Constants.ZERO), |
| | | Notice::getObjType,Constants.TWO) |
| | | .eq(Objects.nonNull(notice.getQueryType())&&Constants.equalsInteger(notice.getQueryType(),Constants.ONE), |
| | | Notice::getObjType,Constants.TWO) |
| | | queryWrapper.ne(Objects.nonNull(notice.getQueryType()), |
| | | Notice::getType,notice.getQueryType()) |
| | | .eq(Notice::getMemberId,notice.getMemberId()) |
| | | .orderByAsc(Notice::getStatus) |
| | | .orderByDesc(Notice::getId) |
| | |
| | | |
| | | /** |
| | | * |
| | | * @param type 0消费者;1=经销商; |
| | | * @param objType 0商城订单 1积分流水 2互动评价 3优惠券 |
| | | * @param type 消息类型 0=系统消息;1=社区消息 |
| | | * @param objType 0商城订单 1积分流水 2过期提醒 3社区消息 |
| | | * |
| | | */ |
| | | |
| | | public void saveNoticeInfo(Integer type,Integer objType,Integer memberId |
| | | ,String title,String content,Integer objId){ |
| | | Notice notice = new Notice(); |
| | |
| | | BigDecimal integral, |
| | | Integer objId,String info){ |
| | | String title = integralObjType.getName(); |
| | | |
| | | this.saveNoticeInfo( |
| | | type, |
| | | Constants.ONE, |
| | |
| | | MemberCoupon mc = c.getMemberCoupon(); |
| | | String info = Constants.equalsInteger(mc.getCouponType(),Constants.ZERO)? |
| | | "满"+mc.getLimitPrice()+"元减"+mc.getPrice()+"元抵扣券*"+c.getNum(): |
| | | "满"+mc.getLimitPrice()+"元享"+mc.getPrice()+"折券"; |
| | | "满"+mc.getLimitPrice()+"元享"+mc.getPrice()+"折券*"+c.getNum(); |
| | | replaceInfo = replaceInfo + (StringUtils.isBlank(replaceInfo)? |
| | | info:","+info); |
| | | } |
| | | noticeInfo.replace("${param}",replaceInfo); |
| | | |
| | | this.saveNoticeInfo( |
| | | Constants.ZERO, |
| | | Constants.ONE, |
| | | Constants.ONE, |
| | | memberId, |
| | | "获得系统发放的优惠券", |
| | |
| | | String noticeInfo = "${param}回复了您的评论"; |
| | | noticeInfo.replace("${param}",memberName); |
| | | this.saveNoticeInfo( |
| | | Constants.ZERO, |
| | | Constants.TWO, |
| | | Constants.ONE, |
| | | Constants.THREE, |
| | | memberId, |
| | | noticeInfo, |
| | | noticeInfo, |
| | |
| | | shop.setIsrec(Constants.ONE); |
| | | shop.setOrigin(Constants.ONE); |
| | | shop.setSaleType(Constants.formatIntegerNum(shop.getSaleType())); |
| | | shop.setAmount(BigDecimal.ZERO); |
| | | shop.setTotalAmount(BigDecimal.ZERO); |
| | | String salt = RandomStringUtils.randomAlphabetic(6); |
| | | |
| | | shop.setPassword(shop.getCode()+"@123456"); |
| | |
| | | if(Objects.isNull(goodsSku)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品SKU信息"); |
| | | } |
| | | Goods goods = goodsMapper.selectById(goodsSku.getGoodsId()); |
| | | if(Objects.isNull(goods)||!Constants.equalsInteger(goods.getStatus(),Constants.ZERO)||!Constants.equalsInteger(goods.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,商品已下架,无法加入购物车!"); |
| | | } |
| | | if(!Objects.isNull(shopcart)){ |
| | | shopcart.setNum(shopcart.getNum() + addCartGoodsRequest.getNum()); |
| | | shopcart.setEditDate(new Date()); |
| | |
| | | return ApiResponse.success("操作成功"); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.model.Goods; |
| | | import com.doumee.dao.business.model.SearchHistory; |
| | | import com.doumee.dao.web.request.goods.GoodsRequest; |
| | | import com.doumee.dao.web.response.goods.GoodsInfoResponse; |
| | |
| | | |
| | | @ApiOperation("商品列表") |
| | | @PostMapping("/goodsPage") |
| | | public ApiResponse<IPage<GoodsInfoResponse>> goodsPage(@RequestBody PageWrap<GoodsRequest> pageWrap) { |
| | | IPage<GoodsInfoResponse> page = goodsService.getGoodsPage(pageWrap); |
| | | public ApiResponse<IPage<Goods>> goodsPage(@RequestBody PageWrap<GoodsRequest> pageWrap) { |
| | | IPage<Goods> page = goodsService.getGoodsPage(pageWrap); |
| | | return ApiResponse.success("查询成功",page); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "goodsId", value = "商品主键", required = true), |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "memberId", value = "用户主键", required = true), |
| | | }) |
| | | public ApiResponse<GoodsInfoResponse> goodsInfo(@RequestParam Integer goodsId,Integer memberId) { |
| | | GoodsInfoResponse goodsInfoResponse = goodsService.getGoodsInfo(goodsId,memberId); |
| | | public ApiResponse<Goods> goodsInfo(@RequestParam Integer goodsId,Integer memberId) { |
| | | Goods goodsInfoResponse = goodsService.getGoodsInfo(goodsId,memberId); |
| | | return ApiResponse.success("查询成功",goodsInfoResponse); |
| | | } |
| | | |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | |
| | | @RequestMapping("/web/orders") |
| | | @Slf4j |
| | | public class OrderApi extends ApiController { |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | @LoginRequired |
| | | @ApiOperation("咖啡计划已订阅列表") |
| | | @PostMapping("/planOrdersPage") |
| | |
| | | }) |
| | | public ApiResponse<PayResponse> orderPay(@Valid @RequestBody ShopOrderPayRequest request) { |
| | | request.setMemberId(getMemberId()); |
| | | return ApiResponse.success("操作成功", goodsorderService.orderPay(request, memberCouponServiceImpl)); |
| | | PayResponse payResponse = goodsorderService.orderPay(request, memberCouponServiceImpl); |
| | | if(Objects.nonNull(payResponse)&&StringUtils.isNotBlank(payResponse.getLockKey())){ |
| | | redisTemplate.delete(payResponse.getLockKey()); |
| | | } |
| | | return ApiResponse.success("操作成功", payResponse); |
| | | } |
| | | |
| | | @LoginRequired |