字典管理

资源管理
资源类型管理
团购卷订单管理
团购卷订单退款
团购卷商品(套餐商品修改与保存)
This commit is contained in:
wangw 2024-05-15 16:32:34 +08:00
parent a4cbb3798e
commit 6ba4aadccb
49 changed files with 1778 additions and 393 deletions

View File

@ -0,0 +1,150 @@
package cn.ysk.cashier.utils;
import org.apache.commons.lang3.StringUtils;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.Map.Entry;
public class BeanUtil {
// Map --> Bean 1: 利用Introspector,PropertyDescriptor实现 Map --> Bean
public static void transMap2Bean(Map<String, Object> map, Object obj) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo
.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
if (map.containsKey(key)) {
Object value = map.get(key);
// 得到property对应的setter方法
Method setter = property.getWriteMethod();
setter.invoke(obj, value);
}
}
} catch (Exception e) {
System.out.println("transMap2Bean Error " + e);
}
return;
}
public static String mapOrderStr(Map<String, Object> map) {
List<Entry<String, Object>> list = new ArrayList<Entry<String, Object>>(map.entrySet());
Collections.sort(list, new Comparator<Entry<String, Object>>() {
@Override
public int compare(Entry<String, Object> o1, Entry<String, Object> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> mapping : list) {
sb.append(mapping.getKey() + "=" + mapping.getValue() + "&");
}
return sb.substring(0, sb.length() - 1);
}
// Bean --> Map 1: 利用Introspector和PropertyDescriptor 将Bean --> Map
public static Map<String, Object> transBean2Map(Object obj) {
if (obj == null) {
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
// 过滤class属性
if (!key.equals("class")) {
// 得到property对应的getter方法
Method getter = property.getReadMethod();
Object value = getter.invoke(obj);
if(null !=value && !"".equals(value)){
map.put(key, value);
}
}
}
} catch (Exception e) {
System.out.println("transBean2Map Error " + e);
}
return map;
}
public static LinkedHashMap<String, Object> transBeanMap(Object obj) {
if (obj == null) {
return null;
}
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
// 过滤class属性
if (!key.equals("class")) {
// 得到property对应的getter方法
Method getter = property.getReadMethod();
Object value = getter.invoke(obj);
if(null !=value && !"".equals(value)){
map.put(key, value);
}
}
}
} catch (Exception e) {
System.out.println("transBean2Map Error " + e);
}
return map;
}
public static <T> T mapToEntity(Map<String, Object> map, Class<T> entity) {
T t = null;
try {
t = entity.newInstance();
for(Field field : entity.getDeclaredFields()) {
if (map.containsKey(field.getName())) {
boolean flag = field.isAccessible();
field.setAccessible(true);
Object object = map.get(field.getName());
if (object!= null && field.getType().isAssignableFrom(object.getClass())) {
field.set(t, object);
}
field.setAccessible(flag);
}
}
return t;
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return t;
}
}

View File

