店铺装修调整
This commit is contained in:
parent
863e9dcab1
commit
dd418b8f75
@ -1,6 +1,7 @@
|
|||||||
package com.suisung.mall.common.modules.page;
|
package com.suisung.mall.common.modules.page;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@ -67,5 +68,18 @@ public class ShopPageApp implements Serializable {
|
|||||||
@ApiModelProperty(value = "是否使用(BOOL):0-否;1-是")
|
@ApiModelProperty(value = "是否使用(BOOL):0-否;1-是")
|
||||||
private Integer app_is_use;
|
private Integer app_is_use;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模板编号,用于模板市场")
|
||||||
|
private Integer app_template_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否收费0否,1是")
|
||||||
|
private String is_pay;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否发布0否,1是")
|
||||||
|
private String is_pulish;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String tpl_label;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "市场展示图片,用,隔开")
|
||||||
|
private String app_market_images;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,4 +37,6 @@ public interface ShopNumberSeqService extends IBaseService<ShopNumberSeq> {
|
|||||||
List<Integer> getBatchLibraryProductId(int batchSize);
|
List<Integer> getBatchLibraryProductId(int batchSize);
|
||||||
|
|
||||||
void clearKeyLibraryProductId();
|
void clearKeyLibraryProductId();
|
||||||
|
|
||||||
|
List<Long> batchCreateShopPageBaseNextNo(int batchSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.suisung.mall.common.feignService.AccountService;
|
|||||||
import com.suisung.mall.common.modules.base.ShopBaseProductSpec;
|
import com.suisung.mall.common.modules.base.ShopBaseProductSpec;
|
||||||
import com.suisung.mall.common.modules.library.LibraryProduct;
|
import com.suisung.mall.common.modules.library.LibraryProduct;
|
||||||
import com.suisung.mall.common.modules.number.ShopNumberSeq;
|
import com.suisung.mall.common.modules.number.ShopNumberSeq;
|
||||||
|
import com.suisung.mall.common.modules.page.ShopPageBase;
|
||||||
import com.suisung.mall.common.modules.product.ShopProductBase;
|
import com.suisung.mall.common.modules.product.ShopProductBase;
|
||||||
import com.suisung.mall.common.modules.product.ShopProductItem;
|
import com.suisung.mall.common.modules.product.ShopProductItem;
|
||||||
import com.suisung.mall.common.modules.product.ShopProductSpecItem;
|
import com.suisung.mall.common.modules.product.ShopProductSpecItem;
|
||||||
@ -17,6 +18,7 @@ import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
|
|||||||
import com.suisung.mall.shop.library.service.LibraryProductService;
|
import com.suisung.mall.shop.library.service.LibraryProductService;
|
||||||
import com.suisung.mall.shop.number.mapper.ShopNumberSeqMapper;
|
import com.suisung.mall.shop.number.mapper.ShopNumberSeqMapper;
|
||||||
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
||||||
|
import com.suisung.mall.shop.page.service.ShopPageBaseService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductSpecItemService;
|
import com.suisung.mall.shop.product.service.ShopProductSpecItemService;
|
||||||
@ -78,7 +80,8 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedissonClient redissonClient;
|
private RedissonClient redissonClient;
|
||||||
|
@Autowired
|
||||||
|
private ShopPageBaseService shopPageBaseService;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.printf(IntStream.rangeClosed(1, 1).boxed().collect(Collectors.toList()).toString());
|
System.out.printf(IntStream.rangeClosed(1, 1).boxed().collect(Collectors.toList()).toString());
|
||||||
@ -466,6 +469,39 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
|||||||
redisService.del(RedisKey.STOREDATALIBRARYID);
|
redisService.del(RedisKey.STOREDATALIBRARYID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> batchCreateShopPageBaseNextNo(int batchSize) {
|
||||||
|
// 定义锁的key,这个key在所有服务实例中必须一致
|
||||||
|
String lockKey = "LOCK:" + RedisKey.STOREDATASHOPBASEPAGE;
|
||||||
|
// 2. 获取分布式锁对象
|
||||||
|
RLock lock = redissonClient.getLock(lockKey);
|
||||||
|
boolean isLocked = false;
|
||||||
|
long start = 0;
|
||||||
|
try {
|
||||||
|
isLocked=lock.tryLock(2,30,TimeUnit.SECONDS);
|
||||||
|
if (!isLocked) {
|
||||||
|
// 获取锁失败,可以根据业务逻辑进行重试或抛出异常
|
||||||
|
throw new ApiException("系统繁忙,请稍后再试");
|
||||||
|
}
|
||||||
|
log.info("成功获得锁:{}",lockKey);
|
||||||
|
QueryWrapper<ShopPageBase> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.select("max(page_id) as page_id");
|
||||||
|
ShopPageBase shopPageBase = shopPageBaseService.getOne(queryWrapper);
|
||||||
|
if (null != shopPageBase) {
|
||||||
|
start = shopPageBase.getPage_id();
|
||||||
|
}
|
||||||
|
return LongStream.rangeClosed(start + 1, start + batchSize).boxed().collect(Collectors.toList());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new ApiException(e);
|
||||||
|
}finally {
|
||||||
|
// 5. 最终检查并释放锁,确保锁一定被释放
|
||||||
|
if (lock != null && lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
log.info("成功释放锁:{}",lockKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化主键
|
* 初始化主键
|
||||||
*/
|
*/
|
||||||
@ -500,4 +536,6 @@ public class ShopNumberSeqServiceImpl extends BaseServiceImpl<ShopNumberSeqMappe
|
|||||||
this.clearRelateGoodsId();
|
this.clearRelateGoodsId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,19 +2,21 @@ package com.suisung.mall.shop.page.controller.admin;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.constant.ConfigConstant;
|
import com.suisung.mall.common.constant.ConfigConstant;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
import com.suisung.mall.common.exception.ApiUserException;
|
import com.suisung.mall.common.exception.ApiUserException;
|
||||||
import com.suisung.mall.common.modules.base.ShopPageModule;
|
import com.suisung.mall.common.modules.base.ShopPageModule;
|
||||||
import com.suisung.mall.common.modules.page.ShopPageApp;
|
import com.suisung.mall.common.modules.page.ShopPageApp;
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreInfo;
|
import com.suisung.mall.common.modules.store.ShopStoreInfo;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
import com.suisung.mall.common.utils.*;
|
||||||
import com.suisung.mall.common.utils.ContextUtil;
|
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
|
||||||
import com.suisung.mall.core.web.service.CloundService;
|
import com.suisung.mall.core.web.service.CloundService;
|
||||||
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
||||||
import com.suisung.mall.shop.page.service.ShopPageAppService;
|
import com.suisung.mall.shop.page.service.ShopPageAppService;
|
||||||
@ -23,10 +25,7 @@ import com.suisung.mall.shop.store.service.ShopStoreInfoService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -76,14 +75,37 @@ public class ShopPageAppController extends BaseControllerImpl {
|
|||||||
|
|
||||||
//读取模板
|
//读取模板
|
||||||
Map data_arr = null;
|
Map data_arr = null;
|
||||||
|
JSONArray items_arr =null;
|
||||||
|
List<Map> items =null;
|
||||||
try {
|
try {
|
||||||
data_arr = cloundService.getAppTpl(accountBaseConfigService.getConfig("service_user_id", 0), accountBaseConfigService.getConfig("service_app_key", ""), null);
|
// data_arr = cloundService.getAppTpl(accountBaseConfigService.getConfig("service_user_id", 0), accountBaseConfigService.getConfig("service_app_key", ""), null);
|
||||||
|
if(user.isStore()) {
|
||||||
|
QueryWrapper<ShopPageApp> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("store_id", user.getStore_id());
|
||||||
|
List<ShopPageApp> shopPageAppList= shopPageAppService.list(queryWrapper);
|
||||||
|
if(shopPageAppList.isEmpty()) {
|
||||||
|
String resultStr= accountBaseConfigService.getSystemConfig("service_app_tpl");
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(resultStr);
|
||||||
|
data_arr = (Map)jsonObject.get("data");
|
||||||
|
items_arr = (JSONArray) data_arr.get("items");
|
||||||
|
items = JSONUtil.toList(items_arr, Map.class);
|
||||||
|
}else {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String gsonStrList= gson.toJson(shopPageAppList);
|
||||||
|
items = JSONUtil.toList(gsonStrList, Map.class);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
String resultStr= accountBaseConfigService.getSystemConfig("service_app_tpl");
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(resultStr);
|
||||||
|
data_arr = (Map)jsonObject.get("data");
|
||||||
|
items_arr = (JSONArray) data_arr.get("items");
|
||||||
|
items = JSONUtil.toList(items_arr, Map.class);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray items_arr = (JSONArray) data_arr.get("items");
|
|
||||||
List<Map> items = JSONUtil.toList(items_arr, Map.class);
|
|
||||||
|
|
||||||
Map current_tpl = new HashMap();
|
Map current_tpl = new HashMap();
|
||||||
|
|
||||||
@ -91,19 +113,18 @@ public class ShopPageAppController extends BaseControllerImpl {
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map item = it.next();
|
Map item = it.next();
|
||||||
Integer tpl_id = Convert.toInt(item.get("tpl_id"));
|
Integer tpl_id = Convert.toInt(item.get("tpl_id"));
|
||||||
String tpl_label = item.get("tpl_label").toString();
|
String tpl_label =CommonUtil.getTplLable(tpl_id);
|
||||||
|
//String tpl_label = item.get("tpl_label").toString();
|
||||||
|
item.put("tpl_label",tpl_label);
|
||||||
if (user.isStore()) {
|
if (user.isStore()) {
|
||||||
//读取店铺信息store_template
|
//读取店铺信息store_template
|
||||||
ShopStoreInfo shopStoreInfo = shopStoreInfoService.get(user.getStore_id());
|
ShopStoreInfo shopStoreInfo = shopStoreInfoService.get(user.getStore_id());
|
||||||
|
|
||||||
if (tpl_id > 1000 || tpl_id == 109 || tpl_id == 105 || tpl_id == 10/* || tpl_id == 107*/) {
|
if (tpl_id > 1000 || tpl_id == 109 || tpl_id == 105 || tpl_id == 10/* || tpl_id == 107*/) {
|
||||||
it.remove();
|
it.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String appId= String.valueOf(item.get("app_id"));
|
||||||
|
if (shopStoreInfo.getStore_template().equals(appId)) {
|
||||||
if (shopStoreInfo.getStore_template().equals(tpl_label)) {
|
|
||||||
current_tpl = item;
|
current_tpl = item;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -163,7 +184,7 @@ public class ShopPageAppController extends BaseControllerImpl {
|
|||||||
@ApiOperation(value = "店铺风格表-编辑app模版", notes = "店铺风格表-编辑app模版")
|
@ApiOperation(value = "店铺风格表-编辑app模版", notes = "店铺风格表-编辑app模版")
|
||||||
@RequestMapping(value = "/editApp", method = RequestMethod.GET)
|
@RequestMapping(value = "/editApp", method = RequestMethod.GET)
|
||||||
public ModelAndView diy(@RequestParam(name = "tpl_id", defaultValue = "1012") Integer tpl_id) {
|
public ModelAndView diy(@RequestParam(name = "tpl_id", defaultValue = "1012") Integer tpl_id) {
|
||||||
UserDto user = getCurrentUser();
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||||
}
|
}
|
||||||
@ -355,5 +376,135 @@ public class ShopPageAppController extends BaseControllerImpl {
|
|||||||
|
|
||||||
return CommonResult.failed();
|
return CommonResult.failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺装修复制
|
||||||
|
*
|
||||||
|
* @param sourceStoreId
|
||||||
|
* @param targetStoreId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/copyDiyByStore", method = RequestMethod.POST)
|
||||||
|
public CommonResult copyDiyByStore(@RequestParam(name = "sourceStoreId") Integer sourceStoreId,
|
||||||
|
@RequestParam(name = "targetStoreId") Integer targetStoreId) {
|
||||||
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonResult.success(shopPageAppService.copyDiyByStore(sourceStoreId, targetStoreId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺装修复制
|
||||||
|
*
|
||||||
|
* @param appId 复制模板的id
|
||||||
|
* @param newAppName 新模板名称
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/copyDiyByAppId", method = RequestMethod.POST)
|
||||||
|
public CommonResult copyDiyByAppId(@RequestParam(name = "appId") Integer appId,
|
||||||
|
@RequestParam(name = "appName") String newAppName) {
|
||||||
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonResult.success(shopPageAppService.copyDiyByAppId(appId, newAppName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传模板市场
|
||||||
|
* @param appId 模板的id
|
||||||
|
* @param isPublish 发布状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/pageAppPubish", method = RequestMethod.POST)
|
||||||
|
public CommonResult pageAppPubish(@RequestParam(name = "appId") Integer appId,
|
||||||
|
@RequestParam(name = "isPublish") String isPublish) {
|
||||||
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||||
|
}
|
||||||
|
ShopPageApp shopPageApp= shopPageAppService.get(appId);
|
||||||
|
if(null == shopPageApp){
|
||||||
|
return CommonResult.failed("不存在模板");
|
||||||
|
}
|
||||||
|
String storeId= user.getStore_id();
|
||||||
|
if(user.isPlatform()){
|
||||||
|
shopPageApp.setIs_pulish(isPublish);
|
||||||
|
shopPageAppService.edit(shopPageApp);
|
||||||
|
}else {
|
||||||
|
if(!Objects.equals(storeId, String.valueOf(shopPageApp.getStore_id()))){
|
||||||
|
return CommonResult.failed("权限不足");
|
||||||
|
}
|
||||||
|
shopPageApp.setIs_pulish(isPublish);
|
||||||
|
shopPageAppService.edit(shopPageApp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonResult.success("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询市场模板
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "店铺风格表-分页查询市场模板", notes = "店铺风格表-分页查询市场模板")
|
||||||
|
@RequestMapping(value = "/listMarketPage", method = RequestMethod.GET)
|
||||||
|
public Page<ShopPageApp> listMarketPage(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize) {
|
||||||
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ApiException("无权限");
|
||||||
|
}
|
||||||
|
QueryWrapper<ShopPageApp> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_pulish", "1");
|
||||||
|
String appName= getParameter("appName");
|
||||||
|
if(StringUtils.isNotEmpty(appName)){
|
||||||
|
queryWrapper.like("app_name", appName);
|
||||||
|
}
|
||||||
|
Page<ShopPageApp> shopPageAppPage= shopPageAppService.lists(queryWrapper,pageNum,pageSize);
|
||||||
|
List<ShopPageApp> shopPageAppPageList = shopPageAppPage.getRecords();
|
||||||
|
for (ShopPageApp shopPageApp : shopPageAppPageList) {
|
||||||
|
String tpl_label = CommonUtil.getTplLable(shopPageApp.getTpl_id());
|
||||||
|
shopPageApp.setTpl_label(tpl_label);
|
||||||
|
}
|
||||||
|
shopPageAppPage.setRecords(shopPageAppPageList);
|
||||||
|
return shopPageAppPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场app编辑
|
||||||
|
* @param shopPageApp
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "店铺风格表-市场app编辑", notes = "店铺风格表-市场app编辑")
|
||||||
|
@RequestMapping(value = "/editPageApp", method = RequestMethod.POST)
|
||||||
|
public CommonResult editPageApp(@RequestBody ShopPageApp shopPageApp) {
|
||||||
|
UserDto user = ContextUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ApiException("无权限");
|
||||||
|
}
|
||||||
|
if(null==shopPageApp.getApp_id()){
|
||||||
|
throw new ApiException("修改的appid不能为空");
|
||||||
|
}
|
||||||
|
ShopPageApp editShopPageApp= shopPageAppService.get(shopPageApp.getApp_id());
|
||||||
|
if(null==editShopPageApp){
|
||||||
|
return CommonResult.failed("不存在模板");
|
||||||
|
}
|
||||||
|
if(Integer.valueOf(user.getStore_id())!=editShopPageApp.getStore_id()){
|
||||||
|
return CommonResult.failed("不能跨店编辑");
|
||||||
|
}
|
||||||
|
editShopPageApp.setApp_name(shopPageApp.getApp_name());
|
||||||
|
editShopPageApp.setIs_pulish(shopPageApp.getIs_pulish());
|
||||||
|
editShopPageApp.setApp_market_images(shopPageApp.getApp_market_images());
|
||||||
|
editShopPageApp.setTpl_image(shopPageApp.getTpl_image());
|
||||||
|
shopPageAppService.edit(editShopPageApp);
|
||||||
|
return CommonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.suisung.mall.shop.page.service;
|
package com.suisung.mall.shop.page.service;
|
||||||
|
|
||||||
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.modules.page.ShopPageApp;
|
import com.suisung.mall.common.modules.page.ShopPageApp;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
@ -53,4 +54,8 @@ public interface ShopPageAppService extends IBaseService<ShopPageApp> {
|
|||||||
Map getModuleTpl();
|
Map getModuleTpl();
|
||||||
|
|
||||||
Map getPageModule(Long page_id);
|
Map getPageModule(Long page_id);
|
||||||
|
|
||||||
|
CommonResult copyDiyByStore(Integer sourceStoreId, Integer tpl_id);
|
||||||
|
|
||||||
|
CommonResult copyDiyByAppId(Integer appId,String a);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import cn.hutool.json.JSONObject;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.api.ResultCode;
|
import com.suisung.mall.common.api.ResultCode;
|
||||||
import com.suisung.mall.common.constant.ConfigConstant;
|
import com.suisung.mall.common.constant.ConfigConstant;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
@ -18,26 +19,33 @@ import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
|||||||
import com.suisung.mall.common.modules.base.ShopPageModule;
|
import com.suisung.mall.common.modules.base.ShopPageModule;
|
||||||
import com.suisung.mall.common.modules.page.ShopPageApp;
|
import com.suisung.mall.common.modules.page.ShopPageApp;
|
||||||
import com.suisung.mall.common.modules.page.ShopPageBase;
|
import com.suisung.mall.common.modules.page.ShopPageBase;
|
||||||
|
import com.suisung.mall.common.modules.product.ShopPageUserForm;
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreInfo;
|
import com.suisung.mall.common.modules.store.ShopStoreInfo;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
import com.suisung.mall.common.utils.CheckUtil;
|
||||||
|
import com.suisung.mall.common.utils.ContextUtil;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
import com.suisung.mall.core.web.service.CloundService;
|
import com.suisung.mall.core.web.service.CloundService;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
||||||
import com.suisung.mall.shop.config.CookieUtil;
|
import com.suisung.mall.shop.config.CookieUtil;
|
||||||
|
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
||||||
import com.suisung.mall.shop.page.mapper.ShopPageAppMapper;
|
import com.suisung.mall.shop.page.mapper.ShopPageAppMapper;
|
||||||
import com.suisung.mall.shop.page.service.ShopPageAppService;
|
import com.suisung.mall.shop.page.service.ShopPageAppService;
|
||||||
import com.suisung.mall.shop.page.service.ShopPageBaseService;
|
import com.suisung.mall.shop.page.service.ShopPageBaseService;
|
||||||
import com.suisung.mall.shop.page.service.ShopPageModuleService;
|
import com.suisung.mall.shop.page.service.ShopPageModuleService;
|
||||||
|
import com.suisung.mall.shop.product.service.ShopPageUserFormService;
|
||||||
|
import com.suisung.mall.shop.product.service.impl.ShopPageUserFormServiceImpl;
|
||||||
import com.suisung.mall.shop.store.service.ShopStoreInfoService;
|
import com.suisung.mall.shop.store.service.ShopStoreInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.security.sasl.AuthenticationException;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
@ -73,6 +81,11 @@ public class ShopPageAppServiceImpl extends BaseServiceImpl<ShopPageAppMapper, S
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CloundService cloundService;
|
private CloundService cloundService;
|
||||||
|
@Autowired
|
||||||
|
private ShopPageUserFormService shopPageUserFormService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ShopNumberSeqService shopNumberSeqService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存/更新 diy app 数据
|
* 保存/更新 diy app 数据
|
||||||
@ -408,7 +421,8 @@ public class ShopPageAppServiceImpl extends BaseServiceImpl<ShopPageAppMapper, S
|
|||||||
queryWrapper.eq("store_id", Convert.toInt(user.getStore_id()));
|
queryWrapper.eq("store_id", Convert.toInt(user.getStore_id()));
|
||||||
ShopStoreInfo shopStoreInfo = new ShopStoreInfo();
|
ShopStoreInfo shopStoreInfo = new ShopStoreInfo();
|
||||||
shopStoreInfo.setStore_id(Convert.toInt(user.getStore_id()));
|
shopStoreInfo.setStore_id(Convert.toInt(user.getStore_id()));
|
||||||
shopStoreInfo.setStore_template(getParameter("store_template", "shop1"));
|
//shopStoreInfo.setStore_template(getParameter("store_template", "shop1"));
|
||||||
|
shopStoreInfo.setStore_template(String.valueOf(getParameter("app_id", 0)));
|
||||||
shopStoreInfoService.edit(shopStoreInfo);
|
shopStoreInfoService.edit(shopStoreInfo);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -831,4 +845,214 @@ public class ShopPageAppServiceImpl extends BaseServiceImpl<ShopPageAppMapper, S
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sourceStoreId 复制到 targetStoreId
|
||||||
|
* @param sourceStoreId
|
||||||
|
* @param targetStoreId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CommonResult copyDiyByStore(Integer sourceStoreId, Integer targetStoreId) {
|
||||||
|
// UserDto userDto= ContextUtil.getCurrentUser();
|
||||||
|
// if(userDto==null){
|
||||||
|
// return CommonResult.failed("用户没有登录");
|
||||||
|
// }
|
||||||
|
// if(!userDto.isPlatform()){
|
||||||
|
// throw new ApiException("没有权限");
|
||||||
|
// }
|
||||||
|
QueryWrapper<ShopStoreInfo> shopStoreInfoQueryWrapper = new QueryWrapper<>();
|
||||||
|
shopStoreInfoQueryWrapper.eq("store_id", sourceStoreId);
|
||||||
|
List<ShopStoreInfo> sourceShopStore= shopStoreInfoService.list(shopStoreInfoQueryWrapper);
|
||||||
|
if(sourceShopStore.isEmpty()){
|
||||||
|
return CommonResult.failed("来源店铺不存在");
|
||||||
|
}
|
||||||
|
shopStoreInfoQueryWrapper.clear();
|
||||||
|
shopStoreInfoQueryWrapper.eq("store_id", targetStoreId);
|
||||||
|
List<ShopStoreInfo> targeShopStore= shopStoreInfoService.list(shopStoreInfoQueryWrapper);
|
||||||
|
if(targeShopStore.isEmpty()){
|
||||||
|
return CommonResult.failed("目标店铺不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<ShopPageApp> sourceShopPageAppQueryWrapper = new QueryWrapper<>();
|
||||||
|
sourceShopPageAppQueryWrapper.eq("store_id", sourceStoreId);
|
||||||
|
sourceShopPageAppQueryWrapper.eq("app_is_use",1);
|
||||||
|
List<ShopPageApp> sourceShopPageApps= shopPageAppService.list(sourceShopPageAppQueryWrapper);
|
||||||
|
if(sourceShopPageApps.isEmpty()){
|
||||||
|
return CommonResult.failed("来源店铺不存在模板");
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceShopPageAppQueryWrapper.clear();
|
||||||
|
sourceShopPageAppQueryWrapper.eq("store_id", targetStoreId);
|
||||||
|
List<ShopPageApp> targetShopPageApps= shopPageAppService.list(sourceShopPageAppQueryWrapper);
|
||||||
|
ShopPageApp shopPageApp=null;
|
||||||
|
if(targetShopPageApps.isEmpty()){
|
||||||
|
shopPageApp= sourceShopPageApps.get(0);
|
||||||
|
shopPageApp.setStore_id(targetStoreId);
|
||||||
|
shopPageApp.setApp_id(null);
|
||||||
|
shopPageAppService.save(shopPageApp);
|
||||||
|
}else {
|
||||||
|
shopPageApp=targetShopPageApps.get(0);
|
||||||
|
shopPageApp.setApp_code(sourceShopPageApps.get(0).getApp_code());
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<ShopPageBase> sourceShopPageBaseQueryWrapper = new QueryWrapper<>();
|
||||||
|
sourceShopPageBaseQueryWrapper.eq("store_id", sourceStoreId);
|
||||||
|
List<ShopPageBase> sourceShopPageBases= shopPageBaseService.list(sourceShopPageBaseQueryWrapper);
|
||||||
|
if(sourceShopPageBases.isEmpty()){
|
||||||
|
return CommonResult.failed("原店铺不存在模板复制");
|
||||||
|
}
|
||||||
|
QueryWrapper<ShopPageBase> targetShopPageBaseQueryWrapper = new QueryWrapper<>();
|
||||||
|
targetShopPageBaseQueryWrapper.eq("store_id", targetStoreId);
|
||||||
|
List<ShopPageBase> targetShopPageBases= shopPageBaseService.list(targetShopPageBaseQueryWrapper);
|
||||||
|
|
||||||
|
List<Long> sourceAppIdList= sourceShopPageBases.stream().map(ShopPageBase::getPage_id).collect(Collectors.toList());
|
||||||
|
List<Long> newShopPageBaseIdList= shopNumberSeqService.batchCreateShopPageBaseNextNo(sourceAppIdList.size());
|
||||||
|
|
||||||
|
//删除目标appid
|
||||||
|
if(!targetShopPageBases.isEmpty()){
|
||||||
|
//shopPageAppService.remove(targetShopPageBases.get(0).getApp_id());
|
||||||
|
List<Long> shopPageBasesIds = targetShopPageBases.stream()
|
||||||
|
.map(ShopPageBase::getPage_id)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
shopPageBaseService.removeBatchByIds(shopPageBasesIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long,Long> shopPageIdsouceTargetMap=getTargetPageIdMap(sourceAppIdList,newShopPageBaseIdList);
|
||||||
|
ShopPageApp finalShopPageApp = shopPageApp;
|
||||||
|
|
||||||
|
sourceShopPageBases= sourceShopPageBases.stream().peek(shopPageBase -> {
|
||||||
|
shopPageBase.setPage_id(shopPageIdsouceTargetMap.get(shopPageBase.getPage_id()));
|
||||||
|
shopPageBase.setApp_id(finalShopPageApp.getApp_id());
|
||||||
|
shopPageBase.setStore_id(targetStoreId);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageBaseService.saveBatch(sourceShopPageBases,sourceShopPageBases.size());
|
||||||
|
|
||||||
|
//赋值模块
|
||||||
|
QueryWrapper<ShopPageModule> shopPageModuleQueryWrapper = new QueryWrapper<>();
|
||||||
|
shopPageModuleQueryWrapper.in("page_id", sourceAppIdList);
|
||||||
|
List<ShopPageModule> sourceShopPageModuleList= shopPageModuleService.list(shopPageModuleQueryWrapper);
|
||||||
|
if(!sourceShopPageModuleList.isEmpty()){
|
||||||
|
sourceShopPageModuleList=sourceShopPageModuleList.stream().peek(shopPageModule -> {
|
||||||
|
shopPageModule.setPm_id(null);
|
||||||
|
shopPageModule.setPage_id(shopPageIdsouceTargetMap.get(shopPageModule.getPage_id()));
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageModuleService.saveBatch(sourceShopPageModuleList,sourceShopPageModuleList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
//动态表单复制,start
|
||||||
|
//1有先删除
|
||||||
|
List<ShopPageUserForm> shopPageUserFormsTarget= shopPageUserFormService.list(new QueryWrapper<ShopPageUserForm>().eq("store_id",targetStoreId));
|
||||||
|
if(!shopPageUserFormsTarget.isEmpty()){
|
||||||
|
List<Integer> shopPageUserFormIds=shopPageUserFormsTarget.stream().map(ShopPageUserForm::getId).collect(Collectors.toList());
|
||||||
|
shopPageUserFormService.removeBatchByIds(shopPageUserFormIds,shopPageUserFormIds.size());
|
||||||
|
}
|
||||||
|
//查询来源是否有表单,有就复制
|
||||||
|
List<ShopPageUserForm> shopPageUserFormsSource= shopPageUserFormService.list(new QueryWrapper<ShopPageUserForm>().eq("store_id",sourceStoreId));
|
||||||
|
if(!shopPageUserFormsSource.isEmpty()){
|
||||||
|
shopPageUserFormsSource=shopPageUserFormsSource.stream().peek(shopPageUserForm -> {
|
||||||
|
shopPageUserForm.setId(null);
|
||||||
|
shopPageUserForm.setPage_id(shopPageIdsouceTargetMap.get(shopPageUserForm.getPage_id()));
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageUserFormService.saveBatch(shopPageUserFormsSource,shopPageUserFormsSource.size());
|
||||||
|
}
|
||||||
|
//动态表单复制,end
|
||||||
|
|
||||||
|
return CommonResult.failed("diy装修模板复制成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult copyDiyByAppId(Integer appId,String appName) {
|
||||||
|
UserDto userDto= ContextUtil.getCurrentUser();
|
||||||
|
if(userDto==null){
|
||||||
|
return CommonResult.failed("用户没有登录");
|
||||||
|
}
|
||||||
|
Integer curentStoreId=Integer.valueOf(userDto.getStore_id());
|
||||||
|
QueryWrapper<ShopStoreInfo> shopStoreInfoQueryWrapper = new QueryWrapper<>();
|
||||||
|
shopStoreInfoQueryWrapper.eq("store_id", curentStoreId);
|
||||||
|
List<ShopStoreInfo> sourceShopStore= shopStoreInfoService.list(shopStoreInfoQueryWrapper);
|
||||||
|
if(sourceShopStore.isEmpty()){
|
||||||
|
return CommonResult.failed("店铺不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<ShopPageApp> sourceShopPageAppQueryWrapper = new QueryWrapper<>();
|
||||||
|
sourceShopPageAppQueryWrapper.eq("app_id", appId);
|
||||||
|
List<ShopPageApp> sourceShopPageApps= shopPageAppService.list(sourceShopPageAppQueryWrapper);
|
||||||
|
if(sourceShopPageApps.isEmpty()){
|
||||||
|
return CommonResult.failed("不存在模板");
|
||||||
|
}
|
||||||
|
ShopPageApp shopPageApp=sourceShopPageApps.get(0);
|
||||||
|
Integer appTemplateId=shopPageApp.getApp_template_id();
|
||||||
|
shopPageApp= sourceShopPageApps.get(0);
|
||||||
|
shopPageApp.setStore_id(curentStoreId);
|
||||||
|
shopPageApp.setApp_template_id(appTemplateId);
|
||||||
|
shopPageApp.setApp_id(null);
|
||||||
|
shopPageApp.setApp_is_use(0);
|
||||||
|
shopPageApp.setApp_name(appName);
|
||||||
|
shopPageApp.setUser_id(userDto.getId());
|
||||||
|
shopPageAppService.save(shopPageApp);
|
||||||
|
|
||||||
|
QueryWrapper<ShopPageBase> sourceShopPageBaseQueryWrapper = new QueryWrapper<>();
|
||||||
|
sourceShopPageBaseQueryWrapper.eq("app_id", appId);
|
||||||
|
List<ShopPageBase> sourceShopPageBases= shopPageBaseService.list(sourceShopPageBaseQueryWrapper);
|
||||||
|
if(sourceShopPageBases.isEmpty()){
|
||||||
|
return CommonResult.failed("不存在复制页面模板");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Long> sourceAppIdList= sourceShopPageBases.stream().map(ShopPageBase::getPage_id).collect(Collectors.toList());
|
||||||
|
List<Long> newShopPageBaseIdList= shopNumberSeqService.batchCreateShopPageBaseNextNo(sourceAppIdList.size());
|
||||||
|
|
||||||
|
Map<Long,Long> shopPageIdsouceTargetMap=getTargetPageIdMap(sourceAppIdList,newShopPageBaseIdList);
|
||||||
|
ShopPageApp finalShopPageApp = shopPageApp;
|
||||||
|
sourceShopPageBases= sourceShopPageBases.stream().peek(shopPageBase -> {
|
||||||
|
shopPageBase.setPage_id(shopPageIdsouceTargetMap.get(shopPageBase.getPage_id()));
|
||||||
|
shopPageBase.setApp_id(finalShopPageApp.getApp_id());
|
||||||
|
shopPageBase.setStore_id(curentStoreId);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageBaseService.saveBatch(sourceShopPageBases,sourceShopPageBases.size());
|
||||||
|
|
||||||
|
//复制模块
|
||||||
|
QueryWrapper<ShopPageModule> shopPageModuleQueryWrapper = new QueryWrapper<>();
|
||||||
|
shopPageModuleQueryWrapper.in("page_id", sourceAppIdList);
|
||||||
|
List<ShopPageModule> sourceShopPageModuleList= shopPageModuleService.list(shopPageModuleQueryWrapper);
|
||||||
|
if(!sourceShopPageModuleList.isEmpty()){
|
||||||
|
sourceShopPageModuleList=sourceShopPageModuleList.stream().peek(shopPageModule -> {
|
||||||
|
shopPageModule.setPm_id(null);
|
||||||
|
shopPageModule.setPage_id(shopPageIdsouceTargetMap.get(shopPageModule.getPage_id()));
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageModuleService.saveBatch(sourceShopPageModuleList,sourceShopPageModuleList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
//动态表单复制,start
|
||||||
|
//查询来源是否有表单,有就复制
|
||||||
|
List<ShopPageUserForm> shopPageUserFormsSource= shopPageUserFormService.list(new QueryWrapper<ShopPageUserForm>().eq("page_id",sourceAppIdList));
|
||||||
|
if(!shopPageUserFormsSource.isEmpty()){
|
||||||
|
shopPageUserFormsSource=shopPageUserFormsSource.stream().peek(shopPageUserForm -> {
|
||||||
|
shopPageUserForm.setId(null);
|
||||||
|
shopPageUserForm.setPage_id(shopPageIdsouceTargetMap.get(shopPageUserForm.getPage_id()));
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
shopPageUserFormService.saveBatch(shopPageUserFormsSource,shopPageUserFormsSource.size());
|
||||||
|
}
|
||||||
|
//动态表单复制,end
|
||||||
|
|
||||||
|
return CommonResult.failed("diy装修模板复制成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产新的id
|
||||||
|
* @param sourceShopPageIdList
|
||||||
|
* @param targetShopPageIdList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<Long,Long> getTargetPageIdMap(List<Long> sourceShopPageIdList, List<Long> targetShopPageIdList){
|
||||||
|
Map<Long,Long> resultMap=new HashMap<>();
|
||||||
|
for(int i=0; i<sourceShopPageIdList.size(); i++){
|
||||||
|
resultMap.put(sourceShopPageIdList.get(i),targetShopPageIdList.get(i));
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
sql/shop/dev/20251121_dml.sql
Normal file
12
sql/shop/dev/20251121_dml.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user