增加支付相关
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package me.zhengjie.modules.payType.domain;
|
||||
|
||||
import com.alipay.service.schema.util.StringUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayTypeEnum {
|
||||
CASH("cash","现金"),BANK("bank","银行卡"),SCANCODE("scanCode","扫码支付"),
|
||||
DEPOSIT("deposit","储值"),ARREARS("arrears","挂单");
|
||||
|
||||
private String type;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
public static String getNameByType(String name) {
|
||||
PayTypeEnum[] operateTypes = values();
|
||||
for (PayTypeEnum ot : operateTypes) {
|
||||
if (ot.name.equals(name)) {
|
||||
return ot.getType();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -37,6 +36,7 @@ public class TbShopPayType implements Serializable {
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`pay_type`")
|
||||
|
||||
@@ -46,7 +46,6 @@ public class TbShopPayTypeController {
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopPayType:list')")
|
||||
public void exportTbShopPayType(HttpServletResponse response, TbShopPayTypeQueryCriteria criteria) throws IOException {
|
||||
tbShopPayTypeService.download(tbShopPayTypeService.queryAll(criteria), response);
|
||||
}
|
||||
@@ -54,7 +53,6 @@ public class TbShopPayTypeController {
|
||||
@GetMapping
|
||||
@Log("查询/merchant/system/paytype")
|
||||
@ApiOperation("查询/merchant/system/paytype")
|
||||
@PreAuthorize("@el.check('tbShopPayType:list')")
|
||||
public ResponseEntity<Object> queryTbShopPayType(TbShopPayTypeQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopPayTypeService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
@@ -62,7 +60,6 @@ public class TbShopPayTypeController {
|
||||
@PostMapping
|
||||
@Log("新增/merchant/system/paytype")
|
||||
@ApiOperation("新增/merchant/system/paytype")
|
||||
@PreAuthorize("@el.check('tbShopPayType:add')")
|
||||
public ResponseEntity<Object> createTbShopPayType(@Validated @RequestBody TbShopPayType resources){
|
||||
return new ResponseEntity<>(tbShopPayTypeService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
@@ -70,7 +67,6 @@ public class TbShopPayTypeController {
|
||||
@PutMapping
|
||||
@Log("修改/merchant/system/paytype")
|
||||
@ApiOperation("修改/merchant/system/paytype")
|
||||
@PreAuthorize("@el.check('tbShopPayType:edit')")
|
||||
public ResponseEntity<Object> updateTbShopPayType(@Validated @RequestBody TbShopPayType resources){
|
||||
tbShopPayTypeService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
@@ -79,7 +75,6 @@ public class TbShopPayTypeController {
|
||||
@DeleteMapping
|
||||
@Log("删除/merchant/system/paytype")
|
||||
@ApiOperation("删除/merchant/system/paytype")
|
||||
@PreAuthorize("@el.check('tbShopPayType:del')")
|
||||
public ResponseEntity<Object> deleteTbShopPayType(@RequestBody Integer[] ids) {
|
||||
tbShopPayTypeService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -15,21 +15,25 @@
|
||||
*/
|
||||
package me.zhengjie.modules.payType.service.impl;
|
||||
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.payType.domain.PayTypeEnum;
|
||||
import me.zhengjie.modules.payType.repository.TbShopPayTypeRepository;
|
||||
import me.zhengjie.modules.payType.service.dto.TbShopPayTypeDto;
|
||||
import me.zhengjie.modules.payType.service.dto.TbShopPayTypeQueryCriteria;
|
||||
import me.zhengjie.modules.payType.service.mapstruct.TbShopPayTypeMapper;
|
||||
import me.zhengjie.modules.payType.domain.TbShopPayType;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.payType.repository.TbShopPayTypeRepository;
|
||||
import me.zhengjie.modules.payType.service.TbShopPayTypeService;
|
||||
import me.zhengjie.modules.payType.service.dto.TbShopPayTypeDto;
|
||||
import me.zhengjie.modules.payType.service.dto.TbShopPayTypeQueryCriteria;
|
||||
import me.zhengjie.modules.payType.service.mapstruct.TbShopPayTypeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
@@ -72,13 +76,31 @@ public class TbShopPayTypeServiceImpl implements TbShopPayTypeService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopPayTypeDto create(TbShopPayType resources) {
|
||||
if (resources.getPayName() == null || "".equals(resources.getPayName())){
|
||||
throw new BadRequestException("付款方式不能为空");
|
||||
}
|
||||
//类型转换
|
||||
String nameByType = PayTypeEnum.getNameByType(resources.getPayName());
|
||||
resources.setPayType(nameByType);
|
||||
resources.setIsRefundable(0);
|
||||
resources.setIsShowShortcut(1);
|
||||
resources.setIsSystem(0);
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
return tbShopPayTypeMapper.toDto(tbShopPayTypeRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopPayType resources) {
|
||||
if (resources.getPayName() == null || "".equals(resources.getPayName())){
|
||||
throw new BadRequestException("付款方式不能为空");
|
||||
}
|
||||
TbShopPayType tbShopPayType = tbShopPayTypeRepository.findById(resources.getId()).orElseGet(TbShopPayType::new);
|
||||
//类型转换
|
||||
String nameByType = PayTypeEnum.getNameByType(resources.getPayName());
|
||||
resources.setPayType(nameByType);
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
ValidationUtil.isNull( tbShopPayType.getId(),"TbShopPayType","id",resources.getId());
|
||||
tbShopPayType.copy(resources);
|
||||
tbShopPayTypeRepository.save(tbShopPayType);
|
||||
|
||||
@@ -138,7 +138,11 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
tbMerchantAccount.setIsMercantile(0);
|
||||
tbMerchantAccount.setStatus(1);
|
||||
tbMerchantAccount.setMsgAble(0);
|
||||
merchantAccountRepository.save(tbMerchantAccount);
|
||||
TbMerchantAccount save1 = merchantAccountRepository.save(tbMerchantAccount);
|
||||
//绑定accountId
|
||||
tbShopInfo.setMerchantId(String.valueOf(save1.getId()));
|
||||
tbShopInfoRepository.save(tbShopInfo);
|
||||
|
||||
//添加收银系统后台账号
|
||||
User user = new User();
|
||||
user.setPassword(passwordEncoder.encode(resources.getPassword()));
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.io.Serializable;
|
||||
public class TbMerchantThirdApply implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
private Integer id;
|
||||
|
||||
@@ -27,13 +27,14 @@ import org.springframework.data.jpa.repository.Query;
|
||||
* @date 2024-02-02
|
||||
**/
|
||||
public interface TbMerchantThirdApplyRepository extends JpaRepository<TbMerchantThirdApply, Integer>, JpaSpecificationExecutor<TbMerchantThirdApply> {
|
||||
/**
|
||||
* 根据 AppId 查询
|
||||
* @param app_id /
|
||||
* @return /
|
||||
*/
|
||||
TbMerchantThirdApply findByAppId(String app_id);
|
||||
|
||||
@Query("select thirdApply from TbMerchantThirdApply thirdApply where thirdApply.shopId = :shopId")
|
||||
TbMerchantThirdApply findByShopId(@Param("shopId") Integer shopId);
|
||||
|
||||
@Query("select thirdApply from TbMerchantThirdApply thirdApply where thirdApply.id = :id")
|
||||
TbMerchantThirdApply findByShopId(@Param("id") Integer id);
|
||||
/**
|
||||
* 根据 AppId 查询
|
||||
* @return /
|
||||
*/
|
||||
@Query("select thirdApply from TbMerchantThirdApply thirdApply where thirdApply.appId = :appId")
|
||||
TbMerchantThirdApply findByAppId(@Param("appId") String appId);
|
||||
}
|
||||
@@ -60,9 +60,9 @@ public class TbMerchantThirdApplyController {
|
||||
return new ResponseEntity<>(tbMerchantThirdApplyService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{shopId}")
|
||||
public ResponseEntity<Object> queryTbMerchantThirdApply(@PathVariable Integer shopId){
|
||||
TbMerchantThirdApplyDto byShopId = tbMerchantThirdApplyService.findByShopId(shopId);
|
||||
@GetMapping("/{merchantId}")
|
||||
public ResponseEntity<Object> queryTbMerchantThirdApply(@PathVariable Integer merchantId){
|
||||
TbMerchantThirdApplyDto byShopId = tbMerchantThirdApplyService.findByShopId(merchantId);
|
||||
if (byShopId == null){
|
||||
return new ResponseEntity<>(new TbMerchantThirdApplyDto(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -90,11 +90,17 @@ public class TbMerchantThirdApplyServiceImpl implements TbMerchantThirdApplyServ
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbMerchantThirdApply resources) {
|
||||
TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyRepository.findById(resources.getId()).orElseGet(TbMerchantThirdApply::new);
|
||||
ValidationUtil.isNull( tbMerchantThirdApply.getId(),"TbMerchantThirdApply","id",resources.getId());
|
||||
tbMerchantThirdApply.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbMerchantThirdApply.copy(resources);
|
||||
tbMerchantThirdApplyRepository.saveAndFlush(tbMerchantThirdApply);
|
||||
TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyRepository.findByShopId(resources.getId());
|
||||
if (tbMerchantThirdApply == null){
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
tbMerchantThirdApplyRepository.save(resources);
|
||||
}else {
|
||||
ValidationUtil.isNull(tbMerchantThirdApply.getId(), "TbMerchantThirdApply", "id", resources.getId());
|
||||
tbMerchantThirdApply.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbMerchantThirdApply.copy(resources);
|
||||
tbMerchantThirdApplyRepository.saveAndFlush(tbMerchantThirdApply);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user