Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product_new

pull/2/head
perry 2023-05-18 13:25:53 +08:00
commit 09659b936c
9 changed files with 189 additions and 28 deletions

View File

@ -46,4 +46,6 @@ public class OrderPayRequest {
@Schema(description = "下单时小程序的场景值")
private Integer scene;
@Schema(description = "openid")
private String openid;
}

View File

@ -21,7 +21,7 @@ import java.util.Map;
* @version: V1.0.0
*/
@Slf4j
@RequestMapping("notify/ali")
@RequestMapping("notify/ali/")
@RestController
@Tag(name = "支付宝支付回调 - 订单支付")
public class AliPayNotifyController {

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.module.shop.dal.mysql.express;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ExpressMapper extends BaseMapper<ExpressDO> {
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.shop.service.express;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* ExpressService
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Service
@Validated
public interface ExpressService {
/**
*
* @param code
* @return ExpressDO
*/
ExpressDO getByCode(String code);
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.shop.service.express.impl;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import cn.iocoder.yudao.module.shop.dal.mysql.express.ExpressMapper;
import cn.iocoder.yudao.module.shop.service.express.ExpressService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class ExpressServiceImpl implements ExpressService {
@Resource
private ExpressMapper dao;
/**
*
* @param code
*/
@Override
public ExpressDO getByCode(String code) {
LambdaQueryWrapper<ExpressDO> lqw = new LambdaQueryWrapper<>();
lqw.eq(ExpressDO::getCode, code);
ExpressDO expressDO = dao.selectOne(lqw);
return expressDO;
}
}

View File

@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.Constants;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserBillDTO;
@ -22,12 +24,17 @@ import cn.iocoder.yudao.module.shop.service.product.StoreProductService;
import cn.iocoder.yudao.module.shop.utils.OrderUtil;
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.WxPayJsResultVo;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.service.WxPayService;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert;
import java.math.BigDecimal;
import java.util.HashMap;
@ -86,6 +93,12 @@ public class OrderPayServiceImpl implements OrderPayService {
@Autowired
private ApiConfigApi apiConfigApi;
@Autowired
private WxPayOneAutoConfiguration wxPayOneAutoConfiguration;
@Autowired
private WxPayProperties payProperties;
/**
*
@ -104,7 +117,7 @@ public class OrderPayServiceImpl implements OrderPayService {
// billList.add(userBill);
// 更新用户下单数量
// user.setPayCount(user.getPayCount() + 1);
// user.setPayCount(user.getPayCount() + 1);
Boolean execute = transactionTemplate.execute(e -> {
@ -135,6 +148,7 @@ public class OrderPayServiceImpl implements OrderPayService {
/**
*
*
* @param storeOrder
* @return Boolean Boolean
*/
@ -191,7 +205,7 @@ public class OrderPayServiceImpl implements OrderPayService {
storeOrder.setIsChannel(3);
}
if (orderPayRequest.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
switch (orderPayRequest.getPayChannel()){
switch (orderPayRequest.getPayChannel()) {
case PayConstants.PAY_CHANNEL_WE_CHAT_H5:// H5
storeOrder.setIsChannel(2);
break;
@ -229,7 +243,7 @@ public class OrderPayServiceImpl implements OrderPayService {
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
// 预下单
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip);
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid());
response.setStatus(true);
WxPayJsResultVo vo = new WxPayJsResultVo();
vo.setAppId(unifiedorder.get("appId"));
@ -266,11 +280,12 @@ public class OrderPayServiceImpl implements OrderPayService {
/**
*
*
* @param storeOrder
* @param ip ip
* @param ip ip
* @return
*/
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip) {
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip,String openid) {
// 获取用户openId
// 根据订单支付类型来判断获取公众号openId还是小程序openId
@ -314,6 +329,25 @@ public class OrderPayServiceImpl implements OrderPayService {
// if (storeOrder.getIsChannel() == 2) {
// map.put("mweb_url", responseVo.getMWebUrl());
// }
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
Assert.notNull(wxPayService, "获取微信支付配置失败!");
WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request();
int sum = storeOrder.getPayPrice().multiply(new BigDecimal("100")).intValue();
wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum));
wxPayRequest.setDescription("会员充值");
wxPayRequest.setOutTradeNo(storeOrder.getOrderId());
wxPayRequest.setNotifyUrl(payProperties.getNotifyUrl());
wxPayRequest.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(openid));
wxPayRequest.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(ip));
wxPayRequest.setAppid(payProperties.getAppId());
wxPayRequest.setMchid(payProperties.getMchId());
try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
} catch (Exception e) {
e.getMessage();
}
return map;
}
}

View File

@ -13,8 +13,10 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.pay.properties.AliPayProperties;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
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.express.ExpressDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
@ -31,6 +33,8 @@ import cn.iocoder.yudao.module.shop.request.order.StoreOrderSendRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderUpdatePriceRequest;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import cn.iocoder.yudao.module.shop.response.order.*;
import cn.iocoder.yudao.module.shop.service.express.ExpressService;
import cn.iocoder.yudao.module.shop.service.onepass.OnePassService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderRefundService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
@ -43,12 +47,12 @@ import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
import cn.iocoder.yudao.module.shop.vo.product.MyRecord;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
@ -69,7 +73,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -126,6 +129,15 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
@Autowired
private AliPayProperties aliPayProperties;
@Autowired
private ExpressService expressService;
@Autowired
private ApiConfigApi apiConfigApi;
// @Autowired
// private OnePassService onePassService;
/**
* PC
*
@ -429,7 +441,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
StoreOrder info = getInfoException(orderNo);
if (info.getType().equals(1)) {// 视频号订单
// TODO 快递信息
// Express express = expressService.getByName(info.getDeliveryName());
// ExpressDO express = expressService.getByName(info.getDeliveryName());
// if (ObjectUtil.isNotNull(express)) {
// info.setDeliveryCode(express.getCode());
// } else {
@ -1461,22 +1473,22 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private void express(StoreOrderSendRequest request, StoreOrder storeOrder) {
// 校验快递发货参数
validateExpressSend(request);
// TODO 快递公司信息
// Express express = expressService.getByCode(request.getExpressCode());
// if (request.getExpressRecordType().equals("1")) { // 正常发货
// deliverGoods(request, storeOrder);
// }
// 快递公司信息
ExpressDO express = expressService.getByCode(request.getExpressCode());
if (request.getExpressRecordType().equals("1")) { // 正常发货
deliverGoods(request, storeOrder);
}
// if (request.getExpressRecordType().equals("2")) { // 电子面单
// request.setExpressName(express.getName());
// expressDump(request, storeOrder, express);
// }
//
// storeOrder.setDeliveryCode(express.getCode());
// storeOrder.setDeliveryName(express.getName());
// storeOrder.setStatus(1);
// storeOrder.setDeliveryType("express");
String message = Constants.ORDER_LOG_MESSAGE_EXPRESS.replace("{deliveryName}", request.getExpressName()).replace("{deliveryCode}", storeOrder.getDeliveryId());
storeOrder.setDeliveryCode(express.getCode());
storeOrder.setDeliveryName(express.getName());
storeOrder.setStatus(1);
storeOrder.setDeliveryType("express");
String message = Constants.ORDER_LOG_MESSAGE_EXPRESS.replace("{deliveryName}", express.getName()).replace("{deliveryCode}", storeOrder.getDeliveryId());
Boolean execute = transactionTemplate.execute(i -> {
updateById(storeOrder);
@ -1490,6 +1502,56 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
sendGoodsNotify(storeOrder);
}
// /**
// * 电子面单
// * @param request
// * @param storeOrder
// * @param express
// */
// private void expressDump(StoreOrderSendRequest request, StoreOrder storeOrder, ExpressDO express) {
// String configExportOpen = apiConfigApi.getConfigKey("config_export_open").toString();
// if (!configExportOpen.equals("1")) {// 电子面单未开启
// throw new ServiceException("请先开启电子面单");
// }
// MyRecord record = new MyRecord();
// record.set("com", express.getCode());// 快递公司编码
// record.set("to_name", storeOrder.getRealName());// 收件人
// record.set("to_tel", storeOrder.getUserPhone());// 收件人电话
// record.set("to_addr", storeOrder.getUserAddress());// 收件人详细地址
// record.set("from_name", request.getToName());// 寄件人
// record.set("from_tel", request.getToTel());// 寄件人电话
// record.set("from_addr", request.getToAddr());// 寄件人详细地址
// record.set("temp_id", request.getExpressTempId());// 电子面单模板ID
// String siid = apiConfigApi.getConfigKey("config_export_siid").toString();
// record.set("siid", siid);// 云打印机编号
// record.set("count", storeOrder.getTotalNum());// 商品数量
//
// //获取购买商品名称
// List<Integer> orderIdList = new ArrayList<>();
// orderIdList.add(storeOrder.getId());
// HashMap<Integer, List<StoreOrderInfoOldVo>> orderInfoMap = StoreOrderInfoService.getMapInId(orderIdList);
// if (orderInfoMap.isEmpty() || !orderInfoMap.containsKey(storeOrder.getId())) {
// throw new ServiceException("没有找到购买的商品信息");
// }
// List<String> productNameList = new ArrayList<>();
// for (StoreOrderInfoOldVo storeOrderInfoVo : orderInfoMap.get(storeOrder.getId())) {
// productNameList.add(storeOrderInfoVo.getInfo().getProductName());
// }
//
// record.set("cargo", String.join(",", productNameList));// 物品名称
// if (express.getPartnerId()) {
// record.set("partner_id", express.getAccount());// 电子面单月结账号(部分快递公司必选)
// }
// if (express.getPartnerKey()) {
// record.set("partner_key", express.getPassword());// 电子面单密码(部分快递公司必选)
// }
// if (express.getNet()) {
// record.set("net", express.getNetName());// 收件网点名称(部分快递公司必选)
// }
//
// MyRecord myRecord = onePassService.expressDump(record);
// storeOrder.setDeliveryId(myRecord.getStr("kuaidinum"));
// }
/**
*
*/
@ -1500,7 +1562,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
}
if (StrUtil.isBlank(request.getExpressCode())) throw new ServiceException("请选择快递公司");
if (StrUtil.isBlank(request.getExpressRecordType())) throw new ServiceException("请选择发货记录类型");
if (StrUtil.isBlank(request.getExpressTempId())) throw new ServiceException("请选择电子面单");
// if (StrUtil.isBlank(request.getExpressTempId())) throw new ServiceException("请选择电子面单");
if (StrUtil.isBlank(request.getToName())) throw new ServiceException("请填写寄件人姓名");
if (StrUtil.isBlank(request.getToTel())) throw new ServiceException("请填写寄件人电话");
if (StrUtil.isBlank(request.getToAddr())) throw new ServiceException("请填写寄件人地址");

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.shop.support.pay;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
@ -61,12 +60,6 @@ public class WxPayStrategy implements IPayStrategy{
return response;
}
public static void main(String[] args) {
String article="MEMBER_11111";
article=article.replace("MEMBER","TUIKUAN");
System.out.println(article);
}
@Override
public void refund(RechargeOrderDO orderDO) {
WxPayRefundV3Request wxPayRefundV3Request = new WxPayRefundV3Request();

View File

@ -215,6 +215,8 @@ yudao:
- cy_recharge_order_info
- cy_refund_fee_record
- market_banner
- eb_express
- eb_store_order_status
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m