fix: 商城支付相关

pull/2/head
tangqian 2023-05-29 14:56:34 +08:00
parent 4aadcef501
commit 80937224e5
15 changed files with 129 additions and 9 deletions

View File

@ -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;
}

View File

@ -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<OrderInfo> orderInfos;
@Data

View File

@ -70,4 +70,5 @@ public class CreateOrderRequest implements Serializable {
@Schema(description = "手机号码")
private String phone;
}

View File

@ -43,6 +43,7 @@ public class OrderPayResultResponse {
@Schema(description ="支付宝返回参数")
private String body;
//
// @Schema(description = "支付宝调起支付参数对象app支付专用")
// private AliPayJsResultVo aliPayConfig;

View File

@ -369,4 +369,8 @@ public class StoreOrderDetailInfoResponse implements Serializable {
// private SystemStore systemStore;
// private String mapKey;
// private String statusPic;
@Schema(description ="倒计时")
private long countDownTime;
}

View File

@ -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<List<RechargeOrderRespVO>> memberOrderInfoByPhone(@RequestParam String phone) {
return CommonResult.success(rechargeOrderService.memberOrderInfoByPhone(phone));
}
@Operation(summary = "会员换绑")
@RequestMapping(value = "/memberChangeTie", method = RequestMethod.POST)
@PreAuthenticated
@TenantIgnore
public CommonResult<Boolean> memberChangeTie(@Validated @RequestBody MemberChangeTieRequest changeTieRequest) {
return CommonResult.success(rechargeOrderService.memberChangeTie(changeTieRequest));
}
}

View File

@ -207,4 +207,16 @@ public class StoreOrder implements Serializable {
@Schema(description = "商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号")
private String outTradeNo;
/**
* 广id
*/
private Long promoterId;
/**
* id
*/
private Long deptId;
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);// 视频号订单
}

View File

@ -159,6 +159,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private RechargeGearService rechargeGearService;
@Autowired
private StoreOrderMapper storeOrderMapper;
/**
* PC
*
@ -1285,6 +1286,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
String s = "MEMBER_1661994584871321602";
System.out.println(s.contains("MEMBER_"));
}
public void addPhoneRecord(RechargeOrderDO orderDO, String orderId) {
List<RechargeOrderInfoDO> infoDOS = rechargeOrderInfoMapper.selectList(Wrappers.<RechargeOrderInfoDO>lambdaQuery().eq(RechargeOrderInfoDO::getOrderNo, orderId));
List<PhoneRecordDO> recordDOS = new ArrayList<>();
@ -1524,7 +1526,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
MemberUserRespDTO userByMobile = userService.getUserByMobile(request.getUserPhone());
// 初始化一个账号
if (Objects.isNull(userByMobile)) {
userService.saveMemberUser(request.getUserPhone(), user.getPromoterId());
userService.saveMemberUser(request.getUserPhone(), user.getPromoterId(), request.getUserName());
}
}
}

View File

@ -5,6 +5,7 @@ import javax.validation.*;
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse;
import org.apache.ibatis.annotations.Param;
@ -78,4 +79,6 @@ public interface RechargeOrderService {
MemberHeadResponse memberHeadInfo();
List<RechargeOrderRespVO> memberOrderInfoByPhone(String phone);
Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest);
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}