用户支付信息录入代码优化

master
yangkai 6 years ago
parent 90e17cc5b8
commit 6929b209fa

@ -16,7 +16,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
@Override
public void saveCustomerPaymentInfo(JSONObject paymentInfo) {
if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) {
throw new BadRequestException("openid exists");
throw new BadRequestException("openid already exists");
}
sysCustomerPaymentInfoMapper.save(paymentInfo);
}
@ -24,10 +24,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
@Override
public void updateCustomerPaymentInfo(JSONObject paymentInfo) {
if (paymentInfo.getString("id") == null) {
throw new BadRequestException("ID is not empty");
}
if (sysCustomerPaymentInfoMapper.selectById(paymentInfo.getString("id")) == null) {
throw new BadRequestException("ID:" + paymentInfo.getString("id") + " not exists!");
throw new BadRequestException("ID is empty");
}
sysCustomerPaymentInfoMapper.update(paymentInfo);
}

@ -13,18 +13,18 @@ public class CustomerPaymentInfoController {
@Resource
private CustomerPaymentInfoService customerPaymentInfoService;
@RequestMapping(value = "/save", method = RequestMethod.POST)
public void saveTest(@RequestBody JSONObject paymentInfo) {
@RequestMapping(value = "/update", method = RequestMethod.POST)
public void savePaymentInfo(@RequestBody JSONObject paymentInfo) {
customerPaymentInfoService.saveCustomerPaymentInfo(paymentInfo);
}
@RequestMapping(value = "/update", method = RequestMethod.PUT)
public void updateTest(@RequestBody JSONObject paymentInfo) {
public void updatePaymentInfo(@RequestBody JSONObject paymentInfo) {
customerPaymentInfoService.updateCustomerPaymentInfo(paymentInfo);
}
@RequestMapping(value = "/{openid}/check", method = RequestMethod.GET)
public JSONObject selectTest(@PathVariable String openid) {
public JSONObject selectPaymentInfo(@PathVariable String openid) {
return customerPaymentInfoService.selectPaymentInfoByOpenId(openid);
}
}

Loading…
Cancel
Save