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

电话手机号码解密 商户切换

xgb 1 неделя назад
Родитель
Сommit
32db2b6a0b

+ 12 - 0
fs-admin/src/main/java/com/fs/his/controller/FsCompanyController.java

@@ -354,4 +354,16 @@ public class FsCompanyController extends BaseController {
         if (value.isEmpty())return true;
         return false;
     }
+
+    /**
+     * 公司分账配置
+     */
+    @PreAuthorize("@ss.hasPermi('company:company:changeMerchant')")
+    @Log(title = "红包商户配置", businessType = BusinessType.UPDATE)
+    @PostMapping("/changeMerchant")
+    public R changeMerchant(@RequestBody CompanyVO companyVO)
+    {
+        return companyService.changeMerchant(companyVO);
+    }
+
 }

+ 10 - 1
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -41,6 +41,7 @@ import com.fs.his.service.IFsStoreOrderDfService;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.impl.FsDfAccountServiceImpl;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.FsStoreOrderListAndStatisticsVo;
 import com.fs.his.vo.FsStoreOrderListVO;
 import com.fs.hisStore.config.FsErpConfig;
@@ -645,7 +646,12 @@ public class FsStoreOrderScrmController extends BaseController {
     @GetMapping(value = "/{id}")
     public R getInfo(@PathVariable("id") Long id) {
         FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
-        order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
+        // 电话号码解密
+        String phone=order.getUserPhone();
+        if(StringUtils.isNotBlank(phone) && phone.endsWith("==")){ // 加密手机号,解密
+            phone= PhoneUtil.decryptPhone( phone);
+        }
+        order.setUserPhone(ParseUtils.parsePhone(phone));
         order.setUserAddress(ParseUtils.parseAddress(order.getUserAddress()));
         FsUser user = userService.selectFsUserById(order.getUserId());
         if (user != null) {
@@ -687,6 +693,9 @@ public class FsStoreOrderScrmController extends BaseController {
     {
         FsStoreOrderScrm order = fsStoreOrderService.selectFsStoreOrderById(id);
         String userPhone = order.getUserPhone();
+        if(StringUtils.isNotBlank(userPhone) && userPhone.endsWith("==")){ // 加密手机号,解密
+            userPhone= PhoneUtil.decryptPhone( userPhone);
+        }
         return R.ok().put("userPhone",userPhone);
     }
 

+ 2 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyService.java

@@ -203,4 +203,6 @@ public interface ICompanyService
     R checkMchTransferStatusByBatchID(String batchId, Long companyId, String appId);
 
     void deleteRedPacketLogBatch();
+
+    R changeMerchant(CompanyVO companyVO);
 }

+ 80 - 1
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -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;
     }

+ 3 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyVO.java

@@ -107,4 +107,7 @@ public class CompanyVO implements Serializable
 
     // 控制休息提示是否打开要暂停  0-关闭 1-打开 null-默认打开
     private Integer isOpenRestReminder;
+
+    // 红包商户号
+    private String redPacketMerchant;
 }