diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/OrderApplyRefundBo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/OrderApplyRefundBo.java index 7e6098a..cc845e0 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/OrderApplyRefundBo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/OrderApplyRefundBo.java @@ -31,4 +31,11 @@ public class OrderApplyRefundBo implements Serializable { @NotBlank(message = "退款原因不能为空") @ApiModelProperty(value = "退款原因",required = true) private String refundReason; + + /** + * openId + */ + @NotBlank(message = "openId不能为空") + @ApiModelProperty(value = "openId",required = true) + private String openId; } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductBo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductBo.java index fb7ab85..802b21c 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductBo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductBo.java @@ -96,7 +96,7 @@ public class ProductBo implements Serializable { private Integer limitNum; /** - * 旧课卡模板id + * 旧模板id */ @ApiModelProperty("旧课卡模板id") private String cardTemplateId; diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductRecordBo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductRecordBo.java index ec22bae..5127116 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductRecordBo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/bo/ProductRecordBo.java @@ -49,4 +49,10 @@ public class ProductRecordBo implements Serializable { */ @ApiModelProperty("记录消耗积分") private Integer recordPoints; + + /** + * 乐观锁字段 + */ + @ApiModelProperty("乐观锁字段") + private Integer version; } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageOrderController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageOrderController.java index aaa9b58..e6cab86 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageOrderController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageOrderController.java @@ -1,9 +1,11 @@ package com.cpop.mall.business.controller.backstage; import com.cpop.core.base.R; +import com.cpop.core.utils.SpringUtils; import com.cpop.mall.business.bo.LogisticsOrderBo; import com.cpop.mall.business.bo.OrderPageBo; import com.cpop.mall.business.service.OrderService; +import com.cpop.mall.business.task.OrderDetailAsyncTask; import com.cpop.mall.business.vo.OrderPageVo; import com.mybatisflex.core.paginate.Page; import io.swagger.annotations.Api; @@ -86,10 +88,7 @@ public class BackstageOrderController { @PutMapping("/orderFinish") @ApiOperation("后台确定订单完成") public R orderFinish(@RequestParam("id") @ApiParam(value = "订单id",required = true) String id) { - orderService.updateChain() - .setRaw(ORDER.PREVIOUS_STATUS, ORDER.ORDER_STATUS) - .set(ORDER.ORDER_STATUS, 3) - .where(ORDER.ID.eq(id)).update(); + orderService.orderFinish(id); return R.ok(); } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/OrderRefund.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/OrderRefund.java index e36a9f3..7baac58 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/OrderRefund.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/entity/OrderRefund.java @@ -59,6 +59,11 @@ public class OrderRefund extends BaseEntity implements Serializable { */ private String rejectReason; + /** + * openId + */ + private String openId; + /** * 逻辑删除(0否1是) */ diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/OrderService.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/OrderService.java index fda5a0b..d68b48d 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/OrderService.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/OrderService.java @@ -1,6 +1,8 @@ package com.cpop.mall.business.service; +import com.alibaba.fastjson.JSONObject; import com.cpop.mall.business.bo.*; +import com.cpop.mall.business.dto.UserPointDto; import com.cpop.mall.business.entity.Order; import com.cpop.mall.business.vo.OrderInfoVo; import com.cpop.mall.business.vo.OrderPageVo; @@ -103,4 +105,20 @@ public interface OrderService extends IService { * @return: com.cpop.mall.business.vo.OrderInfoVo */ OrderInfoVo getOrderInfo(String orderId); + + /** + * @descriptions 后台确定订单完成 + * @author DB + * @date 2023/11/13 17:42 + * @param id 主键 + * @return: void + */ + void orderFinish(String id); + + /** + * 获取用户积分 + * @param loginUserInfo + * @return + */ + UserPointDto getUserPoint(JSONObject loginUserInfo); } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java index 92f77a5..757a52c 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderRefundServiceImpl.java @@ -1,13 +1,16 @@ package com.cpop.mall.business.service.impl; +import com.alibaba.fastjson.JSONObject; import com.cpop.core.base.entity.PageDomain; import com.cpop.core.base.enums.OrderSource; import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.sql.SqlUtils; import com.cpop.core.utils.uuid.IdUtils; import com.cpop.mall.business.bo.OrderRefundPageBo; import com.cpop.mall.business.bo.OrderRejectRefundBo; +import com.cpop.mall.business.dto.UserPointDto; import com.cpop.mall.business.entity.Order; import com.cpop.mall.business.entity.OrderRefund; import com.cpop.mall.business.mapper.OrderRefundMapper; @@ -27,13 +30,19 @@ import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.row.DbChain; +import com.mybatisflex.core.row.RowKey; import com.mybatisflex.spring.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; + 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.OrderTableDef.ORDER; @@ -64,48 +73,78 @@ public class OrderRefundServiceImpl extends ServiceImpl implements //获取当前用户所属品牌 .setBrandId(loginUserInfo.getString("brandId")) .setProductNames(productList.stream().map(Product::getProductName).collect(Collectors.joining(","))) + //当前用户id,根据用户类型查询不同用户列表 .setPayUserId(loginUserInfo.getString("userId")); if (StringUtils.isBlank(bo.getPayUserName())) { order.setPayUserName(loginUserInfo.getString("nickName")); @@ -331,8 +334,6 @@ public class OrderServiceImpl extends ServiceImpl implements .set(ORDER.RECEIVE_NAME, bo.getReceiveName()) .where(ORDER.ID.eq(bo.getId())) .update(); - //异步处理订单详情 - SpringUtils.getBean(OrderDetailAsyncTask.class).asyncProcessingOrderDetails(order, loginUserInfo, orderDetails, productList); return result; } catch (Exception e) { throw new ServiceException(e.getMessage()); @@ -366,7 +367,7 @@ public class OrderServiceImpl extends ServiceImpl implements .set("brand_id", userPoint.getBrandCloudId()) .set("point_behaviour", 9) .set("behaviour_record", "商城购买商品") - .set("point_change", order.getTotalPoint()) + .set("point_change", -order.getTotalPoint()) .set("point_time", now) .set("cumulative", userPoint.getTotalPoint() - order.getTotalPoint()) .set("creation_by", userPoint.getOldUserId()) @@ -393,7 +394,8 @@ public class OrderServiceImpl extends ServiceImpl implements * @param loginUserInfo 用户信息 * @return: java.lang.Integer */ - private UserPointDto getUserPoint(JSONObject loginUserInfo){ + @Override + public UserPointDto getUserPoint(JSONObject loginUserInfo){ //获取云品牌id BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class) .getOne(QueryWrapper.create() @@ -694,4 +696,35 @@ public class OrderServiceImpl extends ServiceImpl implements return orderInfoVo; } + /** + * @descriptions 后台确定订单完成 + * @author DB + * @date 2023/11/13 17:42 + * @param id 主键 + * @return: void + */ + @Override + public void orderFinish(String id) { + //获取订单信息 + Order order = this.getById(id); + //获取预订单详情信息 + OrderDetailService orderDetailService = SpringUtils.getBean(OrderDetailService.class); + List orderDetails = orderDetailService.queryChain().where(ORDER_DETAIL.ORDER_ID.eq(order.getId())).list(); + //获取涉及到的商品 + ProductService productService = SpringUtils.getBean(ProductService.class); + List productList = productService.queryChain() + .select(PRODUCT.ID, PRODUCT.PRODUCT_NAME, PRODUCT.DESCRIPTION, PRODUCT.PRODUCT_TYPE, PRODUCT.CARD_TEMPLATE_ID) + .from(PRODUCT) + .leftJoin(PRODUCT_RECORD).on(PRODUCT_RECORD.PRODUCT_ID.eq(PRODUCT.ID)) + .where(PRODUCT_RECORD.ID.in(orderDetails.stream().map(OrderDetail::getProductRecordId).collect(Collectors.toSet()))) + .list(); + this.updateChain() + .setRaw(ORDER.PREVIOUS_STATUS, ORDER.ORDER_STATUS) + .set(ORDER.ORDER_STATUS, 3) + .where(ORDER.ID.eq(id)).update(); + //异步处理订单详情 + SysUser sysUser = DbChain.table(SYS_USER).where(SYS_USER.ID.eq(order.getPayUserId())).oneAs(SysUser.class); + SpringUtils.getBean(OrderDetailAsyncTask.class).asyncProcessingOrderDetails(order, sysUser.getPhoneNumber(), sysUser.getNickName(), orderDetails, productList); + } + } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java index a754435..999bbd0 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java @@ -44,7 +44,6 @@ import java.util.Comparator; import java.util.List; import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; -import static com.cpop.jambox.business.entity.table.CardTemplateTableDef.CARD_TEMPLATE; import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND; import static com.cpop.mall.business.entity.table.OrderDetailTableDef.ORDER_DETAIL; import static com.cpop.mall.business.entity.table.OrderEvaluateTableDef.ORDER_EVALUATE; @@ -348,6 +347,7 @@ public class ProductServiceImpl extends ServiceImpl impl .leftJoin("t_brand_info").as("tbi").on("tbi.id = tct.brand_id") .where("tbi.brand_id = ?", brandExtend.getBrandCloudId()) .or("tct.brand_id = ?", brandExtend.getBrandCloudId()) + .and("tct.pay_type = 0") //未被删除的模板 .and("tct.deleted = 1") .orderBy("tct.creation_time", false)); @@ -444,7 +444,18 @@ public class ProductServiceImpl extends ServiceImpl impl */ @Override public ProductInfoVo getProductInfo(String id) { - return this.mapper.selectOneWithRelationsByIdAs(id, ProductInfoVo.class); + JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo(); + ProductInfoVo productInfoVo = this.mapper.selectOneWithRelationsByIdAs(id, ProductInfoVo.class); + if (productInfoVo.getProductType() == 0){ + try { + DataSourceKey.use("jambox"); + CardTemplate cardTemplate = SpringUtils.getBean(CardTemplateService.class).getOldTemplateInfo(productInfoVo.getCardTemplateId(), loginUserInfo.getString("brandId")); + productInfoVo.setCardTemplateName(cardTemplate.getName()); + } finally { + DataSourceKey.clear(); + } + } + return productInfoVo; } /** diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/StaffServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/StaffServiceImpl.java index a82937b..6583f6f 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/StaffServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/StaffServiceImpl.java @@ -180,7 +180,7 @@ public class StaffServiceImpl extends ServiceImpl implements LoginUser loginUser = jsonObject.getObject("user", LoginUser.class); MallStaffLoginInfo staffLoginInfo = BeanUtils.mapToClass(bo, MallStaffLoginInfo.class); loginUser.setUser(staffLoginInfo); - redisService.setCacheObject(UserType.MINI_USER.getKey() + loginUser.getUsername(), loginUser); + redisService.setCacheObject(UserType.MINI_USER.getKey() + loginUser.getIdentification(), loginUser); } } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/task/OrderDetailAsyncTask.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/OrderDetailAsyncTask.java index 1a238c9..da30f90 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/task/OrderDetailAsyncTask.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/OrderDetailAsyncTask.java @@ -45,11 +45,11 @@ public class OrderDetailAsyncTask { * @param order 订单 * @param loginUserInfo 用户详情 * @param orderDetails 订单详情 - * @param productList 商品列表 + * @param productList 产品列表 * @return: void */ @Async("customAsyncThreadPool") - public void asyncProcessingOrderDetails(Order order, JSONObject loginUserInfo, List orderDetails, List productList) { + public void asyncProcessingOrderDetails(Order order, String phoneNumber,String nickName, List orderDetails, List productList) { Map productMap = productList.stream().collect(Collectors.toMap(Product::getId, item -> item)); List productRecords = SpringUtils.getBean(ProductRecordService.class).listByIds(orderDetails.stream().map(OrderDetail::getProductRecordId).collect(Collectors.toSet())); Map productRecordMap = productRecords.stream().collect(Collectors.toMap(ProductRecord::getId, item -> item)); @@ -74,9 +74,9 @@ public class OrderDetailAsyncTask { //店铺/校区 jsonBody.put("storeId", storeCloudMap.get(item.getStoreId())); //手机号 - jsonBody.put("phone", loginUserInfo.getString("phoneNumber")); + jsonBody.put("phone", phoneNumber); //客户名称 - jsonBody.put("customerName", loginUserInfo.getString("nickName")); + jsonBody.put("customerName", nickName); //模板id jsonBody.put("templateId", product.getCardTemplateId()); //订单来源 diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java index 4862b1e..133b293 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java @@ -48,6 +48,18 @@ public class ProductInfoVo implements Serializable { @ApiModelProperty("商店(校区)集合") private String storeIds; + /** + * 模板id + */ + @ApiModelProperty("模板Id") + private String cardTemplateId; + + /** + * 模板名 + */ + @ApiModelProperty("模板名") + private String cardTemplateName; + /** * 描述 */