|
@@ -8,6 +8,7 @@ import com.caimei.modules.archive.entity.CmOrderArchiveFile;
|
|
|
import com.caimei.modules.archive.utils.OssArchiveUtil;
|
|
|
import com.caimei.modules.baike.dao.CmBaikeProductRecommendDao;
|
|
|
import com.caimei.modules.baike.entity.*;
|
|
|
+import com.caimei.modules.basesetting.dao.KeywordDao;
|
|
|
import com.caimei.modules.info.entity.Info;
|
|
|
import com.caimei.modules.miniprogram.utils.UploadPicUtils;
|
|
|
import com.caimei.modules.oss.utils.OSSUtils;
|
|
@@ -25,20 +26,24 @@ import javax.annotation.Resource;
|
|
|
|
|
|
/**
|
|
|
* 采美百科产品/仪器Service
|
|
|
+ *
|
|
|
* @author Aslee
|
|
|
* @version 2021-11-19
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(readOnly = true)
|
|
|
public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaikeProduct> {
|
|
|
- @Resource
|
|
|
- private CmBaikeProductDao cmBaikeProductDao;
|
|
|
+ @Resource
|
|
|
+ private CmBaikeProductDao cmBaikeProductDao;
|
|
|
|
|
|
- @Resource
|
|
|
- private CmBaikeProductRecommendDao cmBaikeProductRecommendDao;
|
|
|
+ @Resource
|
|
|
+ private CmBaikeProductRecommendDao cmBaikeProductRecommendDao;
|
|
|
|
|
|
- public CmBaikeProduct get(String id) {
|
|
|
- CmBaikeProduct cmBaikeProduct = super.get(id);
|
|
|
+ @Resource
|
|
|
+ private KeywordDao keywordDao;
|
|
|
+
|
|
|
+ public CmBaikeProduct get(String id) {
|
|
|
+ CmBaikeProduct cmBaikeProduct = super.get(id);
|
|
|
// String marketTime = cmBaikeProduct.getMarketTime();
|
|
|
// if (StringUtils.isNotEmpty(marketTime)) {
|
|
|
// String[] split = marketTime.split("-");
|
|
@@ -76,85 +81,100 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
- return cmBaikeProduct;
|
|
|
- }
|
|
|
-
|
|
|
- public List<CmBaikeProduct> findList(CmBaikeProduct cmBaikeProduct) {
|
|
|
- return super.findList(cmBaikeProduct);
|
|
|
- }
|
|
|
-
|
|
|
- public Page<CmBaikeProduct> findPage(Page<CmBaikeProduct> page, CmBaikeProduct cmBaikeProduct) {
|
|
|
- return super.findPage(page, cmBaikeProduct);
|
|
|
- }
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void saveMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
- cmBaikeProductDao.saveMaterialinfo(cmBaikeReferenceInfo);
|
|
|
-
|
|
|
- }
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void upMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
- cmBaikeProductDao.upMaterialinfo(cmBaikeReferenceInfo);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void delMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
- cmBaikeProductDao.delMaterialinfo(cmBaikeReferenceInfo);
|
|
|
-
|
|
|
- }
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public CmBaikeReferenceInfo getMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
- return cmBaikeProductDao.getMaterialinfo(cmBaikeReferenceInfo);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void save(CmBaikeProduct cmBaikeProduct) {
|
|
|
- // 保存商品图片
|
|
|
- String mainImage = cmBaikeProduct.getImage();
|
|
|
- if (StringUtils.isNotEmpty(mainImage) && !mainImage.startsWith("http:")) {
|
|
|
- cmBaikeProduct.setImage(UploadPicUtils.saveImageToServer(mainImage));
|
|
|
- }
|
|
|
- // 保存正品认证二维码
|
|
|
+ return cmBaikeProduct;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CmBaikeProduct> findList(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ return super.findList(cmBaikeProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Page<CmBaikeProduct> findPage(Page<CmBaikeProduct> page, CmBaikeProduct cmBaikeProduct) {
|
|
|
+ return super.findPage(page, cmBaikeProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void saveMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
+ cmBaikeProductDao.saveMaterialinfo(cmBaikeReferenceInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void upMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
+ cmBaikeProductDao.upMaterialinfo(cmBaikeReferenceInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void delMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
+ cmBaikeProductDao.delMaterialinfo(cmBaikeReferenceInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public CmBaikeReferenceInfo getMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
|
|
|
+ return cmBaikeProductDao.getMaterialinfo(cmBaikeReferenceInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void save(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ // 保存商品图片
|
|
|
+ String mainImage = cmBaikeProduct.getImage();
|
|
|
+ if (StringUtils.isNotEmpty(mainImage) && !mainImage.startsWith("http:")) {
|
|
|
+ cmBaikeProduct.setImage(UploadPicUtils.saveImageToServer(mainImage));
|
|
|
+ }
|
|
|
+ // 保存正品认证二维码
|
|
|
// String authQrCode = cmBaikeProduct.getAuthQrCode();
|
|
|
// if (StringUtils.isNotEmpty(authQrCode) && !authQrCode.startsWith("http:")) {
|
|
|
// cmBaikeProduct.setAuthQrCode(UploadPicUtils.saveImageToServer(authQrCode));
|
|
|
// }
|
|
|
- // 删除原先的图片/参数/问题数据
|
|
|
- if (!cmBaikeProduct.getIsNewRecord()) {
|
|
|
- cmBaikeProductDao.deleteParamsByProductId(cmBaikeProduct.getId());
|
|
|
- cmBaikeProductDao.deleteImagesByProductId(cmBaikeProduct.getId());
|
|
|
- cmBaikeProductDao.delMaterialinfoBYProductId(cmBaikeProduct.getId());
|
|
|
- cmBaikeProductDao.delTextListByEntryId(cmBaikeProduct.getId());//正文
|
|
|
-
|
|
|
- }
|
|
|
- // 保存上市时间和nmpa时间
|
|
|
+ // 删除原先的图片/参数/问题数据
|
|
|
+ if (!cmBaikeProduct.getIsNewRecord()) {
|
|
|
+ cmBaikeProductDao.deleteParamsByProductId(cmBaikeProduct.getId());
|
|
|
+ cmBaikeProductDao.deleteImagesByProductId(cmBaikeProduct.getId());
|
|
|
+ cmBaikeProductDao.delMaterialinfoBYProductId(cmBaikeProduct.getId());
|
|
|
+ cmBaikeProductDao.delTextListByEntryId(cmBaikeProduct.getId());//正文
|
|
|
+
|
|
|
+ }
|
|
|
+ // 保存上市时间和nmpa时间
|
|
|
// saveTime(cmBaikeProduct);
|
|
|
|
|
|
- // 管理员审核百科
|
|
|
- if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
|
|
|
+ // 管理员审核百科
|
|
|
+ if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
|
|
|
cmBaikeProduct.setOnlineStatus(3);
|
|
|
if (null != cmBaikeProduct.getAuditStatus() && 2 == cmBaikeProduct.getAuditStatus()) {
|
|
|
// 审核通过
|
|
|
cmBaikeProduct.setOnlineStatus(2);
|
|
|
cmBaikeProduct.setPublishTime(new Date());
|
|
|
}
|
|
|
- }
|
|
|
- super.save(cmBaikeProduct);
|
|
|
- String fileIds = cmBaikeProduct.getFileIds();
|
|
|
- if (StringUtils.isNotEmpty(fileIds)) {
|
|
|
- for (String id : fileIds.split(",")) {
|
|
|
- if (StringUtil.isNotBlank(id)) {
|
|
|
- cmBaikeProductDao.updateProductFile(Integer.valueOf(id),Integer.valueOf(cmBaikeProduct.getId()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
|
|
|
- Integer emptyNum = checkComplete(cmBaikeProduct);
|
|
|
- cmBaikeProductDao.updateEmptyNum(cmBaikeProduct.getId(), emptyNum);
|
|
|
- }
|
|
|
- String productId = cmBaikeProduct.getId();
|
|
|
+ }
|
|
|
+ // 标签
|
|
|
+ String[] labelIds = StringUtils.split(cmBaikeProduct.getLabelIds(), ",");
|
|
|
+ String labelStr = "";
|
|
|
+ if (null != labelIds && labelIds.length > 0) {
|
|
|
+ for (int i = 0; i < labelIds.length; i++) {
|
|
|
+ labelStr += keywordDao.findKeyWordId(labelIds[i]);
|
|
|
+ if (i != 5) {
|
|
|
+ labelStr += "##";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cmBaikeProduct.setLabelStr(labelStr);
|
|
|
+ super.save(cmBaikeProduct);
|
|
|
+ String fileIds = cmBaikeProduct.getFileIds();
|
|
|
+ if (StringUtils.isNotEmpty(fileIds)) {
|
|
|
+ for (String id : fileIds.split(",")) {
|
|
|
+ if (StringUtil.isNotBlank(id)) {
|
|
|
+ cmBaikeProductDao.updateProductFile(Integer.valueOf(id), Integer.valueOf(cmBaikeProduct.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
|
|
|
+ Integer emptyNum = checkComplete(cmBaikeProduct);
|
|
|
+ cmBaikeProductDao.updateEmptyNum(cmBaikeProduct.getId(), emptyNum);
|
|
|
+ }
|
|
|
+ String productId = cmBaikeProduct.getId();
|
|
|
// // 保存产品认证图片
|
|
|
// List<String> authImageList = cmBaikeProduct.getAuthImageList();
|
|
|
// authImageList.forEach(authImage->{
|
|
@@ -165,292 +185,294 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
|
|
|
// cmBaikeProductDao.insertProductImage(authImage, productId, 1);
|
|
|
// }
|
|
|
// });
|
|
|
- // 保存效果展示图片
|
|
|
- List<String> displayImageList = cmBaikeProduct.getDisplayImageList();
|
|
|
- displayImageList.forEach(displayImage->{
|
|
|
- if (StringUtils.isNotEmpty(displayImage)) {
|
|
|
- if (!displayImage.startsWith("http")) {
|
|
|
- displayImage = UploadPicUtils.saveImageToServer(displayImage);
|
|
|
- }
|
|
|
- cmBaikeProductDao.insertProductImage(displayImage, productId, 2);
|
|
|
- }
|
|
|
- });
|
|
|
- // 保存参数
|
|
|
- List<CmBaikeProductParam> paramList = cmBaikeProduct.getParamList();
|
|
|
- if(null!=paramList&¶mList.size()>0){
|
|
|
- paramList.forEach(param->{
|
|
|
- if (StringUtils.isNotEmpty(param.getName()) && StringUtils.isNotEmpty(param.getContent())) {
|
|
|
- cmBaikeProductDao.insertProductParam(param.getName(), param.getContent(), productId);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- //保存资料
|
|
|
- List<CmBaikeReferenceInfo> cmBaikeReferenceInfo = cmBaikeProduct.getMaterialInfo();
|
|
|
- if(null!=cmBaikeReferenceInfo&&cmBaikeReferenceInfo.size()>0){
|
|
|
- cmBaikeReferenceInfo.forEach(param->{
|
|
|
- if(null!=param){
|
|
|
- if(null==param.getPublicationYear()||" ".equals(param.getPublicationYear())){
|
|
|
- param.setPublicationYear(null);
|
|
|
- }
|
|
|
- if(org.apache.commons.lang.StringUtils.isEmpty(param.getPublicationYearStr())||" ".equals(param.getPublicationYearStr())){
|
|
|
- param.setPublicationYearStr(null);
|
|
|
- }
|
|
|
- if(null==param.getPublishTime()){
|
|
|
- param.setPublishTime(null);
|
|
|
- }
|
|
|
- if(org.apache.commons.lang.StringUtils.isEmpty(param.getPublishTimeStr())||" ".equals(param.getPublishTimeStr())){
|
|
|
- param.setPublishTimeStr(null);
|
|
|
- }
|
|
|
- if(null==param.getAcitationTime()){
|
|
|
- param.setAcitationTime(null);
|
|
|
- }
|
|
|
- if(org.apache.commons.lang.StringUtils.isEmpty(param.getAcitationTimeStr())||" ".equals(param.getAcitationTimeStr())){
|
|
|
- param.setAcitationTimeStr(null);
|
|
|
- }
|
|
|
- }
|
|
|
- param.setProductId(Integer.valueOf(productId));
|
|
|
- cmBaikeProductDao.saveMaterialinfo(param);
|
|
|
- });
|
|
|
- }
|
|
|
- //保存正文
|
|
|
- List<CmBaikeTextInfo> textInfolist = cmBaikeProduct.getTextInfolist();
|
|
|
- if(null!=textInfolist&&textInfolist.size()>0){
|
|
|
- textInfolist.forEach(param->{
|
|
|
- param.setProductId(productId);
|
|
|
- cmBaikeProductDao.insertText(param);
|
|
|
- });
|
|
|
- }
|
|
|
- // 保存问题
|
|
|
+ // 保存效果展示图片
|
|
|
+ List<String> displayImageList = cmBaikeProduct.getDisplayImageList();
|
|
|
+ displayImageList.forEach(displayImage -> {
|
|
|
+ if (StringUtils.isNotEmpty(displayImage)) {
|
|
|
+ if (!displayImage.startsWith("http")) {
|
|
|
+ displayImage = UploadPicUtils.saveImageToServer(displayImage);
|
|
|
+ }
|
|
|
+ cmBaikeProductDao.insertProductImage(displayImage, productId, 2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 保存参数
|
|
|
+ List<CmBaikeProductParam> paramList = cmBaikeProduct.getParamList();
|
|
|
+ if (null != paramList && paramList.size() > 0) {
|
|
|
+ paramList.forEach(param -> {
|
|
|
+ if (StringUtils.isNotEmpty(param.getName()) && StringUtils.isNotEmpty(param.getContent())) {
|
|
|
+ cmBaikeProductDao.insertProductParam(param.getName(), param.getContent(), productId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //保存资料
|
|
|
+ List<CmBaikeReferenceInfo> cmBaikeReferenceInfo = cmBaikeProduct.getMaterialInfo();
|
|
|
+ if (null != cmBaikeReferenceInfo && cmBaikeReferenceInfo.size() > 0) {
|
|
|
+ cmBaikeReferenceInfo.forEach(param -> {
|
|
|
+ if (null != param) {
|
|
|
+ if (null == param.getPublicationYear() || " ".equals(param.getPublicationYear())) {
|
|
|
+ param.setPublicationYear(null);
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(param.getPublicationYearStr()) || " ".equals(param.getPublicationYearStr())) {
|
|
|
+ param.setPublicationYearStr(null);
|
|
|
+ }
|
|
|
+ if (null == param.getPublishTime()) {
|
|
|
+ param.setPublishTime(null);
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(param.getPublishTimeStr()) || " ".equals(param.getPublishTimeStr())) {
|
|
|
+ param.setPublishTimeStr(null);
|
|
|
+ }
|
|
|
+ if (null == param.getAcitationTime()) {
|
|
|
+ param.setAcitationTime(null);
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(param.getAcitationTimeStr()) || " ".equals(param.getAcitationTimeStr())) {
|
|
|
+ param.setAcitationTimeStr(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ param.setProductId(Integer.valueOf(productId));
|
|
|
+ cmBaikeProductDao.saveMaterialinfo(param);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //保存正文
|
|
|
+ List<CmBaikeTextInfo> textInfolist = cmBaikeProduct.getTextInfolist();
|
|
|
+ if (null != textInfolist && textInfolist.size() > 0) {
|
|
|
+ textInfolist.forEach(param -> {
|
|
|
+ param.setProductId(productId);
|
|
|
+ cmBaikeProductDao.insertText(param);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 保存问题
|
|
|
// List<CmBaikeProductQuestion> questionList = cmBaikeProduct.getQuestionList();
|
|
|
// questionList.forEach(question->{
|
|
|
// if (StringUtils.isNotEmpty(question.getQuestion()) && StringUtils.isNotEmpty(question.getAnswer())) {
|
|
|
// cmBaikeProductDao.insertProductQuestion(question.getQuestion(), question.getAnswer(), productId);
|
|
|
// }
|
|
|
// });
|
|
|
- }
|
|
|
-
|
|
|
- private void saveTime(CmBaikeProduct cmBaikeProduct) {
|
|
|
- Integer marketYear = cmBaikeProduct.getMarketYear();
|
|
|
- Integer marketMonth = cmBaikeProduct.getMarketMonth();
|
|
|
- Integer marketDay = cmBaikeProduct.getMarketDay();
|
|
|
- Integer nmpaYear = cmBaikeProduct.getNmpaYear();
|
|
|
- Integer nmpaMonth = cmBaikeProduct.getNmpaMonth();
|
|
|
- Integer nmpaDay = cmBaikeProduct.getNmpaDay();
|
|
|
- String marketTime = "";
|
|
|
- if (null != marketYear) {
|
|
|
- marketTime += marketYear;
|
|
|
- if (null != marketMonth) {
|
|
|
- marketTime += "-" + (marketMonth < 10 ? "0" + marketMonth : marketMonth);
|
|
|
- if (null != marketDay) {
|
|
|
- marketTime += "-" + (marketDay < 10 ? "0" + marketDay : marketDay);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- cmBaikeProduct.setMarketTime(marketTime);
|
|
|
- String nmpaTime = "";
|
|
|
- if (null != nmpaYear) {
|
|
|
- nmpaTime += nmpaYear;
|
|
|
- if (null != nmpaMonth) {
|
|
|
- nmpaTime += "-" + (nmpaMonth < 10 ? "0" + nmpaMonth : nmpaMonth);
|
|
|
- if (null != nmpaDay) {
|
|
|
- nmpaTime += "-" + (nmpaDay < 10 ? "0" + nmpaDay : nmpaDay);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- cmBaikeProduct.setNmpaTime(nmpaTime);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void delete(CmBaikeProduct cmBaikeProduct) {
|
|
|
- super.delete(cmBaikeProduct);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void updateTopPosition(CmBaikeProduct cmBaikeProduct) {
|
|
|
- cmBaikeProductDao.updateTopPosition(cmBaikeProduct);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 清除置顶,将后面置顶位的数据往前移
|
|
|
- * @param cmBaikeProduct
|
|
|
- */
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void moveTopList(CmBaikeProduct cmBaikeProduct) {
|
|
|
- Integer oldPosition = cmBaikeProduct.getTopPosition();
|
|
|
- List<CmBaikeProduct> topCmBaikeProductList = findTopList();
|
|
|
- topCmBaikeProductList.forEach(topCmBaikeProduct->{
|
|
|
- Integer topPosition = topCmBaikeProduct.getTopPosition();
|
|
|
- if (topPosition>oldPosition) {
|
|
|
- topCmBaikeProduct.setTopPosition(--topPosition);
|
|
|
- updateTopPosition(topCmBaikeProduct);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 置顶商品列表
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<CmBaikeProduct> findTopList() {
|
|
|
- CmBaikeProduct cmBaikeProduct = new CmBaikeProduct();
|
|
|
- cmBaikeProduct.setTopFlag(1);
|
|
|
- return cmBaikeProductDao.findList(cmBaikeProduct);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void auditBaike(CmBaikeProduct cmBaikeProduct) {
|
|
|
- Date publishTime = null;
|
|
|
- if (cmBaikeProduct.getAuditStatus() == 2) {
|
|
|
- publishTime = new Date();
|
|
|
- }
|
|
|
- cmBaikeProductDao.auditBaike(cmBaikeProduct.getId(), cmBaikeProduct.getAuditStatus(), cmBaikeProduct.getFailReason(), publishTime);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveTime(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ Integer marketYear = cmBaikeProduct.getMarketYear();
|
|
|
+ Integer marketMonth = cmBaikeProduct.getMarketMonth();
|
|
|
+ Integer marketDay = cmBaikeProduct.getMarketDay();
|
|
|
+ Integer nmpaYear = cmBaikeProduct.getNmpaYear();
|
|
|
+ Integer nmpaMonth = cmBaikeProduct.getNmpaMonth();
|
|
|
+ Integer nmpaDay = cmBaikeProduct.getNmpaDay();
|
|
|
+ String marketTime = "";
|
|
|
+ if (null != marketYear) {
|
|
|
+ marketTime += marketYear;
|
|
|
+ if (null != marketMonth) {
|
|
|
+ marketTime += "-" + (marketMonth < 10 ? "0" + marketMonth : marketMonth);
|
|
|
+ if (null != marketDay) {
|
|
|
+ marketTime += "-" + (marketDay < 10 ? "0" + marketDay : marketDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cmBaikeProduct.setMarketTime(marketTime);
|
|
|
+ String nmpaTime = "";
|
|
|
+ if (null != nmpaYear) {
|
|
|
+ nmpaTime += nmpaYear;
|
|
|
+ if (null != nmpaMonth) {
|
|
|
+ nmpaTime += "-" + (nmpaMonth < 10 ? "0" + nmpaMonth : nmpaMonth);
|
|
|
+ if (null != nmpaDay) {
|
|
|
+ nmpaTime += "-" + (nmpaDay < 10 ? "0" + nmpaDay : nmpaDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cmBaikeProduct.setNmpaTime(nmpaTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void delete(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ super.delete(cmBaikeProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void updateTopPosition(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ cmBaikeProductDao.updateTopPosition(cmBaikeProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除置顶,将后面置顶位的数据往前移
|
|
|
+ *
|
|
|
+ * @param cmBaikeProduct
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void moveTopList(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ Integer oldPosition = cmBaikeProduct.getTopPosition();
|
|
|
+ List<CmBaikeProduct> topCmBaikeProductList = findTopList();
|
|
|
+ topCmBaikeProductList.forEach(topCmBaikeProduct -> {
|
|
|
+ Integer topPosition = topCmBaikeProduct.getTopPosition();
|
|
|
+ if (topPosition > oldPosition) {
|
|
|
+ topCmBaikeProduct.setTopPosition(--topPosition);
|
|
|
+ updateTopPosition(topCmBaikeProduct);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 置顶商品列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<CmBaikeProduct> findTopList() {
|
|
|
+ CmBaikeProduct cmBaikeProduct = new CmBaikeProduct();
|
|
|
+ cmBaikeProduct.setTopFlag(1);
|
|
|
+ return cmBaikeProductDao.findList(cmBaikeProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void auditBaike(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ Date publishTime = null;
|
|
|
+ if (cmBaikeProduct.getAuditStatus() == 2) {
|
|
|
+ publishTime = new Date();
|
|
|
+ }
|
|
|
+ cmBaikeProductDao.auditBaike(cmBaikeProduct.getId(), cmBaikeProduct.getAuditStatus(), cmBaikeProduct.getFailReason(), publishTime);
|
|
|
+ }
|
|
|
|
|
|
@Transactional(readOnly = false)
|
|
|
public void offlineInfo(Integer id) {
|
|
|
cmBaikeProductDao.offline(id);
|
|
|
}
|
|
|
|
|
|
- public Integer checkComplete(CmBaikeProduct product) {
|
|
|
- String productId = product.getId();
|
|
|
- // 参数列表
|
|
|
- List<CmBaikeProductParam> paramList = cmBaikeProductDao.findParamList(productId);
|
|
|
- // 产品/仪器认证图片列表
|
|
|
- List<String> authImageList = cmBaikeProductDao.findImageList(productId, 1);
|
|
|
- // 效果展示图片列表
|
|
|
- List<String> displayImageList = cmBaikeProductDao.findImageList(productId, 2);
|
|
|
- // 问题列表
|
|
|
- List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(productId);
|
|
|
- Integer emptyNum = 0;
|
|
|
- List<String> propertyList1 = new ArrayList<>();
|
|
|
- List<Integer> propertyList2 = new ArrayList<>();
|
|
|
- propertyList1.add(product.getName());
|
|
|
- propertyList1.add(product.getAlias());
|
|
|
- propertyList1.add(product.getDiscription());
|
|
|
- propertyList1.add(product.getProductLink());
|
|
|
- propertyList1.add(product.getImage());
|
|
|
- if (2 == product.getCommodityType()) {
|
|
|
- propertyList1.add(product.getAuthLink());
|
|
|
- propertyList1.add(product.getAuthQrCode());
|
|
|
- }
|
|
|
- propertyList1.add(product.getAdvantage());
|
|
|
- propertyList1.add(product.getDisadvantage());
|
|
|
- propertyList1.add(product.getPrinciple());
|
|
|
- propertyList1.add(product.getSeoKeyword());
|
|
|
- propertyList1.add(product.getBrand());
|
|
|
- propertyList1.add(product.getProducePlace());
|
|
|
- propertyList1.add(product.getMarketTime());
|
|
|
- propertyList1.add(product.getCompany());
|
|
|
- propertyList1.add(product.getNmpaTime());
|
|
|
- propertyList1.add(product.getAdaptiveMan());
|
|
|
- propertyList1.add(product.getUnAdaptiveMan());
|
|
|
- propertyList1.add(product.getAroundOperation());
|
|
|
-
|
|
|
- propertyList2.add(product.getShopId());
|
|
|
- propertyList2.add(product.getBasePv());
|
|
|
- propertyList2.add(product.getTypeId());
|
|
|
- for (String property : propertyList1) {
|
|
|
- if (StringUtils.isEmpty(property)) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- for (Integer property : propertyList2) {
|
|
|
- if (null == property) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (null == product.getPublishTime()) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- if (0 == paramList.size()) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- if (0 == authImageList.size()) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- if (0 == displayImageList.size()) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- if (0 == questionList.size()) {
|
|
|
- emptyNum++;
|
|
|
- }
|
|
|
- return emptyNum;
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public Map<String, Object> upload(MultipartFile multipartFile,String fileTitle, String fileName, Integer productId, String fileIds) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- if (null != productId || StringUtils.isNotEmpty(fileIds)) {
|
|
|
- Integer fileIdByFileName = cmBaikeProductDao.checkFileName(fileName, productId, fileIds);
|
|
|
- if (null != fileIdByFileName) {
|
|
|
- map.put("success", false);
|
|
|
- map.put("msg", "文件已存在");
|
|
|
- return map;
|
|
|
- }
|
|
|
- }
|
|
|
- String fileAllName = multipartFile.getOriginalFilename();
|
|
|
- String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
|
|
|
- String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
- String filePath = uuid + "." + fileType;
|
|
|
- String contentType = OssArchiveUtil.getContentType(fileAllName);
|
|
|
- try {
|
|
|
- //保存本地
|
|
|
- File file = OSSUtils.ossUpload(multipartFile);
|
|
|
- logger.info("默认路径>>>" + file.getAbsolutePath());
|
|
|
- //上传oss
|
|
|
- String url = OSSUtils.ossUpload(filePath, file, contentType);
|
|
|
- //删除本地文件
|
|
|
- OssArchiveUtil.deleteFile(file);
|
|
|
- //保存关联关系
|
|
|
- CmBaikeProductFile productFile = new CmBaikeProductFile();
|
|
|
- productFile.setFileTitle(fileTitle);
|
|
|
- productFile.setFileName(fileName);
|
|
|
- productFile.setOssName(filePath);
|
|
|
- productFile.setOssUrl(url);
|
|
|
- cmBaikeProductDao.insertProductFile(productFile);
|
|
|
- productFile.setOssUrl(url);
|
|
|
- map.put("success", true);
|
|
|
- map.put("msg", "操作成功");
|
|
|
- map.put("productFile", productFile);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- map.put("success", false);
|
|
|
- map.put("msg", "操作失败");
|
|
|
- logger.info("上传异常!!!");
|
|
|
- }
|
|
|
- return map;
|
|
|
+ public Integer checkComplete(CmBaikeProduct product) {
|
|
|
+ String productId = product.getId();
|
|
|
+ // 参数列表
|
|
|
+ List<CmBaikeProductParam> paramList = cmBaikeProductDao.findParamList(productId);
|
|
|
+ // 产品/仪器认证图片列表
|
|
|
+ List<String> authImageList = cmBaikeProductDao.findImageList(productId, 1);
|
|
|
+ // 效果展示图片列表
|
|
|
+ List<String> displayImageList = cmBaikeProductDao.findImageList(productId, 2);
|
|
|
+ // 问题列表
|
|
|
+ List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(productId);
|
|
|
+ Integer emptyNum = 0;
|
|
|
+ List<String> propertyList1 = new ArrayList<>();
|
|
|
+ List<Integer> propertyList2 = new ArrayList<>();
|
|
|
+ propertyList1.add(product.getName());
|
|
|
+ propertyList1.add(product.getAlias());
|
|
|
+ propertyList1.add(product.getDiscription());
|
|
|
+ propertyList1.add(product.getProductLink());
|
|
|
+ propertyList1.add(product.getImage());
|
|
|
+ if (2 == product.getCommodityType()) {
|
|
|
+ propertyList1.add(product.getAuthLink());
|
|
|
+ propertyList1.add(product.getAuthQrCode());
|
|
|
+ }
|
|
|
+ propertyList1.add(product.getAdvantage());
|
|
|
+ propertyList1.add(product.getDisadvantage());
|
|
|
+ propertyList1.add(product.getPrinciple());
|
|
|
+ propertyList1.add(product.getSeoKeyword());
|
|
|
+ propertyList1.add(product.getBrand());
|
|
|
+ propertyList1.add(product.getProducePlace());
|
|
|
+ propertyList1.add(product.getMarketTime());
|
|
|
+ propertyList1.add(product.getCompany());
|
|
|
+ propertyList1.add(product.getNmpaTime());
|
|
|
+ propertyList1.add(product.getAdaptiveMan());
|
|
|
+ propertyList1.add(product.getUnAdaptiveMan());
|
|
|
+ propertyList1.add(product.getAroundOperation());
|
|
|
+
|
|
|
+ propertyList2.add(product.getShopId());
|
|
|
+ propertyList2.add(product.getBasePv());
|
|
|
+ propertyList2.add(product.getTypeId());
|
|
|
+ for (String property : propertyList1) {
|
|
|
+ if (StringUtils.isEmpty(property)) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Integer property : propertyList2) {
|
|
|
+ if (null == property) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null == product.getPublishTime()) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ if (0 == paramList.size()) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ if (0 == authImageList.size()) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ if (0 == displayImageList.size()) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ if (0 == questionList.size()) {
|
|
|
+ emptyNum++;
|
|
|
+ }
|
|
|
+ return emptyNum;
|
|
|
}
|
|
|
|
|
|
- @Transactional(readOnly = false)
|
|
|
- public void deleteFile(Integer fileId) {
|
|
|
- CmBaikeProductFile productFile = cmBaikeProductDao.getProductFileById(fileId);
|
|
|
- if (productFile != null) {
|
|
|
- //删除oss服务器上的文件
|
|
|
- OSSUtils.deleteSingleFile(productFile.getOssName());
|
|
|
- cmBaikeProductDao.deleteProductFile(fileId);
|
|
|
- }
|
|
|
- }
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public Map<String, Object> upload(MultipartFile multipartFile, String fileTitle, String fileName, Integer productId, String fileIds) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (null != productId || StringUtils.isNotEmpty(fileIds)) {
|
|
|
+ Integer fileIdByFileName = cmBaikeProductDao.checkFileName(fileName, productId, fileIds);
|
|
|
+ if (null != fileIdByFileName) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "文件已存在");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileAllName = multipartFile.getOriginalFilename();
|
|
|
+ String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
|
|
|
+ String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
+ String filePath = uuid + "." + fileType;
|
|
|
+ String contentType = OssArchiveUtil.getContentType(fileAllName);
|
|
|
+ try {
|
|
|
+ //保存本地
|
|
|
+ File file = OSSUtils.ossUpload(multipartFile);
|
|
|
+ logger.info("默认路径>>>" + file.getAbsolutePath());
|
|
|
+ //上传oss
|
|
|
+ String url = OSSUtils.ossUpload(filePath, file, contentType);
|
|
|
+ //删除本地文件
|
|
|
+ OssArchiveUtil.deleteFile(file);
|
|
|
+ //保存关联关系
|
|
|
+ CmBaikeProductFile productFile = new CmBaikeProductFile();
|
|
|
+ productFile.setFileTitle(fileTitle);
|
|
|
+ productFile.setFileName(fileName);
|
|
|
+ productFile.setOssName(filePath);
|
|
|
+ productFile.setOssUrl(url);
|
|
|
+ cmBaikeProductDao.insertProductFile(productFile);
|
|
|
+ productFile.setOssUrl(url);
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("msg", "操作成功");
|
|
|
+ map.put("productFile", productFile);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "操作失败");
|
|
|
+ logger.info("上传异常!!!");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void deleteFile(Integer fileId) {
|
|
|
+ CmBaikeProductFile productFile = cmBaikeProductDao.getProductFileById(fileId);
|
|
|
+ if (productFile != null) {
|
|
|
+ //删除oss服务器上的文件
|
|
|
+ OSSUtils.deleteSingleFile(productFile.getOssName());
|
|
|
+ cmBaikeProductDao.deleteProductFile(fileId);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void saveRecommend(CmBaikeProduct cmBaikeProduct) {
|
|
|
- cmBaikeProductDao.updateRecommendType(cmBaikeProduct.getId(), cmBaikeProduct.getRecommendType());
|
|
|
- // 清除原来的推荐数据
|
|
|
- if (1 == cmBaikeProduct.getRecommendType()) {
|
|
|
- cmBaikeProductRecommendDao.clearRecommendData(cmBaikeProduct.getId());
|
|
|
- String[] recommendParams = cmBaikeProduct.getRecommendParams();
|
|
|
- int productId = Integer.parseInt(cmBaikeProduct.getId());
|
|
|
- if (null != recommendParams && recommendParams.length > 0) {
|
|
|
- for (int i = 0; i < recommendParams.length; i++) {
|
|
|
- String recommendParam = recommendParams[i];
|
|
|
- String[] split = recommendParam.split(":");
|
|
|
- CmBaikeProductRecommend recommend = new CmBaikeProductRecommend();
|
|
|
- recommend.setProductId(productId);
|
|
|
- recommend.setRecommendProductId(Integer.parseInt(split[0]) );
|
|
|
- recommend.setSort(Integer.parseInt(split[1]));
|
|
|
- cmBaikeProductRecommendDao.insert(recommend);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ public void saveRecommend(CmBaikeProduct cmBaikeProduct) {
|
|
|
+ cmBaikeProductDao.updateRecommendType(cmBaikeProduct.getId(), cmBaikeProduct.getRecommendType());
|
|
|
+ // 清除原来的推荐数据
|
|
|
+ if (1 == cmBaikeProduct.getRecommendType()) {
|
|
|
+ cmBaikeProductRecommendDao.clearRecommendData(cmBaikeProduct.getId());
|
|
|
+ String[] recommendParams = cmBaikeProduct.getRecommendParams();
|
|
|
+ int productId = Integer.parseInt(cmBaikeProduct.getId());
|
|
|
+ if (null != recommendParams && recommendParams.length > 0) {
|
|
|
+ for (int i = 0; i < recommendParams.length; i++) {
|
|
|
+ String recommendParam = recommendParams[i];
|
|
|
+ String[] split = recommendParam.split(":");
|
|
|
+ CmBaikeProductRecommend recommend = new CmBaikeProductRecommend();
|
|
|
+ recommend.setProductId(productId);
|
|
|
+ recommend.setRecommendProductId(Integer.parseInt(split[0]));
|
|
|
+ recommend.setSort(Integer.parseInt(split[1]));
|
|
|
+ cmBaikeProductRecommendDao.insert(recommend);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|