|
|
@@ -111,30 +111,33 @@ public class WxServiceImpl implements WxService {
|
|
|
|
|
|
// 查找该用户在这家店有几个订单
|
|
|
Long shopId = tbOrder.getShopId();
|
|
|
-
|
|
|
- // 查询用户在当天该店铺内状态为 7、6、3、4 的订单数量
|
|
|
- String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
- String startTime = currentDate + " 00:00:00";
|
|
|
- String endTime = currentDate + " 23:59:59";
|
|
|
- List<Integer> statusList = new ArrayList<>();
|
|
|
- statusList.add(7); // 商家待接单
|
|
|
- statusList.add(6); // 制作中
|
|
|
- statusList.add(3); // 待取餐/派送中
|
|
|
- statusList.add(4); // 已完成
|
|
|
-
|
|
|
- int orderCount = appOrderDao.countByUserIdAndShopIdAndStatusListAndTimeRange(
|
|
|
- userId, shopId, startTime, endTime, statusList);
|
|
|
-
|
|
|
- log.info("getTransactionsParam==>[userId:{}, shopId:{}],当天状态为7、6、3、4的订单数量:{}",
|
|
|
- userId, shopId, orderCount);
|
|
|
-
|
|
|
- if (orderCount>=10) {
|
|
|
- throw new SqxException("该商户当天的订单量已超过当前限额!");
|
|
|
+ // 不为乐豆家则需要去判断
|
|
|
+ if (shopId != 384L) {
|
|
|
+
|
|
|
+ // 查询用户在当天该店铺内状态为 7、6、3、4 的订单数量
|
|
|
+ String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ String startTime = currentDate + " 00:00:00";
|
|
|
+ String endTime = currentDate + " 23:59:59";
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(7); // 商家待接单
|
|
|
+ statusList.add(6); // 制作中
|
|
|
+ statusList.add(3); // 待取餐/派送中
|
|
|
+ statusList.add(4); // 已完成
|
|
|
+
|
|
|
+ int orderCount = appOrderDao.countByUserIdAndShopIdAndStatusListAndTimeRange(
|
|
|
+ userId, shopId, startTime, endTime, statusList);
|
|
|
+
|
|
|
+ log.info("getTransactionsParam==>[userId:{}, shopId:{}],当天状态为7、6、3、4的订单数量:{}",
|
|
|
+ userId, shopId, orderCount);
|
|
|
+
|
|
|
+ if (orderCount >= 10) {
|
|
|
+ throw new SqxException("该商户当天的订单量已超过当前限额!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.INSERT_ORDER_LOCK, tbOrder.getOrderId(), tbOrder.getShopId()));
|
|
|
lock.lock();
|
|
|
- try{
|
|
|
+ try {
|
|
|
return balanceOrders(userId, tbOrder);
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
@@ -145,11 +148,11 @@ public class WxServiceImpl implements WxService {
|
|
|
* 钱包支付订单
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public Result balanceOrders(Long userId, TbOrder tbOrder){
|
|
|
+ public Result balanceOrders(Long userId, TbOrder tbOrder) {
|
|
|
// 扣除用户余额
|
|
|
BigDecimal payMoney = tbOrder.getPayMoney();
|
|
|
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
|
|
- if(payMoney.doubleValue() > userMoney.getMoney().doubleValue()){
|
|
|
+ if (payMoney.doubleValue() > userMoney.getMoney().doubleValue()) {
|
|
|
return Result.error("您的余额不足,请充值后再支付!");
|
|
|
}
|
|
|
userMoneyService.updateMoney(2, userId, payMoney.doubleValue());
|
|
|
@@ -162,7 +165,7 @@ public class WxServiceImpl implements WxService {
|
|
|
userMoneyDetails.setClassify(3);
|
|
|
userMoneyDetails.setState(2);
|
|
|
userMoneyDetails.setMoney(payMoney);
|
|
|
- userMoneyDetails.setContent("使用余额支付:"+ String.format("%.2f", payMoney) +"元");
|
|
|
+ userMoneyDetails.setContent("使用余额支付:" + String.format("%.2f", payMoney) + "元");
|
|
|
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
|
|
userMoneyDetailsDao.insert(userMoneyDetails);
|
|
|
|
|
|
@@ -173,7 +176,7 @@ public class WxServiceImpl implements WxService {
|
|
|
String nowStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
tbOrder.setPayTime(nowStr);
|
|
|
// 订单支付成功
|
|
|
- appOrderService.updateOrderAfterPaySuccess(tbOrder,nowStr);
|
|
|
+ appOrderService.updateOrderAfterPaySuccess(tbOrder, nowStr);
|
|
|
|
|
|
return Result.success();
|
|
|
}
|
|
|
@@ -193,17 +196,17 @@ public class WxServiceImpl implements WxService {
|
|
|
public Result wxPayJsApiBuyVip(Long userId, Integer type) throws Exception {
|
|
|
String generalOrder = getGeneralOrder();
|
|
|
CommonInfo one = commonInfoService.findOne(313);
|
|
|
- if(type==4||type==5){
|
|
|
+ if (type == 4 || type == 5) {
|
|
|
return aliPayController.payVip(Double.valueOf(one.getValue()), type, userId, generalOrder, 4);
|
|
|
}
|
|
|
return pay(Double.valueOf(one.getValue()), type, userId, generalOrder, 4);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
- public Result balanceBuyVips(Long userId){
|
|
|
+ public Result balanceBuyVips(Long userId) {
|
|
|
CommonInfo one = commonInfoService.findOne(313);
|
|
|
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
|
|
- if(userMoney.getMoney().doubleValue()<Double.valueOf(one.getValue())){
|
|
|
+ if (userMoney.getMoney().doubleValue() < Double.valueOf(one.getValue())) {
|
|
|
return Result.error("余额不足!");
|
|
|
}
|
|
|
|
|
|
@@ -221,26 +224,26 @@ public class WxServiceImpl implements WxService {
|
|
|
userMoneyDetails.setType(2);
|
|
|
userMoneyDetails.setClassify(3);
|
|
|
userMoneyDetails.setMoney(BigDecimal.valueOf(Double.valueOf(one.getValue())));
|
|
|
- userMoneyDetails.setContent("用户开通会员,花费"+Double.valueOf(one.getValue())+"元");
|
|
|
+ userMoneyDetails.setContent("用户开通会员,花费" + Double.valueOf(one.getValue()) + "元");
|
|
|
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
userMoneyDetailsDao.insert(userMoneyDetails);
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result shopCashDeposit(Long shopId, Double money, String openId,Integer type) throws Exception {
|
|
|
+ public Result shopCashDeposit(Long shopId, Double money, String openId, Integer type) throws Exception {
|
|
|
GoodsShop goodsShop = goodsShopDao.selectById(shopId);
|
|
|
- if(goodsShop.getStatus()!=1){
|
|
|
+ if (goodsShop.getStatus() != 1) {
|
|
|
return Result.error("管理端审核成功后才能交保证金");
|
|
|
}
|
|
|
String generalOrder = getGeneralOrder();
|
|
|
- return shopPay(money,generalOrder, openId, shopId, type);
|
|
|
+ return shopPay(money, generalOrder, openId, shopId, type);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result payMoney(Long userId, BigDecimal money, Integer type) throws Exception {
|
|
|
String generalOrder = getGeneralOrder();
|
|
|
- if(type==4||type==5){
|
|
|
+ if (type == 4 || type == 5) {
|
|
|
return aliPayController.aliPayMoney(money.doubleValue(), type, userId, generalOrder, 2);
|
|
|
}
|
|
|
return pay(money.doubleValue(), type, userId, generalOrder, 2);
|
|
|
@@ -248,7 +251,8 @@ public class WxServiceImpl implements WxService {
|
|
|
|
|
|
/**
|
|
|
* 微信/支付宝支付订单
|
|
|
- * @param userId 用户id
|
|
|
+ *
|
|
|
+ * @param userId 用户id
|
|
|
* @param payOrderDTO 支付订单
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -263,17 +267,17 @@ public class WxServiceImpl implements WxService {
|
|
|
try {
|
|
|
|
|
|
Integer status = tbOrder.getStatus();
|
|
|
- if (status==0) {
|
|
|
+ if (status == 0) {
|
|
|
// 获取超时时间
|
|
|
Long timeOut = tbOrder.getTimeOut();
|
|
|
if (ObjectUtils.isNotEmpty(timeOut)) {
|
|
|
long time = new Date().getTime();
|
|
|
|
|
|
- if (timeOut<time) {
|
|
|
+ if (timeOut < time) {
|
|
|
return Result.error("订单已过期");
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 设置订单号
|
|
|
if (StrUtil.isBlank(tbOrder.getOrderNumber())) {
|
|
|
tbOrder.setOrderNumber(getGeneralOrder());
|
|
|
@@ -285,17 +289,16 @@ public class WxServiceImpl implements WxService {
|
|
|
|
|
|
// 超时时间
|
|
|
Date date = new Date();
|
|
|
- long time1 = date.getTime()+15*60*1000;
|
|
|
+ long time1 = date.getTime() + 15 * 60 * 1000;
|
|
|
tbOrder.setTimeOut(time1);
|
|
|
}
|
|
|
|
|
|
tbOrder.setPayType(1);
|
|
|
- if(type == 4 || type == 5){
|
|
|
+ if (type == 4 || type == 5) {
|
|
|
tbOrder.setPayType(3);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
// 保存订单信息
|
|
|
appOrderDao.updateById(tbOrder);
|
|
|
|
|
|
@@ -333,17 +336,17 @@ public class WxServiceImpl implements WxService {
|
|
|
} else {
|
|
|
url = oneu.getValue() + "/sqx_fast/app/wxPay/notify";//app支付
|
|
|
}
|
|
|
- String currentTimeMillis=(System.currentTimeMillis() / 1000)+"";
|
|
|
+ String currentTimeMillis = (System.currentTimeMillis() / 1000) + "";
|
|
|
Double mul = AmountCalUtils.mul(moneys, 100);
|
|
|
String money = String.valueOf(mul.intValue());
|
|
|
String generateNonceStr = WXPayUtil.generateNonceStr();
|
|
|
WXConfig config = new WXConfig();
|
|
|
//微信小程序APPID 微信公众号APPID
|
|
|
- if(type==1){
|
|
|
+ if (type == 1) {
|
|
|
config.setAppId(commonInfoService.findOne(74).getValue());
|
|
|
- }else if(type==2){
|
|
|
+ } else if (type == 2) {
|
|
|
config.setAppId(commonInfoService.findOne(5).getValue());
|
|
|
- }else if(type==3){
|
|
|
+ } else if (type == 3) {
|
|
|
config.setAppId(commonInfoService.findOne(45).getValue());
|
|
|
}
|
|
|
//微信商户号mchId
|
|
|
@@ -359,12 +362,12 @@ public class WxServiceImpl implements WxService {
|
|
|
//订单号
|
|
|
data.put("nonce_str", generateNonceStr);
|
|
|
String body = "";
|
|
|
- if(classify==1){
|
|
|
+ if (classify == 1) {
|
|
|
//订单类型
|
|
|
body = "下单支付";
|
|
|
- }else if(classify==2){
|
|
|
+ } else if (classify == 2) {
|
|
|
body = "充值余额";
|
|
|
- }else if(classify==4){
|
|
|
+ } else if (classify == 4) {
|
|
|
body = "购买会员";
|
|
|
}
|
|
|
//订单内容
|
|
|
@@ -377,16 +380,16 @@ public class WxServiceImpl implements WxService {
|
|
|
//异步通知地址(请注意必须是外网)
|
|
|
data.put("notify_url", url);
|
|
|
//交易类型
|
|
|
- data.put("trade_type", type == 1 ? TRADE_TYPE_APP : TRADE_TYPE_JSAPI );
|
|
|
+ data.put("trade_type", type == 1 ? TRADE_TYPE_APP : TRADE_TYPE_JSAPI);
|
|
|
//附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
|
|
|
data.put("attach", "");
|
|
|
data.put("sign", WXPayUtil.generateSignature(data, config.getKey(),
|
|
|
WXPayConstants.SignType.MD5));
|
|
|
- if(type==3 || type == 2){
|
|
|
+ if (type == 3 || type == 2) {
|
|
|
UserEntity userEntity = userService.queryByUserId(userId);
|
|
|
- if(type==2){
|
|
|
+ if (type == 2) {
|
|
|
data.put("openid", userEntity.getWxOpenId());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
data.put("openid", userEntity.getOpenId());
|
|
|
}
|
|
|
}
|
|
|
@@ -394,7 +397,7 @@ public class WxServiceImpl implements WxService {
|
|
|
Map<String, String> response = wxpay.unifiedOrder(data);
|
|
|
if ("SUCCESS".equals(response.get("return_code"))) {
|
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
|
|
|
- if(payDetails==null){
|
|
|
+ if (payDetails == null) {
|
|
|
payDetails = new PayDetails();
|
|
|
payDetails.setState(0);
|
|
|
payDetails.setCreateTime(sdf.format(new Date()));
|
|
|
@@ -446,6 +449,7 @@ public class WxServiceImpl implements WxService {
|
|
|
|
|
|
/**
|
|
|
* 商家缴纳保证金
|
|
|
+ *
|
|
|
* @param moneys
|
|
|
* @param outTradeNo
|
|
|
* @param openId
|
|
|
@@ -465,7 +469,7 @@ public class WxServiceImpl implements WxService {
|
|
|
} else {
|
|
|
url = oneu.getValue() + "/sqx_fast/app/wxPay/notifyShop";//app支付
|
|
|
}
|
|
|
- String currentTimeMillis=(System.currentTimeMillis() / 1000)+"";
|
|
|
+ String currentTimeMillis = (System.currentTimeMillis() / 1000) + "";
|
|
|
//后台服务名称
|
|
|
CommonInfo one = commonInfoService.findOne(12);
|
|
|
log.info("回调地址:" + url);
|
|
|
@@ -476,11 +480,11 @@ public class WxServiceImpl implements WxService {
|
|
|
/*//微信小程序APPID
|
|
|
config.setAppId(commonInfoService.findOne(305).getValue());*/
|
|
|
//微信小程序APPID 微信公众号APPID
|
|
|
- if(type==1){
|
|
|
+ if (type == 1) {
|
|
|
config.setAppId(commonInfoService.findOne(337).getValue());
|
|
|
- }else if(type==2){
|
|
|
+ } else if (type == 2) {
|
|
|
config.setAppId(commonInfoService.findOne(5).getValue());
|
|
|
- }else if(type==3){
|
|
|
+ } else if (type == 3) {
|
|
|
config.setAppId(commonInfoService.findOne(305).getValue());
|
|
|
}
|
|
|
//微信商户key
|
|
|
@@ -506,12 +510,12 @@ public class WxServiceImpl implements WxService {
|
|
|
//异步通知地址(请注意必须是外网)
|
|
|
data.put("notify_url", url);
|
|
|
//交易类型
|
|
|
- data.put("trade_type", type == 1 ? TRADE_TYPE_APP : TRADE_TYPE_JSAPI );
|
|
|
+ data.put("trade_type", type == 1 ? TRADE_TYPE_APP : TRADE_TYPE_JSAPI);
|
|
|
//附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
|
|
|
data.put("attach", "");
|
|
|
data.put("sign", WXPayUtil.generateSignature(data, config.getKey(),
|
|
|
WXPayConstants.SignType.MD5));
|
|
|
- if(type==3 || type == 2){
|
|
|
+ if (type == 3 || type == 2) {
|
|
|
data.put("openid", openId);
|
|
|
}
|
|
|
//使用官方API请求预付订单
|
|
|
@@ -521,7 +525,7 @@ public class WxServiceImpl implements WxService {
|
|
|
}
|
|
|
if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数
|
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
|
|
|
- if(payDetails==null){
|
|
|
+ if (payDetails == null) {
|
|
|
payDetails = new PayDetails();
|
|
|
payDetails.setState(0);
|
|
|
payDetails.setCreateTime(sdf.format(new Date()));
|
|
|
@@ -579,11 +583,11 @@ public class WxServiceImpl implements WxService {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- if(type==1){
|
|
|
+ if (type == 1) {
|
|
|
config.setAppId(commonInfoService.findOne(74).getValue());
|
|
|
- }else if(type==2){
|
|
|
+ } else if (type == 2) {
|
|
|
config.setAppId(commonInfoService.findOne(5).getValue());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
config.setAppId(commonInfoService.findOne(45).getValue());
|
|
|
}
|
|
|
config.setKey(commonInfoService.findOne(75).getValue());
|
|
|
@@ -631,7 +635,7 @@ public class WxServiceImpl implements WxService {
|
|
|
} catch (Exception e) {
|
|
|
System.err.println("手机支付回调通知失败" + e);
|
|
|
xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
|
|
|
- log.error("支付回调异常!",e.getMessage(), e);
|
|
|
+ log.error("支付回调异常!", e.getMessage(), e);
|
|
|
}
|
|
|
return xmlBack;
|
|
|
}
|
|
|
@@ -645,11 +649,11 @@ public class WxServiceImpl implements WxService {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
log.error("进入回调了!!!");
|
|
|
- if(type==1){
|
|
|
+ if (type == 1) {
|
|
|
config.setAppId(commonInfoService.findOne(337).getValue());
|
|
|
- }else if(type==2){
|
|
|
+ } else if (type == 2) {
|
|
|
config.setAppId(commonInfoService.findOne(5).getValue());
|
|
|
- }else if(type==3){
|
|
|
+ } else if (type == 3) {
|
|
|
config.setAppId(commonInfoService.findOne(305).getValue());
|
|
|
}
|
|
|
config.setKey(commonInfoService.findOne(75).getValue());
|
|
|
@@ -697,7 +701,7 @@ public class WxServiceImpl implements WxService {
|
|
|
} catch (Exception e) {
|
|
|
System.err.println("手机支付回调通知失败" + e);
|
|
|
xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
|
|
|
- log.error("支付回调异常!",e.getMessage(), e);
|
|
|
+ log.error("支付回调异常!", e.getMessage(), e);
|
|
|
}
|
|
|
return xmlBack;
|
|
|
}
|
|
|
@@ -712,28 +716,28 @@ public class WxServiceImpl implements WxService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void notifyRider(PayDetails payDetails){
|
|
|
- if(payDetails.getClassify()==1){
|
|
|
+ public void notifyRider(PayDetails payDetails) {
|
|
|
+ if (payDetails.getClassify() == 1) {
|
|
|
//充值金额
|
|
|
payDetails.setClassify(1);//分类:1微信 2支付宝
|
|
|
String date = new SimpleDateFormat("yyyy-MM-dd :HH:mm:ss").format(new Date());
|
|
|
payDetails.setType(1);
|
|
|
- userDao.topUpMoney(payDetails.getClassify(), payDetails.getTradeNo(),payDetails.getMoney(),payDetails.getUserId(),payDetails.getState(),date,date,payDetails.getType());
|
|
|
- }else if(payDetails.getClassify()==2){
|
|
|
+ userDao.topUpMoney(payDetails.getClassify(), payDetails.getTradeNo(), payDetails.getMoney(), payDetails.getUserId(), payDetails.getState(), date, date, payDetails.getType());
|
|
|
+ } else if (payDetails.getClassify() == 2) {
|
|
|
//订单支付
|
|
|
TbIndent indentByIndentNumber = indentService.findIndentByIndentNumber(payDetails.getOrderId());
|
|
|
indentByIndentNumber.setIndentState("2");
|
|
|
indentService.updateById(indentByIndentNumber);
|
|
|
- }else if(payDetails.getClassify()==3){
|
|
|
+ } else if (payDetails.getClassify() == 3) {
|
|
|
//将保证金添加到骑手保证金里
|
|
|
Double cashDeposit = payDetails.getMoney();
|
|
|
Long userId = payDetails.getUserId();
|
|
|
userDao.updateCashDeposit(userId, cashDeposit);
|
|
|
//交保证金的记录
|
|
|
- UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
|
|
+ UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
|
|
userMoneyDetails.setUserId(userId);
|
|
|
userMoneyDetails.setTitle("骑手缴纳保证金");
|
|
|
- userMoneyDetails.setContent("骑手缴纳保证金:"+cashDeposit+"元");
|
|
|
+ userMoneyDetails.setContent("骑手缴纳保证金:" + cashDeposit + "元");
|
|
|
userMoneyDetails.setType(1);
|
|
|
userMoneyDetails.setClassify(1);
|
|
|
userMoneyDetails.setState(2);
|
|
|
@@ -746,12 +750,12 @@ public class WxServiceImpl implements WxService {
|
|
|
JSONObject user = JSONObject.parseObject(remark);
|
|
|
|
|
|
String format = new SimpleDateFormat("yyyy-MM-dd :HH:mm:ss").format(new Date());
|
|
|
- userDao.certification(Long.parseLong(user.getString("userId")),user.getString("phone"),
|
|
|
+ userDao.certification(Long.parseLong(user.getString("userId")), user.getString("phone"),
|
|
|
user.getString("userName"), user.getString("identityCardNumber"), user.getString("identityCardFront"),
|
|
|
- user.getString("identityCardVerso"),user.getString("selfIdentityCard"), format,payDetails.getOrderId(),
|
|
|
+ user.getString("identityCardVerso"), user.getString("selfIdentityCard"), format, payDetails.getOrderId(),
|
|
|
user.getBigDecimal("cashDeposit"));
|
|
|
|
|
|
- }else if(payDetails.getClassify()==4){
|
|
|
+ } else if (payDetails.getClassify() == 4) {
|
|
|
Long userId = payDetails.getUserId();
|
|
|
Double money = payDetails.getMoney();
|
|
|
UserEntity userEntity = userDao.selectById(userId);
|
|
|
@@ -762,10 +766,10 @@ public class WxServiceImpl implements WxService {
|
|
|
userDao.updateById(userEntity1);
|
|
|
|
|
|
//交保证金的记录
|
|
|
- UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
|
|
+ UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
|
|
userMoneyDetails.setUserId(userId);
|
|
|
userMoneyDetails.setTitle("骑手缴纳保证金");
|
|
|
- userMoneyDetails.setContent("骑手缴纳保证金:"+payDetails.getMoney()+"元");
|
|
|
+ userMoneyDetails.setContent("骑手缴纳保证金:" + payDetails.getMoney() + "元");
|
|
|
userMoneyDetails.setType(1);
|
|
|
userMoneyDetails.setClassify(1);
|
|
|
userMoneyDetails.setState(2);
|
|
|
@@ -793,8 +797,8 @@ public class WxServiceImpl implements WxService {
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void notfiy(PayDetails payDetails){
|
|
|
- if(payDetails.getClassify()==2){
|
|
|
+ public void notfiy(PayDetails payDetails) {
|
|
|
+ if (payDetails.getClassify() == 2) {
|
|
|
UpdateMoneyBO updateMoneyBO = UpdateMoneyBO.builder()
|
|
|
.type(1)
|
|
|
.classify(3)
|
|
|
@@ -804,16 +808,16 @@ public class WxServiceImpl implements WxService {
|
|
|
.remark(payDetails.getOrderId())
|
|
|
.build();
|
|
|
userMoneyService.updateUserMoney(updateMoneyBO);
|
|
|
- }else if(payDetails.getClassify()==1){
|
|
|
+ } else if (payDetails.getClassify() == 1) {
|
|
|
// 根据订单编号查询订单
|
|
|
TbOrder tbOrder = appOrderService.selectOrderByNum(payDetails.getOrderId());
|
|
|
|
|
|
// 订单支付成功,修改订单状态
|
|
|
- appOrderService.updateOrderAfterPaySuccess(tbOrder,payDetails.getPayTime());
|
|
|
- }else if(payDetails.getClassify()==3){
|
|
|
+ appOrderService.updateOrderAfterPaySuccess(tbOrder, payDetails.getPayTime());
|
|
|
+ } else if (payDetails.getClassify() == 3) {
|
|
|
//商户交保证金
|
|
|
goodsShopService.updateCashDeposit(payDetails.getMoney(), payDetails.getShopId(), payDetails.getOrderId());
|
|
|
- }else if(payDetails.getClassify()==4){
|
|
|
+ } else if (payDetails.getClassify() == 4) {
|
|
|
PayDetails payDetails1 = new PayDetails();
|
|
|
payDetails1.setId(payDetails.getId());
|
|
|
payDetails1.setState(1);
|
|
|
@@ -826,10 +830,10 @@ public class WxServiceImpl implements WxService {
|
|
|
userMoneyDetails.setType(1);
|
|
|
userMoneyDetails.setClassify(3);
|
|
|
userMoneyDetails.setMoney(BigDecimal.valueOf(payDetails.getMoney()));
|
|
|
- userMoneyDetails.setContent("用户开通会员,花费"+payDetails.getMoney()+"元");
|
|
|
+ userMoneyDetails.setContent("用户开通会员,花费" + payDetails.getMoney() + "元");
|
|
|
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
userMoneyDetailsDao.insert(userMoneyDetails);
|
|
|
- }else if(payDetails.getClassify()==5){
|
|
|
+ } else if (payDetails.getClassify() == 5) {
|
|
|
//订单支付
|
|
|
TbIndent indentByIndentNumber = indentService.findIndentByPayOrdersNo(payDetails.getOrderId());
|
|
|
indentByIndentNumber.setIndentState("2");
|
|
|
@@ -839,7 +843,7 @@ public class WxServiceImpl implements WxService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean wxRefund(PayDetails payDetails){
|
|
|
+ public boolean wxRefund(PayDetails payDetails) {
|
|
|
WXConfigUtil config = null;
|
|
|
try {
|
|
|
config = new WXConfigUtil();
|
|
|
@@ -848,10 +852,16 @@ public class WxServiceImpl implements WxService {
|
|
|
}
|
|
|
int commInfoId = 0;
|
|
|
Integer payWay = payDetails.getType(); //支付方式(1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱)
|
|
|
- switch (payWay){
|
|
|
- case 1 : commInfoId = 74; break; //appId
|
|
|
- case 2 : commInfoId = 5; break; //公众号id
|
|
|
- case 3 : commInfoId = 45; break; //小程序id
|
|
|
+ switch (payWay) {
|
|
|
+ case 1:
|
|
|
+ commInfoId = 74;
|
|
|
+ break; //appId
|
|
|
+ case 2:
|
|
|
+ commInfoId = 5;
|
|
|
+ break; //公众号id
|
|
|
+ case 3:
|
|
|
+ commInfoId = 45;
|
|
|
+ break; //小程序id
|
|
|
}
|
|
|
config.setAppId(commonInfoService.findOne(commInfoId).getValue());
|
|
|
config.setKey(commonInfoService.findOne(75).getValue());
|
|
|
@@ -861,30 +871,30 @@ public class WxServiceImpl implements WxService {
|
|
|
data.put("appid", config.getAppID());
|
|
|
data.put("mch_id", config.getMchID());
|
|
|
data.put("nonce_str", WXPayUtil.generateNonceStr());
|
|
|
- try{
|
|
|
+ try {
|
|
|
data.put("sign", WXPayUtil.generateSignature(data, config.getKey(), WXPayConstants.SignType.MD5));
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return false;
|
|
|
}
|
|
|
data.put("out_trade_no", payDetails.getOrderId()); //订单号,支付单号一致
|
|
|
data.put("out_refund_no", payDetails.getOrderId()); //退款单号,同一笔用不同的退款单号
|
|
|
double total_fee = 0.00;
|
|
|
- data.put("total_fee",String.valueOf((new BigDecimal(payDetails.getMoney()).multiply(BigDecimal.valueOf(100))).intValue())); //1块等于微信支付传入100);
|
|
|
- data.put("refund_fee",String.valueOf((new BigDecimal(payDetails.getMoney()).multiply(BigDecimal.valueOf(100))).intValue())); //1块等于微信支付传入100);
|
|
|
+ data.put("total_fee", String.valueOf((new BigDecimal(payDetails.getMoney()).multiply(BigDecimal.valueOf(100))).intValue())); //1块等于微信支付传入100);
|
|
|
+ data.put("refund_fee", String.valueOf((new BigDecimal(payDetails.getMoney()).multiply(BigDecimal.valueOf(100))).intValue())); //1块等于微信支付传入100);
|
|
|
//使用官方API退款
|
|
|
- try{
|
|
|
+ try {
|
|
|
Map<String, String> response = wxpay.refund(data);
|
|
|
if ("SUCCESS".equals(response.get("return_code"))) {//主要返回以下5个参数
|
|
|
System.err.println("退款成功");
|
|
|
return true;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return false;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("返回");
|
|
|
e.printStackTrace();
|
|
|
- log.error("微信退款失败!,订单号"+payDetails.getOrderId()+",失败原因:"+e.getMessage(),e);
|
|
|
+ log.error("微信退款失败!,订单号" + payDetails.getOrderId() + ",失败原因:" + e.getMessage(), e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|