调整限购策略;预支付成功删除购物车

This commit is contained in:
DB 2023-11-07 17:58:58 +08:00
parent d7dae69e3f
commit 038235bbe9
12 changed files with 47 additions and 20 deletions

View File

@ -99,7 +99,9 @@ public class SysLoginInfoBuild extends AbstractLoginInfoBuild {
staffLoginInfo.setBrandId(row.getString("brandId")); staffLoginInfo.setBrandId(row.getString("brandId"));
staffLoginInfo.setSourceType(SourceType.valueOf(row.getString("sourceType"))); staffLoginInfo.setSourceType(SourceType.valueOf(row.getString("sourceType")));
} else { } else {
staffLoginInfo.setName(Constants.SUPER_ADMIN) //超级管理员
staffLoginInfo.setId("1")
.setName(Constants.SUPER_ADMIN)
.setSourceType(SourceType.COMMON); .setSourceType(SourceType.COMMON);
} }
return new LoginUser(staffLoginInfo, staffLoginInfo.getId(), getPermissionSet(sysUser.getUserName(), staffLoginInfo.getRoleId())); return new LoginUser(staffLoginInfo, staffLoginInfo.getId(), getPermissionSet(sysUser.getUserName(), staffLoginInfo.getRoleId()));

View File

@ -28,6 +28,7 @@
</dependencies> </dependencies>
<build> <build>
<finalName>Cpop-Mall-Web</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -47,19 +47,22 @@ public class CpopWxPayTests {
@Test @Test
public void refund() throws WxPayException { public void refund() throws WxPayException {
Brand brand = SpringUtils.getBean(BrandService.class).getById("75140168047210496"); Brand brand = SpringUtils.getBean(BrandService.class).getById("75140168047210496");
Order order = SpringUtils.getBean(OrderService.class).getById("78954327589658624"); //Order order = SpringUtils.getBean(OrderService.class).getById("78954327589658624");
WxPayRefundV3Request request = new WxPayRefundV3Request(); WxPayRefundV3Request request = new WxPayRefundV3Request();
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount(); WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
//退款金额(单位分) //退款金额(单位分)
int refund = order.getTotalAmount().scaleByPowerOfTen(2).intValue(); //int refund = order.getTotalAmount().scaleByPowerOfTen(2).intValue();
int refund = 1;
amount.setRefund(refund) amount.setRefund(refund)
.setTotal(refund) .setTotal(refund)
.setCurrency("CNY"); .setCurrency("CNY");
request.setTransactionId(order.getOutOrderNo()) request.setSubMchid(wxPayService.getConfig().getSubMchId())
.setSubMchid(wxPayService.getConfig().getSubMchId()) .setTransactionId("4200002027202310279036554434")
.setOutTradeNo("75505378790948864")
//.setTransactionId(order.getOutOrderNo())
//.setOutTradeNo(order.getId())
.setNotifyUrl(wxPayProperties.getNotifyRefund()) .setNotifyUrl(wxPayProperties.getNotifyRefund())
.setOutRefundNo(IdUtils.fastSimpleUUID()) .setOutRefundNo(IdUtils.fastSimpleUUID())
.setOutTradeNo(order.getId())
.setSubMchid(brand.getWxMchId()) .setSubMchid(brand.getWxMchId())
.setReason("接口测试退款") .setReason("接口测试退款")
.setAmount(amount); .setAmount(amount);

View File

@ -57,6 +57,12 @@ public class AdvanceOrderBo implements Serializable {
@ApiModelProperty(value = "支付用户名") @ApiModelProperty(value = "支付用户名")
private String payUserName; private String payUserName;
/**
* 购物车ids
*/
@ApiModelProperty(value = "购物车ids")
private List<String> shoppingCartIds;
/** /**
* 订单详情 * 订单详情
*/ */

View File

@ -24,16 +24,16 @@ public class OrderPageBo implements Serializable {
private String productName; private String productName;
/** /**
* 支付用户 * 收货人
*/ */
@ApiModelProperty("支付用户") @ApiModelProperty("收货人")
private String payUserName; private String receiveName;
/** /**
* 收人手机号 * 人手机号
*/ */
@ApiModelProperty("收人手机号") @ApiModelProperty("人手机号")
private String payUserPhone; private String receivePhone;
/** /**
* 订单状态(0:待付款;1:待发货;2:待确认;3:已完成;4:退款/售后中) * 订单状态(0:待付款;1:待发货;2:待确认;3:已完成;4:退款/售后中)

View File

@ -54,4 +54,5 @@ public class ShoppingCartBo implements Serializable {
@NotNull(message = "数量不能为空") @NotNull(message = "数量不能为空")
@ApiModelProperty(value = "数量",required = true) @ApiModelProperty(value = "数量",required = true)
private Integer number; private Integer number;
} }

View File

@ -36,6 +36,7 @@ public class OrderDetail extends BaseEntity implements Serializable {
/** /**
* 商品记录id * 商品记录id
*/ */
@Id
private String productRecordId; private String productRecordId;
/** /**

View File

@ -32,6 +32,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER; import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
import static com.cpop.mall.business.entity.table.OrderRefundTableDef.ORDER_REFUND; import static com.cpop.mall.business.entity.table.OrderRefundTableDef.ORDER_REFUND;
@ -115,12 +116,17 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
* @return: void * @return: void
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void rejectRefund(OrderRejectRefundBo bo) { public void rejectRefund(OrderRejectRefundBo bo) {
//获取订单
OrderRefund refund = this.queryChain().where(ORDER_REFUND.ID.eq(bo.getId())).one();
this.updateChain().set(ORDER_REFUND.REFUND_STATUS, 2) this.updateChain().set(ORDER_REFUND.REFUND_STATUS, 2)
.set(ORDER_REFUND.REFUND_REASON, bo.getRejectReason()) .set(ORDER_REFUND.REFUND_REASON, bo.getRejectReason())
.where(ORDER_REFUND.ID.eq(bo.getId())) .where(ORDER_REFUND.ID.eq(bo.getId()))
.update(); .update();
//更改订单为原状态
SpringUtils.getBean(OrderService.class).updateChain().set(ORDER.ORDER_STATUS,ORDER.PREVIOUS_STATUS)
.where(ORDER.ID.eq(refund.getOrderId())).update();
} }
/** /**

View File

@ -54,6 +54,7 @@ import static com.cpop.mall.business.entity.table.OrderRefundTableDef.ORDER_REFU
import static com.cpop.mall.business.entity.table.OrderTableDef.ORDER; import static com.cpop.mall.business.entity.table.OrderTableDef.ORDER;
import static com.cpop.mall.business.entity.table.ProductRecordTableDef.PRODUCT_RECORD; import static com.cpop.mall.business.entity.table.ProductRecordTableDef.PRODUCT_RECORD;
import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT; import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT;
import static com.cpop.mall.business.entity.table.ShoppingCartTableDef.SHOPPING_CART;
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING; import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
import static com.cpop.system.business.entity.table.StoreTableDef.STORE; import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
import static com.mybatisflex.core.query.QueryMethods.field; import static com.mybatisflex.core.query.QueryMethods.field;
@ -113,8 +114,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
.select(ORDER.ALL_COLUMNS) .select(ORDER.ALL_COLUMNS)
.from(ORDER) .from(ORDER)
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(ORDER.PAY_USER_ID)) .leftJoin(SYS_USER).on(SYS_USER.ID.eq(ORDER.PAY_USER_ID))
.and(ORDER.PAY_USER_NAME.like(bo.getPayUserName())) .and(ORDER.RECEIVE_NAME.like(bo.getReceiveName()))
.and(SYS_USER.PHONE_NUMBER.like(bo.getPayUserPhone())) .and(ORDER.RECEIVE_PHONE.like(bo.getReceivePhone()))
.and(ORDER.PRODUCT_NAMES.like(bo.getProductName())) .and(ORDER.PRODUCT_NAMES.like(bo.getProductName()))
.and(SYS_USER.USER_TYPE.eq("MINI_USER")) .and(SYS_USER.USER_TYPE.eq("MINI_USER"))
.orderBy(ORDER.CREATE_TIME.desc()), .orderBy(ORDER.CREATE_TIME.desc()),
@ -162,7 +163,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//获取涉及到的商品 //获取涉及到的商品
ProductService productService = SpringUtils.getBean(ProductService.class); ProductService productService = SpringUtils.getBean(ProductService.class);
List<Product> productList = productService.queryChain() List<Product> productList = productService.queryChain()
.select(PRODUCT.ID, PRODUCT.PRODUCT_NAME, PRODUCT.DESCRIPTION) .select(PRODUCT.ID, PRODUCT.PRODUCT_NAME, PRODUCT.DESCRIPTION, PRODUCT.BUY_RESTRICT, PRODUCT.LIMIT_NUM)
.from(PRODUCT) .from(PRODUCT)
.leftJoin(PRODUCT_RECORD).on(PRODUCT_RECORD.PRODUCT_ID.eq(PRODUCT.ID)) .leftJoin(PRODUCT_RECORD).on(PRODUCT_RECORD.PRODUCT_ID.eq(PRODUCT.ID))
.where(PRODUCT_RECORD.ID.in(recordIds)) .where(PRODUCT_RECORD.ID.in(recordIds))
@ -202,6 +203,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
item.setOrderId(order.getId()); item.setOrderId(order.getId());
}); });
SpringUtils.getBean(OrderDetailService.class).saveBatch(orderDetails); SpringUtils.getBean(OrderDetailService.class).saveBatch(orderDetails);
//移除购物车
if (null != bo.getShoppingCartIds()&& !bo.getShoppingCartIds().isEmpty()){
SpringUtils.getBean(ShoppingCartService.class).removeByIds(bo.getShoppingCartIds());
}
return order.getId(); return order.getId();
} catch (Exception e) { } catch (Exception e) {
//回滚库存 //回滚库存
@ -503,7 +508,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Override @Override
public void inputLogisticsOrder(LogisticsOrderBo bo) { public void inputLogisticsOrder(LogisticsOrderBo bo) {
this.updateChain().setRaw(ORDER.PREVIOUS_STATUS, ORDER.ORDER_STATUS) this.updateChain().setRaw(ORDER.PREVIOUS_STATUS, ORDER.ORDER_STATUS)
.set(ORDER.ORDER_STATUS, 2) .set(ORDER.ORDER_STATUS, 3)
.set(ORDER.LOGISTICS_ORDER, bo.getLogisticsOrder()) .set(ORDER.LOGISTICS_ORDER, bo.getLogisticsOrder())
.where(ORDER.ID.eq(bo.getId())).update(); .where(ORDER.ID.eq(bo.getId())).update();
} }

View File

@ -302,7 +302,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
.select("tct.template_id AS id,tct.brand_id,tct.name") .select("tct.template_id AS id,tct.brand_id,tct.name")
.from("t_card_template").as("tct") .from("t_card_template").as("tct")
.leftJoin("t_brand_info").as("tbi").on("tbi.id = tct.brand_id") .leftJoin("t_brand_info").as("tbi").on("tbi.id = tct.brand_id")
.where("tbi.brand_id = ?", brandExtend.getBrandCloudId())); .where("tbi.brand_id = ?", brandExtend.getBrandCloudId())
.or("tct.brand_id = ?", brandExtend.getBrandCloudId()));
cardTemplateListVos = RowUtil.toEntityList(rowList, JamboxCardTemplateListVo.class); cardTemplateListVos = RowUtil.toEntityList(rowList, JamboxCardTemplateListVo.class);
} finally { } finally {
DataSourceKey.clear(); DataSourceKey.clear();

View File

@ -59,7 +59,8 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, Sho
.leftJoin(PRODUCT_RECORD).on(PRODUCT_RECORD.ID.eq(SHOPPING_CART.PRODUCT_RECORD_ID)) .leftJoin(PRODUCT_RECORD).on(PRODUCT_RECORD.ID.eq(SHOPPING_CART.PRODUCT_RECORD_ID))
.leftJoin(PRODUCT).on(PRODUCT.ID.eq(PRODUCT_RECORD.PRODUCT_ID)) .leftJoin(PRODUCT).on(PRODUCT.ID.eq(PRODUCT_RECORD.PRODUCT_ID))
.leftJoin(STORE).on(STORE.ID.eq(SHOPPING_CART.STORE_ID)) .leftJoin(STORE).on(STORE.ID.eq(SHOPPING_CART.STORE_ID))
.where(SHOPPING_CART.USER_ID.eq(loginUserInfo.getString("userId"))), .where(SHOPPING_CART.USER_ID.eq(loginUserInfo.getString("userId")))
.orderBy(SHOPPING_CART.CREATE_TIME.desc()),
MiniShoppingCartPageVo.class); MiniShoppingCartPageVo.class);
} }

View File

@ -56,7 +56,7 @@ public class UserRestrictStrategy implements BuyRestrictStrategy{
num.addAndGet(value); num.addAndGet(value);
} }
}); });
if (product.getLimitNum() - count > num.get()) { if (product.getLimitNum() - count < num.get()) {
//存在过购买记录 //存在过购买记录
throw new ServiceException("您购买的商品已超出限制,无法购买商品" + product.getProductName()); throw new ServiceException("您购买的商品已超出限制,无法购买商品" + product.getProductName());
} }