fix: 美团券核销实现
This commit is contained in:
@@ -20,6 +20,18 @@ public interface TableConstant {
|
||||
}
|
||||
}
|
||||
|
||||
class ThirdPartyCoupon {
|
||||
@Getter
|
||||
public enum Plat {
|
||||
MEI_TUAN("meituan");
|
||||
private final String value;
|
||||
|
||||
Plat(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CashierCart {
|
||||
public static final String ID = "-999";
|
||||
|
||||
@@ -70,6 +82,21 @@ public interface TableConstant {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum OrderType {
|
||||
COUPON("coupon");
|
||||
private final String value;
|
||||
|
||||
OrderType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum UseType {
|
||||
TAKEOUT("takeout"),
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.thirdcoupon.BaseQueryDTO;
|
||||
import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO;
|
||||
import cn.ysk.cashier.service.ThirdPartyCouponService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 三方团购券
|
||||
*/
|
||||
@@ -17,12 +21,57 @@ public class ThirdPartyCouponController {
|
||||
this.thirdPartyCouponService = thirdPartyCouponService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取绑定状态
|
||||
* @return 绑定状态
|
||||
*/
|
||||
@GetMapping("/state")
|
||||
public ResponseEntity<Map<String, Object>> getState(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getState(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取美团绑定链接
|
||||
* @return 美团绑定链接
|
||||
*/
|
||||
@GetMapping
|
||||
@GetMapping("bindUrl")
|
||||
public ResponseEntity<String> getBindUrl(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getBindUrl(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑美团商家
|
||||
* @return 美团解绑链接
|
||||
*/
|
||||
@GetMapping("unBindUrl")
|
||||
public ResponseEntity<String> getUnBindUrl(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getUnBindUrl(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店客核销券
|
||||
* @return 所有券
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public ResponseEntity<Map<String, Object>> getActivateCoupon(@RequestParam Integer shopId, @RequestParam String code) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getActivateCoupon(shopId, code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销券
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Map<String, Object>> checkCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.checkCoupon(checkCouponDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销券核销
|
||||
*/
|
||||
@DeleteMapping("revoke")
|
||||
public ResponseEntity<Map<String, Object>> revokeCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.revokeCoupon(checkCouponDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -250,6 +250,16 @@ public class TbPlaceController {
|
||||
return ResponseEntity.ok(tbShopTableService.printDishes(baseTableDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 美团核销
|
||||
* @param checkDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("checkCoupon")
|
||||
public ResponseEntity<Object> checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) {
|
||||
return ResponseEntity.ok(tbShopTableService.checkCoupon(checkDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
public void test(
|
||||
|
||||
@@ -22,6 +22,7 @@ public class PayDTO {
|
||||
private BigDecimal discount;
|
||||
private Integer vipUserId;
|
||||
private String code;
|
||||
private Integer num;
|
||||
private String token;
|
||||
// 使用的优惠券
|
||||
@Valid
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.ysk.cashier.dto.shoptable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ThirdCouponCheckDTO {
|
||||
private String type = "meituan";
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotBlank
|
||||
private String code;
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
@NotNull
|
||||
private Integer orderId;
|
||||
// 核销的对应商品
|
||||
@NotEmpty
|
||||
private List<Integer> cartId;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.ysk.cashier.dto.thirdcoupon;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class BaseQueryDTO {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.dto.thirdcoupon;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CheckCouponDTO extends BaseQueryDTO {
|
||||
@NotBlank
|
||||
private String couponCode;
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.dto.thirdcoupon;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class GetActivateCouponDTO extends BaseQueryDTO{
|
||||
@NotBlank
|
||||
private String code;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.dto.thirdcoupon;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RevokeCouponDTO extends BaseQueryDTO{
|
||||
@NotBlank
|
||||
private String couponCode;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_third_party_coupon_record")
|
||||
public class TbThirdPartyCouponRecord {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "order_id")
|
||||
private Integer orderId;
|
||||
|
||||
@Column(name = "state")
|
||||
private Byte state;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "plat")
|
||||
private String plat;
|
||||
|
||||
@Size(max = 50)
|
||||
@Column(name = "code", length = 50)
|
||||
private String code;
|
||||
|
||||
private Integer num;
|
||||
|
||||
@Column(name = "create_time")
|
||||
private Instant createTime;
|
||||
|
||||
@Column(name = "check_time")
|
||||
private Instant checkTime;
|
||||
|
||||
@Column(name = "shop_id")
|
||||
private Integer shopId;
|
||||
private String cartIdList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_third_party_coupon_record】的数据库操作Mapper
|
||||
* @createDate 2024-11-25 17:57:03
|
||||
* @Entity cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord
|
||||
*/
|
||||
public interface TbThirdPartyCouponRecordMapper extends BaseMapper<TbThirdPartyCouponRecord> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -90,5 +90,14 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||
* @param statuses 状态
|
||||
*/
|
||||
TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses);
|
||||
|
||||
/**
|
||||
* 根据id查询购物车数据
|
||||
* @param shopId 店铺id
|
||||
* @param orderId 订单id
|
||||
* @param ids 购物车id
|
||||
* @param statuses 状态
|
||||
*/
|
||||
List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务接口
|
||||
@@ -78,5 +80,7 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||
* @param isMember 会员id
|
||||
*/
|
||||
boolean updateMemberByOrderId(Integer orderId, boolean isMember);
|
||||
|
||||
boolean updateFieldByCartId(SFunction<TbOrderDetail, ?> field, Object val, List<Integer> cartIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_third_party_coupon_record】的数据库操作Service
|
||||
* @createDate 2024-11-25 17:57:03
|
||||
*/
|
||||
public interface TbThirdPartyCouponRecordService extends IService<TbThirdPartyCouponRecord> {
|
||||
|
||||
}
|
||||
@@ -184,5 +184,17 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
||||
}
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.eq(TbCashierCart::getOrderId, orderId)
|
||||
.in(TbCashierCart::getId, ids);
|
||||
if (statuses.length != 0) {
|
||||
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
|
||||
}
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,19 +2,18 @@ package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.ysk.cashier.cons.TableConstant;
|
||||
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -88,5 +87,15 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
|
||||
.eq(TbOrderDetail::getOrderId, orderId)
|
||||
.set(TbOrderDetail::getIsMember, isMember ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFieldByCartId(SFunction<TbOrderDetail, ?> field, Object val, List<Integer> cartIds) {
|
||||
LambdaUpdateWrapper<TbOrderDetail> query = new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.set(field, val);
|
||||
if (!cartIds.isEmpty()) {
|
||||
query.in(TbOrderDetail::getCartId, cartIds);
|
||||
}
|
||||
return update(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord;
|
||||
import cn.ysk.cashier.mybatis.service.TbThirdPartyCouponRecordService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbThirdPartyCouponRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_third_party_coupon_record】的数据库操作Service实现
|
||||
* @createDate 2024-11-25 17:57:03
|
||||
*/
|
||||
@Service
|
||||
public class TbThirdPartyCouponRecordServiceImpl extends ServiceImpl<TbThirdPartyCouponRecordMapper, TbThirdPartyCouponRecord>
|
||||
implements TbThirdPartyCouponRecordService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -177,6 +177,8 @@ public class TbCashierCart implements Serializable {
|
||||
private String discountSaleNote;
|
||||
private Boolean isPrint;
|
||||
private String useCouponInfo;
|
||||
// 是否团购券商品
|
||||
private Integer isThirdCoupon;
|
||||
|
||||
public void copy(TbCashierCart source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
@@ -186,6 +188,10 @@ public class TbCashierCart implements Serializable {
|
||||
* 根据是否会员充值价格
|
||||
*/
|
||||
public void resetTotalAmount() {
|
||||
if (isThirdCoupon != null && isThirdCoupon == 1) {
|
||||
totalAmount = BigDecimal.ZERO;
|
||||
return;
|
||||
}
|
||||
if ("false".equals(isPack)) {
|
||||
packFee = BigDecimal.ZERO;
|
||||
}
|
||||
@@ -207,6 +213,10 @@ public class TbCashierCart implements Serializable {
|
||||
* 根据是否会员充值价格
|
||||
*/
|
||||
public void resetTotalAmount(BigDecimal discountRadio) {
|
||||
if (isThirdCoupon != null && isThirdCoupon == 1) {
|
||||
totalAmount = BigDecimal.ZERO;
|
||||
return;
|
||||
}
|
||||
if (discountRadio == null) {
|
||||
discountRadio = BigDecimal.ONE;
|
||||
}
|
||||
@@ -216,10 +226,14 @@ public class TbCashierCart implements Serializable {
|
||||
if ("true".equals(isGift)) {
|
||||
totalAmount = packFee;
|
||||
} else {
|
||||
discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount;
|
||||
BigDecimal subtract;
|
||||
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
|
||||
subtract = memberPrice.subtract(discountSaleAmount);
|
||||
totalAmount = totalNumber.multiply(subtract).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
|
||||
} else {
|
||||
totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice)
|
||||
subtract = salePrice.subtract(discountSaleAmount);
|
||||
totalAmount = totalNumber.multiply(subtract)
|
||||
.add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
@@ -230,6 +244,9 @@ public class TbCashierCart implements Serializable {
|
||||
*
|
||||
*/
|
||||
public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) {
|
||||
if (isThirdCoupon != null && isThirdCoupon == 1) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (discountRadio == null) {
|
||||
discountRadio = new BigDecimal("1");
|
||||
}
|
||||
@@ -250,10 +267,5 @@ public class TbCashierCart implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
public void resetDiscountSaleAmount() {
|
||||
BigDecimal finalAmount = BigDecimal.ZERO;
|
||||
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ public class TbOrderDetail implements Serializable {
|
||||
private String useCouponInfo;
|
||||
private BigDecimal returnAmount;
|
||||
private BigDecimal canReturnAmount;
|
||||
private Integer isThirdCoupon;
|
||||
|
||||
public void copy(TbOrderDetail source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ThirdPartyCouponService {
|
||||
|
||||
String getBindUrl(Integer shopId);
|
||||
|
||||
String getUnBindUrl(Integer shopId);
|
||||
|
||||
Map<String, Object> getActivateCoupon(Integer shopId, String code);
|
||||
|
||||
Map<String, Object> checkCoupon(CheckCouponDTO checkCouponDTO);
|
||||
|
||||
Map<String, Object> revokeCoupon(CheckCouponDTO checkCouponDTO);
|
||||
|
||||
Map<String, Object> getState(Integer shopId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
@@ -30,7 +31,7 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
|
||||
}
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
private <T> T getData(String url, Integer shopId, Object data) {
|
||||
private <T> T exec(String url, Integer shopId, Object data) {
|
||||
// 获取店铺信息
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
|
||||
if (shopInfo == null) {
|
||||
@@ -77,6 +78,33 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
|
||||
|
||||
@Override
|
||||
public String getBindUrl(Integer shopId) {
|
||||
return getData("/meituan/getuisdkurl", shopId, null);
|
||||
return exec("/meituan/getuisdkurl", shopId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnBindUrl(Integer shopId) {
|
||||
return exec("/meituan/getuisdkuniurl", shopId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getActivateCoupon(Integer shopId, String code) {
|
||||
return exec("/meituan/fulfilmentcertificateprepare", shopId, new HashMap<String, Object>(){{
|
||||
put("code", code);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> checkCoupon(CheckCouponDTO checkCouponDTO) {
|
||||
return exec("/meituan/certificateprepare", checkCouponDTO.getShopId(), checkCouponDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> revokeCoupon(CheckCouponDTO checkCouponDTO) {
|
||||
return exec("/meituan/fulfilmentcertificatecancel", checkCouponDTO.getShopId(), checkCouponDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getState(Integer shopId) {
|
||||
return exec("/meituan/searchstorestatus", shopId, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO;
|
||||
import cn.ysk.cashier.dto.shop.TbShopTableDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
|
||||
import cn.ysk.cashier.dto.shoptable.*;
|
||||
import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO;
|
||||
import cn.ysk.cashier.enums.*;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||
import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.*;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
@@ -43,6 +45,7 @@ import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
|
||||
import cn.ysk.cashier.service.PayService;
|
||||
import cn.ysk.cashier.service.ThirdPartyCouponService;
|
||||
import cn.ysk.cashier.service.impl.TbPayServiceImpl;
|
||||
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||
import cn.ysk.cashier.service.shop.TbShopTableService;
|
||||
@@ -125,12 +128,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final MpShopInfoMapper mpShopInfoMapper;
|
||||
private final MpOrderDetailService mpOrderDetailService;
|
||||
private final MpCashierCartService mpCashierCartService;
|
||||
private final MpMerchantThirdApplyMapper mpMerchantThirdApplyMapper;
|
||||
private final PayService payService;
|
||||
private final TbOrderInfoService orderInfoService;
|
||||
private final MpOrderInfoService mpOrderInfoService;
|
||||
private final TbShopUserMapper tbShopUserMapper;
|
||||
private final TbActivateInRecordService activateInRecordService;
|
||||
private final ThirdPartyCouponService thirdPartyCouponService;
|
||||
private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService;
|
||||
|
||||
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) {
|
||||
// 获取当前台桌最新订单,先付款模式不获取
|
||||
@@ -2279,7 +2282,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
payDTO.setDiscount(new BigDecimal("1"));
|
||||
}
|
||||
|
||||
BigDecimal finalAmount = null;
|
||||
BigDecimal finalAmount;
|
||||
|
||||
// 计算优惠券积分折扣信息
|
||||
if (payDTO.getVipUserId() != null) {
|
||||
@@ -2320,6 +2323,28 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
case "deposit":
|
||||
orderInfo = tbPayServiceImpl.memberAccountPay("", String.valueOf(payDTO.getShopId()), payDTO.getCode(), orderInfo, finalAmount);
|
||||
break;
|
||||
// 团购券支付
|
||||
case "partyCoupon":
|
||||
if (payDTO.getNum() == null || payDTO.getNum() < 1) {
|
||||
throw new BadRequestException("团购券核销数量有误");
|
||||
}
|
||||
CheckCouponDTO dto = new CheckCouponDTO();
|
||||
dto.setNum(1);
|
||||
dto.setShopId(payDTO.getShopId());
|
||||
dto.setCouponCode(payDTO.getCode());
|
||||
thirdPartyCouponService.checkCoupon(dto);
|
||||
orderInfo.setOrderType(TableConstant.OrderInfo.OrderType.COUPON.getValue());
|
||||
TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord();
|
||||
record.setOrderId(orderInfo.getId());
|
||||
record.setCode(payDTO.getCode());
|
||||
record.setNum(1);
|
||||
record.setState((byte) 1);
|
||||
record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue());
|
||||
record.setCreateTime(DateUtil.date().toInstant());
|
||||
record.setCheckTime(DateUtil.date().toInstant());
|
||||
record.setShopId(payDTO.getShopId());
|
||||
thirdPartyCouponRecordService.save(record);
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException("未知支付方式");
|
||||
}
|
||||
@@ -3171,4 +3196,49 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
}
|
||||
return cashierCart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object checkCoupon(ThirdCouponCheckDTO checkDTO) {
|
||||
TbOrderInfo orderInfo = mpOrderInfoService.getById(checkDTO.getOrderId());
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单信息不存在");
|
||||
}
|
||||
|
||||
if (!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) {
|
||||
throw new BadRequestException("订单不为待支付状态");
|
||||
}
|
||||
|
||||
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByIds(checkDTO.getShopId(), checkDTO.getOrderId(), checkDTO.getCartId());
|
||||
if (cashierCarts.size() != checkDTO.getCartId().size()) {
|
||||
throw new BadRequestException("含有不存在购物车");
|
||||
}
|
||||
|
||||
CheckCouponDTO dto = new CheckCouponDTO();
|
||||
dto.setShopId(checkDTO.getShopId());
|
||||
dto.setCouponCode(checkDTO.getCode());
|
||||
dto.setNum(checkDTO.getNum());
|
||||
thirdPartyCouponService.checkCoupon(dto);
|
||||
|
||||
BigDecimal incrAmount = BigDecimal.ZERO;
|
||||
for (TbCashierCart item : cashierCarts) {
|
||||
item.setIsThirdCoupon(1);
|
||||
incrAmount = incrAmount.add(item.getTotalAmount());
|
||||
}
|
||||
mpCashierCartService.updateBatchById(cashierCarts);
|
||||
mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsThirdCoupon, 1, checkDTO.getCartId());
|
||||
mpOrderInfoService.incrAmount(orderInfo.getId(), incrAmount.negate());
|
||||
|
||||
TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord();
|
||||
record.setOrderId(orderInfo.getId());
|
||||
record.setCode(checkDTO.getCode());
|
||||
record.setNum(1);
|
||||
record.setState((byte) 1);
|
||||
record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue());
|
||||
record.setCreateTime(DateUtil.date().toInstant());
|
||||
record.setCheckTime(DateUtil.date().toInstant());
|
||||
record.setShopId(checkDTO.getShopId());
|
||||
record.setCartIdList(JSONObject.toJSONString(checkDTO.getCartId()));
|
||||
thirdPartyCouponRecordService.save(record);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,4 +163,8 @@ public interface TbShopTableService {
|
||||
*/
|
||||
TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO);
|
||||
|
||||
/**
|
||||
* 团购券核销
|
||||
*/
|
||||
Object checkCoupon(ThirdCouponCheckDTO checkDTO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbThirdPartyCouponRecordMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="order_id" column="order_id" jdbcType="INTEGER"/>
|
||||
<result property="state" column="state" jdbcType="TINYINT"/>
|
||||
<result property="plat" column="plat" jdbcType="VARCHAR"/>
|
||||
<result property="code" column="code" jdbcType="VARCHAR"/>
|
||||
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="check_time" column="check_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,order_id,state,
|
||||
plat,code,create_time,
|
||||
check_time,shop_id
|
||||
</sql>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user