购物车 多规格商品返回规格信息
团购卷列表 团购卷退款 员工登录管理
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TbGroupOrderCoupon> queryNoRefundByOrderId(Integer orderId);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param tbGroupOrderCoupon 查询条件
|
||||
* @param pageable 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<TbGroupOrderCoupon> queryAll(TbGroupOrderCoupon tbGroupOrderCoupon, @Param("pageable") Pageable pageable);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbGroupOrderCoupon 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TbGroupOrderCoupon tbGroupOrderCoupon);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbGroupOrderCoupon> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TbGroupOrderCoupon> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbGroupOrderCoupon 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TbGroupOrderCoupon tbGroupOrderCoupon);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<TbGroupOrderInfo> queryAll(TbGroupOrderInfo tbGroupOrderInfo);
|
||||
|
||||
List<TbGroupOrderInfo> queryList(GroupOrderDto tbGroupOrderInfo);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbGroupOrderInfo 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TbGroupOrderInfo tbGroupOrderInfo);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbGroupOrderInfo> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TbGroupOrderInfo> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbGroupOrderInfo 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TbGroupOrderInfo tbGroupOrderInfo);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<ProductVo> productList = new ArrayList<>();
|
||||
}
|
||||
@@ -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<Food> 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; // 单位
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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<TbGroupOrderCoupon> 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<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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ProductVo> 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -63,6 +63,8 @@ public enum CodeEnum {
|
||||
|
||||
CARTEXIST("100020",false,"购物车信息不存在","fail"),
|
||||
|
||||
UNAUTHORIZED("100021",false,"该账号无权限登录,请联系管理员","fail"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 <T> List<T> parseListTNewList(String json, Class<T> clazz) {
|
||||
ObjectMapper objectMapper = new ObjectMapper(); // 创建JSON转换器
|
||||
try {
|
||||
// 将JSON字符串转换为List<T>
|
||||
return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JSONEntity {
|
||||
public JSONEntity() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user