Просмотр исходного кода

[B端退款][修复]:B端小程序核销退款修改

release_toaliyun_real
Stormeye.Wu 7 лет назад
Родитель
Сommit
aa580f4ced
7 измененных файлов: 75 добавлений и 11 удалений
  1. +21
    -0
      mallinkBApi/src/main/java/com/simple/config/WebMvcConfig.java
  2. +13
    -0
      mallinkBApi/src/main/java/com/simple/controller/BaseController.java
  3. +2
    -2
      mallinkBApi/src/main/java/com/simple/controller/WxCouponController.java
  4. +21
    -4
      mallinkBApi/src/main/java/com/simple/controller/WxCouponOrderController.java
  5. +7
    -0
      mallinkService/src/main/java/com/simple/common/ErrorCode.java
  6. +1
    -1
      mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java
  7. +10
    -4
      mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java

+ 21
- 0
mallinkBApi/src/main/java/com/simple/config/WebMvcConfig.java Просмотреть файл

@@ -1,14 +1,20 @@
package com.simple.config;

import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.simple.interceptor.AuthorizationInterceptor;
import com.simple.resolver.LoginUserHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.math.BigInteger;
import java.util.List;

/**
@@ -44,4 +50,19 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
//registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/");

}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter fastConverter =
new FastJsonHttpMessageConverter();

FastJsonConfig fastJsonConfig = new FastJsonConfig();
SerializeConfig serializeConfig = SerializeConfig.globalInstance;
serializeConfig.put(BigInteger.class, ToStringSerializer.instance);
serializeConfig.put(Long.class, ToStringSerializer.instance);
serializeConfig.put(Long.TYPE, ToStringSerializer.instance);
fastJsonConfig.setSerializeConfig(serializeConfig);
fastConverter.setFastJsonConfig(fastJsonConfig);
converters.add(fastConverter);
}
}

+ 13
- 0
mallinkBApi/src/main/java/com/simple/controller/BaseController.java Просмотреть файл

@@ -88,4 +88,17 @@ public class BaseController {
service.setWxMaConfig(config);
return service;
}

public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) {
WxMaInMemoryConfig config = new WxMaInMemoryConfig();
config.setAppid(appinfo.getAppId());
config.setSecret(appinfo.getSecret());
config.setToken(appinfo.getToken());
config.setAesKey(appinfo.getAesKey());
config.setMsgDataFormat(appinfo.getMsgDataFormat());

WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(config);
return service;
}
}

+ 2
- 2
mallinkBApi/src/main/java/com/simple/controller/WxCouponController.java Просмотреть файл

@@ -19,11 +19,11 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping("wxCoupon")
public class WxCouponController extends BaseController
{
private Logger logger = Logger.getLogger(WxCouponController.class);

@Autowired
private WxCouponService wxCouponService;

private Logger logger = Logger.getLogger(WxCouponController.class);
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({


+ 21
- 4
mallinkBApi/src/main/java/com/simple/controller/WxCouponOrderController.java Просмотреть файл

@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
@RequestMapping("wxCouponOrder")
@RequestMapping("/api/couponOrder")
@Api(description="核销和用户卡券查询接口")
public class WxCouponOrderController extends BaseController
{
@@ -88,7 +88,16 @@ public class WxCouponOrderController extends BaseController
logger.error("couponOrderId参数不正确: " + paramMap.toString());
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "couponOrderId参数不正确");
}
return wxCouponOrderService.verify(couponOrderId, getUser().getId());
try {
ResultData rd = wxCouponOrderService.verify(couponOrderId, getUser().getId());
return rd;
} catch (MallinkException e) {
logger.error("核销异常: " + e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error("核销异常: " + e.getMessage());
return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage());
}
}

@ApiOperation(value = "退券接口", notes = "{\"couponOrderId\":\"string\"}")
@@ -104,10 +113,18 @@ public class WxCouponOrderController extends BaseController
try {
couponOrderId = Long.valueOf(couponOrderIdStr);
} catch (NumberFormatException e) {
couponOrderId = 0L;
logger.error("couponOrderId参数不正确: " + paramMap.toString());
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "couponOrderId参数不正确");
}
return wxCouponOrderService.refund(couponOrderId, getUser().getId());
try {
ResultData rd = wxCouponOrderService.refund(couponOrderId, getUser().getId());
return rd;
} catch (MallinkException e) {
logger.error("退券异常: " + e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error("退券异常: " + e.getMessage());
return new ResultData(ErrorCode.REFUND_ORDER_ERROR, e.getMessage());
}
}
}

+ 7
- 0
mallinkService/src/main/java/com/simple/common/ErrorCode.java Просмотреть файл

@@ -108,6 +108,13 @@ public enum ErrorCode{
APP_ID_NOT_FOUND(12020, "APPID没找到"),
MCH_INFO_NOT_FOUND(12021, "商户信息没找到"),
MCH_INFO_NOT_EQUAL(12022, "商户信息不对应"),
API_KEY_NOT_FOUND(12023, "支付密钥未配置"),
CERT_PATH_NOT_FOUND(12024, "双向证书未配置"),

/**
* 核销
*/
VERIFY_ERROR(12050, "核销异常")
;




+ 1
- 1
mallinkService/src/main/java/com/simple/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -103,7 +103,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) {
logger.error("已经核销过的券: couponOrder-" + couponOrderId);
return new ResultData(ErrorCode.COUPON_ORDER_IS_USED);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED);
}
try {
wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废


+ 10
- 4
mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java Просмотреть файл

@@ -23,6 +23,7 @@ import com.simple.service.WxRefundOrderService;
import com.simple.utils.BeanUtils;
import com.simple.utils.Utility;
import com.simple.utils.XmlUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -210,6 +211,15 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {

@Override
public ResultData createRefundOrder(WxAppinfo appInfo, WxRefundOrder record, EnumPayWay payWay) {
WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId());
if (StringUtils.isBlank(payAccount.getApiKey())) {
logger.error("支付密钥为空");
throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(), "支付密钥为空,请联系商城管理员");
}
if (StringUtils.isBlank(payAccount.getCertPath())) {
logger.error("证书路径为空");
throw new MallinkException(ErrorCode.CERT_PATH_NOT_FOUND.getCode(), "证书路径为空,请联系商城管理员");
}
// check 是否有退款订单
List<WxRefundOrder> list = wxRefundOrderMapper.findList(record);
if (list.size() > 0) {
@@ -246,8 +256,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_ZERO);
}

// TODO check 可退券????

// 创建退款订单
final IdWorker idWorker = IdWorker.get();
Long id = idWorker.nextId();
@@ -274,8 +282,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService {
throw new MallinkException(ErrorCode.DB_FAIL);
}

WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId());

// 退款申请
String noncestr = Utility.generate32UUID();
WxRefundOrderP wxRefundOrderP = new WxRefundOrderP();


Загрузка…
Отмена
Сохранить