|
@@ -1,13 +1,25 @@
|
|
|
package com.txz.cif.web.mng;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.txz.cif.core.Result;
|
|
|
import com.txz.cif.core.ResultGenerator;
|
|
|
+import com.txz.cif.model.MidChannelMethod;
|
|
|
+import com.txz.cif.model.PaymentChannel;
|
|
|
import com.txz.cif.model.PaymentMethod;
|
|
|
+import com.txz.cif.service.MidChannelMethodService;
|
|
|
+import com.txz.cif.service.PaymentChannelService;
|
|
|
import com.txz.cif.service.PaymentMethodService;
|
|
|
|
|
|
import com.txz.cif.core.ResultCode;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.txz.cif.web.bo.MidChannelMethodBO;
|
|
|
+import com.txz.cif.web.bo.PaymentMethodBO;
|
|
|
+import com.txz.cif.web.bo.UserBo2;
|
|
|
+import com.txz.cif.web.para.PaymentMethodParam;
|
|
|
+import com.txz.cif.web.para.updateparam.PaymentMethodUpdateParam;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -19,110 +31,150 @@ import tk.mybatis.mapper.entity.Condition;
|
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
-* Created by CodeGenerator on 2025/08/04.
|
|
|
-*/
|
|
|
+ * Created by CodeGenerator on 2025/08/04.
|
|
|
+ */
|
|
|
@Api(tags = "[后台]paymentMethod管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/payment/method")
|
|
|
public class PaymentMethodController {
|
|
|
|
|
|
- private static Logger log = LoggerFactory.getLogger(PaymentMethodController.class);
|
|
|
+ private static Logger log = LoggerFactory.getLogger(PaymentMethodController.class);
|
|
|
|
|
|
@Resource
|
|
|
private PaymentMethodService paymentMethodService;
|
|
|
|
|
|
- @PostMapping("/add")
|
|
|
- @ApiOperation(value = "paymentMethod新增",httpMethod = "POST")
|
|
|
- public Result add(@RequestBody PaymentMethod paymentMethod) {
|
|
|
- if(paymentMethod == null){
|
|
|
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
- }
|
|
|
- try {
|
|
|
- // paymentMethod.setCreateTime(new Date());
|
|
|
- // paymentMethod.setCreateUserId(userId);
|
|
|
- paymentMethodService.save(paymentMethod);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("新增对象操作异常e:{}",e);
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- return ResultGenerator.genSuccessResult(paymentMethod);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/delete")
|
|
|
- @ApiOperation(value = "paymentMethod删除",httpMethod = "GET")
|
|
|
- public Result delete(@RequestParam Integer id) {
|
|
|
- if(id == null){
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
- }
|
|
|
- try {
|
|
|
- paymentMethodService.deleteById(id);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("删除对象操作异常e:{}",e);
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- return ResultGenerator.genSuccessResult();
|
|
|
- }
|
|
|
+// @PostMapping("/add")
|
|
|
+// @ApiOperation(value = "paymentMethod新增", httpMethod = "POST")
|
|
|
+// public Result add(@RequestBody PaymentMethod paymentMethod) {
|
|
|
+// if (paymentMethod == null) {
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
+// }
|
|
|
+// try {
|
|
|
+// // paymentMethod.setCreateTime(new Date());
|
|
|
+// // paymentMethod.setCreateUserId(userId);
|
|
|
+// paymentMethodService.save(paymentMethod);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("新增对象操作异常e:{}", e);
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return ResultGenerator.genSuccessResult(paymentMethod);
|
|
|
+// }
|
|
|
+
|
|
|
+// @GetMapping("/delete")
|
|
|
+// @ApiOperation(value = "paymentMethod删除", httpMethod = "GET")
|
|
|
+// public Result delete(@RequestParam Integer id) {
|
|
|
+// if (id == null) {
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
+// }
|
|
|
+// try {
|
|
|
+// paymentMethodService.deleteById(id);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("删除对象操作异常e:{}", e);
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+// }
|
|
|
+// return ResultGenerator.genSuccessResult();
|
|
|
+// }
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
- @ApiOperation(value = "paymentMethod更新",httpMethod = "POST")
|
|
|
- public Result update(@RequestBody PaymentMethod paymentMethod) {
|
|
|
- if(paymentMethod == null){
|
|
|
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
- }
|
|
|
- if(paymentMethod.getId() == null){
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
- }
|
|
|
- try {
|
|
|
- // paymentMethod.setUpdateTime(new Date());
|
|
|
- // paymentMethod.setUpdateUserId(userId);
|
|
|
- paymentMethodService.update(paymentMethod);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("更新对象操作异常e:{}",e);
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
+ @ApiOperation(value = "支付方式启用/关停", httpMethod = "POST")
|
|
|
+ public Result update(@RequestBody PaymentMethodUpdateParam paymentMethodUpdateParam) {
|
|
|
+ if (paymentMethodUpdateParam == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if (paymentMethodUpdateParam.getId() == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+
|
|
|
+ PaymentMethod bean = BeanUtil.toBean(paymentMethodUpdateParam, PaymentMethod.class);
|
|
|
+ try {
|
|
|
+
|
|
|
+ bean.setUpdateUser("lala");
|
|
|
+
|
|
|
+ paymentMethodService.update(bean);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/detail")
|
|
|
- @ApiOperation(value = "paymentMethod获取详情",httpMethod = "GET")
|
|
|
- public Result<PaymentMethod> detail(@RequestParam Integer id) {
|
|
|
- if(id == null){
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
- }
|
|
|
-
|
|
|
- PaymentMethod paymentMethod = null;
|
|
|
- try {
|
|
|
- paymentMethod = paymentMethodService.findById(id);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- return ResultGenerator.genSuccessResult(paymentMethod);
|
|
|
- }
|
|
|
+// @GetMapping("/detail")
|
|
|
+// @ApiOperation(value = "paymentMethod获取详情", httpMethod = "GET")
|
|
|
+// public Result<PaymentMethod> detail(@RequestParam Integer id) {
|
|
|
+// if (id == null) {
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
+// }
|
|
|
+//
|
|
|
+// PaymentMethod paymentMethod = null;
|
|
|
+// try {
|
|
|
+// paymentMethod = paymentMethodService.findById(id);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("查询对象操作异常e:{}", e);
|
|
|
+// return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return ResultGenerator.genSuccessResult(paymentMethod);
|
|
|
+// }
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MidChannelMethodService midChannelMethodService;
|
|
|
+ @Resource
|
|
|
+ private PaymentChannelService paymentChannelService;
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
- @ApiOperation(value = "paymentMethod获取列表",httpMethod = "POST")
|
|
|
- public Result<List<PaymentMethod>> list(@RequestBody PaymentMethod paymentMethod, @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
|
|
|
-
|
|
|
- PageHelper.startPage(page, size);
|
|
|
-
|
|
|
- Condition condition = new Condition(paymentMethod.getClass());
|
|
|
- Criteria criteria = condition.createCriteria();
|
|
|
-// criteria.andEqualTo("name", city.getName());
|
|
|
- PageInfo pageInfo = null;
|
|
|
- try {
|
|
|
- List<PaymentMethod> list = paymentMethodService.findByCondition(condition);
|
|
|
- pageInfo = new PageInfo(list);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
+ @ApiOperation(value = "paymentMethod获取列表", httpMethod = "POST")
|
|
|
+ public Result<List<PaymentMethodBO>> list(@RequestBody PaymentMethodParam paymentMethodParam) {
|
|
|
+
|
|
|
+
|
|
|
+ List<PaymentMethodBO> paymentMethodListBO = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ Map<Long, PaymentChannel> paymentChannelMap;
|
|
|
+ List<PaymentChannel> paymentChannelList = paymentChannelService.findAll();
|
|
|
+ if (!CollectionUtils.isEmpty(paymentChannelList)) {
|
|
|
+ paymentChannelMap = paymentChannelList.stream().collect(Collectors.toMap(PaymentChannel::getId, a -> a, (a, c) -> c));
|
|
|
+ } else {
|
|
|
+ paymentChannelMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MidChannelMethod> midChannelMethodList = midChannelMethodService.findAll();
|
|
|
+
|
|
|
+ Map<Long, List<MidChannelMethodBO>> midChannelMethodBOGroupMap;
|
|
|
+ if (!CollectionUtils.isEmpty(midChannelMethodList)) {
|
|
|
+ midChannelMethodBOGroupMap = midChannelMethodList.stream().filter(a -> a.getAgencyService().equals(paymentMethodParam.getAgencyService())).map(a -> {
|
|
|
+ MidChannelMethodBO bean = BeanUtil.toBean(a, MidChannelMethodBO.class);
|
|
|
+ bean.setPaymentChannel(paymentChannelMap.get(bean.getChannelId()));
|
|
|
+ return bean;
|
|
|
+ }).collect(Collectors.groupingBy(MidChannelMethod::getMethodId));
|
|
|
+ } else {
|
|
|
+ midChannelMethodBOGroupMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PaymentMethod> paymentMethodList = paymentMethodService.findAll();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(paymentMethodList)) {
|
|
|
+ paymentMethodList.stream().forEach(a -> {
|
|
|
+ PaymentMethodBO bean = BeanUtil.toBean(a, PaymentMethodBO.class);
|
|
|
+ List<MidChannelMethodBO> midChannelMethodBOS = midChannelMethodBOGroupMap.get(bean.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(midChannelMethodBOS)) {
|
|
|
+ bean.setMidChannelMethodBOList(midChannelMethodBOS);
|
|
|
+ paymentMethodListBO.add(bean);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+
|
|
|
+ }
|
|
|
+ return ResultGenerator.genSuccessResult(paymentMethodListBO);
|
|
|
}
|
|
|
}
|