diff --git a/src/main/java/cn/chjyj/szwh/bean/PaySetting.java b/src/main/java/cn/chjyj/szwh/bean/PaySetting.java new file mode 100644 index 0000000..939b6e2 --- /dev/null +++ b/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; + } +} diff --git a/src/main/java/cn/chjyj/szwh/controller/admin/AdminAccountCloseController.java b/src/main/java/cn/chjyj/szwh/controller/admin/AdminAccountCloseController.java new file mode 100644 index 0000000..bc8e2f9 --- /dev/null +++ b/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; + } +} diff --git a/src/main/java/cn/chjyj/szwh/mapper/PaySettingMapper.java b/src/main/java/cn/chjyj/szwh/mapper/PaySettingMapper.java new file mode 100644 index 0000000..953578a --- /dev/null +++ b/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); +} diff --git a/src/main/java/cn/chjyj/szwh/service/AccountCloseService.java b/src/main/java/cn/chjyj/szwh/service/AccountCloseService.java new file mode 100644 index 0000000..ef095df --- /dev/null +++ b/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(); +} diff --git a/src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java new file mode 100644 index 0000000..d1c8a7c --- /dev/null +++ b/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; + } +} diff --git a/src/main/resources/mapper/szwh/PaySettingMapper.xml b/src/main/resources/mapper/szwh/PaySettingMapper.xml new file mode 100644 index 0000000..687af09 --- /dev/null +++ b/src/main/resources/mapper/szwh/PaySettingMapper.xml @@ -0,0 +1,50 @@ + + + + + + id,alipay,wechat_pay as wechatPay,ebank_pay as ebankPay + + pay_setting + + + + + + + + insert into + + (alipay,wechat_pay,ebank_pay) + values ( + #{alipay}, + #{wechatPay}, + #{ebankPay} + ) + + + + + update + + + + alipay=#{alipay}, + + + wechat_pay=#{wechatPay}, + + + ebank_pay =#{ebankPay}, + + + where id=#{id}; + + + \ No newline at end of file diff --git a/src/test/java/cn/chjyj/szwh/service/AccountCloseServiceTest.java b/src/test/java/cn/chjyj/szwh/service/AccountCloseServiceTest.java new file mode 100644 index 0000000..7ecdd98 --- /dev/null +++ b/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")); + } +} \ No newline at end of file