Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -6,9 +6,18 @@ import org.apache.commons.lang.time.DateUtils;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class DataMigrationUtil {
|
||||
public class DataMigrationUtil extends Thread {
|
||||
|
||||
Map map;
|
||||
int i;
|
||||
|
||||
public DataMigrationUtil(Map map,int i){
|
||||
this.map = map;
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
@@ -16,7 +25,7 @@ public class DataMigrationUtil {
|
||||
// courseCatalogue();
|
||||
// courseCatalogueChapter();
|
||||
// courseCatalogueChapterVideo();
|
||||
user();
|
||||
user();//用的都是copy表里的数据
|
||||
|
||||
}
|
||||
|
||||
@@ -305,13 +314,10 @@ public class DataMigrationUtil {
|
||||
|
||||
public static void user(){
|
||||
try {
|
||||
Connection fzdsconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true",
|
||||
"nuttyreading", "Wu751019!");
|
||||
Connection yljkconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||
"yljkmaster", "Wu751019!@");
|
||||
PreparedStatement statement = yljkconn.prepareStatement("select oid,cellPhone,nameCN,nickName,superVIP,point,pointByJF,payStatus,paydate,payValidDate from t_customer where valid = 1 ");
|
||||
PreparedStatement statement = yljkconn.prepareStatement("select oid,cellPhone,nameCN,nickName,icons,superVIP,point,pointByJF,payStatus,paydate,payValidDate from t_customer where valid = 1 and cellphone != '' and cellphone is not null ");
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
List<Map> list = new ArrayList();
|
||||
while(resultSet.next()){
|
||||
@@ -320,6 +326,7 @@ public class DataMigrationUtil {
|
||||
map.put("cellPhone",resultSet.getString("cellPhone"));
|
||||
map.put("nameCN",resultSet.getString("nameCN"));
|
||||
map.put("nickName",resultSet.getString("nickName"));
|
||||
map.put("icons",resultSet.getString("icons"));
|
||||
map.put("superVIP",resultSet.getString("superVIP"));
|
||||
map.put("point",resultSet.getString("point"));
|
||||
map.put("pointByJF",resultSet.getString("pointByJF"));
|
||||
@@ -330,47 +337,90 @@ public class DataMigrationUtil {
|
||||
}
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
// 1、创建服务,创建线程池
|
||||
ExecutorService service = Executors.newFixedThreadPool(200);
|
||||
for (int i=1;i<=list.size(); i++){
|
||||
//已绑定过
|
||||
PreparedStatement oidStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and yljk_oid = '"+list.get(i).get("oid")+"' ");
|
||||
ResultSet oidResultSet = oidStatements.executeQuery();
|
||||
if (oidResultSet.next()){
|
||||
PreparedStatement oidUpdateStatement = fzdsconn.prepareStatement("update user_copy1 set " +
|
||||
"name = if(isnull(name),"+list.get(i).get("nameCN")+") , nickname = if(isnull(nickname),"+list.get(i).get("nickName")+") ," +
|
||||
"tel = if(isnull(tel),"+list.get(i).get("cellPhone")+") ," +
|
||||
"vip= "+list.get(i).get("payStatus")+" ,peanut_coin = peanut_coin + "+list.get(i).get("point")+" , jf = jf + "+list.get(i).get("pointByJF")+" where id = "+oidResultSet.getString("id")+"");
|
||||
oidUpdateStatement.executeUpdate();
|
||||
if (list.get(i).get("payValidDate")!=null){
|
||||
PreparedStatement oidInsertStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_vip_copy1 (user_id,type,start_time,end_time,state) VALUES (?, ?, ?, ?, ?)");
|
||||
oidInsertStatement.setString(1,oidResultSet.getString("id"));
|
||||
oidInsertStatement.setString(2,list.get(i).get("payStatus").toString());
|
||||
oidInsertStatement.setString(3,list.get(i).get("paydate").toString());
|
||||
oidInsertStatement.setString(4,list.get(i).get("payValidDate").toString());
|
||||
if (DateUtil.compare(DateUtil.parseDate(list.get(i).get("payValidDate").toString()),new Date())>0){
|
||||
oidInsertStatement.setString(5,"0");
|
||||
}else {
|
||||
oidInsertStatement.setString(5,"1");
|
||||
}
|
||||
oidUpdateStatement.execute();
|
||||
}
|
||||
}else {
|
||||
//未绑定过,用电话查询
|
||||
PreparedStatement telStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and tel = '"+list.get(i).get("cellPhone")+"' ");
|
||||
ResultSet telResultSet = telStatements.executeQuery();
|
||||
if (telResultSet.next()){
|
||||
|
||||
}
|
||||
}
|
||||
DataMigrationUtil d1 = new DataMigrationUtil(list.get(i),i);
|
||||
service.execute(d1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.out.println("Error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
if (i % 1000 == 0) {
|
||||
System.out.println("---已插入数据"+i);
|
||||
}
|
||||
String userId = "";
|
||||
Connection fzdsconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true",
|
||||
"nuttyreading", "Wu751019!");
|
||||
PreparedStatement telInsertStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_copy1 (name,avatar,nickname,tel,vip,peanut_coin,jf,yljk_oid) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement userVipStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_vip_copy1 (user_id,type,start_time,end_time,state) VALUES (?, ?, ?, ?, ?)");
|
||||
PreparedStatement oidStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and yljk_oid = '"+map.get("oid")+"' ");
|
||||
ResultSet oidResultSet = oidStatements.executeQuery();
|
||||
//已绑定过id
|
||||
if (oidResultSet.next()){
|
||||
String sql = "update user_copy1 set " +
|
||||
"name = if(isnull(name),'"+map.get("nameCN")+"',name) , nickname = if(isnull(nickname),'"+map.get("nickName")+"',nickname) ," +
|
||||
"tel = if(isnull(tel),'"+map.get("cellPhone")+"',tel) ," +
|
||||
"vip= "+map.get("payStatus")+" ,peanut_coin = peanut_coin + "+map.get("point")+" , jf = jf + "+map.get("pointByJF")+" where id = "+oidResultSet.getString("id")+"";
|
||||
PreparedStatement oidUpdateStatement = fzdsconn.prepareStatement(sql);
|
||||
userId = oidResultSet.getString("id");
|
||||
oidUpdateStatement.execute();
|
||||
}else {
|
||||
//未绑定过id,用电话查询
|
||||
PreparedStatement telStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and tel = '"+map.get("cellPhone")+"' ");
|
||||
ResultSet telResultSet = telStatements.executeQuery();
|
||||
if (telResultSet.next()){
|
||||
if (telResultSet.getRow()>1){//这里需要检查
|
||||
System.out.println(map.get("oid").toString()+"---"+map.get("nameCN").toString()+"有多账号");
|
||||
}else {
|
||||
String sql = "update user_copy1 set yljk_oid = '" + map.get("oid") +"',"+
|
||||
" name = if(isnull(name),'"+map.get("nameCN")+"',name) , nickname = if(isnull(nickname),'"+map.get("nickName")+"',nickname) ," +
|
||||
"vip= "+map.get("payStatus")+" ,peanut_coin = peanut_coin + "+map.get("point")+" , jf = jf + "+map.get("pointByJF")+" where tel = '"+map.get("cellPhone")+"'";
|
||||
PreparedStatement telUpdateStatement = fzdsconn.prepareStatement(sql);
|
||||
userId = telResultSet.getString("id");
|
||||
telUpdateStatement.execute();
|
||||
}
|
||||
}else {
|
||||
//没有关联,直接导入
|
||||
telInsertStatement.setString(1,map.get("nameCN")==null?"":map.get("nameCN").toString());
|
||||
telInsertStatement.setString(2,map.get("icons")==null?"":map.get("icons").toString());
|
||||
telInsertStatement.setString(3,map.get("nickName")==null?"":map.get("nickName").toString());
|
||||
telInsertStatement.setString(4,map.get("cellPhone")==null?"":map.get("cellPhone").toString());
|
||||
telInsertStatement.setString(5,map.get("payStatus")==null?"":map.get("payStatus").toString());
|
||||
telInsertStatement.setString(6,map.get("point")==null?"":map.get("point").toString());
|
||||
telInsertStatement.setString(7,map.get("pointByJF")==null?"":map.get("pointByJF").toString());
|
||||
telInsertStatement.setString(8,map.get("oid")==null?"":map.get("oid").toString());
|
||||
telInsertStatement.execute();
|
||||
}
|
||||
}
|
||||
//添加超v
|
||||
if (map.get("paydate")!=null&&map.get("payValidDate")!=null){
|
||||
userVipStatement.setString(1,userId);
|
||||
userVipStatement.setString(2,map.get("payStatus").toString());
|
||||
userVipStatement.setString(3,map.get("paydate").toString());
|
||||
userVipStatement.setString(4,map.get("payValidDate").toString());
|
||||
if (DateUtil.compare(DateUtil.parseDate(map.get("payValidDate").toString()),new Date())>0){
|
||||
userVipStatement.setString(5,"0");
|
||||
}else {
|
||||
userVipStatement.setString(5,"1");
|
||||
}
|
||||
userVipStatement.execute();
|
||||
}
|
||||
}catch (Exception ee){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -380,5 +430,4 @@ public class DataMigrationUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -239,18 +239,20 @@ public class BuyOrderController {
|
||||
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
|
||||
String orderSn = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(orderSn);
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", buyOrder.getAddressId());
|
||||
UserAddress userAddress = userAddressService.getOne(queryWrapper);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
buyOrder.setProvince(vo.getProvince());
|
||||
buyOrder.setCity(vo.getCity());
|
||||
buyOrder.setDistrict(vo.getCounty());
|
||||
buyOrder.setAddress(userAddress.getDetailAddress());
|
||||
String str = buyOrder.getShippingUser()+buyOrder.getAddress()+buyOrder.getRemark();
|
||||
if (str.contains("+")||str.contains("&")) {
|
||||
return R.error(500, "信息中不能含有“+”、“&”符号!");
|
||||
if(buyOrder.getAddressId()!=0){
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", buyOrder.getAddressId());
|
||||
UserAddress userAddress = userAddressService.getOne(queryWrapper);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
buyOrder.setProvince(vo.getProvince());
|
||||
buyOrder.setCity(vo.getCity());
|
||||
buyOrder.setDistrict(vo.getCounty());
|
||||
buyOrder.setAddress(userAddress.getDetailAddress());
|
||||
String str = buyOrder.getShippingUser()+buyOrder.getAddress()+buyOrder.getRemark();
|
||||
if (str.contains("+")||str.contains("&")) {
|
||||
return R.error(500, "信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
}
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
|
||||
@@ -129,4 +129,10 @@ public class CourseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/testCourse")
|
||||
public R testCourse(){
|
||||
courseService.testCourse();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ public interface CourseService extends IService<CourseEntity> {
|
||||
List<CourseEntity> getCourseListForSociology(int sociologyId);
|
||||
|
||||
Page getCourseListCanSociology(ParamTo param);
|
||||
|
||||
void testCourse();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
private CourseToSociologyDao courseToSociologyDao;
|
||||
@Autowired
|
||||
private CourseCatalogueDao courseCatalogueDao;
|
||||
@Autowired
|
||||
private ShopProductDao shopProductDao;
|
||||
@Autowired
|
||||
private ShopProductCourseDao shopProductCourseDao;
|
||||
|
||||
@Override
|
||||
public Page getCourseList(Map<String,Object> map) {
|
||||
@@ -117,6 +121,43 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testCourse() {
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>());
|
||||
for (CourseCatalogueEntity c: courseCatalogueEntities){
|
||||
if(shopProductCourseDao.selectCount(new LambdaQueryWrapper<ShopProductCourseEntity>().eq(ShopProductCourseEntity::getCatalogueId,c.getId()))>0){
|
||||
continue;
|
||||
}
|
||||
ShopProduct shopProduct = new ShopProduct();
|
||||
shopProduct.setProductName(c.getTitle()+"."+c.getTitle()+"(半年)");
|
||||
shopProduct.setPrice(c.getHalfFee());
|
||||
shopProduct.setGoodsType("05");
|
||||
shopProductDao.insert(shopProduct);
|
||||
//添加半年期的商品课程对应关系
|
||||
ShopProductCourseEntity shopProductCourseEntity = new ShopProductCourseEntity();
|
||||
shopProductCourseEntity.setProductId(shopProduct.getProductId());
|
||||
shopProductCourseEntity.setCourseId(c.getCourseId());
|
||||
shopProductCourseEntity.setCatalogueId(c.getId());
|
||||
shopProductCourseEntity.setDays(180);
|
||||
shopProductCourseDao.insert(shopProductCourseEntity);
|
||||
|
||||
//添加一年期商品
|
||||
ShopProduct shopProduct1 = new ShopProduct();
|
||||
shopProduct1.setProductName(c.getTitle()+"."+c.getTitle()+"(一年)");
|
||||
shopProduct1.setPrice(c.getFee());
|
||||
shopProduct1.setGoodsType("05");
|
||||
shopProductDao.insert(shopProduct1);
|
||||
//添加一年期的商品课程对应关系
|
||||
ShopProductCourseEntity shopProductCourseEntity1 = new ShopProductCourseEntity();
|
||||
shopProductCourseEntity1.setProductId(shopProduct1.getProductId());
|
||||
shopProductCourseEntity1.setCourseId(c.getCourseId());
|
||||
shopProductCourseEntity1.setCatalogueId(c.getId());
|
||||
shopProductCourseEntity1.setDays(365);
|
||||
shopProductCourseDao.insert(shopProductCourseEntity1);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> categoryIds(Integer id){
|
||||
ArrayList<Integer> integers = new ArrayList<>();
|
||||
CourseCategoryEntity courseCategoryEntity = courseCategoryDao.selectById(id);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.peanut.modules.sociology.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.sociology.service.ShopProductService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController("sociologyProduct")
|
||||
@RequestMapping("sociology/product")
|
||||
@@ -23,5 +26,11 @@ public class ShopProductController {
|
||||
return R.ok().put("products",marketProductList);
|
||||
}
|
||||
|
||||
@RequestMapping("/getProductListForCourse")
|
||||
public R getProductListForCourse(@RequestBody ParamTo param){
|
||||
List<ShopProduct> productListForCourse = shopProductService.getProductListForCourse(param.getId());
|
||||
return R.ok().put("productList",productListForCourse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShopProductService extends IService<ShopProduct> {
|
||||
|
||||
Page getMarketProductList(ParamTo param);
|
||||
|
||||
List<ShopProduct> getProductListForCourse(Integer CatalogueId);
|
||||
}
|
||||
|
||||
@@ -3,17 +3,24 @@ package com.peanut.modules.sociology.service.impl;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.common.dao.ShopProductCourseDao;
|
||||
import com.peanut.modules.common.dao.ShopProductDao;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.ShopProductCourseEntity;
|
||||
import com.peanut.modules.common.entity.ShopProductToSociologyMarket;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.sociology.service.ShopProductService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyShopProduct")
|
||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
|
||||
@Autowired
|
||||
private ShopProductCourseDao shopProductCourseDao;
|
||||
|
||||
@Override
|
||||
public Page getMarketProductList(ParamTo param) {
|
||||
@@ -24,4 +31,16 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
Page<ShopProduct> shopProductPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), ShopProduct.class, wrapper);
|
||||
return shopProductPage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ShopProduct> getProductListForCourse(Integer catalogueId) {
|
||||
MPJLambdaWrapper<ShopProductCourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(ShopProduct.class);
|
||||
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductCourseEntity::getProductId);
|
||||
wrapper.eq(ShopProductCourseEntity::getCatalogueId,catalogueId);
|
||||
wrapper.orderByAsc(ShopProduct::getPrice);
|
||||
List<ShopProduct> shopProducts = shopProductCourseDao.selectJoinList(ShopProduct.class, wrapper);
|
||||
return shopProducts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user