Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2025-05-08 10:48:20 +08:00
commit 5972d6c7b9
34 changed files with 538 additions and 45 deletions

View File

@ -1,5 +1,7 @@
package com.bonus.canteen.core.account.constants;
import com.bonus.canteen.core.pay.constants.PayTypeEnum;
public enum AccTradeTypeEnum {
RECHARGE(10, "充值"),
SUBSIDY(20, "补贴"),
@ -23,4 +25,13 @@ public enum AccTradeTypeEnum {
public String getDesc() {
return this.desc;
}
public static String getDescByKey(Integer targetKey) {
for (AccTradeTypeEnum tradeType : AccTradeTypeEnum.values()) {
if (tradeType.getKey().equals(targetKey)) {
return tradeType.getDesc();
}
}
return "";
}
}

View File

@ -88,7 +88,7 @@ public class AccCardController extends BaseController {
accCard.setOperationType(CardRecordTypeEnum.APPLY.getKey());
return toAjax(accCardService.insertAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -104,7 +104,7 @@ public class AccCardController extends BaseController {
try {
return toAjax(accCardService.updateAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -118,7 +118,7 @@ public class AccCardController extends BaseController {
accCard.setOperationType(CardRecordTypeEnum.CHANGE.getKey());
return toAjax(accCardService.updateAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -133,7 +133,7 @@ public class AccCardController extends BaseController {
accCard.setCardStatus(CardStatusEnum.LOSS.getKey());
return toAjax(accCardService.updateAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -148,7 +148,7 @@ public class AccCardController extends BaseController {
accCard.setCardStatus(CardStatusEnum.NORMAL.getKey());
return toAjax(accCardService.updateAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -163,7 +163,7 @@ public class AccCardController extends BaseController {
accCard.setCardStatus(CardStatusEnum.REFUND.getKey());
return toAjax(accCardService.updateAccCard(accCard));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}

View File

@ -2,6 +2,8 @@ package com.bonus.canteen.core.account.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.canteen.core.account.domain.param.AccConsumeDetailQueryParam;
import com.bonus.common.log.enums.OperaType;
import com.bonus.canteen.core.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
@ -116,4 +118,17 @@ public class AccTradeController extends BaseController {
public AjaxResult remove(@PathVariable Long[] tradeIds) {
return toAjax(accTradeService.deleteAccTradeByTradeIds(tradeIds));
}
/**
* 账户消费记录
*/
@ApiOperation(value = "账户消费记录")
//@PreventRepeatSubmit
//@RequiresPermissions("account:trade:remove")
@SysLog(title = "账户消费记录", businessType = OperaType.QUERY, logType = 1,module = "账户->账户消费记录")
@PostMapping("/consume/detail")
public TableDataInfo consumeDetail(@RequestBody AccConsumeDetailQueryParam param) {
startPage();
return getDataTable(accTradeService.queryAccConsumeDetail(param));
}
}

View File

@ -0,0 +1,29 @@
package com.bonus.canteen.core.account.domain.param;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class AccConsumeDetailQueryParam extends BaseEntity {
@ApiModelProperty("查询组织id集合")
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
@ApiModelProperty("交易类型")
private Integer tradeType;
private Integer walletId;
private String searchValue;
public AccConsumeDetailQueryParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,67 @@
package com.bonus.canteen.core.account.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class AccConsumeDetailVO implements Serializable {
private Long tradeId;
/**
* 用户ID
*/
private Long userId;
/**
* 用户昵称
*/
private String nickName;
/**
* 部门全名
*/
private String deptFullName;
/**
* 用户类型
*/
private Integer userType;
/**
* 支付时间
*/
private LocalDateTime payTime;
/**
* 下单时间
*/
private LocalDateTime orderTime;
/**
* 交易类型
*/
private Integer tradeType;
/**
* 钱包ID
*/
private Long walletId;
/**
* 金额
*/
private BigDecimal amount;
/**
* 钱包余额
*/
private BigDecimal walletBal;
/**
* 来源类型
*/
private Integer sourceType;
}

View File

@ -13,6 +13,8 @@ public interface AccCardMapper {
public int selectAccCardCountByUserId(Long userId);
public int selectAccCardCountByCardSerialNum(String serialNum);
/**
* 查询人员卡片资料
*

View File

@ -3,7 +3,9 @@ package com.bonus.canteen.core.account.mapper;
import java.util.List;
import com.bonus.canteen.core.account.domain.AccTrade;
import com.bonus.canteen.core.account.domain.bo.TradeAndWallerInfo;
import com.bonus.canteen.core.account.domain.param.AccConsumeDetailQueryParam;
import com.bonus.canteen.core.account.domain.param.AccWalletOperationQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccConsumeDetailVO;
import com.bonus.canteen.core.account.domain.vo.AccOperationListVO;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import org.apache.ibatis.annotations.Param;
@ -74,4 +76,7 @@ public interface AccTradeMapper {
List<TradeAndWallerInfo> queryTradeAndWallerInfoByOrderNo(@Param("orderNo") String orderNo,
@Param("accTradeType") Integer accTradeType);
List<AccConsumeDetailVO> queryAccConsumeDetail(@Param("param") AccConsumeDetailQueryParam param,
@Param("encryptedSearchValue") String encryptedSearchValue);
}

View File

@ -3,9 +3,12 @@ package com.bonus.canteen.core.account.service;
import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
import com.bonus.canteen.core.account.domain.AccTrade;
import com.bonus.canteen.core.account.domain.bo.TradeAndWallerInfo;
import com.bonus.canteen.core.account.domain.param.AccConsumeDetailQueryParam;
import com.bonus.canteen.core.account.domain.param.AccWalletOperationQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccConsumeDetailVO;
import com.bonus.canteen.core.account.domain.vo.AccOperationListVO;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -73,4 +76,6 @@ public interface IAccTradeService {
List<AccOperationListVO> queryAccOperationList(AccWalletOperationQueryParam param);
List<TradeAndWallerInfo> queryTradeAndWallerInfoByOrderNo(String orderNo, AccTradeTypeEnum accTradeTypeEnum);
List<AccConsumeDetailVO> queryAccConsumeDetail(AccConsumeDetailQueryParam param);
}

View File

@ -78,16 +78,21 @@ public class AccCardServiceImpl implements IAccCardService {
accCard.setUserId(accInfo.getUserId());
accCard.setCardStatus(CardStatusEnum.NORMAL.getKey());
accCard.setCardType(CardTypeEnum.IC_CARD.getKey());
// 发卡前校验是否卡已存在, 已退卡的可以再发放
// 发卡前校验是否此用户已有卡, 已退卡已过期的可以再发放
int cardCountByUserId= accCardMapper.selectAccCardCountByUserId(accInfo.getUserId());
if (cardCountByUserId > 0) {
throw new ServiceException("用户(user_id=" + accInfo.getUserId() + ")已有卡, 不能再次发放");
throw new ServiceException("此用户已有卡, 不能再次发放");
}
// 发卡前校验是否卡号已存在, 卡号不能重复
int cardCountByCardSerialNum= accCardMapper.selectAccCardCountByCardSerialNum(accCard.getSerialNum());
if (cardCountByCardSerialNum > 0) {
throw new ServiceException("卡号已存在, 卡号不能重复");
}
int count = accCardMapper.insertAccCard(accCard);
saveAccCardChangeRecord(accCard);
return count;
} catch (Exception e) {
throw new ServiceException("发卡异常, " + e.getMessage());
throw new ServiceException(e.getMessage());
}
}
@ -131,6 +136,11 @@ public class AccCardServiceImpl implements IAccCardService {
accCard.setUpdateBy(SecurityUtils.getUsername());
accCard.setUpdateTime(DateUtils.getNowDate());
try {
// 发卡前校验是否卡号已存在, 卡号不能重复
int cardCountByCardSerialNum= accCardMapper.selectAccCardCountByCardSerialNum(accCard.getSerialNum());
if (cardCountByCardSerialNum > 0) {
throw new ServiceException("卡号已存在, 卡号不能重复");
}
AccInfo accInfo = accInfoMapper.selectAccInfoById(accCard.getAccId());
checkAccInfoAndStatus(accInfo);
int count = accCardMapper.updateAccCard(accCard);
@ -144,7 +154,7 @@ public class AccCardServiceImpl implements IAccCardService {
}
return count;
} catch (Exception e) {
throw new ServiceException("更新异常, " + e.getMessage());
throw new ServiceException(e.getMessage());
}
}

View File

@ -4,7 +4,9 @@ import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
import com.bonus.canteen.core.account.domain.AccTrade;
import com.bonus.canteen.core.account.domain.bo.TradeAndWallerInfo;
import com.bonus.canteen.core.account.domain.param.AccConsumeDetailQueryParam;
import com.bonus.canteen.core.account.domain.param.AccWalletOperationQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccConsumeDetailVO;
import com.bonus.canteen.core.account.domain.vo.AccOperationListVO;
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
import com.bonus.canteen.core.account.mapper.AccTradeMapper;
@ -152,4 +154,10 @@ public class AccTradeServiceImpl implements IAccTradeService {
public List<TradeAndWallerInfo> queryTradeAndWallerInfoByOrderNo(String orderNo, AccTradeTypeEnum accTradeTypeEnum) {
return accTradeMapper.queryTradeAndWallerInfoByOrderNo(orderNo, accTradeTypeEnum.getKey());
}
@Override
public List<AccConsumeDetailVO> queryAccConsumeDetail(AccConsumeDetailQueryParam param) {
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(param.getSearchValue());
return accTradeMapper.queryAccConsumeDetail(param, encryptedSearchValue);
}
}

View File

@ -83,7 +83,7 @@ public class AllocCanteenController extends BaseController {
try {
return toAjax(allocCanteenService.insertAllocCanteen(allocCanteen));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -99,7 +99,7 @@ public class AllocCanteenController extends BaseController {
try {
return toAjax(allocCanteenService.updateAllocCanteen(allocCanteen));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}

View File

@ -83,7 +83,7 @@ public class AllocStallController extends BaseController {
try {
return toAjax(allocStallService.insertAllocStall(allocStall));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}
@ -99,7 +99,7 @@ public class AllocStallController extends BaseController {
try {
return toAjax(allocStallService.updateAllocStall(allocStall));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
return error(e.getMessage());
}
}

View File

@ -19,9 +19,6 @@ import com.bonus.common.core.web.domain.BaseEntity;
public class AllocCanteenSuggestion extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键自增 */
private Long id;
/** 投诉建议id */
@Excel(name = "投诉建议id")
@ApiModelProperty(value = "投诉建议id")

View File

@ -52,6 +52,9 @@ public class AllocCanteenEvaluateServiceImpl implements IAllocCanteenEvaluateSer
@Override
public int insertAllocCanteenEvaluate(AllocCanteenEvaluate allocCanteenEvaluate) {
allocCanteenEvaluate.setCreateTime(DateUtils.getNowDate());
allocCanteenEvaluate.setCreateBy(SecurityUtils.getUsername());
allocCanteenEvaluate.setUserId(SecurityUtils.getUserId());
allocCanteenEvaluate.setEvaluateDate(DateUtils.getNowDate());
try {
return allocCanteenEvaluateMapper.insertAllocCanteenEvaluate(allocCanteenEvaluate);
} catch (Exception e) {
@ -68,6 +71,7 @@ public class AllocCanteenEvaluateServiceImpl implements IAllocCanteenEvaluateSer
@Override
public int updateAllocCanteenEvaluate(AllocCanteenEvaluate allocCanteenEvaluate) {
allocCanteenEvaluate.setUpdateTime(DateUtils.getNowDate());
allocCanteenEvaluate.setUpdateBy(SecurityUtils.getUsername());
try {
return allocCanteenEvaluateMapper.updateAllocCanteenEvaluate(allocCanteenEvaluate);
} catch (Exception e) {

View File

@ -67,11 +67,11 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService {
try {
AllocCanteen checkResult = allocCanteenMapper.selectAllocCanteenByCanteenName(allocCanteen);
if (Objects.nonNull(checkResult)) {
throw new ServiceException("食堂名称已存在");
throw new ServiceException("该区域食堂名称已存在");
}
return allocCanteenMapper.insertAllocCanteen(allocCanteen);
} catch (Exception e) {
throw new ServiceException("新增食堂异常," + e.getMessage());
throw new ServiceException(e.getMessage());
}
}
@ -90,11 +90,11 @@ public class AllocCanteenServiceImpl implements IAllocCanteenService {
.filter(item -> item.getAreaId().equals(allocCanteen.getAreaId()))
.map(AllocCanteen::getCanteenName).collect(Collectors.toList());
if (otherCanteenNameList.contains(allocCanteen.getCanteenName())) {
throw new ServiceException("食堂名称已存在");
throw new ServiceException("该区域食堂名称已存在");
}
return allocCanteenMapper.updateAllocCanteen(allocCanteen);
} catch (Exception e) {
throw new ServiceException("更新食堂异常," + e.getMessage());
throw new ServiceException(e.getMessage());
}
}

View File

@ -1,8 +1,11 @@
package com.bonus.canteen.core.alloc.service.impl;
import java.util.List;
import com.bonus.canteen.core.nutrition.common.enums.YesOrNoEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.alloc.mapper.AllocCanteenSuggestionMapper;
@ -51,6 +54,10 @@ public class AllocCanteenSuggestionServiceImpl implements IAllocCanteenSuggestio
@Override
public int insertAllocCanteenSuggestion(AllocCanteenSuggestion allocCanteenSuggestion) {
allocCanteenSuggestion.setCreateTime(DateUtils.getNowDate());
allocCanteenSuggestion.setCreateBy(SecurityUtils.getUsername());
allocCanteenSuggestion.setUserId(SecurityUtils.getUserId());
allocCanteenSuggestion.setSourceType(7L);
allocCanteenSuggestion.setReplyState(YesOrNoEnum.NO.key().longValue());
try {
return allocCanteenSuggestionMapper.insertAllocCanteenSuggestion(allocCanteenSuggestion);
} catch (Exception e) {
@ -67,6 +74,7 @@ public class AllocCanteenSuggestionServiceImpl implements IAllocCanteenSuggestio
@Override
public int updateAllocCanteenSuggestion(AllocCanteenSuggestion allocCanteenSuggestion) {
allocCanteenSuggestion.setUpdateTime(DateUtils.getNowDate());
allocCanteenSuggestion.setUpdateBy(SecurityUtils.getUsername());
try {
return allocCanteenSuggestionMapper.updateAllocCanteenSuggestion(allocCanteenSuggestion);
} catch (Exception e) {

View File

@ -63,7 +63,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
try {
AllocStall checkResult = allocStallMapper.selectAllocStallByStallName(allocStall);
if (Objects.nonNull(checkResult)) {
throw new ServiceException("档口名称已存在");
throw new ServiceException("该食堂档口名称已存在");
}
int stallCount = allocStallMapper.insertAllocStall(allocStall);
if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) {
@ -74,7 +74,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
}
return stallCount;
} catch (Exception e) {
throw new ServiceException("新增档口异常," + e.getMessage());
throw new ServiceException(e.getMessage());
}
}
@ -93,7 +93,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
.filter(item -> item.getCanteenId().equals(allocStall.getCanteenId()))
.map(AllocStall::getStallName).collect(Collectors.toList());
if (otherStallNameList.contains(allocStall.getStallName())) {
throw new ServiceException("档口名称已存在");
throw new ServiceException("该食堂档口名称已存在");
}
int stallCount = allocStallMapper.updateAllocStall(allocStall);
if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) {
@ -102,7 +102,7 @@ public class AllocStallServiceImpl implements IAllocStallService {
}
return stallCount;
} catch (Exception e) {
throw new ServiceException("更新档口异常," + e.getMessage());
throw new ServiceException(e.getMessage());
}
}

View File

@ -56,7 +56,7 @@ public class OrderBusiness {
@Autowired
private IAccWalletInfoService accWalletInfoService;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
@Transactional(rollbackFor = Exception.class)
public List<OrderInfo> orderPlaceHandler(List<OrderInfo> orderInfoList) {
if(CollUtil.isEmpty(orderInfoList)) {
throw new ServiceException("订单明细不能为空");
@ -128,6 +128,9 @@ public class OrderBusiness {
for(OrderInfo orderInfo : orderInfoList) {
deductFromWallets(orderInfo, subsidyWalletBal);
}
} catch (ServiceException ex) {
log.error("订单支付异常", ex);
throw new ServiceException(ex.getMessage());
} catch (Exception ex) {
log.error("订单支付异常", ex);
throw new ServiceException("支付失败");

View File

@ -4,7 +4,7 @@ public enum OrderTypeEnum {
CURR_MEAL(1, "当餐点餐"),
RESERVE_MEAL(2, "预订餐"),
BOOK_MEAL(3, "自定义报餐"),
SHOP(4, ""),
SHOP(4, ""),
RESERVE_SHOP(5, "预订商城"),
ROOM(6, "包间"),
TABLE(7, "餐桌"),

View File

@ -70,6 +70,8 @@ public class OrderInfoController extends BaseController
if(Objects.isNull(orderQueryParam) || CollUtil.isEmpty(orderQueryParam.getOrderTypeList())) {
throw new ServiceException("订单类型不能为空");
}
orderQueryParam.setStartDateTime(orderQueryParam.getStartDate().atTime(0,0,0));
orderQueryParam.setEndDateTime(orderQueryParam.getEndDate().atTime(23,59,59));
startPage();
List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderQueryParam);
return getDataTable(list);
@ -130,7 +132,18 @@ public class OrderInfoController extends BaseController
@ResponseBody
public AjaxResult addSave(@RequestBody @Valid OrderAddParam orderAddParam)
{
return toAjax(orderInfoService.insertCanteenOrderInfo(orderAddParam));
try {
orderInfoService.insertCanteenOrderInfo(orderAddParam);
}catch (ServiceException ex) {
if(Integer.valueOf(500001).equals(ex.getCode())) {
return AjaxResult.success(ex.getMessage());
}else {
return AjaxResult.error(ex.getMessage());
}
}catch (Exception ex) {
return AjaxResult.error("下单失败");
}
return AjaxResult.success();
}
@SysLog(title = "下单", module = "订单", businessType = OperaType.INSERT)

View File

@ -180,6 +180,12 @@ public class OrderInfo extends BaseEntity
private String nickName;
private String phoneNumber;
private String deptFullName;
private String areaName;
List<OrderDetail> orderDetailList;
public List<OrderInfo> of(OrderAddParam param) {

View File

@ -14,11 +14,13 @@ public class OrderRefundHistoryVO implements Serializable {
private Long orderId;
private BigDecimal realAmount;
private LocalDateTime payTime;
private String payType;
private Integer payType;
private String payTypeName;
@JsonIgnore
private Long tradeId;
private BigDecimal actualAmount;
private String tradeType;
private Integer tradeType;
private String tradeTypeName;
private LocalDateTime tradeTime;
private String updateBy;
}

View File

@ -1,13 +1,16 @@
package com.bonus.canteen.core.order.domain.param;
import com.alibaba.excel.util.StringUtils;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
@ -52,6 +55,8 @@ public class OrderQueryParam implements Serializable
/** 是否在线订单 1 是 2 否 */
private Integer isOnline;
private Long areaId;
/** 食堂id */
private Long canteenId;
@ -117,10 +122,29 @@ public class OrderQueryParam implements Serializable
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
private String searchValue;
private String custSearchInfo;
private String goodsSearchInfo;
private String encryptedCustSearchValue;
public OrderQueryParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
this.endDate = LocalDate.now().plusDays(7);
this.startDate = LocalDate.now().minusDays(7);
if(StringUtils.isNotBlank(custSearchInfo)) {
this.encryptedCustSearchValue = SM4EncryptUtils.sm4Encrypt(custSearchInfo);
}
}
}

View File

@ -12,6 +12,8 @@ import com.bonus.canteen.core.account.service.IAccInfoService;
import com.bonus.canteen.core.account.service.IAccTradeService;
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
import com.bonus.canteen.core.account.utils.AccRedisUtils;
import com.bonus.canteen.core.alloc.domain.AllocStall;
import com.bonus.canteen.core.alloc.service.IAllocStallService;
import com.bonus.canteen.core.common.utils.MqUtil;
import com.bonus.canteen.core.common.utils.RedisUtil;
import com.bonus.canteen.core.order.business.OrderBusiness;
@ -30,9 +32,11 @@ import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.constant.SourceTypeEnum;
import com.bonus.common.houqin.mq.constant.LeMqConstant;
import com.bonus.common.houqin.utils.JacksonUtil;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -69,6 +73,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService
private OrderBusiness orderBusiness;
@Autowired
private IAccWalletInfoService accWalletInfoService;
@Autowired
private IAllocStallService allocStallService;
/**
* 查询订单
@ -119,6 +125,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
orderDetail.setOrderId(order.getOrderId());
List<OrderDetail> orderDetailList = orderDetailService.selectOrderDetailList(orderDetail);
order.setOrderDetailList(orderDetailList);
order.setPhoneNumber(SM4EncryptUtils.sm4Decrypt(order.getPhoneNumber()));
});
}
return orderInfoList;
@ -135,6 +142,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId());
accInfoService.checkAccStatus(accInfoVO);
List<OrderInfo> canteenOrderInfoList = new OrderInfo().of(orderAddParam);
checkStallStatus(canteenOrderInfoList);
checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount());
List<OrderInfo> orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList);
try {
@ -142,13 +150,14 @@ public class OrderInfoServiceImpl implements IOrderInfoService
orderBusiness.orderPay(orderInfoList);
}catch (Exception ex) {
orderBusiness.updateOrderPayFailed(orderInfoList);
throw new ServiceException(ex.getMessage());
throw new ServiceException(ex.getMessage(), 500001);
}finally {
AccRedisUtils.unlockUpdateAccWalletBalance(orderAddParam.getUserId());
}
return 1;
}
@Override
@Transactional(rollbackFor = {Exception.class})
public int insertDeviceOrderInfo(DeviceOrderAddParam orderAddParam) {
log.info("[食堂设备下单]入参:{}", JacksonUtil.writeValueAsString(orderAddParam));
String paramMd5 = "sc:device_order_"+DigestUtil.md5Hex(JacksonUtil.writeValueAsString(orderAddParam));
@ -159,6 +168,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId());
accInfoService.checkAccStatus(accInfoVO);
List<OrderInfo> canteenOrderInfoList = new OrderInfo().of(orderAddParam);
checkStallStatus(canteenOrderInfoList);
checkDeviceOrderExisting(canteenOrderInfoList);
checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount());
List<OrderInfo> orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList);
@ -175,6 +185,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
}
@Override
@Transactional(rollbackFor = {Exception.class})
public int insertShopOrderInfo(ShopOrderAddParam orderAddParam) {
log.info("[超市下单]入参:{}", JacksonUtil.writeValueAsString(orderAddParam));
String paramMd5 = "sc:shop_order_"+DigestUtil.md5Hex(JacksonUtil.writeValueAsString(orderAddParam));
@ -211,6 +222,25 @@ public class OrderInfoServiceImpl implements IOrderInfoService
}
}
private void checkStallStatus(List<OrderInfo> orderInfoList) {
if(CollUtil.isEmpty(orderInfoList)) {
throw new ServiceException("订单不能为空");
}
for(OrderInfo orderInfo : orderInfoList) {
if(orderInfo.getIsOnline() == 1) {
AllocStall allocStall = allocStallService.selectAllocStallByStallId(orderInfo.getStallId());
if(Objects.isNull(allocStall) || DelFlagEnum.DEL_TRUE.key().toString().equals(allocStall.getDelFlag())) {
throw new ServiceException("档口不存在");
}
if(1 == allocStall.getBusinessState()) {
throw new ServiceException("档口已休息");
}
}
}
}
@Override
public void pay(Long orderId) {
if(Objects.isNull(orderId) || orderId <= 0) {
@ -245,7 +275,14 @@ public class OrderInfoServiceImpl implements IOrderInfoService
@Override
public List<OrderRefundHistoryVO> orderRefundHistory(OrderRefundHistoryParam param) {
return orderInfoMapper.orderRefundHistory(param);
List<OrderRefundHistoryVO> list = orderInfoMapper.orderRefundHistory(param);
if(CollUtil.isNotEmpty(list)) {
list.forEach(orderRefundHistoryVO -> {
orderRefundHistoryVO.setPayTypeName(PayTypeEnum.getDescByKey(orderRefundHistoryVO.getPayType()));
orderRefundHistoryVO.setTradeTypeName(AccTradeTypeEnum.getDescByKey(orderRefundHistoryVO.getTradeType()));
});
}
return list;
}
@Override

View File

@ -119,5 +119,13 @@ public enum PayTypeEnum {
return this.desc;
}
public static String getDescByKey(Integer targetKey) {
for (PayTypeEnum payType : PayTypeEnum.values()) {
if (payType.getKey().equals(targetKey)) {
return payType.getDesc();
}
}
return "";
}
}

View File

@ -1,5 +1,9 @@
package com.bonus.canteen.core.supermarket.controller;
import com.bonus.canteen.core.order.domain.OrderInfo;
import com.bonus.canteen.core.order.domain.param.OrderQueryParam;
import com.bonus.canteen.core.order.service.IOrderInfoService;
import com.bonus.canteen.core.supermarket.domain.ShopOrderQueryParam;
import com.bonus.canteen.core.supermarket.domain.SupermarketInfo;
import com.bonus.canteen.core.supermarket.service.SupermarketInfoService;
import com.bonus.common.core.utils.poi.ExcelUtil;
@ -10,10 +14,12 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
/**
@ -28,6 +34,8 @@ import java.util.List;
public class SupermarketInfoController extends BaseController {
@Autowired
private SupermarketInfoService supermarketInfoService;
@Autowired
private IOrderInfoService orderInfoService;
/**
* @author jsk
@ -86,4 +94,16 @@ public class SupermarketInfoController extends BaseController {
return toAjax(supermarketInfoService.deleteSupermarketInfoBySupermarketId(supermarketInfo));
}
@ApiOperation(value = "查询超市订单列表")
@PostMapping("/order/list")
public TableDataInfo orderList(@RequestBody @Valid ShopOrderQueryParam shopOrderQueryParam) {
startPage();
shopOrderQueryParam.setStartDateTime(shopOrderQueryParam.getStartDate().atTime(0,0,0));
shopOrderQueryParam.setEndDateTime(shopOrderQueryParam.getEndDate().atTime(23,59,59));
OrderQueryParam orderQueryParam = new OrderQueryParam();
BeanUtils.copyProperties(shopOrderQueryParam, orderQueryParam);
List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderQueryParam);
return getDataTable(list);
}
}

View File

@ -0,0 +1,137 @@
package com.bonus.canteen.core.supermarket.domain;
import com.alibaba.excel.util.StringUtils;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
* 订单对象 order_info
*
* @author ruoyi
* @date 2025-04-14
*/
@Data
public class ShopOrderQueryParam implements Serializable
{
private static final long serialVersionUID = 1L;
/** 设备订单号 */
private String deviceOrderId;
/** 设备sn */
private String deviceSn;
private Long orderId;
private List<Long> orderIdList;
private List<Long> deptIdList;
/** 设备编号 */
private String deviceNum;
/** 人员编号 */
private Long userId;
/** 身份验证方式 1 刷卡 2 刷脸 3 扫码 */
private Integer identityVerification;
/** 订单来源类型 */
private Integer sourceType;
/** 是否在线订单 1 是 2 否 */
private Integer isOnline;
private Long areaId;
/** 食堂id */
private Long canteenId;
private List<Long> canteenIdList;
/** 档口id */
private Long stallId;
private List<Long> stallIdList;
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
private Integer mealtimeType;
private List<Integer> mealtimeTypeList;
/** 订单日期 yyyy-MM-dd */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date orderDate;
/** 下单时间 yyyy-MM-dd HH:mm:ss */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date orderTime;
/** 订单类型 1 当餐 2 预订餐 3 报餐 4 商城 11 线下消费 12 自助餐 21 补扣 22 外部订单 */
@NotNull(message = "订单类型不能为空")
private Integer orderType;
private List<Integer> orderTypeList;
/** 订单状态 1 已下单 2 已完成 3 已取消 */
private Integer orderState;
private List<Integer> orderStateList;
/** 订单退款状态 1 未退单 2 已退单 3 部分退单 */
private Integer orderRefundState;
/** 扣款类型 1 下单扣款 2 核销扣款 */
private Integer deductionType;
/** 支付时间 yyyy-MM-dd HH:mm:ss */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date payTime;
/** 支付方式 */
private Integer payType;
/** 支付渠道 */
private Integer payChannel;
/** 支付状态 1 待支付 2 支付中 3 支付成功 4 支付失败 5 支付取消 6 部分支付 */
private Integer payState;
private List<Integer> payStateList;
/** 评论状态 1 已评论 2 未评论 */
private Integer commentState;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
private String custSearchInfo;
public ShopOrderQueryParam() {
this.endDate = LocalDate.now().plusDays(7);
this.startDate = LocalDate.now().minusDays(7);
}
}

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.user.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.utils.id.Id;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -54,6 +55,7 @@ public class UserAddrServiceImpl implements IUserAddrService {
public int insertUserAddr(UserAddr userAddr) {
userAddr.setCreateTime(DateUtils.getNowDate());
userAddr.setUserId(SecurityUtils.getUserId());
userAddr.setAddrId(Id.next());
try {
return userAddrMapper.insertUserAddr(userAddr);
} catch (Exception e) {

View File

@ -70,6 +70,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where user_id = #{userId} and card_status in (1,4,5)
</select>
<select id="selectAccCardCountByCardSerialNum" parameterType="String" resultType="Integer">
select count(1)
from acc_card
where serial_num = #{serialNum}
</select>
<select id="selectAccCardById" parameterType="Long" resultMap="AccCardResult">
<include refid="selectAccCardVo"/>
where ac.id = #{id}

View File

@ -294,4 +294,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ate.trade_type = #{accTradeType}
</select>
<select id="queryAccConsumeDetail" resultType="com.bonus.canteen.core.account.domain.vo.AccConsumeDetailVO">
select
at2.trade_id,
su.user_id,
su.nick_name,
sd.dept_full_name,
su.user_type,
oi.pay_time,
oi.order_time,
at2.trade_type,
atwd.wallet_id,
atwd.amount,
atwd.wallet_bal,
oi.source_type
from
order_info oi
inner join acc_trade at2 on
oi.order_id = at2.order_no
inner join acc_trade_wallet_detail atwd on
atwd.trade_id = at2.trade_id
inner join sys_user su on
oi.user_id = su.user_id
inner join sys_dept sd on
su.dept_id = sd.dept_id
where
atwd.trade_type in (110, 130)
and oi.order_state in (1, 2, 3)
and oi.pay_state = 3
<if test="param.tradeType != null">
and at2.trade_type = #{param.tradeType}
</if>
<if test="param.walletId != null">
and atwd.wallet_id = #{param.walletId}
</if>
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and sd.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.startDateTime != null">
and at2.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
</if>
<if test="param.endDateTime != null">
and at2.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
</if>
<if test="param.searchValue != null and param.searchValue != ''">
and (su.nick_name like CONCAT('%',#{param.searchValue},'%')
or su.phonenumber = #{encryptedSearchValue}
or su.user_id like CONCAT('%',#{param.searchValue},'%')
)
</if>
order by
oi.pay_time desc
</select>
</mapper>

View File

@ -4,7 +4,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.alloc.mapper.AllocCanteenSuggestionMapper">
<resultMap type="com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion" id="AllocCanteenSuggestionResult">
<result property="id" column="id" />
<result property="complaintId" column="complaint_id" />
<result property="userId" column="user_id" />
<result property="content" column="content" />
@ -22,7 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAllocCanteenSuggestionVo">
select id, complaint_id, user_id, content, canteen_id, complaint_picture, source_type, mobile, reply_content, revision, reply_state, create_by, create_time, update_by, update_time from alloc_canteen_suggestion
select complaint_id, user_id, content, canteen_id, complaint_picture, source_type, mobile,
reply_content, revision, reply_state, create_by, create_time, update_by, update_time
from alloc_canteen_suggestion
</sql>
<select id="selectAllocCanteenSuggestionList" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion" resultMap="AllocCanteenSuggestionResult">
@ -43,13 +44,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAllocCanteenSuggestionById" parameterType="Long" resultMap="AllocCanteenSuggestionResult">
<include refid="selectAllocCanteenSuggestionVo"/>
where id = #{id}
where complaint_id = #{complaintId}
</select>
<insert id="insertAllocCanteenSuggestion" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion" useGeneratedKeys="true" keyProperty="id">
<insert id="insertAllocCanteenSuggestion" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion" useGeneratedKeys="true" keyProperty="complaintId">
insert into alloc_canteen_suggestion
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="complaintId != null">complaint_id,</if>
<if test="userId != null">user_id,</if>
<if test="content != null and content != ''">content,</if>
<if test="canteenId != null">canteen_id,</if>
@ -65,7 +65,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="complaintId != null">#{complaintId},</if>
<if test="userId != null">#{userId},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="canteenId != null">#{canteenId},</if>
@ -85,7 +84,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateAllocCanteenSuggestion" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenSuggestion">
update alloc_canteen_suggestion
<trim prefix="SET" suffixOverrides=",">
<if test="complaintId != null">complaint_id = #{complaintId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="canteenId != null">canteen_id = #{canteenId},</if>
@ -100,17 +98,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
where complaint_id = #{complaintId}
</update>
<delete id="deleteAllocCanteenSuggestionById" parameterType="Long">
delete from alloc_canteen_suggestion where id = #{id}
delete from alloc_canteen_suggestion where complaint_id = #{complaintId}
</delete>
<delete id="deleteAllocCanteenSuggestionByIds" parameterType="String">
delete from alloc_canteen_suggestion where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
delete from alloc_canteen_suggestion where complaint_id in
<foreach item="complaintId" collection="array" open="(" separator="," close=")">
#{complaintId}
</foreach>
</delete>
</mapper>

View File

@ -57,11 +57,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
oi.refund_amount, oi.order_time, oi.order_type, oi.order_state, oi.order_refund_state,
oi.deduction_type, oi.pay_time, oi.pay_type, oi.pay_channel, oi.pay_state, oi.pay_param,
oi.delivery_amount, oi.packing_amount, oi.delivery_type, oi.comment_state, oi.remark,
di.device_name, su.nick_name, oi.create_by, oi.create_time, oi.update_by, oi.update_time
di.device_name, su.nick_name, oi.create_by, oi.create_time, oi.update_by, oi.update_time,
su.phonenumber as phoneNumber, sd.dept_full_name, aa.area_name
from order_info oi
left join alloc_canteen ac on ac.canteen_id = oi.canteen_id
left join alloc_stall ast on ast.stall_id = oi.stall_id
left join alloc_area aa on aa.area_id = ac.area_id
left join sys_user su on oi.user_id = su.user_id
left join sys_dept sd on sd.dept_id = su.dept_id
left join device_info di on oi.device_sn = di.device_sn
</sql>
@ -83,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sourceType != null "> and oi.source_type = #{sourceType}</if>
<if test="isOnline != null "> and oi.is_online = #{isOnline}</if>
<if test="canteenId != null "> and oi.canteen_id = #{canteenId}</if>
<if test="areaId != null "> and ac.area_id = #{areaId}</if>
<if test="canteenIdList != null and canteenIdList.size >0">
and oi.canteen_id in
<foreach collection="canteenIdList" item="canteenId" open="(" separator="," close=")">
@ -148,6 +152,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and od.goods_name like concat('%', #{searchValue}, '%'))
)
</if>
<if test="custSearchInfo != null and custSearchInfo != ''">
and (
su.nick_name like CONCAT('%',#{custSearchInfo},'%')
or su.phonenumber = #{encryptedCustSearchValue}
or su.user_id like concat('%', #{custSearchInfo}, '%')
)
</if>
<if test="goodsSearchInfo != null and goodsSearchInfo != ''">
and (
EXISTS (select 1 from order_detail od
where oi.order_id = od.order_id
and od.goods_name like concat('%', #{goodsSearchInfo}, '%'))
)
</if>
</where>
order by oi.create_time desc
</select>

View File

@ -132,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.phonenumber,
b.dept_id,
b.dept_name,
b.dept_full_name,
b.nick_name,
c.wallet_bal_user as wallet_bal,
c.wallet_bal_user as wallet_bal_now,

View File

@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or su.user_id like concat('%', #{param.searchValue}, '%')
)
</if>
order by at2.trade_time desc
</select>
<select id="selectOperatingRevenue" resultType="com.bonus.canteen.core.report.domain.OperatingRevenueVO">