Просмотр исходного кода

//merchant_credit_locked

release_toaliyun_real
xhxu 3 лет назад
Родитель
Сommit
4ad81aeeb3
13 измененных файлов: 133 добавлений и 57 удалений
  1. +42
    -19
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java
  2. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/sys/SysConfigController.java
  3. +14
    -0
      mallinkAdmin/src/main/resources/db/migration/V2023033000001_upd_merchant_credit_locked.sql
  4. +2
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java
  5. +1
    -0
      mallinkService/src/main/java/com/iformall/common/SysConfigConstant.java
  6. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/SysConfig.java
  7. +0
    -3
      mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java
  8. +3
    -2
      mallinkService/src/main/java/com/iformall/service/SysConfigService.java
  9. +4
    -1
      mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java
  10. +16
    -1
      mallinkService/src/main/java/com/iformall/service/impl/SysConfigServiceImpl.java
  11. +36
    -15
      mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java
  12. +9
    -8
      mallinkService/src/main/resources/mapper/SysConfigMapper.xml
  13. +2
    -6
      mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml

+ 42
- 19
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java Просмотреть файл

@@ -4,14 +4,12 @@ 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.SysConfig;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxMallDispose;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCreditLockedStatus;
import com.iformall.enums.EnumGroupSupport;
import com.iformall.enums.EnumMallDispose;
import com.iformall.enums.EnumScoreRules;
import com.iformall.enums.*;
import com.iformall.service.WxMallDisposeService;
import com.iformall.service.WxMallService;
import com.iformall.service.WxScoreRulesService;
@@ -23,6 +21,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("wxScoreRules")
@Api(description = "成长值积分规则相关接口")
@@ -97,38 +98,60 @@ public class WxScoreRulesController extends BaseController {

@ApiOperation("获取积分倍率设置")
@GetMapping("/credit_double")
@SystemControllerLog(description = "积分-置")
@SystemControllerLog(description = "积分-获取积分倍率设置")
public ResultData creditDoubleRulesList() {
logger.debug("[" + getIpAddr() + "] creditDoubleRulesList::list");

WxScoreRules scoreRules = wxScoreRulesService.getCreditDoubleRules(getTenantInfo());
if(scoreRules == null){
return new ResultData();
}
if(getUser().getTenantId().equals(scoreRules.getTenantId())){
scoreRules.setEditable(true);
}
return new ResultData(scoreRules);
}

@ApiOperation("更新积分开关状态")
@ApiOperation("获取商户积分功能设置")
@GetMapping("/merchantCreditLocked")
@SystemControllerLog(description = "积分-获取商户积分功能设置")
public ResultData merchantCreditLocked() {
logger.debug("[" + getIpAddr() + "] creditDoubleRulesList::merchantCreditLocked");
Map<String,Object> result = new HashMap<>();
SysConfig creditLocked = wxScoreRulesService.merchantCreditLocked(getTenantInfo());
if(creditLocked == null){
return new ResultData();
}
result.put("sysId",creditLocked.getId());
result.put("creditLocked",creditLocked);
if(getUser().getTenantId().equals(getTenantInfo().getTenantId())){
result.put("isEditable",true);
}
return new ResultData(result);
}

@ApiOperation("更新商户积分功能设置")
@PostMapping("updateCreditLocked")
@SystemControllerLog(description = "更新积分开关状态")
public ResultData updateCreditLocked(@RequestBody WxScoreRules wxScoreRules) {
public ResultData updateCreditLocked(@RequestBody Map<String, Object> map) {
logger.debug("[" + getIpAddr() + "] WxScoreRulesController::updateCreditLocked");
if (null == wxScoreRules.getId()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空");
Long sysId = (Long) map.get("sysId");
Integer creditLocked = (Integer) map.get("creditLocked");

if(sysId == null || creditLocked == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
if (null == wxScoreRules.getCreditLocked()) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空");
EnumCreditLockedStatus lockedEnum = EnumCreditLockedStatus.getEnum(creditLocked);
if(lockedEnum == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
TenantEntity tenantEntity = getTenantInfo();
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "子广场用户无此权限");
if(wxMallService.isgroupSupport(getUser())){
return new ResultData(ErrorCode.SYS_AUTH_ERROR);
}
wxScoreRules.updateTenantInfo(tenantEntity);
try {
wxScoreRulesService.updateCreditLocked(wxScoreRules);
} catch (Exception e) {
return new ResultData(ErrorCode.DB_FAIL.getCode(), "更新积分开关状态失败");
if(!getUser().getTenantId().equals(getTenantInfo().getTenantId())){
return new ResultData(ErrorCode.SYS_AUTH_ERROR);
}
wxScoreRulesService.updateCreditLocked(getTenantInfo(),sysId,lockedEnum);
return new ResultData();
}



+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/controller/sys/SysConfigController.java Просмотреть файл

@@ -9,6 +9,7 @@ import com.iformall.domain.po.MallRolePermission;
import com.iformall.domain.po.SysConfig;
import com.iformall.domain.po.SysConfigValue;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.SysConfigService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -39,6 +40,7 @@ public class SysConfigController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) {
SysConfig config = new SysConfig();
config.setIsHide(EnumYesOrNo.NO.getCode());
config.setStatus(0);
PageInfo<SysConfig> page = sysConfigService.listAsPage(config, pageNum, pageSize, getTenantInfo());
return new ResultData(page);


+ 14
- 0
mallinkAdmin/src/main/resources/db/migration/V2023033000001_upd_merchant_credit_locked.sql Просмотреть файл

@@ -0,0 +1,14 @@
ALTER TABLE `mallink`.`sys_config`
ADD COLUMN `is_hide` smallint(2) NOT NULL DEFAULT 0 COMMENT '是否隐藏' AFTER `update_date`;


INSERT INTO `mallink`.`sys_config`(`id`, `config_item_key`, `config_item_remark`, `create_date`, `update_date`, `is_hide`, `status`) VALUES (10, 'merchantCreditLocked', '商户功能是否开启,0-正常,1-锁定', '2023-03-30 18:13:01', '2023-03-30 18:13:01', 1, 0);
--记录下生产需要关闭商户积分的广场(默认是打开的)wx_score_rules 中 type=2 and credit_locked=1 的广场
--初始化数据
--INSERT INTO `mallink`.`sys_config_value`(`id`, `config_item_id`, `config_item_value`, `tenant_id`, `parent_tenant_id`, `create_date`, `update_date`) VALUES (78910, 10, '1', '789', NULL, '2023-03-30 18:13:01', '2023-03-30 18:13:01');

ALTER TABLE `mallink`.`wx_score_rules`
DROP COLUMN `credit_locked`;




+ 2
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java Просмотреть файл

@@ -86,8 +86,8 @@ public class WxMerchantBUserController extends BaseController {
}

resultMap.put("creditLocked", merchant.getCreditLocked());
WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(user);
if (scoreRules.getCreditLocked().equals(EnumCreditLockedStatus.CLOSE.getCode())) {
SysConfig creditLocked = wxScoreRulesService.merchantCreditLocked(merchant);
if (EnumCreditLockedStatus.CLOSE.getCode().toString().equals(creditLocked.getConfigItemValue())) {
resultMap.put("creditLocked", EnumCreditLockedStatus.CLOSE.getCode());
}
resultMap.put("tenant_id",merchant.getTenantId());


+ 1
- 0
mallinkService/src/main/java/com/iformall/common/SysConfigConstant.java Просмотреть файл

@@ -8,5 +8,6 @@ public class SysConfigConstant {
public static final String coupon_detail_show_selled = "couponDetailShowSelled";
public static final String coupon_list_show_selled = "couponListShowSelled";
public static final String member_seconds_key="memberSeconds";
public static final String merchant_credit_locked="merchantCreditLocked";

}

+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/po/SysConfig.java Просмотреть файл

@@ -25,6 +25,8 @@ public class SysConfig extends BaseEntity {
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="",name="updateDate")
private Date updateDate;
@io.swagger.annotations.ApiModelProperty(value="是否隐藏",name="isHide")
private Integer isHide;
@io.swagger.annotations.ApiModelProperty(value="0-有效 1-无效",name="status")
private Integer status;



+ 0
- 3
mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java Просмотреть файл

@@ -108,9 +108,6 @@ public class WxScoreRules extends BaseTenantEntity {
@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;
}


+ 3
- 2
mallinkService/src/main/java/com/iformall/service/SysConfigService.java Просмотреть файл

@@ -31,9 +31,10 @@ public interface SysConfigService {
/**
* 保存或更新实体
*
* @param record
* @param
*/
void saveConfigValue(Long id,TenantEntity tenantEntity,String value);


void saveOrUpdate(SysConfig record);
}

+ 4
- 1
mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java Просмотреть файл

@@ -1,8 +1,10 @@
package com.iformall.service;

import com.iformall.domain.po.SysConfig;
import com.iformall.domain.po.WxScoreHistory;
import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCreditLockedStatus;
import com.iformall.enums.EnumScoreType;

import java.util.List;
@@ -75,7 +77,7 @@ public interface WxScoreRulesService {

List<WxScoreRules> findList(WxScoreRules wxScoreRules);

void updateCreditLocked(WxScoreRules wxScoreRules);
void updateCreditLocked(TenantEntity tenantEntity,Long sysId, EnumCreditLockedStatus lockedEnum);

WxScoreRules getCreditDoubleRules(String tenantId);

@@ -83,4 +85,5 @@ public interface WxScoreRulesService {

WxScoreRules getById(Long id);

SysConfig merchantCreditLocked(TenantEntity tenantInfo);
}

+ 16
- 1
mallinkService/src/main/java/com/iformall/service/impl/SysConfigServiceImpl.java Просмотреть файл

@@ -128,5 +128,20 @@ public class SysConfigServiceImpl implements SysConfigService {
}
RedisCacheUtils.removeCache(baseRedisTemplate, String.format(cache_prex, tenantEntity.getTenantId(),config.getConfigItemKey()));
}

@Override
public void saveOrUpdate(SysConfig record) {
Date curr = new Date();
if (record.getId() == null) {
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateDate(curr);
record.setUpdateDate(curr);
sysConfigMapper.insert(record);
} else {
record.setUpdateDate(curr);
sysConfigMapper.updateById(record);
}
}

}

+ 36
- 15
mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java Просмотреть файл

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.ResultData;
import com.iformall.common.SysConfigConstant;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
@@ -60,6 +61,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
@Autowired
WxMallService wxMallService;

@Autowired
SysConfigService sysConfigService;


@Override
public void wxScoreRulesInit(String tenantId) {
@@ -69,7 +73,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
wxScoreRules.setCreateDate(new Date());
wxScoreRules.setUpdateDate(new Date());
wxScoreRules.setType(EnumScoreRules.CREDIT.getCode());
wxScoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode());
wxScoreRulesMapper.insert(wxScoreRules);
wxScoreRules = new WxScoreRules();
wxScoreRules.setTenantId(tenantId);
@@ -77,7 +80,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
wxScoreRules.setCreateDate(new Date());
wxScoreRules.setUpdateDate(new Date());
wxScoreRules.setType(EnumScoreRules.SCORE.getCode());
wxScoreRules.setCreditLocked(EnumCreditLockedStatus.CLOSE.getCode());
wxScoreRulesMapper.insert(wxScoreRules);
}

@@ -109,7 +111,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
final IdWorker idWorker = IdWorker.get();
scoreRules.setId(idWorker.nextId());
scoreRules.setRules(getScoreRulesNew(baseTenantEntity,WxScoreRules.getScoreDefaultRules(),EnumScoreRules.SCORE));
scoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode());
wxScoreRulesMapper.insert(scoreRules);
}
// 插入缓存
@@ -207,8 +208,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
final IdWorker idWorker = IdWorker.get();
scoreRules.setId(idWorker.nextId());
scoreRules.setRules(getScoreRulesNew(baseTenantEntity,WxScoreRules.getCreditDefaultRules(),EnumScoreRules.CREDIT));
scoreRules.setScale(WxScoreRules.DEFAULT_SCALE);
scoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode());
wxScoreRulesMapper.insert(scoreRules);
}

