diff --git a/bweb/src/main/java/com/bweb/controller/cms/CmsContentController.java b/bweb/src/main/java/com/bweb/controller/cms/CmsContentController.java index 74420c0..ef76c67 100644 --- a/bweb/src/main/java/com/bweb/controller/cms/CmsContentController.java +++ b/bweb/src/main/java/com/bweb/controller/cms/CmsContentController.java @@ -1,12 +1,7 @@ package com.bweb.controller.cms; -import com.bweb.controller.BsMerController; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.model.ResponseData; -import com.hfkj.service.BsMerService; import com.hfkj.service.cms.CmsContentService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/bweb/src/main/java/com/bweb/controller/BsMerController.java b/bweb/src/main/java/com/bweb/controller/mer/BsMerController.java similarity index 58% rename from bweb/src/main/java/com/bweb/controller/BsMerController.java rename to bweb/src/main/java/com/bweb/controller/mer/BsMerController.java index 599125c..d6df513 100644 --- a/bweb/src/main/java/com/bweb/controller/BsMerController.java +++ b/bweb/src/main/java/com/bweb/controller/mer/BsMerController.java @@ -1,4 +1,4 @@ -package com.bweb.controller; +package com.bweb.controller.mer; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; @@ -6,12 +6,20 @@ import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsMer; +import com.hfkj.entity.BsMerPayConfig; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.entity.GoodsType; +import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.BsMerModel; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.BsMerService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.mer.PayPlatformEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -21,7 +29,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -33,12 +44,16 @@ import java.util.Map; @RequestMapping(value="/mer") @Api(value="商户业务") public class BsMerController { + Logger log = LoggerFactory.getLogger(BsMerController.class); @Resource private UserCenter userCenter; @Resource private BsMerService merService; + @Resource + private BsMerPayConfigService bsMerPayConfigService; + @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建商户") @@ -170,4 +185,116 @@ public class BsMerController { } + + + @RequestMapping(value="/editPayConfig",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "创建商户支付内容") + public ResponseData editPayConfig(@RequestBody BsMerPayConfig body, HttpServletRequest request) { + + try { + + + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + + if (userModel.getAccount().getObjectType() != SecUserObjectTypeEnum.type2.getCode()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); + + } + + if (body == null + || body.getMerId() == null + || body.getPayPlatform() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + if (body.getPayPlatform() == PayPlatformEnum.type1.getCode()) { + if ( body.getPayMerNo() == null + || body.getPayMerKey() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + } else if (body.getPayPlatform() == PayPlatformEnum.type2.getCode()) { + if ( body.getHltMerNo() == null + || body.getHltInstCode() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + } + + BsMerPayConfig merPayConfig; + + if (body.getId() != null) { + merPayConfig = bsMerPayConfigService.queryDetail(body.getId()); + if (merPayConfig == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.CONTENT_NOT_FOUND, ""); + } + } else { + merPayConfig = new BsMerPayConfig(); + merPayConfig.setCreateTime(new Date()); + } + + BsMer bsMer = merService.getDetailById(body.getMerId()); + + + + merPayConfig.setUpdateTime(new Date()); + merPayConfig.setMerId(body.getMerId()); + merPayConfig.setMerNo(bsMer.getMerNo()); + merPayConfig.setPayPlatform(body.getPayPlatform()); + merPayConfig.setPayMerNo(body.getPayMerNo()); + merPayConfig.setPayMerKey(body.getPayMerKey()); + merPayConfig.setHltMerNo(body.getHltMerNo()); + merPayConfig.setHltInstCode(body.getHltInstCode()); + merPayConfig.setStatus(1); + + + if (body.getId() != null) { + bsMerPayConfigService.update(merPayConfig); + } else { + bsMerPayConfigService.create(merPayConfig); + } + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + + } + + + @RequestMapping(value="/queryMerPayConfig",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商户支付参数") + public ResponseData queryMerPayConfig(@RequestParam(value = "merNo" , required = true) String merNo) { + try { + + Map param = new HashMap<>(); + param.put("merNo", merNo); + + return ResponseMsgUtil.success(bsMerPayConfigService.getList(param)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/delete",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除") + public ResponseData delete(@RequestParam(value = "id" , required = false) Long id) { + try { + + bsMerPayConfigService.delete(id , false); + + return ResponseMsgUtil.success("删除成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java b/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java new file mode 100644 index 0000000..d391c8d --- /dev/null +++ b/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java @@ -0,0 +1,79 @@ +package com.hfkj.mer; + +import com.hfkj.entity.BsMerPayConfig; + +import java.util.List; +import java.util.Map; + +public interface BsMerPayConfigService { + /** + * @Author Sum1Dream + * @Name create + * @Description // 创建 + * @Date 15:11 2024/4/19 + * @Param GoodsBrand + * @return void + */ + void create(BsMerPayConfig merPayConfig); + + /** + * @Author Sum1Dream + * @Name update + * @Description // 修改 + * @Date 15:12 2024/4/19 + * @Param GoodsBrand + * @return void + */ + void update(BsMerPayConfig merPayConfig); + + /** + * @Author Sum1Dream + * @Name delete + * @Description // 修改 + * @Date 15:12 2024/4/19 + * @Param id + * @return void + */ + void delete(Long id , Boolean fullDelete); + + /** + * @Author Sum1Dream + * @Name queryDetail + * @Description // 根据ID查询产品类型详情 + * @Date 15:12 2024/4/19 + * @Param id + * @return com.hfkj.entity.GoodsBrand + */ + BsMerPayConfig queryDetail(Long id); + + /** + * @Author Sum1Dream + * @Name findGoodsOrder + * @Description // 查询详情 + * @Date 15:44 2023/4/20 + * @Param [orderNo] + * @Return com.hai.entity.GoodsOrder + */ + BsMerPayConfig findGoodsOrder(Long merId); + + /** + * @Author Sum1Dream + * @Name queryDetailByMap + * @Description // 根据多条件查询产品类型 + * @Date 15:12 2024/4/19 + * @Param map + * @return com.hfkj.entity.GoodsBrand + */ + BsMerPayConfig queryDetailByMap(Map map); + + /** + * @Author Sum1Dream + * @Name getList + * @Description // 根据多条件查询列表 + * @Date 15:13 2024/4/19 + * @Param map + * @return java.util.List + */ + List getList(Map map); + +} diff --git a/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java b/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java new file mode 100644 index 0000000..0e3cff7 --- /dev/null +++ b/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java @@ -0,0 +1,90 @@ +package com.hfkj.mer.impl; + +import com.hfkj.dao.BsMerPayConfigMapper; +import com.hfkj.entity.BsMerPayConfig; +import com.hfkj.entity.BsMerPayConfigExample; +import com.hfkj.entity.GoodsMsg; +import com.hfkj.mer.BsMerPayConfigService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service("BsMerPayConfigService") +public class BsMerPayConfigServiceImpl implements BsMerPayConfigService { + + @Resource + private BsMerPayConfigMapper bsMerPayConfigMapper; + + @Override + public void create(BsMerPayConfig merPayConfig) { + bsMerPayConfigMapper.insert(merPayConfig); + } + + @Override + public void update(BsMerPayConfig merPayConfig) { + bsMerPayConfigMapper.updateByPrimaryKeySelective(merPayConfig); + } + + @Override + public void delete(Long id, Boolean fullDelete) { + if (fullDelete) { + bsMerPayConfigMapper.deleteByPrimaryKey(id); + } else { + BsMerPayConfig merPayConfig = queryDetail(id); + merPayConfig.setStatus(0); + merPayConfig.setUpdateTime(new Date()); + update(merPayConfig); + } + } + + @Override + public BsMerPayConfig queryDetail(Long id) { + return bsMerPayConfigMapper.selectByPrimaryKey(id); + } + + @Override + public BsMerPayConfig findGoodsOrder(Long merId) { + BsMerPayConfigExample example = new BsMerPayConfigExample(); + BsMerPayConfigExample.Criteria criteria = example.createCriteria(); + + criteria.andMerIdEqualTo(merId); + + List list = bsMerPayConfigMapper.selectByExample(example); + if (list != null && !list.isEmpty()) { + return list.get(0); + } + return null; + } + + @Override + public BsMerPayConfig queryDetailByMap(Map map) { + BsMerPayConfigExample example = new BsMerPayConfigExample(); + BsMerPayConfigExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getLong(map, "payPlatform") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "payPlatform")); + } + + criteria.andStatusEqualTo(1); + + List list = bsMerPayConfigMapper.selectByExample(example); + if (list != null && !list.isEmpty()) { + return list.get(0); + } + return null; + } + + @Override + public List getList(Map map) { + return Collections.emptyList(); + } +} diff --git a/service/src/main/java/com/hfkj/service/BsMerService.java b/service/src/main/java/com/hfkj/service/BsMerService.java index 79d1103..1914ef7 100644 --- a/service/src/main/java/com/hfkj/service/BsMerService.java +++ b/service/src/main/java/com/hfkj/service/BsMerService.java @@ -44,6 +44,7 @@ public interface BsMerService { * @return */ BsMerModel getDetail(String merNo); + BsMer getDetailById(Long id); /** * 查询商户列表 diff --git a/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java index cf38993..8d131e3 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsMerServiceImpl.java @@ -174,6 +174,11 @@ public class BsMerServiceImpl implements BsMerService { return null; } + @Override + public BsMer getDetailById(Long id) { + return merMapper.selectByPrimaryKey(id); + } + @Override public List getList(Map param) { BsMerExample example = new BsMerExample(); diff --git a/service/src/main/java/com/hfkj/sysenum/mer/PayPlatformEnum.java b/service/src/main/java/com/hfkj/sysenum/mer/PayPlatformEnum.java new file mode 100644 index 0000000..172b744 --- /dev/null +++ b/service/src/main/java/com/hfkj/sysenum/mer/PayPlatformEnum.java @@ -0,0 +1,29 @@ +package com.hfkj.sysenum.mer; + +import lombok.Getter; + +@Getter +public enum PayPlatformEnum { + + /** + * 菜单 + */ + type1(1, "惠支付"), + + /** + * 按钮 + */ + type2(2, "工会卡"), + ; + + private int code; + + private String name; + + + PayPlatformEnum(int code, String name) { + this.code = code; + this.name = name; + } + +}