修改配送方式问题

main
13233904609 4 weeks ago
parent 7c0f65f4ce
commit 1b288400da

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.api.spu.dto;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import lombok.Data;
import java.util.List;
// TODO @LeeYan9: ProductSpuRespDTO
/**
* SPU Response DTO
@ -93,4 +95,6 @@ public class ProductSpuRespDTO {
*/
private Boolean subCommissionType;
private List<Integer> deliveryTypes;
}

@ -94,4 +94,6 @@ public interface ErrorCodeConstants {
ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元");
ErrorCode VERIFY_LOG_NOT_EXISTS = new ErrorCode(1_011_008_004, "门店核销记录不存在");
ErrorCode DELIVERY_NOT_EXISTS = new ErrorCode(1_011_008_005, "订单中商品某个商品配送方式不支持");
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.controller.app.order;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@ -48,12 +49,15 @@ import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.DELIVERY_NOT_EXISTS;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_UPDATE_PAID_STATUS_NOT_UNPAID;
@Tag(name = "用户 App - 交易订单")
@RestController
@ -139,6 +143,19 @@ public class AppTradeOrderController {
LoginUser loginUser = getLoginUser();
createReqVO.setReceiverName(loginUser.getInfo().getOrDefault("nickname",""));
createReqVO.setReceiverMobile(loginUser.getInfo().getOrDefault("mobile",""));
//判断商品配送方式
List<AppTradeOrderSettlementReqVO.Item> items = createReqVO.getItems();
if(ObjectUtil.isNotEmpty(items)){
for (AppTradeOrderSettlementReqVO.Item item:items) {
ProductSkuRespDTO sku = productSkuApi.getSku(item.getSkuId());
ProductSpuRespDTO spu = productSpuApi.getSpu(sku.getSpuId());
if(ObjectUtil.isNotEmpty(spu.getDeliveryTypes())){
if(!CollUtil.contains(spu.getDeliveryTypes(),createReqVO.getDeliveryType())){
throw exception0(1_011_008_006,"商品:"+spu.getName()+"配送方式不支持,请修改后重新提交!");
}
}
}
}
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO);
return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId()));
}

@ -38,14 +38,16 @@ import javax.annotation.Resource;
import javax.validation.Validator;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import org.springframework.core.io.ResourceLoader;
import org.springframework.beans.factory.annotation.Value;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.RECHARGE;
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.*;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
/**
@ -134,19 +136,35 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
paramMap.put("alipay_cert_path_string", keyContent1);
paramMap.put("alipay_root_cert_path_string", keyContent2);
paramMap.put("remark", "余额提现到支付宝");
paramMap.put("out_biz_no", "111222333");
paramMap.put("account", "13233904609");//账号
paramMap.put("name", "马腾达");
paramMap.put("amount", "0.1");
String result= HttpUtil.post(gateway, paramMap);
paramMap.put("out_biz_no", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())+"-"+withdraw.getId());
paramMap.put("account", withdraw.getAccountNo());//账号
paramMap.put("name", withdraw.getName());
paramMap.put("amount", BigDecimal.valueOf(withdraw.getPrice()).subtract(BigDecimal.valueOf(withdraw.getFeePrice())).divide(BigDecimal.valueOf(100)));
String result= HttpUtil.post(gateway, JSON.toJSONString(paramMap));
JSONObject jsonObject = JSONObject.parseObject(result);
if(jsonObject.containsKey("msg")){
if(ObjectUtil.equal("success",jsonObject.getString("msg"))){
withdraw.setStatus(11);
withdraw.setAuditTime(LocalDateTime.now());
}else{
withdraw.setStatus(21);
withdraw.setAuditTime(LocalDateTime.now());
//提现失败返还余额
PayWalletDTO orCreateWallet = payWalletApi.getOrCreateWallet(withdraw.getUserId(), 1);
payWalletApi.addWalletBalance(orCreateWallet.getId(),withdraw.getId()+"",WITHDRAW_LOSE,withdraw.getPrice());
}
}
brokerageWithdrawMapper.updateById(withdraw);
System.out.println(result);
}
// TODO 疯狂:调用转账接口
} else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) {
templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT;
// 3.2 驳回时需要退还用户佣金
brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT,
String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle());
//提现失败返还余额
PayWalletDTO orCreateWallet = payWalletApi.getOrCreateWallet(withdraw.getUserId(), 1);
payWalletApi.addWalletBalance(orCreateWallet.getId(),withdraw.getId()+"",WITHDRAW_REJECT,withdraw.getPrice());
withdraw.setStatus(20);
withdraw.setAuditTime(LocalDateTime.now());
brokerageWithdrawMapper.updateById(withdraw);
} else {
throw new IllegalArgumentException("不支持的提现状态:" + status);
}

@ -20,7 +20,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
PAYMENT(3, "支付"),
PAYMENT_REFUND(4, "支付退款"),
WITHDRAW(5, "提现申请"),
WITHDRAW_REJECT(6, "提现申请驳回");
WITHDRAW_REJECT(6, "提现申请驳回"),
WITHDRAW_LOSE(7, "提现失败退还零钱");

@ -162,6 +162,8 @@ public class PayOrderServiceImpl implements PayOrderService {
PayChannelDO channel = validateChannelCanSubmit(order.getAppId(), reqVO.getChannelCode());
PayClient client = channelService.getPayClient(channel.getId());
//校验配送方式否支持
// 2. 插入 PayOrderExtensionDO
String no = noRedisDAO.generate(payProperties.getOrderNoPrefix());
PayOrderExtensionDO orderExtension = PayOrderConvert.INSTANCE.convert(reqVO, userIp)

@ -233,6 +233,14 @@ public class PayWalletServiceImpl implements PayWalletService {
walletMapper.updateWhenRecharge(payWallet.getId(), price);
break;
}
case WITHDRAW_REJECT: { // 充值更新
walletMapper.updateWhenRecharge(payWallet.getId(), price);
break;
}
case WITHDRAW_LOSE: { // 充值更新
walletMapper.updateWhenRecharge(payWallet.getId(), price);
break;
}
default: {
// TODO 其它类型待实现
throw new UnsupportedOperationException("待实现");

Loading…
Cancel
Save