Просмотр исходного кода

wx third order

release_toaliyun_real
xhxu 5 лет назад
Родитель
Сommit
21ee051d51
16 измененных файлов: 406 добавлений и 96 удалений
  1. +4
    -1
      mallinkCallback/src/main/java/com/iformall/controller/callback/WxBusinessOrderController.java
  2. +18
    -0
      mallinkPublicApi/src/main/java/com/iformall/controller/BaseController.java
  3. +21
    -1
      mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java
  4. +0
    -66
      mallinkPublicApi/src/main/java/com/iformall/controller/UserBusinessOrderController.java
  5. +229
    -0
      mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java
  6. +1
    -0
      mallinkPublicApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java
  7. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxThirdPartyOrders.java
  8. +38
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumThirdOrderType.java
  9. +5
    -1
      mallinkService/src/main/java/com/iformall/service/WxThirdPartyOrdersService.java
  10. +0
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java
  11. +0
    -10
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  12. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  13. +2
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java
  14. +73
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java
  15. +2
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java
  16. +9
    -3
      mallinkService/src/main/resources/mapper/WxThirdPartyOrdersMapper.xml

+ 4
- 1
mallinkCallback/src/main/java/com/iformall/controller/callback/WxBusinessOrderController.java Просмотреть файл

@@ -147,8 +147,11 @@ public class WxBusinessOrderController extends BaseController {
logger.error("微信商圈通知---时间转换异常"); logger.error("微信商圈通知---时间转换异常");
resultMap.put("code","FAIL"); resultMap.put("code","FAIL");
return resultMap; return resultMap;
} catch (Exception e){
e.printStackTrace();
resultMap.put("code","FAIL");
return resultMap;
} }

} }






+ 18
- 0
mallinkPublicApi/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -1,5 +1,7 @@
package com.iformall.controller; package com.iformall.controller;


import com.iformall.domain.po.base.TenantEntity;
import com.iformall.utils.Constant;
import com.iformall.utils.IPUtil; import com.iformall.utils.IPUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -49,6 +51,22 @@ public class BaseController {
}); });
} }


public String getAppId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String appId = (String) request.getAttribute(Constant.APP_Id);
return appId;
}

public TenantEntity getTenantInfo() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String tenantId = (String) request.getAttribute(Constant.TENANT_ID);
String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID);
TenantEntity tenantEntity = new TenantEntity() ;
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);
return tenantEntity;
}

