添加新版开放平台支付
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbActivateMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TbActivate record);
|
||||
|
||||
int insertSelective(TbActivate record);
|
||||
|
||||
TbActivate selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbActivate record);
|
||||
|
||||
int updateByPrimaryKey(TbActivate record);
|
||||
|
||||
TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TbActivate implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private Integer shopId;
|
||||
|
||||
private Integer minNum;
|
||||
|
||||
private Integer maxNum;
|
||||
|
||||
private BigDecimal handselNum;
|
||||
|
||||
private String handselType;
|
||||
|
||||
private String isDel;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public Integer getMinNum() {
|
||||
return minNum;
|
||||
}
|
||||
|
||||
public void setMinNum(Integer minNum) {
|
||||
this.minNum = minNum;
|
||||
}
|
||||
|
||||
public Integer getMaxNum() {
|
||||
return maxNum;
|
||||
}
|
||||
|
||||
public void setMaxNum(Integer maxNum) {
|
||||
this.maxNum = maxNum;
|
||||
}
|
||||
|
||||
public BigDecimal getHandselNum() {
|
||||
return handselNum;
|
||||
}
|
||||
|
||||
public void setHandselNum(BigDecimal handselNum) {
|
||||
this.handselNum = handselNum;
|
||||
}
|
||||
|
||||
public String getHandselType() {
|
||||
return handselType;
|
||||
}
|
||||
|
||||
public void setHandselType(String handselType) {
|
||||
this.handselType = handselType == null ? null : handselType.trim();
|
||||
}
|
||||
|
||||
public String getIsDel() {
|
||||
return isDel;
|
||||
}
|
||||
|
||||
public void setIsDel(String isDel) {
|
||||
this.isDel = isDel == null ? null : isDel.trim();
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,8 @@ public class PayService {
|
||||
@Autowired
|
||||
ThirdPayService thirdPayService;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
|
||||
@Autowired
|
||||
@@ -127,6 +129,9 @@ public class PayService {
|
||||
@Resource
|
||||
private GroupOrderCouponService orderCouponService;
|
||||
|
||||
@Autowired
|
||||
TbActivateMapper tbActivateMapper;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result payOrder(String openId,String orderId,String ip) throws Exception {
|
||||
@@ -630,8 +635,9 @@ public class PayService {
|
||||
return Result.fail("对应的用户信息不存在");
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(tbShopUser.getIsVip())||!"1".equals(tbShopUser.getIsVip().toString())){
|
||||
return Result.fail("非会员用户不允许充值");
|
||||
|
||||
if("0".equals(tbShopUser.getIsPwd())){
|
||||
return Result.fail("用户支付密码未设置");
|
||||
}
|
||||
|
||||
|
||||
@@ -848,10 +854,103 @@ public class PayService {
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
TbActivate activate= tbActivateMapper.selectByAmount(tbShopUser.getShopId(),memberIn.getAmount());
|
||||
if(ObjectUtil.isNotEmpty(activate)&&ObjectUtil.isNotNull(activate)){
|
||||
BigDecimal amount=BigDecimal.ZERO;
|
||||
switch (activate.getHandselType()){
|
||||
case "GD":
|
||||
amount=activate.getHandselNum();
|
||||
break;
|
||||
case "RATIO":
|
||||
amount=memberIn.getAmount().multiply(activate.getHandselNum());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
flow=new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberAwardIn");
|
||||
flow.setBizName("会员充值奖励");
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String fstMemberInSuccess(String payOrderNO,String tradeNo){
|
||||
TbMemberIn memberIn= tbMemberInMapper.selectByOrderNo(payOrderNO);
|
||||
if(ObjectUtil.isEmpty(memberIn)){
|
||||
return "充值记录不存在";
|
||||
}
|
||||
|
||||
memberIn.setTradeNo(tradeNo);
|
||||
memberIn.setStatus("0");
|
||||
memberIn.setUpdateTime(new Date());
|
||||
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(memberIn.getUserId().toString(),memberIn.getShopId().toString());
|
||||
if(ObjectUtil.isEmpty(tbShopUser)){
|
||||
return "用户信息不存在";
|
||||
}
|
||||
|
||||
if(!"1".equals(tbShopUser.getIsVip().toString())){
|
||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||
}
|
||||
|
||||
//修改客户资金
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(memberIn.getAmount()));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
TbShopUserFlow flow=new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberIn");
|
||||
flow.setBizName("会员扫码充值");
|
||||
flow.setAmount(memberIn.getAmount());
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
TbActivate activate= tbActivateMapper.selectByAmount(tbShopUser.getShopId(),memberIn.getAmount());
|
||||
if(ObjectUtil.isNotEmpty(activate)&&ObjectUtil.isNotNull(activate)){
|
||||
BigDecimal amount=BigDecimal.ZERO;
|
||||
switch (activate.getHandselType()){
|
||||
case "GD":
|
||||
amount=activate.getHandselNum();
|
||||
break;
|
||||
case "RATIO":
|
||||
amount=memberIn.getAmount().multiply(activate.getHandselNum());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
flow=new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberAwardIn");
|
||||
flow.setBizName("会员充值奖励");
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
}
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
|
||||
// public Result returnOrder(){
|
||||
//
|
||||
// }
|
||||
|
||||
@@ -83,7 +83,8 @@ public class ProductService {
|
||||
tbShopUser.setShopId(shopId);
|
||||
tbShopUser.setUserId(userId);
|
||||
tbShopUser.setMiniOpenId(openId);
|
||||
tbShopUser.setIsPwd("1");
|
||||
tbShopUser.setPwd(MD5Util.encrypt("123456"));
|
||||
tbShopUser.setIsPwd("0");
|
||||
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.insert(tbShopUser);
|
||||
|
||||
@@ -295,6 +295,6 @@ public class ThirdPayService {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "131112206836873461", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI");
|
||||
new ThirdPayService().mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "132933158610062686", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://cashierclient.sxczgkj.cn/cashierService/notify/fstmemberInCallBack", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,5 +57,5 @@ aliyun:
|
||||
|
||||
thirdPay:
|
||||
payType: fushangtong
|
||||
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||
callBack: https://cashierclient.sxczgkj.cn/${server.servlet.context-path}/notify/fstmemberInCallBack
|
||||
url: https://paymentapi.sxczgkj.cn
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<generatorConfiguration>
|
||||
<!-- 需要指明数据库连接器的绝对路径 -->
|
||||
<!-- <classPathEntry location="C:\Users\admin\.m1\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar" />-->
|
||||
<classPathEntry location="E:\app\maven\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
|
||||
<classPathEntry location="D:\.m2\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
|
||||
<context id="msqlTables" targetRuntime="MyBatis3">
|
||||
<!-- 生成的pojo,将implements Serializable-->
|
||||
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
<!-- 数据库链接URL、用户名、密码 -->
|
||||
|
||||
<jdbcConnection connectionURL="jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8"
|
||||
driverClass="com.mysql.cj.jdbc.Driver" password="mysqlroot@123" userId="root" >
|
||||
<jdbcConnection connectionURL="jdbc:mysql://101.37.12.135:3306/fycashier?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8"
|
||||
driverClass="com.mysql.cj.jdbc.Driver" password="Twc6MrzzjBiWSsjh" userId="fycashier" >
|
||||
|
||||
<property name="nullCatalogMeansCurrent" value="true"/>
|
||||
</jdbcConnection>
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
||||
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
||||
<table tableName="tb_yhq_params" domainObjectName="TbYhqParams"
|
||||
<table tableName="tb_activate" domainObjectName="TbActivate"
|
||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||
enableSelectByExample="false" selectByExampleQueryId="false" >
|
||||
</table>
|
||||
|
||||
121
src/main/resources/mapper/TbActivateMapper.xml
Normal file
121
src/main/resources/mapper/TbActivateMapper.xml
Normal file
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbActivateMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbActivate">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||
<result column="min_num" jdbcType="INTEGER" property="minNum" />
|
||||
<result column="max_num" jdbcType="INTEGER" property="maxNum" />
|
||||
<result column="handsel_num" jdbcType="DECIMAL" property="handselNum" />
|
||||
<result column="handsel_type" jdbcType="VARCHAR" property="handselType" />
|
||||
<result column="is_del" jdbcType="VARCHAR" property="isDel" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_activate
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_activate
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
|
||||
insert into tb_activate (id, shop_id, min_num,
|
||||
max_num, handsel_num, handsel_type,
|
||||
is_del)
|
||||
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{minNum,jdbcType=INTEGER},
|
||||
#{maxNum,jdbcType=INTEGER}, #{handselNum,jdbcType=DECIMAL}, #{handselType,jdbcType=VARCHAR},
|
||||
#{isDel,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
|
||||
insert into tb_activate
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id,
|
||||
</if>
|
||||
<if test="minNum != null">
|
||||
min_num,
|
||||
</if>
|
||||
<if test="maxNum != null">
|
||||
max_num,
|
||||
</if>
|
||||
<if test="handselNum != null">
|
||||
handsel_num,
|
||||
</if>
|
||||
<if test="handselType != null">
|
||||
handsel_type,
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
is_del,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
#{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="minNum != null">
|
||||
#{minNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="maxNum != null">
|
||||
#{maxNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="handselNum != null">
|
||||
#{handselNum,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="handselType != null">
|
||||
#{handselType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
#{isDel,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
|
||||
update tb_activate
|
||||
<set>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="minNum != null">
|
||||
min_num = #{minNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="maxNum != null">
|
||||
max_num = #{maxNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="handselNum != null">
|
||||
handsel_num = #{handselNum,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="handselType != null">
|
||||
handsel_type = #{handselType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isDel != null">
|
||||
is_del = #{isDel,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
|
||||
update tb_activate
|
||||
set shop_id = #{shopId,jdbcType=INTEGER},
|
||||
min_num = #{minNum,jdbcType=INTEGER},
|
||||
max_num = #{maxNum,jdbcType=INTEGER},
|
||||
handsel_num = #{handselNum,jdbcType=DECIMAL},
|
||||
handsel_type = #{handselType,jdbcType=VARCHAR},
|
||||
is_del = #{isDel,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
<select id="selectByAmount" resultMap="BaseResultMap">
|
||||
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num <= #{amount} and max_num >={amount}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user