diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java index 3050cd3..0517625 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java @@ -12,29 +12,25 @@ import org.springframework.stereotype.Service; @Service public class DeviceServiceImpl implements DeviceService { + @Autowired + private DeviceMapper mapper; + + + @Value("${face.android.appId}") + private String appId; + @Value("${face.android.sdkKey}") + private String appKey; + @Override public AjaxResult getDeviceInfo(AppDTO dto) { - return null; + //判断设备是否存在 + DeviceInfoVo deviceInfoVo = mapper.getDeviceInfo(dto); + if (deviceInfoVo == null) { + return AjaxResult.error("设备不存在"); + } + deviceInfoVo.setAppId(appId); + deviceInfoVo.setAppKey(appKey); + deviceInfoVo.setTenantId(String.valueOf(GlobalConstants.TENANT_ID)); + return AjaxResult.success(deviceInfoVo); } -// @Autowired -// private DeviceMapper mapper; -// -// -// @Value("${face.android.appId}") -// private String appId; -// @Value("${face.android.sdkKey}") -// private String appKey; -// -// @Override -// public AjaxResult getDeviceInfo(AppDTO dto) { -// //判断设备是否存在 -// DeviceInfoVo deviceInfoVo = mapper.getDeviceInfo(dto); -// if (deviceInfoVo == null){ -// return AjaxResult.error("设备不存在"); -// } -// deviceInfoVo.setAppId(appId); -// deviceInfoVo.setAppKey(appKey); -// deviceInfoVo.setTenantId(String.valueOf(GlobalConstants.TENANT_ID)); -// return AjaxResult.success(deviceInfoVo); -// } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/UserServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/UserServiceImpl.java index a584d02..7f720d5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/UserServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/UserServiceImpl.java @@ -5,6 +5,7 @@ import com.bonus.canteen.core.android.mapper.UserMapper; import com.bonus.canteen.core.android.service.UserService; import com.bonus.canteen.core.android.vo.UserInfoVo; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.houqin.utils.SM4EncryptUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +27,9 @@ public class UserServiceImpl implements UserService { List moneyList = mapper.getMoneyList(); if (!list.isEmpty()){ list.forEach(userInfoVo -> { + if (userInfoVo.getPhone().length() != 11){ + userInfoVo.setPhone(SM4EncryptUtils.sm4Decrypt(userInfoVo.getPhone())); + } UserInfoVo money = moneyList.stream().filter(moneyVo -> moneyVo.getUserId().equals(userInfoVo.getUserId())).findFirst().orElse(null); if (money != null){ userInfoVo.setPersonalWalletBalance(money.getPersonalWalletBalance()); @@ -38,4 +42,5 @@ public class UserServiceImpl implements UserService { } return AjaxResult.success(list); } + } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/vo/UserInfoVo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/vo/UserInfoVo.java index 21e989f..2097350 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/vo/UserInfoVo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/vo/UserInfoVo.java @@ -13,6 +13,10 @@ public class UserInfoVo { private String userName; + private String phone; + + private String loginType; + private String accId; /** * 卡号 diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/common/utils/ObjectUtils.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/common/utils/ObjectUtils.java new file mode 100644 index 0000000..7e3fd4c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/common/utils/ObjectUtils.java @@ -0,0 +1,18 @@ +package com.bonus.canteen.core.common.utils; + +import com.bonus.common.core.exception.ServiceException; + +import java.lang.reflect.Field; + +public class ObjectUtils { + public static void setAllFieldsToNull(Object obj) { + for (Field field : obj.getClass().getDeclaredFields()) { + field.setAccessible(true); + try { + field.set(obj, null); + } catch (IllegalAccessException e) { + throw new ServiceException("系统异常"); + } + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java index c84dc18..331147f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/business/OrderBusiness.java @@ -3,6 +3,7 @@ package com.bonus.canteen.core.order.business; import cn.hutool.core.collection.CollUtil; import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO; import com.bonus.canteen.core.account.service.IAccInfoService; +import com.bonus.canteen.core.common.utils.ObjectUtils; import com.bonus.canteen.core.menu.domain.MenuRecipeDishes; import com.bonus.canteen.core.menu.service.IMenuRecipeDishesService; import com.bonus.canteen.core.order.constants.OrderDetailTypeEnum; @@ -51,6 +52,7 @@ public class OrderBusiness { continue; } MenuRecipeDishes menuRecipeDishes = new MenuRecipeDishes(); + ObjectUtils.setAllFieldsToNull(menuRecipeDishes); menuRecipeDishes.setDetailId(orderDetail.getMenuDetailId()); menuRecipeDishes.setDishesId(orderDetail.getGoodsId()); menuRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity()); @@ -63,6 +65,7 @@ public class OrderBusiness { continue; } MenuRecipeDishes menuRecipeDishes = new MenuRecipeDishes(); + ObjectUtils.setAllFieldsToNull(menuRecipeDishes); menuRecipeDishes.setDetailId(orderDetail.getDetailId()); menuRecipeDishes.setDishesId(orderDetail.getGoodsId()); menuRecipeDishesService.addMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java index e1bac1a..b99139d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/OrderInfo.java @@ -189,8 +189,6 @@ public class OrderInfo extends BaseEntity orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); @@ -210,7 +208,6 @@ public class OrderInfo extends BaseEntity orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey()); orderInfo.setOrderRefundState(OrderRefundStateEnum.UN_REFUND.getKey()); orderInfo.setDeductionType(DeductionTypeEnum.PAY_PLACE.getKey()); - orderInfo.setPayType(param.getPayType()); orderInfo.setPayChannel(PayChannelEnum.ACC.getKey()); orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); orderInfo.setDeliveryAmount(BigDecimal.ZERO); @@ -286,14 +283,11 @@ public class OrderInfo extends BaseEntity orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setIdentityVerification(orderInfoAddParam.getIdentityVerification()); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); orderInfo.setUpdateBy(SecurityUtils.getUsername()); orderInfo.setUpdateTime(DateUtils.getNowDate()); - orderInfo.setPayType(param.getPayType()); Long canteenId = orderInfoAddParam.getCanteenId(); orderInfo.setCanteenId(Objects.isNull(canteenId) ? -1 : canteenId); Long stallId = orderInfoAddParam.getStallId(); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java index a866650..8839bfd 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/domain/param/ShopOrderAddParam.java @@ -62,8 +62,6 @@ public class ShopOrderAddParam { orderInfo.setDeviceSn(StringUtils.defaultString(orderInfoAddParam.getDeviceSn(), StringUtils.EMPTY)); orderInfo.setDeviceNum(StringUtils.defaultString(orderInfoAddParam.getDeviceNum(), StringUtils.EMPTY)); orderInfo.setUserId(param.getUserId()); - orderInfo.setPayableAmount(param.getPayableAmount()); - orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setSourceType(param.getSourceType()); orderInfo.setCreateBy(SecurityUtils.getUsername()); orderInfo.setCreateTime(DateUtils.getNowDate()); @@ -76,7 +74,6 @@ public class ShopOrderAddParam { orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey()); orderInfo.setOrderRefundState(OrderRefundStateEnum.UN_REFUND.getKey()); orderInfo.setDeductionType(DeductionTypeEnum.PAY_PLACE.getKey()); - orderInfo.setPayType(param.getPayType()); orderInfo.setPayChannel(PayChannelEnum.ACC.getKey()); orderInfo.setPayState(PayStateEnum.PAY_INPROCESS.getKey()); orderInfo.setDeliveryAmount(BigDecimal.ZERO); @@ -86,7 +83,7 @@ public class ShopOrderAddParam { orderInfo.setOrderTime(DateUtils.getNowDate()); orderInfo.setExternalPayAmount(BigDecimal.ZERO); orderInfo.setRefundAmount(BigDecimal.ZERO); - orderInfo.setPayableAmount(param.getRealAmount()); + orderInfo.setPayableAmount(param.getPayableAmount()); orderInfo.setDiscountsAmount(BigDecimal.ZERO); orderInfo.setRealAmount(param.getRealAmount()); orderInfo.setAccountPayAmount(param.getRealAmount()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java index 5e01466..d38546c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/order/service/impl/OrderInfoServiceImpl.java @@ -139,6 +139,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); accInfoService.checkAccStatus(accInfoVO); List canteenOrderInfoList = new OrderInfo().of(orderAddParam); + checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount()); List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); orderPay(orderInfoList); return 1; @@ -154,6 +155,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId()); accInfoService.checkAccStatus(accInfoVO); List canteenOrderInfoList = new OrderInfo().of(orderAddParam); + checkOrdersTotalAmount(canteenOrderInfoList, orderAddParam.getRealAmount()); List orderInfoList = orderBusiness.orderPlaceHandler(canteenOrderInfoList); orderPay(orderInfoList); return 1; @@ -291,6 +293,18 @@ public class OrderInfoServiceImpl implements IOrderInfoService return orderPayDTO; } + private void checkOrdersTotalAmount(List orderInfoList ,BigDecimal totalAmountParam) { + BigDecimal totalAmount = BigDecimal.ZERO; + if(CollUtil.isNotEmpty(orderInfoList)) { + totalAmount = orderInfoList.stream() + .map(OrderInfo::getRealAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + if(totalAmount.compareTo(totalAmountParam) != 0) { + throw new ServiceException("订单金额有误"); + } + } + /** * 修改订单 diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/DeptIncomeOutcomeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/DeptIncomeOutcomeVO.java index 3b27c5c..0bceb8c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/DeptIncomeOutcomeVO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/DeptIncomeOutcomeVO.java @@ -10,6 +10,7 @@ import java.time.LocalDateTime; public class DeptIncomeOutcomeVO implements Serializable { private Long deptId; private String deptName; + private String deptFullName; private BigDecimal walletBal; private BigDecimal income; private BigDecimal outcome; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/UserIncomeOutcomeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/UserIncomeOutcomeVO.java index d58af30..d6b5e83 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/UserIncomeOutcomeVO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/report/domain/UserIncomeOutcomeVO.java @@ -11,6 +11,7 @@ public class UserIncomeOutcomeVO implements Serializable { private String phonenumber; private Long deptId; private String deptName; + private String deptFullName; private String nickName; private BigDecimal walletBal; private BigDecimal walletBalNow; diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/android/UserMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/android/UserMapper.xml index 6a56aa4..35a08e6 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/android/UserMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/android/UserMapper.xml @@ -10,7 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ac.acc_id as accId, ac.card_num as cardNum, ac.serial_num as serialNum, - ai.acc_status as accStatus + ai.acc_status as accStatus, + su.phone as phone, + su.login_type as loginType from sys_user su left join acc_card ac on ac.user_id = su.user_id left join acc_info ai on ai.user_id = su.user_id diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/AccReportMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/AccReportMapper.xml index cc6644b..d03b131 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/AccReportMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/AccReportMapper.xml @@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT c.dept_id, c.dept_name, + c.dept_full_name, c.wallet_bal_dept as wallet_bal, b.income, b.outcome, @@ -95,7 +96,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select IFNULL(sum(a.wallet_bal), 0) as wallet_bal_dept , su.dept_id, - sd.dept_name + sd.dept_name, + sd.dept_full_name from ( select @@ -144,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" su.phonenumber, sd.dept_id, sd.dept_name, + sd.dept_full_name, SUM(IFNULL(CASE WHEN at2.trade_type in (10, 20, 130) then at2.actual_amount @@ -188,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_user su on a.user_id = su.user_id where + 1 = 1 and su.dept_id in diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/TradeReportMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/TradeReportMapper.xml index 3079bf8..5023659 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/TradeReportMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/report/TradeReportMapper.xml @@ -100,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select oi.canteen_id, oi.stall_id, - CONCAT(ac.canteen_name , '/', ast.stall_name), + CONCAT(ac.canteen_name , '/', ast.stall_name) as canteenAndStallName, count(distinct case when oi.mealtime_type = 1 then oi.user_id else null end) as breakfast_user_count, @@ -324,7 +324,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select od.goods_id, od.goods_name, - mrd.sale_price, + ifnull(mrd.sale_price, 0) as sale_price, sum(case when oi.mealtime_type = 1 then od.quantity else 0 end) as breakfast_quantity_count,