public String getIpAddr() { public String getIpAddr() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ipaddress = IPUtil.getIpAddr(request); String ipaddress = IPUtil.getIpAddr(request);


+ 21
- 1
mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java Просмотреть файл

@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxLevelConfig;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.service.WxCUserBasicInfoService; import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxLevelConfigService;
import com.iformall.utils.HttpUtil; import com.iformall.utils.HttpUtil;
import com.iformall.utils.sign.SignUtils; import com.iformall.utils.sign.SignUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.*;


import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;


@RestController @RestController
@@ -31,6 +34,9 @@ public class UserBasicInfoController extends BaseController {
@Autowired @Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService; private WxCUserBasicInfoService wxCUserBasicInfoService;


@Autowired
private WxLevelConfigService wxLevelConfigService;

/** /**
* *
* @param * @param
@@ -47,14 +53,28 @@ public class UserBasicInfoController extends BaseController {
if(!phone.matches("^1[0-9]{10}$")){ if(!phone.matches("^1[0-9]{10}$")){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"手机号格式不正确"); return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"手机号格式不正确");
} }
TenantEntity tenantEntity = new TenantEntity();

TenantEntity tenantEntity = getTenantInfo();

WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone); WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone);


List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(tenantEntity);
userBasicInfo.setLecelList(levelList);
userBasicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL);
if(userBasicInfo.getPoins() != null && userBasicInfo.getPoins() > 0){
for (WxLevelConfig levelConfig : levelList) {
if (userBasicInfo.getPoins() >= levelConfig.getPoints()) {
userBasicInfo.setLevel(levelConfig.getLevel());
}
}
}

return new ResultData(userBasicInfo); return new ResultData(userBasicInfo);
} }













+ 0
- 66
mallinkPublicApi/src/main/java/com/iformall/controller/UserBusinessOrderController.java Просмотреть файл

@@ -1,66 +0,0 @@
package com.iformall.controller;

import com.iformall.common.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("api/userBusiness")
@Api(description = "会员交易相关接口")
public class UserBusinessOrderController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());


/**
*
* @param
* @return
*/
@PostMapping("/order")
@ApiOperation(value = "订单", notes = "")
public ResultData createOrder(@RequestBody Map<String,Object> map) {
logger.info("UserBusinessOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString());


return new ResultData();
}

/**
*
* @param
* @return
*/
@PostMapping("/orderRefund")
@ApiOperation(value = "取消订单", notes = "")
public ResultData orderRefund(@RequestBody Map<String,Object> map) {
logger.info("UserBusinessOrderController >>>>>>>>>>>> orderRefund >>>>>>>>>>>>>"+map.toString());


return new ResultData();
}


/**
*
* @param
* @return
*/
@PostMapping("/pointDeduction")
@ApiOperation(value = "积分抵扣", notes = "")
public ResultData pointDeduction(@RequestBody Map<String,Object> map) {
logger.info("UserBusinessOrderController >>>>>>>>>>>> pointDeduction >>>>>>>>>>>>>"+map.toString());


return new ResultData();
}

}

+ 229
- 0
mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java Просмотреть файл

@@ -0,0 +1,229 @@
package com.iformall.controller;

import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxThirdPartyOrders;
import com.iformall.enums.EnumThirdOrderType;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxThirdPartyOrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("api/thirdCircle")
@Api(description = "会员交易相关接口")
public class UserThirdCircleOrderController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


@Autowired
WxThirdPartyOrdersService thirdPartyOrdersService;

/**
*
* @param
* @return
*/
@PostMapping("/order")
@ApiOperation(value = "订单", notes = "")
public ResultData createOrder(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString());

String transactionId = (String) map.get("transactionId");//***订单Id
Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
String shopName = (String) map.get("shopName");//门店名称
Long userNumber = (Long) map.get("userNumber");//***会员Id
String userPhone = (String) map.get("userPhone");//会员手机号
String timeEnd = (String) map.get("timeEnd");//***付款时间(yyyy-MM-dd HH:mm:ss)
Integer amount = (Integer) map.get("amount");//***付款金额(分)
String summary = (String) map.get("summary");//付款摘要

if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(shopNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
}
if(userNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
}
if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
}
if(timeEnd == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
}
Date timeEndDate = null;
try {
timeEndDate = sdf.parse(timeEnd);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}
if(amount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
}

WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());

thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
thirdPartyOrders.setShopName(shopName);
thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
thirdPartyOrders.setUserPhone(userPhone);
thirdPartyOrders.setTimeEnd(timeEndDate);
thirdPartyOrders.setAmount(amount);
thirdPartyOrders.setSummary(summary);
try{
thirdPartyOrdersService.createOrder(thirdPartyOrders);
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}

return new ResultData();
}

/**
*
* @param
* @return
*/
@PostMapping("/orderRefund")
@ApiOperation(value = "退款", notes = "")
public ResultData orderRefund(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> orderRefund >>>>>>>>>>>>>"+map.toString());

String transactionId = (String) map.get("transactionId");//***订单Id
String refundTime = (String) map.get("refundTime");//***退款时间(yyyy-MM-dd HH:mm:ss)
String refundSummary = (String) map.get("refundSummary");//退款摘要
Integer refundAmount = (Integer) map.get("refundAmount");//退款金额(分)
String refundId = (String) map.get("refundId");//退款Id

if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(refundTime == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"refundTime为空");
}
Date refundTimeDate = null;
try {
refundTimeDate = sdf.parse(refundTime);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}

WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());
thirdPartyOrders.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());

thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setRefundTime(refundTimeDate);
thirdPartyOrders.setRefundSummary(refundSummary);
thirdPartyOrders.setRefundAmount(refundAmount);
thirdPartyOrders.setRefundId(refundId);

try{
thirdPartyOrdersService.updateRefundOrder(thirdPartyOrders);
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}

return new ResultData();
}


/**
*
* @param
* @return
*/
@PostMapping("/pointDeduction")
@ApiOperation(value = "积分抵扣", notes = "")
public ResultData pointDeduction(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> pointDeduction >>>>>>>>>>>>>"+map.toString());

String transactionId = (String) map.get("transactionId");//***订单Id
Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
String shopName = (String) map.get("shopName");//门店名称
Long userNumber = (Long) map.get("userNumber");//***会员Id
String userPhone = (String) map.get("userPhone");//会员手机号
String timeEnd = (String) map.get("timeEnd");//***抵扣时间
Integer amount = (Integer) map.get("amount");//***积分数量
String summary = (String) map.get("summary");//付款摘要

if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(shopNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
}
if(userNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
}
if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
}
if(timeEnd == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
}
Date timeEndDate = null;
try {
timeEndDate = sdf.parse(timeEnd);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}
if(amount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
}

WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());

thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
thirdPartyOrders.setShopName(shopName);
thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
thirdPartyOrders.setUserPhone(userPhone);
thirdPartyOrders.setTimeEnd(timeEndDate);
thirdPartyOrders.setAmount(amount);
thirdPartyOrders.setSummary(summary);
try{
thirdPartyOrdersService.pointDeduction(thirdPartyOrders);
return new ResultData();
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

}

+ 1
- 0
mallinkPublicApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java Просмотреть файл

@@ -56,6 +56,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
if(apiConfig == null){ if(apiConfig == null){
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求"); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求");
} }
request.setAttribute(Constant.APP_Id, apiConfig.getAppId());
request.setAttribute(Constant.TENANT_ID, apiConfig.getTenantId()); request.setAttribute(Constant.TENANT_ID, apiConfig.getTenantId());
request.setAttribute(Constant.PARENT_TENANT_ID, apiConfig.getParentTenantId()); request.setAttribute(Constant.PARENT_TENANT_ID, apiConfig.getParentTenantId());




+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxThirdPartyOrders.java Просмотреть файл

@@ -21,6 +21,9 @@ public class WxThirdPartyOrders extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId") @io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId")
private String sourceAppId; private String sourceAppId;


@io.swagger.annotations.ApiModelProperty(value="1:RMB订单;2:积分订单",name="sourceType")
private Integer sourceType;

@io.swagger.annotations.ApiModelProperty(value="门店名称",name="shopName") @io.swagger.annotations.ApiModelProperty(value="门店名称",name="shopName")
private String shopName; private String shopName;




+ 38
- 0
mallinkService/src/main/java/com/iformall/enums/EnumThirdOrderType.java Просмотреть файл

@@ -0,0 +1,38 @@
package com.iformall.enums;


/**
* @author gongbiao
*/

public enum EnumThirdOrderType {

RMB_PAY(1,"rmb订单"),
CREDIT_PAY(2,"积分订单")
;

public static EnumThirdOrderType getEnum(Integer code) {
for (EnumThirdOrderType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumThirdOrderType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 5
- 1
mallinkService/src/main/java/com/iformall/service/WxThirdPartyOrdersService.java Просмотреть файл

@@ -46,5 +46,9 @@ public interface WxThirdPartyOrdersService {
*/ */
void updateRefundPoints(WxThirdPartyOrders record); void updateRefundPoints(WxThirdPartyOrders record);



/**
* 积分抵扣
* @param record
*/
void pointDeduction(WxThirdPartyOrders record);
} }

+ 0
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java Просмотреть файл

@@ -90,7 +90,6 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
wxBusinessCircleOrderMapper.insertNoticeOrder(record); wxBusinessCircleOrderMapper.insertNoticeOrder(record);


this.sendMessage(record,EnumYesOrNo.NO.getCode()); this.sendMessage(record,EnumYesOrNo.NO.getCode());

} }
} }




+ 0
- 10
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -650,16 +650,6 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc
basicInfo.setPhone(phone); basicInfo.setPhone(phone);
this.save(basicInfo); this.save(basicInfo);
} }
List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(tenantEntity);
basicInfo.setLecelList(levelList);
basicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL);
if(basicInfo.getPoins() != null && basicInfo.getPoins() > 0){
for (WxLevelConfig levelConfig : levelList) {
if (basicInfo.getPoins() >= levelConfig.getPoints()) {
basicInfo.setLevel(levelConfig.getLevel());
}
}
}


return basicInfo; return basicInfo;




+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java Просмотреть файл

