From 3529acb10a8a5b6803fe34dd29919763a577f1e1 Mon Sep 17 00:00:00 2001 From: masterspirit Date: Sat, 25 Aug 2018 14:52:22 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=AF=E5=88=86][=E4=BF=AE=E6=94=B9]?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=8E=B7=E5=BE=97=E7=A7=AF=E5=88=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E6=94=AF=E4=BB=98=E8=8E=B7=E5=BE=97=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/service/WxScoreRulesService.java | 14 ++++-- .../service/impl/WxScoreRulesServiceImpl.java | 50 ++++++++++++++----- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/mallinkService/src/main/java/com/simple/service/WxScoreRulesService.java b/mallinkService/src/main/java/com/simple/service/WxScoreRulesService.java index 66251b8b2..efc495e9b 100644 --- a/mallinkService/src/main/java/com/simple/service/WxScoreRulesService.java +++ b/mallinkService/src/main/java/com/simple/service/WxScoreRulesService.java @@ -38,13 +38,21 @@ public interface WxScoreRulesService { */ void deleteById(Long id); /** - * 登录或消费 调用增长积分 + * 登录 调用增长积分 * @param tenantId - * @param type 1:登录 2:消费 * @param cUserId * @return 新增的积分值 */ - int addScoreByType(String tenantId,int type,Long cUserId); + int loginAddScore(String tenantId,Long cUserId); + + /** + * + * @param tenantId + * @param cUserId + * @param payPrice 实际支付金额(分) + * @return + */ + int payAddScore(String tenantId,Long cUserId,int payPrice); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxScoreRulesServiceImpl.java index c5e12301c..1549e447b 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxScoreRulesServiceImpl.java @@ -52,32 +52,58 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { wxScoreRulesMapper.deleteByPrimaryKey(id); } + @Override - public int addScoreByType(String tenantId, int type, Long cUserId) { - int addScoreNumber=0; + public int loginAddScore(String tenantId, Long cUserId) { + int addScoreNumber = 0; WxScoreRules scoreRules = new WxScoreRules(); scoreRules.setTenantId(tenantId); List list = wxScoreRulesMapper.findList(scoreRules); - if(list.isEmpty()){ + if (list.isEmpty()) { return addScoreNumber; } scoreRules = list.get(0); + addScoreNumber = scoreRules.getLoginScoreNumber(); + WxCUser wxCUser = wxCUserService.getById(cUserId); + wxCUser.setScore(wxCUser.getScore() + addScoreNumber); + wxCUserService.saveOrUpdate(wxCUser); + + //修改basic表积分 + if (wxCUser.getPhone() != null) { + //修改basic表积分 + WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); + wxCUserBasicInfo.setTenantId(tenantId); + wxCUserBasicInfo.setPhone(wxCUser.getPhone()); + wxCUserBasicInfo.setPoins(wxCUser.getScore()); + wxCUserBasicInfo.setCUserId(wxCUser.getId()); + wxCUserBasicInfoService.updateScore(wxCUserBasicInfo); + } + return addScoreNumber; + } - if(type==1){ - //login处理 - addScoreNumber = scoreRules.getLoginScoreNumber(); + @Override + public int payAddScore(String tenantId, Long cUserId,int payPrice) { + if(payPrice==0){ + return 0; } - if(type==2){ - //消费 - addScoreNumber = scoreRules.getConsumptionScoreNumber(); + int addScoreNumber = 0; + WxScoreRules scoreRules = new WxScoreRules(); + scoreRules.setTenantId(tenantId); + List list = wxScoreRulesMapper.findList(scoreRules); + if (list.isEmpty()) { + return 0; } + scoreRules = list.get(0); + int priceCondition = scoreRules.getConsumptionAmount(); + int baseScore = scoreRules.getConsumptionScoreNumber();//消费增长积分 + + addScoreNumber = (payPrice/priceCondition)*baseScore; WxCUser wxCUser = wxCUserService.getById(cUserId); - wxCUser.setScore(wxCUser.getScore()+addScoreNumber); + wxCUser.setScore(wxCUser.getScore() + addScoreNumber); wxCUserService.saveOrUpdate(wxCUser); - //修改basic表积分 - if(wxCUser.getPhone()!=null){ + if (wxCUser.getPhone() != null) { //修改basic表积分 WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); wxCUserBasicInfo.setTenantId(tenantId);