|
@@ -1,5 +1,6 @@
|
|
|
package com.gree.mall.manager.logic.common;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
@@ -23,6 +24,8 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -90,6 +93,8 @@ public class CommonLogic {
|
|
|
|
|
|
@Autowired
|
|
|
AdminDeptWebsitService adminDeptWebsitService;
|
|
|
+ @Autowired
|
|
|
+ IncrKeyValueService incrKeyValueService;
|
|
|
|
|
|
public Map<String, String> getOSSConfig() throws UnsupportedEncodingException {
|
|
|
return ossUtil.getConfig();
|
|
@@ -583,4 +588,36 @@ public class CommonLogic {
|
|
|
return BigDecimal.ZERO;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public String getIncrKeyValue(String companyWechatId, String key, String start, int length) {
|
|
|
+ final IncrKeyValue incrKeyValue = incrKeyValueService.lambdaQuery()
|
|
|
+ .eq(IncrKeyValue::getCompanyWechatId, companyWechatId)
|
|
|
+ .eq(IncrKeyValue::getIncrKey, key)
|
|
|
+ .one();
|
|
|
+ final Integer value = incrKeyValue.getIncrValue();
|
|
|
+ incrKeyValue.setIncrValue(incrKeyValue.getIncrValue() + 1)
|
|
|
+ .updateById();
|
|
|
+ StringBuilder number = new StringBuilder();
|
|
|
+ number.append(start);
|
|
|
+ int ramainLen = length - number.toString().length();
|
|
|
+ //自增 填充位数
|
|
|
+ number.append(String.format("%0" + ramainLen + "d", Integer.parseInt(value.toString())));
|
|
|
+ return number.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void initIncrKeyValue(String companyWechatId, String companyWechatName, List<String> keys) {
|
|
|
+ if (CollectionUtil.isNotEmpty(keys)) {
|
|
|
+ List<IncrKeyValue> list = new ArrayList<>();
|
|
|
+ for (String key : keys) {
|
|
|
+ IncrKeyValue incrKeyValue = new IncrKeyValue();
|
|
|
+ incrKeyValue.setCompanyWechatId(companyWechatId)
|
|
|
+ .setCompanyName(companyWechatName)
|
|
|
+ .setIncrKey(key);
|
|
|
+ list.add(incrKeyValue);
|
|
|
+ }
|
|
|
+ incrKeyValueService.saveBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|