Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop into feature/pg

This commit is contained in:
paulGao
2022-01-21 19:01:10 +08:00
15 changed files with 167 additions and 44 deletions

View File

@@ -36,9 +36,9 @@ public final class CurrencyUtil {
return result.doubleValue();
}
/**
* 提供精确的法运算。
* 提供精确的法运算。
*
* @return 累加之和
* @return 第一个参数为被减数,其余数字为减数
*/
public static Double sub(double... params) {
BigDecimal result = BigDecimal.valueOf(params[0]);

View File

@@ -103,7 +103,7 @@ public class GoodsOperationDTO implements Serializable {
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
*/
@ApiModelProperty(value = "商品类型")
@EnumValue(strValues = {"PHYSICAL_GOODS","VIRTUAL_GOODS","E_COUPON"},message = "商品类型参数值错误")
@EnumValue(strValues = {"PHYSICAL_GOODS", "VIRTUAL_GOODS", "E_COUPON"}, message = "商品类型参数值错误")
private String goodsType;
/**
@@ -112,6 +112,9 @@ public class GoodsOperationDTO implements Serializable {
@ApiModelProperty(value = "商品视频")
private String goodsVideo;
public String getGoodsName() {
//对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤影响很大。
// 业务中,全局代码中只有商品名称不能拥有英文逗号,是由于商品名称存在一个数据库联合查询,结果要根据逗号分组
return goodsName.replace(",", "");
}
}

View File

@@ -1,5 +1,6 @@
package cn.lili.modules.order.order.entity.dos;
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
import cn.lili.mybatis.BaseEntity;
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
@@ -82,6 +83,7 @@ public class Trade extends BaseEntity {
}
BeanUtil.copyProperties(tradeDTO, this);
BeanUtil.copyProperties(tradeDTO.getPriceDetailDTO(), this);
this.setPayStatus(PayStatusEnum.UNPAID.name());
this.setId(originId);
}
}

View File

@@ -309,7 +309,7 @@ public class PriceDetailDTO implements Serializable {
}
public Double getUpdatePrice() {
if (updatePrice == null || updatePrice <= 0) {
if (updatePrice == null) {
return 0D;
}
return updatePrice;

View File

@@ -16,5 +16,10 @@ public enum OrderTypeEnum {
/**
* 虚拟订单
*/
VIRTUAL
VIRTUAL,
/**
* 虚拟订单
*/
E_COUPON,
}

View File

@@ -16,6 +16,7 @@ import cn.lili.modules.order.order.service.OrderPriceService;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.payment.kit.plugin.bank.BankTransferPlugin;
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +30,7 @@ import java.util.List;
* @author Chopper
* @since 2020/11/17 7:36 下午
*/
@Slf4j
@Service
public class OrderPriceServiceImpl implements OrderPriceService {
@@ -106,10 +108,8 @@ public class OrderPriceServiceImpl implements OrderPriceService {
//订单修改金额=使用订单原始金额-修改后金额
orderPriceDetailDTO.setUpdatePrice(CurrencyUtil.sub(orderPrice, orderPriceDetailDTO.getOriginalPrice()));
order.setFlowPrice(orderPriceDetailDTO.getFlowPrice());
order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO));
//修改订单
order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO));
order.setPriceDetailDTO(orderPriceDetailDTO);
orderService.updateById(order);
//修改子订单

View File

