修复优惠卷问题 修复售后订单问题

This commit is contained in:
徐唯轩
2023-11-15 09:38:42 +08:00
parent 406fa693b9
commit 1597f5aaa0
20 changed files with 147 additions and 65 deletions

View File

@ -1234,10 +1234,10 @@ CREATE TABLE `merchant_details` (
-- Records of merchant_details -- Records of merchant_details
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `merchant_details` VALUES ('1', '支付宝配置', 'aliPay', '2021001187645179', '', NULL, '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', NULL, NULL, 'http://yshop.l1.ttut.cc/app-api/order/payBack1.json', '', 'RSA2', '2088821836348568', NULL, NULL, 'UTF-8', 0, '1', NULL, NULL, '2023-09-25 10:33:31', b'0'); INSERT INTO `merchant_details` (`details_id`, `title`, `pay_type`, `appid`, `mch_id`, `cert_store_type`, `key_private`, `key_public`, `key_cert`, `key_cert_pwd`, `notify_url`, `return_url`, `sign_type`, `seller`, `sub_app_id`, `sub_mch_id`, `input_charset`, `is_test`, `updater`, `creator`, `create_time`, `update_time`, `deleted`) VALUES ('1', '支付宝配置', 'aliPay', '2021001187645179', '', NULL, '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', NULL, NULL, 'http://yshop.l1.ttut.cc/app-api/order/payBack1.json', '', 'RSA2', '2088821836348568', NULL, NULL, 'UTF-8', 0, '1', NULL, NULL, '2023-09-25 10:33:31', b'0');
INSERT INTO `merchant_details` VALUES ('3', '微信小程序支付配置', 'wxPay', 'wx604d2ea4702620d2', '1493624002', 'STR', 'dayouqiantuhupeng8638004yixiangt', '', '', '', 'http://yshop.l1.ttut.cc/app-api/order/payBack3.json', '', 'MD5', NULL, NULL, NULL, 'UTF-8', 0, '1', NULL, NULL, '2023-09-25 10:33:20', b'0'); INSERT INTO `merchant_details` (`details_id`, `title`, `pay_type`, `appid`, `mch_id`, `cert_store_type`, `key_private`, `key_public`, `key_cert`, `key_cert_pwd`, `notify_url`, `return_url`, `sign_type`, `seller`, `sub_app_id`, `sub_mch_id`, `input_charset`, `is_test`, `updater`, `creator`, `create_time`, `update_time`, `deleted`) VALUES ('2', '微信app支付配置', 'wxPay', 'wxf0713a10bbae8732', '1558500071', 'STR', 'zk7BHJJWThinkSztbI6zye9ZA70uNFtT', NULL, NULL, NULL, 'https://b2c-pro-api-dev.zkthink.com/app-api/order/pay/wxPayNotify', NULL, 'MD5', NULL, NULL, NULL, 'utf-8', 0, '1', '1', '2023-09-20 09:58:03', '2023-11-14 15:26:56', b'0');
INSERT INTO `merchant_details` VALUES ('4', '微信h5支付配置', 'wxPay', 'wxc061dee8806ff712', '1493624002', '', 'dayouqiantuhupeng8638004yixiangt', NULL, NULL, NULL, 'http://yshop.l1.ttut.cc/app-api/order/payBack4.json', 'https://dc.yixiang.co/h5/#/pages/take-foods/take-foods', 'MD5', NULL, NULL, NULL, 'utf-8', 0, '1', '1', '2023-09-20 09:58:03', '2023-09-25 10:33:04', b'0'); INSERT INTO `merchant_details` (`details_id`, `title`, `pay_type`, `appid`, `mch_id`, `cert_store_type`, `key_private`, `key_public`, `key_cert`, `key_cert_pwd`, `notify_url`, `return_url`, `sign_type`, `seller`, `sub_app_id`, `sub_mch_id`, `input_charset`, `is_test`, `updater`, `creator`, `create_time`, `update_time`, `deleted`) VALUES ('3', '微信小程序支付配置', 'wxPay', 'wxf0713a10bbae8732', '1558500071', 'STR', 'zk7BHJJWThinkSztbI6zye9ZA70uNFtT', '', '', '', 'https://b2c-pro-api-dev.zkthink.com/app-api/order/pay/wxPayNotify', '', 'MD5', NULL, NULL, NULL, 'UTF-8', 0, '1', NULL, NULL, '2023-11-14 15:26:16', b'0');
INSERT INTO `merchant_details` VALUES ('5', '微信app支付配置', 'wxPay', 'wx7c84ede33062d1e4', '1493624002', 'STR', 'dayouqiantuhupeng8638004yixiangt', NULL, NULL, NULL, 'http://yshop.l1.ttut.cc/app-api/order/payBack4.json', NULL, 'MD5', NULL, NULL, NULL, 'utf-8', 0, '1', '1', '2023-09-20 09:58:03', '2023-09-25 10:32:49', b'0'); INSERT INTO `merchant_details` (`details_id`, `title`, `pay_type`, `appid`, `mch_id`, `cert_store_type`, `key_private`, `key_public`, `key_cert`, `key_cert_pwd`, `notify_url`, `return_url`, `sign_type`, `seller`, `sub_app_id`, `sub_mch_id`, `input_charset`, `is_test`, `updater`, `creator`, `create_time`, `update_time`, `deleted`) VALUES ('4', '微信h5支付配置', 'wxPay', 'wxf0713a10bbae8732', '1558500071', '', 'zk7BHJJWThinkSztbI6zye9ZA70uNFtT', NULL, NULL, NULL, 'https://b2c-pro-api-dev.zkthink.com/app-api/order/pay/wxPayNotify', 'https://b2c-pro-ui-h5-dev.zkthink.com/#/pages/payStatus/index?type=1', 'MD5', NULL, NULL, NULL, 'utf-8', 0, '1', '1', '2023-09-20 09:58:03', '2023-11-14 14:20:58', b'0');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------
@ -5930,7 +5930,7 @@ CREATE TABLE `system_sms_channel` (
-- Records of system_sms_channel -- Records of system_sms_channel
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `system_sms_channel` VALUES (2, 'yshop', 'ALIYUN', 0, '啦啦啦', 'LTAI5tCnKso2uG3kJ5gRav88', 'fGJ5SNXL7P1NHNRmJ7DJaMJGPyE55C', NULL, '', '2021-03-31 11:53:10', '1', '2023-07-31 10:10:34', b'0'); INSERT INTO `system_sms_channel` VALUES (2, '中科鑫智', 'ALIYUN', 0, '啦啦啦', 'LTAI5tBBPdRd4f2YZt5UhVjF', 'iVP7EsjX309epI7MqsScziGhcrEHiT', NULL, '', '2021-03-31 11:53:10', '1', '2023-07-31 10:10:34', b'0');
INSERT INTO `system_sms_channel` VALUES (4, '测试渠道', 'DEBUG_DING_TALK', 0, '123', '696b5d8ead48071237e4aa5861ff08dbadb2b4ded1c688a7b7c9afc615579859', 'SEC5c4e5ff888bc8a9923ae47f59e7ccd30af1f14d93c55b4e2c9cb094e35aeed67', NULL, '1', '2021-04-13 00:23:14', '1', '2022-03-27 20:29:49', b'0'); INSERT INTO `system_sms_channel` VALUES (4, '测试渠道', 'DEBUG_DING_TALK', 0, '123', '696b5d8ead48071237e4aa5861ff08dbadb2b4ded1c688a7b7c9afc615579859', 'SEC5c4e5ff888bc8a9923ae47f59e7ccd30af1f14d93c55b4e2c9cb094e35aeed67', NULL, '1', '2021-04-13 00:23:14', '1', '2022-03-27 20:29:49', b'0');
INSERT INTO `system_sms_channel` VALUES (6, '测试演示', 'DEBUG_DING_TALK', 0, NULL, '696b5d8ead48071237e4aa5861ff08dbadb2b4ded1c688a7b7c9afc615579859', 'SEC5c4e5ff888bc8a9923ae47f59e7ccd30af1f14d93c55b4e2c9cb094e35aeed67', NULL, '1', '2022-04-10 23:07:59', '1', '2022-06-19 00:33:54', b'0'); INSERT INTO `system_sms_channel` VALUES (6, '测试演示', 'DEBUG_DING_TALK', 0, NULL, '696b5d8ead48071237e4aa5861ff08dbadb2b4ded1c688a7b7c9afc615579859', 'SEC5c4e5ff888bc8a9923ae47f59e7ccd30af1f14d93c55b4e2c9cb094e35aeed67', NULL, '1', '2022-04-10 23:07:59', '1', '2022-06-19 00:33:54', b'0');
COMMIT; COMMIT;

View File

@ -3,15 +3,11 @@ package co.yixiang.yshop.framework.sms.core.client.impl;
import co.yixiang.yshop.framework.sms.core.client.SmsClient; import co.yixiang.yshop.framework.sms.core.client.SmsClient;
import co.yixiang.yshop.framework.sms.core.client.SmsClientFactory; import co.yixiang.yshop.framework.sms.core.client.SmsClientFactory;
import co.yixiang.yshop.framework.sms.core.client.impl.aliyun.AliyunSmsClient; import co.yixiang.yshop.framework.sms.core.client.impl.aliyun.AliyunSmsClient;
import co.yixiang.yshop.framework.sms.core.client.impl.debug.DebugDingTalkSmsClient;
import co.yixiang.yshop.framework.sms.core.client.impl.tencent.TencentSmsClient;
import co.yixiang.yshop.framework.sms.core.enums.SmsChannelEnum; import co.yixiang.yshop.framework.sms.core.enums.SmsChannelEnum;
import co.yixiang.yshop.framework.sms.core.property.SmsChannelProperties; import co.yixiang.yshop.framework.sms.core.property.SmsChannelProperties;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -41,6 +37,9 @@ public class SmsClientFactoryImpl implements SmsClientFactory {
@Value("${yshop.sms-code.api-secret}") @Value("${yshop.sms-code.api-secret}")
private String apiSecret = "iVP7EsjX309epI7MqsScziGhcrEHiT"; private String apiSecret = "iVP7EsjX309epI7MqsScziGhcrEHiT";
@Value("${yshop.sms-code.signature}")
private String signature = "中科鑫智";
/** /**
* 短信客户端 Map * 短信客户端 Map
* key渠道编码使用 {@link SmsChannelProperties#getCode()} ()} * key渠道编码使用 {@link SmsChannelProperties#getCode()} ()}
@ -55,7 +54,7 @@ public class SmsClientFactoryImpl implements SmsClientFactory {
Arrays.stream(SmsChannelEnum.values()).forEach(channel -> { Arrays.stream(SmsChannelEnum.values()).forEach(channel -> {
// 创建一个空的 SmsChannelProperties 对象 // 创建一个空的 SmsChannelProperties 对象
SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode()) SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode())
.setApiKey(apiKey).setApiSecret(apiSecret); .setApiKey(apiKey).setApiSecret(apiSecret).setSignature(signature);
// 创建 Sms 客户端 // 创建 Sms 客户端
AbstractSmsClient smsClient = createSmsClient(properties); AbstractSmsClient smsClient = createSmsClient(properties);
channelCodeClients.put(channel.getCode(), smsClient); channelCodeClients.put(channel.getCode(), smsClient);

View File

@ -27,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -60,6 +61,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
super(properties, new AliyunSmsCodeMapping()); super(properties, new AliyunSmsCodeMapping());
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空"); Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空"); Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空");
Assert.notEmpty(properties.getSignature(), "短信签名 不能为空");
} }
@Override @Override

View File

@ -63,6 +63,8 @@ public class RedisPendingMessageResendJob {
// 从消费者的 pending 队列中读取消息 // 从消费者的 pending 队列中读取消息
List<MapRecord<String, Object, Object>> records = ops.read(Consumer.from(groupName, consumerName), StreamOffset.create(listener.getStreamKey(), ReadOffset.from("0"))); List<MapRecord<String, Object, Object>> records = ops.read(Consumer.from(groupName, consumerName), StreamOffset.create(listener.getStreamKey(), ReadOffset.from("0")));
if (CollUtil.isEmpty(records)) { if (CollUtil.isEmpty(records)) {
assert records != null;
log.info(records.toString());
return; return;
} }
for (MapRecord<String, Object, Object> record : records) { for (MapRecord<String, Object, Object> record : records) {

View File

@ -17,6 +17,8 @@ public interface ErrorCodeConstants {
ErrorCode SELECT_ADDRESS = new ErrorCode(1008007008, "请选择收货地址"); ErrorCode SELECT_ADDRESS = new ErrorCode(1008007008, "请选择收货地址");
ErrorCode ORDER_GEN_FAIL = new ErrorCode(1008007009, "订单生成失败"); ErrorCode ORDER_GEN_FAIL = new ErrorCode(1008007009, "订单生成失败");
ErrorCode ORDER_PAY_FINISH = new ErrorCode(1008007010, "该订单已支付"); ErrorCode ORDER_PAY_FINISH = new ErrorCode(1008007010, "该订单已支付");
ErrorCode USER_NOT_BINDING_WX_APPLET = new ErrorCode(1008007011, "该用户未绑定微信小程序openid为空");
ErrorCode PAY_YUE_NOT = new ErrorCode(1008007011, "余额不足"); ErrorCode PAY_YUE_NOT = new ErrorCode(1008007011, "余额不足");
ErrorCode ORDER_STATUS_ERROR = new ErrorCode(1008007012, "订单状态错误"); ErrorCode ORDER_STATUS_ERROR = new ErrorCode(1008007012, "订单状态错误");
ErrorCode COMMENT_PRODUCT_NOT_EXISTS = new ErrorCode(1008007013, "评价产品不存在"); ErrorCode COMMENT_PRODUCT_NOT_EXISTS = new ErrorCode(1008007013, "评价产品不存在");

View File

@ -18,18 +18,18 @@ import java.util.stream.Stream;
@AllArgsConstructor @AllArgsConstructor
public enum PayTypeEnum { public enum PayTypeEnum {
ALI("alipay","支付宝支付"), ALI("alipay","支付宝支付","1"),
WEIXIN("weixin","微信支付"), WEIXIN("weixin","微信支付","6"),
WEIXIN_H5("weixin_h5","微信H5支付"), WEIXIN_H5("weixin_h5","微信H5支付","4"),
WEIXIN_APPLET("weixin_applet","微信小程序支付"), WEIXIN_APPLET("weixin_applet","微信小程序支付","3"),
WEIXIN_APP("weixin_app","微信app支付"), WEIXIN_APP("weixin_app","微信app支付","2"),
YUE("yue","余额支付"), YUE("yue","余额支付","10"),
INTEGRAL("integral","积分兑换"); INTEGRAL("integral","积分兑换","11");
private String value; private String value;
private String desc; private String desc;
private String code;
public static PayTypeEnum toType(String value) { public static PayTypeEnum toType(String value) {
return Stream.of(PayTypeEnum.values()) return Stream.of(PayTypeEnum.values())
.filter(p -> p.value.equals(value)) .filter(p -> p.value.equals(value))

View File

@ -75,7 +75,7 @@ public class StoreOrderBaseVO {
private BigDecimal deductionPrice; private BigDecimal deductionPrice;
@Schema(description = "优惠券id", required = true, example = "3299") @Schema(description = "优惠券id", required = true, example = "3299")
@NotNull(message = "优惠券id不能为空") // @NotNull(message = "优惠券id不能为空")
private Long couponId; private Long couponId;
@Schema(description = "优惠券金额", required = true, example = "22157") @Schema(description = "优惠券金额", required = true, example = "22157")

View File

@ -13,4 +13,9 @@ public class AppProsuctParam {
*/ */
private Long productId; private Long productId;
/**
* 商品规格
*/
private String productAttrUnique;
} }

View File

@ -48,9 +48,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception; import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -99,26 +97,54 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
BigDecimal totalPrice = BigDecimal.ZERO; BigDecimal totalPrice = BigDecimal.ZERO;
//拿到所有的商品 //拿到所有的商品
List<StoreOrderCartInfoDO> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<StoreOrderCartInfoDO>lambdaQuery().eq(StoreOrderCartInfoDO::getOid, yxStoreOrder.getId())); List<StoreOrderCartInfoDO> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<StoreOrderCartInfoDO>lambdaQuery().eq(StoreOrderCartInfoDO::getOid, yxStoreOrder.getId()));
List<StoreAfterSalesItemDO> insertAfterSalesItems = new ArrayList<>();
// 所有商品规格合集
Set<String> allProductAttrUniqueSet = new HashSet<>();
for (StoreOrderCartInfoDO yxStoreOrderCartInfo : yxStoreOrderCartInfos) { for (StoreOrderCartInfoDO yxStoreOrderCartInfo : yxStoreOrderCartInfos) {
AppStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), AppStoreCartQueryVo.class); AppStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), AppStoreCartQueryVo.class);
AppProsuctParam productParam = storeAfterSalesParam.getProductParamList().stream().filter(item -> item.getProductId().equals(yxStoreOrderCartInfo.getProductId())).findFirst().orElse(new AppProsuctParam()); allProductAttrUniqueSet.add(cartInfo.getProductAttrUnique());
// 过滤出对应规格的商品
AppProsuctParam productParam = storeAfterSalesParam.getProductParamList().stream()
.filter(item -> cartInfo.getProductAttrUnique().equals(item.getProductAttrUnique()))
.findFirst().orElse(new AppProsuctParam());
if (productParam.getProductId() != null) { if (productParam.getProductId() != null) {
//商品优惠前总金额 //商品优惠前总金额
BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum()); BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum());
//商品优惠总金额
BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); //该项商品优惠金额
BigDecimal commodityDiscountAmount = null;
if (yxStoreOrder.getTotalPrice().compareTo(yxStoreOrder.getPayPostage()) == 0) {
commodityDiscountAmount = totalAmountOfGoods;
} else {
commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil
.sub(yxStoreOrder.getTotalPrice().add(yxStoreOrder.getCouponPrice()),
yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice());
}
//商品优惠后总金额 //商品优惠后总金额
totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
// todo 根据自己的业务逻辑修改,是否退运费,默认不退运费
// 未收货退运费
if (OrderInfoEnum.STATUS_DEFAULT.getValue().equals(yxStoreOrder.getStatus())) {
totalPrice = NumberUtil.add(totalPrice, yxStoreOrder.getPayPostage());
}
yxStoreOrderCartInfo.setIsAfterSales(0); yxStoreOrderCartInfo.setIsAfterSales(0);
storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo); storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo);
// 售后明细
StoreAfterSalesItemDO storeAfterSalesItem = new StoreAfterSalesItemDO();
storeAfterSalesItem.setProductId(yxStoreOrderCartInfo.getProductId());
storeAfterSalesItem.setCartInfo(yxStoreOrderCartInfo.getCartInfo());
insertAfterSalesItems.add(storeAfterSalesItem);
} }
} }
// 退货商品规格合集
Set<String> returnProductAttrUniqueSet =
storeAfterSalesParam.getProductParamList().stream()
.map(AppProsuctParam::getProductAttrUnique).collect(Collectors.toSet());
// 全部退货且未发货退运费
if (allProductAttrUniqueSet.equals(returnProductAttrUniqueSet) &&
OrderInfoEnum.STATUS_DEFAULT.getValue().equals(yxStoreOrder.getStatus())) {
totalPrice = NumberUtil.add(totalPrice, yxStoreOrder.getPayPostage());
}
//更新订单状态 //更新订单状态
yxStoreOrder.setStatus(OrderInfoEnum.STATUS_APPLY_REFUND.getValue()); yxStoreOrder.setStatus(OrderInfoEnum.STATUS_APPLY_REFUND.getValue());
yxStoreOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_BEING_REFUNDED.getValue()); yxStoreOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_BEING_REFUNDED.getValue());
@ -140,15 +166,22 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
storeAfterSales.setCreateTime(LocalDateTime.now()); storeAfterSales.setCreateTime(LocalDateTime.now());
storeAfterSales.setUserId(userId); storeAfterSales.setUserId(userId);
this.baseMapper.insert(storeAfterSales); this.baseMapper.insert(storeAfterSales);
//售后商品详情
for (AppProsuctParam productParam : storeAfterSalesParam.getProductParamList()) { insertAfterSalesItems.forEach(res -> {
StoreOrderCartInfoDO yxStoreOrderCartInfo = yxStoreOrderCartInfos.stream().filter(item -> item.getProductId().equals(productParam.getProductId())).findFirst().orElse(new StoreOrderCartInfoDO()); res.setStoreAfterSalesId(storeAfterSales.getId());
});
// 售后明细批量保存
storeAfterSalesItemMapper.insertBatch(insertAfterSalesItems);
/*for (AppProsuctParam productParam : storeAfterSalesParam.getProductParamList()) {
StoreOrderCartInfoDO yxStoreOrderCartInfo =
yxStoreOrderCartInfos.stream().filter(item -> productParam.getProductId().equals(item.getProductId()))
.findFirst().orElse(new StoreOrderCartInfoDO());
StoreAfterSalesItemDO storeAfterSalesItem = new StoreAfterSalesItemDO(); StoreAfterSalesItemDO storeAfterSalesItem = new StoreAfterSalesItemDO();
storeAfterSalesItem.setStoreAfterSalesId(storeAfterSales.getId()); storeAfterSalesItem.setStoreAfterSalesId(storeAfterSales.getId());
storeAfterSalesItem.setProductId(yxStoreOrderCartInfo.getProductId()); storeAfterSalesItem.setProductId(yxStoreOrderCartInfo.getProductId());
storeAfterSalesItem.setCartInfo(yxStoreOrderCartInfo.getCartInfo()); storeAfterSalesItem.setCartInfo(yxStoreOrderCartInfo.getCartInfo());
storeAfterSalesItemMapper.insert(storeAfterSalesItem); storeAfterSalesItemMapper.insert(storeAfterSalesItem);
} }*/
StoreOrderStatusDO orderStatusDO = StoreOrderStatusDO.builder() StoreOrderStatusDO orderStatusDO = StoreOrderStatusDO.builder()
.oid(yxStoreOrder.getId()).changeType(APPLY_AFTER_SALES.getValue()) .oid(yxStoreOrder.getId()).changeType(APPLY_AFTER_SALES.getValue())
.changeMessage(APPLY_AFTER_SALES.getDesc()).changeTime(LocalDateTime.now()).build(); .changeMessage(APPLY_AFTER_SALES.getDesc()).changeTime(LocalDateTime.now()).build();
@ -256,7 +289,15 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
//商品优惠总金额 //商品优惠总金额
// BigDecimal commodityDiscountAmount = BigDecimal.ZERO; // BigDecimal commodityDiscountAmount = BigDecimal.ZERO;
// if() // if()
BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); BigDecimal commodityDiscountAmount = null;
// 运费金额等于商品总价
if (yxStoreOrder.getTotalPrice().compareTo(yxStoreOrder.getPayPostage()) == 0) {
commodityDiscountAmount = totalAmountOfGoods;
} else {
commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil
.sub(yxStoreOrder.getTotalPrice().add(yxStoreOrder.getCouponPrice()),
yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice());
}
yxStoreOrderCartInfoVo.setRefundablePrice(NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); yxStoreOrderCartInfoVo.setRefundablePrice(NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
@ -271,6 +312,7 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
/** /**
* 查询列表 * 查询列表
*
* @param uid 用户id * @param uid 用户id
* @param status 状态 //状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 * @param status 状态 //状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功
* @param page 页 * @param page 页
@ -282,8 +324,8 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
public List<AppStoreAfterSalesVo> salesList(Long uid, Integer type, Integer page, String orderCode, Integer limit) { public List<AppStoreAfterSalesVo> salesList(Long uid, Integer type, Integer page, String orderCode, Integer limit) {
Page<StoreAfterSalesDO> storeAfterSalesPage = new Page<>(page, limit); Page<StoreAfterSalesDO> storeAfterSalesPage = new Page<>(page, limit);
List<Integer> afterSalesStatusList = getAfterSalesStatus(type); List<Integer> afterSalesStatusList = getAfterSalesStatus(type);
LambdaQueryWrapper<StoreAfterSalesDO> wrappers = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StoreAfterSalesDO> wrappers = new LambdaQueryWrapper<>();
wrappers.eq(uid != null, StoreAfterSalesDO::getUserId, uid) wrappers.eq(uid != null, StoreAfterSalesDO::getUserId, uid)
.in(!type.equals(AfterSalesStatusEnum.PENDING_REVIEW.getValue()), StoreAfterSalesDO::getState, afterSalesStatusList) .in(!type.equals(AfterSalesStatusEnum.PENDING_REVIEW.getValue()), StoreAfterSalesDO::getState, afterSalesStatusList)
.eq(StringUtils.isNotBlank(orderCode), StoreAfterSalesDO::getOrderCode, orderCode); .eq(StringUtils.isNotBlank(orderCode), StoreAfterSalesDO::getOrderCode, orderCode);
baseMapper.selectPage(storeAfterSalesPage, wrappers. baseMapper.selectPage(storeAfterSalesPage, wrappers.
@ -465,7 +507,7 @@ public class AppStoreAfterSalesServiceImpl extends ServiceImpl<StoreAfterSalesMa
StoreOrderDO storeOrderDO = StoreOrderDO storeOrderDO =
storeOrderMapper.selectOne(new LambdaQueryWrapper<StoreOrderDO>() storeOrderMapper.selectOne(new LambdaQueryWrapper<StoreOrderDO>()
.eq(StoreOrderDO::getOrderId, storeAfterSalesVo.getOrderCode())); .eq(StoreOrderDO::getOrderId, storeAfterSalesVo.getOrderCode()));
if(storeOrderDO!= null ) { if (storeOrderDO != null) {
storeAfterSalesVo.setOrderId(storeOrderDO.getId()); storeAfterSalesVo.setOrderId(storeOrderDO.getId());
storeAfterSalesVo.setCompleteTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 3).findFirst().orElse(new StoreAfterSalesStatusDO()).getChangeTime()); storeAfterSalesVo.setCompleteTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 3).findFirst().orElse(new StoreAfterSalesStatusDO()).getChangeTime());
storeAfterSalesVo.setDeliveryTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 2).findFirst().orElse(new StoreAfterSalesStatusDO()).getChangeTime()); storeAfterSalesVo.setDeliveryTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 2).findFirst().orElse(new StoreAfterSalesStatusDO()).getChangeTime());

View File

@ -451,20 +451,16 @@ public class AppStoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, Stor
if (ObjectUtil.isNull(orderInfo)) { if (ObjectUtil.isNull(orderInfo)) {
throw exception(STORE_ORDER_NOT_EXISTS); throw exception(STORE_ORDER_NOT_EXISTS);
} }
if (orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_HAVE_PAID.getValue())) {
throw exception(ORDER_PAY_FINISH);
}
if (orderInfo.getPayInfo() == null) { if (orderInfo.getPayInfo() == null) {
return false; return false;
} }
if (PayTypeEnum.WEIXIN.getValue().equals(param.getPaytype())) { if (PayTypeEnum.WEIXIN.getValue().equals(param.getPaytype())) {
//微信查单 //微信查单
MerchantDetailsDO merchantDetailsDO = merchantDetailsService.getMerchantDetails("4"); MerchantDetailsDO merchantDetailsDO = merchantDetailsService.getMerchantDetails("4");
PayInfo payInfo = JsonUtils.parseObject(orderInfo.getPayInfo(), PayInfo.class); PayInfo payInfo = JsonUtils.parseObject(orderInfo.getPayInfo(), PayInfo.class);
if (payInfo == null) return false; if (payInfo == null) return false;
if (payInfo.getTransaction_id() == null) return false; if (payInfo.getTransaction_id() == null) return false;
Map map = PaymentApi.queryByTransactionId(merchantDetailsDO.getAppid(), merchantDetailsDO.getMchId(), merchantDetailsDO.getKeyPrivate(), payInfo.getTransaction_id()); Map<String, String> map = PaymentApi.queryByTransactionId(merchantDetailsDO.getAppid(), merchantDetailsDO.getMchId(), merchantDetailsDO.getKeyPrivate(), payInfo.getTransaction_id());
log.info("查询到微信订单信息:" + map.toString()); log.info("查询到微信订单信息:" + map.toString());
return map.get("return_code").equals("SUCCESS") && map.get("result_code").equals("SUCCESS") && map.get("trade_state").equals("SUCCESS"); return map.get("return_code").equals("SUCCESS") && map.get("result_code").equals("SUCCESS") && map.get("trade_state").equals("SUCCESS");
} else { } else {
@ -490,15 +486,17 @@ public class AppStoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, Stor
if (orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_HAVE_PAID.getValue())) { if (orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_HAVE_PAID.getValue())) {
throw exception(ORDER_PAY_FINISH); throw exception(ORDER_PAY_FINISH);
} }
//如果是小程序或APP 先获取用户openid
MemberUserDO userDO = memberUserService.getUser(uid);
if (PayTypeEnum.WEIXIN_APPLET.getValue().equals(param.getPaytype())) {
//小程序支付需要openid
if (Objects.isNull(userDO.getRoutineOpenid())) throw exception(USER_NOT_BINDING_WX_APPLET);
}
//微信h5支付商户配置 //微信h5支付商户配置
MerchantDetailsDO merchantDetailsDO = merchantDetailsService.getMerchantDetails("4"); MerchantDetailsDO merchantDetailsDO = merchantDetailsService.getMerchantDetails(PayTypeEnum.toType(param.getPaytype()).getCode());
// paySuccess(orderInfo.getOrderId(), PayTypeEnum.WEIXIN.getValue());
// Map<String, String> packageParams = new HashMap<String, String>();
// packageParams.put("mwebUrl",URLEncoder.encode(merchantDetailsDO.getReturnUrl(), "GBK"));
PayContext payContext = new PayContext(); PayContext payContext = new PayContext();
Map<String, String> packageParams = payContext.selectPayWay(PayEnum.WEIXIN.getCode(), Map<String, String> packageParams = payContext.selectPayWay(PayEnum.WEIXIN.getCode(),
new PayParam(orderInfo.getOrderId(), orderInfo.getPayPrice(), "", ServletUtils.getClientIP(), new PayParam(orderInfo.getOrderId(), orderInfo.getPayPrice(), userDO.getRoutineOpenid(), ServletUtils.getClientIP(),
param.getPaytype(), "Yshop商城", merchantDetailsDO)); param.getPaytype(), "Yshop商城", merchantDetailsDO));
PayInfo payInfo = new PayInfo(); PayInfo payInfo = new PayInfo();
payInfo.setOrderId(orderInfo.getOrderId()); payInfo.setOrderId(orderInfo.getOrderId());
@ -514,7 +512,6 @@ public class AppStoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, Stor
asyncStoreOrderService.orderData(uid); asyncStoreOrderService.orderData(uid);
return packageParams; return packageParams;
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception { public void wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
@ -1025,6 +1022,8 @@ public class AppStoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, Stor
this.regressionStock(order, 0); this.regressionStock(order, 0);
// 取消订单退回优惠券
appCouponRelationService.returnCoupon(order.getCouponId());
this.regressionCoupon(order, 0); this.regressionCoupon(order, 0);
storeOrderMapper.deleteById(order.getId()); storeOrderMapper.deleteById(order.getId());

View File

@ -55,7 +55,7 @@ public interface ErrorCodeConstants {
ErrorCode PRODUCT_COUPON_NOT_EXISTS = new ErrorCode(1008006001, "优惠券不存在!"); ErrorCode PRODUCT_COUPON_NOT_EXISTS = new ErrorCode(1008006001, "优惠券不存在!");
ErrorCode NOT_PRODUCT_COUPON_ERROR = new ErrorCode(1008006002, "无可优惠券!"); ErrorCode NOT_PRODUCT_COUPON_ERROR = new ErrorCode(1008006002, "无可优惠券!");
} }

View File

@ -28,11 +28,19 @@ public interface AppCouponRelationService extends IService<ProductCouponRelation
/** /**
* 核销优惠券 * 核销优惠券
* *
* @param id 优惠券id * @param id 优惠券明细id
* @return * @return
*/ */
void verificationCoupon(Long id); void verificationCoupon(Long id);
/**
* 回退优惠券
*
* @param id 优惠券明细id
* @return
*/
void returnCoupon(Long id);
/** /**
* 查询用户已有优惠券 * 查询用户已有优惠券
* *

View File

@ -16,6 +16,7 @@ import co.yixiang.yshop.module.product.enums.coupon.CouponTypeEnum;
import co.yixiang.yshop.module.product.enums.couponrelation.CouponIsUsedEnum; import co.yixiang.yshop.module.product.enums.couponrelation.CouponIsUsedEnum;
import co.yixiang.yshop.module.product.enums.couponrelation.CouponSearchTypeEnum; import co.yixiang.yshop.module.product.enums.couponrelation.CouponSearchTypeEnum;
import co.yixiang.yshop.module.product.service.productcouponrelation.dto.CartCouponDto; import co.yixiang.yshop.module.product.service.productcouponrelation.dto.CartCouponDto;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -54,10 +55,14 @@ public class AppCouponRelationServiceImpl extends ServiceImpl<ProductCouponRelat
} }
long count = count(new LambdaQueryWrapperX<ProductCouponRelationDO>() long count = count(new LambdaQueryWrapperX<ProductCouponRelationDO>()
.eq(ProductCouponRelationDO::getCouponId, id).eq(ProductCouponRelationDO::getUid, uid)); .eq(ProductCouponRelationDO::getCouponId, id).eq(ProductCouponRelationDO::getUid, uid));
if (CouponReceiveTypeEnum.UNLIMITED.getValue().equals(couponDO.getReceiveType()) || count < couponDO.getLimitNumber()) {
if (couponDO.getNumber() < 1) throw exception(NOT_PRODUCT_COUPON_ERROR);
if (CouponReceiveTypeEnum.UNLIMITED.getValue().equals(couponDO.getReceiveType())
|| count < couponDO.getLimitNumber()) {
ProductCouponRelationDO relationDO = ProductCouponRelationDO.builder().couponId(id).uid(uid).build(); ProductCouponRelationDO relationDO = ProductCouponRelationDO.builder().couponId(id).uid(uid).build();
relationDO.setReceiveTime(LocalDateTime.now()); relationDO.setReceiveTime(LocalDateTime.now());
save(relationDO); save(relationDO);
couponMapper.updateById(ProductCouponDO.builder().id(couponDO.getId()).number(couponDO.getNumber() - 1).build());
} else { } else {
throw exception(PRODUCT_COUPON_RECEIVE_ERROR); throw exception(PRODUCT_COUPON_RECEIVE_ERROR);
} }
@ -69,13 +74,21 @@ public class AppCouponRelationServiceImpl extends ServiceImpl<ProductCouponRelat
if (productCouponDO == null) { if (productCouponDO == null) {
throw exception(PRODUCT_COUPON_NOT_EXISTS); throw exception(PRODUCT_COUPON_NOT_EXISTS);
} }
// 使用优惠券
// 使用优惠券
productCouponDO.setIsUsed(CouponIsUsedEnum.USED.getValue()); productCouponDO.setIsUsed(CouponIsUsedEnum.USED.getValue());
productCouponDO.setUsageTime(LocalDateTime.now()); productCouponDO.setUsageTime(LocalDateTime.now());
updateById(productCouponDO); updateById(productCouponDO);
} }
@Override
public void returnCoupon(Long id) {
// 重置优惠券状态
update(new LambdaUpdateWrapper<ProductCouponRelationDO>()
.set(ProductCouponRelationDO::getIsUsed, CouponIsUsedEnum.NOT_USED.getValue())
.set(ProductCouponRelationDO::getUsageTime, null)
.eq(ProductCouponRelationDO::getId, id));
}
@Override @Override
public List<UserCouponVO> searchUserCoupon(Integer type, Long id) { public List<UserCouponVO> searchUserCoupon(Integer type, Long id) {
List<UserCouponVO> userCouponVOS = this.baseMapper.searchUserCoupon(type, getLoginUserId(), id); List<UserCouponVO> userCouponVOS = this.baseMapper.searchUserCoupon(type, getLoginUserId(), id);

View File

@ -45,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -244,7 +245,7 @@ public class AppStoreProductServiceImpl extends ServiceImpl<StoreProductMapper,
//获取运费模板名称 //获取运费模板名称
String tempName = ""; String tempName = "";
if (storeProduct.getPostage().intValue() == 0 && storeProduct.getTempId() == 0) { if(storeProduct.getPostage().compareTo(BigDecimal.ZERO) == 0 && storeProduct.getTempId() == 0) {
tempName = ProductConstants.FREE_POSTAGE; tempName = ProductConstants.FREE_POSTAGE;
} else { } else {
ShippingTemplatesDO shippingTemplates = shippingTemplatesService.getById(storeProduct.getTempId()); ShippingTemplatesDO shippingTemplates = shippingTemplatesService.getById(storeProduct.getTempId());

View File

@ -15,11 +15,11 @@ import javax.validation.constraints.NotEmpty;
@Builder @Builder
public class AppAuthWeixinMiniAppLoginReqVO { public class AppAuthWeixinMiniAppLoginReqVO {
@Schema(description = "手机 code,小程序通过 wx.getPhoneNumber 方法获得", required = true, example = "hello") @Schema(description = "手机 code,小程序通过 wx.getPhoneNumber 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "hello")
@NotEmpty(message = "手机 code 不能为空") @NotEmpty(message = "手机 code 不能为空")
private String phoneCode; private String phoneCode;
@Schema(description = "登录 code,小程序通过 wx.login 方法获得", required = true, example = "word") @Schema(description = "登录 code,小程序通过 wx.login 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "word")
@NotEmpty(message = "登录 code 不能为空") @NotEmpty(message = "登录 code 不能为空")
private String loginCode; private String loginCode;

View File

@ -161,7 +161,6 @@ public class MemberAuthServiceImpl implements MemberAuthService {
userMapper.updateById(memberUserDO); userMapper.updateById(memberUserDO);
} }
// 创建 Token 令牌,记录登录日志 // 创建 Token 令牌,记录登录日志
return createTokenAfterLoginSuccess(memberUserDO, memberUserDO.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL); return createTokenAfterLoginSuccess(memberUserDO, memberUserDO.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL);
} }

View File

@ -6,6 +6,9 @@ import co.yixiang.yshop.module.pay.strategy.PayFactory;
import lombok.Getter; import lombok.Getter;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
@Getter @Getter
public class PayContext { public class PayContext {

View File

@ -15,7 +15,10 @@ public class WeChatPay implements Pay {
@Override @Override
public Map<String, String> selectPayWay(String payCode, PayParam param) throws Exception { public Map<String, String> selectPayWay(String payCode, PayParam param) throws Exception {
//根据微信type选择不同的支付 H5/APPLET/APP //根据微信type选择不同的支付 H5/APPLET/APP
if (Objects.equals(param.getType(), PayTypeEnum.WEIXIN_H5.getValue())) { if (Objects.equals(param.getType(), PayTypeEnum.WEIXIN_H5.getValue()) ||
Objects.equals(param.getType(), PayTypeEnum.WEIXIN_APP.getValue()) ||
Objects.equals(param.getType(), PayTypeEnum.WEIXIN_APPLET.getValue())
) {
return new WxPayServiceUtils().gotoPay(param); return new WxPayServiceUtils().gotoPay(param);
} }
return Collections.emptyMap(); return Collections.emptyMap();

View File

@ -15,6 +15,9 @@ import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
@Slf4j(topic = "WxPayServiceUtils") @Slf4j(topic = "WxPayServiceUtils")
public class WxPayServiceUtils { public class WxPayServiceUtils {
@ -75,14 +78,14 @@ public class WxPayServiceUtils {
//微信app分配的APPID //微信app分配的APPID
//app_appid //app_appid
outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP"; outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP";
reqParams.put("appid", app_appid); reqParams.put("appid", param.getMerchantDetailsDO().getAppid());
//交易类型 //交易类型
reqParams.put("trade_type", "APP"); reqParams.put("trade_type", "APP");
}else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(param.getType())){ }else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(param.getType())){
//微信app分配的APPID //微信app分配的APPID
//app_appid reqParams.put("openid",param.getOpenid());
outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APPLET"; outTradeNo=param.getOrderId()+"-"+ RandomStringUtil.getRandomCode(3,0)+"APPLET";
reqParams.put("appid", appid); reqParams.put("appid", param.getMerchantDetailsDO().getAppid());
//交易类型 //交易类型
reqParams.put("trade_type", "JSAPI"); reqParams.put("trade_type", "JSAPI");
} }
@ -113,7 +116,7 @@ public class WxPayServiceUtils {
调用支付定义下单API,返回预付单信息 prepay_id 调用支付定义下单API,返回预付单信息 prepay_id
*/ */
String xmlResult = PaymentApi.pushOrder(reqParams); String xmlResult = PaymentApi.pushOrder(reqParams);
log.info("微信下单成功{}",xmlResult); log.info("微信下单信息{}",xmlResult);
Map<String, String> result = PaymentKit.xmlToMap(xmlResult); Map<String, String> result = PaymentKit.xmlToMap(xmlResult);
//预付单信息 //预付单信息
String prepay_id = result.get("prepay_id"); String prepay_id = result.get("prepay_id");
@ -130,6 +133,7 @@ public class WxPayServiceUtils {
String packageSign = WXPayUtil.generateSignature(packageParams, param.getMerchantDetailsDO().getKeyPrivate()); String packageSign = WXPayUtil.generateSignature(packageParams, param.getMerchantDetailsDO().getKeyPrivate());
packageParams.put("paySign", packageSign); packageParams.put("paySign", packageSign);
packageParams.put("codeUrl", result.get("code_url")); packageParams.put("codeUrl", result.get("code_url"));
packageParams.put("orderId", param.getOrderId());
//将组合后的商户订单号返回 //将组合后的商户订单号返回
packageParams.put("out_trade_no", outTradeNo); packageParams.put("out_trade_no", outTradeNo);
packageParams.put("merchant_id", param.getMerchantDetailsDO().getMchId()); packageParams.put("merchant_id", param.getMerchantDetailsDO().getMchId());

View File

@ -81,7 +81,7 @@ public class WxPayServiceImpl implements WxPayService {
//微信app分配的APPID //微信app分配的APPID
//app_appid //app_appid
outTradeNo=orderId+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP"; outTradeNo=orderId+"-"+ RandomStringUtil.getRandomCode(3,0)+"APP";
reqParams.put("appid", app_appid); reqParams.put("appid", merchantDetailsDO.getAppid());
//交易类型 //交易类型
reqParams.put("trade_type", "APP"); reqParams.put("trade_type", "APP");
}else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(type)){ }else if(PayTypeEnum.WEIXIN_APPLET.getValue().equals(type)){