Browse Source

设置支付方式

master
xyiege 4 years ago
parent
commit
ec8340bc36
  1. 43
      src/main/java/cn/chjyj/szwh/bean/PaySetting.java
  2. 32
      src/main/java/cn/chjyj/szwh/controller/admin/AdminAccountCloseController.java
  3. 31
      src/main/java/cn/chjyj/szwh/mapper/PaySettingMapper.java
  4. 16
      src/main/java/cn/chjyj/szwh/service/AccountCloseService.java
  5. 33
      src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java
  6. 50
      src/main/resources/mapper/szwh/PaySettingMapper.xml
  7. 24
      src/test/java/cn/chjyj/szwh/service/AccountCloseServiceTest.java

43
src/main/java/cn/chjyj/szwh/bean/PaySetting.java

@ -0,0 +1,43 @@
package cn.chjyj.szwh.bean;
/**
* 支付方式
*/
public class PaySetting {
private Integer id;
private Integer alipay; //支付宝
private Integer wechatPay; //微信支付
private Integer ebankPay; //网银支付
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAlipay() {
return alipay;
}
public void setAlipay(Integer alipay) {
this.alipay = alipay;
}
public Integer getWechatPay() {
return wechatPay;
}
public void setWechatPay(Integer wechatPay) {
this.wechatPay = wechatPay;
}
public Integer getEbankPay() {
return ebankPay;
}
public void setEbankPay(Integer ebankPay) {
this.ebankPay = ebankPay;
}
}

32
src/main/java/cn/chjyj/szwh/controller/admin/AdminAccountCloseController.java

@ -0,0 +1,32 @@
package cn.chjyj.szwh.controller.admin;
import cn.chjyj.szwh.controller.BaseController;
import cn.chjyj.szwh.service.AccountCloseService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 对账控制器
*/
@RestController
@RequestMapping("//admin/order.AccountClose")
public class AdminAccountCloseController extends BaseController {
@Autowired
private AccountCloseService accountCloseService;
/**
* 获取支付方式
* @return
*/
@RequestMapping("/getPaySetting")
public JSONObject getPaySetting(){
Map map = accountCloseService.getPaySetting();
jsonObject.put("code",200);
jsonObject.put("msg","成功");
jsonObject.put("data",map);
return jsonObject;
}
}

31
src/main/java/cn/chjyj/szwh/mapper/PaySettingMapper.java

@ -0,0 +1,31 @@
package cn.chjyj.szwh.mapper;
import cn.chjyj.szwh.bean.PaySetting;
import org.springframework.stereotype.Component;
/**
* 支付方式设置 mapper
*/
@Component
public interface PaySettingMapper {
/**
* 查询支付方式
* @param id
* @return
*/
PaySetting getPaySettingById(Integer id);
/**
* 新增
* @param paySetting
* @return
*/
int addPaySetting(PaySetting paySetting);
/**
* 支付方式
* @param paySetting
* @return
*/
int upPaySetting(PaySetting paySetting);
}

16
src/main/java/cn/chjyj/szwh/service/AccountCloseService.java

@ -0,0 +1,16 @@
package cn.chjyj.szwh.service;
import cn.chjyj.szwh.bean.PaySetting;
import java.util.Map;
/**
* 商户结算
*/
public interface AccountCloseService {
/**
* 支付配置信息
* @return
*/
Map getPaySetting();
}

33
src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java

@ -0,0 +1,33 @@
package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.PaySetting;
import cn.chjyj.szwh.mapper.PaySettingMapper;
import cn.chjyj.szwh.service.AccountCloseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
public class AccountCloseServiceImpl implements AccountCloseService {
@Autowired
private PaySettingMapper paySettingMapper;
@Override
public Map getPaySetting() {
Map retmap =new HashMap();
PaySetting paySetting = paySettingMapper.getPaySettingById(1);
if(paySetting==null){
retmap.put("alipay",0);
retmap.put("wechat_pay",0);
retmap.put("ebank_pay",0);
}else{
retmap.put("alipay",paySetting.getAlipay());
retmap.put("wechat_pay",paySetting.getWechatPay());
retmap.put("ebank_pay",paySetting.getEbankPay());
}
return retmap;
}
}

50
src/main/resources/mapper/szwh/PaySettingMapper.xml

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.chjyj.szwh.mapper.PaySettingMapper">
<sql id="column">
id,alipay,wechat_pay as wechatPay,ebank_pay as ebankPay
</sql>
<sql id="tbName">pay_setting</sql>
<!--查询记录列表-->
<select id="getPaySettingById" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.PaySetting">
select <include refid="column" />
from <include refid="tbName"/>
where id=#{id}
</select>
<!--新增用户-->
<insert id="addPaySetting" parameterType="cn.chjyj.szwh.bean.PaySetting" useGeneratedKeys="true" keyColumn="id">
insert into
<include refid="tbName"/>
(alipay,wechat_pay,ebank_pay)
values (
#{alipay},
#{wechatPay},
#{ebankPay}
)
</insert>
<!--更新-->
<update id="upPaySetting" parameterType="cn.chjyj.szwh.bean.PaySetting">
update
<include refid="tbName"/>
<set>
<if test="alipay!=null">
alipay=#{alipay},
</if>
<if test="wechatPay!=null">
wechat_pay=#{wechatPay},
</if>
<if test="ebankPay!=null">
ebank_pay =#{ebankPay},
</if>
</set>
where id=#{id};
</update>
</mapper>

24
src/test/java/cn/chjyj/szwh/service/AccountCloseServiceTest.java

@ -0,0 +1,24 @@
package cn.chjyj.szwh.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Map;
import static org.junit.Assert.*;
@SpringBootTest
@RunWith(SpringRunner.class)
public class AccountCloseServiceTest {
@Autowired
private AccountCloseService accountCloseService;
@Test
public void getPaySetting() {
Map map = accountCloseService.getPaySetting();
System.out.println(map.get("alipay"));
}
}
Loading…
Cancel
Save