活动客户端代码提交
This commit is contained in:
parent
7c7e5f62b8
commit
801a5f9ee3
@ -21,9 +21,19 @@ public class WebController {
|
||||
@Autowired
|
||||
private SxDataService sxDataService;
|
||||
|
||||
@RequestMapping("/upload")
|
||||
@RequestMapping("/test")
|
||||
public void upload(){
|
||||
System.out.println("upload");
|
||||
CommentModel commentModel= sxDataService.getCommentModel();
|
||||
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
|
||||
if(dataBaseInfo==null){
|
||||
log.error("syncGoods dataBaseInfo is null");
|
||||
return;
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
}
|
||||
// sxDataService.getCategoryChildren(new DataBaseInfo(),"0101");
|
||||
System.out.println(sxDataService.getCategoryChildren(dataBaseInfo,"01"));
|
||||
//webClientService.uploudSxData();
|
||||
}
|
||||
|
||||
@ -120,7 +130,19 @@ public class WebController {
|
||||
|
||||
@RequestMapping("/syncStoreData")
|
||||
public void syncStoreData(){
|
||||
sxDataService.syncStoreData(new DataBaseInfo(),sxDataService.getCommentModel());
|
||||
CommentModel commentModel= sxDataService.getCommentModel();
|
||||
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
|
||||
if(dataBaseInfo==null){
|
||||
log.error("syncGoods dataBaseInfo is null");
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(commentModel.getSyncTime())){
|
||||
commentModel =sxDataService.getCommentModel();
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
}
|
||||
sxDataService.syncStoreData(dataBaseInfo,commentModel);
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +158,7 @@ public class WebController {
|
||||
commentModel =sxDataService.getCommentModel();
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
commentModel.setSyncTime(DateUtil.formatDate(dataBaseInfo.getRefreshTime()));
|
||||
}
|
||||
sxDataService.syncAtive(new DataBaseInfo(),commentModel);
|
||||
// sxDataService.syncAtive(new DataBaseInfo(),new CommentModel());
|
||||
@ -154,7 +176,7 @@ public class WebController {
|
||||
commentModel =sxDataService.getCommentModel();
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||
commentModel.setSyncTime(DateUtil.formatDate(dataBaseInfo.getRefreshTime()));
|
||||
}
|
||||
sxDataService.syncAtiveShops(new DataBaseInfo(),commentModel);
|
||||
//sxDataService.syncAtiveShops(new DataBaseInfo(),new CommentModel());
|
||||
|
||||
@ -55,6 +55,9 @@ public class SxDataDao extends BaseDao{
|
||||
public final static String DEFAULT_IMG="https://digitalassets.tesla.com/tesla-contents/image/upload/f_auto,q_auto/Homepage-Model-Y-2-Promo-Hero-Tablet-CN.png";
|
||||
|
||||
|
||||
private final static String T_PUB_PLAN_MASTER="t_pub_plan_master";//活动方案表
|
||||
private final static String T_PUB_PLAN_DETAIL_B="t_pub_plan_detail_b";//活动商品表
|
||||
private final static String PLAN_NO="plan_no";//活动方案表排序字段
|
||||
/**
|
||||
* 查找商品分类数据
|
||||
* @param dataBaseInfo
|
||||
@ -601,6 +604,17 @@ public class SxDataDao extends BaseDao{
|
||||
where);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataBaseInfo
|
||||
* @return
|
||||
*/
|
||||
public Integer getNewActiveCount(DataBaseInfo dataBaseInfo){
|
||||
String where=dataBaseInfo.getWhere()+" and rule_no in('DD','PS','PM') and range_flag='I'";
|
||||
return getBaseTotal(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName(),
|
||||
T_PUB_PLAN_MASTER,where);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataBaseInfo
|
||||
@ -712,4 +726,141 @@ public class SxDataDao extends BaseDao{
|
||||
return clsBrandDtos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*获取促销活动价格 时段特价单
|
||||
* @param dataBaseInfo
|
||||
* DD-直接折扣 t_pub_plan_sendext t_pub_plan_detail_b
|
||||
* PS-直接特价 t_pub_plan_detail_b
|
||||
* PM-im促销 t_pub_plan_detail_b
|
||||
* range_flag='I' 代表按商品维度促销
|
||||
* @return
|
||||
*/
|
||||
public List<ActiveDto> getNewActiveList(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
|
||||
String where=dataBaseInfo.getWhere()+" and rule_no in('DD','PS','PM') and range_flag='I'";
|
||||
ResultDto resultDto=baseFindListPage(dataBaseInfo.getIp()
|
||||
,dataBaseInfo.getUserName()
|
||||
,dataBaseInfo.getPassword()
|
||||
,dataBaseInfo.getDbPort()
|
||||
,dataBaseInfo.getDataBaseName()
|
||||
,T_PUB_PLAN_MASTER
|
||||
,PLAN_NO
|
||||
,pageNo
|
||||
,pageSize
|
||||
,where);
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
List<ActiveDto> activeDtos=new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
ActiveDto activeDto=new ActiveDto();
|
||||
String specialType=rs.getString("rule_no").trim();
|
||||
String activityName=rs.getString("plan_name").trim();
|
||||
if(specialType.equals("DD")){//折扣
|
||||
activeDto.setActivityTypeId(2);
|
||||
}
|
||||
if(specialType.equals("PS")||specialType.equals("PM")){//特价(秒杀)
|
||||
activeDto.setActivityTypeId(1);
|
||||
}
|
||||
if(specialType.equals("E")){//满减 todo
|
||||
|
||||
}
|
||||
activeDto.setActivityName(activityName);
|
||||
activeDto.setActivity_remark(rs.getString("plan_memo").trim());
|
||||
activeDto.setFlowNo(rs.getString("plan_no"));
|
||||
activeDto.setActivityReleasetime(rs.getDate("oper_date"));
|
||||
activeDto.setActivityStarttime(rs.getDate("begin_date"));
|
||||
activeDto.setActivityEndtime(rs.getDate("end_date"));
|
||||
if(DateUtil.compare(activeDto.getActivityEndtime(),DateUtil.date())>0){
|
||||
activeDto.setActivityState(1);//正常进行中
|
||||
}else {
|
||||
activeDto.setActivityState(2);//结束
|
||||
}
|
||||
activeDtos.add(activeDto);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
resultDto.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return activeDtos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取折扣商品
|
||||
* @param dataBaseInfo
|
||||
* @return
|
||||
*/
|
||||
public List<ActiveShopInfo> getSpecShops(DataBaseInfo dataBaseInfo,int pageNo,int pageSize){
|
||||
String where=dataBaseInfo.getWhere()+" and b.range_flag='I' and rule_no in('DD','PS','PM')";
|
||||
ResultDto resultDto=baseFindListJoinPage(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName(),
|
||||
T_PUB_PLAN_DETAIL_B,T_PUB_PLAN_MASTER,"plan_no","plan_no","flow_id","t.rule_no,t.plan_name,t.begin_date,t.end_date",pageNo,pageSize,where);
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
List<ActiveShopInfo> activeShopInfos=new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
ActiveShopInfo activeShopInfo=new ActiveShopInfo();
|
||||
activeShopInfo.setItemNo(rs.getString("item_no").trim());
|
||||
String specialType=rs.getString("rule_no").trim();
|
||||
String activityName=rs.getString("plan_name").trim();
|
||||
if(specialType.equals("DD")){//折扣 折扣和满减分类比较多,目前只同步商品级别的
|
||||
BigDecimal discount=rs.getBigDecimal("value");
|
||||
//String discountStr=BigDecimalFormatter.formatWithoutTrailingZeros(discount.multiply(new BigDecimal(10)));
|
||||
// activeShopInfo.setActivityName(activityName);
|
||||
activeShopInfo.setDiscount(discount);
|
||||
activeShopInfo.setActivityTypeId(2);
|
||||
}
|
||||
if(specialType.equals("PS")||specialType.equals("PM")){//特价(秒杀)
|
||||
//activeShopInfo.setActivityName(activityName);
|
||||
activeShopInfo.setOldPrice(rs.getBigDecimal("num2"));
|
||||
activeShopInfo.setSpecPrice(rs.getBigDecimal("value"));
|
||||
activeShopInfo.setActivityTypeId(1);
|
||||
}
|
||||
// if(specialType.equals("FR")){//满减 todo 没有同步
|
||||
// String total1=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("old_price"));
|
||||
// String max1=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("spe_price"));
|
||||
// String max2=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("spe_price").add(rs.getBigDecimal("new_price1")));
|
||||
// String total2=BigDecimalFormatter.formatWithoutTrailingZeros(rs.getBigDecimal("old_price").add(rs.getBigDecimal("old_price1")));
|
||||
// activeShopInfo.setActivityName("满"+total1+"减"+max1+",满"+total2+"减"+max2);
|
||||
// activeShopInfo.setActivityTypeId(3);
|
||||
// }
|
||||
activeShopInfo.setActivityName(activityName);
|
||||
activeShopInfo.setActivityItemMinQuantity(rs.getBigDecimal("limit_qty"));
|
||||
activeShopInfo.setActivityStarttime(rs.getDate("begin_date"));
|
||||
activeShopInfo.setActivityEndtime(rs.getDate("end_date"));
|
||||
activeShopInfo.setFlowNo(rs.getString("plan_no"));
|
||||
activeShopInfo.setItemNo(rs.getString("item_no").trim());
|
||||
if(DateUtil.compare(activeShopInfo.getActivityEndtime(),DateUtil.date())>0){
|
||||
activeShopInfo.setActivityState(1);//正常进行中
|
||||
}else {
|
||||
activeShopInfo.setActivityState(2);//结束
|
||||
}
|
||||
activeShopInfos.add(activeShopInfo);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
resultDto.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return activeShopInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataBaseInfo
|
||||
* @return
|
||||
*/
|
||||
public Integer getTotalSpecShop(DataBaseInfo dataBaseInfo){
|
||||
String where=dataBaseInfo.getWhere()+" and d.range_flag='I' and rule_no in('DD','PS','PM')";
|
||||
return getTotalSpecShop(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),dataBaseInfo.getPassword(),dataBaseInfo.getDbPort(),
|
||||
dataBaseInfo.getDataBaseName(),where);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,4 +72,5 @@ public interface SxDataService {
|
||||
*/
|
||||
void syncAtiveShops(DataBaseInfo dataBaseInfo,CommentModel commentModel);
|
||||
|
||||
String getCategoryChildren(DataBaseInfo dataBaseInfo,String parentId);
|
||||
}
|
||||
|
||||
@ -238,6 +238,26 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
return parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父节点下的子节点
|
||||
* @param dataBaseInfo
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getCategoryChildren(DataBaseInfo dataBaseInfo,String parentId){
|
||||
List<SxSyncCategory> sxSyncCategories=new SxDataDao().findTBdItemClsList(dataBaseInfo);
|
||||
String childrens=commonCache.get(CommonCache.CACHE_CATEGROY+parentId);
|
||||
if(StringUtils.isEmpty(childrens)){
|
||||
log.info(JSONUtil.toJsonStr(buildTree(sxSyncCategories,parentId)));
|
||||
childrens=commonCache.get(CommonCache.CACHE_CATEGROY+parentId);
|
||||
if(StringUtils.isEmpty(childrens)){
|
||||
return parentId;
|
||||
}
|
||||
}
|
||||
return childrens;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树节点
|
||||
* @param sxSyncCategories
|
||||
@ -261,7 +281,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
public List<SxSyncCategory> getRootNode(List<SxSyncCategory> sxSyncCategories){
|
||||
List<SxSyncCategory> rootNodeList=new ArrayList<>();
|
||||
for (SxSyncCategory node : sxSyncCategories) {
|
||||
if (null==node.getCls_parent()) {
|
||||
if (StringUtils.isEmpty(node.getCls_parent())) {
|
||||
rootNodeList.add(node);
|
||||
}
|
||||
}
|
||||
@ -709,10 +729,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
Integer total =0;
|
||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||
where+=" and b.start_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" or b.oper_date>'"+commentModel.getSyncTime()+"' ";
|
||||
// where+=" or b.oper_date>'"+commentModel.getSyncTime()+"') ";
|
||||
}
|
||||
dataBaseInfo.setWhere(where);
|
||||
total = sxDataDao.getActiveCount(dataBaseInfo);
|
||||
total = sxDataDao.getNewActiveCount(dataBaseInfo);
|
||||
if(total==0){
|
||||
log.info("暂无活动同步");
|
||||
return;
|
||||
@ -724,7 +744,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
Date tenMinutesAgo = Date.from(Instant.now());//刷新时间
|
||||
Date refreshDate= DateUtil.date(tenMinutesAgo);
|
||||
for (int i = 1; i <=pages; i++) {
|
||||
List<ActiveDto> activeDtos= sxDataDao.getActiveList(dataBaseInfo,i,SxDataDao.PAGESIZE);
|
||||
List<ActiveDto> activeDtos= sxDataDao.getNewActiveList(dataBaseInfo,i,SxDataDao.PAGESIZE);
|
||||
Gson gson=new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
|
||||
.create();
|
||||
@ -748,12 +768,12 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
String where="where 1=1";
|
||||
Integer total =0;
|
||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||
where+=" and start_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" or oper_date>'"+commentModel.getSyncTime()+"' ";
|
||||
where+=" and m.oper_date>'"+commentModel.getSyncTime()+"' ";
|
||||
// where+=" or m.oper_date>'"+commentModel.getSyncTime()+"') ";
|
||||
}
|
||||
|
||||
dataBaseInfo.setWhere(where);
|
||||
total = sxDataDao.getAllSpecCount(dataBaseInfo);
|
||||
total = sxDataDao.getTotalSpecShop(dataBaseInfo);
|
||||
if(total==0){
|
||||
log.info("暂无活动商品同步");
|
||||
return;
|
||||
@ -765,7 +785,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
||||
Date tenMinutesAgo = Date.from(Instant.now());//刷新时间
|
||||
Date refreshDate= DateUtil.date(tenMinutesAgo);//todo 要记录刷新时间
|
||||
for (int i = 1; i <=pages; i++) {
|
||||
List<ActiveShopInfo> activeDtos= sxDataDao.getAllSpecPriceList(dataBaseInfo,i,SxDataDao.PAGESIZE);
|
||||
List<ActiveShopInfo> activeDtos= sxDataDao.getSpecShops(dataBaseInfo,i,SxDataDao.PAGESIZE);
|
||||
Gson gson=new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss") // 设置全局 Date 格式
|
||||
.registerTypeAdapter(BigDecimal.class,new BigDecimalTypeAdapter())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user