@@ -248,7 +248,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
} }
if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) {
logger.info(ErrorCode.MEMBER_IS_LOCKED.getMessage()); logger.info(ErrorCode.MEMBER_IS_LOCKED.getMessage());
return record;
throw new MallinkException(ErrorCode.MEMBER_IS_LOCKED);
} }
if (StringUtils.isNotEmpty(record.getSpendStr())) { if (StringUtils.isNotEmpty(record.getSpendStr())) {
record.setSpend(new BigDecimal(record.getSpendStr()).multiply(new BigDecimal(100)).intValue()); record.setSpend(new BigDecimal(record.getSpendStr()).multiply(new BigDecimal(100)).intValue());


+ 2
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java Просмотреть файл

@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import static org.springframework.transaction.annotation.Propagation.REQUIRED;
import static org.springframework.transaction.annotation.Propagation.REQUIRES_NEW; import static org.springframework.transaction.annotation.Propagation.REQUIRES_NEW;


@Service @Service
@@ -507,7 +508,7 @@ public class WxGameServiceImpl implements WxGameService {


} }


@Transactional(propagation = REQUIRES_NEW ,rollbackFor = Exception.class)
@Transactional(propagation = REQUIRED ,rollbackFor = Exception.class)
@Override @Override
public ResultData cridetLuckDraw(Long gameId, Long userId) { public ResultData cridetLuckDraw(Long gameId, Long userId) {
WxGame wxGame = wxGameMapper.selectById(gameId); WxGame wxGame = wxGameMapper.selectById(gameId);


+ 73
- 11
mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java Просмотреть файл

@@ -2,25 +2,29 @@ package com.iformall.service.impl;


import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker; import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxThirdPartyOrders; import com.iformall.domain.po.WxThirdPartyOrders;
import com.iformall.domain.po.msg.FmInsideCircleOrderMsg; import com.iformall.domain.po.msg.FmInsideCircleOrderMsg;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxThirdPartyOrdersMapper; import com.iformall.mapper.WxThirdPartyOrdersMapper;
import com.iformall.mq.MqBaseProducer; import com.iformall.mq.MqBaseProducer;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCUserService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxThirdPartyOrdersService;
import com.iformall.service.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


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


import static org.springframework.transaction.annotation.Propagation.REQUIRED;

@Service @Service
public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService { public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -40,6 +44,9 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService
@Autowired @Autowired
MqBaseProducer mqBaseProducer; MqBaseProducer mqBaseProducer;


@Autowired
WxCreditHistoryService wxCreditHistoryService;



@Override @Override
public PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize) { public PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize) {
@@ -67,6 +74,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService
WxThirdPartyOrders byTransactionId = wxThirdPartyOrdersMapper.getByTransactionId(record); WxThirdPartyOrders byTransactionId = wxThirdPartyOrdersMapper.getByTransactionId(record);
if(byTransactionId != null){ if(byTransactionId != null){
logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId()); logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
}else{ }else{
Date now = new Date(); Date now = new Date();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
@@ -74,21 +82,21 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService
record.setCreateTime(now); record.setCreateTime(now);
record.setUpdateTime(now); record.setUpdateTime(now);


record.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());

//TODO 第三方获取门店(标识可能发生变化) //TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber())); WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
if(wxMerchant != null){ if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId()); record.setMerchantId(wxMerchant.getId());
}else{ }else{
logger.error("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
} }


WxCUserBasicInfo basicInfo = null; WxCUserBasicInfo basicInfo = null;
try{
basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
if(basicInfo == null){
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone());
}
}catch(Exception e){}
basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
if(basicInfo == null){
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone());
}


if(basicInfo != null){ if(basicInfo != null){
record.setCUserId(basicInfo.getId()); record.setCUserId(basicInfo.getId());
@@ -126,8 +134,10 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService
WxThirdPartyOrders byTransactionId = this.getByTransactionId(record.getTransactionId(),record.getTenantId()); WxThirdPartyOrders byTransactionId = this.getByTransactionId(record.getTransactionId(),record.getTenantId());
if(byTransactionId == null){ if(byTransactionId == null){
logger.error("--第三方退款--付款消息未找到--transactionId="+record.getTransactionId()); logger.error("--第三方退款--付款消息未找到--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到");
}else if(byTransactionId.getIsRefund().equals(EnumYesOrNo.YES.getCode())){ }else if(byTransactionId.getIsRefund().equals(EnumYesOrNo.YES.getCode())){
logger.error("--第三方退款--已是退款状态--transactionId="+record.getTransactionId()); logger.error("--第三方退款--已是退款状态--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已是退款状态");
}else{ }else{
Date now = new Date(); Date now = new Date();
record.setId(byTransactionId.getId()); record.setId(byTransactionId.getId());
@@ -150,5 +160,57 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService
wxThirdPartyOrdersMapper.updateRefundPoints(record); wxThirdPartyOrdersMapper.updateRefundPoints(record);
} }


@Transactional(propagation = REQUIRED ,rollbackFor = Exception.class)
@Override
public void pointDeduction(WxThirdPartyOrders record) {

WxCUserBasicInfo basicInfo = null;
if(StringUtils.isNotBlank(record.getUserNumber())){
basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
}
if(basicInfo == null){
logger.error("--第三方积分订单--未找到用户---userId="+record.getUserNumber());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到用户");
}

record.setCUserId(basicInfo.getId());

WxThirdPartyOrders byTransactionId = wxThirdPartyOrdersMapper.getByTransactionId(record);
if(byTransactionId != null){
logger.error("--第三方积分订单--数据已存在---byTransactionId="+byTransactionId.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
}else{
Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

record.setSourceType(EnumThirdOrderType.CREDIT_PAY.getCode());

//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId());
}else{
logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
}

WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setTenantId(record.getFinalTenantId());
wxCreditHistory.setCUserId(basicInfo.getId());
wxCreditHistory.setOperatorId(basicInfo.getId());
wxCreditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
wxCreditHistory.setCreditNum(record.getAmount());
wxCreditHistory.setCreditType(EnumScoreType.CHANGE_CREDIT.getCode());
wxCreditHistory.setChangePurpose("第三方消费抵扣{}"+record.getSummary());
wxCreditHistory.setCouponId(record.getId());
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,record.getTenantId());

wxThirdPartyOrdersMapper.insertNoticeOrder(record);
}

}



} }

