Commit 2b11c924 by zhiwj

短信修改流程

parent 6a5aadfe
......@@ -111,6 +111,16 @@ public class TabBillingSmsRecord {
*/
private String storeGroupName;
/**
* 缓存更新成功标志 1:成功
*/
private Integer cacheStatus;
/**
* 数据库更新成功标志 1:成功
*/
private Integer databaseStatus;
public Integer getSmsRecordId() {
return smsRecordId;
}
......@@ -278,4 +288,20 @@ public class TabBillingSmsRecord {
public void setStoreGroupName(String storeGroupName) {
this.storeGroupName = storeGroupName;
}
public Integer getCacheStatus() {
return cacheStatus;
}
public void setCacheStatus(Integer cacheStatus) {
this.cacheStatus = cacheStatus;
}
public Integer getDatabaseStatus() {
return databaseStatus;
}
public void setDatabaseStatus(Integer databaseStatus) {
this.databaseStatus = databaseStatus;
}
}
\ No newline at end of file
......@@ -48,4 +48,7 @@ public interface BillingSmsRecordService {
Integer saveSmsRecord(SmsRecordDTO smsRecordDTO);
void updateCacheStatus(Integer smsRecordId);
void updateDatabaseStatus(Integer smsRecordId);
}
......@@ -63,6 +63,23 @@ public class BillingSmsRecordServiceImpl implements BillingSmsRecordService{
TabBillingSmsRecord billingSmsRecord = EntityUtil.changeEntityByJSON(TabBillingSmsRecord.class, smsRecordDTO);
billingSmsRecord.setStatus(GlobalInfo.DATA_STATUS_NORMAL);
billingSmsRecord.setCreateTime(new Date());
return tabBillingSmsRecordMapper.insertSelective(billingSmsRecord);
tabBillingSmsRecordMapper.insertSelective(billingSmsRecord);
return billingSmsRecord.getSmsRecordId();
}
@Override
public void updateCacheStatus(Integer smsRecordId) {
TabBillingSmsRecord smsRecord = new TabBillingSmsRecord();
smsRecord.setSmsRecordId(smsRecordId);
smsRecord.setCacheStatus(1);
tabBillingSmsRecordMapper.updateByPrimaryKeySelective(smsRecord);
}
@Override
public void updateDatabaseStatus(Integer smsRecordId) {
TabBillingSmsRecord smsRecord = new TabBillingSmsRecord();
smsRecord.setSmsRecordId(smsRecordId);
smsRecord.setDatabaseStatus(1);
tabBillingSmsRecordMapper.updateByPrimaryKeySelective(smsRecord);
}
}
......@@ -67,6 +67,10 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
try {
logger.info("国内短信缓存扣费:{}", arg);
SmsRecordDTO smsRecordDTO = JSON.parseObject(arg, SmsRecordDTO.class);
smsRecordDTO.setCacheStatus(0);
smsRecordDTO.setDatabaseStatus(0);
Integer smsRecordId = billingSmsRecordService.saveSmsRecord(smsRecordDTO);
smsRecordDTO.setSmsRecordId(smsRecordId);
// 判断是扣套餐包还是扣余额
RedissonClient redisClient = RedisUtil.getRedisClient();
RAtomicLong smsCount = redisClient.getAtomicLong(Constants.ENTERPRISE_BILLING_SMS_PACKAGE_COUNT + smsRecordDTO.getEnterpriseId());
......@@ -75,8 +79,9 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
int deductType = deduct(smsCount, smsRecordDTO.getEnterpriseId());
smsRecordDTO.setDeductType(deductType);
// todo 队列
// 队列
client.sendMessage("smsDbMq", JSON.toJSONString(smsRecordDTO));
billingSmsRecordService.updateCacheStatus(smsRecordDTO.getSmsRecordId());
// this.executeDatabase(JSON.toJSONString(smsRecordDTO));
} catch (Exception e) {
logger.warn("调用mq失败", e);
......@@ -128,7 +133,7 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
Integer unitFee = accountStandardService.queryUnitFee(smsRecordDTO.getEnterpriseId(), AccountStandardEnum.SMS.getCode());
billingAccountService.deductAccountByDatabase(unitFee.doubleValue() / 1000, smsRecordDTO.getEnterpriseId());
}
billingSmsRecordService.saveSmsRecord(smsRecordDTO);
billingSmsRecordService.updateDatabaseStatus(smsRecordDTO.getSmsRecordId());
return ServiceResponse.success();
}
}
......@@ -23,11 +23,14 @@
<result column="store_name" jdbcType="VARCHAR" property="storeName" />
<result column="store_group_id" jdbcType="INTEGER" property="storeGroupId" />
<result column="store_group_name" jdbcType="VARCHAR" property="storeGroupName" />
<result column="cache_status" jdbcType="INTEGER" property="cacheStatus" />
<result column="database_status" jdbcType="INTEGER" property="databaseStatus" />
</resultMap>
<sql id="Base_Column_List">
sms_record_id, status, send_time, receive_phone, pay_type, app_code, app_name, sms_type,
bill_number, fee, sms_content, create_time, update_time, deduction_time, enterprise_id,
enterprise_sms_package_id, member_name, store_id, store_name, store_group_id, store_group_name
enterprise_sms_package_id, member_name, store_id, store_name, store_group_id, store_group_name,
cache_status, database_status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
......@@ -46,18 +49,21 @@
fee, sms_content, create_time,
update_time, deduction_time, enterprise_id,
enterprise_sms_package_id, member_name, store_id,
store_name, store_group_id, store_group_name
)
store_name, store_group_id, store_group_name,
cache_status, database_status)
values (#{smsRecordId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP},
#{receivePhone,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, #{appCode,jdbcType=VARCHAR},
#{appName,jdbcType=VARCHAR}, #{smsType,jdbcType=INTEGER}, #{billNumber,jdbcType=INTEGER},
#{fee,jdbcType=DOUBLE}, #{smsContent,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deductionTime,jdbcType=TIMESTAMP}, #{enterpriseId,jdbcType=INTEGER},
#{enterpriseSmsPackageId,jdbcType=INTEGER}, #{memberName,jdbcType=VARCHAR}, #{storeId,jdbcType=INTEGER},
#{storeName,jdbcType=VARCHAR}, #{storeGroupId,jdbcType=INTEGER}, #{storeGroupName,jdbcType=VARCHAR}
)
#{storeName,jdbcType=VARCHAR}, #{storeGroupId,jdbcType=INTEGER}, #{storeGroupName,jdbcType=VARCHAR},
#{cacheStatus,jdbcType=INTEGER}, #{databaseStatus,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabBillingSmsRecord">
<selectKey keyProperty="smsRecordId" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into tab_billing_sms_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="smsRecordId != null">
......@@ -123,6 +129,12 @@
<if test="storeGroupName != null">
store_group_name,
</if>
<if test="cacheStatus != null">
cache_status,
</if>
<if test="databaseStatus != null">
database_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="smsRecordId != null">
......@@ -188,6 +200,12 @@
<if test="storeGroupName != null">
#{storeGroupName,jdbcType=VARCHAR},
</if>
<if test="cacheStatus != null">
#{cacheStatus,jdbcType=INTEGER},
</if>
<if test="databaseStatus != null">
#{databaseStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.enterprise.entity.TabBillingSmsRecord">
......@@ -253,6 +271,12 @@
<if test="storeGroupName != null">
store_group_name = #{storeGroupName,jdbcType=VARCHAR},
</if>
<if test="cacheStatus != null">
cache_status = #{cacheStatus,jdbcType=INTEGER},
</if>
<if test="databaseStatus != null">
database_status = #{databaseStatus,jdbcType=INTEGER},
</if>
</set>
where sms_record_id = #{smsRecordId,jdbcType=INTEGER}
</update>
......@@ -277,7 +301,9 @@
store_id = #{storeId,jdbcType=INTEGER},
store_name = #{storeName,jdbcType=VARCHAR},
store_group_id = #{storeGroupId,jdbcType=INTEGER},
store_group_name = #{storeGroupName,jdbcType=VARCHAR}
store_group_name = #{storeGroupName,jdbcType=VARCHAR},
cache_status = #{cacheStatus,jdbcType=INTEGER},
database_status = #{databaseStatus,jdbcType=INTEGER}
where sms_record_id = #{smsRecordId,jdbcType=INTEGER}
</update>
<select id="listHomeStatistics" parameterType="com.gic.enterprise.qo.HomeStatisticsQO" resultType="com.gic.enterprise.dto.HomeStatisticsDTO">
......@@ -286,6 +312,8 @@
ifnull(sum(fee), 0) fee
from tab_billing_sms_record
where status = 1
and cache_status = 1
and database_status = 1
and enterprise_id = #{enterpriseId}
<if test="startTime != null">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &gt;= #{startTime}
......@@ -301,6 +329,8 @@
ifnull(sum(fee), 0)
from tab_billing_sms_record
where status = 1
and cache_status = 1
and database_status = 1
and enterprise_id = #{enterpriseId}
<if test="dateType == 1 ">
and date_format(deduction_time,'%Y-%m') = date_format(now(),'%Y-%m')
......@@ -314,6 +344,8 @@
ifnull(sum(fee), 0)
from tab_billing_sms_record
where status = 1
and cache_status = 1
and database_status = 1
and enterprise_id = #{enterpriseId}
<if test="startTime != null and startTime != '' ">
and DATE_FORMAT(deduction_time,'%Y-%m-%d') &gt;= #{startTime}
......@@ -327,6 +359,8 @@
<include refid="Base_Column_List" />
from tab_billing_sms_record
where status = 1
and cache_status = 1
and database_status = 1
and enterprise_sms_package_id=#{smsPackageId}
<if test="search != null ">
and sms_content like concat('%',#{search}, '%')
......@@ -344,6 +378,8 @@
<include refid="Base_Column_List" />
from tab_billing_sms_record
<where>
and cache_status = 1
and database_status = 1
<if test="enterpriseId != null ">
and enterprise_id = #{enterpriseId}
</if>
......@@ -370,6 +406,8 @@
count(*)
from tab_billing_sms_record
<where>
and cache_status = 1
and database_status = 1
<if test="enterpriseId != null ">
and enterprise_id = #{enterpriseId}
</if>
......
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