|
|
@@ -10,6 +10,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.constant.FsConstants;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
@@ -64,12 +65,12 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionTemplate;
|
|
|
-
|
|
|
import static com.fs.company.service.impl.CompanyMiniappServiceImpl.GET_MINI_APP_STR;
|
|
|
|
|
|
/**
|
|
|
@@ -82,9 +83,13 @@ import static com.fs.company.service.impl.CompanyMiniappServiceImpl.GET_MINI_APP
|
|
|
public class CompanyServiceImpl implements ICompanyService
|
|
|
{
|
|
|
Logger logger= LoggerFactory.getLogger(getClass());;
|
|
|
+
|
|
|
+ private static final String REDIS_KEY_PREFIX = "red_packet_config:";
|
|
|
@Autowired
|
|
|
private CompanyMapper companyMapper;
|
|
|
@Autowired
|
|
|
+ private CompanyConfigMapper companyConfigMapper;
|
|
|
+ @Autowired
|
|
|
private ICompanyMiniappService companyMiniappService;
|
|
|
@Autowired
|
|
|
private CompanyDeptMapper deptMapper;
|
|
|
@@ -122,6 +127,9 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate<String, String> redisTemplate;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private RedissonClient redissonClient;
|
|
|
@@ -398,6 +406,70 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R changeMerchant(CompanyVO companyVO) {
|
|
|
+ // 长春张磊的不允许换 自用交易写死
|
|
|
+ if("20".equals(companyVO.getCompanyId().toString())){
|
|
|
+ return R.error("该公司不允许换商户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ CompanyConfig companyConfig =companyConfigMapper.selectCompanyConfigByKey(companyVO.getCompanyId(),"redPacket:config");
|
|
|
+
|
|
|
+ String updateKey=REDIS_KEY_PREFIX + companyVO.getCompanyId();
|
|
|
+ // 小艾的商户
|
|
|
+ if("1103448555".equals(companyVO.getRedPacketMerchant())){
|
|
|
+ String redisKey = REDIS_KEY_PREFIX + 20;
|
|
|
+ String json = redisTemplate.opsForValue().get(redisKey);
|
|
|
+ if(json!=null){
|
|
|
+ RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
+ String url = config.getNotifyUrl();
|
|
|
+ url=url.substring(0,url.lastIndexOf("/")+1)+companyVO.getCompanyId();
|
|
|
+ config.setNotifyUrl(url);
|
|
|
+ redisTemplate.opsForValue().set(updateKey,JSONUtil.toJsonStr(config));
|
|
|
+
|
|
|
+ if(companyConfig!=null){
|
|
|
+ // 更新数据库
|
|
|
+ CompanyConfig updateConfig= new CompanyConfig();
|
|
|
+ updateConfig.setCompanyId(companyVO.getCompanyId());
|
|
|
+ updateConfig.setConfigId(companyConfig.getConfigId());
|
|
|
+ updateConfig.setConfigValue(JSONUtil.toJsonStr(config));
|
|
|
+ companyConfigMapper.updateCompanyConfig(updateConfig);
|
|
|
+ }else {
|
|
|
+ CompanyConfig save=new CompanyConfig();
|
|
|
+ save.setCompanyId(companyVO.getCompanyId());
|
|
|
+ save.setConfigKey("redPacket:config");
|
|
|
+ save.setConfigValue(JSONUtil.toJsonStr(config));
|
|
|
+ save.setConfigType("N");
|
|
|
+ companyConfigMapper.insertCompanyConfig( save);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if("1700010711".equals(companyVO.getRedPacketMerchant())){
|
|
|
+ if(redisCache.getCacheObject(updateKey) != null){
|
|
|
+ redisCache.deleteObject(updateKey);
|
|
|
+ if(companyConfig!=null){
|
|
|
+ // 更新数据库
|
|
|
+ CompanyConfig updateConfig= new CompanyConfig();
|
|
|
+ updateConfig.setCompanyId(companyVO.getCompanyId());
|
|
|
+ updateConfig.setConfigId(companyConfig.getConfigId());
|
|
|
+ updateConfig.setConfigValue("");
|
|
|
+ companyConfigMapper.updateCompanyConfig(updateConfig);
|
|
|
+ }else {
|
|
|
+ CompanyConfig save=new CompanyConfig();
|
|
|
+ save.setCompanyId(companyVO.getCompanyId());
|
|
|
+ save.setConfigKey("redPacket:config");
|
|
|
+ save.setConfigValue("");
|
|
|
+ save.setConfigType("N");
|
|
|
+ companyConfigMapper.insertCompanyConfig( save);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ return R.error("该商户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
LocalDateTime threeMonthsAgo = LocalDateTime.now().minusMonths(3);
|
|
|
@@ -1009,6 +1081,13 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
companyVO.setRedPackageMoney(new BigDecimal(redPackageMoney));
|
|
|
|
|
|
}
|
|
|
+ // 返回红包商户
|
|
|
+ String redisKey = REDIS_KEY_PREFIX + companyVO.getCompanyId();
|
|
|
+ String jsonStr = redisTemplate.opsForValue().get(redisKey);
|
|
|
+ if(jsonStr != null && !jsonStr.isEmpty()){
|
|
|
+ RedPacketConfig config = JSONUtil.toBean(jsonStr, RedPacketConfig.class);
|
|
|
+ companyVO.setRedPacketMerchant(config.getMchId());
|
|
|
+ }
|
|
|
});
|
|
|
return companyVOList;
|
|
|
}
|