diff --git a/pom.xml b/pom.xml
index cd63f0c..680dc4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,6 @@
com.chaozhangui.system.cashservice
cashier-client
1.0.0
- jar
8
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
index 333777c..7b4e83f 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
+import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.service.PayService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
@@ -105,7 +106,6 @@ public class PayController {
* @param token
* @param loginName
* @param clientType
- * @param id
* @return
*/
@GetMapping("queryQuickPayStatus")
@@ -217,4 +217,9 @@ public class PayController {
@RequestParam("orderId") String orderId){
return payService.queryOrder(orderId,token);
}
+
+ @RequestMapping("returnGpOrder")
+ public Result returnOrder(@RequestBody ReturnGroupOrderDto param){
+ return payService.returnGroupOrder(param);
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbGroupOrderInfoController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbGroupOrderInfoController.java
new file mode 100644
index 0000000..5d09294
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbGroupOrderInfoController.java
@@ -0,0 +1,67 @@
+package com.chaozhanggui.system.cashierservice.controller;
+
+import com.chaozhanggui.system.cashierservice.entity.dto.GroupOrderDto;
+import com.chaozhanggui.system.cashierservice.service.TbGroupOrderInfoService;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * 团购卷订单(TbGroupOrderInfo)表控制层
+ *
+ * @author ww
+ * @since 2024-05-20 10:04:50
+ */
+
+@Slf4j
+@RestController
+@CrossOrigin(origins = "*")
+@RequestMapping("groupOrder")
+public class TbGroupOrderInfoController {
+ /**
+ * 服务对象
+ */
+ @Resource
+ private TbGroupOrderInfoService tbGroupOrderInfoService;
+
+ /**
+ * 分页查询
+ * @return 查询结果
+ */
+ @RequestMapping("list")
+ public Result queryByPage(@RequestBody GroupOrderDto param) {
+ return tbGroupOrderInfoService.queryByPage(param);
+ }
+
+ @RequestMapping("details")
+ public Result queryById(Integer id) {
+ return tbGroupOrderInfoService.queryById(id);
+ }
+
+
+ /**
+ * 团购卷核销前回显
+ *
+ * @param coupon
+ * @return
+ */
+ @RequestMapping("orderInfo")
+ public Result groupOrderInfo(String coupon) {
+ return tbGroupOrderInfoService.groupOrderInfo(coupon);
+ }
+
+ /**
+ * 团购卷扫码核销
+ *
+ * @param loginName
+ * @param id
+ * @return
+ */
+ @RequestMapping("groupScan")
+ public Result groupScan(@RequestHeader("loginName") String loginName, Integer id) {
+ return tbGroupOrderInfoService.groupScan(loginName, id);
+ }
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderCouponMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderCouponMapper.java
new file mode 100644
index 0000000..33fdd0b
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderCouponMapper.java
@@ -0,0 +1,72 @@
+package com.chaozhanggui.system.cashierservice.dao;
+
+import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderCoupon;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 团购卷 卷码表(TbGroupOrderCoupon)表数据库访问层
+ *
+ * @author ww
+ * @since 2024-05-20 10:42:18
+ */
+public interface TbGroupOrderCouponMapper {
+
+ /**
+ * 通过ID查询单条数据
+ *
+ * @param id 主键
+ * @return 实例对象
+ */
+ TbGroupOrderCoupon queryById(Integer id);
+
+ TbGroupOrderCoupon queryByCoupon(String coupon);
+
+ List queryNoRefundByOrderId(Integer orderId);
+
+ /**
+ * 查询数据
+ *
+ * @param tbGroupOrderCoupon 查询条件
+ * @param pageable 分页对象
+ * @return 对象列表
+ */
+ List queryAll(TbGroupOrderCoupon tbGroupOrderCoupon, @Param("pageable") Pageable pageable);
+
+
+ /**
+ * 新增数据
+ *
+ * @param tbGroupOrderCoupon 实例对象
+ * @return 影响行数
+ */
+ int insert(TbGroupOrderCoupon tbGroupOrderCoupon);
+
+ /**
+ * 批量新增数据(MyBatis原生foreach方法)
+ *
+ * @param entities List 实例对象列表
+ * @return 影响行数
+ */
+ int insertBatch(@Param("entities") List entities);
+
+ /**
+ * 修改数据
+ *
+ * @param tbGroupOrderCoupon 实例对象
+ * @return 影响行数
+ */
+ int update(TbGroupOrderCoupon tbGroupOrderCoupon);
+
+ /**
+ * 通过主键删除数据
+ *
+ * @param id 主键
+ * @return 影响行数
+ */
+ int deleteById(Integer id);
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderInfoMapper.java
new file mode 100644
index 0000000..bb8e4cb
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbGroupOrderInfoMapper.java
@@ -0,0 +1,69 @@
+package com.chaozhanggui.system.cashierservice.dao;
+
+import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderInfo;
+import com.chaozhanggui.system.cashierservice.entity.dto.GroupOrderDto;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 团购卷订单(TbGroupOrderInfo)表数据库访问层
+ *
+ * @author ww
+ * @since 2024-05-20 10:04:50
+ */
+public interface TbGroupOrderInfoMapper {
+
+ /**
+ * 通过ID查询单条数据
+ *
+ * @param id 主键
+ * @return 实例对象
+ */
+ TbGroupOrderInfo queryById(Integer id);
+
+ /**
+ * 查询数据
+ *
+ * @param tbGroupOrderInfo 查询条件
+ * @return 对象列表
+ */
+ List queryAll(TbGroupOrderInfo tbGroupOrderInfo);
+
+ List queryList(GroupOrderDto tbGroupOrderInfo);
+
+
+ /**
+ * 新增数据
+ *
+ * @param tbGroupOrderInfo 实例对象
+ * @return 影响行数
+ */
+ int insert(TbGroupOrderInfo tbGroupOrderInfo);
+
+ /**
+ * 批量新增数据(MyBatis原生foreach方法)
+ *
+ * @param entities List 实例对象列表
+ * @return 影响行数
+ */
+ int insertBatch(@Param("entities") List entities);
+
+ /**
+ * 修改数据
+ *
+ * @param tbGroupOrderInfo 实例对象
+ * @return 影响行数
+ */
+ int update(TbGroupOrderInfo tbGroupOrderInfo);
+
+ /**
+ * 通过主键删除数据
+ *
+ * @param id 主键
+ * @return 影响行数
+ */
+ int deleteById(Integer id);
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
index ffafd53..12e0100 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
@@ -58,6 +58,7 @@ public class TbCashierCart implements Serializable {
private Integer userId;
private String tableId;
private TbProductSpec tbProductSpec;
+ private String selectSpec="";
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderCoupon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderCoupon.java
new file mode 100644
index 0000000..26793e8
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderCoupon.java
@@ -0,0 +1,49 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 团购卷 卷码表(TbGroupOrderCoupon)实体类
+ *
+ * @author ww
+ * @since 2024-05-20 10:42:18
+ */
+@Data
+public class TbGroupOrderCoupon implements Serializable {
+ private static final long serialVersionUID = -79087167053650793L;
+
+ private Integer id;
+ /**
+ * 团购订单id
+ */
+ private Integer orderId;
+ /**
+ * 团购卷码
+ */
+ private String couponNo;
+ /**
+ * 是否已退款
+ * 0:否
+ * 1:是
+ */
+ private Integer isRefund;
+ /**
+ * 退款金额
+ */
+ private BigDecimal refundAmount;
+ /**
+ * 退款原因
+ */
+ private String refundReason;
+ /**
+ * 退款说明
+ */
+ private String refundDesc;
+
+
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderInfo.java
new file mode 100644
index 0000000..84adabd
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbGroupOrderInfo.java
@@ -0,0 +1,132 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.io.Serializable;
+
+/**
+ * 团购卷订单(TbGroupOrderInfo)实体类
+ *
+ * @author ww
+ * @since 2024-05-20 10:04:50
+ */
+@Data
+public class TbGroupOrderInfo implements Serializable {
+ private static final long serialVersionUID = -54354891204103762L;
+ /**
+ * 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 Date 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 Date payTime;
+ /**
+ * 是否支持退款 0:不支持 1:支持
+ */
+ private Integer refundAble;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+ /**
+ * 卷码核销员
+ */
+ private String verifier;
+ /**
+ * 更新时间
+ */
+ private Date updateTime;
+ /**
+ * 支付订单号
+ */
+ private String payOrderNo;
+ /**
+ * 交易日期
+ */
+ private Date tradeDay;
+ /**
+ * 原订单id 退单
+ */
+ private Integer source;
+
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussShopStaff.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussShopStaff.java
index c79e4a1..a9a829d 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussShopStaff.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlussShopStaff.java
@@ -27,6 +27,8 @@ public class TbPlussShopStaff implements Serializable {
private Long updatedAt;
private String type;
+ private Integer isManage;
+ private Integer isPc;
private static final long serialVersionUID = 1L;
@@ -122,6 +124,22 @@ public class TbPlussShopStaff implements Serializable {
return type;
}
+ public Integer getIsManage() {
+ return isManage;
+ }
+
+ public void setIsManage(Integer isManage) {
+ this.isManage = isManage;
+ }
+
+ public Integer getIsPc() {
+ return isPc;
+ }
+
+ public void setIsPc(Integer isPc) {
+ this.isPc = isPc;
+ }
+
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BasePageDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BasePageDto.java
new file mode 100644
index 0000000..434abd8
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/BasePageDto.java
@@ -0,0 +1,12 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class BasePageDto {
+ private Integer page = 1;
+
+ private Integer size = 10;
+
+ private String shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/GroupOrderDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/GroupOrderDto.java
new file mode 100644
index 0000000..8a7caf0
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/GroupOrderDto.java
@@ -0,0 +1,12 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class GroupOrderDto extends BasePageDto{
+ private String orderNo;
+
+ private String proName;
+
+ private String status;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnGroupOrderDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnGroupOrderDto.java
new file mode 100644
index 0000000..2fa813e
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnGroupOrderDto.java
@@ -0,0 +1,29 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+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;
+}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderInfoVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderInfoVo.java
new file mode 100644
index 0000000..8aa3c9f
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/GroupOrderInfoVo.java
@@ -0,0 +1,39 @@
+package com.chaozhanggui.system.cashierservice.entity.vo;
+
+import com.alibaba.fastjson.JSONArray;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author lyf
+ */
+@Data
+public class GroupOrderInfoVo {
+ private Integer id;
+ /**
+ * 商品图片
+ */
+ private JSONArray images;
+
+ /**
+ * 现价
+ */
+ private BigDecimal salePrice;
+ /**
+ * 原价
+ */
+ private BigDecimal originPrice;
+
+ /**
+ * 商品名称
+ */
+ private String productName;
+
+ /**
+ * 套餐详情
+ */
+ List productList = new ArrayList<>();
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java
new file mode 100644
index 0000000..6c9ad41
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java
@@ -0,0 +1,31 @@
+package com.chaozhanggui.system.cashierservice.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ProductVo {
+ //选几个
+ private Integer number;
+
+ //类别
+ private String title;
+
+ //食物
+ private List goods=new ArrayList<>(); // 食品列表
+
+ @Data
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Food {
+ private Integer id;
+ private String name; // 商品名称
+ private BigDecimal lowPrice; // 售价
+ private String groupNum; // 数量
+ private String unitName; // 单位
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java
index 6093540..8266487 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java
@@ -76,7 +76,7 @@ public class LoginService {
return Result.fail(CodeEnum.PASSWORD);
}
- String key=RedisCst.ONLINE_USER.concat(":").concat(loginReq.getClientType()).concat(":").concat(loginReq.getLoginName());
+ String key = RedisCst.ONLINE_USER.concat(":").concat(loginReq.getClientType()).concat(":").concat(loginReq.getLoginName());
//
// String data = redisUtil.getMessage(key);
// if(ObjectUtil.isNotEmpty(data)){
@@ -91,6 +91,11 @@ public class LoginService {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffMapper.selectByAccount(loginReq.getLoginName());
if (ObjectUtil.isEmpty(tbPlussShopStaff)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
+ } else if (tbPlussShopStaff.getType().equals("staff")) {
+ Integer isPc = tbPlussShopStaff.getIsPc();
+ if (isPc != null && isPc != 1) {
+ return Result.fail(CodeEnum.UNAUTHORIZED);
+ }
}
@@ -99,15 +104,13 @@ public class LoginService {
}
-
-
//生成token 信息
String token = TokenUtil.generateToken(account.getId().toString(), loginReq.getLoginName(), loginReq.getClientType()
, account.getShopId(), tbPlussShopStaff.getId().toString(), tbPlussShopStaff.getCode());
//存储登录记录
- TbToken tbToken = new TbToken(account.getId(), tbPlussShopStaff.getId(),loginReq.getClientType(), token, ip, "1", new Date());
+ TbToken tbToken = new TbToken(account.getId(), tbPlussShopStaff.getId(), loginReq.getClientType(), token, ip, "1", new Date());
tbTokenMapper.insert(tbToken);
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
@@ -126,7 +129,7 @@ public class LoginService {
accountMap.put("userCode", tbPlussShopStaff.getCode());
accountMap.put("token", token);
accountMap.put("loginTime", System.currentTimeMillis());
- if (Objects.nonNull(shopInfo)){
+ if (Objects.nonNull(shopInfo)) {
accountMap.put("shopName", shopInfo.getShopName());
}
accountMap.put("uuid", uuid);
@@ -166,10 +169,10 @@ public class LoginService {
tbToken.setUpdateTime(new Date());
tbTokenMapper.updateByPrimaryKey(tbToken);
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type","close");
- jsonObject.put("token",token);
- rabbitProducer.putOrderCollect(jsonObject.toJSONString());
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("type", "close");
+ jsonObject.put("token", token);
+ rabbitProducer.putOrderCollect(jsonObject.toJSONString());
return Result.success(SUCCESS);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
index be2fc48..3830d29 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
@@ -227,10 +227,13 @@ public class OrderService {
if (Objects.nonNull(skuWithBLOBs)) {
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
}
- TbProduct tbProduct = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
+ TbProductWithBLOBs tbProduct = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
+ cashierCart.setSelectSpec(tbProduct.getSelectSpec());
if (Objects.nonNull(tbProduct)) {
- TbProductSpec tbProductSpec = tbProductSpecMapper.selectByPrimaryKey(tbProduct.getSpecId());
- cashierCart.setTbProductSpec(tbProductSpec);
+ if(tbProduct.getSpecId()!=null){
+ TbProductSpec tbProductSpec = tbProductSpecMapper.selectByPrimaryKey(tbProduct.getSpecId());
+ cashierCart.setTbProductSpec(tbProductSpec);
+ }
}
// TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPr imaryKey(Integer.valueOf(cashierCart.getProductId()));
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
index 329cdd5..07e745e 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
@@ -5,6 +5,7 @@ import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
+import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.po.OrderDetailPo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
@@ -13,10 +14,7 @@ import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
-import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
-import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderReturnResp;
-import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
-import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
+import com.chaozhanggui.system.cashierservice.thirdpay.resp.*;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.chaozhanggui.system.cashierservice.util.*;
import com.github.pagehelper.PageHelper;
@@ -29,6 +27,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
+import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@@ -71,6 +70,10 @@ public class PayService {
@Autowired
RabbitProducer producer;
+ @Resource
+ private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
+ @Resource
+ private TbGroupOrderCouponMapper couponMapper;
@Autowired
@@ -91,6 +94,8 @@ public class PayService {
private String url;
@Value("${thirdPay.callBack}")
private String callBack;
+ @Value("${thirdPay.groupCallBack}")
+ private String groupCallBack;
public static void main(String[] args) {
@@ -1025,4 +1030,59 @@ public class PayService {
int randomNum = random.nextInt(900) + 100;
return "RO" + date + randomNum;
}
+
+ @Transactional(rollbackFor = Exception.class)
+ public Result returnGroupOrder(ReturnGroupOrderDto param) {
+ TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
+ List tbGroupOrderCoupons = couponMapper.queryNoRefundByOrderId(param.getOrderId());
+ if (param.getNum() > tbGroupOrderCoupons.size()) {
+ return Result.fail("可退数量不足");
+ }
+ 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());
+ couponMapper.update(coupon);
+ }
+ TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(groupOrderInfo.getMerchantId());
+ MsgException.checkNull(thirdApply, "支付参数配置错误");
+
+ TbOrderPayment payment= tbOrderPaymentMapper.selectByOrderId(param.getOrderId()+"");
+ PublicResp 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)) {
+ GroupOrderReturnResp returnInfo = com.chaozhanggui.system.cashierservice.util.JSONUtil.parseJSONStr2T(publicResp.getBizData(), GroupOrderReturnResp.class);
+ if ("000000".equals(publicResp.getCode())) {
+ //TRADE_REFUND
+ if (!"SUCCESS".equals(returnInfo.getState()) && !"TRADE_SUCCESS".equals(returnInfo.getState()) && !returnInfo.getState().equals("ING")) {
+ return Result.fail("退款渠道调用失败,"+returnInfo.getNote());
+ }
+ } else {
+ return Result.fail("退款渠道调用失败:" + publicResp.getMsg());
+ }
+ }
+ groupOrderInfo.setRefundNumber(groupOrderInfo.getRefundNumber() + param.getNum());
+ 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");
+ }
+ tbGroupOrderInfoMapper.update(groupOrderInfo);
+ return Result.success(CodeEnum.SUCCESS);
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java
new file mode 100644
index 0000000..2c06098
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java
@@ -0,0 +1,131 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.chaozhanggui.system.cashierservice.dao.TbGroupOrderCouponMapper;
+import com.chaozhanggui.system.cashierservice.dao.TbGroupOrderInfoMapper;
+import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
+import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
+import com.chaozhanggui.system.cashierservice.entity.*;
+import com.chaozhanggui.system.cashierservice.entity.dto.GroupOrderDto;
+import com.chaozhanggui.system.cashierservice.entity.vo.GroupOrderInfoVo;
+import com.chaozhanggui.system.cashierservice.entity.vo.ProductVo;
+import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import com.chaozhanggui.system.cashierservice.util.JSONUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 团购卷订单(TbGroupOrderInfo)表服务接口
+ *
+ * @author ww
+ * @since 2024-05-20 10:04:50
+ */
+@Service
+@Slf4j
+public class TbGroupOrderInfoService {
+ @Resource
+ private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
+ @Resource
+ private TbGroupOrderCouponMapper couponMapper;
+ @Resource
+ private TbProductMapper productMapper;
+ @Resource
+ private TbProductSkuMapper skuMapper;
+
+ /**
+ * 通过ID查询单条数据
+ *
+ * @param id 主键
+ * @return 实例对象
+ */
+ public Result queryById(Integer id) {
+ TbGroupOrderInfo tbGroupOrderInfo = tbGroupOrderInfoMapper.queryById(id);
+ TbProductWithBLOBs tbProduct = productMapper.selectByPrimaryKey(tbGroupOrderInfo.getProId());
+ TbProductSkuWithBLOBs tbProductSku = skuMapper.selectByProduct(tbGroupOrderInfo.getProId());
+
+ GroupOrderInfoVo productInfo = new GroupOrderInfoVo();
+ productInfo.setId(id);
+ // 图片组装
+ if (StringUtils.isNotBlank(tbProduct.getImages())) {
+ productInfo.setImages(JSON.parseArray(tbProduct.getImages()));
+ } else {
+ productInfo.setImages(new JSONArray());
+ }
+
+ //售价
+ if (tbProductSku.getSalePrice().compareTo(BigDecimal.ZERO) == 0) {
+ if (tbProductSku.getOriginPrice().compareTo(BigDecimal.ZERO) == 0) {
+ productInfo.setOriginPrice(BigDecimal.ZERO);
+ productInfo.setSalePrice(BigDecimal.ZERO);
+ } else {
+ productInfo.setOriginPrice(tbProductSku.getOriginPrice());
+ productInfo.setSalePrice(tbProductSku.getOriginPrice());
+ }
+ } else {
+ productInfo.setOriginPrice(tbProductSku.getOriginPrice());
+ //现价
+ productInfo.setSalePrice(tbProductSku.getSalePrice());
+ }
+
+ //名称
+ productInfo.setProductName(tbProduct.getName());
+
+ List productVos = JSONUtil.parseListTNewList(tbProduct.getGroupSnap(), ProductVo.class);
+ productInfo.setProductList(productVos);
+
+ return Result.success(CodeEnum.SUCCESS, productInfo);
+ }
+
+ public Result groupOrderInfo(String coupon) {
+ TbGroupOrderCoupon tbGroupOrderCoupon = couponMapper.queryByCoupon(coupon);
+ if (tbGroupOrderCoupon == null) {
+ return Result.fail("该卷码不可用。");
+ }
+ return queryById(tbGroupOrderCoupon.getOrderId());
+ }
+
+ public Result groupScan(String loginName, Integer orderId) {
+ TbGroupOrderInfo groupOrder = tbGroupOrderInfoMapper.queryById(orderId);
+ String status = groupOrder.getStatus();
+ if(!status.equals("unused")){
+ return Result.fail("卷码核销失败,订单状态异常");
+ }
+ groupOrder.setId(orderId);
+ groupOrder.setVerifier(loginName);
+ groupOrder.setStatus("closed");
+ groupOrder.setUpdateTime(new Date());
+ tbGroupOrderInfoMapper.update(groupOrder);
+ return Result.success(CodeEnum.SUCCESS, groupOrder);
+ }
+
+ public Result queryByPage(GroupOrderDto param) {
+ PageHelper.startPage(param.getPage(), param.getSize());
+ return Result.success(CodeEnum.SUCCESS, new PageInfo(tbGroupOrderInfoMapper.queryList(param)));
+ }
+
+
+ /**
+ * 修改数据
+ *
+ * @param tbGroupOrderInfo 实例对象
+ * @return 实例对象
+ */
+ public Result update(TbGroupOrderInfo tbGroupOrderInfo) {
+ tbGroupOrderInfo.setUpdateTime(new Date());
+ tbGroupOrderInfoMapper.update(tbGroupOrderInfo);
+ return Result.success(CodeEnum.SUCCESS);
+ }
+
+
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java
index 8f56714..2069d21 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java
@@ -63,6 +63,8 @@ public enum CodeEnum {
CARTEXIST("100020",false,"购物车信息不存在","fail"),
+ UNAUTHORIZED("100021",false,"该账号无权限登录,请联系管理员","fail"),
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/resp/GroupOrderReturnResp.java b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/resp/GroupOrderReturnResp.java
new file mode 100644
index 0000000..3a89265
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/resp/GroupOrderReturnResp.java
@@ -0,0 +1,22 @@
+package com.chaozhanggui.system.cashierservice.thirdpay.resp;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class GroupOrderReturnResp implements Serializable {
+
+ private String ifCode;
+ private String mchRefundNo;
+ private String mercNo;
+ private String note;
+ private Integer oriAmount;
+ private String oriPayOrderId;
+ private String payType;
+ private Integer refundAmt;
+ private String refundOrderId;
+ private String refundReason;
+ private Integer refundType;
+ private String state;
+}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java
index 9dad0b8..b5ffe0b 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/JSONUtil.java
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
@@ -199,6 +200,17 @@ public class JSONUtil {
}
}
+ public static List parseListTNewList(String json, Class clazz) {
+ ObjectMapper objectMapper = new ObjectMapper(); // 创建JSON转换器
+ try {
+ // 将JSON字符串转换为List
+ return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
public static class JSONEntity {
public JSONEntity() {
}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index d5cbf79..f018c70 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -47,7 +47,8 @@ pagehelper:
reasonable: true
helperDialect: mysql
params: count=countSql
-
+thirdPay:
+ groupCallBack: https:///cashierService/notify/notifyCallBackGroup
mybatis:
configuration:
map-underscore-to-camel-case: true
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 8654eb7..bea544d 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -49,6 +49,9 @@ pagehelper:
helperDialect: mysql
params: count=countSql
+thirdPay:
+ groupCallBack: https://cashierclient.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
+
mybatis:
configuration:
map-underscore-to-camel-case: true
diff --git a/src/main/resources/mapper/TbGroupOrderCouponMapper.xml b/src/main/resources/mapper/TbGroupOrderCouponMapper.xml
new file mode 100644
index 0000000..012d653
--- /dev/null
+++ b/src/main/resources/mapper/TbGroupOrderCouponMapper.xml
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id
+ , order_id, coupon_no, is_refund, refund_amount, refund_reason, refund_desc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ insert into tb_group_order_coupon(order_id, coupon_no, is_refund, refund_amount, refund_reason, refund_desc)
+ values (#{orderId}, #{couponNo}, #{isRefund}, #{refundAmount}, #{refundReason}, #{refundDesc})
+
+
+
+ insert into tb_group_order_coupon(order_id, coupon_no, is_refund, refund_amount, refund_reason, refund_desc)
+ values
+
+ (#{entity.orderId}, #{entity.couponNo}, #{entity.isRefund}, #{entity.refundAmount}, #{entity.refundReason},
+ #{entity.refundDesc})
+
+
+
+
+
+ update tb_group_order_coupon
+
+
+ order_id = #{orderId},
+
+
+ coupon_no = #{couponNo},
+
+
+ is_refund = #{isRefund},
+
+
+ refund_amount = #{refundAmount},
+
+
+ refund_reason = #{refundReason},
+
+
+ refund_desc = #{refundDesc},
+
+
+ where id = #{id}
+
+
+
+
+ delete
+ from tb_group_order_coupon
+ where id = #{id}
+
+
+
+
diff --git a/src/main/resources/mapper/TbGroupOrderInfoMapper.xml b/src/main/resources/mapper/TbGroupOrderInfoMapper.xml
new file mode 100644
index 0000000..0d14511
--- /dev/null
+++ b/src/main/resources/mapper/TbGroupOrderInfoMapper.xml
@@ -0,0 +1,288 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id
+ , order_no, merchant_id, shop_id, user_id, pro_id, pro_img, pro_name, exp_date, order_type, pay_type, order_amount, save_amount, pay_amount, refund_amount, refund_number, number, status, remark, phone, pay_time, refund_able, create_time, verifier, update_time, pay_order_no, trade_day, source
+
+
+
+
+
+
+
+
+
+
+
+
+ insert into tb_group_order_info(order_no, merchant_id, shop_id, user_id, pro_id, pro_img, pro_name, exp_date,
+ order_type, pay_type, order_amount, save_amount, pay_amount, refund_amount,
+ refund_number, number, status, remark, phone, pay_time, refund_able,
+ create_time, verifier, update_time, pay_order_no, trade_day, source)
+ values (#{orderNo}, #{merchantId}, #{shopId}, #{userId}, #{proId}, #{proImg}, #{proName}, #{expDate},
+ #{orderType}, #{payType}, #{orderAmount}, #{saveAmount}, #{payAmount}, #{refundAmount}, #{refundNumber},
+ #{number}, #{status}, #{remark}, #{phone}, #{payTime}, #{refundAble}, #{createTime}, #{verifier},
+ #{updateTime}, #{payOrderNo}, #{tradeDay}, #{source})
+
+
+
+ insert into tb_group_order_info(order_no, merchant_id, shop_id, user_id, pro_id, pro_img, pro_name, exp_date,
+ order_type, pay_type, order_amount, save_amount, pay_amount, refund_amount, refund_number, number, status,
+ remark, phone, pay_time, refund_able, create_time, verifier, update_time, pay_order_no, trade_day, source)
+ values
+
+ (#{entity.orderNo}, #{entity.merchantId}, #{entity.shopId}, #{entity.userId}, #{entity.proId},
+ #{entity.proImg}, #{entity.proName}, #{entity.expDate}, #{entity.orderType}, #{entity.payType},
+ #{entity.orderAmount}, #{entity.saveAmount}, #{entity.payAmount}, #{entity.refundAmount},
+ #{entity.refundNumber}, #{entity.number}, #{entity.status}, #{entity.remark}, #{entity.phone},
+ #{entity.payTime}, #{entity.refundAble}, #{entity.createTime}, #{entity.verifier}, #{entity.updateTime},
+ #{entity.payOrderNo}, #{entity.tradeDay}, #{entity.source})
+
+
+
+
+
+ update tb_group_order_info
+
+
+ order_no = #{orderNo},
+
+
+ merchant_id = #{merchantId},
+
+
+ shop_id = #{shopId},
+
+
+ user_id = #{userId},
+
+
+ pro_id = #{proId},
+
+
+ pro_img = #{proImg},
+
+
+ pro_name = #{proName},
+
+
+ exp_date = #{expDate},
+
+
+ order_type = #{orderType},
+
+
+ pay_type = #{payType},
+
+
+ order_amount = #{orderAmount},
+
+
+ save_amount = #{saveAmount},
+
+
+ pay_amount = #{payAmount},
+
+
+ refund_amount = #{refundAmount},
+
+
+ refund_number = #{refundNumber},
+
+
+ number = #{number},
+
+
+ status = #{status},
+
+
+ remark = #{remark},
+
+
+ phone = #{phone},
+
+
+ pay_time = #{payTime},
+
+
+ refund_able = #{refundAble},
+
+
+ create_time = #{createTime},
+
+
+ verifier = #{verifier},
+
+
+ update_time = #{updateTime},
+
+
+ pay_order_no = #{payOrderNo},
+
+
+ trade_day = #{tradeDay},
+
+
+ source = #{source},
+
+
+ where id = #{id}
+
+
+
+
+ delete
+ from tb_group_order_info
+ where id = #{id}
+
+
+
+
diff --git a/src/main/resources/mapper/TbPlussShopStaffMapper.xml b/src/main/resources/mapper/TbPlussShopStaffMapper.xml
index d44eb2f..9bda03b 100644
--- a/src/main/resources/mapper/TbPlussShopStaffMapper.xml
+++ b/src/main/resources/mapper/TbPlussShopStaffMapper.xml
@@ -14,10 +14,13 @@
+
+
- id, code, name, account, password, max_discount_amount, status, employee, shop_id,
- created_at, updated_at, type
+ id
+ , code, name, account, password, max_discount_amount, status, employee, shop_id,
+ created_at, updated_at, type,is_manage,is_pc