| | |
| | | private Long id; |
| | | |
| | | @Column(name = "ac_provider_id") |
| | | private String providerId; |
| | | private Long providerId; |
| | | |
| | | @Column(name = "ac_account_name") |
| | | private String accountName; |
| | |
| | | private String appKey; |
| | | |
| | | @Column(name = "ac_app_secret") |
| | | private Integer appSecret; |
| | | private String appSecret; |
| | | |
| | | @Column(name = "ac_max_money") |
| | | private BigDecimal maxMoney; |
| | |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getProviderId() { |
| | | public Long getProviderId() { |
| | | return providerId; |
| | | } |
| | | |
| | | public void setProviderId(String providerId) { |
| | | public void setProviderId(Long providerId) { |
| | | this.providerId = providerId; |
| | | } |
| | | |
| | |
| | | this.appKey = appKey; |
| | | } |
| | | |
| | | public Integer getAppSecret() { |
| | | public String getAppSecret() { |
| | | return appSecret; |
| | | } |
| | | |
| | | public void setAppSecret(Integer appSecret) { |
| | | public void setAppSecret(String appSecret) { |
| | | this.appSecret = appSecret; |
| | | } |
| | | |
| | |
| | | private String title; |
| | | |
| | | @Column(name = "ne_content") |
| | | private Integer content; |
| | | private String content; |
| | | |
| | | @Column(name = "ne_type") |
| | | private String type; |
| | |
| | | this.title = title; |
| | | } |
| | | |
| | | public Integer getContent() { |
| | | public String getContent() { |
| | | return content; |
| | | } |
| | | |
| | | public void setContent(Integer content) { |
| | | public void setContent(String content) { |
| | | this.content = content; |
| | | } |
| | | |
| | |
| | | |
| | | public class LiJinCreateParam { |
| | | |
| | | String appkey; |
| | | String appsecret; |
| | | |
| | | private String pid; |
| | | |
| | | // 用户id |
| | | private String uid; |
| | | // 商品id |
| | |
| | | private Date sendEndTime; |
| | | private Date useStartTime; |
| | | private Date useEndTime; |
| | | private String pid; |
| | | |
| | | |
| | | public String getAppkey() { |
| | | return appkey; |
| | | } |
| | | |
| | | public void setAppkey(String appkey) { |
| | | this.appkey = appkey; |
| | | } |
| | | |
| | | public String getAppsecret() { |
| | | return appsecret; |
| | | } |
| | | |
| | | public void setAppsecret(String appsecret) { |
| | | this.appsecret = appsecret; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
New file |
| | |
| | | package com.ks.lijin.pojo.Enums; |
| | | |
| | | public enum NoticeTypeEnum { |
| | | |
| | | noMoney("金额不足"), |
| | | normal("正常"); |
| | | |
| | | private final String desc; |
| | | |
| | | private NoticeTypeEnum(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | } |
| | |
| | | |
| | | public void delete(Long id); |
| | | |
| | | public LiJinExpendRecord createLiJin(Long uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | public LiJinExpendRecord createLiJin(String uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | throws LiJinExpendRecordException; |
| | | |
| | | /** |
| | | * 统计今日已使用次数 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public int countTodayNumByExpend(String uid); |
| | | |
| | | |
| | | /** |
| | | * 统计今日已使用金额 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public BigDecimal countTodayMoneyByExpend(String uid); |
| | | |
| | | } |
| | |
| | | public void updateByPrimaryKeySelective(LiJinProviderAccount provider); |
| | | |
| | | public void delete(Long id); |
| | | |
| | | public LiJinProviderAccount getByAppInfo(String appKey, String appSecret); |
| | | |
| | | } |
| | |
| | | import com.ks.lijin.query.ExpendRecordQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | public interface LiJinExpendRecordMapper extends BaseMapper<LiJinExpendRecord> { |
| | |
| | | List<LiJinExpendRecord> listByPage(@Param("query") ExpendRecordQuery query); |
| | | |
| | | long count(@Param("query")ExpendRecordQuery query); |
| | | |
| | | |
| | | /** |
| | | * 统计今日已使用次数 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | int countTodayNumByExpend(@Param("uid")String uid); |
| | | |
| | | |
| | | /** |
| | | * 统计今日已使用金额 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | BigDecimal countTodayMoneyByExpend(@Param("uid")String uid); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | //状态 |
| | | public Long id; |
| | | |
| | | //状态 |
| | | public Integer state; |
| | | |
| | | // 名称 |
| | | public String name; |
| | | |
| | | public String appKey; |
| | | public String appSecret; |
| | | } |
| | |
| | | import com.ks.lijin.exception.TaoKeApiException; |
| | | import com.ks.lijin.mapper.LiJinExpendRecordMapper; |
| | | import com.ks.lijin.pojo.DO.LiJinExpendRecord; |
| | | import com.ks.lijin.pojo.DO.LiJinProviderAccount; |
| | | import com.ks.lijin.pojo.DO.LiJinProviderNotice; |
| | | import com.ks.lijin.pojo.DTO.LiJinCreateParam; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoBaoGoodsBrief; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoLiJinDTO; |
| | | import com.ks.lijin.pojo.Enums.NoticeTypeEnum; |
| | | import com.ks.lijin.query.ExpendRecordQuery; |
| | | import com.ks.lijin.service.LiJinExpendRecordService; |
| | | import com.ks.lijin.service.LiJinProviderAccountService; |
| | | import com.ks.lijin.service.LiJinProviderNoticeService; |
| | | import com.ks.lijin.utils.taobao.TaoKeApiUtil; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.core.task.TaskExecutor; |
| | |
| | | @Resource |
| | | private LiJinExpendRecordMapper liJinExpendRecordMapper; |
| | | |
| | | @Resource |
| | | private LiJinProviderNoticeService liJinProviderNoticeService; |
| | | |
| | | @Resource |
| | | private LiJinProviderAccountService liJinProviderAccountService; |
| | | |
| | | @Override |
| | | public long count(LiJinExpendRecord obj) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public LiJinExpendRecord createLiJin(Long uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | public LiJinExpendRecord createLiJin(String uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | throws LiJinExpendRecordException { |
| | | |
| | | // TODO 验证次数 |
| | | int expendNum = countTodayNumByExpend(uid); |
| | | // TODO 验证金额 |
| | | BigDecimal bigDecimal = countTodayMoneyByExpend(uid); |
| | | |
| | | |
| | | Date date = new Date(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | params.setSendEndTime(sendEndTime); |
| | | params.setNum(1); |
| | | params.setMoney(money); |
| | | |
| | | // params.setPid(); // pid缺少 TODO |
| | | // params.setAppkey(); |
| | | // params.setAppsecret(); |
| | | |
| | | return createTaoLiJin(params); |
| | | } |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public LiJinExpendRecord createTaoLiJin(LiJinCreateParam params) throws LiJinExpendRecordException { |
| | | |
| | | String appkey = ""; |
| | | String appsecret = ""; |
| | | |
| | | // 总金额 |
| | | //BigDecimal totalMoney = BigDecimalUtil.mul(params.getMoney(), new BigDecimal(params.getNum())); |
| | | String appkey =params.getAppkey(); |
| | | String appsecret = params.getAppsecret(); |
| | | |
| | | // 创建淘礼金红包 |
| | | TaoLiJinDTO taoLiJinDTO = null; |
| | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | LiJinProviderAccount account = liJinProviderAccountService.getByAppInfo(appkey, appsecret); |
| | | if (account == null) { |
| | | return; |
| | | } |
| | | |
| | | LiJinProviderNotice notice = new LiJinProviderNotice(); |
| | | notice.setRead(false); |
| | | notice.setProviderId(account.getProviderId()); |
| | | |
| | | if (e.getCode() == LiJinException.CODE_TLJ_FORBIDDEN) { |
| | | // 该商品不支持创建淘礼金红包 |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_NO_MONEY) { |
| | | // 官方玩法钱包余额不足 |
| | | notice.setTitle("玩法钱包余额不足"); |
| | | notice.setContent("账号:"+ appkey +"官方玩法钱包余额不足"); |
| | | notice.setType(NoticeTypeEnum.noMoney.name()); |
| | | liJinProviderNoticeService.save(notice); |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_UN_PAID) { |
| | | // 未创建账户 |
| | | } |
| | |
| | | record.setCreateTime(new Date()); |
| | | liJinExpendRecordMapper.insertSelective(record); |
| | | |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 更新对应 限制次数和金额 |
| | | } |
| | | }); |
| | | return record; |
| | | } |
| | | |
| | | @Override |
| | | public int countTodayNumByExpend(String uid) { |
| | | return liJinExpendRecordMapper.countTodayNumByExpend(uid); |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal countTodayMoneyByExpend(String uid) { |
| | | return liJinExpendRecordMapper.countTodayMoneyByExpend(uid); |
| | | } |
| | | |
| | | } |
| | |
| | | @Override |
| | | public long count(LiJinProviderAccount obj) { |
| | | ProviderAccountQuery query = new ProviderAccountQuery(); |
| | | // query.appId = appId; |
| | | // query.uid = uid; |
| | | query.id = obj.getId(); |
| | | query.state = obj.getState(); |
| | | query.appKey = obj.getAppKey(); |
| | | query.appSecret = obj.getAppSecret(); |
| | | return liJinProviderAccountMapper.count(query); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<LiJinProviderAccount> listByPage(int page, int pageSize, LiJinProviderAccount obj) { |
| | | ProviderAccountQuery query = new ProviderAccountQuery(); |
| | | // query.appId = appId; |
| | | // query.uid = uid; |
| | | // query.drawStateList = Arrays.asList(new Integer[]{LuckyActivityJoinRecord.DRAW_STATE_UNOPEN}); |
| | | query.id = obj.getId(); |
| | | query.state = obj.getState(); |
| | | query.appKey = obj.getAppKey(); |
| | | query.appSecret = obj.getAppSecret(); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return liJinProviderAccountMapper.listByPage(query); |
| | |
| | | public void delete(Long id) { |
| | | liJinProviderAccountMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | |
| | | |
| | | public LiJinProviderAccount getByAppInfo(String appKey, String appSecret){ |
| | | LiJinProviderAccount obj = new LiJinProviderAccount(); |
| | | obj.setAppKey(appKey); |
| | | obj.setAppSecret(appSecret); |
| | | obj.setState(1); |
| | | List<LiJinProviderAccount> list = listByPage(0, 100, obj); |
| | | if (list ==null && list.size() == 0) { |
| | | return null; |
| | | } |
| | | return list.get(0); |
| | | } |
| | | } |
| | |
| | | </select> |
| | | |
| | | <select id="count" resultType="java.lang.Long"> |
| | | select count(*) from tlj_expend_record |
| | | select IFNULL(count(*),0) from tlj_expend_record |
| | | where 1=1 |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | |
| | | <select id="countTodayNumByExpend" resultType="Integer"> |
| | | select IFNULL(count(*),0) from tlj_expend_record |
| | | where rd_uid=#{uid} and date(rd_create_time) = curdate(); |
| | | </select> |
| | | |
| | | <select id="countTodayMoneyByExpend" resultType="BigDecimal"> |
| | | select IFNULL(SUM(rd_money),0) from tlj_expend_record |
| | | where rd_uid=#{uid} and date(rd_create_time) = curdate(); |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <mapper namespace="com.ks.lijin.mapper.LiJinProviderAccountMapper"> |
| | | <resultMap id="BaseResultMap" type="com.ks.lijin.pojo.DO.LiJinProviderAccount"> |
| | | <id column="ac_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="ac_provider_id" property="providerId" jdbcType="VARCHAR"/> |
| | | <result column="ac_provider_id" property="providerId" jdbcType="BIGINT"/> |
| | | <result column="ac_account_name" property="accountName" jdbcType="VARCHAR"/> |
| | | <result column="ac_app_key" property="appKey" jdbcType="VARCHAR"/> |
| | | <result column="ac_app_secret" property="appSecret" jdbcType="INTEGER"/> |
| | | <result column="ac_app_secret" property="appSecret" jdbcType="VARCHAR"/> |
| | | <result column="ac_max_money" property="maxMoney" jdbcType="DECIMAL"/> |
| | | <result column="ac_max_number" property="maxNumber" jdbcType="INTEGER"/> |
| | | <result column="ac_today_consume_money" property="todayConsumeMoney" jdbcType="DECIMAL"/> |
| | |
| | | <include refid="Base_Column_List"/>from tlj_provider_account where ac_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from tlj_provider_account where ac_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount" useGeneratedKeys="true" keyProperty="id">insert into tlj_provider_account (ac_id, ac_provider_id, ac_account_name, ac_app_key, ac_app_secret, ac_max_money, ac_max_number, ac_today_consume_money, ac_today_consume_number, ac_state, ac_creator_id, ac_create_time, ac_updator_id, ac_update_time)values (#{id,jdbcType=BIGINT}, #{providerId,jdbcType=VARCHAR}, #{accountName,jdbcType=VARCHAR}, #{appKey,jdbcType=VARCHAR}, #{appSecret,jdbcType=INTEGER}, #{maxMoney,jdbcType=DECIMAL}, #{maxNumber,jdbcType=INTEGER}, #{todayConsumeMoney,jdbcType=DECIMAL}, #{todayConsumeNumber,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updatorId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount" useGeneratedKeys="true" keyProperty="id">insert into tlj_provider_account (ac_id, ac_provider_id, ac_account_name, ac_app_key, ac_app_secret, ac_max_money, ac_max_number, ac_today_consume_money, ac_today_consume_number, ac_state, ac_creator_id, ac_create_time, ac_updator_id, ac_update_time)values (#{id,jdbcType=BIGINT}, #{providerId,jdbcType=BIGINT}, #{accountName,jdbcType=VARCHAR}, #{appKey,jdbcType=VARCHAR}, #{appSecret,jdbcType=VARCHAR}, #{maxMoney,jdbcType=DECIMAL}, #{maxNumber,jdbcType=INTEGER}, #{todayConsumeMoney,jdbcType=DECIMAL}, #{todayConsumeNumber,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updatorId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount" useGeneratedKeys="true" keyProperty="id">insert into tlj_provider_account |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ac_id,</if> |
| | |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="providerId != null">#{providerId,jdbcType=VARCHAR},</if> |
| | | <if test="providerId != null">#{providerId,jdbcType=BIGINT},</if> |
| | | <if test="accountName != null">#{accountName,jdbcType=VARCHAR},</if> |
| | | <if test="appKey != null">#{appKey,jdbcType=VARCHAR},</if> |
| | | <if test="appSecret != null">#{appSecret,jdbcType=INTEGER},</if> |
| | | <if test="appSecret != null">#{appSecret,jdbcType=VARCHAR},</if> |
| | | <if test="maxMoney != null">#{maxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="maxNumber != null">#{maxNumber,jdbcType=INTEGER},</if> |
| | | <if test="todayConsumeMoney != null">#{todayConsumeMoney,jdbcType=DECIMAL},</if> |
| | |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount">update tlj_provider_account set ac_provider_id = #{providerId,jdbcType=VARCHAR},ac_account_name = #{accountName,jdbcType=VARCHAR},ac_app_key = #{appKey,jdbcType=VARCHAR},ac_app_secret = #{appSecret,jdbcType=INTEGER},ac_max_money = #{maxMoney,jdbcType=DECIMAL},ac_max_number = #{maxNumber,jdbcType=INTEGER},ac_today_consume_money = #{todayConsumeMoney,jdbcType=DECIMAL},ac_today_consume_number = #{todayConsumeNumber,jdbcType=INTEGER},ac_state = #{state,jdbcType=INTEGER},ac_creator_id = #{creatorId,jdbcType=BIGINT},ac_create_time = #{createTime,jdbcType=TIMESTAMP},ac_updator_id = #{updatorId,jdbcType=BIGINT},ac_update_time = #{updateTime,jdbcType=TIMESTAMP}where ac_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount">update tlj_provider_account set ac_provider_id = #{providerId,jdbcType=BIGINT},ac_account_name = #{accountName,jdbcType=VARCHAR},ac_app_key = #{appKey,jdbcType=VARCHAR},ac_app_secret = #{appSecret,jdbcType=VARCHAR},ac_max_money = #{maxMoney,jdbcType=DECIMAL},ac_max_number = #{maxNumber,jdbcType=INTEGER},ac_today_consume_money = #{todayConsumeMoney,jdbcType=DECIMAL},ac_today_consume_number = #{todayConsumeNumber,jdbcType=INTEGER},ac_state = #{state,jdbcType=INTEGER},ac_creator_id = #{creatorId,jdbcType=BIGINT},ac_create_time = #{createTime,jdbcType=TIMESTAMP},ac_updator_id = #{updatorId,jdbcType=BIGINT},ac_update_time = #{updateTime,jdbcType=TIMESTAMP}where ac_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.lijin.pojo.DO.LiJinProviderAccount">update tlj_provider_account |
| | | <set> |
| | | <if test="providerId != null">ac_provider_id=#{providerId,jdbcType=VARCHAR},</if> |
| | | <if test="providerId != null">ac_provider_id=#{providerId,jdbcType=BIGINT},</if> |
| | | <if test="accountName != null">ac_account_name=#{accountName,jdbcType=VARCHAR},</if> |
| | | <if test="appKey != null">ac_app_key=#{appKey,jdbcType=VARCHAR},</if> |
| | | <if test="appSecret != null">ac_app_secret=#{appSecret,jdbcType=INTEGER},</if> |
| | | <if test="appSecret != null">ac_app_secret=#{appSecret,jdbcType=VARCHAR},</if> |
| | | <if test="maxMoney != null">ac_max_money=#{maxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="maxNumber != null">ac_max_number=#{maxNumber,jdbcType=INTEGER},</if> |
| | | <if test="todayConsumeMoney != null">ac_today_consume_money=#{todayConsumeMoney,jdbcType=DECIMAL},</if> |
| | |
| | | <if test="query.id!=null">and ac_id=#{query.id}</if> |
| | | <if test="query.name!=null">and ac_account_name=#{query.name}</if> |
| | | <if test="query.state!=null">and ac_state=#{query.state}</if> |
| | | <if test="query.appKey!=null">and ac_app_key=#{query.appKey}</if> |
| | | <if test="query.appSecret!=null">and ac_app_secret=#{query.appSecret}</if> |
| | | </sql> |
| | | |
| | | |