|
@@ -36,6 +36,7 @@ import org.springblade.modules.finance.service.IOrderGrantService;
|
|
|
import org.springblade.modules.finance.service.IOrderService;
|
|
|
import org.springblade.modules.shopping.entity.Consign;
|
|
|
import org.springblade.modules.shopping.service.IConsignService;
|
|
|
+import org.springblade.modules.shopping.wrapper.ConsignWrapper;
|
|
|
import org.springblade.modules.system.entity.User;
|
|
|
import org.springblade.modules.system.entity.UserApp;
|
|
|
import org.springblade.modules.system.service.IUserService;
|
|
@@ -204,6 +205,20 @@ public class AliPay01Controller {
|
|
|
return R.fail("发起支付失败!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发起支付宝预授权
|
|
|
+ *
|
|
|
+ * 1、判断用户是否能抢购
|
|
|
+ * 2、查询是否有寄售/进货单
|
|
|
+ * 3、发起支付宝预支付
|
|
|
+ * 4、请求成功 创建预支付订单 默认为未授权
|
|
|
+ * @param userId 用户id
|
|
|
+ * @param batNo 批次ID
|
|
|
+ * @param price 金额
|
|
|
+ * @param num 预授数量
|
|
|
+ * @return R
|
|
|
+ * @throws AlipayApiException
|
|
|
+ */
|
|
|
@ApiLog("发起支付宝预授权")
|
|
|
@PostMapping("/pay_003")
|
|
|
@ApiOperation(value = "线上资金授权冻结接口-调用支付宝预授权", notes = "支付请求")
|
|
@@ -214,10 +229,12 @@ public class AliPay01Controller {
|
|
|
@ApiParam(value = "数量", required = true) @RequestParam Integer num) throws AlipayApiException {
|
|
|
UserApp userApp = new UserApp();
|
|
|
UserApp query = userApp.selectOne(Wrappers.<UserApp>lambdaQuery().eq(UserApp::getUserId,userId));
|
|
|
+ if (Objects.isNull(query)){
|
|
|
+ return R.fail("该用户不存在!");
|
|
|
+ }
|
|
|
if (query.getEnableAuth() != 2){
|
|
|
double k = (double)query.getCreditScore() / 100;
|
|
|
int scoreCount = NumberUtil.roundDown(k, 2).intValue();
|
|
|
- log.info("用户【"+ query.getUserId() +"】的积分【" + query.getCreditScore() + "】可抢次数: " + scoreCount);
|
|
|
int consignCount = Integer.parseInt(ParamCache.getValue(CommonConstant.DEFAULT_CONDIGN_COUNT));
|
|
|
if (scoreCount > consignCount){
|
|
|
scoreCount = consignCount;
|
|
@@ -226,23 +243,22 @@ public class AliPay01Controller {
|
|
|
return R.fail("预授数量不能大于单场可抢次数!");
|
|
|
}
|
|
|
}
|
|
|
- if(query.getState() != 1){
|
|
|
+ if(query.getState() != 1 ){
|
|
|
return R.fail("该账号已冻结!");
|
|
|
}
|
|
|
Consign consign = consignService.queryConsign(batNo, userId);
|
|
|
- if (consign == null){
|
|
|
+ if (Objects.isNull(consign)){
|
|
|
return R.fail("亲,好物已抢完欢迎再来!");
|
|
|
}
|
|
|
//判断用户是否在该场次下有预授权
|
|
|
OrderGrant orderGrant = orderGrantService.getOne(Wrappers.<OrderGrant>lambdaQuery()
|
|
|
- .eq(OrderGrant::getBatNo,batNo)
|
|
|
- .eq(OrderGrant::getUserId,userId)
|
|
|
+ .eq(OrderGrant::getBatNo, batNo)
|
|
|
+ .eq(OrderGrant::getUserId, userId)
|
|
|
.eq(OrderGrant::getStatus,1)
|
|
|
);
|
|
|
- if (orderGrant != null){
|
|
|
+ if (Objects.isNull(orderGrant)){
|
|
|
return R.fail("您已发起预授权,无需再次发起!");
|
|
|
}
|
|
|
- //1.通过批次号和用户id查询是有在预授权的数据
|
|
|
JSONObject data = new JSONObject();
|
|
|
String orderNo = CommonUtil.genTimeID();
|
|
|
data.put("out_order_no", orderNo);
|
|
@@ -260,7 +276,6 @@ public class AliPay01Controller {
|
|
|
//必须使用 sdkExecute
|
|
|
AlipayFundAuthOrderAppFreezeResponse response = client.sdkExecute(request);
|
|
|
if(response.isSuccess()){
|
|
|
- //查询数据如果已经预授权的
|
|
|
String dataDate = DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATE);
|
|
|
OrderGrant grant = new OrderGrant();
|
|
|
grant.setBatNo(batNo);
|
|
@@ -275,7 +290,6 @@ public class AliPay01Controller {
|
|
|
orderGrantService.save(grant);
|
|
|
return R.data(response.getBody());
|
|
|
}
|
|
|
- //return R.data(400,null,"授权失败");
|
|
|
return R.fail("授权失败!");
|
|
|
}
|
|
|
|