1、新增恢复回收站商品功能
2、短信记录显示内容
This commit is contained in:
@@ -10,6 +10,8 @@ package com.constants;
|
||||
public class Constants {
|
||||
public static final long TOKEN_EXPRESS_MINUTES = (60 * 1); //1小时
|
||||
|
||||
public static final int HTTPSTATUS_CODE_SUCCESS = 200;
|
||||
|
||||
public static final int NUM_ZERO = 0;
|
||||
public static final int NUM_ONE = 1;
|
||||
public static final int NUM_TWO = 2;
|
||||
|
||||
@@ -557,15 +557,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
SystemAttachment systemAttachmentPram = new SystemAttachment();
|
||||
systemAttachmentPram.setName(name);
|
||||
// todo 二维码前端生成
|
||||
// List<SystemAttachment> sysAttachments = systemAttachmentService.getByEntity(systemAttachmentPram);
|
||||
// String siteUrl = systemConfigService.getValueByKey("");
|
||||
// if(sysAttachments.size() == 0){
|
||||
// // todo 二维码
|
||||
// String qrCode = "";
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// }
|
||||
}
|
||||
storeOrderDetailResponse.setMapKey(systemConfigService.getValueByKey("tengxun_map_key"));
|
||||
// StoreOrder storeOrder = new StoreOrder();
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface SmsService{
|
||||
* 根据发送id同步发送短信结果
|
||||
* @param recordIds 短信发送id
|
||||
*/
|
||||
void pushByAsyncStatus(List<Integer> recordIds);
|
||||
void pushByAsyncStatus(String recordIds);
|
||||
|
||||
void consume();
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.zbkj.crmeb.sms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.constants.SmsConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.zbkj.crmeb.sms.SmsResultVo;
|
||||
import com.zbkj.crmeb.sms.model.SmsRecord;
|
||||
import com.zbkj.crmeb.sms.dao.SmsRecordDao;
|
||||
import com.zbkj.crmeb.sms.request.SmsRecordRequest;
|
||||
@@ -22,6 +27,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -89,10 +95,25 @@ public class SmsRecordServiceImpl extends ServiceImpl<SmsRecordDao, SmsRecord> i
|
||||
}
|
||||
|
||||
int resultCode = joResult.getInteger("status");
|
||||
String message = joResult.getString("msg");
|
||||
JSONObject data = joResult.getJSONObject("data");
|
||||
String smsRecodeId = (data.containsKey("id") ? data.getString("id") : "0");
|
||||
if(resultCode == Constants.HTTPSTATUS_CODE_SUCCESS){
|
||||
List<SmsRecord> smsRecords = new ArrayList<>();
|
||||
for (Object data : joResult.getJSONArray("data")) {
|
||||
JSONObject resultJo = JSONObject.parseObject(data.toString());
|
||||
SmsRecord smsRecord = new SmsRecord().setRecordId(resultJo.getInteger("id"))
|
||||
.setResultcode(resultJo.getInteger("resultcode"));
|
||||
smsRecords.add(smsRecord);
|
||||
}
|
||||
updateSendSmsStatus(smsRecords);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSendSmsStatus(List<SmsRecord> smsRecords){
|
||||
for (SmsRecord smsRecord : smsRecords) {
|
||||
LambdaUpdateWrapper<SmsRecord> lup = new LambdaUpdateWrapper<>();
|
||||
lup.eq(SmsRecord::getRecordId, smsRecord.getRecordId())
|
||||
.set(SmsRecord::getResultcode,smsRecord.getResultcode());
|
||||
update(lup);
|
||||
}
|
||||
}
|
||||
|
||||
// 短信发送状态同步队列消费者
|
||||
@@ -108,8 +129,9 @@ public class SmsRecordServiceImpl extends ServiceImpl<SmsRecordDao, SmsRecord> i
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
List<Integer> recordIds = (List<Integer>) JSONObject.parseObject(data.toString());
|
||||
List<Integer> recordIds = CrmebUtil.stringToArray(data.toString());
|
||||
updateSmsStatus(recordIds);
|
||||
|
||||
}catch (Exception e){
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_RESULT_KEY, data);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.zbkj.crmeb.sms.service.impl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.constants.SmsConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.exception.ExceptionCodeEnum;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
@@ -19,6 +21,7 @@ import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -439,21 +442,24 @@ public class SmsServiceImpl implements SmsService {
|
||||
String message = joResult.getString("msg");
|
||||
JSONObject data = joResult.getJSONObject("data");
|
||||
String smsRecodeId = (data.containsKey("id") ? data.getString("id") : "0");
|
||||
sendSmsVo.setContent(data.getString("content"));
|
||||
|
||||
try{
|
||||
// 注意这里的状态仅仅是调用是否成功的状态 需要等待5分钟一周另外一个任务去查询发送状态后再更新status数据
|
||||
SmsRecord smsRecord = new SmsRecord(0,sendSmsVo.getUid(), sendSmsVo.getMobile(),sendSmsVo.getContent(),
|
||||
"", sendSmsVo.getTemplate().toString(),
|
||||
resultCode,Integer.parseInt(smsRecodeId), message);
|
||||
smsRecordService.save(smsRecord);
|
||||
}catch (Exception e){
|
||||
return true;
|
||||
}
|
||||
// 添加到短信实际发送状态队列
|
||||
if(smsRecodeId.length() > 0){
|
||||
List<Integer> recordsIds = new ArrayList<>();
|
||||
recordsIds.add(Integer.parseInt(smsRecodeId));
|
||||
pushByAsyncStatus(recordsIds);
|
||||
if(resultCode == Constants.HTTPSTATUS_CODE_SUCCESS){
|
||||
try{
|
||||
// 注意这里的状态仅仅是调用是否成功的状态 需要等待5分钟一周另外一个任务去查询发送状态后再更新status数据
|
||||
SmsRecord smsRecord = new SmsRecord(0,sendSmsVo.getUid(), sendSmsVo.getMobile(),sendSmsVo.getContent(),
|
||||
"", sendSmsVo.getTemplate().toString(),
|
||||
resultCode,Integer.parseInt(smsRecodeId), message);
|
||||
smsRecordService.save(smsRecord);
|
||||
}catch (Exception e){
|
||||
return true;
|
||||
}
|
||||
// 添加到短信实际发送状态队列
|
||||
if(smsRecodeId.length() > 0){
|
||||
List<Integer> recordsIds = new ArrayList<>();
|
||||
recordsIds.add(Integer.parseInt(smsRecodeId));
|
||||
pushByAsyncStatus(StringUtils.join(recordsIds,","));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -557,9 +563,9 @@ public class SmsServiceImpl implements SmsService {
|
||||
* @param recordIds 短信发送id
|
||||
*/
|
||||
@Override
|
||||
public void pushByAsyncStatus(List<Integer> recordIds) {
|
||||
public void pushByAsyncStatus(String recordIds) {
|
||||
if(null == recordIds) return;
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_RESULT_KEY, JSONObject.toJSONString(recordIds));
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_RESULT_KEY, recordIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,6 +91,23 @@ public class StoreProductController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复已删除商品表
|
||||
* @param id Integer
|
||||
* @author Stivepeim
|
||||
* @since 2020-08-28
|
||||
*/
|
||||
@ApiOperation(value = "恢复商品")
|
||||
@RequestMapping(value = "/restore/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<String> restore(@RequestBody @PathVariable Integer id){
|
||||
if(storeProductService.reStoreProduct(id)){
|
||||
// storeCartService.productStatusNotEnable(id);
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品表
|
||||
* @param storeProductRequest 修改参数
|
||||
|
||||
@@ -128,6 +128,13 @@ public interface StoreProductService extends IService<StoreProduct> {
|
||||
*/
|
||||
boolean deleteProduct(Integer productId);
|
||||
|
||||
/**
|
||||
* 恢复已删除商品
|
||||
* @param productId 商品id
|
||||
* @return 恢复结果
|
||||
*/
|
||||
boolean reStoreProduct(Integer productId);
|
||||
|
||||
/**
|
||||
* 后台任务批量操作
|
||||
*/
|
||||
|
||||
@@ -819,7 +819,7 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
||||
|
||||
/**
|
||||
* 根据其他平台url导入产品信息
|
||||
* @param url
|
||||
* @param url 待导入平台url
|
||||
* @param tag 1=淘宝,2=京东,3=苏宁,4=拼多多, 5=天猫
|
||||
* @return
|
||||
*/
|
||||
@@ -845,7 +845,7 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
||||
break;
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new CrmebException("确认URL和平台是否正确");
|
||||
throw new CrmebException("确认URL和平台是否正确,以及平台费用是否足额"+e.getMessage());
|
||||
}
|
||||
return productRequest;
|
||||
}
|
||||
@@ -958,17 +958,18 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
||||
StoreProductAttr spattr = new StoreProductAttr();
|
||||
String stepkey = saleProps.next();
|
||||
String stepValue = props.getString(stepkey);
|
||||
if(stepValue.length() > 0){
|
||||
String stepValueValidLength = stepValue.replace("[","").replace("]","").replace("\"","");
|
||||
if(stepValueValidLength.length() > 0){
|
||||
com.alibaba.fastjson.JSONArray stepValues = JSON.parseArray(stepValue);
|
||||
int c = stepValues.get(0).toString().length();
|
||||
attrValueIsNullCount += c == 0 ? 1 : 0;
|
||||
spattr.setAttrName(saleJson.getString(stepkey));
|
||||
spattr.setAttrValues(props.getString(stepkey));
|
||||
spaAttes.add(spattr);
|
||||
productRequest.setAttr(spaAttes);
|
||||
}else{
|
||||
attrValueIsNullCount += 1;
|
||||
}
|
||||
spattr.setAttrName(saleJson.getString(stepkey));
|
||||
spattr.setAttrValues(props.getString(stepkey));
|
||||
spaAttes.add(spattr);
|
||||
productRequest.setAttr(spaAttes);
|
||||
}
|
||||
// 判断是否单属性
|
||||
productRequest.setSpecType(spaAttes.size() != attrValueIsNullCount);
|
||||
@@ -1303,6 +1304,19 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreP
|
||||
return update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复已删除的商品
|
||||
* @param productId 商品id
|
||||
* @return 恢复结果
|
||||
*/
|
||||
@Override
|
||||
public boolean reStoreProduct(Integer productId) {
|
||||
LambdaUpdateWrapper<StoreProduct> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(StoreProduct::getId, productId);
|
||||
lambdaUpdateWrapper.set(StoreProduct::getIsDel, false);
|
||||
return update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////自定义方法
|
||||
|
||||
// 操作库存
|
||||
|
||||
@@ -54,10 +54,12 @@ public class SystemStoreServiceImpl extends ServiceImpl<SystemStoreDao, SystemSt
|
||||
public List<SystemStore> getList(String keywords, int status, PageParamRequest pageParamRequest) {
|
||||
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<SystemStore> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if(status == 2){
|
||||
if(status == 1){ // 显示中
|
||||
lambdaQueryWrapper.eq(SystemStore::getIsShow, true).eq(SystemStore::getIsDel, false);
|
||||
}else if(status == 2){ // 回收站中
|
||||
lambdaQueryWrapper.eq(SystemStore::getIsDel, true);
|
||||
}else{
|
||||
lambdaQueryWrapper.eq(SystemStore::getIsShow, status).eq(SystemStore::getIsDel, false);
|
||||
}else{ // 隐藏中的
|
||||
lambdaQueryWrapper.eq(SystemStore::getIsShow, false).eq(SystemStore::getIsDel, false);;
|
||||
}
|
||||
if(!StringUtils.isBlank(keywords)){
|
||||
lambdaQueryWrapper.and(i -> i.or().like(SystemStore::getName, keywords)
|
||||
|
||||
@@ -18,26 +18,26 @@ import org.springframework.stereotype.Component;
|
||||
* @Date 2020/8/18
|
||||
* @Created by stivepeim
|
||||
*/
|
||||
//@Component
|
||||
//@Configuration //读取配置
|
||||
//@EnableScheduling // 2.开启定时任务
|
||||
@Component
|
||||
@Configuration //读取配置
|
||||
@EnableScheduling // 2.开启定时任务
|
||||
public class AsyncSmsSendResult {
|
||||
// //日志
|
||||
// private static final Logger logger = LoggerFactory.getLogger(AsyncSmsSendResult.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private SmsRecordService smsRecordsService;
|
||||
//
|
||||
// @Scheduled(fixedDelay = 1000 * 10L) // todo 后面更改为 一分钟同步一次数据
|
||||
// public void init(){
|
||||
// logger.info("---AsyncSmsResult task------produce Data with fixed rate task: Execution Time - {}", DateUtil.nowDate());
|
||||
// try {
|
||||
// smsRecordsService.consumeSmsStatus();
|
||||
//
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// logger.error("AsyncSmsSend.task" + " | msg : " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//日志
|
||||
private static final Logger logger = LoggerFactory.getLogger(AsyncSmsSendResult.class);
|
||||
|
||||
@Autowired
|
||||
private SmsRecordService smsRecordsService;
|
||||
|
||||
@Scheduled(fixedDelay = 1000 * 60L) // todo 后面更改为 一分钟同步一次数据
|
||||
public void init(){
|
||||
logger.info("---AsyncSmsResult task------produce Data with fixed rate task: Execution Time - {}", DateUtil.nowDate());
|
||||
try {
|
||||
smsRecordsService.consumeSmsStatus();
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error("AsyncSmsSend.task" + " | msg : " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user