+ 2
- 0
mallinkService/src/main/java/com/iformall/utils/Constant.java Просмотреть файл

@@ -50,6 +50,8 @@ public class Constant {
public static final String TENANT_ID = "TENANT_ID"; public static final String TENANT_ID = "TENANT_ID";
public static final String PARENT_TENANT_ID = "PARENT_TENANT_ID"; public static final String PARENT_TENANT_ID = "PARENT_TENANT_ID";
public static final String REQUEST_C_USER_KEY = "REQUEST_C_USER"; public static final String REQUEST_C_USER_KEY = "REQUEST_C_USER";

public static final String APP_Id = "APP_Id";
public static final String LOGIN_B_USER_KEY = "LOGIN_B_USER_KEY"; public static final String LOGIN_B_USER_KEY = "LOGIN_B_USER_KEY";




+ 9
- 3
mallinkService/src/main/resources/mapper/WxThirdPartyOrdersMapper.xml Просмотреть файл

@@ -6,6 +6,8 @@
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/> <result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>

<result column="shop_name" jdbcType="VARCHAR" property="shopName" /> <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber" /> <result column="shop_number" jdbcType="VARCHAR" property="shopNumber" />
<result column="user_phone" jdbcType="VARCHAR" property="userPhone" /> <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
@@ -37,7 +39,7 @@




<sql id="allColumns"> <sql id="allColumns">
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `shop_name`, `shop_number`,
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`, `shop_name`, `shop_number`,
`user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`, `user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`,
`create_time`, `update_time`, `merchant_id`, `c_user_id`, `create_time`, `update_time`, `merchant_id`, `c_user_id`,
`earn_points`, `increased_points`, `points_update_time`, `earn_points`, `increased_points`, `points_update_time`,
@@ -63,6 +65,10 @@
and `source_app_id` = #{sourceAppId} and `source_app_id` = #{sourceAppId}
</if> </if>


<if test=" null != sourceType and '' != sourceType">
and `source_type` = #{sourceType}
</if>

<if test=" null != shopName "> <if test=" null != shopName ">
and `shop_name` like concat('%', #{shopName},'%') and `shop_name` like concat('%', #{shopName},'%')
</if> </if>
@@ -148,12 +154,12 @@


<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" > <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO wx_business_circle_order ( INSERT INTO wx_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`,`shop_name`, `shop_number`,
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`,`source_type`,`shop_name`, `shop_number`,
`user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`, `user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`,
`create_time`, `update_time`, `merchant_id`, `c_user_id`, `earn_points`, `is_refund` `create_time`, `update_time`, `merchant_id`, `c_user_id`, `earn_points`, `is_refund`
) )
VALUES( VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{shopName},#{shopNumber},
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{shopName},#{shopNumber},
#{userPhone},#{userNumber},#{timeEnd},#{amount},#{transactionId},#{summary}, #{userPhone},#{userNumber},#{timeEnd},#{amount},#{transactionId},#{summary},
#{createTime},#{updateTime}, #{merchantId},#{cUserId},0,0 #{createTime},#{updateTime}, #{merchantId},#{cUserId},0,0
); );


Загрузка…
Отмена
Сохранить