@@ -688,15 +687,15 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
}

@Override
public void updateCreditLocked(WxScoreRules wxScoreRules) {
wxScoreRulesMapper.updateById(wxScoreRules);
updateMerchantCreditLocked(wxScoreRules);
public void updateCreditLocked(TenantEntity tenantEntity,Long sysId, EnumCreditLockedStatus lockedEnum) {
sysConfigService.saveConfigValue(sysId,tenantEntity,lockedEnum.getCode().toString());
updateMerchantCreditLocked(tenantEntity,lockedEnum);
}

public void updateMerchantCreditLocked(WxScoreRules wxScoreRules) {
public void updateMerchantCreditLocked(TenantEntity tenantEntity, EnumCreditLockedStatus lockedEnum) {
WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(wxScoreRules);
wxMerchant.setStatus(wxScoreRules.getCreditLocked());
wxMerchant.updateTenantInfo(tenantEntity);
wxMerchant.setStatus(lockedEnum.getCode());
wxMerchant.setUpdateDate(new Date());
wxMerchantMapper.updateCreditLocked(wxMerchant);
}
@@ -718,12 +717,16 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules);
if (list.size() > 0) {
scoreRules = list.get(0);
// 插入缓存
scoreRulesRedisTemplate.opsForValue().set(key, scoreRules);
logger.info("WxScoreRulesServiceImpl.getScoreRules() : 积分设置插入缓存 >> " + scoreRules.toString());
} else{
return null;
final IdWorker idWorker = IdWorker.get();
scoreRules.setId(idWorker.nextId());
scoreRules.setRules("[]");
scoreRules.setScale(WxScoreRules.DEFAULT_SCALE);
wxScoreRulesMapper.insert(scoreRules);
}
// 插入缓存
scoreRulesRedisTemplate.opsForValue().set(key, scoreRules);
logger.info("WxScoreRulesServiceImpl.getScoreRules() : 积分设置插入缓存 >> " + scoreRules.toString());
return scoreRules;
}

