parent
0b666f80c2
commit
90e17cc5b8
@ -0,0 +1,12 @@
|
||||
package au.com.royalpay.payment.manage.customers.core;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public interface CustomerPaymentInfoService {
|
||||
|
||||
void saveCustomerPaymentInfo(JSONObject paymentInfo);
|
||||
|
||||
void updateCustomerPaymentInfo(JSONObject paymentInfo);
|
||||
|
||||
JSONObject selectPaymentInfoByOpenId(String open_id);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package au.com.royalpay.payment.manage.customers.core.impls;
|
||||
|
||||
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
|
||||
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
|
||||
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
|
||||
@Resource
|
||||
private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper;
|
||||
|
||||
@Override
|
||||
public void saveCustomerPaymentInfo(JSONObject paymentInfo) {
|
||||
if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) {
|
||||
throw new BadRequestException("openid exists");
|
||||
}
|
||||
sysCustomerPaymentInfoMapper.save(paymentInfo);
|
||||
}
|
||||
|
||||
@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!");
|
||||
}
|
||||
sysCustomerPaymentInfoMapper.update(paymentInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject selectPaymentInfoByOpenId(String open_id) {
|
||||
return sysCustomerPaymentInfoMapper.selectPaymentInfo(open_id);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package au.com.royalpay.payment.manage.customers.web;
|
||||
|
||||
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/customer/payment")
|
||||
public class CustomerPaymentInfoController {
|
||||
|
||||
@Resource
|
||||
private CustomerPaymentInfoService customerPaymentInfoService;
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public void saveTest(@RequestBody JSONObject paymentInfo) {
|
||||
customerPaymentInfoService.saveCustomerPaymentInfo(paymentInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.PUT)
|
||||
public void updateTest(@RequestBody JSONObject paymentInfo) {
|
||||
customerPaymentInfoService.updateCustomerPaymentInfo(paymentInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{openid}/check", method = RequestMethod.GET)
|
||||
public JSONObject selectTest(@PathVariable String openid) {
|
||||
return customerPaymentInfoService.selectPaymentInfoByOpenId(openid);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package au.com.royalpay.payment.manage.mappers.system;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@AutoMapper(tablename = "sys_customer_payment_info", pkName = "id")
|
||||
public interface SysCustomerPaymentInfoMapper {
|
||||
|
||||
@AutoSql(type = SqlType.INSERT)
|
||||
void save(JSONObject paymentInfo);
|
||||
|
||||
@AutoSql(type = SqlType.UPDATE)
|
||||
void update(JSONObject paymentInfo);
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject selectPaymentInfo(@Param(value = "wechat_openid") String open_id);
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject selectById(@Param(value = "id") String id);
|
||||
}
|
Loading…
Reference in new issue