lin 2 lat temu
rodzic
commit
a472198a28
12 zmienionych plików z 67 dodań i 20 usunięć
  1. +9
    -3
      mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java
  2. +4
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java
  3. +4
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java
  5. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxAppinfoService.java
  6. +5
    -5
      mallinkService/src/main/java/com/iformall/service/cache/WxAppInfoCache.java
  7. +5
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java
  8. +23
    -3
      mallinkService/src/main/java/com/iformall/service/wx/WxPayServiceImpl.java
  9. +1
    -0
      mallinkService/src/main/java/com/iformall/utils/SysConfigConstant.java
  10. +1
    -1
      mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml
  11. +8
    -1
      mallinkService/src/main/resources/mapper/WxCUserMapper.xml
  12. +3
    -1
      mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml

+ 9
- 3
mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java Wyświetl plik

@@ -55,6 +55,9 @@ public class WxUserGrantController extends BaseController {
@Autowired
WxCUserService wxCUserService;
@Autowired
SysConfigService sysConfigService;


/**
@@ -96,20 +99,23 @@ public class WxUserGrantController extends BaseController {
@AuthIgnore
@TenantIgnore
@PostMapping("/login")
@ApiOperation(value = "用户登录", notes = "{\"code\":\"string\"}")
@ApiOperation(value = "用户登录", notes = "{\"appId\":\"string\",\"code\":\"string\"}")
public ResultData userLogin(@RequestBody Map<String, String> map) {
Map resultMap = new HashMap();
String code = map.get("code");
String appId = map.get("appId");
if (StringUtils.isBlank(code)) {
return new ResultData(ErrorCode.PARAM_EMPITY.getCode(), "code不能为空");
}
if (StringUtils.isBlank(appId)) {
return new ResultData(ErrorCode.PARAM_EMPITY.getCode(), "appId不能为空");
}
String session_key = null;
String openId = null;
String unionId = null;

try {
TenantEntity tenantEntity = this.getTenantInfo();
WxAppinfo wxAppinfo = wxAppinfoServie.getCAppInfoFromRedis(tenantEntity.getTenantId());
WxAppinfo wxAppinfo = wxAppinfoServie.getCAppInfoFromRedis(appId);
WxMaJscode2SessionResult session = wxWeappService.jsCode2SessionInfo(code, wxAppinfo, false);
logger.info("sessionResult: " + session);
if (null != session) {


+ 4
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java Wyświetl plik

@@ -26,4 +26,8 @@ public class WxCUser extends TenantEntity {
private Date updateDate;
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="生效开始时间",name="validStartTime")
private Date validStartTime;
@io.swagger.annotations.ApiModelProperty(value="生效结束时间",name="validEndTime")
private Date validEndTime;
}

+ 4
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java Wyświetl plik

@@ -45,6 +45,10 @@ public class WxPayOrder extends TenantEntity {
private Date payTime;
@io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId")
private String transactionId;
@io.swagger.annotations.ApiModelProperty(value="生效开始时间",name="validStartTime")
private Date validStartTime;
@io.swagger.annotations.ApiModelProperty(value="生效结束时间",name="validEndTime")
private Date validEndTime;
@TableField(exist = false)


+ 3
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java Wyświetl plik

@@ -1,5 +1,6 @@
package com.iformall.mapper;

import java.util.Date;
import java.util.List;

import com.iformall.common.CommonMapper;
@@ -16,4 +17,6 @@ public interface WxCUserMapper extends CommonMapper<WxCUser, Long> {

WxCUser selectById(@Param("id")Long id,@Param("tenantId")String tenantId);
void updateValidTime(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("validBeginTime")Date validBeginTime,@Param("validEndTime")Date validEndTime);
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxAppinfoService.java Wyświetl plik

@@ -18,6 +18,6 @@ public interface WxAppinfoService {
*/
void saveOrUpdate(WxAppinfo record);

WxAppinfo getCAppInfoFromRedis(String tenantId);
WxAppinfo getCAppInfoFromRedis(String appId);

}

+ 5
- 5
mallinkService/src/main/java/com/iformall/service/cache/WxAppInfoCache.java Wyświetl plik

@@ -15,18 +15,18 @@ public class WxAppInfoCache {
return key;
}
public static WxAppinfo getCacheAppInfo(RedisTemplate<String, Object> wxAppinfoRedisTemplate,String tenantId) {
String key = getKey(tenantId);
public static WxAppinfo getCacheAppInfo(RedisTemplate<String, Object> wxAppinfoRedisTemplate,String appId) {
String key = getKey(appId);
return RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class);
}
public static void cacheApp(RedisTemplate<String, Object> wxAppinfoRedisTemplate,WxAppinfo appInfo) {
String key = getKey(appInfo.getTenantId());
String key = getKey(appInfo.getAppId());
RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, appInfo, 3600*24*7);
}
public static void removeCache(RedisTemplate<String, Object> wxAppinfoRedisTemplate,String tenantId) {
String key = getKey(tenantId);
public static void removeCache(RedisTemplate<String, Object> wxAppinfoRedisTemplate,String appId) {
String key = getKey(appId);
RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key);
}
}

+ 5
- 5
mallinkService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java Wyświetl plik

@@ -54,16 +54,16 @@ public class WxAppinfoServiceImpl implements WxAppinfoService {
}