@@ -741,4 +744,22 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
return wxScoreRulesMapper.selectById(id);
}

@Override
public SysConfig merchantCreditLocked(TenantEntity tenantInfo) {
SysConfig creditLocked = sysConfigService.getByKey(SysConfigConstant.merchant_credit_locked,tenantInfo);
if(creditLocked == null){
creditLocked = new SysConfig();
final IdWorker idWorker = IdWorker.get();
creditLocked.setId(idWorker.nextId());
creditLocked.setConfigItemKey(SysConfigConstant.merchant_credit_locked);
creditLocked.setConfigItemRemark("商户功能是否开启,0-正常,1-锁定");
creditLocked.setIsHide(EnumYesOrNo.YES.getCode());
sysConfigService.saveOrUpdate(creditLocked);
}
if(creditLocked.getConfigItemValue() == null){
creditLocked.setConfigItemValue(EnumCreditLockedStatus.OPEN.getCode().toString());
}
return creditLocked;
}

}

+ 9
- 8
mallinkService/src/main/resources/mapper/SysConfigMapper.xml Просмотреть файл

@@ -7,11 +7,12 @@
<result column="config_item_remark" jdbcType="VARCHAR" property="configItemRemark" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="is_hide" jdbcType="INTEGER" property="isHide" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<sql id="allColumns">
`id`,`config_item_key`,`config_item_remark`,`create_date`,`update_date`,`status`
`id`,`config_item_key`,`config_item_remark`,`create_date`,`update_date`,`is_hide`,`status`
</sql>

<sql id="dynamicWhereConditions">
@@ -22,9 +23,12 @@
<if test=" null != configItemKey ">
and `config_item_key` = #{configItemKey}
</if>
<if test=" null != status ">
and `status` = #{status}
</if>
<if test=" null != isHide ">
and `is_hide` = #{isHide}
</if>
<if test=" null != status ">
and `status` = #{status}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
@@ -42,8 +46,5 @@
<select id="findByKey" parameterType="com.iformall.domain.po.SysConfig" resultMap="BaseResultMap">
select <include refid="allColumns" /> from sys_config where `config_item_key` = #{configItemKey}
</select>

</mapper>

+ 2
- 6
mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml Просмотреть файл

@@ -10,12 +10,11 @@
<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`,credit_locked
`id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale`
</sql>

<sql id="dynamicWhereConditions">
@@ -44,10 +43,7 @@
<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=")">


Загрузка…
Отмена
Сохранить