Commit 78533c3b by huluobin

代理

parent 75f9ae1d
......@@ -50,4 +50,11 @@ public interface IAgentUserService extends IService<AgentUser> {
* @param agentUserId
*/
void addBalanceLog(Integer type, BigDecimal amount, Integer agentUserId);
/**
* 代理余额充值
* @param amount
* @return
*/
WxPayMpOrderResult chargeAmount(BigDecimal amount) throws UnknownHostException, WxPayException;
}
......@@ -100,8 +100,7 @@ public class AgentUserServiceImpl extends ServiceImpl<AgentUserMapper, AgentUser
AgentUser agentUser = this.selectByPhone(customer.getPhone());
AgentConfig agentConfig = agentConfigMapper.selectOne(new LambdaQueryWrapper<AgentConfig>()
.eq(AgentConfig::getRechargeAmount, amount));
AgentConfig agentConfig = agentConfigMapper.selectByRechargeAmount(new BigDecimal(result.getTotalFee() / 100))
//首次充值
......@@ -163,4 +162,28 @@ public class AgentUserServiceImpl extends ServiceImpl<AgentUserMapper, AgentUser
throw new RRException("invalid type");
}
}
@Override
public WxPayMpOrderResult chargeAmount(BigDecimal amount) throws UnknownHostException, WxPayException {
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyyMMddHHmmss");
WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder()
.deviceInfo("设备号")
.body("充值" + amount)
.detail("详情")
.attach("c")
.outTradeNo(IdWorker.getIdStr())
//充值金额
.totalFee(amount.multiply(new BigDecimal("100")).intValue())
.spbillCreateIp(InetAddress.getLocalHost().getHostAddress())
.timeStart(yyyyMMddHHmmss.format(new Date()))
.notifyUrl(gogirlProperties.getNotifyChargeAgent())
.tradeType("JSAPI")
.openid(SessionUtils.getCustomerToken().getOpenid())
.sceneInfo("gogirl美甲美睫沙龙")
.build();
return wxPayService.createJsapiOrder(request);
}
}
......@@ -3,6 +3,7 @@ package com.gogirl.domain.common;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -56,21 +57,25 @@ public class AgentUser implements Serializable {
@ApiModelProperty(value = "余额")
private BigDecimal balance;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "签约时间")
private LocalDateTime signingTime;
@ApiModelProperty(value = "当期累积消费")
private BigDecimal currentConsumeAmount;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "当前年度开始时间")
private LocalDateTime currentStartTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "到期时间")
private LocalDateTime dueDate;
@ApiModelProperty(value = "品牌id")
private Integer brandId;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private LocalDateTime createDate;
......
......@@ -2,6 +2,9 @@ package com.gogirl.infrastructure.mapper.common;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.common.AgentConfig;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
/**
* <p>
......@@ -13,4 +16,5 @@ import com.gogirl.domain.common.AgentConfig;
*/
public interface AgentConfigMapper extends BaseMapper<AgentConfig> {
AgentConfig selectByRechargeAmount(@Param("amount") BigDecimal amount);
}
......@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.net.UnknownHostException;
/**
......@@ -39,5 +40,11 @@ public class AgentUserController {
}
@ApiOperation("代理余额充值")
@GetMapping("/chargeAmount")
public JsonResult<WxPayMpOrderResult> chargeAmount(@RequestParam BigDecimal amount) throws WxPayException, UnknownHostException {
WxPayMpOrderResult result = agentUserService.chargeAmount(amount);
return JsonResult.success(result);
}
}
......@@ -65,9 +65,6 @@ public class MallOrderPayController {
}
@ApiOperation("余额抵扣的微信支付")
@GetMapping("/customer/mallOrderPay/balanceWxPayMallOrder/{mallOrderId}")
public JsonResult<WxPayMpOrderResult> balanceWxPayMallOrder(@RequestHeader String token,
......
......@@ -2,4 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gogirl.infrastructure.mapper.common.AgentConfigMapper">
<select id="selectByRechargeAmount" resultType="com.gogirl.domain.common.AgentConfig">
select *
from agent_config
where recharge_amount &lt;= #{amount}
order by recharge_amount desc
limit 1;
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment