Browse Source

[积分开关][修改][添加积分开关业务逻辑]

release_toaliyun_real
gongbiao 6 years ago
parent
commit
ee16540b88
12 changed files with 113 additions and 9 deletions
  1. +22
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java
  2. +1
    -0
      mallinkAdmin/src/main/resources/db/migration/V201909231350__G_ALTER_MERCHANT.sql
  3. +1
    -0
      mallinkAdmin/src/main/resources/db/migration/V201909231430__G_ALTER_CREDIT_RULES.sql
  4. +1
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java
  5. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java
  6. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java
  7. +36
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumCreditLockedStatus.java
  8. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxMerchantMapper.java
  9. +2
    -0
      mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java
  10. +26
    -7
      mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java
  11. +9
    -1
      mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
  12. +7
    -1
      mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml

+ 22
- 0
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java View File

@@ -1,6 +1,7 @@
package com.iformall.controller.mem;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxScoreRules;
@@ -48,4 +49,25 @@ public class WxScoreRulesController extends BaseController {
WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantId());
return new ResultData(scoreRules);
}

@ApiOperation("更新积分开关状态")
@PostMapping("updateCreditLocked")
@SystemControllerLog(description = "更新积分开关状态")
public ResultData 更新积分开关状态(@RequestBody WxScoreRules wxScoreRules) {
logger.debug("[" + getIpAddr() + "] WxScoreRulesController::updateCreditLocked");
if (null == wxScoreRules.getId()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空");
}
if (null == wxScoreRules.getCreditLocked()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空");
}
wxScoreRules.setTenantId(getTenantId());
try {
wxScoreRulesService.updateCreditLocked(wxScoreRules);
} catch (Exception e) {
return new ResultData(ErrorCode.DB_FAIL.getCode(), "更新积分开关状态失败");
}
return new ResultData();
}

}

+ 1
- 0
mallinkAdmin/src/main/resources/db/migration/V201909231350__G_ALTER_MERCHANT.sql View File

@@ -0,0 +1 @@
alter table wx_merchant add column credit_locked tinyint(1) default 0 not null comment '0开放1锁定';

+ 1
- 0
mallinkAdmin/src/main/resources/db/migration/V201909231430__G_ALTER_CREDIT_RULES.sql View File

@@ -0,0 +1 @@
alter table wx_score_rules add column credit_locked tinyint(1) default 0 not null comment '0开放1锁定';

+ 1
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java View File

@@ -81,6 +81,7 @@ public class WxMerchantBUserController extends BaseController {
resultMap.put("tenant_id",merchant.getTenantId());
resultMap.put("merchant_id",merchant.getId());
resultMap.put("is_admin",merchant.getIsAdmin());
resultMap.put("creditLocked", merchant.getCreditLocked());
String mid = null;
try {
mid = String.valueOf(merchant.getId());


+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java View File

@@ -233,4 +233,7 @@ public class WxMerchant extends BaseEntity {
return "t:md:" + id;
}

@io.swagger.annotations.ApiModelProperty(value = "积分锁定0正常1锁定", name = "creditLocked")
private Integer creditLocked;

}

+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java View File

@@ -110,6 +110,9 @@ public class WxScoreRules extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="生日积分倍率",name="scale")
private Integer scale;

@io.swagger.annotations.ApiModelProperty(value = "积分锁定0正常1锁定", name = "creditLocked")
private Integer creditLocked;

public static String getScoreDefaultRules() {
return scoreDefaultRules;
}


+ 36
- 0
mallinkService/src/main/java/com/iformall/enums/EnumCreditLockedStatus.java View File

@@ -0,0 +1,36 @@
package com.iformall.enums;


/**
* @author gongbiao
*/
public enum EnumCreditLockedStatus {

OPEN(0, "正常"),
CLOSE(1, "锁定"),;

public static EnumCreditLockedStatus getEnum(Integer code) {
for (EnumCreditLockedStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumCreditLockedStatus(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxMerchantMapper.java View File

@@ -25,4 +25,6 @@ public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> {

List<WxMerchant> findListVo(WxMerchant record);

void updateCreditLocked(WxMerchant wxMerchant);

}

+ 2
- 0
mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java View File

@@ -52,4 +52,6 @@ public interface WxScoreRulesService {

List<WxScoreRules> findList(WxScoreRules wxScoreRules);

void updateCreditLocked(WxScoreRules wxScoreRules);

}

+ 26
- 7
mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java View File

@@ -9,10 +9,7 @@ import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumScoreRules;
import com.iformall.enums.EnumScoreType;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxCUserBasicInfoMapper;
import com.iformall.mapper.WxCUserMapper;
import com.iformall.mapper.WxScoreHistoryMapper;
import com.iformall.mapper.WxScoreRulesMapper;
import com.iformall.mapper.*;
import com.iformall.service.WxCUserService;
import com.iformall.service.WxScoreRulesService;
import com.iformall.utils.Constant;
@@ -45,6 +42,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
@Qualifier("scoreRuleRedisTemplate")
RedisTemplate<String, WxScoreRules> scoreRulesRedisTemplate;

@Autowired
WxMerchantMapper wxMerchantMapper;

@Override
public WxScoreRules getScoreRules(String tenantId) {
// get pushLime from cache
@@ -159,16 +159,18 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {

@Override
public void saveOrUpdate(WxScoreRules record) {
Date date = new Date();
record.setUpdateDate(date);
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateDate(date);
wxScoreRulesMapper.insert(record);
} else {
wxScoreRulesMapper.updateById(record);
}

if (record != null && record.getType() == EnumScoreRules.SCORE.getCode()) {
if (record != null && record.getType().equals(EnumScoreRules.SCORE.getCode())) {
// 缓存存在,删除缓存
String key = Constant.SCORE_RULES_KEY_PREV + record.getTenantId();
boolean hasKey = scoreRulesRedisTemplate.hasKey(key);
@@ -177,7 +179,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除成长值设置 >> " + record.toString());
}
}
if (record != null && record.getType() == EnumScoreRules.CREDIT.getCode()) {
if (record != null && record.getType().equals(EnumScoreRules.CREDIT.getCode())) {
// 缓存存在,删除缓存
String key = Constant.CREDIT_RULES_KEY_PREV + record.getTenantId();
boolean hasKey = scoreRulesRedisTemplate.hasKey(key);
@@ -186,6 +188,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除积分设置 >> " + record.toString());
}
}

//更新商户数据
updateMerchantCreditLocked(record);
}

@Override
@@ -618,4 +623,18 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
public List<WxScoreRules> findList(WxScoreRules wxScoreRules) {
return wxScoreRulesMapper.findList(wxScoreRules);
}

@Override
public void updateCreditLocked(WxScoreRules wxScoreRules) {
wxScoreRulesMapper.updateById(wxScoreRules);
updateMerchantCreditLocked(wxScoreRules);
}

public void updateMerchantCreditLocked(WxScoreRules wxScoreRules) {
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.setTenantId(wxScoreRules.getTenantId());
wxMerchant.setStatus(wxScoreRules.getCreditLocked());
wxMerchant.setUpdateDate(new Date());
wxMerchantMapper.updateCreditLocked(wxMerchant);
}
}

+ 9
- 1
mallinkService/src/main/resources/mapper/WxMerchantMapper.xml View File

@@ -33,13 +33,14 @@
<result column="link_line_phone" property="linkLinePhone"/>
<result column="rental_start_date" property="rentalStartDate"/>
<result column="rental_end_date" property="rentalEndDate"/>
<result column="credit_locked" property="creditLocked"/>

</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`,
`business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`,
`introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone
`introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone,credit_locked
</sql>
<sql id="allColumnsVo">
@@ -118,6 +119,9 @@
<if test=" null != brand ">
and `brand` = #{brand}
</if>
<if test=" null != creditLocked ">
and `credit_locked` = #{creditLocked}
</if>
<if test=" null != rentShopType ">
and id not in(
select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
@@ -414,5 +418,9 @@
and `id` != #{id}
</if>
</select>
<update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant">
update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId}
</update>

</mapper>

+ 7
- 1
mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml View File

@@ -10,10 +10,12 @@
<result column="type" jdbcType="INTEGER" property="type"/>
<result column="clear_year" jdbcType="INTEGER" property="clearYear"/>
<result column="scale" jdbcType="INTEGER" property="scale"/>
<result column="credit_locked" jdbcType="INTEGER" property="creditLocked"/>

</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale`
`id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale`,credit_locked
</sql>

<sql id="dynamicWhereConditions">
@@ -42,6 +44,10 @@
<if test=" null != scale ">
and `scale` = #{scale}
</if>
<if test=" null != creditLocked ">
and `credit_locked` = #{creditLocked}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Loading…
Cancel
Save