分销二维码接口
This commit is contained in:
parent
b355cd0ba7
commit
30c513d71d
|
|
@ -40,78 +40,78 @@ public class DistributionController {
|
||||||
@Resource
|
@Resource
|
||||||
private AppWxServiceImpl appWxService;
|
private AppWxServiceImpl appWxService;
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 配置信息详情
|
* 配置信息详情
|
||||||
// */
|
*/
|
||||||
// @SaAdminCheckPermission(value = "distribution:detail", name = "分销配置")
|
@SaAdminCheckPermission(value = "distribution:detail", name = "分销配置")
|
||||||
// @GetMapping
|
@GetMapping
|
||||||
// public CzgResult<MkDistributionConfigVO> detail() {
|
public CzgResult<MkDistributionConfigVO> detail() {
|
||||||
// return CzgResult.success(configService.detail(StpKit.USER.getShopId()));
|
return CzgResult.success(configService.detail(StpKit.USER.getShopId()));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 配置信息修改
|
* 配置信息修改
|
||||||
// *
|
*
|
||||||
// * @return 是否成功
|
* @return 是否成功
|
||||||
// */
|
*/
|
||||||
// @SaAdminCheckPermission(value = "distribution:edit", name = "分销修改")
|
@SaAdminCheckPermission(value = "distribution:edit", name = "分销修改")
|
||||||
// @SaCheckMainShop
|
@SaCheckMainShop
|
||||||
// @PutMapping
|
@PutMapping
|
||||||
// public CzgResult<Boolean> edit( @RequestBody MkDistributionConfigDTO dto) {
|
public CzgResult<Boolean> edit( @RequestBody MkDistributionConfigDTO dto) {
|
||||||
// return CzgResult.success(configService.edit(StpKit.USER.getShopId(), dto));
|
return CzgResult.success(configService.edit(StpKit.USER.getShopId(), dto));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 现金充值
|
* 现金充值
|
||||||
// * @param payParam 充值信息
|
* @param payParam 充值信息
|
||||||
// * @return 是否成功
|
* @return 是否成功
|
||||||
// */
|
*/
|
||||||
// @PostMapping("/cashPay")
|
@PostMapping("/cashPay")
|
||||||
// public CzgResult<Boolean> cashPayOrder(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
public CzgResult<Boolean> cashPayOrder(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||||
// AssertUtil.isNull(payParam.getShopId(), "店铺id不能为空");
|
AssertUtil.isNull(payParam.getShopId(), "店铺id不能为空");
|
||||||
// AssertUtil.isNull(payParam.getAmount(), "充值金额不能为空");
|
AssertUtil.isNull(payParam.getAmount(), "充值金额不能为空");
|
||||||
// AssertUtil.isTrue(payParam.getAmount().compareTo(BigDecimal.ZERO) == 0, "金额不为0");
|
AssertUtil.isTrue(payParam.getAmount().compareTo(BigDecimal.ZERO) == 0, "金额不为0");
|
||||||
// return CzgResult.success(distributionUserService.cashPayOrder(StpKit.USER.getLoginIdAsLong(), payParam));
|
return CzgResult.success(distributionUserService.cashPayOrder(StpKit.USER.getLoginIdAsLong(), payParam));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 金额记录
|
* 金额记录
|
||||||
// * @param type manual_recharge充值 self_recharge自助充值 refund退款 manual_sub手动扣减 sub统扣减
|
* @param type manual_recharge充值 self_recharge自助充值 refund退款 manual_sub手动扣减 sub统扣减
|
||||||
// * @param key 搜索
|
* @param key 搜索
|
||||||
// */
|
*/
|
||||||
// @GetMapping("/flow")
|
@GetMapping("/flow")
|
||||||
// public CzgResult<Map<String, Object>> flow(@RequestParam(required = false) Long shopId, @RequestParam(required = false) String type, @RequestParam(required = false) String key) {
|
public CzgResult<Map<String, Object>> flow(@RequestParam(required = false) Long shopId, @RequestParam(required = false) String type, @RequestParam(required = false) String key) {
|
||||||
// return CzgResult.success(distributionAmountFlowService.pageInfo(StpKit.USER.isAdmin() ? shopId : StpKit.USER.getShopId(), type, key));
|
return CzgResult.success(distributionAmountFlowService.pageInfo(StpKit.USER.isAdmin() ? shopId : StpKit.USER.getShopId(), type, key));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 开通记录
|
* 开通记录
|
||||||
// * @param startTime 开始时间
|
* @param startTime 开始时间
|
||||||
// * @param endTime 结束时间
|
* @param endTime 结束时间
|
||||||
// * @param key 用户id昵称
|
* @param key 用户id昵称
|
||||||
// */
|
*/
|
||||||
// @GetMapping("openFlow")
|
@GetMapping("openFlow")
|
||||||
// public CzgResult<Map<String, Object>> openFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String key) {
|
public CzgResult<Map<String, Object>> openFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String key) {
|
||||||
// return CzgResult.success(distributionAmountFlowService.openPageInfo(StpKit.USER.getShopId(),
|
return CzgResult.success(distributionAmountFlowService.openPageInfo(StpKit.USER.getShopId(),
|
||||||
// StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key));
|
StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 分销明细
|
* 分销明细
|
||||||
// * @param startTime 开始时间
|
* @param startTime 开始时间
|
||||||
// * @param endTime 结束时间
|
* @param endTime 结束时间
|
||||||
// * @param key 用户id昵称
|
* @param key 用户id昵称
|
||||||
// * @param status pending待入账 success已入账
|
* @param status pending待入账 success已入账
|
||||||
// */
|
*/
|
||||||
// @GetMapping("distributionFlow")
|
@GetMapping("distributionFlow")
|
||||||
// public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
|
public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
|
||||||
// @RequestParam(required = false) String key, @RequestParam(required = false) String status,
|
@RequestParam(required = false) String key, @RequestParam(required = false) String status,
|
||||||
// @RequestParam(required = false) Long id) {
|
@RequestParam(required = false) Long id) {
|
||||||
// return CzgResult.success(distributionFlowService.pageInfo(StpKit.USER.getShopId(),
|
return CzgResult.success(distributionFlowService.pageInfo(StpKit.USER.getShopId(),
|
||||||
// StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key, status, id));
|
StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key, status, id));
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -136,7 +136,7 @@ public class DistributionController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/rechargeQrCode")
|
@GetMapping("/rechargeQrCode")
|
||||||
public CzgResult<String> rechargeQrCode(@RequestParam BigDecimal amount) {
|
public CzgResult<String> rechargeQrCode(@RequestParam BigDecimal amount) {
|
||||||
return CzgResult.success(appWxService.genCode("pages/pay", "amount=" + amount + "&shopId=" + StpKit.USER.getShopId()));
|
return CzgResult.success(configService.rechargeQrCode(StpKit.USER.getShopId(), amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,6 @@ public interface MkDistributionConfigService extends IService<MkDistributionConf
|
||||||
MkDistributionConfigVO detail(Long shopId);
|
MkDistributionConfigVO detail(Long shopId);
|
||||||
|
|
||||||
Boolean edit(Long shopId, MkDistributionConfigDTO dto);
|
Boolean edit(Long shopId, MkDistributionConfigDTO dto);
|
||||||
|
|
||||||
|
String rechargeQrCode(Long shopId, BigDecimal amount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.codec.Base64Encoder;
|
||||||
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
import com.czg.market.dto.MkDistributionConfigDTO;
|
import com.czg.market.dto.MkDistributionConfigDTO;
|
||||||
import com.czg.market.entity.MkDistributionConfig;
|
import com.czg.market.entity.MkDistributionConfig;
|
||||||
import com.czg.market.entity.MkDistributionLevelConfig;
|
import com.czg.market.entity.MkDistributionLevelConfig;
|
||||||
|
|
@ -16,6 +18,11 @@ import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分销配置 服务层实现。
|
* 分销配置 服务层实现。
|
||||||
*
|
*
|
||||||
|
|
@ -55,4 +62,27 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
||||||
|
|
||||||
return updateById(config);
|
return updateById(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String rechargeQrCode(Long shopId, BigDecimal amount) {
|
||||||
|
try {
|
||||||
|
// 生成二维码图片
|
||||||
|
BufferedImage image = QrCodeUtil.generate(
|
||||||
|
"https://cashier.sxczgkj.com/payTest?shopId=" + shopId + "&amount=" + amount,
|
||||||
|
500,
|
||||||
|
500
|
||||||
|
);
|
||||||
|
|
||||||
|
// 转为字节流
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(image, "png", os);
|
||||||
|
|
||||||
|
// 转 Base64
|
||||||
|
String base64 = Base64Encoder.encode(os.toByteArray());
|
||||||
|
return "data:image/png;base64," + base64;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("生成二维码失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue