parent
0e35116e9d
commit
44509e1d32
|
|
@ -0,0 +1,236 @@
|
|||
package cn.ysk.cashier.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Stone
|
||||
* @version V1.0.0
|
||||
* @date 2020/2/12
|
||||
*/
|
||||
public class JSONUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串
|
||||
*
|
||||
* @param obj 被转的对象
|
||||
* @param dateFormat 日期格式,当传null或空串时,则被格式化为时间戳,否则返回指定的格式。例子:yyyy-MM-dd HH:mm:ss(不合法的日期格式会格式化出错)
|
||||
* @param ignoreNull 是否忽略null字段。true时,且当字段的值是null,则不输出该字段
|
||||
* @param noRef 是否不转换成ref。例如false,当字段间是相同的引用之时,则将出现$ref之类的符号替代冗余的值
|
||||
* @param pretty 是否格式化JSON字符串以便有更好的可读性
|
||||
* @return JSON字符串,出异常时抛出
|
||||
*/
|
||||
public static String toJSONString0(Object obj,
|
||||
String dateFormat,
|
||||
boolean ignoreNull,
|
||||
boolean noRef,
|
||||
boolean pretty) {
|
||||
try {
|
||||
List<SerializerFeature> featureList = new ArrayList<>();
|
||||
|
||||
// 当传null时,则返回默认的时间戳,否则则返回指定的格式
|
||||
if (dateFormat != null && dateFormat.length() > 0) {
|
||||
featureList.add(SerializerFeature.WriteDateUseDateFormat);
|
||||
}
|
||||
if (!ignoreNull) {
|
||||
// 当字段的值是null时,依然出现这个字段,即不忽略
|
||||
featureList.add(SerializerFeature.WriteMapNullValue);
|
||||
}
|
||||
if (noRef) {
|
||||
featureList.add(SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
if (pretty) {
|
||||
featureList.add(SerializerFeature.PrettyFormat);
|
||||
}
|
||||
|
||||
SerializerFeature[] featureArr = featureList.toArray(new SerializerFeature[featureList.size()]);
|
||||
return JSONObject.toJSONString(obj, SerializeConfig.globalInstance, null, dateFormat,
|
||||
JSON.DEFAULT_GENERATE_FEATURE, featureArr);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Convert object to JSON string, error[" + obj + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串。
|
||||
* 日期转为特别的格式,不忽略null值的字段,不格式化JSON字符串
|
||||
*
|
||||
* @param obj 被转换的对象
|
||||
* @return JSON字符串,发送异常时抛出
|
||||
*/
|
||||
public static String toJSONString(Object obj) {
|
||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串。
|
||||
* 日期转为特别的格式,不忽略null值的字段,不格式化JSON字符串
|
||||
*
|
||||
* @param obj 被转换的对象
|
||||
* @return JSON字符串,发送异常时抛出
|
||||
*/
|
||||
public static String toJSONString(Object obj,boolean ignoreNull) {
|
||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", ignoreNull, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串。不抛出异常,专用于日志打印
|
||||
*
|
||||
* @param obj 被转换的对象
|
||||
* @return JSON字符串,出异常时返回null
|
||||
*/
|
||||
public static String toJSONStringNoThrows(Object obj) {
|
||||
try {
|
||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
||||
} catch (Exception e) {
|
||||
logError(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析JSON字符串成为一个Object,结果可能是JSONArray(多个)或JSONObject(单个)
|
||||
* (该方法可用于对json字符串不知道是对象还是列表的时候之用)
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONEntity会有这个字段)
|
||||
*
|
||||
* @param jsonStr 要解析的JSON字符串
|
||||
* @return 返回JSONEntity,当jsonArrayFlag 为true,表示它是 JSONArray,否则是JSONObject
|
||||
*/
|
||||
public static JSONEntity parseJSONStr2JSONEntity(String jsonStr) {
|
||||
try {
|
||||
Object value = JSON.parse(jsonStr);
|
||||
boolean jsonArrayFlag = false;
|
||||
if (value instanceof JSONArray) {
|
||||
jsonArrayFlag = true;
|
||||
}
|
||||
return new JSONEntity(jsonArrayFlag, value);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为JSON对象,注意数组类型会抛异常[{name:"Stone"}]
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONObject时会有这个字段,因为JSONObject就相当于map)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @return 返回转换结果。传入的JSON字串必须是对象而非数组,否则会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static JSONObject parseJSONStr2JSONObject(String jsonStr) {
|
||||
try {
|
||||
return (JSONObject) JSONObject.parse(jsonStr);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为JSON数组,注意对象类型,非数组的会抛异常{name:"Stone"}
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONArray时,其元素会有这个字段,因为JSONArray的元素JSONObject就相当于map)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @return 返回转换结果。当传入的JSON字串是非数组形式时,会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static JSONArray parseJSONStr2JSONArray(String jsonStr) {
|
||||
try {
|
||||
return (JSONArray) JSONArray.parse(jsonStr);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为某个类
|
||||
* (日期字段不管是时间戳形式还是yyyy-MM-dd HH:mm:ss的形式都能成功转换)
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,T类没有,转换成T对象的时候,不会抛出异常)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @param clazz 转为什么类型
|
||||
* @return 返回转换结果。当传入的JSON字串是数组形式时,会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static <T> T parseJSONStr2T(String jsonStr, Class<T> clazz) {
|
||||
try {
|
||||
return JSONObject.parseObject(jsonStr, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
public static <T> T jsonStrToObject(String jsonStr, Class<T> clazz) {
|
||||
Object obj = JSONArray.parseObject(jsonStr, clazz);
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
public static <T> T jsonstrtoObject(String str,TypeReference<T> tTypeReference ){
|
||||
return JSON.parseObject(str, tTypeReference);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String sss = "{\"bizData\":{\"amount\":1,\"currency\":\"cny\",\"ifCode\":\"sxfpay\",\"mchOrderNo\":\"CZ1715744291232\",\"mercNo\":\"B240510702030\",\"note\":\"等待用户付款\",\"payOrderId\":\"O1790587460614225921\",\"payType\":\"WECHAT\",\"settlementType\":\"D1\",\"state\":\"TRADE_AWAIT\",\"storeId\":\"S2405103298\",\"subject\":\"测试支付\",\"tradeFee\":0},\"code\":\"000000\",\"msg\":\"请求成功\",\"sign\":\"40710a3c293eeac3c7f4a1b0696a2bf6\",\"signType\":\"MD5\",\"timestamp\":\"20240515113813\"}";
|
||||
// TypeReference<PublicResp<MainScanResp>> typeRef = new TypeReference<PublicResp<MainScanResp>>(){};
|
||||
// PublicResp<MainScanResp> response = JSON.parseObject(sss, typeRef);
|
||||
System.out.println("pm");
|
||||
}
|
||||
/**
|
||||
* 字符串转为某个类的列表
|
||||
* (日期字段不管是时间戳形式还是yyyy-MM-dd HH:mm:ss的形式都能成功转换)
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,T类没有,转换成T对象的时候,不会抛出异常)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @param clazz List里装的元素的类型
|
||||
* @return 返回转换结果。当传入的JSON字串是非数组的形式时会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static <T> List<T> parseJSONStr2TList(String jsonStr, Class<T> clazz) {
|
||||
try {
|
||||
return JSONObject.parseArray(jsonStr, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class JSONEntity {
|
||||
public JSONEntity() {
|
||||
}
|
||||
|
||||
public JSONEntity(boolean jsonArrayFlag, Object value) {
|
||||
this.jsonArrayFlag = jsonArrayFlag;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private boolean jsonArrayFlag;
|
||||
private Object value;
|
||||
|
||||
public boolean getJsonArrayFlag() {
|
||||
return jsonArrayFlag;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JSONEntity{" +
|
||||
"jsonArrayFlag=" + jsonArrayFlag +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
private static void logError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.service.TbPlatformDictService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "应用中心管理")
|
||||
@RequestMapping("/api/appCenter")
|
||||
public class AppCenterController {
|
||||
|
||||
private final TbPlatformDictService tbPlatformDictService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("获取应用中心列表")
|
||||
public ResponseEntity<Object> queryBotButtonConfig(){
|
||||
return new ResponseEntity<>(tbPlatformDictService.queryByType("appCenter"), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorage;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageRecordService;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Sort;
|
||||
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.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "存酒管理")
|
||||
@RequestMapping("/api/storage")
|
||||
public class TbShopStorageController {
|
||||
|
||||
private final TbShopStorageService tbShopStorageService;
|
||||
private final TbShopStorageRecordService tbShopStorageRecordService;
|
||||
//
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// public void exportTbShopStorage(HttpServletResponse response, TbShopStorageQueryCriteria criteria) throws IOException {
|
||||
// tbShopStorageService.download(tbShopStorageService.queryAll(criteria), response);
|
||||
// }
|
||||
|
||||
@PostMapping("list")
|
||||
@ApiOperation("查询存酒列表")
|
||||
public ResponseEntity<Object> queryTbShopStorage(@RequestBody TbShopStorageQueryCriteria criteria){
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(),Sort.by(Sort.Direction.DESC, "id"));
|
||||
return new ResponseEntity<>(tbShopStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增存酒:#resources.name")
|
||||
@ApiOperation("新增存酒")
|
||||
public ResponseEntity<Object> createTbShopStorage(@Validated @RequestBody TbShopStorage resources){
|
||||
return new ResponseEntity<>(tbShopStorageService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("存取酒")
|
||||
@ApiOperation("存取酒")
|
||||
public ResponseEntity<Object> updateTbShopStorage(@Validated @RequestBody TbShopStorageNumDto resources) {
|
||||
tbShopStorageService.updateNum(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@GetMapping("recordList")
|
||||
@ApiOperation("查询存取酒记录")
|
||||
public ResponseEntity<Object> queryTbShopStorageRecord(TbShopStorageRecordQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopStorageRecordService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodQueryCriteria;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageGoodService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Sort;
|
||||
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.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "酒品管理")
|
||||
@RequestMapping("/api/tbShopStorageGood")
|
||||
public class TbShopStorageGoodController {
|
||||
|
||||
private final TbShopStorageGoodService tbShopStorageGoodService;
|
||||
|
||||
// @ApiOperation("导出酒品数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// public void exportTbShopStorageGood(HttpServletResponse response, TbShopStorageGoodQueryCriteria criteria) throws IOException {
|
||||
// tbShopStorageGoodService.download(tbShopStorageGoodService.queryAll(criteria), response);
|
||||
// }
|
||||
|
||||
@PostMapping("list")
|
||||
@Log("查询酒品列表")
|
||||
@ApiOperation("查询酒品列表")
|
||||
public ResponseEntity<Object> queryTbShopStorageGood(@RequestBody TbShopStorageGoodQueryCriteria criteria){
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), Sort.by(Sort.Direction.DESC, "id"));
|
||||
return new ResponseEntity<>(tbShopStorageGoodService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增酒品")
|
||||
@ApiOperation("新增酒品")
|
||||
public ResponseEntity<Object> createTbShopStorageGood(@Validated @RequestBody TbShopStorageGood resources){
|
||||
return new ResponseEntity<>(tbShopStorageGoodService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改酒品")
|
||||
@ApiOperation("修改酒品")
|
||||
public ResponseEntity<Object> updateTbShopStorageGood(@Validated @RequestBody TbShopStorageGood resources){
|
||||
tbShopStorageGoodService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
//
|
||||
// @DeleteMapping
|
||||
// @Log("删除酒品")
|
||||
// @ApiOperation("删除酒品")
|
||||
// public ResponseEntity<Object> deleteTbShopStorageGood(@RequestBody Integer[] ids) {
|
||||
// tbShopStorageGoodService.deleteAll(ids);
|
||||
// return new ResponseEntity<>(HttpStatus.OK);
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
public class TbShopStorageDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 酒品名 */
|
||||
private String name;
|
||||
|
||||
/** 酒品图 */
|
||||
private String imgUrl;
|
||||
|
||||
/** 单位 */
|
||||
private String unit;
|
||||
|
||||
/** 数量 */
|
||||
private Integer num;
|
||||
|
||||
/** 0:已取完;1:未取完 */
|
||||
private Integer status;
|
||||
|
||||
/** 到期时间 */
|
||||
private Timestamp expTime;
|
||||
|
||||
/** 存酒时间 */
|
||||
private Timestamp savTime;
|
||||
|
||||
/** 用户Id */
|
||||
private Integer userid;
|
||||
|
||||
/** 用户昵称 */
|
||||
private String nickname;
|
||||
|
||||
/** 用户电话 */
|
||||
private String telphone;
|
||||
|
||||
/** 店铺id */
|
||||
private Integer shopId;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Data
|
||||
public class TbShopStorageGoodDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 酒品名 */
|
||||
private String name;
|
||||
|
||||
/** 图片地址 */
|
||||
private String imgUrl;
|
||||
|
||||
/** 单位 */
|
||||
private String unit;
|
||||
|
||||
/** 有效期(天) */
|
||||
private Integer period;
|
||||
|
||||
/** 0:未删除;1:已删除 */
|
||||
private Integer isDel;
|
||||
|
||||
private Timestamp createTime;
|
||||
|
||||
/** 0:手动;1:商品; */
|
||||
private Integer source;
|
||||
|
||||
/** 商户Id */
|
||||
private Integer shopId;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Data
|
||||
public class TbShopStorageGoodQueryCriteria{
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String name;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
|
||||
private Integer page=0;
|
||||
private Integer size=10;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TbShopStorageNumDto {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 数量 */
|
||||
private Integer num;
|
||||
/**
|
||||
* 0取酒
|
||||
* 1存酒
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TbShopStorageQueryCriteria {
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String name;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String telphone;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
private Integer page=0;
|
||||
private Integer size=10;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Data
|
||||
public class TbShopStorageRecordDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 存酒信息id */
|
||||
private Integer storageId;
|
||||
|
||||
/** 记录 */
|
||||
private String content;
|
||||
|
||||
/** 操作时间 */
|
||||
private Timestamp time;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Data
|
||||
public class TbShopStorageRecordQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer storageId;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.ysk.cashier.mapper.shop;
|
||||
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodDto;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopStorageGoodMapper extends BaseMapper<TbShopStorageGoodDto, TbShopStorageGood> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mapper.shop;
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageDto;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopStorageMapper extends BaseMapper<TbShopStorageDto, TbShopStorage> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.ysk.cashier.mapper.shop;
|
||||
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordDto;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopStorageRecordMapper extends BaseMapper<TbShopStorageRecordDto, TbShopStorageRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
/**
|
||||
* 订单支付展示(TbOrderPayment)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-05-21 13:55:18
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbOrderPayment extends Model<TbOrderPayment> {
|
||||
//主键
|
||||
private Integer id;
|
||||
//支付方式Id
|
||||
private String payTypeId;
|
||||
//实际支付金额
|
||||
private Double amount;
|
||||
|
||||
private Double paidAmount;
|
||||
//退款金额
|
||||
private Double hasRefundAmount;
|
||||
//支付方式名称
|
||||
private String payName;
|
||||
//支付方式
|
||||
private String payType;
|
||||
//收款
|
||||
private Double received;
|
||||
//找零
|
||||
private Double changeFee;
|
||||
//商户Id
|
||||
private String merchantId;
|
||||
//店铺Id
|
||||
private String shopId;
|
||||
//结算单号
|
||||
private String billingId;
|
||||
|
||||
private String orderId;
|
||||
|
||||
private String authCode;
|
||||
|
||||
private String refundable;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private String tradeNumber;
|
||||
//会员Id
|
||||
private String memberId;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPayTypeId() {
|
||||
return payTypeId;
|
||||
}
|
||||
|
||||
public void setPayTypeId(String payTypeId) {
|
||||
this.payTypeId = payTypeId;
|
||||
}
|
||||
|
||||
public Double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(Double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Double getPaidAmount() {
|
||||
return paidAmount;
|
||||
}
|
||||
|
||||
public void setPaidAmount(Double paidAmount) {
|
||||
this.paidAmount = paidAmount;
|
||||
}
|
||||
|
||||
public Double getHasRefundAmount() {
|
||||
return hasRefundAmount;
|
||||
}
|
||||
|
||||
public void setHasRefundAmount(Double hasRefundAmount) {
|
||||
this.hasRefundAmount = hasRefundAmount;
|
||||
}
|
||||
|
||||
public String getPayName() {
|
||||
return payName;
|
||||
}
|
||||
|
||||
public void setPayName(String payName) {
|
||||
this.payName = payName;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public Double getReceived() {
|
||||
return received;
|
||||
}
|
||||
|
||||
public void setReceived(Double received) {
|
||||
this.received = received;
|
||||
}
|
||||
|
||||
public Double getChangeFee() {
|
||||
return changeFee;
|
||||
}
|
||||
|
||||
public void setChangeFee(Double changeFee) {
|
||||
this.changeFee = changeFee;
|
||||
}
|
||||
|
||||
public String getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
public void setMerchantId(String merchantId) {
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
|
||||
public String getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(String shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getBillingId() {
|
||||
return billingId;
|
||||
}
|
||||
|
||||
public void setBillingId(String billingId) {
|
||||
this.billingId = billingId;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getAuthCode() {
|
||||
return authCode;
|
||||
}
|
||||
|
||||
public void setAuthCode(String authCode) {
|
||||
this.authCode = authCode;
|
||||
}
|
||||
|
||||
public String getRefundable() {
|
||||
return refundable;
|
||||
}
|
||||
|
||||
public void setRefundable(String refundable) {
|
||||
this.refundable = refundable;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getTradeNumber() {
|
||||
return tradeNumber;
|
||||
}
|
||||
|
||||
public void setTradeNumber(String tradeNumber) {
|
||||
this.tradeNumber = tradeNumber;
|
||||
}
|
||||
|
||||
public String getMemberId() {
|
||||
return memberId;
|
||||
}
|
||||
|
||||
public void setMemberId(String memberId) {
|
||||
this.memberId = memberId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
|
||||
|
||||
public interface TbOrderPaymentMapper extends BaseMapper<TbOrderPayment> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
|
||||
/**
|
||||
* 订单支付展示(TbOrderPayment)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-05-21 13:55:18
|
||||
*/
|
||||
public interface TbOrderPaymentService extends IService<TbOrderPayment> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderPaymentMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 订单支付展示(TbOrderPayment)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-05-21 13:55:18
|
||||
*/
|
||||
@Service
|
||||
public class TbOrderPaymentServiceImpl extends ServiceImpl<TbOrderPaymentMapper, TbOrderPayment> implements TbOrderPaymentService {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
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.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_storage")
|
||||
public class TbShopStorage implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`name`")
|
||||
@ApiModelProperty(value = "酒品名")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`img_url`")
|
||||
@ApiModelProperty(value = "酒品图")
|
||||
private String imgUrl;
|
||||
|
||||
@Column(name = "`unit`")
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
@Column(name = "`num`")
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer num;
|
||||
|
||||
@Column(name = "`status`")
|
||||
@ApiModelProperty(value = "0:已取完;1:未取完")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "`exp_time`")
|
||||
@ApiModelProperty(value = "到期时间")
|
||||
private Timestamp expTime;
|
||||
|
||||
@Column(name = "`sav_time`")
|
||||
@ApiModelProperty(value = "存酒时间")
|
||||
private Timestamp savTime;
|
||||
|
||||
@Column(name = "`user_id`")
|
||||
@ApiModelProperty(value = "用户Id")
|
||||
private Integer userid;
|
||||
|
||||
@Column(name = "`nick_name`")
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@Column(name = "`telphone`")
|
||||
@ApiModelProperty(value = "用户电话")
|
||||
private String telphone;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "店铺id")
|
||||
private Integer shopId;
|
||||
|
||||
@Transient
|
||||
private Integer expDay;
|
||||
|
||||
public void copy(TbShopStorage source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
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.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_storage_good")
|
||||
public class TbShopStorageGood implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`name`")
|
||||
@ApiModelProperty(value = "酒品名")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`img_url`")
|
||||
@ApiModelProperty(value = "图片地址")
|
||||
private String imgUrl;
|
||||
|
||||
@Column(name = "`unit`")
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
@Column(name = "`period`")
|
||||
@ApiModelProperty(value = "有效期(天)")
|
||||
private Integer period;
|
||||
|
||||
@Column(name = "`is_del`")
|
||||
@ApiModelProperty(value = "0:未删除;1:已删除")
|
||||
private Integer isDel;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`source`")
|
||||
@ApiModelProperty(value = "0:手动;1:商品;")
|
||||
private Integer source;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "商户Id")
|
||||
private Integer shopId;
|
||||
|
||||
public void copy(TbShopStorageGood source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
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 javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_storage_record")
|
||||
public class TbShopStorageRecord implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`storage_id`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "存酒信息id")
|
||||
private Integer storageId;
|
||||
|
||||
@Column(name = "`content`")
|
||||
@ApiModelProperty(value = "记录")
|
||||
private String content;
|
||||
|
||||
@Column(name = "`time`")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private Timestamp time;
|
||||
|
||||
public void copy(TbShopStorageRecord source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author ww
|
||||
|
|
@ -15,4 +17,7 @@ public interface TbPlatformDictRepository extends JpaRepository<TbPlatformDict,
|
|||
|
||||
@Query("SELECT count(1) FROM TbPlatformDict WHERE name = :name AND type =:type")
|
||||
int isExist(@Param("type")String type, @Param("name") String name);
|
||||
|
||||
@Query
|
||||
List<TbPlatformDict> findAllByTypeAndIsShowCash(String type,Integer isShowCash);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package cn.ysk.cashier.repository.shop;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageGoodRepository extends JpaRepository<TbShopStorageGood, Integer>, JpaSpecificationExecutor<TbShopStorageGood> {
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package cn.ysk.cashier.repository.shop;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageRecordRepository extends JpaRepository<TbShopStorageRecord, Integer>, JpaSpecificationExecutor<TbShopStorageRecord> {
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package cn.ysk.cashier.repository.shop;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorage;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageRepository extends JpaRepository<TbShopStorage, Integer>, JpaSpecificationExecutor<TbShopStorage> {
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ public interface TbPlatformDictService {
|
|||
*/
|
||||
List<TbPlatformDictDto> queryAll(TbPlatformDictQueryCriteria criteria);
|
||||
|
||||
List<TbPlatformDictDto> queryByType(String type);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ public class TbPlatformDictServiceImpl implements TbPlatformDictService {
|
|||
return tbPlatformDictMapper.toDto(tbPlatformDictRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbPlatformDictDto> queryByType(String type){
|
||||
return tbPlatformDictMapper.toDto(tbPlatformDictRepository.findAllByTypeAndIsShowCash(type,1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbPlatformDictDto findById(Integer id) {
|
||||
|
|
|
|||
|
|
@ -1,43 +1,47 @@
|
|||
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.mybatis.entity.TbOrderPayment;
|
||||
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.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.thirdpay.resp.OrderReturnResp;
|
||||
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
||||
import cn.ysk.cashier.thirdpay.service.ThirdPayService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
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.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
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
|
||||
* @description 服务实现
|
||||
* @date 2024-05-07
|
||||
**/
|
||||
@Service
|
||||
|
|
@ -50,22 +54,31 @@ public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
|
|||
private final TbGroupOrderCouponService orderCouponService;
|
||||
private final TbMerchantThirdApplyService thirdApplyService;
|
||||
|
||||
private final ThirdPayService thirdPayService;
|
||||
@Autowired
|
||||
private TbOrderPaymentService paymentService;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
private String url;
|
||||
@Value("${thirdPay.groupCallBack}")
|
||||
private String groupCallBack;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbGroupOrderInfoQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbGroupOrderInfo> page = tbGroupOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
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)));
|
||||
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);
|
||||
ValidationUtil.isNull(tbGroupOrderInfo.getId(), "TbGroupOrderInfo", "id", id);
|
||||
TbGroupOrderInfoDto dto = tbGroupOrderInfoMapper.toDto(tbGroupOrderInfo);
|
||||
dto.setCoupons(orderCouponService.queryAll(dto.getId()));
|
||||
return dto;
|
||||
|
|
@ -81,7 +94,7 @@ public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
|
|||
@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());
|
||||
ValidationUtil.isNull(tbGroupOrderInfo.getId(), "TbGroupOrderInfo", "id", resources.getId());
|
||||
tbGroupOrderInfo.copy(resources);
|
||||
tbGroupOrderInfoRepository.save(tbGroupOrderInfo);
|
||||
}
|
||||
|
|
@ -137,7 +150,7 @@ public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
|
|||
public ResponseEntity<Object> returnOrder(ReturnGroupOrderDto param) {
|
||||
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoRepository.getById(param.getOrderId());
|
||||
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
|
||||
if (param.getNum() >= tbGroupOrderCoupons.size()) {
|
||||
if (param.getNum() > tbGroupOrderCoupons.size()) {
|
||||
throw new BadRequestException("可退数量不足");
|
||||
}
|
||||
for (int i = 0; i < param.getNum(); i++) {
|
||||
|
|
@ -149,31 +162,40 @@ public class TbGroupOrderInfoServiceImpl implements TbGroupOrderInfoService {
|
|||
orderCouponService.update(coupon);
|
||||
}
|
||||
TbMerchantThirdApplyDto thirdApply = thirdApplyService.findById(groupOrderInfo.getMerchantId());
|
||||
if(Objects.isNull(thirdApply)){
|
||||
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("退款渠道调用失败");
|
||||
QueryWrapper<TbOrderPayment> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", param.getOrderId());
|
||||
TbOrderPayment payment = paymentService.getOne(queryWrapper);
|
||||
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(
|
||||
url,
|
||||
thirdApply.getAppId(),
|
||||
groupOrderInfo.getOrderNo(),
|
||||
payment.getTradeNumber(),
|
||||
null,
|
||||
"团购卷订单退款",
|
||||
param.getRefundAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(),
|
||||
groupCallBack,
|
||||
null,
|
||||
thirdApply.getAppToken());
|
||||
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
//TRADE_REFUND
|
||||
if (!"TRADE_SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
|
||||
throw new BadRequestException("退款渠道调用失败");
|
||||
}
|
||||
} else {
|
||||
throw new BadRequestException("退款渠道调用失败:" + publicResp.getMsg());
|
||||
}
|
||||
}
|
||||
groupOrderInfo.setRefundNumber(groupOrderInfo.getRefundNumber() + param.getNum());
|
||||
groupOrderInfo.setRefundAmount(groupOrderInfo.getRefundAmount().add(param.getRefundAmount()));
|
||||
if (groupOrderInfo.getRefundAmount() == null) {
|
||||
groupOrderInfo.setRefundAmount(param.getRefundAmount());
|
||||
}else {
|
||||
groupOrderInfo.setRefundAmount(groupOrderInfo.getRefundAmount().add(param.getRefundAmount()));
|
||||
}
|
||||
if (groupOrderInfo.getNumber().equals(groupOrderInfo.getRefundNumber())) {
|
||||
groupOrderInfo.setRefundAble(0);
|
||||
groupOrderInfo.setStatus("refund");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodQueryCriteria;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopStorageGoodMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
|
||||
import cn.ysk.cashier.repository.shop.TbShopStorageGoodRepository;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageGoodService;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopStorageGoodServiceImpl implements TbShopStorageGoodService {
|
||||
|
||||
private final TbShopStorageGoodRepository tbShopStorageGoodRepository;
|
||||
private final TbShopStorageGoodMapper tbShopStorageGoodMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopStorageGoodQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbShopStorageGood> page = tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbShopStorageGoodMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopStorageGoodDto> queryAll(TbShopStorageGoodQueryCriteria criteria){
|
||||
return tbShopStorageGoodMapper.toDto(tbShopStorageGoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopStorageGoodDto findById(Integer id) {
|
||||
TbShopStorageGood tbShopStorageGood = tbShopStorageGoodRepository.findById(id).orElseGet(TbShopStorageGood::new);
|
||||
ValidationUtil.isNull(tbShopStorageGood.getId(),"TbShopStorageGood","id",id);
|
||||
return tbShopStorageGoodMapper.toDto(tbShopStorageGood);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopStorageGoodDto create(TbShopStorageGood resources) {
|
||||
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
return tbShopStorageGoodMapper.toDto(tbShopStorageGoodRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopStorageGood resources) {
|
||||
TbShopStorageGood tbShopStorageGood = tbShopStorageGoodRepository.findById(resources.getId()).orElseGet(TbShopStorageGood::new);
|
||||
ValidationUtil.isNull( tbShopStorageGood.getId(),"TbShopStorageGood","id",resources.getId());
|
||||
tbShopStorageGood.copy(resources);
|
||||
tbShopStorageGoodRepository.save(tbShopStorageGood);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopStorageGoodRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopStorageGoodDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopStorageGoodDto tbShopStorageGood : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("酒品名", tbShopStorageGood.getName());
|
||||
map.put("图片地址", tbShopStorageGood.getImgUrl());
|
||||
map.put("单位", tbShopStorageGood.getUnit());
|
||||
map.put("有效期(天)", tbShopStorageGood.getPeriod());
|
||||
map.put("0:未删除;1:已删除", tbShopStorageGood.getIsDel());
|
||||
map.put(" createTime", tbShopStorageGood.getCreateTime());
|
||||
map.put("0:手动;1:商品;", tbShopStorageGood.getSource());
|
||||
map.put("商户Id", tbShopStorageGood.getShopId());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordQueryCriteria;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopStorageRecordMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import cn.ysk.cashier.repository.shop.TbShopStorageRecordRepository;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageRecordService;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopStorageRecordServiceImpl implements TbShopStorageRecordService {
|
||||
|
||||
private final TbShopStorageRecordRepository tbShopStorageRecordRepository;
|
||||
private final TbShopStorageRecordMapper tbShopStorageRecordMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopStorageRecordQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbShopStorageRecord> page = tbShopStorageRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbShopStorageRecordMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopStorageRecordDto> queryAll(TbShopStorageRecordQueryCriteria criteria){
|
||||
return tbShopStorageRecordMapper.toDto(tbShopStorageRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopStorageRecordDto findById(Integer id) {
|
||||
TbShopStorageRecord tbShopStorageRecord = tbShopStorageRecordRepository.findById(id).orElseGet(TbShopStorageRecord::new);
|
||||
ValidationUtil.isNull(tbShopStorageRecord.getId(),"TbShopStorageRecord","id",id);
|
||||
return tbShopStorageRecordMapper.toDto(tbShopStorageRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopStorageRecordDto create(TbShopStorageRecord resources) {
|
||||
resources.setTime(new Timestamp(System.currentTimeMillis()));
|
||||
return tbShopStorageRecordMapper.toDto(tbShopStorageRecordRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopStorageRecord resources) {
|
||||
TbShopStorageRecord tbShopStorageRecord = tbShopStorageRecordRepository.findById(resources.getId()).orElseGet(TbShopStorageRecord::new);
|
||||
ValidationUtil.isNull( tbShopStorageRecord.getId(),"TbShopStorageRecord","id",resources.getId());
|
||||
tbShopStorageRecord.copy(resources);
|
||||
tbShopStorageRecordRepository.save(tbShopStorageRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopStorageRecordRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopStorageRecordDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopStorageRecordDto tbShopStorageRecord : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("存酒信息id", tbShopStorageRecord.getStorageId());
|
||||
map.put("记录", tbShopStorageRecord.getContent());
|
||||
map.put("操作时间", tbShopStorageRecord.getTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopStorageMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorage;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import cn.ysk.cashier.repository.shop.TbShopStorageRepository;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageRecordService;
|
||||
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopStorageServiceImpl implements TbShopStorageService {
|
||||
|
||||
private final TbShopStorageRepository tbShopStorageRepository;
|
||||
private final TbShopStorageMapper tbShopStorageMapper;
|
||||
private final TbShopStorageRecordService storageRecordService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopStorageQueryCriteria criteria, Pageable pageable) {
|
||||
Page<TbShopStorage> page = tbShopStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(tbShopStorageMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopStorageDto> queryAll(TbShopStorageQueryCriteria criteria) {
|
||||
return tbShopStorageMapper.toDto(tbShopStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopStorageDto findById(Integer id) {
|
||||
TbShopStorage tbShopStorage = tbShopStorageRepository.findById(id).orElseGet(TbShopStorage::new);
|
||||
ValidationUtil.isNull(tbShopStorage.getId(), "TbShopStorage", "id", id);
|
||||
return tbShopStorageMapper.toDto(tbShopStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopStorageDto create(TbShopStorage resources) {
|
||||
resources.setSavTime(new Timestamp(System.currentTimeMillis()));
|
||||
resources.setExpTime(new Timestamp(System.currentTimeMillis() + 86400000 * resources.getExpDay()));
|
||||
return tbShopStorageMapper.toDto(tbShopStorageRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateNum(TbShopStorageNumDto resources) {
|
||||
TbShopStorage tbShopStorage = tbShopStorageRepository.findById(resources.getId()).orElseGet(TbShopStorage::new);
|
||||
ValidationUtil.isNull(tbShopStorage.getId(), "TbShopStorage", "id", resources.getId());
|
||||
if (resources.getType() == 1) {
|
||||
tbShopStorage.setNum(tbShopStorage.getNum() + resources.getNum());
|
||||
if (tbShopStorage.getStatus() == 0) {
|
||||
tbShopStorage.setStatus(1);
|
||||
}
|
||||
} else if (resources.getType() == 0) {
|
||||
int sum = tbShopStorage.getNum() - resources.getNum();
|
||||
if (sum < 0) {
|
||||
throw new BadRequestException("取酒失败,该酒余量不足");
|
||||
}
|
||||
if (sum == 0) {
|
||||
tbShopStorage.setStatus(0);
|
||||
}
|
||||
tbShopStorage.setNum(sum);
|
||||
} else {
|
||||
throw new BadRequestException("存取酒失败");
|
||||
}
|
||||
tbShopStorageRepository.save(tbShopStorage);
|
||||
TbShopStorageRecord record = new TbShopStorageRecord();
|
||||
record.setStorageId(resources.getId());
|
||||
record.setTime(new Timestamp(System.currentTimeMillis()));
|
||||
record.setContent((resources.getType() == 1 ? "存入" : "取出") + resources.getNum() + tbShopStorage.getUnit() + tbShopStorage.getName());
|
||||
storageRecordService.create(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopStorage resources) {
|
||||
TbShopStorage tbShopStorage = tbShopStorageRepository.findById(resources.getId()).orElseGet(TbShopStorage::new);
|
||||
ValidationUtil.isNull(tbShopStorage.getId(), "TbShopStorage", "id", resources.getId());
|
||||
tbShopStorage.copy(resources);
|
||||
tbShopStorageRepository.save(tbShopStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopStorageRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopStorageDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopStorageDto tbShopStorage : all) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("酒品名", tbShopStorage.getName());
|
||||
map.put("酒品图", tbShopStorage.getImgUrl());
|
||||
map.put("单位", tbShopStorage.getUnit());
|
||||
map.put("数量", tbShopStorage.getNum());
|
||||
map.put("0:已取完;1:未取完", tbShopStorage.getStatus());
|
||||
map.put("到期时间", tbShopStorage.getExpTime());
|
||||
map.put("存酒时间", tbShopStorage.getSavTime());
|
||||
map.put("用户Id", tbShopStorage.getUserid());
|
||||
map.put("用户昵称", tbShopStorage.getNickname());
|
||||
map.put("用户电话", tbShopStorage.getTelphone());
|
||||
map.put("店铺id", tbShopStorage.getShopId());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package cn.ysk.cashier.service.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageGoodQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageGood;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageGoodService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopStorageGoodQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopStorageGoodDto>
|
||||
*/
|
||||
List<TbShopStorageGoodDto> queryAll(TbShopStorageGoodQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopStorageGoodDto
|
||||
*/
|
||||
TbShopStorageGoodDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopStorageGoodDto
|
||||
*/
|
||||
TbShopStorageGoodDto create(TbShopStorageGood resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopStorageGood resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopStorageGoodDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package cn.ysk.cashier.service.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageRecordQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorageRecord;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageRecordService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopStorageRecordQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopStorageRecordDto>
|
||||
*/
|
||||
List<TbShopStorageRecordDto> queryAll(TbShopStorageRecordQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopStorageRecordDto
|
||||
*/
|
||||
TbShopStorageRecordDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopStorageRecordDto
|
||||
*/
|
||||
TbShopStorageRecordDto create(TbShopStorageRecord resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopStorageRecord resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopStorageRecordDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package cn.ysk.cashier.service.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageNumDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopStorageQueryCriteria;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopStorage;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @date 2024-05-21
|
||||
**/
|
||||
public interface TbShopStorageService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopStorageQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopStorageDto>
|
||||
*/
|
||||
List<TbShopStorageDto> queryAll(TbShopStorageQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopStorageDto
|
||||
*/
|
||||
TbShopStorageDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopStorageDto
|
||||
*/
|
||||
TbShopStorageDto create(TbShopStorage resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopStorage resources);
|
||||
|
||||
void updateNum(TbShopStorageNumDto resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopStorageDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.ysk.cashier.thirdpay.constants;
|
||||
|
||||
public enum SignTypeEnum {
|
||||
|
||||
MD5("MD5"),RSA2("RSA2");
|
||||
|
||||
private final String value;
|
||||
|
||||
SignTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package cn.ysk.cashier.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
public class OrderRefundReq implements Serializable {
|
||||
|
||||
private String mchRefundNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String refundReason;
|
||||
|
||||
private Long refundAmount;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String extParam;
|
||||
|
||||
public OrderRefundReq(String mchRefundNo, String payOrderId, String mchOrderNo, String refundReason, Long refundAmount, String notifyUrl, String extParam) {
|
||||
this.mchRefundNo = mchRefundNo;
|
||||
this.payOrderId = payOrderId;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.refundReason = refundReason;
|
||||
this.refundAmount = refundAmount;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.extParam = extParam;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.ysk.cashier.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OrderReturnQueryReq implements Serializable {
|
||||
|
||||
private String mchRefundNo;
|
||||
|
||||
private String refundOrderId;
|
||||
|
||||
public OrderReturnQueryReq(String mchRefundNo, String refundOrderId) {
|
||||
this.mchRefundNo = mchRefundNo;
|
||||
this.refundOrderId = refundOrderId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.ysk.cashier.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OrderStatusQueryReq implements Serializable {
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
public OrderStatusQueryReq(String payOrderId, String mchOrderNo) {
|
||||
this.payOrderId = payOrderId;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package cn.ysk.cashier.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PublicParam implements Serializable {
|
||||
|
||||
private String appId;
|
||||
|
||||
private String sign;
|
||||
|
||||
private String signType;
|
||||
|
||||
private String bizData;
|
||||
|
||||
private String reqTime;
|
||||
|
||||
private String version;
|
||||
|
||||
private String reqId;
|
||||
|
||||
public PublicParam(String appId, String sign, String signType, String bizData, String reqTime, String version, String reqId) {
|
||||
this.appId = appId;
|
||||
this.sign = sign;
|
||||
this.signType = signType;
|
||||
this.bizData = bizData;
|
||||
this.reqTime = reqTime;
|
||||
this.version = version;
|
||||
this.reqId = reqId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package cn.ysk.cashier.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OderReturnQueyResp implements Serializable {
|
||||
|
||||
|
||||
private String mchRefundNo;
|
||||
|
||||
private String refundOrderId;
|
||||
|
||||
private String state;
|
||||
|
||||
private String oriPayOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private Long oriAmount;
|
||||
|
||||
private Long refundAmt;
|
||||
|
||||
private String refundReason;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String note;
|
||||
|
||||
private String refundTime;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payType;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package cn.ysk.cashier.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OrderReturnResp implements Serializable {
|
||||
|
||||
private String mchRefundNo;
|
||||
|
||||
private String refundOrderId;
|
||||
|
||||
private String state;
|
||||
|
||||
private String oriPayOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private Long oriAmount;
|
||||
|
||||
private Long refundAmt;
|
||||
|
||||
private String refundReason;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String refundTime;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payType;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package cn.ysk.cashier.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OrderStatusQueryResp implements Serializable {
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payTime;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.ysk.cashier.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
public class PublicResp <T> implements Serializable {
|
||||
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String sign;
|
||||
|
||||
private String bizData;
|
||||
|
||||
private T objData;
|
||||
|
||||
private String signType;
|
||||
|
||||
private String timestamp;
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package cn.ysk.cashier.thirdpay.service;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
|
||||
import cn.ysk.cashier.thirdpay.constants.SignTypeEnum;
|
||||
import cn.ysk.cashier.thirdpay.req.OrderRefundReq;
|
||||
import cn.ysk.cashier.thirdpay.req.OrderReturnQueryReq;
|
||||
import cn.ysk.cashier.thirdpay.req.OrderStatusQueryReq;
|
||||
import cn.ysk.cashier.thirdpay.req.PublicParam;
|
||||
import cn.ysk.cashier.thirdpay.resp.OrderReturnResp;
|
||||
import cn.ysk.cashier.thirdpay.resp.OrderStatusQueryResp;
|
||||
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
||||
import cn.ysk.cashier.utils.JSONUtil;
|
||||
import cn.ysk.cashier.utils.MD5Utils;
|
||||
import com.dianguang.cloud.ossservice.model.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ThirdPayService {
|
||||
|
||||
|
||||
private static String trade="/api/open/query/trade";
|
||||
|
||||
/**
|
||||
* 查询订单状态
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param payOrderId
|
||||
* @param mchOrderNo
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<OrderStatusQueryResp> queryOrder(String url, String appId, String payOrderId, String mchOrderNo, String key){
|
||||
OrderStatusQueryReq req=new OrderStatusQueryReq(payOrderId,mchOrderNo);
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str = JSONUtil.toJSONString(sortFields(req));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Utils.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(trade)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<OrderStatusQueryResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),OrderStatusQueryResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退款
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param mchRefundNo
|
||||
* @param payOrderId
|
||||
* @param mchOrderNo
|
||||
* @param refundReason
|
||||
* @param refundAmount
|
||||
* @param notifyUrl
|
||||
* @param extParam
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<OrderReturnResp> returnOrder(String url, String appId, String mchRefundNo, String payOrderId, String mchOrderNo, String refundReason, Long refundAmount, String notifyUrl, String extParam, String key){
|
||||
OrderRefundReq req=new OrderRefundReq(mchRefundNo, payOrderId, mchOrderNo, refundReason, refundAmount, notifyUrl, extParam);
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str = JSONUtil.toJSONString(sortFields(req));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Utils.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(trade)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<OrderReturnResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),OrderReturnResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询退款订单
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param mchRefundNo
|
||||
* @param refundOrderId
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<OrderReturnQueryReq> returnOrderQuery(String url, String appId, String mchRefundNo, String refundOrderId, String key){
|
||||
OrderReturnQueryReq req=new OrderReturnQueryReq(mchRefundNo,refundOrderId);
|
||||
PublicParam param=new PublicParam(appId,null, SignTypeEnum.MD5.getValue(), null, DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str = JSONUtil.toJSONString(sortFields(req));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Utils.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(trade)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<OrderReturnQueryReq> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),OrderReturnQueryReq.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static String sortFieldsAndPrint(Object obj) throws IllegalAccessException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Class<?> clazz = obj.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
// 按字段名称排序
|
||||
Arrays.sort(fields, Comparator.comparing(Field::getName));
|
||||
|
||||
for (Field field : fields) {
|
||||
// 可能需要设置访问权限
|
||||
field.setAccessible(true);
|
||||
if ("sign".equals(field.getName())) {
|
||||
continue;
|
||||
}
|
||||
Object value = field.get(obj);
|
||||
|
||||
|
||||
StringBuffer param = new StringBuffer();
|
||||
param.append(field.getName());
|
||||
param.append("=");
|
||||
if (value instanceof String) {
|
||||
param.append(value);
|
||||
|
||||
} else if (value instanceof Integer) {
|
||||
param.append(value);
|
||||
} else if (value instanceof Long) {
|
||||
param.append(value);
|
||||
}
|
||||
|
||||
param.append("&");
|
||||
sb.append(param);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public static LinkedHashMap<String, Object> sortFields(Object obj) throws IllegalAccessException {
|
||||
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
Class<?> clazz = obj.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
// 按字段名称排序
|
||||
Arrays.sort(fields, Comparator.comparing(Field::getName));
|
||||
|
||||
for (Field field : fields) {
|
||||
// 可能需要设置访问权限
|
||||
field.setAccessible(true);
|
||||
Object value = field.get(obj);
|
||||
if(value==null){
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put(field.getName(), value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "131112206836873461", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI");
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +72,11 @@ rsa:
|
|||
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
|
||||
|
||||
qrcode: https://kysh.sxczgkj.cn/codeplate?code=
|
||||
|
||||
thirdPay:
|
||||
groupCallBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||
url: https://paymentapi.sxczgkj.cn
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/cn/ysk/cashier/mybatis/mapper/*Mapper.xml
|
||||
type-aliases-package: me.zhengjie.mybatis.entity
|
||||
|
|
|
|||
Loading…
Reference in New Issue