| @@ -87,7 +87,6 @@ public class WxCreditHistoryController extends BaseController | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findById"); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCreditHistoryService.getById(id)); | |||
| } | |||
| } | |||
| @@ -71,7 +71,7 @@ public class WxCoupon implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,10.积分券,11积分停车券,100.消费卡)",name="type") | |||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51积分停车券,100.消费卡)",name="type") | |||
| private Integer type; | |||
| /**封面图**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") | |||
| @@ -51,7 +51,7 @@ public class WxCreditHistory implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") | |||
| private Integer creditNum; | |||
| /**积分类型*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="积分类型",name="creditType") | |||
| @io.swagger.annotations.ApiModelProperty(value="积分类型 1每日登录,2消费,3绑车牌,4连接WIFI,5微信用户昵称授权,6微信用户手机授权,7完善个人信息,8积分导入,10消费积分,11积分兑换",name="creditType") | |||
| private Integer creditType; | |||
| /**创建日期*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | |||
| @@ -77,6 +77,9 @@ public class WxCreditHistory implements Serializable { | |||
| /**花费*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="花费",name="spend") | |||
| private Integer spend; | |||
| /**兑换用途*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="兑换用途",name="changePurpose") | |||
| private String changePurpose; | |||
| @@ -24,6 +24,8 @@ import lombok.extern.slf4j.Slf4j; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| @Service | |||
| @Slf4j | |||
| @@ -129,6 +131,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(WxCreditHistory record) { | |||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(record.getCUserId()); | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(record.getCUserId()); | |||
| @@ -137,7 +140,14 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| //获取当前用户总积分 | |||
| int currentCreditAmount = wxCreditHistoryMapper.creditAmount(record.getCUserId()); | |||
| //int currentCreditAmount = wxCreditHistoryMapper.creditAmount(record.getCUserId()); | |||
| int currentCreditAmount = 0; | |||
| //获取当前用户总积分规则:优先获取wxCUserBasicInfo中数据 若不存在 再获取wxCUser表中数据 | |||
| if (wxCUserBasicInfo != null && wxCUserBasicInfo.getCredit() > 0) { | |||
| currentCreditAmount = wxCUserBasicInfo.getCredit(); | |||
| } else if (wxCUser != null && wxCUser.getCredit() > 0) { | |||
| currentCreditAmount = wxCUser.getCredit(); | |||
| } | |||
| //计算出需要新增或减少的积分 | |||
| int creditChangeNum = creditIncrement(record); | |||
| @@ -155,7 +165,14 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| record.setId(idWorker.nextId()); | |||
| wxCreditHistoryMapper.insertSelective(record); | |||
| //将计算出来新的总积分 更新到两张用户表里 | |||
| updateCredit(wxCUser,wxCUserBasicInfo,record.getCreditAmount()); | |||
| if (wxCUser != null) { | |||
| wxCUser.setCredit(record.getCreditAmount()); | |||
| wxCUserMapper.updateByPrimaryKeySelective(wxCUser); | |||
| } | |||
| if (wxCUserBasicInfo != null) { | |||
| wxCUserBasicInfo.setCredit(record.getCreditAmount()); | |||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(wxCUserBasicInfo); | |||
| } | |||
| } else { | |||
| //wxCreditHistoryMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @@ -327,20 +344,4 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| return addCreditNumber; | |||
| } | |||
| /** | |||
| * 更新两个表中的最新总积分 | |||
| * @param creditAmount 用户最新总积分 | |||
| */ | |||
| private void updateCredit(WxCUser wxCUser, WxCUserBasicInfo wxCUserBasicInfo, int creditAmount) { | |||
| if (wxCUser != null) { | |||
| wxCUser.setCredit(creditAmount); | |||
| wxCUserMapper.updateByPrimaryKeySelective(wxCUser); | |||
| } | |||
| if (wxCUserBasicInfo != null) { | |||
| wxCUserBasicInfo.setCredit(creditAmount); | |||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(wxCUserBasicInfo); | |||
| } | |||
| } | |||
| } | |||
| @@ -32,6 +32,8 @@ | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/> | |||
| <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/> | |||
| </resultMap> | |||
| <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | |||
| @@ -81,7 +83,7 @@ | |||
| `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, | |||
| `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, | |||
| `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type`, | |||
| `press_limit_num`, `press_limit_hours`, `auto_refund` | |||
| `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -207,6 +209,14 @@ | |||
| and `auto_refund` = #{autoRefund} | |||
| </if> | |||
| <if test=" null != creditPrice "> | |||
| and `credit_price` = #{creditPrice} | |||
| </if> | |||
| <if test=" null != creditRefund "> | |||
| and `credit_refund` = #{creditRefund} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -16,10 +16,11 @@ | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="business_id" jdbcType="BIGINT" property="businessId" /> | |||
| <result column="spend" jdbcType="INTEGER" property="spend" /> | |||
| <result column="change_purpose" jdbcType="VARCHAR" property="changePurpose" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`credate_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend` | |||
| `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`credate_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -60,6 +61,9 @@ | |||
| <if test=" null != spend "> | |||
| and `spend` = #{spend} | |||
| </if> | |||
| <if test=" null != changePurpose "> | |||
| and `change_purpose` = #{changePurpose} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||