Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product

pull/2/head
TianYu 2023-05-24 10:52:29 +08:00
commit 9c1415e411
2 changed files with 16 additions and 6 deletions

View File

@ -37,6 +37,8 @@ import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -333,15 +335,17 @@ public class OrderPayServiceImpl implements OrderPayService {
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService(); WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
Assert.notNull(wxPayService, "获取微信支付配置失败!"); Assert.notNull(wxPayService, "获取微信支付配置失败!");
WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request(); WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request();
int sum = storeOrder.getPayPrice().multiply(new BigDecimal("100")).intValue(); // int sum = storeOrder.getPayPrice().multiply(new BigDecimal("100")).intValue();
int sum = 1;
wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum)); wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum));
wxPayRequest.setDescription("会员充值"); wxPayRequest.setDescription("商城消费");
wxPayRequest.setOutTradeNo(storeOrder.getOrderId()); wxPayRequest.setOutTradeNo(storeOrder.getOrderId());
wxPayRequest.setNotifyUrl(payProperties.getNotifyUrl()); wxPayRequest.setNotifyUrl(payProperties.getNotifyUrl());
wxPayRequest.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(openid)); wxPayRequest.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(openid));
wxPayRequest.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(ip)); wxPayRequest.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(ip));
wxPayRequest.setAppid(payProperties.getAppId()); wxPayRequest.setAppid(payProperties.getAppId());
wxPayRequest.setMchid(payProperties.getMchId()); wxPayRequest.setMchid(payProperties.getMchId());
wxPayRequest.setTimeExpire(formatLocalDateTime(LocalDateTime.now().plusMinutes(30), "yyyyMMddHHmmss"));
try { try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest); WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url()); map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
@ -350,4 +354,8 @@ public class OrderPayServiceImpl implements OrderPayService {
} }
return map; return map;
} }
public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) {
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
}
} }

View File

@ -62,14 +62,16 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO); RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO);
rechargeOrderMapper.updateById(updateObj); rechargeOrderMapper.updateById(updateObj);
} }
@Override @Override
public void updateRechargeOrderStatus(RechargeOrderUpdateReqVO updateReqVO) { public void updateRechargeOrderStatus(RechargeOrderUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
validateRechargeOrderExists(updateReqVO.getId()); validateRechargeOrderExists(updateReqVO.getId());
// 更新 // 更新
RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO); RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO);
rechargeOrderMapper.updateById(updateObj); rechargeOrderMapper.updateById(updateObj);
} }
@Override @Override
public void deleteRechargeOrder(Long id) { public void deleteRechargeOrder(Long id) {
// 校验存在 // 校验存在
@ -97,7 +99,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
@Override @Override
public PageResult<RechargeOrderRespVO> getRechargeOrderPage(RechargeOrderPageReqVO pageReqVO) { public PageResult<RechargeOrderRespVO> getRechargeOrderPage(RechargeOrderPageReqVO pageReqVO) {
Page<RechargeOrderRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); Page<RechargeOrderRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
rechargeOrderMapper.findListPage(page,pageReqVO); rechargeOrderMapper.findListPage(page, pageReqVO);
return new PageResult<>(page.getRecords(), page.getTotal()); return new PageResult<>(page.getRecords(), page.getTotal());
} }
@ -149,7 +151,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
MemberHeadResponse response = new MemberHeadResponse(); MemberHeadResponse response = new MemberHeadResponse();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Assert.notNull(loginUser, "登录失效,请重新登录!"); Assert.notNull(loginUser, "登录失效,请重新登录!");
List<RechargeOrderDO> orderDOS = rechargeOrderMapper.selectList(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getUid, loginUser.getId())); List<RechargeOrderDO> orderDOS = rechargeOrderMapper.selectList(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getUid, loginUser.getId()).eq(RechargeOrderDO::getPaid, 1));
if (!CollectionUtils.isEmpty(orderDOS)) { if (!CollectionUtils.isEmpty(orderDOS)) {
BigDecimal amount = new BigDecimal("0"); BigDecimal amount = new BigDecimal("0");
for (RechargeOrderDO orderDO : orderDOS) { for (RechargeOrderDO orderDO : orderDOS) {
@ -158,7 +160,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
if (amount.compareTo(new BigDecimal("640")) < 0) { if (amount.compareTo(new BigDecimal("640")) < 0) {
response.setGrade("普通会员"); response.setGrade("普通会员");
response.setIntegral(amount.stripTrailingZeros().toPlainString() + "/" + "640"); response.setIntegral(amount.stripTrailingZeros().toPlainString() + "/" + "640");
} else if (amount.compareTo(new BigDecimal("640")) >= 0) { } else if (amount.compareTo(new BigDecimal("1040")) >= 0) {
response.setGrade("高级会员"); response.setGrade("高级会员");
response.setIntegral(amount.stripTrailingZeros().toPlainString() + "/" + "1040"); response.setIntegral(amount.stripTrailingZeros().toPlainString() + "/" + "1040");
} else { } else {