@ -3,12 +3,16 @@ package cn.ysk.cashier.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* json工具类所有JSON转换通用该JSON工具类不许直接使用外部JSON转换后期会封闭掉直接调用JSON转换
@ -38,7 +42,7 @@ public final class FastJsonUtils {
* @param object 转换对象
* @return 转换结果
*/
public static String toJSONString(Object object) {
public static String toJSONString(Object object){
//不可序列化的类型直接打印其类名称
if (object instanceof HttpServletRequest
|| object instanceof HttpServletResponse

View File

@ -1,10 +1,12 @@
package cn.ysk.cashier.utils;
import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
public class MD5Utils {
private static String byteArrayToHexString(byte b[]) {
@ -121,4 +123,30 @@ public class MD5Utils {
}
}
/**
* @Title: encrypt
* @Description: (16位或32位密码)
* @param @param
* plainText
* @param @param
* flag true为32位,false为16位
* @throws UnsupportedEncodingException
*/
public static String encrypt(Map<String, Object> map, String privateKey, boolean flag) {
String param = null;
map.remove("sign");
map.remove("encrypt");
String result = BeanUtil.mapOrderStr(map);
if (StringUtils.isEmpty(result)) {
return null;
}
param = encrypt(encrypt(result)+privateKey);
if (flag) {
return param;
} else {
param = param.substring(8, 24);
}
return param;
}
}

View File

@ -2,6 +2,8 @@ package cn.ysk.cashier.config;
import cn.ysk.cashier.utils.FastJsonUtils;
import cn.ysk.cashier.utils.SpringContextHolder;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
@ -42,6 +44,7 @@ public class AppApiMethodAspect {
Map<String, Object> params = new HashMap<>();
Object result = null;
String requestJson="";
try {
// 获取方法参数
Object[] args = pjp.getArgs();
@ -49,37 +52,42 @@ public class AppApiMethodAspect {
for (int i = 0; i < args.length; i++) {
params.put(paramNames[i], FastJsonUtils.toJSONString(args[i]));
}
requestJson=FastJsonUtils.toJSONString(params);
// 执行被拦截的方法
result = pjp.proceed();
String resultJson = FastJsonUtils.toJSONString(result);
if (resultJson.length() > 300) {
resultJson = resultJson.substring(0, 300);
}
log.info("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Response: {}"
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
FastJsonUtils.toJSONString(params),
FastJsonUtils.toJSONString(result)
requestJson,
resultJson
);
return result;
} catch (RuntimeException e) {
if (StringUtils.isBlank(e.getMessage())) {
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
log.error("\n>>>>>>{} {} {}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
FastJsonUtils.toJSONString(params),
requestJson,
e);
} else {
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
log.error("\n>>>>>>{} {} {}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
FastJsonUtils.toJSONString(params),
requestJson,
e.getMessage());
}
throw e;
} catch (Error e) {
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
log.error("\n>>>>>>{} {} {}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
FastJsonUtils.toJSONString(params),
requestJson,
e);
throw e;
} catch (Throwable e) {
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
log.error("\n>>>>>>{} {} {}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
FastJsonUtils.toJSONString(params),
requestJson,
e);
throw new RuntimeException(e);
}

View File

@ -0,0 +1,38 @@
package cn.ysk.cashier.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
@Api(tags = "通用组件")
@RequestMapping("/api")
public class CommonController {
@GetMapping("geocode")
@ApiOperation("通过经纬度查询位置信息")
public ResponseEntity<Object> getGeocode(String location){
return new ResponseEntity<>(geocode(location), HttpStatus.OK);
}
public JsonNode geocode(String location) {
RestTemplate restTemplate = new RestTemplate();
String s = restTemplate.getForObject("https://restapi.amap.com/v3/geocode/regeo?key=7a7f2e4790ea222660a027352ee3af39&location="+location, String.class);
ObjectMapper objectMapper = new ObjectMapper();
// JSON 字符串解析为 JsonNode 对象
try {
JsonNode jsonNode = objectMapper.readTree(s).get("regeocode");
return jsonNode;
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.controller;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.dto.TbPlatformDictDto;
import cn.ysk.cashier.dto.TbPlatformDictQueryCriteria;
import cn.ysk.cashier.pojo.TbPlatformDict;
@ -20,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "新字典管理")
@Api(tags = "资源管理")
@RequestMapping("/api/tbPlatformDict")
public class TbPlatformDictController {
@ -28,8 +29,9 @@ public class TbPlatformDictController {
@GetMapping
@ApiOperation("查询新字典")
public ResponseEntity<Object> queryTbPlatformDict(TbPlatformDictQueryCriteria criteria){
return new ResponseEntity<>(tbPlatformDictService.queryAllPage(criteria),HttpStatus.OK);
@AnonymousGetMapping
public ResponseEntity<Object> queryTbPlatformDict(TbPlatformDictQueryCriteria criteria) {
return new ResponseEntity<>(tbPlatformDictService.queryAllPage(criteria), HttpStatus.OK);
}
@GetMapping("/{id}")

View File

@ -0,0 +1,51 @@
package cn.ysk.cashier.controller;
import cn.ysk.cashier.dto.TbPlatformDictTypeQueryCriteria;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import cn.ysk.cashier.service.TbPlatformDictTypeService;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author ww
* @date 2024-05-11
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "资源类别管理")
@RequestMapping("/api/tbPlatformDictType")
public class TbPlatformDictTypeController {
private final TbPlatformDictTypeService tbPlatformDictTypeService;
@GetMapping
@ApiOperation("查询资源类别列表")
public ResponseEntity<Object> queryTbPlatformDictType(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbPlatformDictTypeService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@ApiOperation("新增资源类别")
public ResponseEntity<Object> createTbPlatformDictType(@Validated @RequestBody TbPlatformDictType resources){
return new ResponseEntity<>(tbPlatformDictTypeService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@ApiOperation("修改资源类别")
public ResponseEntity<Object> updateTbPlatformDictType(@Validated @RequestBody TbPlatformDictType resources){
tbPlatformDictTypeService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@ApiOperation("删除资源类别")
public ResponseEntity<Object> deleteTbPlatformDictType(@RequestBody Integer[] ids) {
tbPlatformDictTypeService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,44 @@
package cn.ysk.cashier.controller.order;
import cn.ysk.cashier.dto.order.ReturnGroupOrderDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoQueryCriteria;
import cn.ysk.cashier.service.order.TbGroupOrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequiredArgsConstructor
@Api(tags = "团购卷订单管理")
@RequestMapping("/api/tbGroupOrderInfo")
public class TbGroupOrderInfoController {
private final TbGroupOrderInfoService tbGroupOrderInfoService;
@PostMapping
@ApiOperation("团购卷订单列表")
public ResponseEntity<Object> queryTbGroupOrderInfo(@RequestBody TbGroupOrderInfoQueryCriteria criteria){
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(),Sort.by(criteria.getSort()));
return new ResponseEntity<>(tbGroupOrderInfoService.queryAll(criteria,pageable),HttpStatus.OK);
}
@GetMapping("/{id}")
@ApiOperation("通过Id查询订单详情")
public TbGroupOrderInfoDto queryTbGroupOrderInfo(@PathVariable("id") Integer id){
return tbGroupOrderInfoService.findById(id);
}
@RequestMapping("returnGpOrder")
public ResponseEntity<Object> returnOrder(@RequestBody ReturnGroupOrderDto param){
return tbGroupOrderInfoService.returnOrder(param);
}
}

View File

@ -7,9 +7,6 @@ public class TbPlatformDictDto implements Serializable {
private Integer id;
/** 标签前小图标 */
private String shareImg;
/** 描述 */
private String name;
@ -22,21 +19,34 @@ public class TbPlatformDictDto implements Serializable {
/** 类型: scan拉起相机relative内部页面absolute外链url */
private String jumpType;
/** 绝对跳转地址 */
private String absUrl;
/** */
private String value;
/** 轮播图;首页小菜单; */
/** homeDistrict--金刚区首页
carousel--轮播图
proTag--商品标签
shopTag--店铺标签
icon--小图标
subShop--预约到店顶部图
数字--数字为团购卷分类id
ownMenu--个人中心菜单 */
private String type;
/** 封面图 */
/** 展示图 */
private String coverImg;
/** 标签前小图标 */
private String shareImg;
/** 视频URL地址 */
private String video;
/** 视频封面图 */
private String videoCoverImg;
/** 绝对跳转地址 */
private String absUrl;
/** 创建时间 */
private Long createdAt;

View File

@ -35,9 +35,9 @@ public class TbPlatformDictQueryCriteria{
@Query
private Integer isShowApp;
private Integer pageSize;
private Integer pageSize = 10;
private Integer page;
private Integer page = 0;
private String sort;

View File

@ -0,0 +1,21 @@
package cn.ysk.cashier.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class TbPlatformDictTypeDto implements Serializable {
/** id */
private Integer id;
/** 类型名称 */
private String name;
/** 类型标识 */
private String key;
/** 排序 */
private Integer sort;
}

View File

@ -0,0 +1,12 @@
package cn.ysk.cashier.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
@Data
public class TbPlatformDictTypeQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String name;
}

View File

@ -0,0 +1,29 @@
package cn.ysk.cashier.dto.order;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ReturnGroupOrderDto {
/**
* 退单数
*/
private Integer num;
/**
* 团购订单id
*/
private Integer orderId;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退款原因
*/
private String refundReason;
/**
* 退款说明
*/
private String refundDesc;
}

View File

@ -0,0 +1,129 @@
package cn.ysk.cashier.dto.order;
import cn.ysk.cashier.pojo.order.TbGroupOrderCoupon;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.List;
@Data
public class TbGroupOrderInfoDto implements Serializable {
/** id */
private Integer id;
/** 订单编号 */
private String orderNo;
private Integer merchantId;
/** 商户Id */
private Integer shopId;
/** 用户id */
private Integer userId;
/** 商品id */
private Integer proId;
/** 商品图 */
private String proImg;
/** 商品名称 */
private String proName;
private Timestamp expDate;
/** 订单类型 预留字段 */
private String orderType;
/** 支付方式 wechatPay微信支付aliPay支付宝支付 */
private String payType;
/** 订单金额 */
private BigDecimal orderAmount;
/** 优惠金额 */
private BigDecimal saveAmount;
/** 实付金额 */
private BigDecimal payAmount;
/** 退单金额 */
private BigDecimal refundAmount;
/** 退单数量 */
private Integer refundNumber;
/** 数量 */
private Integer number;
/** 订单状态
状态: unpaid-待付款;unused-待使用;closed-已完成;refunding-退款中;refund-已退款;cancelled-已取消; */
private String status;
/** 备注 */
private String remark;
/** 手机号 */
private String phone;
/** 付款时间 */
private Timestamp payTime;
/** 是否支持退款 0不支持 1支持 */
private Integer refundAble;
/** 创建时间 */
private Timestamp createTime;
/** 卷码核销员 */
private String verifier;
/** 更新时间 */
private Timestamp updateTime;
/** 支付订单号 */
private String payOrderNo;
/** 交易日期 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date tradeDay;
/** 原订单id 退单 */
private Integer source;
/**
* 卷码
*/
private List<TbGroupOrderCoupon> coupons;
public void setStatus(String status) {
switch (status) {
case "unpaid":
this.status = "待付款";
break;
case "unused":
this.status = "待使用";
break;
case "closed":
this.status = "已完成";
break;
case "refunding":
this.status = "退款中";
break;
case "refund":
this.status = "已退款";
break;
case "cancelled":
this.status = "已取消";
break;
default:
this.status = status;
}
}
}

View File

@ -0,0 +1,45 @@
package cn.ysk.cashier.dto.order;
import cn.ysk.cashier.annotation.Query;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
@Data
public class TbGroupOrderInfoQueryCriteria {
/** 精确 */
@Query
private String orderNo;
/** 精确 */
@Query
private Integer shopId;
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String proName;
/** 精确 */
@Query
private String payType;
/** 精确 */
@Query
private String status;
/** 精确 */
@Query
private String phone;
/** BETWEEN */
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
private Integer page;
private Integer size;
private String sort = "id";
}

View File

@ -121,7 +121,9 @@ public class TbShopInfoDto implements Serializable {
private String industryName;
/** 营业时间 */
private String businessTime;
private String businessStartDay;//
private String businessEndDay;//
private String businessTime;//09:00-20:00
/** 配送时间 */
private String postTime;

View File

@ -0,0 +1,12 @@
package cn.ysk.cashier.mapper;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import cn.ysk.cashier.dto.TbPlatformDictTypeDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbPlatformDictTypeMapper extends BaseMapper<TbPlatformDictTypeDto, TbPlatformDictType> {
}

View File

@ -0,0 +1,12 @@
package cn.ysk.cashier.mapper.order;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoDto;
import cn.ysk.cashier.pojo.order.TbGroupOrderInfo;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbGroupOrderInfoMapper extends BaseMapper<TbGroupOrderInfoDto, TbGroupOrderInfo> {
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.model;
import lombok.Data;
import java.io.Serializable;
@Data
public class BaseRequest implements Serializable {
private String appId;
private String sign;
private Long timestamp;
}

View File

@ -0,0 +1,17 @@
package cn.ysk.cashier.model;
import lombok.Data;
@Data
public class ReturnOrderReq extends BaseRequest {
private String orderNumber;
private String amount;
private String mercRefundNo;
private String refundReason;
private String payPassword;
}

View File

@ -12,21 +12,22 @@ import java.io.Serializable;
@Data
@Table(name="tb_platform_dict")
public class TbPlatformDict implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`share_img`")
@ApiModelProperty(value = "标签前 小图标")
private String shareImg;
@Column(name = "`name`",nullable = false)
@NotBlank
@ApiModelProperty(value = "描述")
private String name;
@Column(name = "`value`")
@ApiModelProperty(value = "")
private String value;
@Column(name = "`font_color`")
@ApiModelProperty(value = "字体色")
private String fontColor;
@ -39,20 +40,25 @@ public class TbPlatformDict implements Serializable {
@ApiModelProperty(value = "类型: scan拉起相机relative内部页面absolute外链url ")
private String jumpType;
@Column(name = "`abs_url`")
@ApiModelProperty(value = "绝对跳转地址")
private String absUrl;
@Column(name = "`cover_img`")
@ApiModelProperty(value = "封面图")
private String coverImg;
@Column(name = "`type`",nullable = false)
@NotBlank
@ApiModelProperty(value = "homeDistrict--金刚区(首页) carousel--轮播图 proTag--商品标签 shopTag店铺标签")
@ApiModelProperty(value = "homeDistrict--金刚区(首页) \n" +
"carousel--轮播图 \n" +
"proTag--商品标签 \n" +
"shopTag--店铺标签\n" +
"icon--小图标\n" +
"subShop--预约到店顶部图\n" +
"数字--数字为团购卷分类id\n" +
"ownMenu--个人中心菜单")
private String type;
@Column(name = "`video`")
@Column(name = "`cover_img`")
@ApiModelProperty(value = "展示图")
private String coverImg;
@Column(name = "`share_img`")
@ApiModelProperty(value = "标签前小图标")
private String shareImg;
@ApiModelProperty(value = "视频URL地址")
private String video;
@ -60,6 +66,9 @@ public class TbPlatformDict implements Serializable {
@ApiModelProperty(value = "视频封面图")
private String videoCoverImg;
@Column(name = "`abs_url`")
@ApiModelProperty(value = "绝对跳转地址")
private String absUrl;
@Column(name = "`created_at`")
@ApiModelProperty(value = "创建时间")
@ -81,11 +90,10 @@ public class TbPlatformDict implements Serializable {
@ApiModelProperty(value = "APP端展示 0:不展示 1:展示")
private Integer isShowApp;
@Column(name = "`sort`")
@ApiModelProperty(value = "排序")
private Integer sort;
public void copy(TbPlatformDict source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
}

View File

@ -0,0 +1,36 @@
package cn.ysk.cashier.pojo;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Data
@Table(name="tb_platform_dict_type")
public class TbPlatformDictType implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`name`")
@ApiModelProperty(value = "类型名称")
private String name;
@Column(name = "`key`")
@ApiModelProperty(value = "类型标识")
private String key;
@Column(name = "`sort`")
@ApiModelProperty(value = "排序")
private Integer sort;
public void copy(TbPlatformDictType source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,49 @@
package cn.ysk.cashier.pojo.order;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import java.math.BigDecimal;
import java.io.Serializable;
@Entity
@Data
@Table(name = "tb_group_order_coupon")
public class TbGroupOrderCoupon implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`order_id`", nullable = false)
@ApiModelProperty(value = "团购订单id")
private Integer orderId;
@Column(name = "`coupon_no`", nullable = false)
@ApiModelProperty(value = "团购卷码")
private String couponNo;
@Column(name = "`is_refund`", nullable = false)
@ApiModelProperty(value = "是否已退款 0否 1")
private Integer isRefund;
@Column(name = "`refund_amount`")
@ApiModelProperty(value = "退款金额")
private BigDecimal refundAmount;
@Column(name = "`refund_reason`")
@ApiModelProperty(value = "退款原因")
private String refundReason;
@Column(name = "`refund_desc`")
@ApiModelProperty(value = "退款说明")
private String refundDesc;
public void copy(TbGroupOrderCoupon source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,136 @@
package cn.ysk.cashier.pojo.order;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.sql.Date;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
@Entity
@Data
@Table(name = "tb_group_order_info")
public class TbGroupOrderInfo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`order_no`")
@ApiModelProperty(value = "订单编号")
private String orderNo;
@Column(name = "`merchant_id`")
@ApiModelProperty(value = "merchantId")
private Integer merchantId;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "商户Id")
private Integer shopId;
@Column(name = "`user_id`")
@ApiModelProperty(value = "用户id")
private Integer userId;
@Column(name = "`pro_id`")
@ApiModelProperty(value = "商品id")
private Integer proId;
@Column(name = "`pro_img`")
@ApiModelProperty(value = "商品图")
private String proImg;
@Column(name = "`pro_name`")
@ApiModelProperty(value = "商品名称")
private String proName;
@Column(name = "`exp_date`")
@ApiModelProperty(value = "团购卷到期日期")
private Timestamp expDate;
@Column(name = "`order_type`")
@ApiModelProperty(value = "订单类型 预留字段")
private String orderType;
@Column(name = "`pay_type`")
@ApiModelProperty(value = "支付方式 wechatPay微信支付aliPay支付宝支付")
private String payType;
@Column(name = "`order_amount`")
@ApiModelProperty(value = "订单金额")
private BigDecimal orderAmount;
@Column(name = "`save_amount`")
@ApiModelProperty(value = "优惠金额")
private BigDecimal saveAmount;
@Column(name = "`pay_amount`")
@ApiModelProperty(value = "实付金额")
private BigDecimal payAmount;
@Column(name = "`refund_amount`")
@ApiModelProperty(value = "退单金额")
private BigDecimal refundAmount;
@Column(name = "`refund_number`")
@ApiModelProperty(value = "退单数量")
private Integer refundNumber;
@Column(name = "`number`")
@ApiModelProperty(value = "数量")
private Integer number;
@Column(name = "`status`")
@ApiModelProperty(value = "订单状态 状态: unpaid-待付款;unused-待使用;closed-已完成;refunding-退款中;refund-已退款;cancelled-已取消;")
private String status;
@Column(name = "`remark`")
@ApiModelProperty(value = "备注")
private String remark;
@Column(name = "`phone`")
@ApiModelProperty(value = "手机号")
private String phone;
@Column(name = "`pay_time`")
@ApiModelProperty(value = "付款时间")
private Timestamp payTime;
@Column(name = "`refund_able`")
@ApiModelProperty(value = "是否支持退款 0不支持 1支持")
private Integer refundAble;
@Column(name = "`create_time`")
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@Column(name = "`verifier`")
@ApiModelProperty(value = "卷码核销员")
private String verifier;
@Column(name = "`update_time`")
private Timestamp updateTime;
@Column(name = "`pay_order_no`")
@ApiModelProperty(value = "支付订单号")
private String payOrderNo;
@Column(name = "`trade_day`")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date tradeDay;
@Column(name = "`source`")
@ApiModelProperty(value = "原订单id 退单")
private Integer source;
public void copy(TbGroupOrderInfo source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -150,6 +150,14 @@ public class TbShopInfo implements Serializable {
@ApiModelProperty(value = "行业名称")
private String industryName;
@Column(name = "`business_start_day`")
@ApiModelProperty(value = "营业时间")
private String businessStartDay;
@Column(name = "`business_end_day`")
@ApiModelProperty(value = "营业时间")
private String businessEndDay;
@Column(name = "`business_time`")
@ApiModelProperty(value = "营业时间")
private String businessTime;
@ -227,12 +235,12 @@ public class TbShopInfo implements Serializable {
@Column(name = "provinces")
@ApiModelProperty(value = "")
private String provinces;
@Column(name = "districts")
@ApiModelProperty(value = "")
private String districts;
@Column(name = "cities")
@ApiModelProperty(value = "")
@ApiModelProperty(value = "")
private String cities;
@Column(name = "districts")
@ApiModelProperty(value = "")
private String districts;
public void copy(TbShopInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));

View File

@ -0,0 +1,19 @@
package cn.ysk.cashier.repository;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* @author ww
* @date 2024-05-11
**/
public interface TbPlatformDictTypeRepository extends JpaRepository<TbPlatformDictType, Integer>, JpaSpecificationExecutor<TbPlatformDictType> {
@Query("SELECT dictType.name FROM TbPlatformDictType dictType WHERE dictType.key = :key")
String queryNameByKey(@Param("key")String key);
}

View File

@ -0,0 +1,18 @@
package cn.ysk.cashier.repository.order;
import cn.ysk.cashier.pojo.order.TbGroupOrderCoupon;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @website https://eladmin.vip
* @author ww
* @date 2024-05-07
**/
public interface TbGroupOrderCouponRepository extends JpaRepository<TbGroupOrderCoupon, Integer>, JpaSpecificationExecutor<TbGroupOrderCoupon> {
List<TbGroupOrderCoupon> queryByOrderId(Integer orderId);
List<TbGroupOrderCoupon> queryByOrderIdAndAndIsRefund(Integer orderId,Integer isRefund);
}

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.repository.order;
import cn.ysk.cashier.pojo.order.TbGroupOrderInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author ww
* @date 2024-05-07
**/
public interface TbGroupOrderInfoRepository extends JpaRepository<TbGroupOrderInfo, Integer>, JpaSpecificationExecutor<TbGroupOrderInfo> {
}

View File

@ -0,0 +1,56 @@
package cn.ysk.cashier.service;
import cn.ysk.cashier.dto.TbPlatformDictTypeDto;
import cn.ysk.cashier.dto.TbPlatformDictTypeQueryCriteria;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
* @author ww
* @date 2024-05-11
**/
public interface TbPlatformDictTypeService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbPlatformDictTypeDto>
*/
List<TbPlatformDictTypeDto> queryAll(TbPlatformDictTypeQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TbPlatformDictTypeDto
*/
TbPlatformDictTypeDto findById(Integer id);
/**
* 创建
* @param resources /
* @return TbPlatformDictTypeDto
*/
TbPlatformDictTypeDto create(TbPlatformDictType resources);
/**
* 编辑
* @param resources /
*/
void update(TbPlatformDictType resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
}

View File

@ -6,6 +6,7 @@ import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.TbPlatformDictMapper;
import cn.ysk.cashier.pojo.TbPlatformDict;
import cn.ysk.cashier.repository.TbPlatformDictRepository;
import cn.ysk.cashier.repository.TbPlatformDictTypeRepository;
import cn.ysk.cashier.service.TbPlatformDictService;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
@ -27,16 +28,23 @@ import java.util.Map;
@RequiredArgsConstructor
public class TbPlatformDictServiceImpl implements TbPlatformDictService {
private final TbPlatformDictRepository tbPlatformDictRepository;
private final TbPlatformDictTypeRepository dictTypeRepository;
private final TbPlatformDictMapper tbPlatformDictMapper;
@Override
public Map<String,Object> queryAllPage(TbPlatformDictQueryCriteria criteria){
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by("sort"));
// Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by("type").and(Sort.by("sort")));
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by("type","sort"));
Page<TbPlatformDict> page = tbPlatformDictRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbPlatformDictMapper::toDto));
Page<TbPlatformDictDto> map = page.map(tbPlatformDictMapper::toDto);
for (TbPlatformDictDto tbPlatformDictDto : map.getContent()) {
if (StringUtils.isNotBlank(tbPlatformDictDto.getType())) {
tbPlatformDictDto.setType(dictTypeRepository.queryNameByKey(tbPlatformDictDto.getType()));
}
}
return PageUtil.toPage(map);
}
@Override
public List<TbPlatformDictDto> queryAll(TbPlatformDictQueryCriteria criteria){
return tbPlatformDictMapper.toDto(tbPlatformDictRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
@ -47,7 +55,11 @@ public class TbPlatformDictServiceImpl implements TbPlatformDictService {
public TbPlatformDictDto findById(Integer id) {
TbPlatformDict tbPlatformDict = tbPlatformDictRepository.findById(id).orElseGet(TbPlatformDict::new);
ValidationUtil.isNull(tbPlatformDict.getId(),"TbPlatformDict","id",id);
return tbPlatformDictMapper.toDto(tbPlatformDict);
TbPlatformDictDto dto = tbPlatformDictMapper.toDto(tbPlatformDict);
if (StringUtils.isNotBlank(dto.getType())) {
dto.setType(dictTypeRepository.queryNameByKey(dto.getType()));
}
return dto;
}
@Override
@ -71,9 +83,11 @@ public class TbPlatformDictServiceImpl implements TbPlatformDictService {
@Transactional(rollbackFor = Exception.class)
public void update(TbPlatformDict resources) {
TbPlatformDict tbPlatformDict = tbPlatformDictRepository.findById(resources.getId()).orElseGet(TbPlatformDict::new);
String type = tbPlatformDict.getType();
resources.setUpdatedAt(Instant.now().toEpochMilli());
ValidationUtil.isNull( tbPlatformDict.getId(),"TbPlatformDict","id",resources.getId());
tbPlatformDict.copy(resources);
tbPlatformDict.setType(type);
tbPlatformDictRepository.save(tbPlatformDict);
}

View File

@ -0,0 +1,72 @@
package cn.ysk.cashier.service.impl;
import cn.ysk.cashier.dto.TbPlatformDictTypeDto;
import cn.ysk.cashier.dto.TbPlatformDictTypeQueryCriteria;
import cn.ysk.cashier.mapper.TbPlatformDictTypeMapper;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.TbPlatformDictTypeRepository;
import cn.ysk.cashier.service.TbPlatformDictTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author ww
* @date 2024-05-11
**/
@Service
@RequiredArgsConstructor
public class TbPlatformDictTypeServiceImpl implements TbPlatformDictTypeService {
private final TbPlatformDictTypeRepository tbPlatformDictTypeRepository;
private final TbPlatformDictTypeMapper tbPlatformDictTypeMapper;
@Override
public Map<String,Object> queryAll(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){
Page<TbPlatformDictType> page = tbPlatformDictTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbPlatformDictTypeMapper::toDto));
}
@Override
public List<TbPlatformDictTypeDto> queryAll(TbPlatformDictTypeQueryCriteria criteria){
return tbPlatformDictTypeMapper.toDto(tbPlatformDictTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public TbPlatformDictTypeDto findById(Integer id) {
TbPlatformDictType tbPlatformDictType = tbPlatformDictTypeRepository.findById(id).orElseGet(TbPlatformDictType::new);
ValidationUtil.isNull(tbPlatformDictType.getId(),"TbPlatformDictType","id",id);
return tbPlatformDictTypeMapper.toDto(tbPlatformDictType);
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbPlatformDictTypeDto create(TbPlatformDictType resources) {
return tbPlatformDictTypeMapper.toDto(tbPlatformDictTypeRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbPlatformDictType resources) {
TbPlatformDictType tbPlatformDictType = tbPlatformDictTypeRepository.findById(resources.getId()).orElseGet(TbPlatformDictType::new);
ValidationUtil.isNull( tbPlatformDictType.getId(),"TbPlatformDictType","id",resources.getId());
tbPlatformDictType.copy(resources);
tbPlatformDictTypeRepository.save(tbPlatformDictType);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
tbPlatformDictTypeRepository.deleteById(id);
}
}
}

View File

@ -0,0 +1,37 @@
package cn.ysk.cashier.service.impl.order;
import cn.ysk.cashier.pojo.order.TbGroupOrderCoupon;
import cn.ysk.cashier.repository.order.TbGroupOrderCouponRepository;
import cn.ysk.cashier.service.order.TbGroupOrderCouponService;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@RequiredArgsConstructor
public class TbGroupOrderCouponServiceImpl implements TbGroupOrderCouponService {
private final TbGroupOrderCouponRepository tbGroupOrderCouponRepository;
@Override
public List<TbGroupOrderCoupon> queryAll(Integer orderId){
return tbGroupOrderCouponRepository.queryByOrderId(orderId);
}
@Override
public List<TbGroupOrderCoupon> queryNoRefundByOrderId(Integer orderId) {
return tbGroupOrderCouponRepository.queryByOrderIdAndAndIsRefund(orderId,0);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbGroupOrderCoupon resources) {
TbGroupOrderCoupon tbGroupOrderCoupon = tbGroupOrderCouponRepository.findById(resources.getId()).orElseGet(TbGroupOrderCoupon::new);
ValidationUtil.isNull( tbGroupOrderCoupon.getId(),"TbGroupOrderCoupon","id",resources.getId());
tbGroupOrderCoupon.copy(resources);
tbGroupOrderCouponRepository.save(tbGroupOrderCoupon);
}
}

View File

@ -0,0 +1,184 @@
package cn.ysk.cashier.service.impl.order;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.ysk.cashier.dto.order.ReturnGroupOrderDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoQueryCriteria;
import cn.ysk.cashier.dto.shop.TbMerchantThirdApplyDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.order.TbGroupOrderInfoMapper;
import cn.ysk.cashier.model.ReturnOrderReq;
import cn.ysk.cashier.pojo.order.TbGroupOrderCoupon;
import cn.ysk.cashier.pojo.order.TbGroupOrderInfo;
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
import cn.ysk.cashier.repository.order.TbGroupOrderInfoRepository;
import cn.ysk.cashier.service.order.TbGroupOrderCouponService;
import cn.ysk.cashier.service.order.TbGroupOrderInfoService;
import cn.ysk.cashier.service.shop.TbMerchantThirdApplyService;
import cn.ysk.cashier.utils.*;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.Objects;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
* @description 服务实现
* @author ww
* @date 2024-05-07
**/
@Service
@Slf4j
@RequiredArgsConstructor
public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
private final TbGroupOrderInfoRepository tbGroupOrderInfoRepository;
private final TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
private final TbGroupOrderCouponService orderCouponService;
private final TbMerchantThirdApplyService thirdApplyService;
@Override
public Map<String,Object> queryAll(TbGroupOrderInfoQueryCriteria criteria, Pageable pageable){
Page<TbGroupOrderInfo> page = tbGroupOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbGroupOrderInfoMapper::toDto));
}
@Override
public List<TbGroupOrderInfoDto> queryAll(TbGroupOrderInfoQueryCriteria criteria){
return tbGroupOrderInfoMapper.toDto(tbGroupOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public TbGroupOrderInfoDto findById(Integer id) {
TbGroupOrderInfo tbGroupOrderInfo = tbGroupOrderInfoRepository.findById(id).orElseGet(TbGroupOrderInfo::new);
ValidationUtil.isNull(tbGroupOrderInfo.getId(),"TbGroupOrderInfo","id",id);
TbGroupOrderInfoDto dto = tbGroupOrderInfoMapper.toDto(tbGroupOrderInfo);
dto.setCoupons(orderCouponService.queryAll(dto.getId()));
return dto;
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbGroupOrderInfoDto create(TbGroupOrderInfo resources) {
return tbGroupOrderInfoMapper.toDto(tbGroupOrderInfoRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbGroupOrderInfo resources) {
TbGroupOrderInfo tbGroupOrderInfo = tbGroupOrderInfoRepository.findById(resources.getId()).orElseGet(TbGroupOrderInfo::new);
ValidationUtil.isNull( tbGroupOrderInfo.getId(),"TbGroupOrderInfo","id",resources.getId());
tbGroupOrderInfo.copy(resources);
tbGroupOrderInfoRepository.save(tbGroupOrderInfo);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
tbGroupOrderInfoRepository.deleteById(id);
}
}
@Override
public void download(List<TbGroupOrderInfoDto> all, HttpServletResponse response) throws IOException {
// List<Map<String, Object>> list = new ArrayList<>();
// for (TbGroupOrderInfoDto tbGroupOrderInfo : all) {
// Map<String,Object> map = new LinkedHashMap<>();
// map.put("订单编号", tbGroupOrderInfo.getOrderNo());
// map.put(" merchantId", tbGroupOrderInfo.getMerchantId());
// map.put("商户Id", tbGroupOrderInfo.getShopId());
// map.put("用户id", tbGroupOrderInfo.getUserId());
// map.put("商品id", tbGroupOrderInfo.getProId());
// map.put("商品图", tbGroupOrderInfo.getProImg());
// map.put("商品名称", tbGroupOrderInfo.getProName());
// map.put("团购卷到期日期", tbGroupOrderInfo.getExpDate());
// map.put("订单类型 预留字段", tbGroupOrderInfo.getOrderType());
// map.put("支付方式 wechatPay微信支付aliPay支付宝支付", tbGroupOrderInfo.getPayType());
// map.put("订单金额", tbGroupOrderInfo.getOrderAmount());
// map.put("优惠金额", tbGroupOrderInfo.getSaveAmount());
// map.put("实付金额", tbGroupOrderInfo.getPayAmount());
// map.put("退单金额", tbGroupOrderInfo.getRefundAmount());
// map.put("退单数量", tbGroupOrderInfo.getRefundNumber());
// map.put("数量", tbGroupOrderInfo.getNumber());
// map.put("订单状态
// 状态: unpaid-待付款;unused-待使用;closed-已完成;refunding-退款中;refund-已退款;cancelled-已取消;", tbGroupOrderInfo.getStatus());
// map.put("备注", tbGroupOrderInfo.getRemark());
// map.put("手机号", tbGroupOrderInfo.getPhone());
// map.put("付款时间", tbGroupOrderInfo.getPayTime());
// map.put("是否支持退款 0不支持 1支持", tbGroupOrderInfo.getRefundAble());
// map.put("创建时间", tbGroupOrderInfo.getCreateTime());
// map.put("卷码核销员", tbGroupOrderInfo.getVerifier());
// map.put("更新时间", tbGroupOrderInfo.getUpdateTime());
// map.put("支付订单号", tbGroupOrderInfo.getPayOrderNo());
// map.put("交易日期", tbGroupOrderInfo.getTradeDay());
// map.put("原订单id 退单", tbGroupOrderInfo.getSource());
// list.add(map);
// }
// FileUtil.downloadExcel(list, response);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<Object> returnOrder(ReturnGroupOrderDto param) {
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoRepository.getById(param.getOrderId());
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
if (param.getNum() >= tbGroupOrderCoupons.size()) {
throw new BadRequestException("可退数量不足");
}
for (int i = 0; i < param.getNum(); i++) {
TbGroupOrderCoupon coupon = tbGroupOrderCoupons.get(i);
coupon.setIsRefund(1);
coupon.setRefundAmount(param.getRefundAmount());
coupon.setRefundDesc(param.getRefundDesc());
coupon.setRefundReason(param.getRefundReason());
orderCouponService.update(coupon);
}
TbMerchantThirdApplyDto thirdApply = thirdApplyService.findById(groupOrderInfo.getMerchantId());
if(Objects.isNull(thirdApply)){
throw new BadRequestException("支付参数配置错误");
}
ReturnOrderReq req = new ReturnOrderReq();
req.setAppId(thirdApply.getAppId());
req.setTimestamp(System.currentTimeMillis());
req.setOrderNumber(groupOrderInfo.getPayOrderNo());
req.setAmount(param.getRefundAmount().toString());
req.setMercRefundNo(groupOrderInfo.getOrderNo());
req.setRefundReason("团购卷:退货");
req.setPayPassword(thirdApply.getPayPassword());
Map<String, Object> map = BeanUtil.transBean2Map(req);
req.setSign(MD5Utils.encrypt(map, thirdApply.getAppToken(), true));
log.info("groupOrderReturn req:{}", JSONUtil.toJsonStr(req));
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.postForEntity("https://gatewaytestapi.sxczgkj.cn/gate-service/merchantOrder/returnOrder", req, String.class);
log.info("groupOrderReturn:{}", response.getBody());
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
JSONObject object = JSONObject.parseObject(response.getBody());
if (!object.get("code").equals("0")) {
throw new BadRequestException("退款渠道调用失败");
}
}
groupOrderInfo.setRefundNumber(groupOrderInfo.getRefundNumber() + param.getNum());
groupOrderInfo.setRefundAmount(groupOrderInfo.getRefundAmount().add(param.getRefundAmount()));
if (groupOrderInfo.getNumber().equals(groupOrderInfo.getRefundNumber())) {
groupOrderInfo.setRefundAble(0);
groupOrderInfo.setStatus("refund");
}
tbGroupOrderInfoRepository.save(groupOrderInfo);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -19,6 +19,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.ysk.cashier.dto.product.TbProductDto;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
import cn.ysk.cashier.dto.shop.TbCouponCategoryDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.product.TbProductMapper;
import cn.ysk.cashier.pojo.product.*;
@ -27,11 +28,13 @@ import cn.ysk.cashier.repository.product.*;
import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
import cn.ysk.cashier.repository.shop.TbShopUserDutyDetailRepository;
import cn.ysk.cashier.service.product.TbProductService;
import cn.ysk.cashier.service.shop.TbCouponCategoryService;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.TbProductVo;
import com.alibaba.fastjson.JSONArray;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -40,7 +43,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -69,6 +71,7 @@ public class TbProductServiceImpl implements TbProductService {
private final TbProductSkuResultRepository tbProductSkuResultRepository;
private final TbShopCategoryRepository tbShopCategoryRepository;
private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe;
private final TbCouponCategoryService tbCouponCategoryService;
private final RedisUtils redisUtils;
@ -241,6 +244,15 @@ public class TbProductServiceImpl implements TbProductService {
Optional<TbProductSkuResult> skuResult = tbProductSkuResultRepository.findById(tbProductVo.getId());
tbProductVo.setSkuSnap(skuResult.get().getTagSnap());
}
if ("group".equals(tbProductVo.getTypeEnum())) {
if (StringUtils.isNotBlank(tbProduct.getGroupCategoryId())) {
JSONArray objects = ListUtil.stringChangeList(tbProduct.getGroupCategoryId());
for (Object groupCategoryId : objects) {
TbCouponCategoryDto byId = tbCouponCategoryService.findById(Integer.valueOf(groupCategoryId.toString()));
tbProductVo.getGroupCategoryId().add(byId);
}
}
}
return tbProductVo;
}
@ -294,16 +306,19 @@ public class TbProductServiceImpl implements TbProductService {
product.setStatus(1);
product.setCreatedAt(Instant.now().toEpochMilli());
product.setUpdatedAt(Instant.now().toEpochMilli());
if (!resources.getGroupSnap().isEmpty()) {
ListUtil.JSONArrayChangeString(resources.getGroupSnap());
}
if (resources.getUnitId() != null) {
product.setUnitId(resources.getUnitId());
}
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
product.setIsCombo(1);
if("group".equals(resources.getTypeEnum())){
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
product.setIsCombo(1);
}
if(!CollectionUtils.isEmpty(resources.getGroupCategoryId())){
List<Integer> collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList());
product.setGroupCategoryId(collect.toString());
}
}
TbProduct save = tbProductRepository.save(product);
@ -351,8 +366,16 @@ public class TbProductServiceImpl implements TbProductService {
product.setUpdatedAt(Instant.now().toEpochMilli());
product.setCategoryId(resources.getCategoryId().toString());
product.setImages(resources.getImages().toString());
if (!resources.getGroupSnap().isEmpty()) {
ListUtil.JSONArrayChangeString(resources.getGroupSnap());
if("group".equals(resources.getTypeEnum())){
//套餐内容
if (!resources.getGroupSnap().isEmpty()) {
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
product.setIsCombo(1);
}
if(!CollectionUtils.isEmpty(resources.getGroupCategoryId())){
List<Integer> collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList());
product.setGroupCategoryId(collect.toString());
}
}
TbProduct save = tbProductRepository.save(product);

View File

@ -90,12 +90,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables);
List<TbShopInfo> content = page.getContent();
for (TbShopInfo data: content){
if (data.getProfiles() == null){
data.setProfiles("");
}
}
return PageUtil.toPage(page);
}

View File

@ -0,0 +1,23 @@
package cn.ysk.cashier.service.order;
import cn.ysk.cashier.pojo.order.TbGroupOrderCoupon;
import java.util.List;
/**
* @author ww
* @date 2024-05-07
**/
public interface TbGroupOrderCouponService {
/**
* 查询所有数据不分页
*/
List<TbGroupOrderCoupon> queryAll(Integer orderId);
List<TbGroupOrderCoupon> queryNoRefundByOrderId(Integer orderId);
void update(TbGroupOrderCoupon resources);
}

View File

@ -0,0 +1,72 @@
package cn.ysk.cashier.service.order;
import cn.ysk.cashier.dto.order.ReturnGroupOrderDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoDto;
import cn.ysk.cashier.dto.order.TbGroupOrderInfoQueryCriteria;
import cn.ysk.cashier.pojo.order.TbGroupOrderInfo;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author ww
* @date 2024-05-07
**/
public interface TbGroupOrderInfoService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbGroupOrderInfoQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbGroupOrderInfoDto>
*/
List<TbGroupOrderInfoDto> queryAll(TbGroupOrderInfoQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TbGroupOrderInfoDto
*/
TbGroupOrderInfoDto findById(Integer id);
ResponseEntity<Object> returnOrder(ReturnGroupOrderDto param);
/**
* 创建
* @param resources /
* @return TbGroupOrderInfoDto
*/
TbGroupOrderInfoDto create(TbGroupOrderInfo resources);
/**
* 编辑
* @param resources /
*/
void update(TbGroupOrderInfo resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<TbGroupOrderInfoDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -34,32 +34,42 @@ import java.util.List;
@Setter
@Table(name="sys_dict")
public class Dict extends BaseEntity implements Serializable {
@Id
@Column(name = "dict_id")
@NotNull(groups = Update.class)
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "`dict_id`")
@ApiModelProperty(value = "ID")
private Integer id;
@OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
private List<DictDetail> dictDetails;
@Column(name = "dict_name")
@Column(name = "`dict_name`")
@ApiModelProperty(value = "字典标识")
private String dictName;
@Column(name = "`name`",nullable = false)
@NotBlank
@ApiModelProperty(value = "名称")
@ApiModelProperty(value = "字典名称")
private String name;
@ApiModelProperty(value = "描述")
private String description;
@Column(name = "`is_child`")
@ApiModelProperty(value = "是否有子类0否1是")
private Integer isChild;
@Column(name = "`rele_id`")
@ApiModelProperty(value = "父id")
private Integer releId;
@Column(name = "`value`")
@ApiModelProperty(value = "")
private String value;
@Column(name = "`type`")
@ApiModelProperty(value = "类型:通用-common首页-home热销-hot")
private String type;
@Column(name = "is_child")
@ApiModelProperty(value = "描述 是否有子类0否1是")
private Integer isChild;
@Column(name = "`status`")
@ApiModelProperty(value = "是否展示 0否 1是")
private Integer status;
@Column(name = "`sort`")
@ApiModelProperty(value = "排序")
private Integer sort;
}

View File

@ -57,6 +57,9 @@ public class DictDetail extends BaseEntity implements Serializable {
@ApiModelProperty(value = "字典值")
private String value;
@ApiModelProperty(value = "是否展示 0否 1是")
private Integer status;
@JoinColumn(name = "rele_id")
@ApiModelProperty(value = "自关联id 三级时存在",hidden = true)
private Integer releId;

View File

@ -18,6 +18,7 @@ package cn.ysk.cashier.system.repository;
import cn.ysk.cashier.system.domain.Dict;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@ -34,14 +35,21 @@ public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificat
* 删除
* @param ids /
*/
void deleteByIdIn(Set<Long> ids);
void deleteByIdIn(Set<Integer> ids);
void deleteByReleId(Integer releId);
List<Dict> findByReleId(Integer releId);
@Modifying
@Query("update Dict dict set dict.isChild=1 where dict.id =:id")
void updateByReleId(@Param("id")Integer id);
/**
* 查询
* @param ids /
* @return /
*/
List<Dict> findByIdIn(Set<Long> ids);
List<Dict> findByIdIn(Set<Integer> ids);
@Query("select dict from Dict dict where dict.name =:name")
Dict findByName(@Param("name") String name);

View File

@ -46,20 +46,6 @@ public class DictController {
private final DictService dictService;
private static final String ENTITY_NAME = "dict";
@ApiOperation("导出字典数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dict:list')")
public void exportDict(HttpServletResponse response, DictQueryCriteria criteria) throws IOException {
dictService.download(dictService.queryAll(criteria), response);
}
@ApiOperation("查询字典")
@GetMapping(value = "/all")
@PreAuthorize("@el.check('dict:list')")
public ResponseEntity<Object> queryAllDict(){
return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK);
}
@ApiOperation("查询字典")
@GetMapping
@PreAuthorize("@el.check('dict:list')")
@ -93,7 +79,7 @@ public class DictController {
@ApiOperation("删除字典")
@DeleteMapping
@PreAuthorize("@el.check('dict:del')")
public ResponseEntity<Object> deleteDict(@RequestBody Set<Long> ids){
public ResponseEntity<Object> deleteDict(@RequestBody Set<Integer> ids){
dictService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -1,93 +1,93 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.system.rest;
import cn.ysk.cashier.system.domain.DictDetail;
import cn.ysk.cashier.system.service.dto.DictDetailDto;
import cn.ysk.cashier.system.service.dto.DictDetailQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.system.service.DictDetailService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:字典详情管理")
@RequestMapping("/api/dictDetail")
public class DictDetailController {
private final DictDetailService dictDetailService;
private static final String ENTITY_NAME = "dictDetail";
@ApiOperation("查询字典详情")
@GetMapping
public ResponseEntity<Object> queryDictDetail(DictDetailQueryCriteria criteria,
@PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable) {
return new ResponseEntity<>(dictDetailService.queryAll(criteria, pageable), HttpStatus.OK);
}
@Log("新增字典详情")
@ApiOperation("新增字典详情")
@PostMapping
@PreAuthorize("@el.check('dict:add')")
public ResponseEntity<Object> createDictDetail(@Validated @RequestBody DictDetail resources) {
if (resources.getId() != null) {
throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
}
if (resources.getDict() != null && resources.getReleId() != null) {
throw new BadRequestException("参数错误");
}
dictDetailService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("修改字典详情")
@ApiOperation("修改字典详情")
@PutMapping
@PreAuthorize("@el.check('dict:edit')")
public ResponseEntity<Object> updateDictDetail(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources) {
dictDetailService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除字典详情")
@ApiOperation("删除字典详情")
@DeleteMapping(value = "/{id}")
@PreAuthorize("@el.check('dict:del')")
public ResponseEntity<Object> deleteDictDetail(@PathVariable Long id) {
dictDetailService.delete(id);
return new ResponseEntity<>(HttpStatus.OK);
}
}
///*
// * Copyright 2019-2020 Zheng Jie
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package cn.ysk.cashier.system.rest;
//
//import cn.ysk.cashier.system.domain.DictDetail;
//import cn.ysk.cashier.system.service.dto.DictDetailDto;
//import cn.ysk.cashier.system.service.dto.DictDetailQueryCriteria;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.RequiredArgsConstructor;
//import cn.ysk.cashier.annotation.Log;
//import cn.ysk.cashier.exception.BadRequestException;
//import cn.ysk.cashier.system.service.DictDetailService;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.domain.Sort;
//import org.springframework.data.web.PageableDefault;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * @author Zheng Jie
// * @date 2019-04-10
// */
//@RestController
//@RequiredArgsConstructor
//@Api(tags = "系统:字典详情管理")
//@RequestMapping("/api/dictDetail")
//public class DictDetailController {
//
// private final DictDetailService dictDetailService;
// private static final String ENTITY_NAME = "dictDetail";
//
// @ApiOperation("查询字典详情")
// @GetMapping
// public ResponseEntity<Object> queryDictDetail(DictDetailQueryCriteria criteria,
// @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable) {
// return new ResponseEntity<>(dictDetailService.queryAll(criteria, pageable), HttpStatus.OK);
// }
//
// @Log("新增字典详情")
// @ApiOperation("新增字典详情")
// @PostMapping
// @PreAuthorize("@el.check('dict:add')")
// public ResponseEntity<Object> createDictDetail(@Validated @RequestBody DictDetail resources) {
// if (resources.getId() != null) {
// throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
// }
// if (resources.getDict() != null && resources.getReleId() != null) {
// throw new BadRequestException("参数错误");
// }
// dictDetailService.create(resources);
// return new ResponseEntity<>(HttpStatus.CREATED);
// }
//
// @Log("修改字典详情")
// @ApiOperation("修改字典详情")
// @PutMapping
// @PreAuthorize("@el.check('dict:edit')")
// public ResponseEntity<Object> updateDictDetail(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources) {
// dictDetailService.update(resources);
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
// }
//
// @Log("删除字典详情")
// @ApiOperation("删除字典详情")
// @DeleteMapping(value = "/{id}")
// @PreAuthorize("@el.check('dict:del')")
// public ResponseEntity<Object> deleteDictDetail(@PathVariable Long id) {
// dictDetailService.delete(id);
// return new ResponseEntity<>(HttpStatus.OK);
// }
//}

View File

@ -39,12 +39,6 @@ public interface DictService {
*/
Map<String,Object> queryAll(DictQueryCriteria criteria, Pageable pageable);
/**
* 查询全部数据
* @param dict /
* @return /
*/
List<DictDto> queryAll(DictQueryCriteria dict);
/**
* 创建
@ -63,13 +57,6 @@ public interface DictService {
* 删除
* @param ids /
*/
void delete(Set<Long> ids);
void delete(Set<Integer> ids);
/**
* 导出数据
* @param queryAll 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException;
}

View File

@ -15,6 +15,7 @@
*/
package cn.ysk.cashier.system.service.dto;
import cn.ysk.cashier.system.domain.Dict;
import lombok.Getter;
import lombok.Setter;
import cn.ysk.cashier.base.BaseDTO;
@ -29,13 +30,29 @@ import java.util.List;
@Setter
public class DictDto extends BaseDTO implements Serializable {
private Long id;
private Integer id;
private String dictName;
private List<DictDetailDto> dictDetails;
private String name;
private String description;
/** 是否有子类0否1是 */
private Integer isChild;
/** 父id */
private Integer releId;
/** 值 */
private String value;
/** 类型:通用-common首页-home热销-hot */
private String type;
/** 是否展示 0否 1是 */
private Integer status;
/** 排序 */
private Integer sort;
private List<Dict> dictDetails;
}

View File

@ -18,6 +18,8 @@ package cn.ysk.cashier.system.service.dto;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
import static cn.ysk.cashier.annotation.Query.Type.IS_NULL;
/**
* @author Zheng Jie
* 公共查询类
@ -27,4 +29,6 @@ public class DictQueryCriteria {
@Query(blurry = "name,description")
private String blurry;
@Query(type = IS_NULL)
private Integer releId;
}

View File

@ -1,122 +1,122 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.system.service.impl;
import cn.ysk.cashier.system.domain.Dict;
import cn.ysk.cashier.system.domain.DictDetail;
import cn.ysk.cashier.system.repository.DictDetailRepository;
import cn.ysk.cashier.system.repository.DictRepository;
import cn.ysk.cashier.system.service.DictDetailService;
import cn.ysk.cashier.system.service.dto.DictDetailDto;
import cn.ysk.cashier.system.service.dto.DictDetailQueryCriteria;
import cn.ysk.cashier.system.service.mapstruct.DictDetailMapper;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.exception.BadRequestException;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Service
@RequiredArgsConstructor
@CacheConfig(cacheNames = "dict")
public class DictDetailServiceImpl implements DictDetailService {
private final DictRepository dictRepository;
private final DictDetailRepository dictDetailRepository;
private final DictDetailMapper dictDetailMapper;
private final RedisUtils redisUtils;
@Override
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DictDetail resources) {
if(resources.getDict()!=null){
Dict dict = dictRepository.findById(resources.getDict().getId()).orElseGet(Dict::new);
dict.setIsChild(1);
dictRepository.save(dict);
resources.setDictName(dict.getDictName());
// 清理缓存
delCaches(resources);
}
dictDetailRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(DictDetail resources) {
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
resources.setId(dictDetail.getId());
dictDetailRepository.save(resources);
// 清理缓存
delCaches(resources);
}
@Override
@Cacheable(key = "'name:' + #p0")
public List<DictDetailDto> getDictByName(String name) {
return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
DictDetail dictDetail = dictDetailRepository.findById(id).orElseGet(DictDetail::new);
Dict dict = dictDetail.getDict();
// 清理缓存
delCaches(dictDetail);
// dictDetailRepository.deleteById(id);
dictDetailRepository.delAllById(id);
if (dict!=null) {
List<DictDetail> dictDetails = queryName(dict.getName());
if(CollectionUtils.isEmpty(dictDetails)){
dict.setIsChild(0);
dictRepository.save(dict);
}
}
}
@Override
public List<DictDetail> queryName(String name) {
Dict byName = dictRepository.findByName(name);
if (byName.getId() == null){
throw new BadRequestException("字典值有误");
}
return byName.getDictDetails();
}
public void delCaches(DictDetail dictDetail){
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
redisUtils.del(CacheKey.DICT_NAME + dict.getName());
}
}
///*
// * Copyright 2019-2020 Zheng Jie
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package cn.ysk.cashier.system.service.impl;
//
//import cn.ysk.cashier.system.domain.Dict;
//import cn.ysk.cashier.system.domain.DictDetail;
//import cn.ysk.cashier.system.repository.DictDetailRepository;
//import cn.ysk.cashier.system.repository.DictRepository;
//import cn.ysk.cashier.system.service.DictDetailService;
//import cn.ysk.cashier.system.service.dto.DictDetailDto;
//import cn.ysk.cashier.system.service.dto.DictDetailQueryCriteria;
//import cn.ysk.cashier.system.service.mapstruct.DictDetailMapper;
//import cn.ysk.cashier.utils.*;
//import lombok.RequiredArgsConstructor;
//import cn.ysk.cashier.exception.BadRequestException;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.Cacheable;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.Pageable;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.CollectionUtils;
//
//import java.util.List;
//import java.util.Map;
//
///**
//* @author Zheng Jie
//* @date 2019-04-10
//*/
//@Service
//@RequiredArgsConstructor
//@CacheConfig(cacheNames = "dict")
//public class DictDetailServiceImpl implements DictDetailService {
//
// private final DictRepository dictRepository;
// private final DictDetailRepository dictDetailRepository;
// private final DictDetailMapper dictDetailMapper;
// private final RedisUtils redisUtils;
//
// @Override
// public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
// Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
// return PageUtil.toPage(page.map(dictDetailMapper::toDto));
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void create(DictDetail resources) {
// if(resources.getDict()!=null){
// Dict dict = dictRepository.findById(resources.getDict().getId()).orElseGet(Dict::new);
// dict.setIsChild(1);
// dictRepository.save(dict);
// resources.setDictName(dict.getDictName());
// // 清理缓存
// delCaches(resources);
// }
// dictDetailRepository.save(resources);
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void update(DictDetail resources) {
// DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
// ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
// resources.setId(dictDetail.getId());
// dictDetailRepository.save(resources);
// // 清理缓存
// delCaches(resources);
// }
//
// @Override
// @Cacheable(key = "'name:' + #p0")
// public List<DictDetailDto> getDictByName(String name) {
// return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void delete(Long id) {
// DictDetail dictDetail = dictDetailRepository.findById(id).orElseGet(DictDetail::new);
// Dict dict = dictDetail.getDict();
// // 清理缓存
// delCaches(dictDetail);
//// dictDetailRepository.deleteById(id);
// dictDetailRepository.delAllById(id);
// if (dict!=null) {
// List<DictDetail> dictDetails = queryName(dict.getName());
// if(CollectionUtils.isEmpty(dictDetails)){
// dict.setIsChild(0);
// dictRepository.save(dict);
// }
// }
// }
//
// @Override
// public List<DictDetail> queryName(String name) {
// Dict byName = dictRepository.findByName(name);
// if (byName.getId() == null){
// throw new BadRequestException("字典值有误");
// }
// return byName.getDictDetails();
// }
//
// public void delCaches(DictDetail dictDetail){
// Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
// redisUtils.del(CacheKey.DICT_NAME + dict.getName());
// }
//}

View File

@ -15,33 +15,35 @@
*/
package cn.ysk.cashier.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import cn.ysk.cashier.system.domain.Dict;
import cn.ysk.cashier.system.domain.DictDetail;
import cn.ysk.cashier.system.repository.DictDetailRepository;
import cn.ysk.cashier.system.repository.DictRepository;
import cn.ysk.cashier.system.service.DictDetailService;
import cn.ysk.cashier.system.service.DictService;
import cn.ysk.cashier.system.service.dto.DictDetailDto;
import cn.ysk.cashier.system.service.dto.DictDto;
import cn.ysk.cashier.system.service.dto.DictQueryCriteria;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.system.service.mapstruct.DictMapper;
import cn.ysk.cashier.utils.CacheKey;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.RedisUtils;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import javax.persistence.criteria.Predicate;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
* @author Zheng Jie
* @date 2019-04-10
*/
@Service
@RequiredArgsConstructor
@CacheConfig(cacheNames = "dict")
@ -53,20 +55,30 @@ public class DictServiceImpl implements DictService {
private final RedisUtils redisUtils;
@Override
public Map<String, Object> queryAll(DictQueryCriteria dict, Pageable pageable){
Page<Dict> page = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb), pageable);
return PageUtil.toPage(page.map(dictMapper::toDto));
}
public Map<String, Object> queryAll(DictQueryCriteria criteria, Pageable pageable) {
@Override
public List<DictDto> queryAll(DictQueryCriteria dict) {
List<Dict> list = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb));
return dictMapper.toDto(list);
Page<Dict> page = dictRepository.findAll((root, criteriaQuery, criteriaBuilder) -> {
Predicate predicate = QueryHelp.getPredicate(root, criteria, criteriaBuilder);
// 追加校验参数 status不为空 source不为空 不查询状态为 "refund"
predicate = criteriaBuilder.and(predicate, criteriaBuilder.isNull(root.get("releId")));
return predicate;
}, pageable);
Page<DictDto> pageDto = page.map(dictMapper::toDto);
for (DictDto dictDto : pageDto.getContent()) {
if (dictDto.getIsChild() != null && dictDto.getIsChild() == 1) {
dictDto.setDictDetails(dictRepository.findByReleId(dictDto.getId()));
}
}
return PageUtil.toPage(pageDto);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Dict resources) {
resources.setIsChild(0);
if (resources.getReleId() != null) {
dictRepository.updateByReleId(resources.getReleId());
}
dictRepository.save(resources);
}
@ -75,59 +87,23 @@ public class DictServiceImpl implements DictService {
public void update(Dict resources) {
// 清理缓存
delCaches(resources);
Dict dict = dictRepository.findById(resources.getId()).orElseGet(Dict::new);
ValidationUtil.isNull( dict.getId(),"Dict","id",resources.getId());
dict.setName(resources.getName());
dict.setDescription(resources.getDescription());
dictRepository.save(dict);
dictRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Set<Long> ids) {
// 清理缓存
public void delete(Set<Integer> ids) {
List<Dict> dicts = dictRepository.findByIdIn(ids);
for (Dict dict : dicts) {
Dict byName = dictRepository.findByName(dict.getName());
if(CollectionUtil.isNotEmpty(byName.getDictDetails())){
Set<Long> idSet = byName.getDictDetails().stream()
.map(DictDetail::getId) // 提取id
.collect(Collectors.toSet()); // 转为Set集合
dictDetailRepository.delAllByIdIn(idSet);
if (dict.getIsChild()==1) {
dictRepository.deleteByReleId(dict.getId());
}
delCaches(dict);
}
dictRepository.deleteByIdIn(ids);
}
@Override
public void download(List<DictDto> dictDtos, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (DictDto dictDTO : dictDtos) {
if(CollectionUtil.isNotEmpty(dictDTO.getDictDetails())){
for (DictDetailDto dictDetail : dictDTO.getDictDetails()) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("字典名称", dictDTO.getName());
map.put("字典描述", dictDTO.getDescription());
map.put("字典标签", dictDetail.getLabel());
map.put("字典值", dictDetail.getValue());
map.put("创建日期", dictDetail.getCreateTime());
list.add(map);
}
} else {
Map<String,Object> map = new LinkedHashMap<>();
map.put("字典名称", dictDTO.getName());
map.put("字典描述", dictDTO.getDescription());
map.put("字典标签", null);
map.put("字典值", null);
map.put("创建日期", dictDTO.getCreateTime());
list.add(map);
}
}
FileUtil.downloadExcel(list, response);
}
public void delCaches(Dict dict){
public void delCaches(Dict dict) {
redisUtils.del(CacheKey.DICT_NAME + dict.getName());
}
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.vo;
import cn.ysk.cashier.dto.shop.TbCouponCategoryDto;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import cn.ysk.cashier.pojo.product.TbProductSku;
@ -217,4 +218,5 @@ public class TbProductVo {
private String skuSnap;
private List<TbCouponCategoryDto> groupCategoryId = new ArrayList<>();
}

View File

@ -29,7 +29,7 @@ spring:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
show_sql: true
show_sql: false
# redisdb5:
# #数据库索引