Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -40,78 +40,78 @@ public class DistributionController {
|
||||
@Resource
|
||||
private AppWxServiceImpl appWxService;
|
||||
|
||||
// /**
|
||||
// * 配置信息详情
|
||||
// */
|
||||
// @SaAdminCheckPermission(value = "distribution:detail", name = "分销配置")
|
||||
// @GetMapping
|
||||
// public CzgResult<MkDistributionConfigVO> detail() {
|
||||
// return CzgResult.success(configService.detail(StpKit.USER.getShopId()));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 配置信息修改
|
||||
// *
|
||||
// * @return 是否成功
|
||||
// */
|
||||
// @SaAdminCheckPermission(value = "distribution:edit", name = "分销修改")
|
||||
// @SaCheckMainShop
|
||||
// @PutMapping
|
||||
// public CzgResult<Boolean> edit( @RequestBody MkDistributionConfigDTO dto) {
|
||||
// return CzgResult.success(configService.edit(StpKit.USER.getShopId(), dto));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 现金充值
|
||||
// * @param payParam 充值信息
|
||||
// * @return 是否成功
|
||||
// */
|
||||
// @PostMapping("/cashPay")
|
||||
// public CzgResult<Boolean> cashPayOrder(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
// AssertUtil.isNull(payParam.getShopId(), "店铺id不能为空");
|
||||
// AssertUtil.isNull(payParam.getAmount(), "充值金额不能为空");
|
||||
// AssertUtil.isTrue(payParam.getAmount().compareTo(BigDecimal.ZERO) == 0, "金额不为0");
|
||||
// return CzgResult.success(distributionUserService.cashPayOrder(StpKit.USER.getLoginIdAsLong(), payParam));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 金额记录
|
||||
// * @param type manual_recharge充值 self_recharge自助充值 refund退款 manual_sub手动扣减 sub统扣减
|
||||
// * @param key 搜索
|
||||
// */
|
||||
// @GetMapping("/flow")
|
||||
// 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));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 开通记录
|
||||
// * @param startTime 开始时间
|
||||
// * @param endTime 结束时间
|
||||
// * @param key 用户id昵称
|
||||
// */
|
||||
// @GetMapping("openFlow")
|
||||
// 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(),
|
||||
// StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 分销明细
|
||||
// * @param startTime 开始时间
|
||||
// * @param endTime 结束时间
|
||||
// * @param key 用户id昵称
|
||||
// * @param status pending待入账 success已入账
|
||||
// */
|
||||
// @GetMapping("distributionFlow")
|
||||
// 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) Long id) {
|
||||
// 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));
|
||||
// }
|
||||
/**
|
||||
* 配置信息详情
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "distribution:detail", name = "分销配置")
|
||||
@GetMapping
|
||||
public CzgResult<MkDistributionConfigVO> detail() {
|
||||
return CzgResult.success(configService.detail(StpKit.USER.getShopId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息修改
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "distribution:edit", name = "分销修改")
|
||||
@SaCheckMainShop
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit( @RequestBody MkDistributionConfigDTO dto) {
|
||||
return CzgResult.success(configService.edit(StpKit.USER.getShopId(), dto));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
* @param payParam 充值信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping("/cashPay")
|
||||
public CzgResult<Boolean> cashPayOrder(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopId(), "店铺id不能为空");
|
||||
AssertUtil.isNull(payParam.getAmount(), "充值金额不能为空");
|
||||
AssertUtil.isTrue(payParam.getAmount().compareTo(BigDecimal.ZERO) == 0, "金额不为0");
|
||||
return CzgResult.success(distributionUserService.cashPayOrder(StpKit.USER.getLoginIdAsLong(), payParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 金额记录
|
||||
* @param type manual_recharge充值 self_recharge自助充值 refund退款 manual_sub手动扣减 sub统扣减
|
||||
* @param key 搜索
|
||||
*/
|
||||
@GetMapping("/flow")
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通记录
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param key 用户id昵称
|
||||
*/
|
||||
@GetMapping("openFlow")
|
||||
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(),
|
||||
StrUtil.isNotBlank(startTime) ? DateUtil.parseLocalDateTime(startTime) : null, StrUtil.isNotBlank(endTime) ? DateUtil.parseLocalDateTime(endTime) : null, key));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销明细
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param key 用户id昵称
|
||||
* @param status pending待入账 success已入账
|
||||
*/
|
||||
@GetMapping("distributionFlow")
|
||||
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) Long id) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ public class DistributionController {
|
||||
*/
|
||||
@GetMapping("/rechargeQrCode")
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class NotifyController {
|
||||
payment.setPayTime(DateUtil.date().toLocalDateTime());
|
||||
payment.setRespJson(plainTextJson.toJSONString());
|
||||
paymentService.updateById(payment);
|
||||
distributionUserService.rechargeCallBack(payment.getSourceId(), payment.getShopId(), payment.getAmount(), payment.getId());
|
||||
distributionUserService.rechargeCallBack(payment.getShopId(), payment.getAmount(), payment.getId());
|
||||
}catch (Exception e) {
|
||||
log.error("充值回调失败", e);
|
||||
return "SUCCESS";
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface MkDistributionConfigService extends IService<MkDistributionConf
|
||||
MkDistributionConfigVO detail(Long shopId);
|
||||
|
||||
Boolean edit(Long shopId, MkDistributionConfigDTO dto);
|
||||
|
||||
String rechargeQrCode(Long shopId, BigDecimal amount);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
/**
|
||||
* 分销商户运营余额充值回调
|
||||
*/
|
||||
void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId);
|
||||
void rechargeCallBack(Long shopId, BigDecimal amount, Long paymentId);
|
||||
|
||||
/**
|
||||
* 发放分销奖励
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
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.entity.MkDistributionConfig;
|
||||
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.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);
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
|
||||
@Override
|
||||
public void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId) {
|
||||
public void rechargeCallBack(Long shopId, BigDecimal amount, Long paymentId) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
BigDecimal finalAmount = shopInfoService.updateAmount(shopId, amount);
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
|
||||
@@ -101,7 +101,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
|
||||
@Override
|
||||
public Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, true);
|
||||
InitInfo initInfo = initPayment(payParam.getUserId() == null ? payParam.getShopId() : payParam.getUserId(), payParam, true);
|
||||
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getPayType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user