优化小程序,后台bug
parent
27d2203d2d
commit
fad3648345
|
|
@ -68,7 +68,8 @@ public class AlbumsServiceImpl implements IAlbumsService {
|
||||||
|
|
||||||
albumMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
albumMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
||||||
"=:type:int",
|
"=:type:int",
|
||||||
"like:keyword@name:str"
|
"like:keyword@name:str",
|
||||||
|
"like:name@name:str"
|
||||||
});
|
});
|
||||||
|
|
||||||
IPage<Album> iPage = albumMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
IPage<Album> iPage = albumMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,10 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
model.setSort(createValidate.getSort());
|
model.setSort(createValidate.getSort());
|
||||||
model.setIsShow(createValidate.getIsShow());
|
model.setIsShow(createValidate.getIsShow());
|
||||||
model.setClassId(createValidate.getClassId());
|
model.setClassId(createValidate.getClassId());
|
||||||
|
ClassInfo classInfo = classInfoMapper.selectById(createValidate.getClassId());
|
||||||
|
if (classInfo!=null){
|
||||||
|
model.setPid(classInfo.getPid());
|
||||||
|
}
|
||||||
model.setContent(createValidate.getContent());
|
model.setContent(createValidate.getContent());
|
||||||
int insert = experimentMapper.insert(model);
|
int insert = experimentMapper.insert(model);
|
||||||
if (insert>0) {
|
if (insert>0) {
|
||||||
|
|
@ -179,9 +183,9 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
public void edit(ExperimentUpdateValidate updateValidate) {
|
public void edit(ExperimentUpdateValidate updateValidate) {
|
||||||
Experiment model = experimentMapper.selectOne(
|
Experiment model = experimentMapper.selectOne(
|
||||||
new QueryWrapper<Experiment>()
|
new QueryWrapper<Experiment>()
|
||||||
.eq("id", updateValidate.getId())
|
.eq("id", updateValidate.getId())
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
Assert.notNull(model, "数据不存在!");
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
|
@ -195,6 +199,16 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
model.setClassId(updateValidate.getClassId());
|
model.setClassId(updateValidate.getClassId());
|
||||||
model.setContent(updateValidate.getContent());
|
model.setContent(updateValidate.getContent());
|
||||||
experimentMapper.updateById(model);
|
experimentMapper.updateById(model);
|
||||||
|
if (updateValidate.getGoodsIds() != null) {
|
||||||
|
goodsExperimentMapper.delete(Wrappers.<GoodsExperiment>lambdaQuery().eq(GoodsExperiment::
|
||||||
|
getExperimentId, model.getId()));
|
||||||
|
for (Integer goodsId : updateValidate.getGoodsIds()) {
|
||||||
|
GoodsExperiment goodsExperiment = new GoodsExperiment();
|
||||||
|
goodsExperiment.setExperimentId(model.getId());
|
||||||
|
goodsExperiment.setGoodsId(goodsId);
|
||||||
|
goodsExperimentMapper.insert(goodsExperiment);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,7 @@ public class AlbumSearchValidate implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(value = "关键词")
|
@ApiModelProperty(value = "关键词")
|
||||||
private String keyword;
|
private String keyword;
|
||||||
|
@ApiModelProperty(value = "文件名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,4 +51,7 @@ public class Experiment implements Serializable {
|
||||||
@ApiModelProperty(value = "实验内容")
|
@ApiModelProperty(value = "实验内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类pid")
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,10 @@ public enum NoticeEnum {
|
||||||
BIND_MOBILE_CODE(102, "绑定手机验证码"),
|
BIND_MOBILE_CODE(102, "绑定手机验证码"),
|
||||||
CHANGE_MOBILE_CODE(103, "变更手机验证码"),
|
CHANGE_MOBILE_CODE(103, "变更手机验证码"),
|
||||||
FORGOT_PASSWORD_CODE(104, "找回登录密码验证码"),
|
FORGOT_PASSWORD_CODE(104, "找回登录密码验证码"),
|
||||||
REGISTER_CODE(105, "登录验证码");
|
REGISTER_CODE(105, "注册验证码"),
|
||||||
|
|
||||||
|
SALESMAN_CODE(106, "业务员通知"),
|
||||||
|
SEND_USER_CODE(107, "用户下单通知");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造方法
|
* 构造方法
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
package com.wyh.common.plugin.notice.engine;
|
package com.wyh.common.plugin.notice.engine;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.wyh.common.entity.notice.NoticeRecord;
|
import com.wyh.common.entity.notice.NoticeRecord;
|
||||||
|
import com.wyh.common.entity.notice.NoticeSetting;
|
||||||
import com.wyh.common.enums.NoticeEnum;
|
import com.wyh.common.enums.NoticeEnum;
|
||||||
import com.wyh.common.exception.OperateException;
|
import com.wyh.common.exception.OperateException;
|
||||||
import com.wyh.common.mapper.notice.NoticeRecordMapper;
|
import com.wyh.common.mapper.notice.NoticeRecordMapper;
|
||||||
|
import com.wyh.common.mapper.notice.NoticeSettingMapper;
|
||||||
import com.wyh.common.plugin.notice.vo.NoticeSmsVo;
|
import com.wyh.common.plugin.notice.vo.NoticeSmsVo;
|
||||||
import com.wyh.common.plugin.notice.template.SmsTemplate;
|
import com.wyh.common.plugin.notice.template.SmsTemplate;
|
||||||
import com.wyh.common.plugin.sms.SmsDriver;
|
import com.wyh.common.plugin.sms.SmsDriver;
|
||||||
|
import com.wyh.common.plugin.sms.engine.AliSms;
|
||||||
import com.wyh.common.util.ConfigUtils;
|
import com.wyh.common.util.ConfigUtils;
|
||||||
|
import com.wyh.common.util.MapUtils;
|
||||||
import com.wyh.common.util.SpringUtils;
|
import com.wyh.common.util.SpringUtils;
|
||||||
import com.wyh.common.util.StringUtils;
|
import com.wyh.common.util.StringUtils;
|
||||||
|
|
||||||
|
|
@ -21,9 +27,9 @@ public class SmsNoticeHandle {
|
||||||
/**
|
/**
|
||||||
* 发送短信通知
|
* 发送短信通知
|
||||||
*
|
*
|
||||||
|
* @param noticeSmsVo 基础配置
|
||||||
|
* @param smsTemplate 短信模板
|
||||||
* @author wyh
|
* @author wyh
|
||||||
* @param noticeSmsVo 基础配置
|
|
||||||
* @param smsTemplate 短信模板
|
|
||||||
*/
|
*/
|
||||||
public void send(NoticeSmsVo noticeSmsVo, SmsTemplate smsTemplate) {
|
public void send(NoticeSmsVo noticeSmsVo, SmsTemplate smsTemplate) {
|
||||||
// 基础参数
|
// 基础参数
|
||||||
|
|
@ -34,7 +40,7 @@ public class SmsNoticeHandle {
|
||||||
Map<String, String> params = new LinkedHashMap<>();
|
Map<String, String> params = new LinkedHashMap<>();
|
||||||
if (StringUtils.isNotNull(noticeSmsVo.getParams())) {
|
if (StringUtils.isNotNull(noticeSmsVo.getParams())) {
|
||||||
for (String s : noticeSmsVo.getParams()) {
|
for (String s : noticeSmsVo.getParams()) {
|
||||||
String[] arr = s.split(":");
|
String[] arr = s.split(":");
|
||||||
String key = arr[0].trim();
|
String key = arr[0].trim();
|
||||||
String val = arr[1].trim();
|
String val = arr[1].trim();
|
||||||
params.put(key, val);
|
params.put(key, val);
|
||||||
|
|
@ -84,10 +90,10 @@ public class SmsNoticeHandle {
|
||||||
/**
|
/**
|
||||||
* 获取短信内容
|
* 获取短信内容
|
||||||
*
|
*
|
||||||
* @author wyh
|
* @param params 短信参数
|
||||||
* @param params 短信参数
|
|
||||||
* @param content 短信模板
|
* @param content 短信模板
|
||||||
* @return String 短信内容
|
* @return String 短信内容
|
||||||
|
* @author wyh
|
||||||
*/
|
*/
|
||||||
private String getContent(Map<String, String> params, String content) {
|
private String getContent(Map<String, String> params, String content) {
|
||||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
|
@ -101,10 +107,10 @@ public class SmsNoticeHandle {
|
||||||
/**
|
/**
|
||||||
* 腾讯云参数处理
|
* 腾讯云参数处理
|
||||||
*
|
*
|
||||||
* @author wyh
|
* @param params 短信参数
|
||||||
* @param params 短信参数
|
|
||||||
* @param content 短信内容
|
* @param content 短信内容
|
||||||
* @return Map<String, String>
|
* @return Map<String, String>
|
||||||
|
* @author wyh
|
||||||
*/
|
*/
|
||||||
private Map<String, String> getSmsParams(Map<String, String> params, String content) {
|
private Map<String, String> getSmsParams(Map<String, String> params, String content) {
|
||||||
String engine = ConfigUtils.get("sms", "default", "");
|
String engine = ConfigUtils.get("sms", "default", "");
|
||||||
|
|
@ -116,16 +122,16 @@ public class SmsNoticeHandle {
|
||||||
List<String> arr = new LinkedList<>();
|
List<String> arr = new LinkedList<>();
|
||||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
String search = "\\$\\{" + entry.getKey() + "}";
|
String search = "\\$\\{" + entry.getKey() + "}";
|
||||||
if (content.indexOf(search) != 1 && !arr.contains(entry.getKey())) {
|
if (content.indexOf(search) != 1 && !arr.contains(entry.getKey())) {
|
||||||
arr.add(entry.getKey());
|
arr.add(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取变量名称
|
// 获取变量名称
|
||||||
List<Integer> arrIndex = new LinkedList<>();
|
List<Integer> arrIndex = new LinkedList<>();
|
||||||
Map<Integer, String> arr2 = new LinkedHashMap<>();
|
Map<Integer, String> arr2 = new LinkedHashMap<>();
|
||||||
if (arr.size() > 0) {
|
if (arr.size() > 0) {
|
||||||
for (String v: arr) {
|
for (String v : arr) {
|
||||||
int k = content.indexOf(v);
|
int k = content.indexOf(v);
|
||||||
arrIndex.add(k);
|
arrIndex.add(k);
|
||||||
arr2.put(k, v);
|
arr2.put(k, v);
|
||||||
|
|
@ -150,4 +156,153 @@ public class SmsNoticeHandle {
|
||||||
return arr4;
|
return arr4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信通知(通知类型)
|
||||||
|
*
|
||||||
|
* @param mobile 发送人
|
||||||
|
* @param name 名称
|
||||||
|
* @param order 地址
|
||||||
|
* @author wyh
|
||||||
|
*/
|
||||||
|
public void sendUserMessage(
|
||||||
|
String mobile,
|
||||||
|
String name,
|
||||||
|
String order
|
||||||
|
) {
|
||||||
|
NoticeSmsVo params = new NoticeSmsVo()
|
||||||
|
.setScene(NoticeEnum.SALESMAN_CODE.getCode())
|
||||||
|
.setMobile(mobile)
|
||||||
|
.setExpire(900)
|
||||||
|
.setParams(new String[]{
|
||||||
|
"order:" + order,
|
||||||
|
"name:" + name
|
||||||
|
});
|
||||||
|
NoticeSettingMapper noticeSettingMapper = SpringUtils.getBean(NoticeSettingMapper.class);
|
||||||
|
NoticeSetting noticeSetting = noticeSettingMapper.selectOne(
|
||||||
|
new QueryWrapper<NoticeSetting>()
|
||||||
|
.eq("scene", NoticeEnum.SEND_USER_CODE.getCode())
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
if (StringUtils.isNull(noticeSetting)) {
|
||||||
|
throw new OperateException("消息场景不存在!");
|
||||||
|
}
|
||||||
|
SmsTemplate smsTemplate = new SmsTemplate();
|
||||||
|
smsTemplate.setName(noticeSetting.getName());
|
||||||
|
smsTemplate.setType(noticeSetting.getType());
|
||||||
|
smsTemplate.setParams(noticeSetting.getSmsNotice());
|
||||||
|
if (StringUtils.isNotNull(smsTemplate.getStatus()) && smsTemplate.getStatus().equals(1)) {
|
||||||
|
(new SmsNoticeHandle()).send(params, smsTemplate);
|
||||||
|
|
||||||
|
Map<String, String> sendParams = new LinkedHashMap<>();
|
||||||
|
if (StringUtils.isNotNull(params.getParams())) {
|
||||||
|
for (String s : params.getParams()) {
|
||||||
|
String[] arr = s.split(":");
|
||||||
|
String key = arr[0].trim();
|
||||||
|
String val = arr[1].trim();
|
||||||
|
sendParams.put(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, String> sendConfig = new HashMap<>();
|
||||||
|
sendConfig.put("secretKey", "cY7fbU0hvGvUl16ywGn4RUAoiu4zNO");
|
||||||
|
sendConfig.put("name", "阿里云短信");
|
||||||
|
sendConfig.put("sign", "上海中将科教设备");
|
||||||
|
sendConfig.put("alias", "aliyun");
|
||||||
|
sendConfig.put("appKey", "LTAI5tAxZbqdxWnf15651D4C");
|
||||||
|
Integer sendResult = 0;
|
||||||
|
String results = "";
|
||||||
|
String templateParam = JSON.toJSONString(MapUtils.getSmsParams(sendParams, smsTemplate.getContent()));
|
||||||
|
|
||||||
|
AliSms aliSms = new AliSms(sendConfig);
|
||||||
|
results = aliSms.setMobile(mobile)
|
||||||
|
.setTemplateId("SMS_473495009")
|
||||||
|
.setTemplateParams(templateParam)
|
||||||
|
.send();
|
||||||
|
|
||||||
|
sendResult = aliSms.getSendResult();
|
||||||
|
|
||||||
|
if (sendResult == 2) {
|
||||||
|
throw new OperateException(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信通知(通知类型)
|
||||||
|
*
|
||||||
|
* @param mobile 发送人
|
||||||
|
* @param name 名称
|
||||||
|
* @param address 地址
|
||||||
|
* @param phone 联系人电话
|
||||||
|
* @author wyh
|
||||||
|
*/
|
||||||
|
public void sendMessage(
|
||||||
|
String mobile,
|
||||||
|
String name,
|
||||||
|
String address,
|
||||||
|
String phone
|
||||||
|
) {
|
||||||
|
NoticeSmsVo params = new NoticeSmsVo()
|
||||||
|
.setScene(NoticeEnum.SALESMAN_CODE.getCode())
|
||||||
|
.setMobile(mobile)
|
||||||
|
.setExpire(900)
|
||||||
|
.setParams(new String[]{
|
||||||
|
"address:" + address,
|
||||||
|
"name:" + name,
|
||||||
|
"phone:" + phone
|
||||||
|
});
|
||||||
|
NoticeSettingMapper noticeSettingMapper = SpringUtils.getBean(NoticeSettingMapper.class);
|
||||||
|
NoticeSetting noticeSetting = noticeSettingMapper.selectOne(
|
||||||
|
new QueryWrapper<NoticeSetting>()
|
||||||
|
.eq("scene", NoticeEnum.SALESMAN_CODE.getCode())
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
if (StringUtils.isNull(noticeSetting)) {
|
||||||
|
throw new OperateException("消息场景不存在!");
|
||||||
|
}
|
||||||
|
SmsTemplate smsTemplate = new SmsTemplate();
|
||||||
|
smsTemplate.setName(noticeSetting.getName());
|
||||||
|
smsTemplate.setType(noticeSetting.getType());
|
||||||
|
smsTemplate.setParams(noticeSetting.getSmsNotice());
|
||||||
|
if (StringUtils.isNotNull(smsTemplate.getStatus()) && smsTemplate.getStatus().equals(1)) {
|
||||||
|
(new SmsNoticeHandle()).send(params, smsTemplate);
|
||||||
|
|
||||||
|
Map<String, String> sendParams = new LinkedHashMap<>();
|
||||||
|
if (StringUtils.isNotNull(params.getParams())) {
|
||||||
|
for (String s : params.getParams()) {
|
||||||
|
String[] arr = s.split(":");
|
||||||
|
String key = arr[0].trim();
|
||||||
|
String val = arr[1].trim();
|
||||||
|
sendParams.put(key, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, String> sendConfig = new HashMap<>();
|
||||||
|
sendConfig.put("secretKey", "cY7fbU0hvGvUl16ywGn4RUAoiu4zNO");
|
||||||
|
sendConfig.put("name", "阿里云短信");
|
||||||
|
sendConfig.put("sign", "上海中将科教设备");
|
||||||
|
sendConfig.put("alias", "aliyun");
|
||||||
|
sendConfig.put("appKey", "LTAI5tAxZbqdxWnf15651D4C");
|
||||||
|
Integer sendResult = 0;
|
||||||
|
String results = "";
|
||||||
|
String templateParam = JSON.toJSONString(MapUtils.getSmsParams(sendParams, smsTemplate.getContent()));
|
||||||
|
|
||||||
|
AliSms aliSms = new AliSms(sendConfig);
|
||||||
|
results = aliSms.setMobile(mobile)
|
||||||
|
.setTemplateId("SMS_472995029")
|
||||||
|
.setTemplateParams(templateParam)
|
||||||
|
.send();
|
||||||
|
|
||||||
|
sendResult = aliSms.getSendResult();
|
||||||
|
|
||||||
|
if (sendResult == 2) {
|
||||||
|
throw new OperateException(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map工具类
|
* Map工具类
|
||||||
|
|
@ -79,4 +78,60 @@ public class MapUtils {
|
||||||
return map2;
|
return map2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Map<String, String> getSmsParams(Map<String, String> params, String content) {
|
||||||
|
String engine = ConfigUtils.get("sms", "default", "");
|
||||||
|
if (!engine.equals("tencent")) {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取内容变量
|
||||||
|
List<String> arr = new LinkedList<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
String search = "\\$\\{" + entry.getKey() + "}";
|
||||||
|
if (content.indexOf(search) != 1 && !arr.contains(entry.getKey())) {
|
||||||
|
arr.add(entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取变量名称
|
||||||
|
List<Integer> arrIndex = new LinkedList<>();
|
||||||
|
Map<Integer, String> arr2 = new LinkedHashMap<>();
|
||||||
|
if (arr.size() > 0) {
|
||||||
|
for (String v: arr) {
|
||||||
|
int k = content.indexOf(v);
|
||||||
|
arrIndex.add(k);
|
||||||
|
arr2.put(k, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从小到大排序
|
||||||
|
List<String> arr3 = new LinkedList<>();
|
||||||
|
Collections.sort(arrIndex);
|
||||||
|
for (Integer i : arrIndex) {
|
||||||
|
arr3.add(arr2.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取变量对应值
|
||||||
|
Map<String, String> arr4 = new LinkedHashMap<>();
|
||||||
|
for (String v : arr3) {
|
||||||
|
if (StringUtils.isNotNull(params.get(v))) {
|
||||||
|
arr4.put(params.get(v), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getContent(Map<String, String> params, String content) {
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
String searchReplace = "\\$\\{" + entry.getKey() + "}";
|
||||||
|
content = content.replaceAll(searchReplace, entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ public class ExperimentSearchValidate implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(value = "分类id")
|
@ApiModelProperty(value = "分类id")
|
||||||
private Integer classId;
|
private Integer classId;
|
||||||
|
@ApiModelProperty(value = "分类pId")
|
||||||
|
private Integer pId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "实验内容")
|
@ApiModelProperty(value = "实验内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实验信息参数
|
* 实验信息参数
|
||||||
|
|
@ -50,4 +51,7 @@ public class ExperimentUpdateValidate implements Serializable {
|
||||||
@ApiModelProperty(value = "实验内容")
|
@ApiModelProperty(value = "实验内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类ids")
|
||||||
|
private List<Integer> goodsIds ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.wyh.common.validator;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("搜索参数")
|
||||||
|
public class SearchVO {
|
||||||
|
|
||||||
|
@ApiModelProperty("实验id")
|
||||||
|
private Integer id;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.wyh.common.validator;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("用户商品信息创建参数")
|
||||||
|
public class UserGoodsNumUpdateValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "goodsId参数缺失")
|
||||||
|
@ApiModelProperty(value = "商品id")
|
||||||
|
private Integer goodsId;
|
||||||
|
|
||||||
|
@NotNull(message = "num参数缺失")
|
||||||
|
@ApiModelProperty(value = "商品数量")
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wyh.common.vo;
|
package com.wyh.common.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wyh.common.entity.user.UserAddress;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -16,7 +17,7 @@ public class OrderDetailResponseVo {
|
||||||
@ApiModelProperty(value = "订单编号")
|
@ApiModelProperty(value = "订单编号")
|
||||||
private String sn;
|
private String sn;
|
||||||
@ApiModelProperty(value = "收货地址")
|
@ApiModelProperty(value = "收货地址")
|
||||||
private String address;
|
private UserAddress address;
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private String createTime;
|
private String createTime;
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "用户id")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.wyh.common.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderSnDto {
|
||||||
|
|
||||||
|
private String orderSn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.wyh.common.vo.info;
|
package com.wyh.common.vo.info;
|
||||||
|
|
||||||
|
import com.wyh.common.entity.Experiment;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("班级信息列表Vo")
|
@ApiModel("班级信息列表Vo")
|
||||||
|
|
@ -30,5 +32,7 @@ public class ClassInfoListedVo implements Serializable {
|
||||||
@ApiModelProperty(value = "排序编号")
|
@ApiModelProperty(value = "排序编号")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
private List<Experiment> experimentList;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.wyh.front.controller;
|
||||||
|
|
||||||
import com.wyh.common.core.AjaxResult;
|
import com.wyh.common.core.AjaxResult;
|
||||||
import com.wyh.common.validator.UserGoodsCreateValidate;
|
import com.wyh.common.validator.UserGoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.UserGoodsNumUpdateValidate;
|
||||||
import com.wyh.common.vo.CartVo;
|
import com.wyh.common.vo.CartVo;
|
||||||
import com.wyh.front.ZJFrontThreadLocal;
|
import com.wyh.front.ZJFrontThreadLocal;
|
||||||
import com.wyh.front.service.CartService;
|
import com.wyh.front.service.CartService;
|
||||||
|
|
@ -54,4 +55,22 @@ public class CartController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("updateCheckOne")
|
||||||
|
@ApiOperation(value = "修改单个商品选中状态")
|
||||||
|
|
||||||
|
public AjaxResult<Object> updateCheckOne(@RequestParam(name = "goodsId" ) @ApiParam(value = "商品id") Integer goodsId) {
|
||||||
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
|
CartVo cartVo = cartService.updateCheckOne(userId, goodsId);
|
||||||
|
return AjaxResult.success(cartVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("updateNum")
|
||||||
|
@ApiOperation(value = "修改购物车中商品数量")
|
||||||
|
public AjaxResult<Object> updateNum(@RequestBody @Validated UserGoodsNumUpdateValidate updateValidate) {
|
||||||
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
|
CartVo cartVo = cartService.updateNum(updateValidate , userId);
|
||||||
|
return AjaxResult.success(cartVo);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.wyh.common.validator.ExperimentSearchValidate;
|
||||||
import com.wyh.common.validator.annotation.IDMust;
|
import com.wyh.common.validator.annotation.IDMust;
|
||||||
import com.wyh.common.vo.ExperimentDetailVo;
|
import com.wyh.common.vo.ExperimentDetailVo;
|
||||||
import com.wyh.common.vo.ExperimentListedVo;
|
import com.wyh.common.vo.ExperimentListedVo;
|
||||||
|
import com.wyh.front.service.IClassInfoService;
|
||||||
import com.wyh.front.service.IExperimentService;
|
import com.wyh.front.service.IExperimentService;
|
||||||
import com.wyh.front.validate.common.PageValidate;
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -29,6 +30,9 @@ public class ExperimentController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IClassInfoService iClassInfoService;
|
||||||
|
|
||||||
@NotLogin
|
@NotLogin
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation(value="实验信息列表")
|
@ApiOperation(value="实验信息列表")
|
||||||
|
|
@ -46,4 +50,9 @@ public class ExperimentController {
|
||||||
return AjaxResult.success(detail);
|
return AjaxResult.success(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.wyh.front.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.wyh.common.core.AjaxResult;
|
||||||
|
import com.wyh.common.validator.SearchVO;
|
||||||
|
import com.wyh.common.validator.info.ClassInfoSearchValidate;
|
||||||
|
import com.wyh.front.service.IClassInfoService;
|
||||||
|
import com.wyh.front.service.IExperimentService;
|
||||||
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("front/")
|
||||||
|
@Api(tags = "(PC端)实验信息")
|
||||||
|
public class ExperimentPcController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IExperimentService iExperimentService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IClassInfoService iClassInfoService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("experiment/pc/treeList")
|
||||||
|
@ApiOperation(value="(pc)实验树状列表")
|
||||||
|
public AjaxResult<JSONArray> list(@Validated PageValidate pageValidate,
|
||||||
|
@Validated ClassInfoSearchValidate searchValidate) {
|
||||||
|
JSONArray list = iClassInfoService.listTree(pageValidate, searchValidate);
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
JSONObject obj = list.getJSONObject(i);
|
||||||
|
System.out.println("obj = " + obj);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("experiment/pc/getGoods")
|
||||||
|
@ApiOperation(value="(pc)点击获取实验商品")
|
||||||
|
public AjaxResult<Object> getGoods(@Validated PageValidate pageValidate,
|
||||||
|
@Validated SearchVO searchVO) {
|
||||||
|
return iExperimentService.getGoods(pageValidate,searchVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,8 +9,8 @@ import com.wyh.common.enums.NoticeEnum;
|
||||||
import com.wyh.common.exception.OperateException;
|
import com.wyh.common.exception.OperateException;
|
||||||
import com.wyh.common.mapper.notice.NoticeRecordMapper;
|
import com.wyh.common.mapper.notice.NoticeRecordMapper;
|
||||||
import com.wyh.common.plugin.notice.NoticeDriver;
|
import com.wyh.common.plugin.notice.NoticeDriver;
|
||||||
|
import com.wyh.common.plugin.notice.engine.SmsNoticeHandle;
|
||||||
import com.wyh.common.plugin.notice.vo.NoticeSmsVo;
|
import com.wyh.common.plugin.notice.vo.NoticeSmsVo;
|
||||||
import com.wyh.common.util.HttpUtils;
|
|
||||||
import com.wyh.common.util.StringUtils;
|
import com.wyh.common.util.StringUtils;
|
||||||
import com.wyh.common.util.ToolUtils;
|
import com.wyh.common.util.ToolUtils;
|
||||||
import com.wyh.front.ZJFrontThreadLocal;
|
import com.wyh.front.ZJFrontThreadLocal;
|
||||||
|
|
@ -187,11 +187,14 @@ public class LoginController {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
@NotLogin
|
||||||
ZJFrontThreadLocal.getUserId();
|
@GetMapping("/putsms")
|
||||||
String s = HttpUtils.sendGet("https://github.com/modood/Administrative-divisions-of-China/blob/master/dist/pca-code.json");
|
@ApiOperation(value="ceshi")
|
||||||
System.out.println(s);
|
public AjaxResult<Object> putsms() {
|
||||||
|
|
||||||
|
new SmsNoticeHandle().sendUserMessage("17647557909","张三","12345678901");
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,13 @@ package com.wyh.front.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.wyh.common.core.AjaxResult;
|
import com.wyh.common.core.AjaxResult;
|
||||||
|
import com.wyh.common.core.PageResult;
|
||||||
|
import com.wyh.common.entity.Order;
|
||||||
import com.wyh.common.validator.OrderSearchValidate;
|
import com.wyh.common.validator.OrderSearchValidate;
|
||||||
|
import com.wyh.common.vo.OrderResponseVo;
|
||||||
import com.wyh.front.service.OrderService;
|
import com.wyh.front.service.OrderService;
|
||||||
import com.wyh.front.validate.OrderCreateDto;
|
import com.wyh.front.validate.OrderCreateDto;
|
||||||
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -25,15 +29,16 @@ public class OrderController {
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
@ApiOperation("添加订单")
|
@ApiOperation("添加订单")
|
||||||
public AjaxResult<Object> add(@Validated @RequestBody OrderCreateDto orderCreateDto){
|
public AjaxResult<Object> add(@Validated @RequestBody OrderCreateDto orderCreateDto){
|
||||||
orderService.add(orderCreateDto);
|
Order add = orderService.add(orderCreateDto);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success(add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("get")
|
@GetMapping("get")
|
||||||
@ApiOperation("获取订单")
|
@ApiOperation("获取订单")
|
||||||
public AjaxResult<Object> get(@Validated OrderSearchValidate validate){
|
public AjaxResult<PageResult<OrderResponseVo>> get(@Validated PageValidate pageValidate,
|
||||||
return AjaxResult.success(orderService.get(validate));
|
@Validated OrderSearchValidate validate){
|
||||||
|
return AjaxResult.success(orderService.get(pageValidate,validate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import com.wyh.common.enums.PaymentEnum;
|
||||||
import com.wyh.common.exception.OperateException;
|
import com.wyh.common.exception.OperateException;
|
||||||
import com.wyh.common.mapper.RechargeOrderMapper;
|
import com.wyh.common.mapper.RechargeOrderMapper;
|
||||||
import com.wyh.common.plugin.wechat.WxPayDriver;
|
import com.wyh.common.plugin.wechat.WxPayDriver;
|
||||||
|
import com.wyh.common.vo.OrderSnDto;
|
||||||
import com.wyh.front.ZJFrontThreadLocal;
|
import com.wyh.front.ZJFrontThreadLocal;
|
||||||
import com.wyh.front.service.IPayService;
|
import com.wyh.front.service.IPayService;
|
||||||
import com.wyh.front.validate.PaymentValidate;
|
import com.wyh.front.validate.PaymentValidate;
|
||||||
|
|
@ -30,8 +31,7 @@ import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/front/pay")
|
@RequestMapping("/front/pay")
|
||||||
//@Api(tags = "支付管理")
|
@Api(tags = "支付管理")
|
||||||
@ApiIgnore
|
|
||||||
public class PayController {
|
public class PayController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -41,6 +41,7 @@ public class PayController {
|
||||||
IPayService iPayService;
|
IPayService iPayService;
|
||||||
|
|
||||||
@GetMapping("/payWay")
|
@GetMapping("/payWay")
|
||||||
|
@ApiIgnore
|
||||||
@ApiOperation("支付方式")
|
@ApiOperation("支付方式")
|
||||||
public AjaxResult<PayWayListVo> payWay(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
public AjaxResult<PayWayListVo> payWay(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
||||||
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
||||||
|
|
@ -51,6 +52,7 @@ public class PayController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/payStatus")
|
@GetMapping("/payStatus")
|
||||||
|
@ApiIgnore
|
||||||
@ApiOperation(("支付状态"))
|
@ApiOperation(("支付状态"))
|
||||||
public AjaxResult<PayStatusVo> payStatus(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
public AjaxResult<PayStatusVo> payStatus(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
||||||
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
||||||
|
|
@ -59,6 +61,7 @@ public class PayController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/prepay")
|
@PostMapping("/prepay")
|
||||||
|
@ApiIgnore
|
||||||
@ApiOperation("发起支付")
|
@ApiOperation("发起支付")
|
||||||
public AjaxResult<Object> prepay(@Validated @RequestBody PaymentValidate requestObj) {
|
public AjaxResult<Object> prepay(@Validated @RequestBody PaymentValidate requestObj) {
|
||||||
// 接收参数
|
// 接收参数
|
||||||
|
|
@ -102,6 +105,7 @@ public class PayController {
|
||||||
|
|
||||||
@NotLogin
|
@NotLogin
|
||||||
@PostMapping("/notifyMnp")
|
@PostMapping("/notifyMnp")
|
||||||
|
@ApiIgnore
|
||||||
@ApiOperation("微信支付回调")
|
@ApiOperation("微信支付回调")
|
||||||
public AjaxResult<Object> notifyMnp(@RequestBody String jsonData, HttpServletRequest request) throws WxPayException {
|
public AjaxResult<Object> notifyMnp(@RequestBody String jsonData, HttpServletRequest request) throws WxPayException {
|
||||||
// 构建签名
|
// 构建签名
|
||||||
|
|
@ -125,4 +129,16 @@ public class PayController {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/deductPoints")
|
||||||
|
@ApiOperation("扣除积分")
|
||||||
|
public AjaxResult deductPoints(@RequestBody OrderSnDto orderSnDto){
|
||||||
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
|
|
||||||
|
iPayService.deductPoints(orderSnDto,userId);
|
||||||
|
return AjaxResult.success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wyh.front.service;
|
package com.wyh.front.service;
|
||||||
|
|
||||||
import com.wyh.common.validator.UserGoodsCreateValidate;
|
import com.wyh.common.validator.UserGoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.UserGoodsNumUpdateValidate;
|
||||||
import com.wyh.common.vo.CartVo;
|
import com.wyh.common.vo.CartVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -15,4 +16,8 @@ public interface CartService {
|
||||||
void remove(Integer[] ids);
|
void remove(Integer[] ids);
|
||||||
|
|
||||||
void remove(List<Integer> ids);
|
void remove(List<Integer> ids);
|
||||||
|
|
||||||
|
CartVo updateCheckOne(Integer userId, Integer goodsId);
|
||||||
|
|
||||||
|
CartVo updateNum(UserGoodsNumUpdateValidate updateValidate , Integer userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,5 @@ public interface IClassInfoService {
|
||||||
*/
|
*/
|
||||||
void del(Integer id);
|
void del(Integer id);
|
||||||
|
|
||||||
|
JSONArray listTree(PageValidate pageValidate, ClassInfoSearchValidate searchValidate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package com.wyh.front.service;
|
package com.wyh.front.service;
|
||||||
|
|
||||||
|
import com.wyh.common.core.AjaxResult;
|
||||||
import com.wyh.common.core.PageResult;
|
import com.wyh.common.core.PageResult;
|
||||||
import com.wyh.common.validator.ExperimentCreateValidate;
|
import com.wyh.common.validator.ExperimentCreateValidate;
|
||||||
import com.wyh.common.validator.ExperimentSearchValidate;
|
import com.wyh.common.validator.ExperimentSearchValidate;
|
||||||
import com.wyh.common.validator.ExperimentUpdateValidate;
|
import com.wyh.common.validator.ExperimentUpdateValidate;
|
||||||
|
import com.wyh.common.validator.SearchVO;
|
||||||
import com.wyh.common.vo.ExperimentDetailVo;
|
import com.wyh.common.vo.ExperimentDetailVo;
|
||||||
import com.wyh.common.vo.ExperimentListedVo;
|
import com.wyh.common.vo.ExperimentListedVo;
|
||||||
import com.wyh.front.validate.common.PageValidate;
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
|
|
@ -57,4 +59,5 @@ public interface IExperimentService {
|
||||||
*/
|
*/
|
||||||
void del(Integer id);
|
void del(Integer id);
|
||||||
|
|
||||||
|
AjaxResult<Object> getGoods(PageValidate pageValidate, SearchVO searchVO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wyh.front.service;
|
package com.wyh.front.service;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
import com.wyh.common.vo.OrderSnDto;
|
||||||
import com.wyh.front.validate.PaymentValidate;
|
import com.wyh.front.validate.PaymentValidate;
|
||||||
import com.wyh.front.vo.pay.PayStatusVo;
|
import com.wyh.front.vo.pay.PayStatusVo;
|
||||||
import com.wyh.front.vo.pay.PayWayListVo;
|
import com.wyh.front.vo.pay.PayWayListVo;
|
||||||
|
|
@ -49,4 +50,5 @@ public interface IPayService {
|
||||||
*/
|
*/
|
||||||
void handlePaidNotify(String attach, String outTradeNo, String transactionId) throws WxPayException;
|
void handlePaidNotify(String attach, String outTradeNo, String transactionId) throws WxPayException;
|
||||||
|
|
||||||
|
void deductPoints(OrderSnDto orderSnDto, Integer userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
package com.wyh.front.service;
|
package com.wyh.front.service;
|
||||||
|
|
||||||
|
import com.wyh.common.core.PageResult;
|
||||||
|
import com.wyh.common.entity.Order;
|
||||||
import com.wyh.common.validator.OrderSearchValidate;
|
import com.wyh.common.validator.OrderSearchValidate;
|
||||||
import com.wyh.common.vo.OrderDetailResponseVo;
|
import com.wyh.common.vo.OrderDetailResponseVo;
|
||||||
import com.wyh.common.vo.OrderResponseVo;
|
import com.wyh.common.vo.OrderResponseVo;
|
||||||
import com.wyh.front.validate.OrderCreateDto;
|
import com.wyh.front.validate.OrderCreateDto;
|
||||||
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface OrderService {
|
public interface OrderService {
|
||||||
void add(OrderCreateDto orderCreateDto);
|
Order add(OrderCreateDto orderCreateDto);
|
||||||
|
|
||||||
List<OrderResponseVo> get(OrderSearchValidate validate);
|
PageResult<OrderResponseVo> get(PageValidate pageValidate, OrderSearchValidate validate);
|
||||||
|
|
||||||
OrderDetailResponseVo getDetail(OrderSearchValidate validate);
|
OrderDetailResponseVo getDetail(OrderSearchValidate validate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.wyh.common.entity.goods.Goods;
|
||||||
import com.wyh.common.mapper.UserGoodsMapper;
|
import com.wyh.common.mapper.UserGoodsMapper;
|
||||||
import com.wyh.common.mapper.goods.GoodsMapper;
|
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||||
import com.wyh.common.validator.UserGoodsCreateValidate;
|
import com.wyh.common.validator.UserGoodsCreateValidate;
|
||||||
|
import com.wyh.common.validator.UserGoodsNumUpdateValidate;
|
||||||
import com.wyh.common.vo.CartVo;
|
import com.wyh.common.vo.CartVo;
|
||||||
import com.wyh.common.vo.GoodsUserVo;
|
import com.wyh.common.vo.GoodsUserVo;
|
||||||
import com.wyh.front.ZJFrontThreadLocal;
|
import com.wyh.front.ZJFrontThreadLocal;
|
||||||
|
|
@ -33,11 +34,19 @@ public class CartServiceImpl implements CartService {
|
||||||
@Override
|
@Override
|
||||||
public void addCart( List<UserGoodsCreateValidate> cartCreateValited) {
|
public void addCart( List<UserGoodsCreateValidate> cartCreateValited) {
|
||||||
Integer userId = ZJFrontThreadLocal.getUserId();
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
|
|
||||||
for (UserGoodsCreateValidate userGoodsCreateValidate : cartCreateValited) {
|
for (UserGoodsCreateValidate userGoodsCreateValidate : cartCreateValited) {
|
||||||
Integer goodsId = userGoodsCreateValidate.getGoodsId();
|
Integer goodsId = userGoodsCreateValidate.getGoodsId();
|
||||||
Goods goods = goodsMapper.selectById(goodsId);
|
Goods goods = goodsMapper.selectById(goodsId);
|
||||||
|
|
||||||
Integer num = userGoodsCreateValidate.getNum();
|
Integer num = userGoodsCreateValidate.getNum();
|
||||||
Integer isCheck = userGoodsCreateValidate.getIsCheck();
|
Integer isCheck = userGoodsCreateValidate.getIsCheck();
|
||||||
|
UserGoods selectOne = userGoodsMapper.selectOne(Wrappers.<UserGoods>lambdaQuery().eq(UserGoods::getUserId, userId).eq(UserGoods::getGoodsId, goodsId));
|
||||||
|
if (selectOne != null) {
|
||||||
|
selectOne.setNum(selectOne.getNum() + num);
|
||||||
|
userGoodsMapper.updateById(selectOne);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
UserGoods userGoods = new UserGoods();
|
UserGoods userGoods = new UserGoods();
|
||||||
userGoods.setUserId(userId);
|
userGoods.setUserId(userId);
|
||||||
userGoods.setGoodsId(goodsId);
|
userGoods.setGoodsId(goodsId);
|
||||||
|
|
@ -89,8 +98,7 @@ public class CartServiceImpl implements CartService {
|
||||||
|
|
||||||
//获取选中商品数量
|
//获取选中商品数量
|
||||||
Integer checkNum = collect.stream()
|
Integer checkNum = collect.stream()
|
||||||
.filter(obj -> obj.getIsCheck() == 1)
|
.map(UserGoods::getIsCheck)
|
||||||
.map(UserGoods::getNum)
|
|
||||||
.reduce(Integer::sum)
|
.reduce(Integer::sum)
|
||||||
.orElse(0);
|
.orElse(0);
|
||||||
int totalNum = userGoodsList.stream()
|
int totalNum = userGoodsList.stream()
|
||||||
|
|
@ -128,6 +136,27 @@ public class CartServiceImpl implements CartService {
|
||||||
userGoodsMapper.deleteBatchIds(ids);
|
userGoodsMapper.deleteBatchIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CartVo updateCheckOne(Integer userId, Integer goodsId) {
|
||||||
|
|
||||||
|
UserGoods userGoods = userGoodsMapper.selectOne(Wrappers.<UserGoods>lambdaQuery().eq(UserGoods::getUserId, userId).eq(UserGoods::getGoodsId, goodsId));
|
||||||
|
if (userGoods.getIsCheck().equals(1)) {
|
||||||
|
userGoods.setIsCheck(0);
|
||||||
|
} else {
|
||||||
|
userGoods.setIsCheck(1);
|
||||||
|
}
|
||||||
|
userGoodsMapper.updateById(userGoods);
|
||||||
|
return getCart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CartVo updateNum(UserGoodsNumUpdateValidate updateValidate, Integer userId) {
|
||||||
|
UserGoods userGoods = userGoodsMapper.selectOne(Wrappers.<UserGoods>lambdaQuery().eq(UserGoods::getUserId, userId).eq(UserGoods::getGoodsId, updateValidate.getGoodsId()));
|
||||||
|
userGoods.setNum(updateValidate.getNum());
|
||||||
|
userGoodsMapper.updateById(userGoods);
|
||||||
|
return getCart();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateCheckDown(Integer userId) {
|
private void updateCheckDown(Integer userId) {
|
||||||
userGoodsMapper.update(null, Wrappers.<UserGoods>lambdaUpdate()
|
userGoodsMapper.update(null, Wrappers.<UserGoods>lambdaUpdate()
|
||||||
.set(UserGoods::getIsCheck, 0)
|
.set(UserGoods::getIsCheck, 0)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,11 @@ package com.wyh.front.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.github.yulichang.query.MPJQueryWrapper;
|
import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
|
import com.wyh.common.entity.Experiment;
|
||||||
import com.wyh.common.entity.info.ClassInfo;
|
import com.wyh.common.entity.info.ClassInfo;
|
||||||
|
import com.wyh.common.mapper.ExperimentMapper;
|
||||||
import com.wyh.common.mapper.info.ClassInfoMapper;
|
import com.wyh.common.mapper.info.ClassInfoMapper;
|
||||||
import com.wyh.common.util.ListUtils;
|
import com.wyh.common.util.ListUtils;
|
||||||
import com.wyh.common.util.TimeUtils;
|
import com.wyh.common.util.TimeUtils;
|
||||||
|
|
@ -32,6 +35,9 @@ public class ClassInfoServiceImpl implements IClassInfoService {
|
||||||
@Resource
|
@Resource
|
||||||
ClassInfoMapper classInfoMapper;
|
ClassInfoMapper classInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ExperimentMapper experimentMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 班级信息列表
|
* 班级信息列表
|
||||||
*
|
*
|
||||||
|
|
@ -150,4 +156,32 @@ public class ClassInfoServiceImpl implements IClassInfoService {
|
||||||
classInfoMapper.updateById(model);
|
classInfoMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONArray listTree(PageValidate pageValidate, ClassInfoSearchValidate searchValidate) {
|
||||||
|
MPJQueryWrapper<ClassInfo> mpjQueryWrapper = new MPJQueryWrapper<>();
|
||||||
|
mpjQueryWrapper.selectAll(ClassInfo.class);
|
||||||
|
mpjQueryWrapper.eq("is_delete", 0);
|
||||||
|
mpjQueryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
|
||||||
|
classInfoMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{
|
||||||
|
"like:name:str",
|
||||||
|
"=:pid:str",
|
||||||
|
"=:sort:str",
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ClassInfoListedVo> array = classInfoMapper.selectJoinList(
|
||||||
|
ClassInfoListedVo.class,
|
||||||
|
mpjQueryWrapper);
|
||||||
|
|
||||||
|
for (ClassInfoListedVo item : array) {
|
||||||
|
item.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||||
|
item.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||||
|
List<Experiment> experiments = experimentMapper.selectList(Wrappers.<Experiment>lambdaQuery().eq(Experiment::getClassId, item.getId()).eq(Experiment::getIsDelete, 0).eq(Experiment::getPid, item.getPid()));
|
||||||
|
item.setExperimentList(experiments);
|
||||||
|
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(array));
|
||||||
|
|
||||||
|
return ListUtils.listToTree(jsonArray, "id", "pid", "children");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ package com.wyh.front.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.wyh.common.core.AjaxResult;
|
||||||
import com.wyh.common.core.PageResult;
|
import com.wyh.common.core.PageResult;
|
||||||
import com.wyh.common.entity.Experiment;
|
import com.wyh.common.entity.Experiment;
|
||||||
import com.wyh.common.entity.GoodsExperiment;
|
import com.wyh.common.entity.GoodsExperiment;
|
||||||
|
|
@ -17,6 +19,7 @@ import com.wyh.common.util.TimeUtils;
|
||||||
import com.wyh.common.validator.ExperimentCreateValidate;
|
import com.wyh.common.validator.ExperimentCreateValidate;
|
||||||
import com.wyh.common.validator.ExperimentSearchValidate;
|
import com.wyh.common.validator.ExperimentSearchValidate;
|
||||||
import com.wyh.common.validator.ExperimentUpdateValidate;
|
import com.wyh.common.validator.ExperimentUpdateValidate;
|
||||||
|
import com.wyh.common.validator.SearchVO;
|
||||||
import com.wyh.common.vo.ExperimentDetailVo;
|
import com.wyh.common.vo.ExperimentDetailVo;
|
||||||
import com.wyh.common.vo.ExperimentListedVo;
|
import com.wyh.common.vo.ExperimentListedVo;
|
||||||
import com.wyh.common.vo.goods.GoodsListedVo;
|
import com.wyh.common.vo.goods.GoodsListedVo;
|
||||||
|
|
@ -76,6 +79,7 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
"=:sort:int",
|
"=:sort:int",
|
||||||
"=:isShow@is_show:int",
|
"=:isShow@is_show:int",
|
||||||
"=:classId@class_id:int",
|
"=:classId@class_id:int",
|
||||||
|
"=:PId@pid:int",
|
||||||
"=:content:str",
|
"=:content:str",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -151,6 +155,10 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
model.setExperimentVideo(createValidate.getExperimentVideo());
|
model.setExperimentVideo(createValidate.getExperimentVideo());
|
||||||
model.setSort(createValidate.getSort());
|
model.setSort(createValidate.getSort());
|
||||||
model.setIsShow(createValidate.getIsShow());
|
model.setIsShow(createValidate.getIsShow());
|
||||||
|
ClassInfo classInfo = classInfoMapper.selectById(createValidate.getClassId());
|
||||||
|
if (classInfo!=null){
|
||||||
|
model.setPid(classInfo.getPid());
|
||||||
|
}
|
||||||
model.setClassId(createValidate.getClassId());
|
model.setClassId(createValidate.getClassId());
|
||||||
model.setContent(createValidate.getContent());
|
model.setContent(createValidate.getContent());
|
||||||
experimentMapper.insert(model);
|
experimentMapper.insert(model);
|
||||||
|
|
@ -205,4 +213,28 @@ public class ExperimentServiceImpl implements IExperimentService {
|
||||||
experimentMapper.updateById(model);
|
experimentMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult<Object> getGoods(PageValidate pageValidate, SearchVO searchVO) {
|
||||||
|
Integer page = pageValidate.getPageNo();
|
||||||
|
Integer limit = pageValidate.getPageSize();
|
||||||
|
QueryWrapper<GoodsExperiment> queryWrapper = new QueryWrapper<>();
|
||||||
|
if (searchVO.getId() != null) {
|
||||||
|
queryWrapper.like("id", searchVO.getId());
|
||||||
|
}
|
||||||
|
List<GoodsExperiment> goodsExperiments = goodsExperimentMapper.selectList(queryWrapper);
|
||||||
|
if (CollectionUtils.isNotEmpty(goodsExperiments)) {
|
||||||
|
List<Integer> collect = goodsExperiments.stream().map(GoodsExperiment::getGoodsId).collect(Collectors.toList());
|
||||||
|
QueryWrapper<Goods> queryWrapper1 = new QueryWrapper<>();
|
||||||
|
queryWrapper1.in("id", collect);
|
||||||
|
Page<Goods> page1 = new Page<>(page, limit);
|
||||||
|
IPage<Goods> iPage = goodsMapper.selectPage(page1, queryWrapper1);
|
||||||
|
return AjaxResult.success(iPage);
|
||||||
|
}
|
||||||
|
// goodsMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,23 @@
|
||||||
package com.wyh.front.service.impl;
|
package com.wyh.front.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.wyh.common.core.PageResult;
|
||||||
import com.wyh.common.entity.GoodsOrder;
|
import com.wyh.common.entity.GoodsOrder;
|
||||||
import com.wyh.common.entity.Order;
|
import com.wyh.common.entity.Order;
|
||||||
|
import com.wyh.common.entity.Salesman;
|
||||||
import com.wyh.common.entity.goods.Goods;
|
import com.wyh.common.entity.goods.Goods;
|
||||||
import com.wyh.common.entity.user.User;
|
import com.wyh.common.entity.user.User;
|
||||||
import com.wyh.common.entity.user.UserAddress;
|
import com.wyh.common.entity.user.UserAddress;
|
||||||
import com.wyh.common.mapper.GoodsOrderMapper;
|
import com.wyh.common.mapper.GoodsOrderMapper;
|
||||||
import com.wyh.common.mapper.OrderMapper;
|
import com.wyh.common.mapper.OrderMapper;
|
||||||
|
import com.wyh.common.mapper.SalesmanMapper;
|
||||||
import com.wyh.common.mapper.goods.GoodsMapper;
|
import com.wyh.common.mapper.goods.GoodsMapper;
|
||||||
import com.wyh.common.mapper.user.UserAddressMapper;
|
import com.wyh.common.mapper.user.UserAddressMapper;
|
||||||
import com.wyh.common.mapper.user.UserMapper;
|
import com.wyh.common.mapper.user.UserMapper;
|
||||||
|
import com.wyh.common.plugin.notice.engine.SmsNoticeHandle;
|
||||||
import com.wyh.common.util.TimeUtils;
|
import com.wyh.common.util.TimeUtils;
|
||||||
import com.wyh.common.util.ToolUtils;
|
import com.wyh.common.util.ToolUtils;
|
||||||
import com.wyh.common.validator.OrderSearchValidate;
|
import com.wyh.common.validator.OrderSearchValidate;
|
||||||
|
|
@ -22,6 +28,7 @@ import com.wyh.front.ZJFrontThreadLocal;
|
||||||
import com.wyh.front.service.OrderService;
|
import com.wyh.front.service.OrderService;
|
||||||
import com.wyh.front.validate.OrderCreateDto;
|
import com.wyh.front.validate.OrderCreateDto;
|
||||||
import com.wyh.front.validate.OrderGoodsDto;
|
import com.wyh.front.validate.OrderGoodsDto;
|
||||||
|
import com.wyh.front.validate.common.PageValidate;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
@ -52,8 +59,13 @@ public class OrderServiceImpl implements OrderService {
|
||||||
@Resource
|
@Resource
|
||||||
private GoodsOrderMapper goodsOrderMapper;
|
private GoodsOrderMapper goodsOrderMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SalesmanMapper salesmanMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(OrderCreateDto orderCreateDto) {
|
public Order add(OrderCreateDto orderCreateDto) {
|
||||||
Integer userId = ZJFrontThreadLocal.getUserId();
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
Integer source = orderCreateDto.getSource();
|
Integer source = orderCreateDto.getSource();
|
||||||
String sn = "order" + ToolUtils.randomString(16);
|
String sn = "order" + ToolUtils.randomString(16);
|
||||||
|
|
@ -84,7 +96,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
}
|
}
|
||||||
User user = userMapper.selectById(userId);
|
User user = userMapper.selectById(userId);
|
||||||
Assert.isTrue(user != null, "用户不存在");
|
Assert.isTrue(user != null, "用户不存在");
|
||||||
Assert.isTrue(user.getMoney().compareTo(totalPrice) >= 0, "余额不足");
|
// Assert.isTrue(user.getMoney().compareTo(totalPrice) >= 0, "余额不足");
|
||||||
Order order = new Order();
|
Order order = new Order();
|
||||||
order.setSn(sn);
|
order.setSn(sn);
|
||||||
order.setUserId(userId);
|
order.setUserId(userId);
|
||||||
|
|
@ -95,22 +107,65 @@ public class OrderServiceImpl implements OrderService {
|
||||||
order.setTotalPrice(totalPrice);
|
order.setTotalPrice(totalPrice);
|
||||||
order.setAdId(orderCreateDto.getAdId());
|
order.setAdId(orderCreateDto.getAdId());
|
||||||
|
|
||||||
orderMapper.insert(order);
|
int insert = orderMapper.insert(order);
|
||||||
|
if (insert <= 0) {
|
||||||
|
throw new RuntimeException("创建订单失败");
|
||||||
|
}
|
||||||
|
new SmsNoticeHandle().sendUserMessage(user.getMobile(),user.getNickname(),sn);
|
||||||
|
|
||||||
|
Assert.isTrue(insert > 0, "创建订单失败");
|
||||||
|
String mobile = "";
|
||||||
|
String name = "";
|
||||||
|
String address = "";
|
||||||
|
List<Salesman> salesmen = salesmanMapper.selectList(null);
|
||||||
|
UserAddress userAddress = addressMapper.selectById(orderCreateDto.getAdId());
|
||||||
|
for (Salesman salesman : salesmen) {
|
||||||
|
if(salesman.getAddress().contains(userAddress.getCity()) || salesman.getAddress().contains(userAddress.getProvince())) {
|
||||||
|
mobile = salesman.getMobile();
|
||||||
|
name = salesman.getName();
|
||||||
|
address = userAddress.getArea() + userAddress.getAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送短信给业务员
|
||||||
|
new SmsNoticeHandle().sendMessage(mobile, name , address , user.getMobile());
|
||||||
|
|
||||||
|
|
||||||
|
// NoticeRecord noticeRecord = noticeRecordMapper.selectOne(new QueryWrapper<NoticeRecord>()
|
||||||
|
// .eq("account", smsValidate.getMobile())
|
||||||
|
// .eq("scene", smsValidate.getScene())
|
||||||
|
// .eq("status", Arrays.asList(NoticeEnum.STATUS_WAIT, NoticeEnum.STATUS_OK))
|
||||||
|
// .orderByDesc("id")
|
||||||
|
// .last("limit 1"));
|
||||||
|
//
|
||||||
|
// if (StringUtils.isNotNull(noticeRecord)) {
|
||||||
|
// if (noticeRecord.getCreateTime() >= (System.currentTimeMillis() / 1000 - 60)){
|
||||||
|
// throw new OperateException("操作频繁,请稍后再试!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
return order;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderResponseVo> get(OrderSearchValidate validate) {
|
public PageResult<OrderResponseVo> get(PageValidate pageValidate, OrderSearchValidate validate) {
|
||||||
|
Integer pageNo = pageValidate.getPageNo();
|
||||||
|
Integer pageSize = pageValidate.getPageSize();
|
||||||
|
|
||||||
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (validate.getStatus() != null && validate.getStatus() != 0) {
|
if (validate.getStatus() != null && validate.getStatus() != 0) {
|
||||||
orderLambdaQueryWrapper.eq(Order::getStatus, validate.getStatus());
|
orderLambdaQueryWrapper.eq(Order::getStatus, validate.getStatus());
|
||||||
}
|
}
|
||||||
Integer userId = ZJFrontThreadLocal.getUserId();
|
Integer userId = ZJFrontThreadLocal.getUserId();
|
||||||
orderLambdaQueryWrapper.eq(Order::getUserId, userId);
|
orderLambdaQueryWrapper.eq(Order::getUserId, userId);
|
||||||
List<Order> orders = orderMapper.selectList(orderLambdaQueryWrapper);
|
orderLambdaQueryWrapper.orderByDesc(Order::getCreateTime);
|
||||||
|
IPage<Order> iPage = orderMapper.selectPage( new Page<>(pageNo, pageSize), orderLambdaQueryWrapper);
|
||||||
|
|
||||||
|
List<Order> orders = iPage.getRecords();
|
||||||
List<OrderResponseVo> orderResponseVos = new ArrayList<>();
|
List<OrderResponseVo> orderResponseVos = new ArrayList<>();
|
||||||
if (CollectionUtils.isEmpty(orders)) {
|
if (CollectionUtils.isEmpty(orders)) {
|
||||||
return orderResponseVos;
|
return new PageResult<>();
|
||||||
}
|
}
|
||||||
List<String> orderSns = orders.stream().map(Order::getSn).collect(Collectors.toList());
|
List<String> orderSns = orders.stream().map(Order::getSn).collect(Collectors.toList());
|
||||||
List<GoodsOrder> goodsOrders = goodsOrderMapper.selectList(Wrappers.<GoodsOrder>lambdaQuery().in(GoodsOrder::getOrderSn, orderSns));
|
List<GoodsOrder> goodsOrders = goodsOrderMapper.selectList(Wrappers.<GoodsOrder>lambdaQuery().in(GoodsOrder::getOrderSn, orderSns));
|
||||||
|
|
@ -134,7 +189,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
}
|
}
|
||||||
orderResponseVos.add(orderResponseVo) ;
|
orderResponseVos.add(orderResponseVo) ;
|
||||||
}
|
}
|
||||||
return orderResponseVos;
|
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), orderResponseVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -154,7 +209,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderDetailResponseVo.setStatus(order.getStatus());
|
orderDetailResponseVo.setStatus(order.getStatus());
|
||||||
orderDetailResponseVo.setUserId(order.getUserId());
|
orderDetailResponseVo.setUserId(order.getUserId());
|
||||||
orderDetailResponseVo.setCreateTime(TimeUtils.timestampToDate(order.getCreateTime()));
|
orderDetailResponseVo.setCreateTime(TimeUtils.timestampToDate(order.getCreateTime()));
|
||||||
orderDetailResponseVo.setAddress(userAddresses.getAddress());
|
orderDetailResponseVo.setAddress(userAddresses);
|
||||||
orderDetailResponseVo.setMobile(user.getMobile());
|
orderDetailResponseVo.setMobile(user.getMobile());
|
||||||
orderDetailResponseVo.setNickName(user.getNickname());
|
orderDetailResponseVo.setNickName(user.getNickname());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package com.wyh.front.service.impl;
|
package com.wyh.front.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.wyh.common.entity.GoodsOrder;
|
||||||
|
import com.wyh.common.entity.Order;
|
||||||
import com.wyh.common.entity.RechargeOrder;
|
import com.wyh.common.entity.RechargeOrder;
|
||||||
|
import com.wyh.common.entity.UserGoods;
|
||||||
import com.wyh.common.entity.setting.DevPayConfig;
|
import com.wyh.common.entity.setting.DevPayConfig;
|
||||||
import com.wyh.common.entity.setting.DevPayWay;
|
import com.wyh.common.entity.setting.DevPayWay;
|
||||||
import com.wyh.common.entity.user.User;
|
import com.wyh.common.entity.user.User;
|
||||||
|
|
@ -11,34 +15,49 @@ import com.wyh.common.enums.LogMoneyEnum;
|
||||||
import com.wyh.common.enums.PaymentEnum;
|
import com.wyh.common.enums.PaymentEnum;
|
||||||
import com.wyh.common.exception.OperateException;
|
import com.wyh.common.exception.OperateException;
|
||||||
import com.wyh.common.exception.PaymentException;
|
import com.wyh.common.exception.PaymentException;
|
||||||
import com.wyh.common.mapper.log.LogMoneyMapper;
|
import com.wyh.common.mapper.GoodsOrderMapper;
|
||||||
|
import com.wyh.common.mapper.OrderMapper;
|
||||||
import com.wyh.common.mapper.RechargeOrderMapper;
|
import com.wyh.common.mapper.RechargeOrderMapper;
|
||||||
|
import com.wyh.common.mapper.UserGoodsMapper;
|
||||||
|
import com.wyh.common.mapper.log.LogMoneyMapper;
|
||||||
import com.wyh.common.mapper.setting.DevPayConfigMapper;
|
import com.wyh.common.mapper.setting.DevPayConfigMapper;
|
||||||
import com.wyh.common.mapper.setting.DevPayWayMapper;
|
import com.wyh.common.mapper.setting.DevPayWayMapper;
|
||||||
import com.wyh.common.mapper.user.UserAuthMapper;
|
import com.wyh.common.mapper.user.UserAuthMapper;
|
||||||
import com.wyh.common.mapper.user.UserMapper;
|
import com.wyh.common.mapper.user.UserMapper;
|
||||||
import com.wyh.common.plugin.wechat.WxPayDriver;
|
import com.wyh.common.plugin.wechat.WxPayDriver;
|
||||||
import com.wyh.common.plugin.wechat.request.PaymentRequestV3;
|
import com.wyh.common.plugin.wechat.request.PaymentRequestV3;
|
||||||
|
import com.wyh.common.util.StringUtils;
|
||||||
|
import com.wyh.common.util.TimeUtils;
|
||||||
|
import com.wyh.common.util.UrlUtils;
|
||||||
|
import com.wyh.common.vo.OrderSnDto;
|
||||||
import com.wyh.front.service.IPayService;
|
import com.wyh.front.service.IPayService;
|
||||||
import com.wyh.front.validate.PaymentValidate;
|
import com.wyh.front.validate.PaymentValidate;
|
||||||
import com.wyh.front.vo.pay.PayStatusVo;
|
import com.wyh.front.vo.pay.PayStatusVo;
|
||||||
import com.wyh.front.vo.pay.PayWayInfoVo;
|
import com.wyh.front.vo.pay.PayWayInfoVo;
|
||||||
import com.wyh.front.vo.pay.PayWayListVo;
|
import com.wyh.front.vo.pay.PayWayListVo;
|
||||||
import com.wyh.common.util.StringUtils;
|
|
||||||
import com.wyh.common.util.TimeUtils;
|
|
||||||
import com.wyh.common.util.UrlUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class PayServiceImpl implements IPayService {
|
public class PayServiceImpl implements IPayService {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsOrderMapper goodsOrderMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserGoodsMapper userGoodsMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
UserMapper userMapper;
|
UserMapper userMapper;
|
||||||
|
|
||||||
|
|
@ -206,6 +225,31 @@ public class PayServiceImpl implements IPayService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deductPoints(OrderSnDto orderSnDto, Integer userId) {
|
||||||
|
Order order = orderMapper.selectOne(new QueryWrapper<Order>().eq("sn", orderSnDto.getOrderSn()).eq("user_id", userId));
|
||||||
|
Assert.notNull(order, "订单不存在");
|
||||||
|
User user = userMapper.selectById(userId);
|
||||||
|
Assert.notNull(user, "用户不存在");
|
||||||
|
|
||||||
|
BigDecimal money = user.getMoney();
|
||||||
|
Assert.isTrue(money.compareTo(order.getTotalPrice()) >= 0, "余额不足");
|
||||||
|
|
||||||
|
|
||||||
|
user.setMoney(money.subtract(order.getTotalPrice()));
|
||||||
|
|
||||||
|
userMapper.updateById(user);
|
||||||
|
|
||||||
|
List<GoodsOrder> goodsOrders = goodsOrderMapper.selectList(Wrappers.<GoodsOrder>lambdaQuery().eq(GoodsOrder::getOrderSn, order.getSn()));
|
||||||
|
for (GoodsOrder goodsOrder : goodsOrders) {
|
||||||
|
userGoodsMapper.delete(Wrappers.<UserGoods>lambdaQuery().eq(UserGoods::getUserId, userId).eq(UserGoods::getGoodsId, goodsOrder.getGoodsId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Todo:修改订单支付状态
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额充值回调
|
* 余额充值回调
|
||||||
*
|
*
|
||||||
|
|
@ -250,4 +294,11 @@ public class PayServiceImpl implements IPayService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
BigDecimal totalScope = new BigDecimal("1000");
|
||||||
|
Assert.isTrue(totalScope.compareTo(new BigDecimal("1001")) >= 0, "余额不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class SignServiceImpl implements SignService {
|
||||||
}
|
}
|
||||||
result.sort((a, b) -> a.getDate().compareTo(b.getDate()));
|
result.sort((a, b) -> a.getDate().compareTo(b.getDate()));
|
||||||
signLogVo.setSignDateList(result);
|
signLogVo.setSignDateList(result);
|
||||||
int asInt = signLogs.stream().mapToInt(SignLog::getContinueNums).max().getAsInt();
|
int asInt = signLogs.stream().mapToInt(SignLog::getContinueNums).max() .orElse(0);
|
||||||
signLogVo.setContinuousDays(asInt);
|
signLogVo.setContinuousDays(asInt);
|
||||||
return signLogVo;
|
return signLogVo;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,11 @@ declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
AppLink: typeof import('./src/components/app-link/index.vue')['default']
|
AppLink: typeof import('./src/components/app-link/index.vue')['default']
|
||||||
ColorPicker: typeof import('./src/components/color-picker/index.vue')['default']
|
ColorPicker: typeof import('./src/components/color-picker/index.vue')['default']
|
||||||
CustomLink: typeof import('./src/components/link/custom-link.vue')['default']
|
|
||||||
DaterangePicker: typeof import('./src/components/daterange-picker/index.vue')['default']
|
DaterangePicker: typeof import('./src/components/daterange-picker/index.vue')['default']
|
||||||
DelWrap: typeof import('./src/components/del-wrap/index.vue')['default']
|
DelWrap: typeof import('./src/components/del-wrap/index.vue')['default']
|
||||||
DictValue: typeof import('./src/components/dict-value/index.vue')['default']
|
DictValue: typeof import('./src/components/dict-value/index.vue')['default']
|
||||||
Editor: typeof import('./src/components/editor/index.vue')['default']
|
Editor: typeof import('./src/components/editor/index.vue')['default']
|
||||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||||
ElAmap: typeof import('element-plus/es')['ElAmap']
|
|
||||||
ElAmapMarker: typeof import('element-plus/es')['ElAmapMarker']
|
|
||||||
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
|
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
|
||||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||||
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
|
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
|
||||||
|
|
@ -52,7 +49,6 @@ declare module '@vue/runtime-core' {
|
||||||
ElRow: typeof import('element-plus/es')['ElRow']
|
ElRow: typeof import('element-plus/es')['ElRow']
|
||||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||||
ElStatistic: typeof import('element-plus/es')['ElStatistic']
|
|
||||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||||
ElTable: typeof import('element-plus/es')['ElTable']
|
ElTable: typeof import('element-plus/es')['ElTable']
|
||||||
|
|
@ -64,7 +60,6 @@ declare module '@vue/runtime-core' {
|
||||||
ElTree: typeof import('element-plus/es')['ElTree']
|
ElTree: typeof import('element-plus/es')['ElTree']
|
||||||
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
||||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||||
File: typeof import('./src/components/material/file.vue')['default']
|
|
||||||
FooterBtns: typeof import('./src/components/footer-btns/index.vue')['default']
|
FooterBtns: typeof import('./src/components/footer-btns/index.vue')['default']
|
||||||
Icon: typeof import('./src/components/icon/index.vue')['default']
|
Icon: typeof import('./src/components/icon/index.vue')['default']
|
||||||
IconPicker: typeof import('./src/components/icon/picker.vue')['default']
|
IconPicker: typeof import('./src/components/icon/picker.vue')['default']
|
||||||
|
|
@ -75,7 +70,6 @@ declare module '@vue/runtime-core' {
|
||||||
LinkPicker: typeof import('./src/components/link/picker.vue')['default']
|
LinkPicker: typeof import('./src/components/link/picker.vue')['default']
|
||||||
LinkShopPages: typeof import('./src/components/link/shop-pages.vue')['default']
|
LinkShopPages: typeof import('./src/components/link/shop-pages.vue')['default']
|
||||||
Loading: typeof import('element-plus/es')['ElLoadingDirective']
|
Loading: typeof import('element-plus/es')['ElLoadingDirective']
|
||||||
MapContainer: typeof import('./src/components/map/MapContainer.vue')['default']
|
|
||||||
MapMapContainer: typeof import('./src/components/map/MapContainer.vue')['default']
|
MapMapContainer: typeof import('./src/components/map/MapContainer.vue')['default']
|
||||||
Material: typeof import('./src/components/material/index.vue')['default']
|
Material: typeof import('./src/components/material/index.vue')['default']
|
||||||
MaterialFile: typeof import('./src/components/material/file.vue')['default']
|
MaterialFile: typeof import('./src/components/material/file.vue')['default']
|
||||||
|
|
@ -83,14 +77,10 @@ declare module '@vue/runtime-core' {
|
||||||
MaterialPreview: typeof import('./src/components/material/preview.vue')['default']
|
MaterialPreview: typeof import('./src/components/material/preview.vue')['default']
|
||||||
OverflowTooltip: typeof import('./src/components/overflow-tooltip/index.vue')['default']
|
OverflowTooltip: typeof import('./src/components/overflow-tooltip/index.vue')['default']
|
||||||
Pagination: typeof import('./src/components/pagination/index.vue')['default']
|
Pagination: typeof import('./src/components/pagination/index.vue')['default']
|
||||||
Picker: typeof import('./src/components/icon/picker.vue')['default']
|
|
||||||
PopoverInput: typeof import('./src/components/popover-input/index.vue')['default']
|
PopoverInput: typeof import('./src/components/popover-input/index.vue')['default']
|
||||||
Popup: typeof import('./src/components/popup/index.vue')['default']
|
Popup: typeof import('./src/components/popup/index.vue')['default']
|
||||||
Preview: typeof import('./src/components/material/preview.vue')['default']
|
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
ShopPages: typeof import('./src/components/link/shop-pages.vue')['default']
|
|
||||||
SvgIcon: typeof import('./src/components/icon/svg-icon.vue')['default']
|
|
||||||
Upload: typeof import('./src/components/upload/index.vue')['default']
|
Upload: typeof import('./src/components/upload/index.vue')['default']
|
||||||
VideoPlayer: typeof import('./src/components/video-player/index.vue')['default']
|
VideoPlayer: typeof import('./src/components/video-player/index.vue')['default']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="banner图" prop="img">
|
<el-form-item label="banner图" prop="img">
|
||||||
<material-picker size="100px" v-model="formData.img" type="video" />
|
<material-picker size="100px" v-model="formData.img" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="menuSort">
|
<el-form-item label="排序" prop="menuSort">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="banner图" prop="img" min-width="100">
|
<el-table-column label="banner图" prop="img" min-width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<file-item :uri="row.img" file-size="80px" type="video"></file-item>
|
<file-item :uri="row.img" file-size="80px" type="image"></file-item>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,17 @@
|
||||||
>
|
>
|
||||||
<el-form ref="formRef" :model="formData" label-width="110px" :rules="formRules">
|
<el-form ref="formRef" :model="formData" label-width="110px" :rules="formRules">
|
||||||
<el-form-item label="实验标题" prop="title">
|
<el-form-item label="实验标题" prop="title">
|
||||||
<el-input v-model="formData.title" placeholder="请输入实验标题" />
|
<el-input v-model="formData.title" placeholder="请输入实验标题"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="实验主图" prop="experimentImg">
|
<el-form-item label="实验主图" prop="experimentImg">
|
||||||
<material-picker size="300px" v-model="formData.experimentImg" />
|
<material-picker size="300px" v-model="formData.experimentImg"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="实验视频" prop="experimentVideo">
|
<el-form-item label="实验视频" prop="experimentVideo">
|
||||||
<material-picker size="300px" v-model="formData.experimentVideo" type="video" />
|
<material-picker size="300px" v-model="formData.experimentVideo" type="video"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<div>
|
<div>
|
||||||
<el-input-number v-model="formData.sort" :max="9999" />
|
<el-input-number v-model="formData.sort" :max="9999"/>
|
||||||
<div class="form-tips">数值越大越排前</div>
|
<div class="form-tips">数值越大越排前</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -29,68 +29,83 @@
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formData.goodsIds"
|
v-model="formData.goodsIds"
|
||||||
multiple
|
multiple
|
||||||
collapse-tags
|
remote
|
||||||
placeholder="Select"
|
:remote-method="getGoodsOption"
|
||||||
style="width: 240px"
|
filterable
|
||||||
> <el-option
|
placeholder="请选择产品"
|
||||||
v-for="item in goodsOption"
|
style="width: 400px"
|
||||||
:key="item.id"
|
>
|
||||||
:label="item.goodsName"
|
<el-option
|
||||||
:value="item.id"
|
v-for="item in goodsFilterOption"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否展示" prop="isShow">
|
<el-form-item label="是否展示" prop="isShow">
|
||||||
<el-radio-group v-model="formData.isShow" >
|
<el-radio-group v-model="formData.isShow">
|
||||||
<el-radio :label="1">是</el-radio>
|
<el-radio :label="1">是</el-radio>
|
||||||
<el-radio :label="0">否</el-radio>
|
<el-radio :label="0">否</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="分类id" prop="classId">
|
<el-form-item label="分类" prop="classId">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
v-model="formData.classId"
|
v-model="formData.classId"
|
||||||
:data="optionsData.class"
|
:data="optionsData.class"
|
||||||
clearable
|
clearable
|
||||||
node-key="id"
|
node-key="id"
|
||||||
:props="{
|
:props="{
|
||||||
label: 'name'
|
label: 'name'
|
||||||
}"
|
}"
|
||||||
:default-expand-all="true"
|
:default-expand-all="true"
|
||||||
placeholder="请选择产品分类"
|
placeholder="请选择产品分类"
|
||||||
check-strictly
|
check-strictly
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="实验内容" prop="content">
|
<el-form-item label="实验内容" prop="content">
|
||||||
<editor v-model="formData.content" :height="500" />
|
<editor v-model="formData.content" :height="500"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</popup>
|
</popup>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { FormInstance } from 'element-plus'
|
import type {FormInstance} from 'element-plus'
|
||||||
import { experimentEdit, experimentAdd, experimentDetail } from '@/api/experiment'
|
import {experimentEdit, experimentAdd, experimentDetail} from '@/api/experiment'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import feedback from '@/utils/feedback'
|
import feedback from '@/utils/feedback'
|
||||||
import type { PropType } from 'vue'
|
import type {PropType} from 'vue'
|
||||||
import {useDictOptions} from "@/hooks/useDictOptions";
|
import {useDictOptions} from "@/hooks/useDictOptions";
|
||||||
import {cateLists} from "@/api/cate";
|
import {cateLists} from "@/api/cate";
|
||||||
import {infoLists} from "@/api/info"
|
import {infoLists} from "@/api/info"
|
||||||
import { goodsAll} from "@/api/goods"
|
import {goodsAll} from "@/api/goods"
|
||||||
import {listAll} from "@/api/newscate";
|
import {listAll} from "@/api/newscate";
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
dictData: {
|
dictData: {
|
||||||
type: Object as PropType<Record<string, any[]>>,
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface ListItem {
|
||||||
|
value: string
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
const emit = defineEmits(['success', 'close'])
|
const emit = defineEmits(['success', 'close'])
|
||||||
const formRef = shallowRef<FormInstance>()
|
const formRef = shallowRef<FormInstance>()
|
||||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
const mode = ref('add')
|
const mode = ref('add')
|
||||||
const goodsOption = ref<any[]>([])
|
const goodsOption = ref<any[]>([])
|
||||||
const { optionsData } = useDictOptions<{
|
const list = ref<ListItem[]>([])
|
||||||
|
const goodsFilterOption = ref<ListItem[]>([])
|
||||||
|
const {optionsData} = useDictOptions<{
|
||||||
class: any[]
|
class: any[]
|
||||||
}>({
|
}>({
|
||||||
class: {
|
class: {
|
||||||
|
|
@ -113,6 +128,7 @@ const formData = reactive({
|
||||||
goodsIds: []
|
goodsIds: []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const formRules = {
|
const formRules = {
|
||||||
id: [
|
id: [
|
||||||
{
|
{
|
||||||
|
|
@ -172,9 +188,31 @@ const formRules = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const getGoodsOption = async (query:string) => {
|
||||||
|
if (query) {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
|
||||||
|
console.log("远程搜索参数---------》:", query);
|
||||||
|
console.log("数据搜索前集合------------->:", list.value);
|
||||||
|
|
||||||
|
goodsFilterOption.value = list.value.filter((item) => item.label && item.label.includes(query));
|
||||||
|
|
||||||
|
console.log("数据搜索后集合---------》:", goodsFilterOption.value);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error performing remote search:", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goodsFilterOption.value = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
const data: any = { ...formData }
|
const data: any = {...formData}
|
||||||
mode.value == 'edit' ? await experimentEdit(data) : await experimentAdd(data)
|
mode.value == 'edit' ? await experimentEdit(data) : await experimentAdd(data)
|
||||||
popupRef.value?.close()
|
popupRef.value?.close()
|
||||||
feedback.msgSuccess('操作成功')
|
feedback.msgSuccess('操作成功')
|
||||||
|
|
@ -193,6 +231,7 @@ const setFormData = async (data: Record<string, any>) => {
|
||||||
formData[key] = data[key]
|
formData[key] = data[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDetail = async (row: Record<string, any>) => {
|
const getDetail = async (row: Record<string, any>) => {
|
||||||
|
|
@ -207,9 +246,16 @@ const handleClose = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const getGoodsAllList = async () => {
|
const getGoodsAllList = async () => {
|
||||||
const res: any = await goodsAll()
|
const res: any = await goodsAll()
|
||||||
goodsOption.value = res || []
|
goodsOption.value = res || []
|
||||||
|
for (let i = 0; i <goodsOption.value.length; i++) {
|
||||||
|
list.value.push({
|
||||||
|
value: goodsOption.value[i].id,
|
||||||
|
label: goodsOption.value[i].goodsName
|
||||||
|
})
|
||||||
|
goodsFilterOption.value = list.value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ const inputs = ref([]);
|
||||||
|
|
||||||
function addInput() {
|
function addInput() {
|
||||||
inputs.value.push({ name: '' });
|
inputs.value.push({ name: '' });
|
||||||
|
formData.goodsExpand = inputs.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeInput(index) {
|
function removeInput(index) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue