优化今日菜品

This commit is contained in:
seesaw
2024-11-26 09:30:51 +08:00
parent 29f1ade843
commit c12ac09944
12 changed files with 119 additions and 21 deletions

View File

@ -64,4 +64,7 @@ public class MemberUserBaseVO {
private String cardId;
@Schema(description = "人脸")
private Long faceId;
@Schema(description = "人脸")
private String type;
}

View File

@ -106,7 +106,7 @@ public class AppStoreOrderController {
}
@GetMapping("/refund")
@Operation(summary = "退款")
@Operation(summary = "用户退款申请")
public CommonResult<Long> refund(Integer orderId) {
return success(storeOrderService.refund(orderId));
}
@ -117,4 +117,15 @@ public class AppStoreOrderController {
storeOrderService.reduction(orderId, money);
return CommonResult.success(true);
}
@GetMapping("/refundAdmin")
@Operation(summary = "管理员执行退款")
public CommonResult<Boolean> refundAdmin(Integer orderId) {
AddReqVO addReqVO = storeOrderService.refundAdmin(orderId);
//记录
memberAsyncService.batchRecord(addReqVO);
return success(true);
}
}

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@ -108,4 +109,6 @@ public interface DiningPlatesService {
List<String> getBindDiningPlatesList();
Map<String, String> checkBindAndUnBind(String diningPlatesNum, Long storeId);
BigDecimal getOrderMoney(Long orderId);
}

View File

@ -524,4 +524,11 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
return map;
}
@Override
public BigDecimal getOrderMoney(Long orderId) {
DiningPlatesDO diningPlatesDO = diningPlatesMapper.selectOne(Wrappers.<DiningPlatesDO>lambdaQuery()
.eq(DiningPlatesDO::getOrderId, orderId));
String s = stringRedisTemplate.opsForValue().get(diningPlatesDO.getDiningPlatesNum() + "-" + diningPlatesDO.getStoreId());
return StrUtil.isNotBlank(s)?new BigDecimal(s):null;
}
}

View File

@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
import cn.iocoder.yudao.module.member.service.business.BusinessService;
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
import cn.iocoder.yudao.module.member.service.refund.RefundService;
import cn.iocoder.yudao.module.member.util.MemberConstants;
@ -87,6 +88,8 @@ public class OrderServiceImpl implements OrderService {
private BusinessService businessService;
@Resource
private DeductionService deductionService;
@Resource
private DiningPlatesService diningPlatesService;
@Override
public Long createOrder(AppOrderSaveReqVO createReqVO) {
@ -478,7 +481,12 @@ public class OrderServiceImpl implements OrderService {
}
} else {
dishOrderDO.setReductionAmount(dishOrderDO.getReductionAmount().add(money));
BigDecimal orderMoney = diningPlatesService.getOrderMoney(orderId);
BigDecimal add = dishOrderDO.getReductionAmount().add(money);
if (orderMoney != null && orderMoney.compareTo(add) < 0) {
add = orderMoney;
}
dishOrderDO.setReductionAmount(add);
}
dishOrderMapper.updateById(dishOrderDO);

View File

@ -94,4 +94,6 @@ public interface StoreOrderService {
Long refund(Integer orderId);
List<StoreOrderDO> selectPayOrder();
AddReqVO refundAdmin(Integer orderId);
}

View File

@ -309,6 +309,10 @@ public class StoreOrderServiceImpl implements StoreOrderService {
@Override
public void reduction(Long orderId, BigDecimal money) {
StoreOrderDO storeOrderDO = storeOrderMapper.selectById(orderId);
Double totalPrice = storeOrderDO.getTotalPrice();
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
Double reductionPrice = storeOrderDO.getReductionPrice();
@ -571,6 +575,58 @@ public class StoreOrderServiceImpl implements StoreOrderService {
.eq(StoreOrderDO::getStatus,StoreOrderStatusEnum.PAY.getCode()));
}
@Override
public AddReqVO refundAdmin(Integer orderId) {
StoreOrderDO storeOrderDO;
synchronized (getStoreOrderLock(LockManager.CANCEL_KEY)) {
storeOrderDO = storeOrderMapper.selectById(orderId);
if(ObjectUtil.isEmpty(storeOrderDO)){
throw exception(STORE_ORDER_NOT_EXISTS);
}
if( storeOrderDO.getStatus().equals(StoreOrderStatusEnum.REFUND.getCode())){
throw exception(STATUS_ERROR_REFUND);
}
if(storeOrderDO.getStatus().equals(StoreOrderStatusEnum.CANCEL.getCode())){
throw exception(STATUS_ERROR_CANCEL);
}
}
//修改状态
storeOrderDO.setStatus(StoreOrderStatusEnum.REFUND.getCode());
storeOrderMapper.updateById(storeOrderDO);
//退款
deductionService.reduction(storeOrderDO.getUserId(),BigDecimal.valueOf(storeOrderDO.getTotalPrice())
,BigDecimal.ZERO,BigDecimal.valueOf(storeOrderDO.getTotalPrice()),BigDecimal.ZERO);
//更新库存
List<StoreOrderDetailDO> listByOrderId = orderDetailService.getListByOrderId(storeOrderDO.getOrderId());
AddReqVO addReqVO = new AddReqVO();
addReqVO.setType(InventoryTypeEnum.IN.getCode());
addReqVO.setOutType(OutTypeEnum.ORDER_ADD.getCode());
List<GoodsInfoReqVO> infos = new ArrayList<>();
for (StoreOrderDetailDO detail : listByOrderId){
GoodsInfoReqVO vo = new GoodsInfoReqVO();
BeanUtil.copyProperties(detail,vo);
vo.setCarteenId(storeOrderDO.getCarteenId());
infos.add(vo);
}
addReqVO.setList(infos);
storeGoodsInventoryService.createStoreGoodsInventory(addReqVO);
//营业数据
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setCarteenId(storeOrderDO.getCarteenId());
statisticsVo.setTotalMoney(BigDecimal.valueOf(storeOrderDO.getTotalPrice()).negate());
statisticsVo.setOrderSum(-1);
statisticsVo.setTime(storeOrderDO.getCreateTime());
statisticsVo.setOrderId(storeOrderDO.getOrderId().longValue());
storeBusinessService.updateStatistics(statisticsVo);
return addReqVO;
}
public void test() {
//计算金额
//if (total.compareTo(wxAmount) <= 0) {

View File

@ -77,10 +77,11 @@ public class QRCodeWithJWTUtil {
public static void main(String[] args) {
String encode = DigestUtil.md5Hex("340"+ System.currentTimeMillis());
System.out.println(encode);
String encode = "https://yclhit.com:8896/qrCodes/code?id=177799";
// System.out.println(encode);
String fileName = "QRCode_" + "test" + ".png";
String path = QRCodeWithJWTUtil.BASE_PATH+fileName;
QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path);
String s = QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path);
System.out.println(s);
}
}