修改商品修改bug;修复积分退款;处理商城只查询微信支付课卡;修复完成订单时才进行办卡

This commit is contained in:
DB 2023-11-13 18:40:36 +08:00
parent 921a09c428
commit 78f4ee135c
12 changed files with 186 additions and 56 deletions

View File

@ -31,4 +31,11 @@ public class OrderApplyRefundBo implements Serializable {
@NotBlank(message = "退款原因不能为空") @NotBlank(message = "退款原因不能为空")
@ApiModelProperty(value = "退款原因",required = true) @ApiModelProperty(value = "退款原因",required = true)
private String refundReason; private String refundReason;
/**
* openId
*/
@NotBlank(message = "openId不能为空")
@ApiModelProperty(value = "openId",required = true)
private String openId;
} }

View File

@ -96,7 +96,7 @@ public class ProductBo implements Serializable {
private Integer limitNum; private Integer limitNum;
/** /**
* 课卡模板id * 模板id
*/ */
@ApiModelProperty("旧课卡模板id") @ApiModelProperty("旧课卡模板id")
private String cardTemplateId; private String cardTemplateId;

View File

@ -49,4 +49,10 @@ public class ProductRecordBo implements Serializable {
*/ */
@ApiModelProperty("记录消耗积分") @ApiModelProperty("记录消耗积分")
private Integer recordPoints; private Integer recordPoints;
/**
* 乐观锁字段
*/
@ApiModelProperty("乐观锁字段")
private Integer version;
} }

View File

@ -1,9 +1,11 @@
package com.cpop.mall.business.controller.backstage; package com.cpop.mall.business.controller.backstage;
import com.cpop.core.base.R; 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.LogisticsOrderBo;
import com.cpop.mall.business.bo.OrderPageBo; import com.cpop.mall.business.bo.OrderPageBo;
import com.cpop.mall.business.service.OrderService; import com.cpop.mall.business.service.OrderService;
import com.cpop.mall.business.task.OrderDetailAsyncTask;
import com.cpop.mall.business.vo.OrderPageVo; import com.cpop.mall.business.vo.OrderPageVo;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -86,10 +88,7 @@ public class BackstageOrderController {
@PutMapping("/orderFinish") @PutMapping("/orderFinish")
@ApiOperation("后台确定订单完成") @ApiOperation("后台确定订单完成")
public R<Void> orderFinish(@RequestParam("id") @ApiParam(value = "订单id",required = true) String id) { public R<Void> orderFinish(@RequestParam("id") @ApiParam(value = "订单id",required = true) String id) {
orderService.updateChain() orderService.orderFinish(id);
.setRaw(ORDER.PREVIOUS_STATUS, ORDER.ORDER_STATUS)
.set(ORDER.ORDER_STATUS, 3)
.where(ORDER.ID.eq(id)).update();
return R.ok(); return R.ok();
} }

View File

@ -59,6 +59,11 @@ public class OrderRefund extends BaseEntity implements Serializable {
*/ */
private String rejectReason; private String rejectReason;
/**
* openId
*/
private String openId;
/** /**
* 逻辑删除0否1是 * 逻辑删除0否1是
*/ */

View File

@ -1,6 +1,8 @@
package com.cpop.mall.business.service; package com.cpop.mall.business.service;
import com.alibaba.fastjson.JSONObject;
import com.cpop.mall.business.bo.*; 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.entity.Order;
import com.cpop.mall.business.vo.OrderInfoVo; import com.cpop.mall.business.vo.OrderInfoVo;
import com.cpop.mall.business.vo.OrderPageVo; import com.cpop.mall.business.vo.OrderPageVo;
@ -103,4 +105,20 @@ public interface OrderService extends IService<Order> {
* @return: com.cpop.mall.business.vo.OrderInfoVo * @return: com.cpop.mall.business.vo.OrderInfoVo
*/ */
OrderInfoVo getOrderInfo(String orderId); 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);
} }

View File