@Override
public WxAppinfo getCAppInfoFromRedis(String tenantId) {
WxAppinfo record = WxAppInfoCache.getCacheAppInfo(wxAppinfoRedisTemplate, tenantId);
public WxAppinfo getCAppInfoFromRedis(String appId) {
WxAppinfo record = WxAppInfoCache.getCacheAppInfo(wxAppinfoRedisTemplate, appId);
if (null == record) {
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(tenantId);
record = this.getCAppInfo(tenantEntity);
record = wxAppinfoMapper.findByAppId(appId);
if(record != null){
WxAppInfoCache.cacheApp(wxAppinfoRedisTemplate, record);
}
}
return record;
}
}

+ 23
- 3
mallinkService/src/main/java/com/iformall/service/wx/WxPayServiceImpl.java Wyświetl plik

@@ -6,18 +6,22 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.domain.entity.PayAdapterResult;
import com.iformall.domain.po.SysConfig;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxAppinfoMapper;
import com.iformall.mapper.WxCUserMapper;
import com.iformall.mapper.WxPayOrderMapper;
import com.iformall.mapper.WxPayAccountMapper;
import com.iformall.service.SysConfigService;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxPayAccountService;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;
import com.iformall.utils.SysConfigConstant;
import com.iformall.utils.XmlUtil;
import java.util.Date;
import java.util.Map;
@@ -29,6 +33,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class WxPayServiceImpl implements WxPayService {
@@ -58,6 +64,13 @@ public class WxPayServiceImpl implements WxPayService {
@Autowired
WxPayAccountService wxPayAccountService;
@Lazy
@Autowired
SysConfigService sysConfigService;
@Autowired
WxCUserMapper wxCUserMapper;
@Override
public PageInfo<WxPayOrder> listPayOrderAsPage(WxPayOrder record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPayOrderMapper.findList(record));
@@ -132,6 +145,7 @@ public class WxPayServiceImpl implements WxPayService {
}
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public void handlePaidSuccess(String tenantId,Long orderId,Long cUserId,Integer fee,Date paidTime,String transcationId,
String userPhone) throws Exception{
@@ -151,17 +165,23 @@ public class WxPayServiceImpl implements WxPayService {
Long id = idworker.nextId();
payOrder.setId(id);
payOrder.setTenantId(tenantId);
payOrder.setCreateTime(new Date());
payOrder.setUpdateTime(new Date());
payOrder.setcUserId(cUserId);
payOrder.setPayAmount(fee);
payOrder.setPayTime(paidTime);
payOrder.setTransactionId(transcationId);
payOrder.setcUserPhone(userPhone);
SysConfig config = sysConfigService.getByKey(SysConfigConstant.expired_days, payOrder);
Date curr = new Date();
payOrder.setCreateTime(curr);
payOrder.setUpdateTime(curr);
payOrder.setValidStartTime(curr);
Date endtime = DateUtils.getTimeAfterDays(Integer.parseInt(config.getConfigItemValue()), curr);
payOrder.setValidEndTime(endtime);
wxPayOrderMapper.insert(payOrder);
wxCUserMapper.updateValidTime(cUserId, tenantId, curr, endtime);
}catch(Exception e) {
logger.error("handlePaidSuccess fail.",e);
throw new MallinkException(ErrorCode.SERVER_ERROR.getCode(),"支付失败"+orderId);
throw new MallinkException(ErrorCode.SERVER_ERROR.getCode(),"支付更新失败"+orderId);
}finally {
redisLock.unlock("carPayOrderLock_"+orderId, timeStr);
}


+ 1
- 0
mallinkService/src/main/java/com/iformall/utils/SysConfigConstant.java Wyświetl plik

@@ -4,5 +4,6 @@ public class SysConfigConstant {

public static final String sale_price="salePrice";
public static final String pay_call_back = "payCallBack";
public static final String expired_days = "expiredDays";

}

+ 1
- 1
mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml Wyświetl plik

@@ -109,7 +109,7 @@
</select>

<select id="findByAppId" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT *
SELECT <include refid="allColumns"/>
FROM wx_appinfo
WHERE `app_id` = #{appId}
<if test=" null != tenantId ">


+ 8
- 1
mallinkService/src/main/resources/mapper/WxCUserMapper.xml Wyświetl plik

@@ -10,10 +10,12 @@
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="valid_start_time" jdbcType="TIMESTAMP" property="validStartTime"/>
<result column="valid_end_time" jdbcType="TIMESTAMP" property="validEndTime"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`phone`,`update_date`,`create_date`
`id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`phone`,`update_date`,`create_date`,`valid_start_time`,`valid_end_time`
</sql>

<sql id="dynamicWhereConditions">
@@ -74,5 +76,10 @@
where id = #{id}
and `tenant_id` = #{tenantId}
</select>
<update id="updateValidTime" parameterType="map">
update wx_c_user set valid_start_time = #{validBeginTime},valid_end_time = #{validEndTime},update_date = NOW()
where id = #{id} and tenant_id = #{tenantId}
</update>

</mapper>

+ 3
- 1
mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml Wyświetl plik

@@ -12,11 +12,13 @@
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
<result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
<result column="valid_start_time" jdbcType="TIMESTAMP" property="validStartTime"/>
<result column="valid_end_time" jdbcType="TIMESTAMP" property="validEndTime"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`c_user_id`,`c_user_phone`,`pay_amount`,
`pay_time`,`transaction_id`
`pay_time`,`transaction_id`,`valid_start_time`,`valid_end_time`
</sql>

<sql id="dynamicWhereConditions">


Ładowanie…
Anuluj
Zapisz