From 9a91f3566103dec58f01cad8b9a82b824323125b Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Tue, 06 Apr 2021 20:55:54 +0800 Subject: [PATCH] 预约奖励积分,评价奖励积分 --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java | 22 +++- zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java | 31 +++++- zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProductComment.java | 11 +- zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java | 83 ++++++++++++---- zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java | 6 + zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java | 84 ++++++++-------- 7 files changed, 159 insertions(+), 82 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java index d9285cb..01db2dd 100644 --- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java +++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiServiceOrderAction.java @@ -150,9 +150,7 @@ throw new GlobleException("请选择服务"); } SysVipInfo vipInfo = sysVipInfoService.findById(serviceOrderDto.getVipId()); -// if (StringUtils.isBlank(vipInfo.getPassWord())) { -// return AjaxResult.buildFailInstance("未设置资金密码"); -// } + if (StringUtils.isNotBlank(vipInfo.getPassWord())) { if (!vipInfo.getPassWord().equals(serviceOrderDto.getPassword())) { diff --git a/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java b/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java index 947e243..50d7870 100644 --- a/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java +++ b/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java @@ -33,6 +33,12 @@ */ public static final int SCORE_VIP_TYPE_REFERRER=3; /** + * 获取类型(4参加活动) + */ + public static final int SCORE_VIP_TYPE_JOIN_ACTIVE=4; + + + /** * 获取类型(4人工调整) */ public static final int SCORE_VIP_TYPE_USERCHANGE=4; diff --git a/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java b/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java index 24c9221..7c27a80 100644 --- a/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java +++ b/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java @@ -183,57 +183,59 @@ * 根据固定等级规则新增用户积分 */ @Transactional(rollbackFor = Exception.class) - public void addScoreByParamSetting(Long vipId, Long oprationUserId, Long shopId, Integer firstScore, Long businessId, int type, String remark, BusParameterSettings parameterSetting) { + public void addScoreByParamSetting(Long vipId, Long oprationUserId, Long shopId, Long businessId, int type, String remark, BusParameterSettings parameterSetting) { - - SysVipInfo vipInfo = sysVipInfoDao.selectById(vipId); - - - //添加自己的积分 - if (firstScore > 0) { - addScore( - vipInfo.getId(), - oprationUserId, - shopId, - firstScore, - businessId, - type, - remark - ); - } - - if (StringUtils.isNotBlank(parameterSetting.getParamValue()) - && vipInfo.getRecommendId() != null) { - //推荐注册老带新积分奖励 - SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); - Integer secondScore = new Integer(parameterSetting.getParamValue()); - if (secondScore > 0) { - addScore( - referrerVip.getId(), - oprationUserId, - shopId, - secondScore, - businessId, - type, - remark - ); - } - //推荐注册二级带新积分奖励 - if (StringUtils.isNotBlank(parameterSetting.getParamValue1()) - && referrerVip.getRecommendId() != null) { - Integer threeScore = new Integer(parameterSetting.getParamValue()); - if (threeScore > 0) { + if (parameterSetting != null) { + SysVipInfo vipInfo = sysVipInfoDao.selectById(vipId); + //添加自己的积分 + if (StringUtils.isNotBlank(parameterSetting.getParamValue())) { + Integer firstScore = new Integer(parameterSetting.getParamValue()); + if (firstScore > 0) { addScore( - referrerVip.getRecommendId(), + vipInfo.getId(), oprationUserId, shopId, - threeScore, + firstScore, businessId, type, remark ); } } + + if (StringUtils.isNotBlank(parameterSetting.getParamValue1()) + && vipInfo.getRecommendId() != null) { + //推荐注册老带新积分奖励 + SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); + Integer secondScore = new Integer(parameterSetting.getParamValue1()); + if (secondScore > 0) { + addScore( + referrerVip.getId(), + oprationUserId, + shopId, + secondScore, + businessId, + type, + remark + ); + } + //推荐注册二级带新积分奖励 + if (StringUtils.isNotBlank(parameterSetting.getParamValue2()) + && referrerVip.getRecommendId() != null) { + Integer threeScore = new Integer(parameterSetting.getParamValue2()); + if (threeScore > 0) { + addScore( + referrerVip.getRecommendId(), + oprationUserId, + shopId, + threeScore, + businessId, + type, + remark + ); + } + } + } } } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java index 7b87e5f..456b0e2 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java @@ -1,10 +1,13 @@ package com.matrix.system.shopXcx.api.action; -import com.matrix.core.pojo.AjaxResult; -import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.component.redis.RedisUserLoginUtils; +import com.matrix.core.pojo.AjaxResult; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; - +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.hive.bean.SysVipInfo; +import com.matrix.system.score.constant.ScoreSettingConstant; +import com.matrix.system.score.entity.ScoreVipDetail; import com.matrix.system.score.service.ScoreVipDetailService; import com.matrix.system.shopXcx.bean.ShopOrder; import com.matrix.system.shopXcx.bean.ShopProductComment; @@ -35,6 +38,11 @@ @Autowired private ShopOrderDao shopOrderDao; + @Autowired + ScoreVipDetailService scoreVipDetailService; + + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; /** * 根据ID逻辑删除产品评价 * @param @@ -52,9 +60,6 @@ } return new AjaxResult(AjaxResult.STATUS_SUCCESS, "删除成功"); } - - @Autowired - ScoreVipDetailService scoreVipDetailService; /** * 接收保存产品评价数据 @@ -86,7 +91,10 @@ modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_ALREADY_REMARK); shopOrderDao.updateByMap(modifyMap); - //scoreVipDetailService.addScoreByParamSetting(loginUser.getId(),null,); + //添加用户积分 + BusParameterSettings parameterSetting = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.EVALUATUIN_ORDER_SHOP_NAME, loginUser.getCompanyId()); + scoreVipDetailService.addScoreByParamSetting(loginUser.getId(), null,null, commentList.get(0).getComId(), + ScoreVipDetail.SCORE_VIP_TYPE_JOIN_ACTIVE,"评价送积分", parameterSetting); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java index ec10347..9aefc8a 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java @@ -1,7 +1,5 @@ package com.matrix.system.shopXcx.api.action; -import com.matrix.system.hive.bean.SysVipInfo; -import com.matrix.system.hive.dao.SysVipInfoDao; import com.matrix.component.rabbitmq.RabiitMqTemplate; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.exception.GlobleException; @@ -10,8 +8,12 @@ import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.app.mapper.SysProjUseMapper; -import com.matrix.system.app.vo.*; +import com.matrix.system.app.vo.ServiceProductListVo; +import com.matrix.system.app.vo.ServiceProjVo; +import com.matrix.system.app.vo.ServiceTcVo; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysUsers; +import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.common.tools.LocationUtil; @@ -20,6 +22,9 @@ import com.matrix.system.hive.dao.*; import com.matrix.system.hive.plugin.util.CollectionUtils; import com.matrix.system.hive.service.*; +import com.matrix.system.score.constant.ScoreSettingConstant; +import com.matrix.system.score.entity.ScoreVipDetail; +import com.matrix.system.score.service.ScoreVipDetailService; import com.matrix.system.shopXcx.api.dto.ErpServiceCommentDto; import com.matrix.system.shopXcx.api.dto.ErpServiceOrderListDto; import com.matrix.system.shopXcx.api.vo.ErpServiceOrderListVo; @@ -27,7 +32,9 @@ import com.matrix.system.shopXcx.dao.ShopSkuDao; import com.matrix.system.shopXcx.dto.YYDayOfWeek; import com.matrix.system.shopXcx.dto.YYmonth; -import io.swagger.annotations.*; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -36,7 +43,9 @@ import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** * @author jiangyouyao @@ -91,6 +100,11 @@ @Autowired ShoppingGoodsDao shoppingGoodsDao; + @Autowired + ScoreVipDetailService scoreVipDetailService; + + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; @Value("${evn}") private String evn; @@ -303,6 +317,13 @@ sysProjServices.setState(Dictionary.SERVICE_STATU_DQR); SysProjServices newSysProjServices = projServicesService.addSysProjServices(sysProjServices); if (newSysProjServices != null) { + + //添加用户积分 + BusParameterSettings parameterSetting = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.RESERVATION_SERVICE_SHOP, sysVipInfo.getCompanyId()); + scoreVipDetailService.addScoreByParamSetting(sysVipInfo.getId(), null,null, newSysProjServices.getId(), + ScoreVipDetail.SCORE_VIP_TYPE_JOIN_ACTIVE,"预约送积分", parameterSetting); + + return AjaxResult.buildSuccessInstance("下单成功"); } else { return new AjaxResult(AjaxResult.STATUS_FAIL, "下单失败!"); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProductComment.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProductComment.java index 9c9557d..77e678d 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProductComment.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProductComment.java @@ -20,7 +20,7 @@ /** * 主键 */ - private Integer comId; + private Long comId; /** @@ -182,14 +182,13 @@ auditStatus = auditStatus; } - public Integer getComId() { + public Long getComId() { return comId; } - - public void setComId(Integer comId) { - this.comId=comId; + + public void setComId(Long comId) { + this.comId = comId; } - public String getUserId() { return userId; diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java index 3b7c40e..0ad9e03 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/ScoreOrderTask.java @@ -1,11 +1,13 @@ package com.matrix.system.shopXcx.mqTask; -import com.matrix.system.hive.service.SysVipInfoService; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.hive.bean.SysVipInfo; +import com.matrix.system.hive.dao.SysVipInfoDao; +import com.matrix.system.hive.service.SysVipInfoService; import com.matrix.system.score.constant.ScoreSettingConstant; import com.matrix.system.score.entity.ScoreVipDetail; import com.matrix.system.score.service.ScoreVipDetailService; @@ -38,14 +40,14 @@ SysVipInfoService sysVipInfoService; - @Autowired ScoreVipDetailService scoreVipDetailService; @Autowired BusParameterSettingsDao busParameterSettingsDao; - + @Autowired + SysVipInfoDao sysVipInfoDao; @Override public void handle(String consumerTag, Delivery message) throws IOException { @@ -58,37 +60,78 @@ List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId)); order.setDetails(orderDetails); //扣除积分 - if(order.getScorePay()!=null&&order.getScorePay()>0){ - scoreVipDetailService.deductionScore(order.getUserId(),null, - Long.parseLong(order.getStoreId()+""),order.getScorePay(), - Long.parseLong(order.getId()+""), ScoreVipDetail.SCORE_VIP_TYPE_CASH,"商城积分抵扣"); - }else{ + if (order.getScorePay() != null && order.getScorePay() > 0) { + scoreVipDetailService.deductionScore(order.getUserId(), null, + Long.parseLong(order.getStoreId() + ""), order.getScorePay(), + Long.parseLong(order.getId() + ""), ScoreVipDetail.SCORE_VIP_TYPE_CASH, "商城积分抵扣"); + } else { //消费获得积分 - int addScore=0; + int addScore = 0; BusParameterSettings cashConsumptionShop = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.CASH_CONSUMPTION_SHOP, order.getCompanyId()); - for(ShopOrderDetails shopOrderDetail : orderDetails) { - if(shopOrderDetail.getPayType()==ShopOrderDetails.PAYTYPE_MICRO){ - Integer xfkdScore= shopOrderDetail.getShopSku().getScore(); - if(xfkdScore!=null && xfkdScore>0){ - addScore+=xfkdScore; - }else{ - if(StringUtils.isNotBlank(cashConsumptionShop.getParamValue())){ - addScore+= shopOrderDetail.getTotalPrice().divide(new BigDecimal(cashConsumptionShop.getParamValue())).intValue(); + for (ShopOrderDetails shopOrderDetail : orderDetails) { + if (shopOrderDetail.getPayType() == ShopOrderDetails.PAYTYPE_MICRO) { + Integer xfkdScore = shopOrderDetail.getShopSku().getScore(); + if (xfkdScore != null && xfkdScore > 0) { + addScore += xfkdScore; + } else { + if (StringUtils.isNotBlank(cashConsumptionShop.getParamValue())) { + addScore += shopOrderDetail.getTotalPrice().divide(new BigDecimal(cashConsumptionShop.getParamValue())).intValue(); } } } } - if(addScore>0){ + if (addScore > 0) { //插入新的积分 scoreVipDetailService.addScore( order.getUserId(), null, - Long.parseLong(order.getStoreId()+""), + Long.parseLong(order.getStoreId() + ""), addScore, - Long.parseLong(orderId+""), + Long.parseLong(orderId + ""), ScoreVipDetail.SCORE_VIP_TYPE_CASH, "微商城消费"); + + //插入上级积分 + SysVipInfo vipInfo = sysVipInfoService.findById(order.getUserId()); + + + if (vipInfo.getRecommendId() != null) { + //推荐注册老带新积分奖励 + SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); + if (StringUtils.isNotBlank(cashConsumptionShop.getParamValue1())) { + + int parentScore = order.getOrderMoney().divide(new BigDecimal(cashConsumptionShop.getParamValue1())).intValue(); + if (parentScore > 0) { + scoreVipDetailService.addScore( + referrerVip.getId(), + null, + Long.parseLong(order.getStoreId() + ""), + parentScore, + Long.parseLong(order.getId() + ""), + ScoreVipDetail.SCORE_VIP_TYPE_CASH, + "推荐消费奖励" + ); + } + } + + //推荐注册二级带新积分奖励 + if (referrerVip.getRecommendId() != null && StringUtils.isNotBlank(cashConsumptionShop.getParamValue2())) { + SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId()); + int topParentScore = order.getOrderMoney().divide(new BigDecimal(cashConsumptionShop.getParamValue2())).intValue(); + if (topParentScore > 0) { + scoreVipDetailService.addScore( + topVipInfo.getId(), + null, + Long.parseLong(order.getStoreId() + ""), + topParentScore, + Long.parseLong(order.getId() + ""), + ScoreVipDetail.SCORE_VIP_TYPE_CASH, + "推荐消费奖励" + ); + } + } + } } } -- Gitblit v1.9.1