@ -1,13 +1,16 @@
package com.cpop.mall.business.service.impl; package com.cpop.mall.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cpop.core.base.entity.PageDomain; import com.cpop.core.base.entity.PageDomain;
import com.cpop.core.base.enums.OrderSource; import com.cpop.core.base.enums.OrderSource;
import com.cpop.core.base.exception.ServiceException; import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.SpringUtils; import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils; import com.cpop.core.utils.sql.SqlUtils;
import com.cpop.core.utils.uuid.IdUtils; import com.cpop.core.utils.uuid.IdUtils;
import com.cpop.mall.business.bo.OrderRefundPageBo; import com.cpop.mall.business.bo.OrderRefundPageBo;
import com.cpop.mall.business.bo.OrderRejectRefundBo; 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.Order;
import com.cpop.mall.business.entity.OrderRefund; import com.cpop.mall.business.entity.OrderRefund;
import com.cpop.mall.business.mapper.OrderRefundMapper; 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.bean.result.WxPayRefundV3Result;
import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService; 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.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; 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 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 org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
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;
import static com.cpop.mall.business.entity.table.OrderTableDef.ORDER; import static com.cpop.mall.business.entity.table.OrderTableDef.ORDER;
@ -64,10 +73,12 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
*/ */
@Override @Override
public void agreeRefund(String id) { public void agreeRefund(String id) {
try {
WxPayService wxPayService = wxPayHandler.getWxPayService();
OrderRefund orderRefund = this.queryChain().where(ORDER_REFUND.ID.eq(id)).one(); OrderRefund orderRefund = this.queryChain().where(ORDER_REFUND.ID.eq(id)).one();
Order order = SpringUtils.getBean(OrderService.class).queryChain().where(ORDER.ID.eq(orderRefund.getOrderId())).one(); Order order = SpringUtils.getBean(OrderService.class).queryChain().where(ORDER.ID.eq(orderRefund.getOrderId())).one();
//微信支付
if (order.getPayType() == 0) {
try {
WxPayService wxPayService = wxPayHandler.getWxPayService();
//分账记录 //分账记录
ProfitSharingService profitSharingService = SpringUtils.getBean(ProfitSharingService.class); ProfitSharingService profitSharingService = SpringUtils.getBean(ProfitSharingService.class);
ProfitSharing profitSharing = profitSharingService.queryChain().where(PROFIT_SHARING.ORDER_ID.eq(order.getId())) ProfitSharing profitSharing = profitSharingService.queryChain().where(PROFIT_SHARING.ORDER_ID.eq(order.getId()))
@ -106,6 +117,34 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
} catch (WxPayException e) { } catch (WxPayException e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
} else if (order.getPayType() == 1){
//扣除积分
JSONObject loginUserInfo = new JSONObject();
loginUserInfo.put("openId",orderRefund.getOpenId());
JSONObject loginStaffInfo = SecurityUtils.getInstance().getLoginUserInfo();
loginUserInfo.put("brandId",loginStaffInfo.getString("brandId"));
UserPointDto userPoint = SpringUtils.getBean(OrderService.class).getUserPoint(loginUserInfo);
try {
LocalDateTime now = LocalDateTime.now();
DataSourceKey.use("jambox");
DbChain.table("t_point_record")
.setId(RowKey.of("record_id", KeyType.Auto))
.set("user_id", userPoint.getOldUserId())
.set("brand_id", userPoint.getBrandCloudId())
.set("point_behaviour", 9)
.set("behaviour_record", "商城购买商品")
.set("point_change", order.getTotalPoint())
.set("point_time", now)
.set("cumulative", userPoint.getTotalPoint() + order.getTotalPoint())
.set("creation_by", userPoint.getOldUserId())
.set("last_modified", userPoint.getOldUserId())
.set("creation_time", now)
.save();
} finally {
DataSourceKey.clear();
}
}
} }
/** /**

View File

@ -8,6 +8,8 @@ import com.cpop.common.utils.ip.IpUtils;
import com.cpop.core.base.entity.PageDomain; import com.cpop.core.base.entity.PageDomain;
import com.cpop.core.base.enums.UserType; import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.ServiceException; import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
import com.cpop.core.service.CoreService;
import com.cpop.core.service.RedisService; import com.cpop.core.service.RedisService;
import com.cpop.core.utils.QuartzUtils; import com.cpop.core.utils.QuartzUtils;
import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.SecurityUtils;
@ -194,6 +196,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//获取当前用户所属品牌 //获取当前用户所属品牌
.setBrandId(loginUserInfo.getString("brandId")) .setBrandId(loginUserInfo.getString("brandId"))
.setProductNames(productList.stream().map(Product::getProductName).collect(Collectors.joining(","))) .setProductNames(productList.stream().map(Product::getProductName).collect(Collectors.joining(",")))
//当前用户id根据用户类型查询不同用户列表
.setPayUserId(loginUserInfo.getString("userId")); .setPayUserId(loginUserInfo.getString("userId"));
if (StringUtils.isBlank(bo.getPayUserName())) { if (StringUtils.isBlank(bo.getPayUserName())) {
order.setPayUserName(loginUserInfo.getString("nickName")); order.setPayUserName(loginUserInfo.getString("nickName"));
@ -331,8 +334,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
.set(ORDER.RECEIVE_NAME, bo.getReceiveName()) .set(ORDER.RECEIVE_NAME, bo.getReceiveName())
.where(ORDER.ID.eq(bo.getId())) .where(ORDER.ID.eq(bo.getId()))
.update(); .update();
//异步处理订单详情
SpringUtils.getBean(OrderDetailAsyncTask.class).asyncProcessingOrderDetails(order, loginUserInfo, orderDetails, productList);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
@ -366,7 +367,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
.set("brand_id", userPoint.getBrandCloudId()) .set("brand_id", userPoint.getBrandCloudId())
.set("point_behaviour", 9) .set("point_behaviour", 9)
.set("behaviour_record", "商城购买商品") .set("behaviour_record", "商城购买商品")
.set("point_change", order.getTotalPoint()) .set("point_change", -order.getTotalPoint())
.set("point_time", now) .set("point_time", now)
.set("cumulative", userPoint.getTotalPoint() - order.getTotalPoint()) .set("cumulative", userPoint.getTotalPoint() - order.getTotalPoint())
.set("creation_by", userPoint.getOldUserId()) .set("creation_by", userPoint.getOldUserId())
@ -393,7 +394,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
* @param loginUserInfo 用户信息 * @param loginUserInfo 用户信息
* @return: java.lang.Integer * @return: java.lang.Integer
*/ */
private UserPointDto getUserPoint(JSONObject loginUserInfo){ @Override
public UserPointDto getUserPoint(JSONObject loginUserInfo){
//获取云品牌id //获取云品牌id
BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class) BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class)
.getOne(QueryWrapper.create() .getOne(QueryWrapper.create()
@ -694,4 +696,35 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
return orderInfoVo; 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<OrderDetail> orderDetails = orderDetailService.queryChain().where(ORDER_DETAIL.ORDER_ID.eq(order.getId())).list();
//获取涉及到的商品
ProductService productService = SpringUtils.getBean(ProductService.class);
List<Product> 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);
}
} }

