From 80937224e555cd2234303b547ef7ea844da8c6ce Mon Sep 17 00:00:00 2001 From: tangqian Date: Mon, 29 May 2023 14:56:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=95=86=E5=9F=8E=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/MemberChangeTieRequest.java | 22 +++++++++++++++ .../request/member/OrderContentRequest.java | 4 +++ .../request/order/CreateOrderRequest.java | 1 + .../order/OrderPayResultResponse.java | 1 + .../order/StoreOrderDetailInfoResponse.java | 4 +++ .../app/member/MemberController.java | 19 ++++++++++--- .../shop/dal/dataobject/order/StoreOrder.java | 12 ++++++++ .../dal/dataobject/order/StoreOrderInfo.java | 10 +++++++ .../order/impl/OrderPayServiceImpl.java | 12 ++++++++ .../service/order/impl/OrderServiceImpl.java | 28 ++++++++++++++++++- .../order/impl/StoreOrderServiceImpl.java | 4 ++- .../recharge/RechargeOrderService.java | 3 ++ .../recharge/RechargeOrderServiceImpl.java | 12 ++++++++ .../module/member/api/user/MemberUserApi.java | 2 +- .../member/api/user/MemberUserApiImpl.java | 4 +-- 15 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/MemberChangeTieRequest.java diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/MemberChangeTieRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/MemberChangeTieRequest.java new file mode 100644 index 000000000..225915dc9 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/MemberChangeTieRequest.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.shop.request.member; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Title:MemberChangeTieRequest + * @Description: TODO + * @author: tangqian + * @date: 2023/5/29 14:47 + * @version: V1.0.0 + */ +@Data +public class MemberChangeTieRequest implements Serializable { + private static final long serialVersionUID = -7173209981786890536L; + @Schema(description = "推广员id") + @NotNull(message = "推广员id不能为空") + private Long promoterId; +} diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/OrderContentRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/OrderContentRequest.java index 73c9fe6d7..7710a6891 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/OrderContentRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/OrderContentRequest.java @@ -24,6 +24,9 @@ import java.util.List; @Schema(description="会员充值下单请求入参") public class OrderContentRequest implements Serializable { private static final long serialVersionUID = -9170167938995005780L; + @Schema(description = "用户姓名") + private String userName; + @Schema(description = "用户电话") private String userPhone; @@ -37,6 +40,7 @@ public class OrderContentRequest implements Serializable { @NotEmpty(message = "支付类型不能为空") private String payType; + @Schema(description = "订单信息") private List orderInfos; @Data diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java index 9e9b5b330..e5a91e6da 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/CreateOrderRequest.java @@ -70,4 +70,5 @@ public class CreateOrderRequest implements Serializable { @Schema(description = "手机号码") private String phone; + } diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/OrderPayResultResponse.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/OrderPayResultResponse.java index 59895f859..103e07031 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/OrderPayResultResponse.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/OrderPayResultResponse.java @@ -43,6 +43,7 @@ public class OrderPayResultResponse { @Schema(description ="支付宝返回参数") private String body; + // // @Schema(description = "支付宝调起支付参数对象(app支付专用)") // private AliPayJsResultVo aliPayConfig; diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/StoreOrderDetailInfoResponse.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/StoreOrderDetailInfoResponse.java index 37359abdc..ae645cc57 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/StoreOrderDetailInfoResponse.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/response/order/StoreOrderDetailInfoResponse.java @@ -369,4 +369,8 @@ public class StoreOrderDetailInfoResponse implements Serializable { // private SystemStore systemStore; // private String mapKey; // private String statusPic; + + + @Schema(description ="倒计时") + private long countDownTime; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java index cc7bca07b..30febe39d 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/member/MemberController.java @@ -3,10 +3,13 @@ package cn.iocoder.yudao.module.shop.controller.app.member; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeGearRespVO; import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO; import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; +import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest; +import cn.iocoder.yudao.module.shop.request.order.CreateOrderRequest; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; import cn.iocoder.yudao.module.shop.service.recharge.PhoneRecordService; import cn.iocoder.yudao.module.shop.service.recharge.RechargeGearService; @@ -16,10 +19,8 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -41,6 +42,7 @@ public class MemberController { @Autowired private RechargeOrderService rechargeOrderService; + // 会员档次信息列表 @Operation(summary = "会员档次信息") @RequestMapping(value = "/memberGradeInfo", method = RequestMethod.GET) @@ -82,4 +84,13 @@ public class MemberController { public CommonResult> memberOrderInfoByPhone(@RequestParam String phone) { return CommonResult.success(rechargeOrderService.memberOrderInfoByPhone(phone)); } + + @Operation(summary = "会员换绑") + @RequestMapping(value = "/memberChangeTie", method = RequestMethod.POST) + @PreAuthenticated + @TenantIgnore + public CommonResult memberChangeTie(@Validated @RequestBody MemberChangeTieRequest changeTieRequest) { + return CommonResult.success(rechargeOrderService.memberChangeTie(changeTieRequest)); + } + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java index 8330de9d9..c9887bfcb 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrder.java @@ -207,4 +207,16 @@ public class StoreOrder implements Serializable { @Schema(description = "商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号") private String outTradeNo; + + /** + * 推广员id + */ + private Long promoterId; + + /** + * 组织id + */ + private Long deptId; + + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrderInfo.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrderInfo.java index a5e5c50ae..77b23b49f 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrderInfo.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/dataobject/order/StoreOrderInfo.java @@ -91,4 +91,14 @@ public class StoreOrderInfo implements Serializable { @Schema(description = "商品类型:0-普通,1-秒杀,2-砍价,3-拼团,4-视频号") private Integer productType; + /** + * 推广员id + */ + private Long promoterId; + + /** + * 组织id + */ + private Long deptId; + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderPayServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderPayServiceImpl.java index 03d0da38e..dcc49a801 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderPayServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderPayServiceImpl.java @@ -45,9 +45,12 @@ import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.Assert; import java.math.BigDecimal; +import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; @@ -403,4 +406,13 @@ public class OrderPayServiceImpl implements OrderPayService { return localDateTime.format(DateTimeFormatter.ofPattern(pattern)); } + public static void main(String[] args) { + System.out.println(formatLocalDateTime(LocalDateTime.now().plusMinutes(30),"yyyyMMddHHmmss")); + LocalDateTime localDateTime = LocalDateTime.now().plusMinutes(30); + long l = localDateTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli(); + LocalDateTime a = Instant.ofEpochMilli(l).atZone(ZoneOffset.ofHours(8)).toLocalDateTime(); + System.out.println(l); + System.out.println(a); + } + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java index 6ccc2f220..62bb5afe1 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/OrderServiceImpl.java @@ -10,12 +10,16 @@ import cn.iocoder.yudao.framework.common.pojo.DateLimitUtilVo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi; import cn.iocoder.yudao.module.member.api.address.AddressApi; import cn.iocoder.yudao.module.member.api.address.UserAddressApi; import cn.iocoder.yudao.module.member.api.address.dto.UserAddressRespDTO; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.member.api.user.dto.PromoterDTO; import cn.iocoder.yudao.module.shop.constants.PayConstants; import cn.iocoder.yudao.module.shop.constants.SysConfigConstants; import cn.iocoder.yudao.module.shop.convert.order.StoreOrderConvert; @@ -51,6 +55,8 @@ import cn.iocoder.yudao.module.shop.vo.order.OrderInfoVo; import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo; import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoVo; import cn.iocoder.yudao.module.shop.vo.product.MyRecord; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -64,6 +70,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.support.TransactionTemplate; +import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -146,6 +153,12 @@ public class OrderServiceImpl implements OrderService { @Autowired private StoreProductAttrValueService storeProductAttrValueService; + @Autowired + private MemberUserApi userService; + + @Autowired + private DeptApi deptApi; + /** * 订单列表 * @@ -1158,7 +1171,16 @@ public class OrderServiceImpl implements OrderService { } String orderVoString = redisUtil.get(key).toString(); OrderInfoVo orderInfoVo = JSONUtil.toBean(orderVoString, OrderInfoVo.class); - + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Assert.notNull(loginUser, "登录失效,请重新登录!"); + // 获取组织id + PromoterDTO promoterDTO = userService.getPromoterDOByUserId(user.getId()); + Long tenantId = TenantContextHolder.getTenantId(); + Long deptId = promoterDTO.getDeptId(); + if (deptId == null) { + DeptRespDTO deptRespDTO = deptApi.findParentDept(tenantId); + deptId = deptRespDTO.getId(); + } // 检测支付方式 if (!orderUtil.checkPayType(orderRequest.getPayType())) throw new ServiceException("暂不支持该支付方式,请刷新页面或者联系管理员"); @@ -1248,6 +1270,8 @@ public class OrderServiceImpl implements OrderService { soInfo.setPayNum(detailVo.getPayNum()); soInfo.setWeight(detailVo.getWeight()); soInfo.setVolume(detailVo.getVolume()); + soInfo.setPromoterId(user.getPromoterId()); + soInfo.setDeptId(deptId); if (ObjectUtil.isNotNull(detailVo.getGiveIntegral()) && detailVo.getGiveIntegral() > 0) { soInfo.setGiveIntegral(detailVo.getGiveIntegral()); } else { @@ -1334,6 +1358,8 @@ public class OrderServiceImpl implements OrderService { storeOrder.setPaid(false); storeOrder.setCost(BigDecimal.ZERO); storeOrder.setType(0); + storeOrder.setPromoterId(user.getPromoterId()); + storeOrder.setDeptId(deptId); if (orderInfoVo.getIsVideo()) { storeOrder.setType(1);// 视频号订单 } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java index c3713984a..bc81689c6 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java @@ -159,6 +159,7 @@ public class StoreOrderServiceImpl extends ServiceImpl infoDOS = rechargeOrderInfoMapper.selectList(Wrappers.lambdaQuery().eq(RechargeOrderInfoDO::getOrderNo, orderId)); List recordDOS = new ArrayList<>(); @@ -1524,7 +1526,7 @@ public class StoreOrderServiceImpl extends ServiceImpl memberOrderInfoByPhone(String phone); + + Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java index d3fc5ad04..e0aa144ce 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper; +import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest; import cn.iocoder.yudao.module.shop.request.member.RefundRequest; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -51,6 +52,8 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { private MemberUserApi userService; @Resource private PhoneRecordService phoneRecordService; + @Autowired + private MemberUserApi memberUserApi; @Override public Long createRechargeOrder(RechargeOrderCreateReqVO createReqVO) { @@ -210,4 +213,13 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { return null; } + @Override + public Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest) { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Assert.notNull(loginUser, "登录失效,请重新登录!"); + MemberUserRespDTO user = userService.getUser(loginUser.getId()); + user.setPromoterId(changeTieRequest.getPromoterId()); + return memberUserApi.updateById(user)>0; + } + } diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java index 62faaf15c..2c8e49f56 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java @@ -80,7 +80,7 @@ public interface MemberUserApi { MemberUserRespDTO getInfo(); - void saveMemberUser(String phone,Long promoterId); + void saveMemberUser(String phone,Long promoterId,String userName); PromoterDTO getPromoterDOByUserId(Long userId); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index 17603857a..e46ca4bd1 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -107,11 +107,11 @@ public class MemberUserApiImpl implements MemberUserApi { } @Override - public void saveMemberUser(String phone,Long promoterId) { + public void saveMemberUser(String phone,Long promoterId,String userName) { AppAuthSmsLoginReqVO reqVO = new AppAuthSmsLoginReqVO(); reqVO.setMobile(phone); reqVO.setPromoterId(promoterId); - reqVO.setRealName("初始化账号"); + reqVO.setRealName(userName); authService.initialize(reqVO); }