Commit f0b9f7cb authored by ysongq's avatar ysongq

commit

parent d85b43d7
package com.jz.dm.mall.moduls.controller.finance;
import com.jz.common.base.BaseController;
import com.jz.common.utils.Result;
import com.jz.dm.mall.moduls.service.FinanceCustomerAssetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
/**
* 商城企业客户资产(TFinanceCustomerAssets)表控制层
*
* @author Bellamy
* @since 2020-12-01 10:41:38
*/
@RestController
@RequestMapping("financeCustomerAssets")
@Api(tags = "商城企业客户资产--controller")
public class FinanceCustomerAssetsController extends BaseController {
/**
* 服务对象
*/
@Autowired
private FinanceCustomerAssetsService assetsService;
@GetMapping("/findAssets")
@ApiOperation(value = "查询余额是否充足")
public Result findAssets(@RequestParam(name = "assetsId", required = false) Long assetsId,
@RequestParam(name = "datarice", required = false) BigDecimal dataPrice) {
assetsService.findAssets(assetsId,dataPrice);
return null;
}
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.jz.dm.mall.moduls.controller.order.bean; ...@@ -2,6 +2,7 @@ package com.jz.dm.mall.moduls.controller.order.bean;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -14,6 +15,7 @@ import java.util.List; ...@@ -14,6 +15,7 @@ import java.util.List;
* @since 2020-12-01 10:41:31 * @since 2020-12-01 10:41:31
*/ */
@ApiModel @ApiModel
@Data
public class DataGoodsApiDto implements Serializable { public class DataGoodsApiDto implements Serializable {
private static final long serialVersionUID = -14346819849726413L; private static final long serialVersionUID = -14346819849726413L;
/** /**
...@@ -96,7 +98,7 @@ public class DataGoodsApiDto implements Serializable { ...@@ -96,7 +98,7 @@ public class DataGoodsApiDto implements Serializable {
* 授权码token * 授权码token
*/ */
@ApiModelProperty(value = "授权码token") @ApiModelProperty(value = "授权码token")
private String requestToken; private String goodsToken;
/** /**
* 接口参数信息 * 接口参数信息
...@@ -104,139 +106,4 @@ public class DataGoodsApiDto implements Serializable { ...@@ -104,139 +106,4 @@ public class DataGoodsApiDto implements Serializable {
@ApiModelProperty(value = "接口参数信息") @ApiModelProperty(value = "接口参数信息")
private List<DataGoodsApiParamsDto> apiParamsDto; private List<DataGoodsApiParamsDto> apiParamsDto;
public Long getGoodsApi() {
return goodsApi;
}
public void setGoodsApi(Long goodsApi) {
this.goodsApi = goodsApi;
}
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public String getApiName() {
return apiName;
}
public void setApiName(String apiName) {
this.apiName = apiName;
}
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getApiMethod() {
return apiMethod;
}
public void setApiMethod(String apiMethod) {
this.apiMethod = apiMethod;
}
public String getApiProtocl() {
return apiProtocl;
}
public void setApiProtocl(String apiProtocl) {
this.apiProtocl = apiProtocl;
}
public String getReturnDataExample() {
return returnDataExample;
}
public void setReturnDataExample(String returnDataExample) {
this.returnDataExample = returnDataExample;
}
public String getRequestExample() {
return requestExample;
}
public void setRequestExample(String requestExample) {
this.requestExample = requestExample;
}
public String getReturnType() {
return returnType;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public Date getCreTime() {
return creTime;
}
public void setCreTime(Date creTime) {
this.creTime = creTime;
}
public String getCrePerson() {
return crePerson;
}
public void setCrePerson(String crePerson) {
this.crePerson = crePerson;
}
public String getUptPerson() {
return uptPerson;
}
public void setUptPerson(String uptPerson) {
this.uptPerson = uptPerson;
}
public Date getUptTime() {
return uptTime;
}
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
public String getRequestToken() {
return requestToken;
}
public void setRequestToken(String requestToken) {
this.requestToken = requestToken;
}
public List<DataGoodsApiParamsDto> getApiParamsDto() {
return apiParamsDto;
}
public void setApiParamsDto(List<DataGoodsApiParamsDto> apiParamsDto) {
this.apiParamsDto = apiParamsDto;
}
} }
\ No newline at end of file
...@@ -37,7 +37,7 @@ public class PayDto implements Serializable { ...@@ -37,7 +37,7 @@ public class PayDto implements Serializable {
@ApiModelProperty(value = "价格类型") @ApiModelProperty(value = "价格类型")
private String priceType; private String priceType;
@ApiModelProperty(value = "年(元)") @ApiModelProperty(value = "购买方式")
private String purchaseMethod; private String purchaseMethod;
// /** // /**
......
<?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.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao">
<resultMap type="com.jz.dm.mall.moduls.entity.FinanceCustomerAssets" id="TFinanceCustomerAssetsMap">
<result property="assetsId" column="assets_id" jdbcType="INTEGER"/>
<result property="departmentId" column="department_id" jdbcType="INTEGER"/>
<result property="useMoney" column="use_money" jdbcType="NUMERIC"/>
<result property="frozenMoney" column="frozen_money" jdbcType="NUMERIC"/>
<result property="totalMoney" column="total_money" jdbcType="NUMERIC"/>
<result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>
<result property="crePerson" column="cre_person" jdbcType="VARCHAR"/>
<result property="uptTime" column="upt_time" jdbcType="TIMESTAMP"/>
<result property="uptPerson" column="upt_person" jdbcType="VARCHAR"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="TFinanceCustomerAssetsMap">
select
assets_id, department_id, use_money, frozen_money, total_money, cre_time, cre_person, upt_time, upt_person, del_flag
from t_finance_customer_assets
where assets_id = #{assetsId}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TFinanceCustomerAssetsMap">
select
assets_id, department_id, use_money, frozen_money, total_money, cre_time, cre_person, upt_time, upt_person, del_flag
from t_finance_customer_assets
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="TFinanceCustomerAssetsMap">
select
assets_id, department_id, use_money, frozen_money, total_money, cre_time, cre_person, upt_time, upt_person,
del_flag
from t_finance_customer_assets
<where>
<if test="assetsId != null">
and assets_id = #{assetsId}
</if>
<if test="departmentId != null">
and department_id = #{departmentId}
</if>
<if test="useMoney != null">
and use_money = #{useMoney}
</if>
<if test="frozenMoney != null">
and frozen_money = #{frozenMoney}
</if>
<if test="totalMoney != null">
and total_money = #{totalMoney}
</if>
<if test="creTime != null">
and cre_time = #{creTime}
</if>
<if test="crePerson != null and crePerson != ''">
and cre_person = #{crePerson}
</if>
<if test="uptTime != null">
and upt_time = #{uptTime}
</if>
<if test="uptPerson != null and uptPerson != ''">
and upt_person = #{uptPerson}
</if>
<if test="delFlag != null and delFlag != ''">
and del_flag = #{delFlag}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="assetsId" useGeneratedKeys="true">
insert into t_finance_customer_assets(department_id, use_money, frozen_money, total_money, cre_time, cre_person, upt_time, upt_person, del_flag)
values (#{departmentId}, #{useMoney}, #{frozenMoney}, #{totalMoney}, #{creTime}, #{crePerson}, #{uptTime}, #{uptPerson}, #{delFlag})
</insert>
<insert id="insertBatch" keyProperty="assetsId" useGeneratedKeys="true">
insert into t_finance_customer_assets(department_id, use_money, frozen_money, total_money,
cre_time, cre_person, upt_time, upt_person, del_flag)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.departmentId}, #{entity.useMoney}, #{entity.frozenMoney}, #{entity.totalMoney}, #{entity.creTime},
#{entity.crePerson}, #{entity.uptTime}, #{entity.uptPerson}, #{entity.delFlag})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update t_finance_customer_assets
<set>
<if test="departmentId != null">
department_id = #{departmentId},
</if>
<if test="useMoney != null">
use_money = #{useMoney},
</if>
<if test="frozenMoney != null">
frozen_money = #{frozenMoney},
</if>
<if test="totalMoney != null">
total_money = #{totalMoney},
</if>
<if test="creTime != null">
cre_time = #{creTime},
</if>
<if test="crePerson != null and crePerson != ''">
cre_person = #{crePerson},
</if>
<if test="uptTime != null">
upt_time = #{uptTime},
</if>
<if test="uptPerson != null and uptPerson != ''">
upt_person = #{uptPerson},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
</set>
where assets_id = #{assetsId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from t_finance_customer_assets where assets_id = #{assetsId}
</delete>
<update id="uptAccountMoney" parameterType="com.jz.dm.mall.moduls.entity.FinanceCustomerAssets">
update t_finance_customer_assets
<set>
<if test="useMoney != null">
use_money = #{useMoney},
</if>
<if test="totalMoney != null">
total_money = #{totalMoney},
</if>
<if test="frozenMoney != null">
frozen_money = #{frozenMoney},
</if>
<if test="uptTime != null">
upt_time = #{uptTime},
</if>
<if test="uptPerson != null and uptPerson != ''">
upt_person = #{uptPerson},
</if>
<if test="remark != null">
remark = #{remark},
</if>
</set>
where assets_id = #{assetsId}
</update>
<!--添加一条充值记录-->
<insert id="addCoustomerCzMoney" keyProperty="cashOutId" useGeneratedKeys="true">
insert into t_finance_customer_balance(assets_id, balance_money, remark, cre_time, cre_person, audit_status)
values (#{assetsId}, #{balanceMoney}, #{remark}, #{creTime}, #{crePerson}, #{auditStatus})
</insert>
<insert id="insertFinanceCustome">
INSERT INTO t_finance_customer_assets(department_id,cre_time, cre_person)VALUES
(#{finance.departmentId},NOW(),#{finance.crePerson})
</insert>
<select id="findById" resultMap="TFinanceCustomerAssetsMap">
select
assets_id, department_id, use_money, frozen_money, total_money, cre_time, cre_person, upt_time, upt_person, del_flag
from t_finance_customer_assets
where assets_id = #{assetsId}
</select>
<insert id="updateAssets" parameterType="com.jz.dm.mall.moduls.entity.FinanceCustomerAssets">
update t_finance_customer_assets
<set>
<if test="departmentId != null">
department_id = #{departmentId},
</if>
<if test="useMoney != null">
use_money = #{useMoney},
</if>
<if test="totalMoney != null">
total_money = #{totalMoney},
</if>
<if test="uptTime != null">
upt_time = #{uptTime},
</if>
<if test="uptPerson != null and uptPerson != ''">
upt_person = #{uptPerson},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
</set>
where assets_id = #{assetsId}
</insert>
</mapper>
\ No newline at end of file
...@@ -29,5 +29,15 @@ public interface OrderDao extends BaseMapper<Order> { ...@@ -29,5 +29,15 @@ public interface OrderDao extends BaseMapper<Order> {
List<DataGoodsApiParamsDto> getApiParamsInfo(@Param("goodsApi") Long goodsApi); List<DataGoodsApiParamsDto> getApiParamsInfo(@Param("goodsApi") Long goodsApi);
/**
* 添加订单
* @param order
*/
void addOrder(Order order); void addOrder(Order order);
/**
* 跟新授权码和盐值
* @param order
*/
void updateTokenAndSalt(Order order);
} }
\ No newline at end of file
package com.jz.dm.mall.moduls.service;
import com.jz.dm.mall.moduls.entity.FinanceCustomerAssets;
import java.math.BigDecimal;
/**
* 商城企业客户资产(TFinanceCustomerAssets)表服务接口
*
* @author Bellamy
* @since 2020-12-01 10:41:38
*/
public interface FinanceCustomerAssetsService {
/**
* 查询余额是否充足
* @param id
*/
FinanceCustomerAssets findAssets(Long id, BigDecimal dataPrice);
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service.impl;
import com.jz.dm.mall.moduls.entity.FinanceCustomerAssets;
import com.jz.dm.mall.moduls.mapper.FinanceCustomerAssetsDao;
import com.jz.dm.mall.moduls.service.FinanceCustomerAssetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* 商城企业客户资产(TFinanceCustomerAssets)表服务实现类
*
* @author Bellamy
* @since 2020-12-01 10:41:38
*/
@Service("financeCustomerAssetsService")
public class FinanceCustomerAssetsServiceImpl implements FinanceCustomerAssetsService {
@Autowired
private FinanceCustomerAssetsDao assetsDao;
/**
* 查询余额是否充足
*
* @param id
*/
@Override
@Async
public FinanceCustomerAssets findAssets(Long id, BigDecimal dataPrice) {
FinanceCustomerAssets assets = assetsDao.findById(id);
if(assets.getUseMoney().compareTo(dataPrice) == -1){
new Thread(new Runnable() {
@Override
public void run() {
// 解冻
BigDecimal frozenMoney = assets.getFrozenMoney();
}
}).start();
}
return null;
}
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service.impl; package com.jz.dm.mall.moduls.service.impl;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.ResultMsg; import com.jz.common.constant.ResultMsg;
import com.jz.common.enums.auth.AuthModeEnum; import com.jz.common.enums.auth.AuthModeEnum;
import com.jz.common.enums.auth.AuthTypeEnum; import com.jz.common.enums.auth.AuthTypeEnum;
import com.jz.common.utils.DateUtils; import com.jz.common.utils.*;
import com.jz.common.utils.NumberUtils;
import com.jz.common.utils.RestTemplateUtils;
import com.jz.common.utils.Result;
import com.jz.dm.mall.moduls.controller.pay.dto.PayDto; import com.jz.dm.mall.moduls.controller.pay.dto.PayDto;
import com.jz.dm.mall.moduls.controller.pay.req.AuthMallUserApiReq; import com.jz.dm.mall.moduls.controller.pay.req.AuthMallUserApiReq;
...@@ -80,9 +79,10 @@ public class PayServiceImpl implements PayService { ...@@ -80,9 +79,10 @@ public class PayServiceImpl implements PayService {
order.setOrderTime(DateUtils.getToday()); order.setOrderTime(DateUtils.getToday());
order.setPaymentTime(order.getOrderTime()); order.setPaymentTime(order.getOrderTime());
order.setPaymentMethod("01"); order.setPaymentMethod("01");
// order.setSellerId(); // order.setSellerId(); // TODO 卖家id
// order.setDistrictMoney(); // order.setDistrictMoney(); //TODO 优惠金额
order.setTakeEffectTime(order.getOrderTime()); order.setTakeEffectTime(order.getOrderTime());
order.setApiKey(payDto.getApiKey());
//处理生效期 //处理生效期
Date time = getTime(payDto); Date time = getTime(payDto);
if (time != null) { if (time != null) {
...@@ -141,7 +141,7 @@ public class PayServiceImpl implements PayService { ...@@ -141,7 +141,7 @@ public class PayServiceImpl implements PayService {
apiReq.setApiKey(payDto.getApiKey()); apiReq.setApiKey(payDto.getApiKey());
apiReq.setAuthType(AuthTypeEnum.DATA_BANK_AUTH); apiReq.setAuthType(AuthTypeEnum.DATA_BANK_AUTH);
apiReq.setOrgCode("WAISJYX40E3e"); // TODO apiReq.setOrgCode("WAISJYX40E3e"); // TODO
apiReq.setOrgType("OUT"); apiReq.setOrgType("OUT"); // TODO
apiReq.setUserId(payDto.getCustomerId() + ""); apiReq.setUserId(payDto.getCustomerId() + "");
apiReq.setValidStartTime(order.getTakeEffectTime()); apiReq.setValidStartTime(order.getTakeEffectTime());
apiReq.setValidEndTime(order.getInvalidTime()); apiReq.setValidEndTime(order.getInvalidTime());
...@@ -157,6 +157,17 @@ public class PayServiceImpl implements PayService { ...@@ -157,6 +157,17 @@ public class PayServiceImpl implements PayService {
assets.setUptPerson(payDto.getCustomerId()+ ""); assets.setUptPerson(payDto.getCustomerId()+ "");
financeCustomerAssetsDao.updateAssets(assets); financeCustomerAssetsDao.updateAssets(assets);
// 获取到盐值和token,更新订单表
String data = params.getString("data");
JSONObject parse = JSONObject.parseObject(data);
String authCode = parse.getString("authCode");
String salt = parse.getString("salt");
order.setGoodsToken(authCode);
order.setSaltValue(salt);
order.setUptTime(DateUtils.getToday());
order.setUptPerson(payDto.getCustomerId() + "");
orderDao.updateTokenAndSalt(order);
// 新增记录表 // 新增记录表
Long assetsId = assets.getAssetsId(); Long assetsId = assets.getAssetsId();
if (assetsId!= null) { if (assetsId!= null) {
......
...@@ -219,15 +219,15 @@ ...@@ -219,15 +219,15 @@
</if> </if>
<if test="uptTime != null "> <if test="uptTime != null ">
ORDER BY ORDER BY
#{uptTime} desc t1.upt_time desc
</if> </if>
<if test="usePerson != null "> <if test="usePerson != null ">
ORDER BY ORDER BY
#{usePerson} desc t1.use_person desc
</if> </if>
<if test="synthesizeRank != null"> <if test="synthesizeRank != null">
ORDER BY ORDER BY
#{synthesizeRank} desc t1.upt_time,t1.use_person desc
</if> </if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -344,7 +344,7 @@ ...@@ -344,7 +344,7 @@
t3.request_example as requestExample, t3.request_example as requestExample,
t3.return_type as returnType, t3.return_type as returnType,
t3.api_key as apiKey, t3.api_key as apiKey,
t3.request_token as requestToken t.goods_token as goodsToken
from t_order t from t_order t
inner join t_order_goods_info t1 on t.order_id=t1.order_id inner join t_order_goods_info t1 on t.order_id=t1.order_id
inner join t_data_goods t2 on t2.data_goods_id=t1.data_goods_id <if test="dataGoodsId != null">and t2.data_goods_id = #{dataGoodsId}</if> inner join t_data_goods t2 on t2.data_goods_id=t1.data_goods_id <if test="dataGoodsId != null">and t2.data_goods_id = #{dataGoodsId}</if>
...@@ -380,6 +380,7 @@ ...@@ -380,6 +380,7 @@
order_time, order_time,
payment_money, payment_money,
payment_time, payment_time,
api_key,
payment_method, payment_method,
purchase_method, purchase_method,
take_effect_time, take_effect_time,
...@@ -389,6 +390,25 @@ ...@@ -389,6 +390,25 @@
cre_time cre_time
) )
VALUES VALUES
(#{orderNumber}, #{customerId}, #{orderStatus},#{orderMoney}, #{orderTime}, #{paymentMoney}, #{paymentTime}, #{paymentMethod}, #{purchaseMethod}, #{takeEffectTime} ,#{invalidTime}, #{priceType}, #{crePerson}, #{creTime}) (#{orderNumber}, #{customerId}, #{orderStatus},#{orderMoney}, #{orderTime}, #{paymentMoney}, #{paymentTime}, #{apiKey}, #{paymentMethod}, #{purchaseMethod}, #{takeEffectTime} ,#{invalidTime}, #{priceType}, #{crePerson}, #{creTime})
</insert> </insert>
<update id="updateTokenAndSalt" parameterType="com.jz.dm.mall.moduls.entity.Order">
update t_order
<set>
<if test="goodsToken != null and goodsToken != ''">
goods_token = #{goodsToken},
</if>
<if test="saltValue != null and saltValue != ''">
salt_value = #{saltValue},
</if>
<if test="uptTime != null">
upt_time = #{uptTime},
</if>
<if test="uptPerson != null and uptPerson != ''">
upt_person = #{uptPerson},
</if>
</set>
where order_id = #{orderId}
</update>
</mapper> </mapper>
\ No newline at end of file
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