ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java
@@ -5,6 +5,7 @@ import com.ruoyi.common.core.dto.ExchangeDto; import com.ruoyi.order.api.feignClient.OrderClient; import com.ruoyi.order.api.model.ChargingListQuery; import com.ruoyi.order.api.model.TGrantVip; import com.ruoyi.order.api.model.TShoppingOrder; import com.ruoyi.order.api.model.TVipOrder; import com.ruoyi.order.api.query.TActivityStatisticsQuery; @@ -35,6 +36,11 @@ @Override public R managementGiveVip(TGrantVip grantVip) { return R.fail("管理后台赠送会员:" + cause.getMessage()); } @Override public R<List<Integer>> getSalesCountByGoodsId(String goodsIds) { return R.fail("根据商品订单ids查询销量:" + cause.getMessage()); } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/OrderClient.java
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.dto.ExchangeDto; import com.ruoyi.order.api.factory.OrderFallbackFactory; import com.ruoyi.order.api.model.ChargingListQuery; import com.ruoyi.order.api.model.TGrantVip; import com.ruoyi.order.api.model.TShoppingOrder; import com.ruoyi.order.api.model.TVipOrder; import com.ruoyi.order.api.query.TActivityStatisticsQuery; @@ -23,7 +24,8 @@ */ @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderFallbackFactory.class) public interface OrderClient { @PostMapping(value = "/t-charging-order/management/give/vip") public R managementGiveVip(@RequestBody TGrantVip grantVip); @GetMapping("/t-exchange-order/getSalesCountByGoodsIds/{goodsIds}") R<List<Integer>> getSalesCountByGoodsId(@PathVariable("goodsIds") String goodsIds); ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TActivityStatisticslVO.java
@@ -17,6 +17,8 @@ @ApiModelProperty(value = "用户手机号") private String phone; @ApiModelProperty(value = "用户id") private Long appUserId; @ApiModelProperty(value = "参与类型 优惠券 会员抵扣 会员活动 赠送会员") private String type; ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -19,6 +19,7 @@ import com.ruoyi.common.core.dto.PointChangeDto; import com.ruoyi.common.core.enums.status.AppUserStatusEnum; import com.ruoyi.common.core.utils.JwtUtils; import com.ruoyi.common.core.utils.OrderCodeUtil; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.domain.AjaxResult; @@ -33,8 +34,10 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.api.feignClient.ChargingOrderClient; import com.ruoyi.order.api.feignClient.ExchangeOrderClient; import com.ruoyi.order.api.feignClient.OrderClient; import com.ruoyi.order.api.model.TChargingOrder; import com.ruoyi.order.api.model.TExchangeOrder; import com.ruoyi.order.api.model.TGrantVip; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.domain.TCoupon; import com.ruoyi.other.api.dto.UnitListQueryDto; @@ -51,6 +54,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; @@ -76,6 +80,8 @@ private TAppUserService appUserService; @Resource private TAppUserTagService appUserTagService; @Autowired private OrderClient orderClient; @Resource private TAppUserVipDetailService tAppUserVipDetailService; @@ -726,9 +732,31 @@ } else if (giveVipDto.getType() == 3) { plusDay = 12; } //增加vipDetail BigDecimal bigDecimal = new BigDecimal("0"); TVip info = vipClient.getInfo1(giveVipDto.getVipId()).getData(); switch (giveVipDto.getType()){ case 1: bigDecimal = bigDecimal.add(info.getMonthlyCard()); break; case 2: bigDecimal = bigDecimal.add(info.getSeasonCard()); break; case 3: bigDecimal = bigDecimal.add(info.getAnnualCard()); break; } //增加vipDetail giveVipUtil.sendVip(nowUser, giveVipDto.getVipId(),plusDay,giveVipDto.getType()); appUserService.updateById(nowUser); // 新增后台赠送记录 TGrantVip tGrantVip = new TGrantVip(); tGrantVip.setCode(OrderCodeUtil.getOrderCode("ZS")); tGrantVip.setAppUserId(nowUser.getId()); tGrantVip.setVipId(giveVipDto.getVipId()); tGrantVip.setOrderAmount(bigDecimal); tGrantVip.setCreateTime(LocalDateTime.now()); tGrantVip.setAppUserId(nowUser.getId()); orderClient.managementGiveVip(tGrantVip); } return R.ok(); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -92,7 +92,8 @@ private TokenService tokenService; @Autowired private TOrderEvaluateService orderEvaluateService; @Autowired private TGrantVipService tGrantVipService; @Resource private WxPaymentClient wxPaymentClient; @@ -133,6 +134,15 @@ @Resource private TOrderInvoiceService invoiceService; /** * 远程调用 增加管理后台赠送会员记录 * @return */ @ResponseBody @PostMapping(value = "/management/give/vip") public R managementGiveVip(@RequestBody TGrantVip grantVip) { return R.ok(tGrantVipService.save(grantVip)); } /** * 远程调用根据枪id 查询最新的订单id 用户后台结束充电 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -117,6 +117,10 @@ BigDecimal grantVip = new BigDecimal("0"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (TActivityStatisticslVO tActivityStatisticslVO : list1) { TAppUser data = appUserClient.getUserById(tActivityStatisticslVO.getAppUserId()).getData(); if (data!=null){ tActivityStatisticslVO.setPhone(data.getPhone()); } // 判断享有了哪些类型 switch (tActivityStatisticslVO.getOrderType()){ case 1: @@ -187,6 +191,7 @@ } } for (TActivityStatisticslVO tActivityStatisticslVO : list) { // 判断享有了哪些类型 switch (tActivityStatisticslVO.getOrderType()){ case 1: ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -49,6 +49,7 @@ t9.vip_discount_amount as vipDiscountAmount, t9.payment_amount as paymentAmount, t9.create_time as createTime, t9.app_user_id as appUserId, 1 as orderType from t_charging_order t9 where t9.id = 0 limit 1 @@ -60,6 +61,7 @@ t1.vip_discount_amount as vipDiscountAmount, t1.payment_amount as paymentAmount, t1.create_time as createTime, t1.app_user_id as appUserId, 1 as orderType from t_charging_order t1 where 1 = 1 @@ -67,10 +69,13 @@ and t1.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="req.type != null and req.type != '' and req.type == 1"> and t1.coupon_discount_amount IS NOT NULL and t1.coupon_discount_amount != 0 and t1.coupon_discount_amount > 0 </if> <if test="req.type != null and req.type != '' and req.type == 2"> and t1.vip_discount_amount IS NOT NULL and t1.vip_discount_amount != 0 and t1.vip_discount_amount > 0 </if> <if test="req.type == null "> and (t1.vip_discount_amount > 0 or t1.coupon_discount_amount > 0) </if> <if test="null != req.userIds and req.userIds.size()>0" > and t1.app_user_id in @@ -95,11 +100,12 @@ <if test="req.orderType == null or req.orderType == 2"> <if test="req.type == null or req.type == 1 or req.type == 2"> union all select t2.code ,t2.order_amount as orderAmount, select t2.code ,t2.order_amount as paymentAmount, t2.coupon_discount_amount as couponDiscountAmount, t2.vip_discount_amount as vipDiscountAmount, t2.payment_amount as paymentAmount, t2.payment_amount as orderAmount, t2.create_time as createTime, t2.app_user_id as appUserId, 2 as orderType from t_shopping_order t2 where 1 = 1 @@ -136,6 +142,7 @@ t3.discount_amount as vipDiscountAmount, t3.payment_amount as paymentAmount, t3.create_time as createTime, t3.app_user_id as appUserId, 3 as orderType from t_vip_order t3 where 1 = 1 @@ -144,7 +151,7 @@ and t3.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="req.type == null "> and t3.discount_amount IS NOT NULL and t3.discount_amount != 0 and t3.discount_amount > 0 </if> <if test="null != req.userIds and req.userIds.size()>0" > and t3.app_user_id in @@ -167,6 +174,7 @@ t4.discount_amount as vipDiscountAmount, t4.payment_amount as paymentAmount, t4.create_time as createTime, t4.app_user_id as appUserId, 4 as orderType from t_vip_order t4 where 1 = 1 @@ -175,7 +183,7 @@ and t4.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="req.type == null "> and t4.discount_amount IS NOT NULL and t4.discount_amount != 0 and t4.discount_amount > 0 </if> <if test="null != req.userIds and req.userIds.size()>0" > and t4.app_user_id in @@ -198,6 +206,7 @@ 0 as vipDiscountAmount, 0 as paymentAmount, t5.create_time as createTime, t5.app_user_id as appUserId, 4 as orderType from t_grant_vip t5 where 1 = 1