This commit is contained in:
admin
2024-08-01 16:03:15 +08:00
parent 8c759c73e8
commit 27d89957f2
5 changed files with 66 additions and 6 deletions

View File

@@ -1,11 +1,16 @@
package com.starry.admin.modules.order.controller; package com.starry.admin.modules.order.controller;
import com.starry.admin.common.exception.CustomException; import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity; import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
import com.starry.admin.modules.order.module.entity.PlayOrderRandomInfoEntity; import com.starry.admin.modules.order.module.entity.PlayOrderRandomInfoEntity;
import com.starry.admin.modules.order.module.vo.*; import com.starry.admin.modules.order.module.vo.*;
import com.starry.admin.modules.order.service.IPlayOrderInfoService; import com.starry.admin.modules.order.service.IPlayOrderInfoService;
import com.starry.admin.modules.order.service.IPlayOrderRandomInfoService; import com.starry.admin.modules.order.service.IPlayOrderRandomInfoService;
import com.starry.admin.modules.play.module.vo.PlayCommodityInfoVo;
import com.starry.admin.modules.play.service.IPlayCommodityInfoService;
import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.common.annotation.Log; import com.starry.common.annotation.Log;
import com.starry.common.context.CustomSecurityContextHolder; import com.starry.common.context.CustomSecurityContextHolder;
import com.starry.common.enums.BusinessType; import com.starry.common.enums.BusinessType;
@@ -31,6 +36,14 @@ public class PlayOrderInfoController {
@Resource @Resource
private IPlayOrderRandomInfoService playOrderRandomInfoService; private IPlayOrderRandomInfoService playOrderRandomInfoService;
@Resource
private WxCustomMpService wxCustomMpService;
@Resource
private IPlayClerkUserInfoService playClerkUserInfoService;
@Resource
private IPlayCommodityInfoService playCommodityInfoService;
/** /**
* 分页查询订单列表 * 分页查询订单列表
@@ -78,6 +91,10 @@ public class PlayOrderInfoController {
@PostMapping("/orderEditAcceptBy") @PostMapping("/orderEditAcceptBy")
public R orderEditAcceptBy(@Validated @RequestBody PlayOrderEditAcceptByVo vo) { public R orderEditAcceptBy(@Validated @RequestBody PlayOrderEditAcceptByVo vo) {
orderInfoService.updateStateTo1("2", CustomSecurityContextHolder.getUserId(), vo.getAcceptBy(), vo.getOrderId()); orderInfoService.updateStateTo1("2", CustomSecurityContextHolder.getUserId(), vo.getAcceptBy(), vo.getOrderId());
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.selectById(vo.getAcceptBy());
PlayOrderInfoEntity orderInfo = orderInfoService.selectOrderInfoById(vo.getOrderId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(orderInfo.getCommodityId());
wxCustomMpService.sendCreateOrderMessage(clerkUserInfo.getTenantId(), clerkUserInfo.getOpenid(), clerkUserInfo.getNickname(), orderInfo.getOrderNo(), orderInfo.getId(), String.valueOf(orderInfo.getPurchaserTime()), orderInfo.getOrderMoney().toString(), commodityInfo.getCommodityName());
return R.ok("操作成功"); return R.ok("操作成功");
} }

View File

@@ -647,8 +647,6 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
entity.setEstimatedRevenueRatio(estimatedRevenueVo.getRevenueRatio()); entity.setEstimatedRevenueRatio(estimatedRevenueVo.getRevenueRatio());
this.baseMapper.updateById(entity); this.baseMapper.updateById(entity);
// 接单后,发送微信消息 // 接单后,发送微信消息
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.selectById(acceptBy);
wxCustomMpService.sendOrderMessage(clerkUserInfo.getTenantId(), clerkUserInfo.getOpenid(), "1", clerkUserInfo.getNickname(), orderInfo.getOrderNo(), orderInfo.getId(), orderInfo.getOrderMoney().toString());
PlayCustomUserInfoEntity customUserInfo = playCustomUserInfoService.selectById(orderInfo.getPurchaserBy()); PlayCustomUserInfoEntity customUserInfo = playCustomUserInfoService.selectById(orderInfo.getPurchaserBy());
wxCustomMpService.sendOrderMessage(customUserInfo.getTenantId(), customUserInfo.getOpenid(), "0", customUserInfo.getNickname(), orderInfo.getOrderNo(), orderInfo.getId(), orderInfo.getOrderMoney().toString()); wxCustomMpService.sendOrderMessage(customUserInfo.getTenantId(), customUserInfo.getOpenid(), "0", customUserInfo.getNickname(), orderInfo.getOrderNo(), orderInfo.getId(), orderInfo.getOrderMoney().toString());
} }

View File

@@ -1,6 +1,7 @@
package com.starry.admin.modules.weichat.controller; package com.starry.admin.modules.weichat.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -43,6 +44,7 @@ import com.starry.admin.modules.weichat.entity.order.PlayCustomOrderInfoQueryVo;
import com.starry.admin.modules.weichat.entity.order.PlayCustomOrderListReturnVo; import com.starry.admin.modules.weichat.entity.order.PlayCustomOrderListReturnVo;
import com.starry.admin.modules.weichat.entity.order.PlayOrderInfoCommodityAdd; import com.starry.admin.modules.weichat.entity.order.PlayOrderInfoCommodityAdd;
import com.starry.admin.modules.weichat.entity.user.PlayCustomUserReturnDetailVo; import com.starry.admin.modules.weichat.entity.user.PlayCustomUserReturnDetailVo;
import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.admin.modules.weichat.service.WxCustomUserService; import com.starry.admin.modules.weichat.service.WxCustomUserService;
import com.starry.admin.utils.MoneyUtils; import com.starry.admin.utils.MoneyUtils;
import com.starry.common.result.R; import com.starry.common.result.R;
@@ -112,6 +114,9 @@ public class WxCustomController {
@Resource @Resource
private IPlayCouponInfoService playCouponInfoService; private IPlayCouponInfoService playCouponInfoService;
@Resource
private WxCustomMpService wxCustomMpService;
/** /**
* 根据店员ID查询店员详细信息 * 根据店员ID查询店员详细信息
@@ -296,11 +301,13 @@ public class WxCustomController {
throw new CustomException("余额不足"); throw new CustomException("余额不足");
} }
String orderId = IdUtils.getUuid(); String orderId = IdUtils.getUuid();
String orderNo = playOrderInfoService.getOrderNo();
// 记录订单信息 // 记录订单信息
playOrderInfoService.createOrderInfo(orderId, playOrderInfoService.getOrderNo(), "0", "2", "0", "", "1", commodityInfo.getCommodityId(), "1", commodityInfo.getCommodityPrice(), commodityInfo.getServiceDuration(), commodityInfo.getCommodityName(), String.valueOf(vo.getCommodityQuantity()), money, money, BigDecimal.ZERO, customId, clerkUserInfo.getId(), vo.getWeiChatCode(), vo.getCouponIds(), vo.getRemark()); playOrderInfoService.createOrderInfo(orderId, orderNo, "0", "2", "0", "", "1", commodityInfo.getCommodityId(), "1", commodityInfo.getCommodityPrice(), commodityInfo.getServiceDuration(), commodityInfo.getCommodityName(), String.valueOf(vo.getCommodityQuantity()), money, money, BigDecimal.ZERO, customId, clerkUserInfo.getId(), vo.getWeiChatCode(), vo.getCouponIds(), vo.getRemark());
// 顾客减少余额 // 顾客减少余额
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(money), "1", "下单-指定单", money, BigDecimal.ZERO, orderId); customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(money), "1", "下单-指定单", money, BigDecimal.ZERO, orderId);
//发送通知给店员
wxCustomMpService.sendCreateOrderMessage(clerkUserInfo.getTenantId(), clerkUserInfo.getOpenid(), clerkUserInfo.getNickname(), orderNo, orderId, DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), money.toString(), commodityInfo.getCommodityName());
return R.ok("成功"); return R.ok("成功");
} }

View File

@@ -160,7 +160,7 @@ public class WxPlayController {
// 用户信息 // 用户信息
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(ThreadLocalRequestDetail.getCustomUserInfo().getId()); PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(ThreadLocalRequestDetail.getCustomUserInfo().getId());
// 租户信息 // 租户信息
SysTenantEntity entity = tenantService.selectSysTenantByTenantId(tenantId); // SysTenantEntity entity = tenantService.selectSysTenantByTenantId(tenantId);
// 订单总金额,单位为分 // 订单总金额,单位为分
long totalFee = getTotalFee(money); long totalFee = getTotalFee(money);
// 创建订单信息 // 创建订单信息

View File

@@ -115,6 +115,44 @@ public class WxCustomMpService {
} }
} }
/**
* 顾客下指定单后,给店员发新订单通知
* 通过微信公众号发送消息
*
* @param tenantId 租户ID
* @param openId 消息接收人openID
* @param nickName 消息内容-消息接收人昵称
* @param orderNo 消息内容-订单编号
* @param orderId 消息内容-订单ID
* @param orderTime 消息内容-下单时间
* @param orderAmount 消息内容-订单金额
* @param commodityName 消息内容-服务项目名称
*/
public void sendCreateOrderMessage(String tenantId, String openId, String nickName, String orderNo, String orderId, String orderTime, String orderAmount, String commodityName) {
SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(tenantId);
String template_id = tenant.getXdcgtzTemplateId();
String tenantKey = tenant.getTenantKey();
String url = "http://" + tenantKey + ".july.hucs.top/clerk/#/orderDetail/" + orderId;
WxMpTemplateMessage templateMessage = new WxMpTemplateMessage();
templateMessage.setTemplateId(template_id);
templateMessage.setToUser(openId);
templateMessage.setUrl(url);
List<WxMpTemplateData> data = new ArrayList<>();
data.add(new WxMpTemplateData("time5", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")));
data.add(new WxMpTemplateData("thing6", commodityName));
data.add(new WxMpTemplateData("amount8", orderAmount));
data.add(new WxMpTemplateData("thing12", nickName));
data.add(new WxMpTemplateData("character_string2", orderNo));
data.add(new WxMpTemplateData("time7", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")));
templateMessage.setData(data);
try {
proxyWxMpService().getTemplateMsgService().sendTemplateMsg(templateMessage);
} catch (WxErrorException e) {
log.error(e.getMessage(), e);
}
}
/** /**
* 通过微信公众号发送消息 * 通过微信公众号发送消息
* *
@@ -125,7 +163,7 @@ public class WxCustomMpService {
* @param orderNo 消息内容-订单编号 * @param orderNo 消息内容-订单编号
* @param orderId 消息内容-订单ID * @param orderId 消息内容-订单ID
* @param orderAmount 消息内容-订单金额 * @param orderAmount 消息内容-订单金额
* @author 杭州世平信息科技有限公司-xuhq * @author admin
* @since 2024/7/31 10:51 * @since 2024/7/31 10:51
**/ **/
public void sendOrderMessage(String tenantId, String openId, String userType, String nickName, String orderNo, String orderId, String orderAmount) { public void sendOrderMessage(String tenantId, String openId, String userType, String nickName, String orderNo, String orderId, String orderAmount) {