From 09331a4bbb59fe45931a3ec86e6af2e377af44a7 Mon Sep 17 00:00:00 2001 From: hanxueda Date: Thu, 18 Apr 2019 17:06:25 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=AF=E5=88=86][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E8=8A=B1=E8=B4=B9=E9=87=91=E9=A2=9D=E5=A2=9E=E5=8A=A0str?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=20=E5=AF=BC=E5=87=BA=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCreditHistoryController.java | 4 ++-- .../controller/WxCreditHistoryController.java | 4 ++-- .../com/iformall/domain/po/WxCreditHistory.java | 4 ++++ .../iformall/service/WxCreditHistoryService.java | 2 +- .../service/impl/WxCreditHistoryServiceImpl.java | 13 +++++++++---- .../resources/mapper/WxCUserBasicInfoMapper.xml | 4 ++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCreditHistoryController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCreditHistoryController.java index 5726b0782..fbd1509aa 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCreditHistoryController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCreditHistoryController.java @@ -40,9 +40,9 @@ public class WxCreditHistoryController extends BaseController @ApiImplicitParams({ @ApiImplicitParam(name="merchantId",value="商户ID",dataType="long", paramType = "query",required=true), @ApiImplicitParam(name="spend",value="消费金额",dataType="int", paramType = "query",required=true)}) - public ResultData findByMerchantIdAndSpend(@RequestParam Long merchantId, @RequestParam Integer spend) { + public ResultData findByMerchantIdAndSpend(@RequestParam Long merchantId, @RequestParam String spendStr) { logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findByMerchantIdAndSpend"); - return new ResultData(wxCreditHistoryService.findByMerchantIdAndSpend(merchantId,spend,getTenantId())); + return new ResultData(wxCreditHistoryService.findByMerchantIdAndSpend(merchantId,spendStr,getTenantId())); } @ApiOperation("新增接口") diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java index 41dc0ef2e..6bdb40acf 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java @@ -35,9 +35,9 @@ public class WxCreditHistoryController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name="merchantId",value="商户ID",dataType="long", paramType = "query",required=true), @ApiImplicitParam(name="spend",value="消费金额",dataType="int", paramType = "query",required=true)}) - public ResultData findByMerchantIdAndSpend(@RequestParam Long merchantId, @RequestParam Integer spend) { + public ResultData findByMerchantIdAndSpend(@RequestParam Long merchantId, @RequestParam String spendStr) { log.debug("[" + getIpAddr() + "] WxCreditHistoryController::findByMerchantIdAndSpend"); - return new ResultData(wxCreditHistoryService.findByMerchantIdAndSpend(merchantId,spend,getTenantId())); + return new ResultData(wxCreditHistoryService.findByMerchantIdAndSpend(merchantId,spendStr,getTenantId())); } @ApiOperation("根据手机号查询接口") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java index 4cfe84068..d1d54bf39 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java @@ -39,6 +39,10 @@ public class WxCreditHistory implements Serializable { @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") private String name; + @Transient + @io.swagger.annotations.ApiModelProperty(value="花费Str",name="spendStr") + private String spendStr; + /**租户ID*/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; diff --git a/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java b/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java index 70d897dc7..bd5ae6088 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java @@ -50,7 +50,7 @@ public interface WxCreditHistoryService { */ void deleteById(Long id); - Map findByMerchantIdAndSpend(Long merchantId, Integer spend, String tenantId); + Map findByMerchantIdAndSpend(Long merchantId, String spendStr, String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java index 5c46efa5c..3db888662 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java @@ -19,11 +19,13 @@ import com.iformall.service.WxCreditHistoryService; import com.iformall.service.WxScoreRulesService; import com.iformall.utils.RedisLock; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; @@ -147,8 +149,9 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { //验证此用户是否存在 throw new MallinkException(ErrorCode.USER_IS_EMPTY); } - //获取当前用户总积分 - //int currentCreditAmount = wxCreditHistoryMapper.creditAmount(record.getCUserId()); + if (StringUtils.isNotEmpty(record.getSpendStr())) { + record.setSpend(new BigDecimal(record.getSpendStr()).multiply(new BigDecimal(100)).intValue()); + } int currentCreditAmount = 0; //获取当前用户总积分规则:优先获取wxCUserBasicInfo中数据 若不存在 再获取wxCUser表中数据 if (wxCUserBasicInfo != null && wxCUserBasicInfo.getCredit() != null && wxCUserBasicInfo.getCredit() > 0) { @@ -197,14 +200,16 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { } @Override - public Map findByMerchantIdAndSpend(Long merchantId, Integer spend, String tenantId) { + public Map findByMerchantIdAndSpend(Long merchantId, String spendStr, String tenantId) { WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(merchantId); Map creditMap = Maps.newHashMap(); if (wxMerchant != null && wxMerchant.getBusinessId() != null) { WxCreditHistory wxCreditHistory = new WxCreditHistory(); wxCreditHistory.setBusinessId(Long.valueOf(wxMerchant.getBusinessId())); wxCreditHistory.setTenantId(tenantId); - wxCreditHistory.setSpend(spend); + if (StringUtils.isNotEmpty(spendStr)) { + wxCreditHistory.setSpend(new BigDecimal(spendStr).multiply(new BigDecimal(100)).intValue()); + } int credit = payAddCredit(wxCreditHistory); creditMap.put("credit", credit); } diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index f235b3d94..d0dab7dbe 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -245,14 +245,14 @@ - + cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`, cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`, - cut.`tags` + cut.`tags`,cu.`credit`