@@ -642,7 +642,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
public Double getPaymentTotal(String orderSn) {
Order order = this.getBySn(orderSn);
Trade trade = tradeService.getBySn(order.getTradeSn());
if (trade.getPayStatus().equals(PayStatusEnum.PAID.name())) {
//如果交易不为空,则返回交易的金额,否则返回订单金额
if (StringUtils.isNotEmpty(trade.getPayStatus())
&& trade.getPayStatus().equals(PayStatusEnum.PAID.name())) {
return trade.getFlowPrice();
}
return order.getFlowPrice();

View File

@@ -273,7 +273,7 @@ public class AliPayPlugin implements Payment {
log.info("支付回调通知:支付失败-参数:{}", map);
}
ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap()+"/pages/order/myOrder?status=0");
ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap() + "/pages/order/myOrder?status=0");
} catch (Exception e) {
log.error("支付回调同步通知异常", e);
}
@@ -293,7 +293,11 @@ public class AliPayPlugin implements Payment {
log.info("支付回调响应:{}", JSONUtil.toJsonStr(map));
boolean verifyResult = AlipaySignature.rsaCertCheckV1(map, alipayPaymentSetting.getAlipayPublicCertPath(), "UTF-8",
"RSA2");
//支付完成判定
if (!"TRADE_FINISHED".equals(map.get("trade_status")) &&
!"TRADE_SUCCESS".equals(map.get("trade_status"))) {
return;
}
String payParamStr = map.get("passback_params");
String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8);
PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam());

View File

@@ -258,9 +258,6 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
String appid = setting.getAppId();
if (appid == null) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
.setAppid(appid)
.setMchid(setting.getMchId())
@@ -326,9 +323,6 @@ public class WechatPlugin implements Payment {
WechatPaymentSetting setting = wechatPaymentSetting();
String appid = setting.getServiceAppId();
if (appid == null) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
.setAppid(appid)
.setMchid(setting.getMchId())
@@ -397,10 +391,6 @@ public class WechatPlugin implements Payment {
//微信小程序appid 需要单独获取这里读取了联合登陆配置的appid 实际场景小程序自动登录所以这个appid是最为保险的做法
//如果有2开需求这里需要调整修改这个appid的获取途径即可
String appid = wechatPaymentSetting().getMpAppId();
if (appid == null) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
WechatPaymentSetting setting = wechatPaymentSetting();

View File

@@ -20,7 +20,10 @@ public class PointSetting implements Serializable {
@ApiModelProperty(value = "注册")
private Integer register;
@ApiModelProperty(value = "1元等级*积分")
@ApiModelProperty(value = "消费1元赠送多少积分")
private Integer consumer;
@ApiModelProperty(value = "积分付款X积分=1元")
private Integer money;
@ApiModelProperty(value = "每日签到积分")
@@ -32,5 +35,38 @@ public class PointSetting implements Serializable {
@ApiModelProperty(value = "积分具体设置")
private List<PointSettingItem> pointSettingItems = new ArrayList<>();
public Integer getRegister() {
if (register == null || register < 0) {
return 0;
}
return register;
}
public Integer getMoney() {
if (money == null || money < 0) {
return 0;
}
return money;
}
public Integer getConsumer() {
if (consumer == null || consumer < 0) {
return 0;
}
return consumer;
}
public Integer getSignIn() {
if (signIn == null || signIn < 0) {
return 0;
}
return signIn;
}
public Integer getComment() {
if (comment == null || comment < 0) {
return 0;
}
return comment;
}
}

View File

@@ -20,6 +20,17 @@ public class PointSettingItem implements Comparable<PointSettingItem> {
@ApiModelProperty(value = "赠送积分")
private Integer point;
public Integer getPoint() {
if (point != null || point < 0) {
return 0;
}
return point;
}
public void setPoint(Integer point) {
this.point = point;
}
@Override
public int compareTo(PointSettingItem pointSettingItem) {
return this.day - pointSettingItem.getDay();

View File

@@ -1,5 +1,8 @@
package cn.lili.modules.system.entity.dto.payment;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import com.alibaba.druid.util.StringUtils;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -14,7 +17,7 @@ import lombok.experimental.Accessors;
public class WechatPaymentSetting {
/**
* APP应用id
* APP应用id
*/
private String appId;
/**
@@ -49,4 +52,26 @@ public class WechatPaymentSetting {
* apiv3私钥
*/
private String apiKey3;
public String getAppId() {
if (StringUtils.isEmpty(appId)) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
return appId;
}
public String getMpAppId() {
if (StringUtils.isEmpty(mpAppId)) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
return mpAppId;
}
public String getServiceAppId() {
if (StringUtils.isEmpty(serviceAppId)) {
throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING);
}
return serviceAppId;
}
}