数据同步商品活动和会员调试问题修复
This commit is contained in:
parent
f3b5f63f59
commit
b915bbff21
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.service.*;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.*;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.MybatisPlusQueryUtil;
|
||||
import io.seata.core.context.RootContext;
|
||||
import io.seata.core.exception.TransactionException;
|
||||
@ -438,4 +439,37 @@ public class AccountController {
|
||||
return accountUserInfoService.find(MybatisPlusQueryUtil.getQueryWrapper(AccountUserBase.class, queryParams));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getAccountsMapByMobile", method = RequestMethod.POST)
|
||||
public Map<String,Integer> getAccountsMapByMobile(@RequestBody List<String> mobiles) {
|
||||
return accountUserBaseService.getAccountBaseMapByMobile(mobiles);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getAccountMaxId", method = RequestMethod.POST)
|
||||
public Integer getAccountMaxId() {
|
||||
return accountUserBaseService.getAccountMaxId();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveBatchAccountBase", method = RequestMethod.POST)
|
||||
public ThirdApiRes saveBatchAccountBase(@RequestBody List<AccountUserBase> accountUserBaseList) {
|
||||
return accountUserBaseService.saveBatchAccountBase(accountUserBaseList);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/saveBatchAccountInfo", method = RequestMethod.POST)
|
||||
public ThirdApiRes saveBatchAccountInfo(@RequestBody List<AccountUserInfo> accountUserInfoList) {
|
||||
return accountUserBaseService.saveBatchAccountInfo( accountUserInfoList);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/findOneAccountUserBase", method = RequestMethod.POST)
|
||||
public AccountUserBase findOneAccountUserBase(@RequestBody AccountUserBase accountUserBase) {
|
||||
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_is_admin", accountUserBase.getUser_is_admin());
|
||||
queryWrapper.eq("store_ids",accountUserBase.getStore_ids());
|
||||
queryWrapper.last("limit 1");
|
||||
return accountUserBaseService.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@ package com.suisung.mall.account.service;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
import org.springframework.data.util.Pair;
|
||||
|
||||
@ -235,4 +237,31 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
* @return
|
||||
*/
|
||||
Boolean sendSmsMessage(String mobile, String templateCode, Map<String, Object> msgArgs);
|
||||
|
||||
/**
|
||||
* 根据手机号和商户查询map,用于批量匹配
|
||||
* @param moblies 就是账号集合
|
||||
* @return
|
||||
*/
|
||||
Map<String,Integer> getAccountBaseMapByMobile(List<String> moblies);
|
||||
|
||||
/**
|
||||
* 找出accountbase的最大id
|
||||
* @return
|
||||
*/
|
||||
Integer getAccountMaxId();
|
||||
|
||||
|
||||
/**
|
||||
* 批量保存accountBase
|
||||
* @return
|
||||
*/
|
||||
ThirdApiRes saveBatchAccountBase(List<AccountUserBase> accountUserBaseList);
|
||||
|
||||
|
||||
/**
|
||||
* 批量保存accountInfo
|
||||
* @return
|
||||
*/
|
||||
ThirdApiRes saveBatchAccountInfo(List<AccountUserInfo> accountUserInfoList);
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||
import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser;
|
||||
import com.suisung.mall.common.pojo.dto.SmsDto;
|
||||
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.service.MessageService;
|
||||
import com.suisung.mall.common.utils.*;
|
||||
import com.suisung.mall.common.utils.constbank.RSAUtil;
|
||||
@ -3562,8 +3563,57 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
logger.error("发送短信失败:", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Integer> getAccountBaseMapByMobile(List<String> moblies) {
|
||||
QueryWrapper<AccountUserBase> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.select("user_id", "user_account");
|
||||
moblies.forEach(moblie -> {
|
||||
queryWrapper.or(q -> q.eq("user_account", moblie));
|
||||
});
|
||||
List<AccountUserBase> userBaseList= this.list(queryWrapper);
|
||||
return userBaseList.stream().collect(Collectors.toMap(AccountUserBase::getUser_account, AccountUserBase::getUser_id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getAccountMaxId() {
|
||||
QueryWrapper<AccountUserBase> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.select("max(user_id) as user_id");
|
||||
AccountUserBase accountUserBase=this.getOne(queryWrapper);
|
||||
return accountUserBase.getUser_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThirdApiRes saveBatchAccountBase(List<AccountUserBase> accountUserBaseList) {
|
||||
boolean result=false;
|
||||
if(!accountUserBaseList.isEmpty()){
|
||||
try {
|
||||
result= saveBatch(accountUserBaseList,accountUserBaseList.size());
|
||||
}catch (RuntimeException e){
|
||||
throw new ApiException("保存saveBatchAccountBase报错:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
if(result){
|
||||
return new ThirdApiRes().success("成功");
|
||||
}
|
||||
return new ThirdApiRes().fail(250,"保存异常");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThirdApiRes saveBatchAccountInfo(List<AccountUserInfo> accountUserInfoList){
|
||||
boolean result=false;
|
||||
if(!accountUserInfoList.isEmpty()){
|
||||
try {
|
||||
result= accountUserInfoService.saveBatch(accountUserInfoList,accountUserInfoList.size());
|
||||
}catch (Exception e){
|
||||
throw new RuntimeException("保存AccountUserInfo报错:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
if(result){
|
||||
return new ThirdApiRes().success("成功");
|
||||
}
|
||||
return new ThirdApiRes().fail(250,"保存异常");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://@mysql.host@:@mysql.port@/@mysql.db@?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
url: jdbc:mysql://@mysql.host@:@mysql.port@/@mysql.db@?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
username: @mysql.user@
|
||||
password: @mysql.pwd@
|
||||
driver-class-name: @mysql.driver@
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.suisung.mall.common.adapter;
|
||||
|
||||
import com.google.gson.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BigDecimalTypeAdapter implements JsonSerializer<BigDecimal>, JsonDeserializer<BigDecimal> {
|
||||
@Override
|
||||
public JsonElement serialize(BigDecimal value, Type type, JsonSerializationContext context) {
|
||||
if (value == null) {
|
||||
return JsonNull.INSTANCE;
|
||||
}
|
||||
// 去除末尾的 0,并避免科学计数法
|
||||
return new JsonPrimitive(value.stripTrailingZeros().toPlainString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal deserialize(JsonElement json, Type type, JsonDeserializationContext context) {
|
||||
return json.isJsonNull() ? null : new BigDecimal(json.getAsString());
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.*;
|
||||
import com.suisung.mall.common.modules.push.PushTemplate;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -229,10 +230,10 @@ public interface AccountService {
|
||||
@RequestParam(name = "user_type", required = false) Integer user_type);
|
||||
|
||||
@PostMapping("/admin/account/pushTocid")
|
||||
String pushTocid(@RequestParam(name = "message") String message, @RequestParam(name = "userId") String userId);
|
||||
String pushTocid(@RequestParam(name = "message") String message,@RequestParam(name = "userId") String userId);
|
||||
|
||||
@PostMapping("/admin/account/pushNotificationTocid")
|
||||
String pushNotificationTocid(@RequestParam("userId") String userId, @RequestBody PushTemplate pushTemplate);
|
||||
String pushNotificationTocid(@RequestParam("userId") String userId,@RequestBody PushTemplate pushTemplate);
|
||||
|
||||
/**
|
||||
* 根据用户 Id 获取账号推送绑定关系列表记录
|
||||
@ -242,4 +243,41 @@ public interface AccountService {
|
||||
*/
|
||||
@PostMapping("admin/account/account-user-bind-getui/selectAccountUserBindGeTuiListByUserId")
|
||||
List<AccountUserBindGeTui> selectAccountUserBindGeTuiListByUserId(@RequestParam(name = "userId", defaultValue = "0") Integer userId);
|
||||
|
||||
/**
|
||||
* 通过手机号查找map
|
||||
* @param mobiles
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/getAccountsMapByMobile")
|
||||
Map<String,Integer> getAccountsMapByMobile(@RequestBody List<String> mobiles);
|
||||
|
||||
/**
|
||||
* 找出account表的最大id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/getAccountMaxId")
|
||||
Integer getAccountMaxId();
|
||||
|
||||
|
||||
/**
|
||||
* 批量保存accountBase
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/saveBatchAccountBase")
|
||||
ThirdApiRes saveBatchAccountBase(@RequestBody List<AccountUserBase> accountUserBaseList);
|
||||
|
||||
/**
|
||||
* 批量保存accountInfo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/saveBatchAccountInfo")
|
||||
ThirdApiRes saveBatchAccountInfo(@RequestBody List<AccountUserInfo> accountUserInfoList);
|
||||
|
||||
/**
|
||||
* 批量保存accountInfo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/findOneAccountUserBase")
|
||||
AccountUserBase findOneAccountUserBase(@RequestBody AccountUserBase accountUserBase);
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ import com.suisung.mall.common.modules.order.ShopOrderReturn;
|
||||
import com.suisung.mall.common.modules.pay.*;
|
||||
import com.suisung.mall.common.modules.product.ShopProductIndex;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -192,4 +194,10 @@ public interface PayService {
|
||||
Boolean changePayConsumeTradeState(@RequestParam(name = "order_id") String orderId,
|
||||
@RequestParam(name = "order_state_id") Integer orderStateId,
|
||||
@RequestParam(name = "trade_is_paid") Integer tradeIsPaid);
|
||||
|
||||
|
||||
@PostMapping(value = "/admin/pay/payController/saveBatchPayUserResources")
|
||||
@Transactional
|
||||
ThirdApiRes saveBatchPayUserResources(@RequestBody List<PayUserResource> payUserResourceList);
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mall-suite
|
||||
* @description: es远程调用
|
||||
@ -32,5 +34,6 @@ public interface SearchService {
|
||||
@PostMapping(value = "/esProduct/recommend")
|
||||
CommonResult recommend(@RequestBody ProductRecommendDTO productRecommendDTO);
|
||||
|
||||
|
||||
@PostMapping("/esProduct/batchImport")
|
||||
CommonResult batchImport(@RequestBody List<ShopProductIndex> shopProductIndexList);
|
||||
}
|
||||
|
||||
@ -123,4 +123,8 @@ public class ShopStoreActivityBase implements Serializable {
|
||||
@ApiModelProperty(value = "乐观锁")
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "思迅活动id")
|
||||
@TableField(updateStrategy = NOT_EMPTY)
|
||||
private String flow_no;
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderReturn;
|
||||
import com.suisung.mall.common.modules.pay.*;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.MybatisPlusQueryUtil;
|
||||
import com.suisung.mall.pay.service.*;
|
||||
import io.seata.core.context.RootContext;
|
||||
@ -406,5 +407,11 @@ public class PayController {
|
||||
payUserPayService.wxRefundNotify(request);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量保存", notes = "用户资源表")
|
||||
@RequestMapping(value = "/saveBatchPayUserResources", method = {RequestMethod.POST})
|
||||
public ThirdApiRes saveBatchPayUserResources(@RequestBody List<PayUserResource> payUserResourceList) {
|
||||
return payUserPayService.saveBatchPayUserResources(payUserResourceList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ package com.suisung.mall.pay.service;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderReturn;
|
||||
import com.suisung.mall.common.modules.pay.PayUserPay;
|
||||
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
import com.suisung.mall.pay.entity.PayTypeBean;
|
||||
|
||||
@ -63,4 +65,6 @@ public interface PayUserPayService extends IBaseService<PayUserPay> {
|
||||
|
||||
boolean deleteUserChainByUid(List<Integer> user_ids);
|
||||
|
||||
ThirdApiRes saveBatchPayUserResources(List<PayUserResource> payUserResourceList);
|
||||
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ import com.suisung.mall.common.modules.order.ShopOrderReturn;
|
||||
import com.suisung.mall.common.modules.pay.*;
|
||||
import com.suisung.mall.common.modules.pay.dto.ItemActivityInfoDTO;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.LogUtil;
|
||||
@ -69,6 +70,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -1765,4 +1767,23 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
|
||||
|
||||
shopService.updateRefundOrderReturn(shopOrderReturn);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ThirdApiRes saveBatchPayUserResources(List<PayUserResource> payUserResourceList) {
|
||||
boolean result=false;
|
||||
if(!payUserResourceList.isEmpty()){
|
||||
try {
|
||||
result=payUserResourceService.saveBatch(payUserResourceList,payUserResourceList.size());
|
||||
}catch (RuntimeException e){
|
||||
throw new ApiException("保存saveBatchPayUserResources报错:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
if(result){
|
||||
return new ThirdApiRes().success("批量保存成功");
|
||||
}
|
||||
return new ThirdApiRes().fail(250,"批量保存失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -78,4 +78,11 @@ public class EsProductController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "导入商品到ES")
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||
public CommonResult batchImport(List<ShopProductIndex> shopProductIndexList) {
|
||||
int count = esProductService.batchImport(shopProductIndexList);
|
||||
return CommonResult.success(count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -49,4 +49,10 @@ public interface EsProductService {
|
||||
*/
|
||||
PageImpl<? extends Serializable> recommend(ProductRecommendDTO productRecommendDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据id创建商品
|
||||
*/
|
||||
int batchImport(List<ShopProductIndex> shopProductIndexList);
|
||||
|
||||
}
|
||||
|
||||
@ -56,14 +56,14 @@ public class EsProductServiceImpl implements EsProductService {
|
||||
@Override
|
||||
public int importAll() {
|
||||
List<EsProduct> esProductList = productDao.getAllEsProductList(null);
|
||||
Iterable<EsProduct> esProductIterable = productRepository.saveAll(esProductList);
|
||||
Iterator<EsProduct> iterator = esProductIterable.iterator();
|
||||
int result = 0;
|
||||
while (iterator.hasNext()) {
|
||||
result++;
|
||||
iterator.next();
|
||||
}
|
||||
return result;
|
||||
// Iterable<EsProduct> esProductIterable = productRepository.saveAll(esProductList);
|
||||
// Iterator<EsProduct> iterator = esProductIterable.iterator();
|
||||
// int result = 0;
|
||||
// while (iterator.hasNext()) {
|
||||
// result++;
|
||||
// iterator.next();
|
||||
// }
|
||||
return saveBatchEsProduct(esProductList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -311,4 +311,29 @@ public class EsProductServiceImpl implements EsProductService {
|
||||
return new PageImpl<>(collects, pageable, searchHits.getTotalHits());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchImport(List<ShopProductIndex> shopProductIndexList) {
|
||||
List<EsProduct> esProductList = new ArrayList<>();
|
||||
for (ShopProductIndex shopProductIndex : shopProductIndexList) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(shopProductIndex);
|
||||
EsProduct es_product = JSONUtil.toBean(jsonObject, EsProduct.class);
|
||||
esProductList.add(es_product);
|
||||
}
|
||||
if(esProductList.isEmpty()){
|
||||
return 0;
|
||||
}
|
||||
return saveBatchEsProduct(esProductList);
|
||||
}
|
||||
|
||||
private int saveBatchEsProduct(List<EsProduct> esProductList){
|
||||
Iterable<EsProduct> esProductIterable = productRepository.saveAll(esProductList);
|
||||
Iterator<EsProduct> iterator = esProductIterable.iterator();
|
||||
int result = 0;
|
||||
while (iterator.hasNext()) {
|
||||
result++;
|
||||
iterator.next();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,4 +29,8 @@ public interface ShopNumberSeqService extends IBaseService<ShopNumberSeq> {
|
||||
List<Integer> getBatchSpecItemId(int batchSize);
|
||||
|
||||
void clearKeyStoreItemSepcId();
|
||||
|
||||
List<Integer> getBatchUserAccountBaseId(int batchSize);
|
||||
|
||||
void clearKeyStoreAccountBaseId();
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.suisung.mall.shop.number.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
import com.suisung.mall.common.modules.number.ShopNumberSeq;
|
||||
import com.suisung.mall.common.modules.product.ShopProductSpecItem;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
@ -15,7 +16,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -45,6 +45,9 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
||||
@Autowired
|
||||
private ShopProductSpecItemService shopProductSpecItemService;
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
/**
|
||||
* 得到下一个Id
|
||||
* 方法走到这里会产生串行化,集群部署这里不能使用单机锁
|
||||
@ -201,6 +204,12 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
||||
redisService.del(RedisKey.STOREDATASPECITEMID);
|
||||
}
|
||||
|
||||
public void clearKeyStoreAccountBaseId(){
|
||||
redisService.del(RedisKey.STOREDATACCOUNTBASEID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 清除缓存,专门给并发使用,防止redis的缓存没有加载
|
||||
*/
|
||||
@ -261,6 +270,32 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
||||
return IntStream.rangeClosed(start+1, start+batchSize).boxed().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 存的是最大值,取的是范围,如存最大值1,批量是2,则取范围【1+1,1+2】,如果没有则从1开始算即取范围[0+1,0+2]
|
||||
* @param batchSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<Integer> getBatchUserAccountBaseId(int batchSize) {
|
||||
int start=0;
|
||||
if(null!=redisService.get(RedisKey.STOREDATACCOUNTBASEID)){
|
||||
start=(Integer) redisService.get(RedisKey.STOREDATACCOUNTBASEID);
|
||||
redisService.set(RedisKey.STOREDATACCOUNTBASEID,start+batchSize);
|
||||
}
|
||||
Integer maxId= accountService.getAccountMaxId();
|
||||
if(null!=maxId){
|
||||
start=maxId;
|
||||
redisService.set(RedisKey.STOREDATACCOUNTBASEID,start+batchSize);
|
||||
}
|
||||
if(start==0){
|
||||
redisService.set(RedisKey.STOREDATACCOUNTBASEID,start+batchSize);
|
||||
return IntStream.rangeClosed(start+1, start+batchSize).boxed().collect(Collectors.toList());
|
||||
}
|
||||
return IntStream.rangeClosed(start+1, start+batchSize).boxed().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.printf(IntStream.rangeClosed(1, 1).boxed().collect(Collectors.toList()).toString());
|
||||
}
|
||||
|
||||
@ -288,14 +288,13 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
|
||||
List<ShopProductInfo> shopProductInfoList, List<List<ShopProductItem>> shopProductItemList,
|
||||
List<ShopProductImage> shopProductImageList,
|
||||
List<ShopProductValidPeriod> shopProductValidPeriodList,
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList);
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList,String priorityMode);
|
||||
|
||||
/**
|
||||
* 加载商品
|
||||
* @param store_id
|
||||
* @return
|
||||
*/
|
||||
Map getProductBasicIdByStore(Integer store_id);
|
||||
Map<String,Long> getProductBasicIdByStore(Integer store_id,List<String> productNumberList);
|
||||
|
||||
void clearBasicIdByStore(Integer store_id);
|
||||
}
|
||||
|
||||
@ -75,9 +75,8 @@ public interface ShopProductItemService extends IBaseService<ShopProductItem> {
|
||||
* @param store_id
|
||||
* @return
|
||||
*/
|
||||
Map getProductItemIdByStore(Integer store_id);
|
||||
Map<String,String> getProductItemIdByStore(Integer store_id,List<String> productNumbers);
|
||||
|
||||
void clearProductItemIdByStore(Integer store_id);
|
||||
|
||||
/**
|
||||
* 更加产品名称更新状态
|
||||
|
||||
@ -213,6 +213,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
private StoreDbConfigService storeDbConfigService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean trySaveProduct(String productObj, String productItems) {
|
||||
|
||||
@ -5277,7 +5278,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<ShopProductData> shopProductDataList, List<ShopProductDetail> shopProductDetailList,
|
||||
List<ShopProductInfo> shopProductInfoList, List<List<ShopProductItem>> shopProductItemList,
|
||||
List<ShopProductImage> shopProductImageList, List<ShopProductValidPeriod> shopProductValidPeriodList,
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList) {
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList,String priorityMode) {
|
||||
|
||||
// 1. 参数校验
|
||||
if (shopProductBaseList == null || shopProductBaseList.isEmpty()) {
|
||||
@ -5422,7 +5423,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
newProductDataList,updateProductDataList,newShopProductDetailList,updateShopProductDetailList,
|
||||
newShopProductInfoList,updateShopProductInfoList,newShopProductItemList,updateShopProductItemList,
|
||||
newShopProductImageList,updateShopProductImageList,newShopProductValidPeriodList,updateShopProductValidPeriodList,
|
||||
newShopProductAssistIndexList,updateShopProductAssistIndexList);
|
||||
newShopProductAssistIndexList,updateShopProductAssistIndexList,priorityMode);
|
||||
}
|
||||
|
||||
|
||||
@ -5437,7 +5438,8 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<List<ShopProductItem>> newShopProductItemList,List<List<ShopProductItem>> udpateShopProductItemList,
|
||||
List<ShopProductImage> newShopProductImageList, List<ShopProductImage> udpteShopProductImageList,
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList, List<ShopProductValidPeriod> updateShopProductValidPeriodList,
|
||||
List<ShopProductAssistIndex> newShopProductAssistIndexList, List<ShopProductAssistIndex> udpateShopProductAssistIndexList
|
||||
List<ShopProductAssistIndex> newShopProductAssistIndexList, List<ShopProductAssistIndex> udpateShopProductAssistIndexList,
|
||||
String priorityMode
|
||||
) {
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
@ -5577,8 +5579,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
productMappingService.computeProductMapping(newProducts,newProducts.get(0).getStore_id(),false);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateProducts)){//如果时自动优先,则按平台规则切割商品
|
||||
Map map=storeDbConfigService.getPriorityModeCachByStoreId(newProducts.get(0).getStore_id());
|
||||
String priorityMode= (String) map.get(String.valueOf(newProducts.get(0).getStore_id()));
|
||||
if(DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)){
|
||||
productMappingService.computeProductMapping(updateProducts,updateProducts.get(0).getStore_id(),true);
|
||||
}
|
||||
@ -5618,7 +5618,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newShopProductIndex-{}条数据耗时:{}",newShopProductIndex.size(),duration/1000000000);
|
||||
|
||||
boolean esearch_enable = accountBaseConfigService.getConfig("esearch_enable", false);
|
||||
//调用es,create
|
||||
if (esearch_enable) {
|
||||
searchService.batchImport(newShopProductIndex);//创建es
|
||||
}
|
||||
//}
|
||||
|
||||
}
|
||||
@ -5629,6 +5633,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductIndex-{}条数据耗时:{}",updateShopProductIndex.size(),duration/1000000000);
|
||||
boolean esearch_enable = accountBaseConfigService.getConfig("esearch_enable", false);
|
||||
//调用es,create
|
||||
if (esearch_enable) {
|
||||
searchService.batchImport(newShopProductIndex);//创建es
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@ -6103,25 +6112,21 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getProductBasicIdByStore(Integer store_id) {
|
||||
String key=redisService.get(RedisKey.STORESHOPPRODUCTKEY)+":"+store_id;
|
||||
if(null!=redisService.get(key)){
|
||||
return (Map) redisService.get(key);
|
||||
}
|
||||
public Map<String,Long> getProductBasicIdByStore(Integer store_id,List<String> productNumberList) {
|
||||
QueryWrapper<ShopProductBase> queryWrapper=new QueryWrapper();
|
||||
queryWrapper.select("product_number","product_id");
|
||||
productNumberList.forEach(productNumber->{
|
||||
queryWrapper.or(q->q.eq("store_id",store_id).eq("product_number",productNumber));
|
||||
});
|
||||
List<ShopProductBase> shopProductBaseList= this.list(queryWrapper);
|
||||
Map map= shopProductBaseList.stream().collect(Collectors.toMap(shopBase->shopBase.getProduct_number(),shopBase->shopBase.getProduct_id()));
|
||||
redisService.set(RedisKey.STORESHOPPRODUCTKEY,map,60*10);
|
||||
return map;
|
||||
Map<String,Long> resultMap=new HashMap();
|
||||
shopProductBaseList.forEach(shopProductBase->{
|
||||
if(StringUtils.isNotEmpty(shopProductBase.getProduct_number())){
|
||||
resultMap.put(String.valueOf(shopProductBase.getProduct_number()),shopProductBase.getProduct_id());
|
||||
}
|
||||
});
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBasicIdByStore(Integer store_id) {
|
||||
String key=redisService.get(RedisKey.STORESHOPPRODUCTKEY)+":"+store_id;
|
||||
if(null!=redisService.get(key)){
|
||||
redisService.del(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2245,34 +2245,24 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getProductItemIdByStore(Integer store_id) {
|
||||
String key= RedisKey.STORESHOPPRODUCITEMTKEY+":"+store_id;
|
||||
if(null!=redisService.get(key)){
|
||||
return (Map) redisService.get(key);
|
||||
}
|
||||
public Map<String,String> getProductItemIdByStore(Integer store_id,List<String> productNumbers) {
|
||||
QueryWrapper<ShopProductItem> queryWrapper = new QueryWrapper<>();
|
||||
/**
|
||||
* 一对多,如product_id:1002,item_number:120_121;数据格式为item_id,item_id item_unit_price,item_unit_price
|
||||
* 最终组合item_id,item_id_item_unit_price,item_unit_price
|
||||
*/
|
||||
queryWrapper.select("product_id","GROUP_CONCAT(item_id SEPARATOR ',') AS mergedItemId","GROUP_CONCAT(item_unit_price SEPARATOR ',') AS mergedUnitPrices");
|
||||
productNumbers.forEach(productNumber -> {
|
||||
queryWrapper.or(q->q.eq("store_id",store_id).eq("item_src_id",productNumber));
|
||||
});
|
||||
queryWrapper.eq("store_id",store_id);
|
||||
queryWrapper.groupBy("product_id");
|
||||
List<ShopProductItem> shopProductItems= this.list(queryWrapper);
|
||||
|
||||
Map map=shopProductItems.stream().collect(Collectors.toMap(ShopProductItem::getProduct_id,shopProductItem->shopProductItem.getMergedItemId()
|
||||
+"_"+shopProductItem.getMergedUnitPrices()));
|
||||
redisService.set(key,map,60*10);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearProductItemIdByStore(Integer store_id) {
|
||||
String key= RedisKey.STORESHOPPRODUCITEMTKEY+":"+store_id;
|
||||
if(null!=redisService.get(key)){
|
||||
redisService.del(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理库存缓存
|
||||
|
||||
@ -174,7 +174,7 @@ public class ActiveShopJsonUtils {
|
||||
for (int i = 0; i < discountArray.length(); i++) {
|
||||
JSONObject seckillItem = discountArray.getJSONObject(i);
|
||||
if (seckillItem.getInt("item_id") == itemId) {
|
||||
seckillItem.put("price", item.getInt("price"));
|
||||
seckillItem.put("price", item.getBigDecimal("price"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ public class ActiveShopJsonUtils {
|
||||
// 添加新商品
|
||||
JSONObject seckillItem = new JSONObject();
|
||||
seckillItem.put("item_id", itemId);
|
||||
seckillItem.put("price", item.getInt("price"));
|
||||
seckillItem.put("price", item.getBigDecimal("price"));
|
||||
discountArray.put(seckillItem);
|
||||
existingIds.add(itemId);
|
||||
}
|
||||
|
||||
@ -117,11 +117,6 @@ public class SyncThirdDataController {
|
||||
return readSxData(folders,appKey,sign,syncType);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "获取加密密钥", notes = "获取加密密钥")
|
||||
// @RequestMapping(value = "/getAppSign", method = RequestMethod.POST)
|
||||
// public Map<String,Object> getAppSign(@RequestParam String primaryKey) {
|
||||
// return syncAppService.getAppSign(primaryKey);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 客户端查询配置
|
||||
@ -181,6 +176,4 @@ public class SyncThirdDataController {
|
||||
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.suisung.mall.shop.sync.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ActiveMaxDes {
|
||||
|
||||
private BigDecimal total;
|
||||
|
||||
private BigDecimal maxNum;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.suisung.mall.shop.sync.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ActiveModel implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "活动名称")
|
||||
private String activityName;
|
||||
|
||||
@ApiModelProperty(value = "活动类型 1秒杀;2单件折扣,3满减")
|
||||
private Integer activityTypeId;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "活动开始时间")
|
||||
private Date activityStarttime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "活动结束时间")
|
||||
private Date activityEndtime;
|
||||
|
||||
@ApiModelProperty(value = "活动状态(ENUM):0-未开启;1-正常;2-已结束;3-管理员关闭;4-商家关闭")
|
||||
private Integer activityState;
|
||||
|
||||
@ApiModelProperty(value = "发布时间")
|
||||
private Date activityReleasetime;
|
||||
|
||||
@ApiModelProperty(value = "折扣")
|
||||
private BigDecimal discount;
|
||||
|
||||
@ApiModelProperty(value = "满减规则")
|
||||
private List<ActiveMaxDes> activeMaxDesList;
|
||||
|
||||
@ApiModelProperty(value = "活动id")
|
||||
private String flowNo;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.suisung.mall.shop.sync.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ActiveShopInfo {
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String itemNo;
|
||||
|
||||
@ApiModelProperty(value = "活动名称")
|
||||
private String activityName;
|
||||
|
||||
@ApiModelProperty(value = "活动类型 1秒杀;2单件折扣,3满减")
|
||||
private Integer activityTypeId;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "活动开始时间")
|
||||
private Date activityStarttime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "活动结束时间")
|
||||
private Date activityEndtime;
|
||||
|
||||
@ApiModelProperty(value = "折扣")
|
||||
private BigDecimal discount;
|
||||
|
||||
@ApiModelProperty(value = "活动状态(ENUM):0-未开启;1-正常;2-已结束;3-管理员关闭;4-商家关闭")
|
||||
private Integer activityState;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal oldPrice;//原价
|
||||
|
||||
@ApiModelProperty(value = "折后价")
|
||||
private BigDecimal specPrice;//折后价
|
||||
|
||||
@ApiModelProperty(value = "活动id")
|
||||
private String flowNo;
|
||||
}
|
||||
@ -15,9 +15,9 @@ public class RedisKey {
|
||||
|
||||
public static final String STOREDATAPRODUCTSPECITEM="storedata:ProductSpecItem";
|
||||
|
||||
public static final String STORESHOPPRODUCTKEY="storedata:shopProductkey";
|
||||
|
||||
public static final String STORESHOPPRODUCITEMTKEY="storedata:shopProductItemKey";
|
||||
|
||||
public static final String STOREDBDATAPRIORITYMODEKEY="storedbdata:priorityModeKey";
|
||||
|
||||
|
||||
public static final String STOREDATACCOUNTBASEID="storedata:accountBaseId";
|
||||
}
|
||||
|
||||
@ -204,11 +204,12 @@ public class StoreDbConfigServiceImpl extends BaseServiceImpl<StoreDbConfigMappe
|
||||
return (Map)redisService.get(key);
|
||||
}
|
||||
QueryWrapper<StoreDbConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
queryWrapper.select("priority_mode");
|
||||
StoreDbConfig dbConfig= this.getOne(queryWrapper);
|
||||
queryWrapper.eq("store_id", String.valueOf(storeId));
|
||||
StoreDbConfig dbConfig= this.findOne(queryWrapper);
|
||||
Map map=new HashMap();
|
||||
map.put(String.valueOf(storeId),dbConfig.getPriorityMode());
|
||||
redisService.hSetAll(key,map,60*10);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.enums.DicEnum;
|
||||
@ -33,6 +34,7 @@ import com.suisung.mall.common.modules.store.ShopStoreActivityBase;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.pojo.dto.LibraryProductDTO;
|
||||
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
@ -184,7 +186,6 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
if(CollectionUtil.isNotEmpty(libraryProductDTOS)){
|
||||
secondCate.setCategory_image(libraryProductDTOS.get(0).getThumb());
|
||||
}
|
||||
|
||||
if (productCategoryService.saveOrUpdate(secondCate)) {
|
||||
// 当前子分类的第二级父类id
|
||||
list.get(i).setCategory_parent_id(secondCate.getId());
|
||||
@ -448,6 +449,112 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量保存会员
|
||||
* @param memberList
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
public int baseBatchSaveOrUpdateMemberBatch(List<SyncThirdMemberReq> memberList,String storeId){
|
||||
int count = 0;
|
||||
List<String> moblies=new ArrayList<>();
|
||||
for (SyncThirdMemberReq member : memberList) {
|
||||
String user_mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(member.getUser_mobile(), CommonConstant.IDD_ZH_CN);//+86
|
||||
moblies.add(user_mobile);
|
||||
}
|
||||
Map<String, Integer> stringIntegerMap= accountService.getAccountsMapByMobile(moblies);
|
||||
//Map<String, Integer> stringIntegerMap= new HashMap<>();
|
||||
if(stringIntegerMap.keySet().size()==memberList.size()){//如果查到的数据全部匹配,就是全部存在,没有走下去的必要了
|
||||
return count;
|
||||
}
|
||||
//去除已存在的手机号
|
||||
List<SyncThirdMemberReq> addMemberList=new ArrayList<>();
|
||||
for (SyncThirdMemberReq member : memberList) {
|
||||
String user_mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(member.getUser_mobile(), CommonConstant.IDD_ZH_CN);//+86
|
||||
if (!stringIntegerMap.containsKey(user_mobile)) {
|
||||
addMemberList.add(member);
|
||||
}
|
||||
}
|
||||
//计算userId
|
||||
List<Integer> accountBaseIds=shopNumberSeqService.getBatchUserAccountBaseId(addMemberList.size());
|
||||
List<AccountUserBase> addAccountUserBases=new ArrayList<>();
|
||||
List<AccountUserInfo> addAcountUserInfo=new ArrayList<>();
|
||||
List<PayUserResource> addPayUserResource=new ArrayList<>();
|
||||
for (int i = 0; i < accountBaseIds.size(); i++) {
|
||||
// account_user_base
|
||||
SyncThirdMemberReq syncThirdMemberReq=addMemberList.get(i);
|
||||
Integer userId=accountBaseIds.get(i);
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
String user_mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(syncThirdMemberReq.getUser_mobile(), CommonConstant.IDD_ZH_CN);//+86
|
||||
accountUserBase.setUser_id(userId);
|
||||
accountUserBase.setUser_account(user_mobile);
|
||||
accountUserBase.setUser_nickname(syncThirdMemberReq.getUser_nickname());
|
||||
accountUserBase.setUser_state(2);// 状态(ENUM):0-锁定;1-未激活;2-已激活;
|
||||
accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL);
|
||||
accountUserBase.setStore_ids(storeId);
|
||||
accountUserBase.setRights_group_id("0");// 普通用户,不是商家
|
||||
accountUserBase.setUser_type(CommonConstant.USER_TYPE_NORMAL);
|
||||
|
||||
// 默认给了随机密码和盐,token
|
||||
String user_key = IdUtil.simpleUUID();
|
||||
String user_salt = IdUtil.simpleUUID();
|
||||
String user_token = IdUtil.simpleUUID();
|
||||
accountUserBase.setUser_salt(user_salt);
|
||||
accountUserBase.setUser_token(user_token);
|
||||
accountUserBase.setUser_key(user_key);
|
||||
accountUserBase.setUser_password(SecureUtil.md5(user_salt + SecureUtil.md5(IdUtil.simpleUUID())));
|
||||
addAccountUserBases.add(accountUserBase);
|
||||
// account_user_info
|
||||
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||
accountUserInfo.setUser_id(userId);
|
||||
accountUserInfo.setUser_type_id(0);
|
||||
accountUserInfo.setUser_mobile(user_mobile);
|
||||
accountUserInfo.setUser_level_card(syncThirdMemberReq.getUser_level_card());
|
||||
//user_level_id
|
||||
accountUserInfo.setUser_level_id(1); // todo select id
|
||||
accountUserInfo.setUser_gender(syncThirdMemberReq.getUser_gender());
|
||||
accountUserInfo.setUser_mobile(syncThirdMemberReq.getUser_mobile());
|
||||
accountUserInfo.setUser_intl(CommonConstant.IDD_ZH_CN);
|
||||
if(null!=syncThirdMemberReq.getUser_birthday()){
|
||||
accountUserInfo.setUser_birthday(DateTimeUtils.parseDate(syncThirdMemberReq.getUser_birthday(), "yyyy-MM-dd"));
|
||||
}
|
||||
addAcountUserInfo.add(accountUserInfo);
|
||||
if (syncThirdMemberReq.getUser_money() != null || syncThirdMemberReq.getUser_points() != null) {
|
||||
// pay_user_resource 用户支付资源,积分,余额
|
||||
PayUserResource payUserResource = new PayUserResource();
|
||||
payUserResource.setUser_id(userId);
|
||||
payUserResource.setUser_money(BigDecimal.ZERO);
|
||||
payUserResource.setUser_money_frozen(BigDecimal.ZERO);
|
||||
payUserResource.setUser_points(BigDecimal.ZERO);
|
||||
payUserResource.setUser_points_frozen(BigDecimal.ZERO);
|
||||
addPayUserResource.add(payUserResource);
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
if(!addAccountUserBases.isEmpty()){
|
||||
ThirdApiRes thirdApiRes=accountService.saveBatchAccountBase(addAccountUserBases);
|
||||
if(thirdApiRes.getError_code()!=0){
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
if(!addAcountUserInfo.isEmpty()){
|
||||
ThirdApiRes thirdApiRes= accountService.saveBatchAccountInfo(addAcountUserInfo);
|
||||
if(thirdApiRes.getError_code()!=0){
|
||||
throw new ApiException(ResultCode.FAILED,"addAcountUserInfo保存异常");
|
||||
}
|
||||
}
|
||||
|
||||
if(!addPayUserResource.isEmpty()){
|
||||
ThirdApiRes thirdApiRes= payService.saveBatchPayUserResources(addPayUserResource);
|
||||
if(thirdApiRes.getError_code()!=0){
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* List<SxSyncVip> 转换为 List<SyncThirdMemberReq>
|
||||
* @param sxSyncVipList
|
||||
@ -548,7 +655,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
public int baseSaveOrUpdateGoodsBatch(JSONArray goodsListJSON,String storeId,String isNegativeAllowed){
|
||||
public int baseSaveOrUpdateGoodsBatch(JSONArray goodsListJSON,String storeId,String isNegativeAllowed,String priorityMode){
|
||||
AtomicInteger resultCount = new AtomicInteger();
|
||||
Map categoryMap= productCategoryService.getCategoryListByStoreId(storeId);//热数据加载
|
||||
List<ShopProductBase> shopProductBaseList=new ArrayList<>();
|
||||
@ -724,7 +831,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
shopProductBaseService.saveProductBatch(shopProductBaseList,shopProductIndexList,shopProductDataList,shopProductDetailList,shopProductInfoList,shopProductItemLists,
|
||||
shopProductImageList,
|
||||
new ArrayList<ShopProductValidPeriod>(),
|
||||
new ArrayList<ShopProductAssistIndex>());
|
||||
new ArrayList<ShopProductAssistIndex>(),priorityMode);
|
||||
|
||||
return resultCount.get();
|
||||
}
|
||||
@ -863,17 +970,27 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
shopStoreActivityBase.setActivity_name(jsonObj.getStr("activityName"));
|
||||
shopStoreActivityBase.setActivity_state(jsonObj.getInt("activityState"));
|
||||
shopStoreActivityBase.setActivity_starttime(jsonObj.getDate("activityStarttime"));
|
||||
shopStoreActivityBase.setFlow_no(jsonObj.getStr("flowNo"));
|
||||
return shopStoreActivityBase;
|
||||
})
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<ShopStoreActivityBase> existing = batchGetByAtiveShopBase(storeProductPairs,storeId);
|
||||
return existing.stream()
|
||||
.collect(Collectors.toMap(
|
||||
shopStoreActivityBase -> shopStoreActivityBase.getActivity_title()+"_"+shopStoreActivityBase.getActivity_starttime().getTime()+"_"+shopStoreActivityBase.getActivity_state(),
|
||||
shopStoreActivityBase->shopStoreActivityBase.getActivity_id()+"_"+shopStoreActivityBase.getActivity_rule()
|
||||
));
|
||||
|
||||
Map<String,String> resultMap=new HashMap<>();
|
||||
|
||||
existing.forEach(shopStoreActivityBase -> {
|
||||
resultMap.put(shopStoreActivityBase.getActivity_name()+"_"+shopStoreActivityBase.getActivity_starttime().getTime()+"_"+shopStoreActivityBase.getActivity_state()+"_"+shopStoreActivityBase.getFlow_no(),shopStoreActivityBase.getActivity_id()+"__"+(StringUtils.isEmpty(shopStoreActivityBase.getActivity_rule())?"0":shopStoreActivityBase.getActivity_rule()));
|
||||
});
|
||||
|
||||
return resultMap;
|
||||
|
||||
// return existing.stream()
|
||||
// .collect(Collectors.toMap(
|
||||
// shopStoreActivityBase -> shopStoreActivityBase.getActivity_name()+"_"+shopStoreActivityBase.getActivity_starttime()+"_"+shopStoreActivityBase.getActivity_state(),
|
||||
// shopStoreActivityBase->shopStoreActivityBase.getActivity_id()+"_"+(StringUtils.isEmpty(shopStoreActivityBase.getActivity_rule())?"0":shopStoreActivityBase.getActivity_rule())
|
||||
// ));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -884,10 +1001,11 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
QueryWrapper<ShopStoreActivityBase> query = new QueryWrapper<>();
|
||||
query.select("activity_name", "activity_state");
|
||||
query.select("activity_name", "activity_state","activity_starttime","activity_rule","activity_endtime","activity_id","flow_no");
|
||||
shopStoreActivityBases.forEach(shopStoreActivityBase -> {
|
||||
query.or(q -> q.eq("activity_name", shopStoreActivityBase.getActivity_name()).eq("activity_state",shopStoreActivityBase.getActivity_state())
|
||||
.eq("activity_starttime",shopStoreActivityBase.getActivity_starttime())
|
||||
.eq("flow_no",shopStoreActivityBase.getFlow_no())
|
||||
.eq("store_id", storeId));
|
||||
});
|
||||
|
||||
|
||||
@ -23,10 +23,15 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.qcloud.cos.model.COSObjectSummary;
|
||||
import com.suisung.mall.common.adapter.BigDecimalTypeAdapter;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.enums.DicEnum;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
||||
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncGoods;
|
||||
@ -61,9 +66,12 @@ import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
|
||||
import com.suisung.mall.shop.sync.Utils.ActiveShopJsonUtils;
|
||||
import com.suisung.mall.shop.sync.Utils.BigDecimalFormatter;
|
||||
import com.suisung.mall.shop.sync.Utils.ThreadFileUtils;
|
||||
import com.suisung.mall.shop.sync.dto.ActiveModel;
|
||||
import com.suisung.mall.shop.sync.dto.ActiveShopInfo;
|
||||
import com.suisung.mall.shop.sync.dto.BrandModel;
|
||||
import com.suisung.mall.shop.sync.keymanage.RedisKey;
|
||||
import com.suisung.mall.shop.sync.service.*;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -79,6 +87,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
@ -99,6 +108,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.I18nUtil._;
|
||||
|
||||
|
||||
@Service
|
||||
public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements SyncThirdDataService {
|
||||
@ -157,6 +168,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
|
||||
@Autowired
|
||||
private SyncShopImageService syncShopImageService;
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
/**
|
||||
* 批量保存商品的分类
|
||||
@ -270,6 +283,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
// @Transactional
|
||||
public ThirdApiRes saveOrUpdateMemberBatch(String appKey, String sign, List<SyncThirdMemberReq> memberList) {
|
||||
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || CollUtil.isEmpty(memberList)) {
|
||||
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||
@ -287,8 +302,15 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (memberList.size() > limitCnt) {
|
||||
return new ThirdApiRes().fail(1004, I18nUtil._("单次同步记录最多" + limitCnt + "条!"));
|
||||
}
|
||||
shopNumberSeqService.clearKeyStoreAccountBaseId();
|
||||
int count =0;
|
||||
try {
|
||||
count= baseBatchSaveOrUpdateMemberBatch(memberList, storeId);
|
||||
}catch (RuntimeException e) {
|
||||
throw new ApiException(_("保存失败"+e.getMessage()));
|
||||
}
|
||||
|
||||
int count = baseSaveOrUpdateMemberBatch(memberList, storeId);
|
||||
// shopNumberSeqService.clearKeyStoreAccountBaseId();
|
||||
Map<String, Integer> resp = new HashMap<>();
|
||||
resp.put("count", count);
|
||||
|
||||
@ -554,6 +576,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
for (int i = 0; i < newFolders.size(); i++) {
|
||||
final int taskId = i;
|
||||
final String isNegativeAllowed=storeDbConfig.getIsNegativeAllowed();
|
||||
String priorityMode=storeDbConfig.getPriorityMode();
|
||||
threadNum.incrementAndGet();
|
||||
futures.add(executor.submit(() -> {
|
||||
int count = 0;//失败重试机制,当失败重试一次,再次失败则记录到数据库中
|
||||
@ -563,7 +586,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
String fileName = "good_" + (taskId + 1) + ".txt";
|
||||
JSONArray jsonArray = new ThreadFileUtils().processFolder(taskName, newFolders.get(taskId));
|
||||
try {
|
||||
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed);
|
||||
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed,priorityMode);
|
||||
success.getAndIncrement();
|
||||
threadNum.decrementAndGet();
|
||||
return "成功" + taskId;
|
||||
@ -725,7 +748,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign)) {
|
||||
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||
}
|
||||
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncAppO = syncAppService.getOne(new LambdaQueryWrapper<SyncApp>()
|
||||
.select(SyncApp::getApp_key, SyncApp::getApp_secret, SyncApp::getStore_id)
|
||||
@ -799,7 +821,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (StrUtil.isBlank(productKey) || delta == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 使用 Redis 的 HINCRBY 保证原子性和高性能
|
||||
redisTemplate.opsForHash().increment(RedisKey.STOREDATARELEASE, productKey, delta);
|
||||
@ -919,10 +940,12 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
return;
|
||||
}
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncAppO = syncAppService.getOne(new LambdaQueryWrapper<SyncApp>()
|
||||
.select(SyncApp::getApp_key, SyncApp::getApp_secret,SyncApp::getStore_id)
|
||||
.eq(SyncApp::getApp_key, appKey)
|
||||
.eq(SyncApp::getApp_secret,sign));
|
||||
List<ActiveModel> activeModelList= activeJsonArray.toList(ActiveModel.class);
|
||||
Gson gson=new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
|
||||
.create();
|
||||
String gsonStr= gson.toJson(activeModelList);
|
||||
SyncApp syncAppO = syncAppService.checkAppSign(appKey,sign,gsonStr);
|
||||
if (syncAppO == null) {
|
||||
logger.error("签名有误!");
|
||||
return;
|
||||
@ -940,6 +963,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
List<ShopStoreActivityBase> addshopStoreActivityBaseList=new ArrayList<>();
|
||||
List<ShopStoreActivityBase> updateShopStoreActivityBaseList=new ArrayList<>();
|
||||
Map<String, String> stringIntegerMap= checkExistingActive(jsonArray,storeId);
|
||||
AccountUserBase accountUserBase=new AccountUserBase();
|
||||
accountUserBase.setUser_is_admin(1);
|
||||
accountUserBase.setStore_ids("1");
|
||||
AccountUserBase accountUserBases=accountService.findOneAccountUserBase(accountUserBase);
|
||||
Integer userId= accountUserBases.getUser_id();
|
||||
jsonArray.stream().parallel().forEach(object->{
|
||||
final JSONObject jsonObj= (JSONObject) object;
|
||||
String activityName=jsonObj.getStr("activityName");
|
||||
@ -963,13 +991,14 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
Date activityStarttime=jsonObj.getDate("activityStarttime");
|
||||
Date activityEndtime=jsonObj.getDate("activityEndtime");
|
||||
Integer activityState=jsonObj.getInt("activityState");
|
||||
Date activityReleasetime= jsonObj.getDate("activityReleasetime");
|
||||
String flowNo=jsonObj.getStr("flowNo");
|
||||
// Date activityReleasetime= jsonObj.getDate("activityReleasetime");
|
||||
BigDecimal discount=jsonObj.getBigDecimal("discount");
|
||||
String key=activityName+"_"+activityStarttime.getTime()+"_"+activityState;
|
||||
String key=activityName+"_"+activityStarttime.getTime()+"_"+activityState+"_"+flowNo;
|
||||
shopStoreActivityBase.setActivity_state(activityState);
|
||||
shopStoreActivityBase.setActivity_name(activityName);
|
||||
shopStoreActivityBase.setActivity_type(1);//免费参与
|
||||
shopStoreActivityBase.setActivity_releasetime(activityReleasetime);
|
||||
// shopStoreActivityBase.setActivity_releasetime(activityReleasetime);
|
||||
shopStoreActivityBase.setStore_id(storeId);
|
||||
shopStoreActivityBase.setActivity_on_is_off(0);
|
||||
shopStoreActivityBase.setActivity_type_id(activityTypeId);
|
||||
@ -977,12 +1006,18 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
shopStoreActivityBase.setActivity_endtime(activityEndtime);
|
||||
shopStoreActivityBase.setActivity_state(activityState);
|
||||
shopStoreActivityBase.setSubsite_id(0);
|
||||
shopStoreActivityBase.setUser_id(userId);
|
||||
shopStoreActivityBase.setFlow_no(flowNo);
|
||||
if(stringIntegerMap.containsKey(key)){//更新
|
||||
String keyVal= MapUtil.getStr(stringIntegerMap,key);
|
||||
shopStoreActivityBase.setActivity_id(MapUtil.getInt(stringIntegerMap,keyVal.split("_")[0]));
|
||||
updateShopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
synchronized(updateShopStoreActivityBaseList){
|
||||
updateShopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
}
|
||||
}else {
|
||||
addshopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
synchronized(addshopStoreActivityBaseList) {
|
||||
addshopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@ -992,7 +1027,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if(CollectionUtil.isNotEmpty(updateShopStoreActivityBaseList)){
|
||||
shopStoreActivityBaseService.updateBatchById(updateShopStoreActivityBaseList);
|
||||
}
|
||||
|
||||
logger.info("同步活动数据结束:共{}条数据更新,{}条数据新增",updateShopStoreActivityBaseList.size(),addshopStoreActivityBaseList.size());
|
||||
}
|
||||
|
||||
|
||||
@ -1012,10 +1047,13 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
return;
|
||||
}
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncAppO = syncAppService.getOne(new LambdaQueryWrapper<SyncApp>()
|
||||
.select(SyncApp::getApp_key, SyncApp::getApp_secret,SyncApp::getStore_id)
|
||||
.eq(SyncApp::getApp_key, appKey)
|
||||
.eq(SyncApp::getApp_secret,sign));
|
||||
List<ActiveShopInfo> activeShopInfos= activeJsonArray.toList(ActiveShopInfo.class);
|
||||
Gson gson=new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
|
||||
.registerTypeAdapter(BigDecimal.class,new BigDecimalTypeAdapter())
|
||||
.create();
|
||||
String gsonStr= gson.toJson(activeShopInfos);
|
||||
SyncApp syncAppO = syncAppService.checkAppSign(appKey,sign,gsonStr);
|
||||
if (syncAppO == null) {
|
||||
logger.error("签名有误!");
|
||||
return;
|
||||
@ -1023,6 +1061,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
String storeId = syncAppO.getStore_id();
|
||||
//把商品添加到活动的逻辑
|
||||
batchAddActiveShopBase(activeJsonArray, Integer.valueOf(storeId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1032,8 +1071,17 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
private void batchAddActiveShopBase(JSONArray jsonArray,Integer storeId) {
|
||||
List<ShopStoreActivityBase> updateShopStoreActivityBaseList=new ArrayList<>();
|
||||
Map<String, String> stringIntegerMap= checkExistingActive(jsonArray,storeId);
|
||||
Map shopProduckKeyMap=shopProductBaseService.getProductBasicIdByStore(storeId);//获取货架号对应的商品id
|
||||
Map shopItemKeyMap=shopProductItemService.getProductItemIdByStore(storeId);//获取商品id对应的item的id
|
||||
List<String> productNumbers=new ArrayList<>();
|
||||
jsonArray.stream().parallel().forEach(object->{
|
||||
final JSONObject jsonObj= (JSONObject) object;
|
||||
synchronized (productNumbers) {
|
||||
String itemNo=jsonObj.getStr("itemNo");
|
||||
productNumbers.add(itemNo);
|
||||
}
|
||||
});
|
||||
Map<String,Long> shopProduckKeyMap=shopProductBaseService.getProductBasicIdByStore(storeId,productNumbers);//获取货架号对应的商品id
|
||||
Map<String,String> shopItemKeyMap=shopProductItemService.getProductItemIdByStore(storeId,productNumbers);//获取商品id对应的item的id
|
||||
|
||||
Map<String,String> rulesChe=new HashMap();//存储rule格式activeId:rules,如果不存在则从数据库取,存在则从缓存取数据
|
||||
jsonArray.forEach(object->{
|
||||
final JSONObject jsonObj= (JSONObject) object;
|
||||
@ -1044,12 +1092,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
}
|
||||
String ruleType="";
|
||||
List<org.json.JSONObject> newItems=new ArrayList<>();
|
||||
ShopStoreActivityBase shopStoreActivityBase=new ShopStoreActivityBase();
|
||||
Integer productId=null;
|
||||
Long productId=null;
|
||||
String itemNo=jsonObj.getStr("itemNo");
|
||||
BigDecimal discount=jsonObj.getBigDecimal("discount");
|
||||
if(shopProduckKeyMap.containsKey(itemNo)){
|
||||
productId= (Integer) shopProduckKeyMap.get(itemNo);
|
||||
productId= (Long) shopProduckKeyMap.get(itemNo);
|
||||
}
|
||||
if(null==productId){
|
||||
return;
|
||||
@ -1057,8 +1104,9 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
|
||||
Date activityStarttime=jsonObj.getDate("activityStarttime");
|
||||
Integer activityState=jsonObj.getInt("activityState");
|
||||
String flowNo=jsonObj.getStr("flowNo");
|
||||
|
||||
String key=activityName+"_"+activityStarttime.getTime()+"_"+activityState;
|
||||
String key=activityName+"_"+activityStarttime.getTime()+"_"+activityState+"_"+flowNo;
|
||||
|
||||
if(stringIntegerMap.containsKey(key)){//更新
|
||||
String keyVal=MapUtil.getStr(stringIntegerMap,key);
|
||||
@ -1067,12 +1115,12 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if(null!=rulesChe.get(activityId)){
|
||||
rules=rulesChe.get(activityId);
|
||||
}else {
|
||||
rules=keyVal.split("_")[1];
|
||||
}
|
||||
String itemIds= (String) shopItemKeyMap.get(productId);
|
||||
if(null!=itemIds){
|
||||
itemIds= (String) shopItemKeyMap.get(String.valueOf(productId));
|
||||
rules=keyVal.split("__")[1].equals("0")?null:keyVal.split("_")[1];
|
||||
}
|
||||
String itemIds= shopItemKeyMap.get(productId);
|
||||
// if(null!=itemIds){
|
||||
// itemIds= (String) shopItemKeyMap.get(String.valueOf(productId));
|
||||
// }
|
||||
assert itemIds != null;
|
||||
if (activityTypeId == 1) {//限时秒杀
|
||||
ruleType=ActiveShopJsonUtils.SECKILL;
|
||||
@ -1095,18 +1143,27 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
ruleType=ActiveShopJsonUtils.FULLREDUCE;
|
||||
newItems.addAll(getFulReduItemList(itemIds,ruleType,null));//获取满减规则的itemid
|
||||
}
|
||||
shopStoreActivityBase.setActivity_id(MapUtil.getInt(stringIntegerMap,activityId));
|
||||
|
||||
String newRules= ActiveShopJsonUtils.buildPromotionRule(ruleType,rules,newItems);
|
||||
rulesChe.put(activityId,newRules);
|
||||
shopStoreActivityBase.setActivity_rule(rules);
|
||||
updateShopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!rulesChe.isEmpty()){
|
||||
rulesChe.forEach((k,v)->{
|
||||
if(StringUtils.isNotEmpty(v)){
|
||||
ShopStoreActivityBase shopStoreActivityBase=new ShopStoreActivityBase();
|
||||
shopStoreActivityBase.setActivity_id(Integer.valueOf(k));
|
||||
shopStoreActivityBase.setActivity_rule(v);
|
||||
updateShopStoreActivityBaseList.add(shopStoreActivityBase);
|
||||
}
|
||||
});
|
||||
}
|
||||
if(CollectionUtil.isNotEmpty(updateShopStoreActivityBaseList)){
|
||||
shopStoreActivityBaseService.updateBatchById(updateShopStoreActivityBaseList);
|
||||
}
|
||||
|
||||
logger.info("同步活动商品数据结束:更新共{}条活动数据,商品数据为{}条",updateShopStoreActivityBaseList.size(),jsonArray.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1159,13 +1216,14 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
for (int i=0;i<itemIdsArray.length;i++) {
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject();
|
||||
jsonObject.put("item_id", itemIdsArray[i]);
|
||||
jsonObject.put("price", BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(unitPricesArray[i]))));
|
||||
|
||||
jsonObject.put("price", BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(unitPricesArray[i])).setScale(2,RoundingMode.HALF_UP)));
|
||||
newItems.add(jsonObject);
|
||||
}
|
||||
}else {
|
||||
org.json.JSONObject jsonObject=new org.json.JSONObject();
|
||||
jsonObject.put("item_id",itemIds);
|
||||
jsonObject.put("price", BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(unitPrices))));
|
||||
jsonObject.put("price", BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(unitPrices)).setScale(2,RoundingMode.HALF_UP)));
|
||||
newItems.add(jsonObject);
|
||||
}
|
||||
break;
|
||||
|
||||
1
sql/shop/dev/20250703_ddl.sql
Normal file
1
sql/shop/dev/20250703_ddl.sql
Normal file
@ -0,0 +1 @@
|
||||
alter table shop_store_activity_base add column flow_no varchar(255) DEFAULT NULL COMMENT '思迅活动id';
|
||||
Loading…
Reference in New Issue
Block a user