|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -46,8 +45,8 @@ import com.sqx.modules.coupon.entity.TbCouponUser;
|
|
|
import com.sqx.modules.datacentre.entity.SysUserShop;
|
|
import com.sqx.modules.datacentre.entity.SysUserShop;
|
|
|
import com.sqx.modules.errand.dao.TbIndentDao;
|
|
import com.sqx.modules.errand.dao.TbIndentDao;
|
|
|
import com.sqx.modules.errand.entity.TbIndent;
|
|
import com.sqx.modules.errand.entity.TbIndent;
|
|
|
-import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
|
|
|
|
|
import com.sqx.modules.errand.service.TbIndentService;
|
|
import com.sqx.modules.errand.service.TbIndentService;
|
|
|
|
|
+import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
|
|
|
import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
|
|
import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
|
|
|
import com.sqx.modules.errand.service.TbIndentSmsTemplateService;
|
|
import com.sqx.modules.errand.service.TbIndentSmsTemplateService;
|
|
|
import com.sqx.modules.goods.dao.GoodsDao;
|
|
import com.sqx.modules.goods.dao.GoodsDao;
|
|
@@ -71,9 +70,15 @@ import com.sqx.modules.order.entity.TbOrder;
|
|
|
import com.sqx.modules.order.service.AppOrderService;
|
|
import com.sqx.modules.order.service.AppOrderService;
|
|
|
import com.sqx.modules.pay.controller.app.AliPayController;
|
|
import com.sqx.modules.pay.controller.app.AliPayController;
|
|
|
import com.sqx.modules.pay.dao.PayDetailsDao;
|
|
import com.sqx.modules.pay.dao.PayDetailsDao;
|
|
|
|
|
+import com.sqx.modules.pay.dto.GetPayParamDTO;
|
|
|
import com.sqx.modules.pay.dto.PayOrderDTO;
|
|
import com.sqx.modules.pay.dto.PayOrderDTO;
|
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
|
|
|
+import com.sqx.modules.pay.enums.PayChannelEnum;
|
|
|
|
|
+import com.sqx.modules.pay.enums.PaySceneEnum;
|
|
|
|
|
+import com.sqx.modules.pay.service.NewPayService;
|
|
|
import com.sqx.modules.pay.service.WxErrService;
|
|
import com.sqx.modules.pay.service.WxErrService;
|
|
|
|
|
+import com.sqx.modules.pay.vo.AliPayTransactionsParam;
|
|
|
|
|
+import com.sqx.modules.pay.vo.PayTransactionsVO;
|
|
|
import com.sqx.modules.shop.service.ShopMessageService;
|
|
import com.sqx.modules.shop.service.ShopMessageService;
|
|
|
import com.sqx.modules.sys.dao.SysUserRoleDao;
|
|
import com.sqx.modules.sys.dao.SysUserRoleDao;
|
|
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
|
@@ -96,7 +101,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.Serializable;
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -165,7 +169,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
private ActivityService activityService;
|
|
private ActivityService activityService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ActivityPartRecordService activityPartRecordService;
|
|
private ActivityPartRecordService activityPartRecordService;
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysUserService sysUserService;
|
|
private SysUserService sysUserService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -173,6 +176,10 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TbIndentSmsTemplateService smsTemplateService;
|
|
private TbIndentSmsTemplateService smsTemplateService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private NewPayService newPayService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AliPayController aliPayController;
|
|
|
|
|
+ @Autowired
|
|
|
private PlatformTransactionManager transactionManager;
|
|
private PlatformTransactionManager transactionManager;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@@ -428,6 +435,8 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 获取店铺信息
|
|
// 获取店铺信息
|
|
|
// 注意:调用shopMessageService获取店铺信息,这个service对店铺的抽成比例有特殊处理(历史代码就是如此/(ㄒoㄒ)/~~)
|
|
// 注意:调用shopMessageService获取店铺信息,这个service对店铺的抽成比例有特殊处理(历史代码就是如此/(ㄒoㄒ)/~~)
|
|
|
GoodsShop goodsShop = shopMessageService.selectShopId(parentOrder.getShopId());
|
|
GoodsShop goodsShop = shopMessageService.selectShopId(parentOrder.getShopId());
|
|
|
|
|
+ // 给支付的时候商品描述用
|
|
|
|
|
+ parentOrder.setShopName(goodsShop.getShopName());
|
|
|
|
|
|
|
|
// // 设置订单类型
|
|
// // 设置订单类型
|
|
|
// parentOrder.setOrderType(payOrderDTO.getOrderType());
|
|
// parentOrder.setOrderType(payOrderDTO.getOrderType());
|
|
@@ -1772,7 +1781,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
|
- boolean b = wxErrService.wxRefund(payDetails);
|
|
|
|
|
|
|
+ boolean b = wechatPayRefund(payDetails);
|
|
|
if (!b) {
|
|
if (!b) {
|
|
|
return Result.error("退款失败,请联系客服!");
|
|
return Result.error("退款失败,请联系客服!");
|
|
|
}
|
|
}
|
|
@@ -1844,6 +1853,22 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
return Result.success();
|
|
return Result.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 微信支付退款
|
|
|
|
|
+ * @param payDetails 支付订单
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean wechatPayRefund(PayDetails payDetails) {
|
|
|
|
|
+ boolean b;
|
|
|
|
|
+ boolean newPay = newPayService.enableNewPay();
|
|
|
|
|
+ if (newPay) {
|
|
|
|
|
+ b = newPayService.wechatRefund(payDetails.getOrderId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ b = wxErrService.wxRefund(payDetails);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return b;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Result updateOrder(TbOrder order) {
|
|
public Result updateOrder(TbOrder order) {
|
|
@@ -2210,7 +2235,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
|
- boolean b = wxErrService.wxRefund(payDetails);
|
|
|
|
|
|
|
+ boolean b = wechatPayRefund(payDetails);
|
|
|
if (!b) {
|
|
if (!b) {
|
|
|
return Result.error("退款失败,请联系客服!");
|
|
return Result.error("退款失败,请联系客服!");
|
|
|
}
|
|
}
|
|
@@ -2355,7 +2380,8 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
userMoneyDao.updateMayMoney(1, tbOrder.getUserId(), tbOrder.getPayMoney().doubleValue());
|
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
} else if (tbOrder.getPayType() == 1) {
|
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
PayDetails payDetails = payDetailsDao.selectByOrderId(tbOrder.getOrderNumber());
|
|
|
- boolean b = wxErrService.wxRefund(payDetails);
|
|
|
|
|
|
|
+ // 退款
|
|
|
|
|
+ boolean b = wechatPayRefund(payDetails);
|
|
|
if (!b) {
|
|
if (!b) {
|
|
|
return Result.error("退款失败,请联系客服!");
|
|
return Result.error("退款失败,请联系客服!");
|
|
|
}
|
|
}
|
|
@@ -2499,27 +2525,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
return format + newString;
|
|
return format + newString;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- // @Scheduled(cron = "0 */1 * * * ?")
|
|
|
|
|
- // public void makeOrders(){
|
|
|
|
|
- // //自动制作完成订单
|
|
|
|
|
- // String value = commonInfoService.findOne(418).getValue();
|
|
|
|
|
- // if("是".equals(value)){
|
|
|
|
|
- // String minute = commonInfoService.findOne(419).getValue();
|
|
|
|
|
- // LocalDateTime minusMinutes = LocalDateTime.now().minusMinutes(Long.valueOf(minute));
|
|
|
|
|
- // List<TbOrder> tbOrders = baseMapper.selectMakeOrdersList(minusMinutes);
|
|
|
|
|
- // for (TbOrder order:tbOrders){
|
|
|
|
|
- // try{
|
|
|
|
|
- // order.setStatus(3);
|
|
|
|
|
- // updateOrder(order);
|
|
|
|
|
- // }catch (Exception e){
|
|
|
|
|
- // e.printStackTrace();
|
|
|
|
|
- // log.error("自动完成异常:"+e.getMessage(),e);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<TbOrder> getProdIngOrders(LocalDateTime minusMinutes) {
|
|
public List<TbOrder> getProdIngOrders(LocalDateTime minusMinutes) {
|
|
|
return baseMapper.selectMakeOrdersList(minusMinutes);
|
|
return baseMapper.selectMakeOrdersList(minusMinutes);
|
|
@@ -2572,9 +2577,45 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
} finally {
|
|
} finally {
|
|
|
lock.unlock();
|
|
lock.unlock();
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public PayTransactionsVO getTransactionsParam(Long userId, PayOrderDTO payOrderDTO) {
|
|
|
|
|
+ TbOrder order = prepareOrder(userId, payOrderDTO);
|
|
|
|
|
|
|
|
|
|
+ // 在同一时刻用户只能在同一家店铺执行一次下单操作 ??
|
|
|
|
|
+ RLock lock = redissonClient.getLock(String.format(RedisKey.INSERT_ORDER_LOCK, order.getUserId(), order.getShopId()));
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 设置支付方式 1表示微信支付、4或5表示支付宝支付
|
|
|
|
|
+ Integer type = payOrderDTO.getType();
|
|
|
|
|
+
|
|
|
|
|
+ // 微信支付
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ UserEntity userEntity = userService.queryByUserId(userId);
|
|
|
|
|
+
|
|
|
|
|
+ GetPayParamDTO dto = GetPayParamDTO.builder()
|
|
|
|
|
+ .orderNo(order.getOrderNumber())
|
|
|
|
|
+ .orderDesc(order.getShopName())
|
|
|
|
|
+ .amount(order.getPayMoney())
|
|
|
|
|
+ .userId(userId)
|
|
|
|
|
+ .userThirdId(userEntity.getOpenId())
|
|
|
|
|
+ .payChannel(PayChannelEnum.WECHAT_JS_API)
|
|
|
|
|
+ .paySceneEnum(PaySceneEnum.ORDER_PAY)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ return newPayService.getWechatTransactionsParamVO(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 支付宝支付,暂时未重构先不管,copy原有代码
|
|
|
|
|
+ else {
|
|
|
|
|
+ Result result = aliPayController.payAppOrders(order.getPayMoney().doubleValue(), type, order.getUserId(), order.getOrderNumber(), 1);
|
|
|
|
|
|
|
|
|
|
+ AliPayTransactionsParam transactionsParam = new AliPayTransactionsParam();
|
|
|
|
|
+ transactionsParam.setBody(result.get("data").toString());
|
|
|
|
|
+ return transactionsParam;
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ lock.unlock();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|