|
@@ -1,19 +1,27 @@
|
|
|
package com.ruoyi.web.controller.platform;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
+import com.ruoyi.common.utils.CreateCharAndNum;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.system.domain.BaseParam;
|
|
|
import com.ruoyi.system.domain.MerchantUser;
|
|
|
import com.ruoyi.system.service.MerchantUserService;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* 商户信息Controller
|
|
|
- *
|
|
|
+ *
|
|
|
* @author liming
|
|
|
* @date 2023-08-16
|
|
|
*/
|
|
@@ -22,9 +30,22 @@ import java.util.UUID;
|
|
|
public class MerchantUserController extends BaseController {
|
|
|
@Autowired
|
|
|
private MerchantUserService merchantUserService;
|
|
|
+ @Autowired
|
|
|
+ private CreateCharAndNum createCharAndNum;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商户列表
|
|
|
+ */
|
|
|
+ @PostMapping("/list")
|
|
|
+ public R<IPage<MerchantUser>> list(@RequestBody BaseParam param) {
|
|
|
+ IPage<MerchantUser> merchantUserIPage = merchantUserService.page(new Page<MerchantUser>().setCurrent(param.getCurrent()).setSize(param.getSize()),
|
|
|
+ new LambdaQueryWrapper<MerchantUser>().like(param.getName() != null, MerchantUser::getName, param.getName())
|
|
|
+ .eq(MerchantUser::getDelFlag, 0));
|
|
|
+ return R.ok(merchantUserIPage);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 查询商户信息列表
|
|
|
+ * 查询全部商户信息列表
|
|
|
*/
|
|
|
@PostMapping("/allList")
|
|
|
public R<List<MerchantUser>> list() {
|
|
@@ -36,18 +57,44 @@ public class MerchantUserController extends BaseController {
|
|
|
/**
|
|
|
* 新增商户信息
|
|
|
*/
|
|
|
- @PostMapping("/add")
|
|
|
+ @PostMapping("/addOrUpdate")
|
|
|
public R<Boolean> add(@RequestBody MerchantUser param) {
|
|
|
if (param.getId() != null) {
|
|
|
+ //更新
|
|
|
param.setUpdateTime(DateUtils.getNowDate());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ //新增
|
|
|
param.setCreateTime(DateUtils.getNowDate());
|
|
|
- //随机生成6位商户标识
|
|
|
- String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 6);
|
|
|
- param.setMerchantCode(uuid);
|
|
|
+// //随机生成6位商户标识
|
|
|
+// String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 6);
|
|
|
+ //随机生成4位数字加字母
|
|
|
+ String charAndNum = createCharAndNum.getCharAndNum(4);
|
|
|
+ //如果有重复的重新生成
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ MerchantUser one = merchantUserService.getOne(new LambdaQueryWrapper<MerchantUser>().eq(MerchantUser::getMerchantCode, charAndNum), false);
|
|
|
+ if (one != null) {
|
|
|
+ charAndNum = createCharAndNum.getCharAndNum(4);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ param.setMerchantCode(charAndNum);
|
|
|
}
|
|
|
return R.ok(merchantUserService.saveOrUpdate(param));
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除商户
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public R<T> remove(@RequestBody BaseParam param) {
|
|
|
+ boolean flat = merchantUserService.removeById(param.getId());
|
|
|
+ if (!flat) {
|
|
|
+ return R.fail("删除失败");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
}
|