fix: 支付模块调整和对接
This commit is contained in:
@@ -13,9 +13,11 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.core.domain.R;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.common.security.annotation.InnerAuth;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.user.domain.UOrder;
|
||||
import org.wfc.user.domain.UPackage;
|
||||
@@ -96,8 +98,8 @@ public class UOrderController extends BaseController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody UOrder uOrder) {
|
||||
return toAjax(uOrderService.saveOrder(uOrder));
|
||||
public R<Long> add(@RequestBody UOrder uOrder) {
|
||||
return R.ok(uOrderService.saveOrder(uOrder));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@@ -110,4 +112,9 @@ public class UOrderController extends BaseController {
|
||||
return toAjax(uOrderService.removeByIds(CollUtil.newArrayList(ids)));
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping("paySuccess/{id}")
|
||||
public AjaxResult paySuccess(@PathVariable("id") Long id) {
|
||||
return toAjax(uOrderService.paySuccess(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IUOrderService extends IService<UOrder> {
|
||||
|
||||
boolean saveOrder(UOrder order);
|
||||
Long saveOrder(UOrder order);
|
||||
|
||||
boolean paySuccess(Long orderId);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.wfc.user.api.IWifiApi;
|
||||
import org.wfc.user.api.omada.domain.convert.OmadaConvert;
|
||||
import org.wfc.user.api.omada.domain.dto.ClientRateLimitSettingDto;
|
||||
import org.wfc.user.domain.UAccount;
|
||||
import org.wfc.user.domain.UBillRule;
|
||||
import org.wfc.user.domain.UClient;
|
||||
import org.wfc.user.domain.UOrder;
|
||||
import org.wfc.user.domain.UPackage;
|
||||
@@ -22,6 +23,7 @@ import org.wfc.user.domain.URateLimit;
|
||||
import org.wfc.user.domain.constant.OrderStatusEnum;
|
||||
import org.wfc.user.domain.constant.OrderTypeEnum;
|
||||
import org.wfc.user.domain.constant.PeriodTypeEnum;
|
||||
import org.wfc.user.mapper.UBillRuleMapper;
|
||||
import org.wfc.user.mapper.UOrderMapper;
|
||||
import org.wfc.user.service.IUAccountService;
|
||||
import org.wfc.user.service.IUClientService;
|
||||
@@ -58,14 +60,21 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
@Autowired
|
||||
private IUClientService clientService;
|
||||
|
||||
@Autowired
|
||||
private UBillRuleMapper billRuleMapper;
|
||||
|
||||
@Autowired
|
||||
private IWifiApi wifiApi;
|
||||
|
||||
public void paySuccess(Long orderId) {
|
||||
@Override
|
||||
public boolean paySuccess(Long orderId) {
|
||||
// 支付成功回调(预留)
|
||||
|
||||
// 更新当前订单状态为已支付
|
||||
UOrder order = this.getById(orderId);
|
||||
if (OrderStatusEnum.PAID.getCode().equals(order.getStatus())) {
|
||||
return false;
|
||||
}
|
||||
order.setStatus(OrderStatusEnum.PAID.getCode());
|
||||
this.updateById(order);
|
||||
|
||||
@@ -109,7 +118,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
wifiApi.updateClientRateLimitSetting(client.getSiteId(), client.getClientMac(), clientRateLimitSetting);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void callbackPackage(UOrder order, UAccount account) {
|
||||
@@ -156,14 +165,20 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveOrder(UOrder order) {
|
||||
public Long saveOrder(UOrder order) {
|
||||
order.setUserId(SecurityUtils.getUserId());
|
||||
order.setStatus(OrderStatusEnum.UNPAID.getCode());
|
||||
order.setOrderNo(System.currentTimeMillis() + StrUtil.EMPTY);
|
||||
this.save(order);
|
||||
// 支付成功回调
|
||||
paySuccess(order.getId());
|
||||
List<UBillRule> billRules = billRuleMapper.selectList(Wrappers.lambdaQuery());
|
||||
billRules.stream().findFirst().ifPresent(billRule -> {
|
||||
// 测试
|
||||
if (billRule.getTraffic() == 1) {
|
||||
// 支付成功回调
|
||||
paySuccess(order.getId());
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return order.getId();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user