View File

@ -44,7 +44,6 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND; 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.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.OrderDetailTableDef.ORDER_DETAIL;
import static com.cpop.mall.business.entity.table.OrderEvaluateTableDef.ORDER_EVALUATE; import static com.cpop.mall.business.entity.table.OrderEvaluateTableDef.ORDER_EVALUATE;
@ -348,6 +347,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
.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()) .or("tct.brand_id = ?", brandExtend.getBrandCloudId())
.and("tct.pay_type = 0")
//未被删除的模板 //未被删除的模板
.and("tct.deleted = 1") .and("tct.deleted = 1")
.orderBy("tct.creation_time", false)); .orderBy("tct.creation_time", false));
@ -444,7 +444,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
*/ */
@Override @Override
public ProductInfoVo getProductInfo(String id) { 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;
} }
/** /**

View File

@ -180,7 +180,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
LoginUser loginUser = jsonObject.getObject("user", LoginUser.class); LoginUser loginUser = jsonObject.getObject("user", LoginUser.class);
MallStaffLoginInfo staffLoginInfo = BeanUtils.mapToClass(bo, MallStaffLoginInfo.class); MallStaffLoginInfo staffLoginInfo = BeanUtils.mapToClass(bo, MallStaffLoginInfo.class);
loginUser.setUser(staffLoginInfo); loginUser.setUser(staffLoginInfo);
redisService.setCacheObject(UserType.MINI_USER.getKey() + loginUser.getUsername(), loginUser); redisService.setCacheObject(UserType.MINI_USER.getKey() + loginUser.getIdentification(), loginUser);
} }
} }

View File

@ -45,11 +45,11 @@ public class OrderDetailAsyncTask {
* @param order 订单 * @param order 订单
* @param loginUserInfo 用户详情 * @param loginUserInfo 用户详情
* @param orderDetails 订单详情 * @param orderDetails 订单详情
* @param productList 品列表 * @param productList 品列表
* @return: void * @return: void
*/ */
@Async("customAsyncThreadPool") @Async("customAsyncThreadPool")
public void asyncProcessingOrderDetails(Order order, JSONObject loginUserInfo, List<OrderDetail> orderDetails, List<Product> productList) { public void asyncProcessingOrderDetails(Order order, String phoneNumber,String nickName, List<OrderDetail> orderDetails, List<Product> productList) {
Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, item -> item)); Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, item -> item));
List<ProductRecord> productRecords = SpringUtils.getBean(ProductRecordService.class).listByIds(orderDetails.stream().map(OrderDetail::getProductRecordId).collect(Collectors.toSet())); List<ProductRecord> productRecords = SpringUtils.getBean(ProductRecordService.class).listByIds(orderDetails.stream().map(OrderDetail::getProductRecordId).collect(Collectors.toSet()));
Map<String, ProductRecord> productRecordMap = productRecords.stream().collect(Collectors.toMap(ProductRecord::getId, item -> item)); Map<String, ProductRecord> 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("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 //模板id
jsonBody.put("templateId", product.getCardTemplateId()); jsonBody.put("templateId", product.getCardTemplateId());
//订单来源 //订单来源

View File

@ -48,6 +48,18 @@ public class ProductInfoVo implements Serializable {
@ApiModelProperty("商店(校区)集合") @ApiModelProperty("商店(校区)集合")
private String storeIds; private String storeIds;
/**
* 模板id
*/
@ApiModelProperty("模板Id")
private String cardTemplateId;
/**
* 模板名
*/
@ApiModelProperty("模板名")
private String cardTemplateName;
/** /**
* 描述 * 描述
*/ */