2 files modified
7 files added
| | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.service.ISiteBannerService; |
| | | import com.nq.service.ISiteInfoService; |
| | | import com.nq.service.ISitePayOptionService; |
| | | import com.nq.service.ISitePayService; |
| | | import com.nq.utils.http.HttpClientRequest; |
| | | import com.nq.utils.PropertiesUtil; |
| | |
| | | |
| | | @Autowired |
| | | ISitePayService iSitePayService; |
| | | |
| | | @Autowired |
| | | ISitePayOptionService iSitePayOptionService; |
| | | |
| | | //查询官网PC端交易 轮播图信息 |
| | | @RequestMapping({"getBannerByPlat.do"}) |
| | |
| | | return this.iSitePayService.getPayInfoById(payId); |
| | | } |
| | | |
| | | /** |
| | | * H5 查询支付设置(仅返回已开启的项,按排序;每项含 name、param,如 默认:0 支付1:1) |
| | | */ |
| | | @RequestMapping({"getPayOptionList.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getPayOptionList() { |
| | | return this.iSitePayOptionService.listForH5(); |
| | | } |
| | | |
| | | //查询设置信息 |
| | | @RequestMapping({"getMan.do"}) |
| | | @ResponseBody |
| New file |
| | |
| | | package com.nq.controller.backend; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.service.ISitePayOptionService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 管理后台 - 支付设置(默认/支付1/支付2/支付3) |
| | | * 支持拖拽排序(参数随排序变动)、开启/关闭 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/admin/payOption/") |
| | | public class AdminSitePayOptionController { |
| | | private static final Logger log = LoggerFactory.getLogger(AdminSitePayOptionController.class); |
| | | |
| | | @Autowired |
| | | private ISitePayOptionService sitePayOptionService; |
| | | |
| | | /** 列表(按当前排序),用于管理页展示与拖拽 */ |
| | | @RequestMapping("list.do") |
| | | @ResponseBody |
| | | public ServerResponse list() { |
| | | return sitePayOptionService.listForAdmin(); |
| | | } |
| | | |
| | | /** 拖动排序:传入新顺序的 id 列表,如 [3,1,4,2],后端按顺序将 param 设为 0,1,2,3 */ |
| | | @RequestMapping("updateSort.do") |
| | | @ResponseBody |
| | | public ServerResponse updateSort(@RequestBody List<Integer> orderedIds) { |
| | | return sitePayOptionService.updateSort(orderedIds); |
| | | } |
| | | |
| | | /** 开启/关闭:enabled 1=开启 0=关闭 */ |
| | | @RequestMapping("setEnabled.do") |
| | | @ResponseBody |
| | | public ServerResponse setEnabled(@RequestParam("id") Integer id, @RequestParam("enabled") Integer enabled) { |
| | | return sitePayOptionService.setEnabled(id, enabled); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.nq.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.nq.pojo.SitePayOption; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface SitePayOptionMapper extends BaseMapper<SitePayOption> { |
| | | |
| | | List<SitePayOption> listAllOrderBySort(); |
| | | |
| | | List<SitePayOption> listEnabledOrderBySort(); |
| | | |
| | | int updateParamAndSortOrder(@Param("id") Integer id, @Param("param") Integer param, @Param("sortOrder") Integer sortOrder); |
| | | |
| | | int updateEnabled(@Param("id") Integer id, @Param("enabled") Integer enabled); |
| | | } |
| New file |
| | |
| | | package com.nq.pojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 支付设置项:默认、支付1、支付2、支付3 |
| | | * 冒号后为参数 param,可拖动排序,排序后 param 按新顺序重新分配 0,1,2,3 |
| | | */ |
| | | @Data |
| | | public class SitePayOption { |
| | | private Integer id; |
| | | /** 显示名称:默认、支付1、支付2、支付3 */ |
| | | private String name; |
| | | /** 参数:0/1/2/3,随排序变动 */ |
| | | private Integer param; |
| | | /** 排序序号,越小越靠前 */ |
| | | private Integer sortOrder; |
| | | /** 是否开启:1 开启,0 关闭 */ |
| | | private Integer enabled; |
| | | } |
| New file |
| | |
| | | package com.nq.service; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 支付设置:默认/支付1/支付2/支付3,可拖拽排序(param 随排序变动)、可开关 |
| | | */ |
| | | public interface ISitePayOptionService { |
| | | |
| | | /** 管理后台:查询全部,按排序 */ |
| | | ServerResponse listForAdmin(); |
| | | |
| | | /** 管理后台:拖动排序,传入新顺序的 id 列表,param 按新顺序赋 0,1,2,3 */ |
| | | ServerResponse updateSort(List<Integer> orderedIds); |
| | | |
| | | /** 管理后台:开启/关闭 */ |
| | | ServerResponse setEnabled(Integer id, Integer enabled); |
| | | |
| | | /** H5:查询已开启的支付设置,按排序 */ |
| | | ServerResponse listForH5(); |
| | | } |
| | |
| | | }else if(type == 2){//支付2 |
| | | return getPaymentZero(tradeAmount, uipReqRul, user,request); |
| | | } else if(type == 3){//支付2 |
| | | // return getPaymentTwo(tradeAmount, uipReqRul, user,request); |
| | | return ServerResponse.createByErrorMsg("未开启,请选择其他支付方式",request); |
| | | return getPaymentTwo(tradeAmount, uipReqRul, user,request); |
| | | // return ServerResponse.createByErrorMsg("未开启,请选择其他支付方式",request); |
| | | }else if(type == 1){ |
| | | // return getPaymentThree(tradeAmount, threeUrl, user,request); |
| | | return getPaymentOne(tradeAmount, reqUrl,user,request); |
| New file |
| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.SitePayOptionMapper; |
| | | import com.nq.pojo.SitePayOption; |
| | | import com.nq.service.ISitePayOptionService; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class SitePayOptionServiceImpl implements ISitePayOptionService { |
| | | |
| | | @Resource |
| | | private SitePayOptionMapper sitePayOptionMapper; |
| | | |
| | | @Override |
| | | public ServerResponse listForAdmin() { |
| | | List<SitePayOption> list = sitePayOptionMapper.listAllOrderBySort(); |
| | | return ServerResponse.createBySuccess(list); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse updateSort(List<Integer> orderedIds) { |
| | | if (CollectionUtils.isEmpty(orderedIds)) { |
| | | return ServerResponse.createByErrorMsg("排序数据不能为空"); |
| | | } |
| | | for (int i = 0; i < orderedIds.size(); i++) { |
| | | Integer id = orderedIds.get(i); |
| | | int param = i; |
| | | int sortOrder = i; |
| | | sitePayOptionMapper.updateParamAndSortOrder(id, param, sortOrder); |
| | | } |
| | | return ServerResponse.createBySuccessMsg("排序已更新"); |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse setEnabled(Integer id, Integer enabled) { |
| | | if (id == null) { |
| | | return ServerResponse.createByErrorMsg("id不能为空"); |
| | | } |
| | | if (enabled == null || (enabled != 0 && enabled != 1)) { |
| | | return ServerResponse.createByErrorMsg("enabled 只能为 0 或 1"); |
| | | } |
| | | int n = sitePayOptionMapper.updateEnabled(id, enabled); |
| | | if (n > 0) { |
| | | return ServerResponse.createBySuccessMsg(enabled == 1 ? "已开启" : "已关闭"); |
| | | } |
| | | return ServerResponse.createByErrorMsg("操作失败"); |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse listForH5() { |
| | | List<SitePayOption> list = sitePayOptionMapper.listEnabledOrderBySort(); |
| | | return ServerResponse.createBySuccess(list); |
| | | } |
| | | } |
| New file |
| | |
| | | <?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="com.nq.dao.SitePayOptionMapper"> |
| | | <resultMap id="BaseResultMap" type="com.nq.pojo.SitePayOption"> |
| | | <id column="id" property="id"/> |
| | | <result column="name" property="name"/> |
| | | <result column="param" property="param"/> |
| | | <result column="sort_order" property="sortOrder"/> |
| | | <result column="enabled" property="enabled"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">id, name, param, sort_order, enabled</sql> |
| | | |
| | | <select id="listAllOrderBySort" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List"/> |
| | | FROM site_pay_option |
| | | ORDER BY sort_order ASC, id ASC |
| | | </select> |
| | | |
| | | <select id="listEnabledOrderBySort" resultMap="BaseResultMap"> |
| | | SELECT <include refid="Base_Column_List"/> |
| | | FROM site_pay_option |
| | | WHERE enabled = 1 |
| | | ORDER BY sort_order ASC, id ASC |
| | | </select> |
| | | |
| | | <update id="updateParamAndSortOrder"> |
| | | UPDATE site_pay_option SET param = #{param}, sort_order = #{sortOrder} WHERE id = #{id} |
| | | </update> |
| | | |
| | | <update id="updateEnabled"> |
| | | UPDATE site_pay_option SET enabled = #{enabled} WHERE id = #{id} |
| | | </update> |
| | | </mapper> |
| New file |
| | |
| | | -- 支付设置表:默认、支付1、支付2、支付3,可排序,参数随排序变动,可开关 |
| | | CREATE TABLE IF NOT EXISTS `site_pay_option` ( |
| | | `id` int(11) NOT NULL AUTO_INCREMENT, |
| | | `name` varchar(32) NOT NULL COMMENT '显示名称:默认、支付1、支付2、支付3', |
| | | `param` int(11) NOT NULL DEFAULT '0' COMMENT '参数 0/1/2/3,随排序变动', |
| | | `sort_order` int(11) NOT NULL DEFAULT '0' COMMENT '排序序号', |
| | | `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否开启:1开启 0关闭', |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='支付设置(4项可拖拽排序、开关)'; |
| | | |
| | | -- 初始化 4 条:默认:0 支付1:1 支付2:2 支付3:3 |
| | | INSERT INTO `site_pay_option` (`name`, `param`, `sort_order`, `enabled`) VALUES |
| | | ('默认', 0, 0, 1), |
| | | ('支付1', 1, 1, 1), |
| | | ('支付2', 2, 2, 1), |
| | | ('支付3', 3, 3, 1); |