|
@@ -1,22 +1,22 @@
|
|
package com.txz.cif.web.mng;
|
|
package com.txz.cif.web.mng;
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
+
|
|
import com.txz.cif.core.Result;
|
|
import com.txz.cif.core.Result;
|
|
|
|
+import com.txz.cif.core.ResultCode;
|
|
import com.txz.cif.core.ResultGenerator;
|
|
import com.txz.cif.core.ResultGenerator;
|
|
import com.txz.cif.model.Goods;
|
|
import com.txz.cif.model.Goods;
|
|
|
|
+import com.txz.cif.model.PaymentMethod;
|
|
import com.txz.cif.model.RechargeRecord;
|
|
import com.txz.cif.model.RechargeRecord;
|
|
import com.txz.cif.service.GoodsService;
|
|
import com.txz.cif.service.GoodsService;
|
|
-
|
|
|
|
-import com.txz.cif.core.ResultCode;
|
|
|
|
-
|
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
+import com.txz.cif.service.PaymentMethodService;
|
|
import com.txz.cif.web.para.GoodsParam;
|
|
import com.txz.cif.web.para.GoodsParam;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import com.txz.cif.web.ro.PaymentPriceConfigRO;
|
|
|
|
+import com.txz.cif.web.vo.PaymentPriceVO;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
-
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
|
|
|
@@ -24,96 +24,134 @@ import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
-* Created by CodeGenerator on 2025/07/15.
|
|
|
|
-*/
|
|
|
|
|
|
+ * Created by CodeGenerator on 2025/07/15.
|
|
|
|
+ */
|
|
@Api(tags = "[后台]充值商品管理")
|
|
@Api(tags = "[后台]充值商品管理")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/goods")
|
|
@RequestMapping("/goods")
|
|
public class GoodsController {
|
|
public class GoodsController {
|
|
-
|
|
|
|
- private static Logger log = LoggerFactory.getLogger(GoodsController.class);
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private GoodsService goodsService;
|
|
|
|
-
|
|
|
|
- @PostMapping("/update")
|
|
|
|
- @ApiOperation(value = "更新",httpMethod = "POST")
|
|
|
|
- public Result update(@RequestBody Goods goods) {
|
|
|
|
- if (goods.getId() == null) {
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
- }
|
|
|
|
- goodsService.update(goods);
|
|
|
|
- return ResultGenerator.genSuccessResult();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @PostMapping("/add")
|
|
|
|
- @ApiOperation(value = "新增",httpMethod = "POST")
|
|
|
|
- public Result add(@RequestBody Goods goods) {
|
|
|
|
- goods.setId(null);
|
|
|
|
- goodsService.save(goods);
|
|
|
|
- return ResultGenerator.genSuccessResult();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @GetMapping("/delete")
|
|
|
|
- @ApiOperation(value = "删除",httpMethod = "GET")
|
|
|
|
- public Result<Goods> delete(@RequestParam Long id) {
|
|
|
|
- if(id == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- goodsService.deleteById(id);
|
|
|
|
- return ResultGenerator.genSuccessResult();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private static Logger log = LoggerFactory.getLogger(GoodsController.class);
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private GoodsService goodsService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private PaymentMethodService paymentMethodService;
|
|
|
|
+
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
+ @ApiOperation(value = "更新", httpMethod = "POST")
|
|
|
|
+ public Result update(@RequestBody Goods goods) {
|
|
|
|
+ if (goods.getId() == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ goodsService.update(goods);
|
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/add")
|
|
|
|
+ @ApiOperation(value = "新增", httpMethod = "POST")
|
|
|
|
+ public Result add(@RequestBody Goods goods) {
|
|
|
|
+ goods.setId(null);
|
|
|
|
+ goodsService.save(goods);
|
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/delete")
|
|
|
|
+ @ApiOperation(value = "删除", httpMethod = "GET")
|
|
|
|
+ public Result<Goods> delete(@RequestParam Long id) {
|
|
|
|
+ if (id == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ goodsService.deleteById(id);
|
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
@GetMapping("/detail")
|
|
@GetMapping("/detail")
|
|
- @ApiOperation(value = "获取详情",httpMethod = "GET")
|
|
|
|
|
|
+ @ApiOperation(value = "获取详情", httpMethod = "GET")
|
|
public Result<Goods> detail(@RequestParam Long id) {
|
|
public Result<Goods> detail(@RequestParam Long id) {
|
|
- if(id == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- Goods goods = goodsService.findById(id);
|
|
|
|
- if (goods == null){
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
|
- }
|
|
|
|
- return ResultGenerator.genSuccessResult(goods);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if (id == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Goods goods = goodsService.findById(id);
|
|
|
|
+ if (goods == null) {
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
|
+ }
|
|
|
|
+ return ResultGenerator.genSuccessResult(goods);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
- @ApiOperation(value = "获取列表",httpMethod = "POST")
|
|
|
|
|
|
+ @ApiOperation(value = "获取列表", httpMethod = "POST")
|
|
public Result<List<Goods>> list(@RequestBody GoodsParam param) {
|
|
public Result<List<Goods>> list(@RequestBody GoodsParam param) {
|
|
-
|
|
|
|
- PageHelper.startPage(param.getPage(), param.getSize());
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ PaymentMethod paymentMethod = paymentMethodService.findById(param.getMethodId());
|
|
|
|
+
|
|
Condition condition = new Condition(RechargeRecord.class);
|
|
Condition condition = new Condition(RechargeRecord.class);
|
|
Criteria criteria = condition.createCriteria();
|
|
Criteria criteria = condition.createCriteria();
|
|
criteria.andEqualTo("methodId", param.getMethodId());
|
|
criteria.andEqualTo("methodId", param.getMethodId());
|
|
- if (param.getStatus() != null){
|
|
|
|
- criteria.andEqualTo("status", param.getStatus());
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(param.getStartTime())){
|
|
|
|
- criteria.andBetween("createTime", param.getStartTime(),param.getEndTime());
|
|
|
|
- }
|
|
|
|
- PageInfo pageInfo = null;
|
|
|
|
- try {
|
|
|
|
- condition.setOrderByClause("create_time desc");
|
|
|
|
- List<Goods> list = goodsService.findByCondition(condition);
|
|
|
|
- pageInfo = new PageInfo(list);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
|
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
|
- }
|
|
|
|
- return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
|
|
|
+ if (param.getStatus() != null) {
|
|
|
|
+ criteria.andEqualTo("status", param.getStatus());
|
|
|
|
+ }
|
|
|
|
+ condition.setOrderByClause("create_time desc");
|
|
|
|
+ List<Goods> list = goodsService.findByCondition(condition);
|
|
|
|
+
|
|
|
|
+ return Result.success(PaymentPriceVO.builder()
|
|
|
|
+ .list(list)
|
|
|
|
+ .miniPrice(paymentMethod.getMiniPrice())
|
|
|
|
+ .maxPrice(paymentMethod.getMaxPrice())
|
|
|
|
+ .build()
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改区间
|
|
|
|
+ */
|
|
|
|
+ @PatchMapping("editInterval/{paymentId:^\\d+$}")
|
|
|
|
+ public Result editInterval(@PathVariable("paymentId") Long paymentId, @RequestBody @Validated({PaymentPriceConfigRO.EditInterval.class}) PaymentPriceConfigRO ro) {
|
|
|
|
+ // PaymentPriceConfig mini = paymentPriceConfigService.getOne(Wrappers.<PaymentPriceConfig>lambdaQuery()
|
|
|
|
+ // .eq(PaymentPriceConfig::getPaymentId, paymentId)
|
|
|
|
+ // .lt(PaymentPriceConfig::getPriceVal, ro.getMiniPrice())
|
|
|
|
+ // .eq(PaymentPriceConfig::getIsValid, 1)
|
|
|
|
+ // .last("limit 1")
|
|
|
|
+ // );
|
|
|
|
+ // if (ObjectUtil.isNotEmpty(mini)) {
|
|
|
|
+ // return Result.fail("最小金额不能小于已配置金额");
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // PaymentPriceConfig max = paymentPriceConfigService.getOne(Wrappers.<PaymentPriceConfig>lambdaQuery()
|
|
|
|
+ // .eq(PaymentPriceConfig::getPaymentId, paymentId)
|
|
|
|
+ // .gt(PaymentPriceConfig::getPriceVal, ro.getMaxPrice())
|
|
|
|
+ // .eq(PaymentPriceConfig::getIsValid, 1)
|
|
|
|
+ // .last("limit 1")
|
|
|
|
+ // );
|
|
|
|
+ // if (ObjectUtil.isNotEmpty(max)) {
|
|
|
|
+ // return Result.fail("最大金额不能大于已配置金额");
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ if (ro.getMiniPrice() > ro.getMaxPrice()) {
|
|
|
|
+ return Result.fail("最小金额不能大于最大金额");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PaymentMethod updateMethod = new PaymentMethod();
|
|
|
|
+ updateMethod.setId(paymentId);
|
|
|
|
+ updateMethod.setMiniPrice(ro.getMiniPrice());
|
|
|
|
+ updateMethod.setMaxPrice(ro.getMaxPrice());
|
|
|
|
+
|
|
|
|
+ paymentMethodService.update(updateMethod);
|
|
|
|
+
|
|
|
|
+ return Result.success();
|
|
}
|
|
}
|
|
}
|
|
}
|